@firecms/core 3.0.0-canary.287 → 3.0.0-canary.289

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.
package/dist/index.umd.js CHANGED
@@ -253,6 +253,13 @@
253
253
  function isObject(item) {
254
254
  return item && typeof item === "object" && !Array.isArray(item);
255
255
  }
256
+ function isPlainObject(obj) {
257
+ if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
258
+ return false;
259
+ }
260
+ const proto = Object.getPrototypeOf(obj);
261
+ return proto === Object.prototype;
262
+ }
256
263
  function mergeDeep(target, source, ignoreUndefined = false) {
257
264
  if (!isObject(target)) {
258
265
  return target;
@@ -273,7 +280,28 @@
273
280
  if (sourceValue instanceof Date) {
274
281
  output[key] = new Date(sourceValue.getTime());
275
282
  } else if (Array.isArray(sourceValue)) {
276
- output[key] = [...sourceValue];
283
+ if (Array.isArray(outputValue)) {
284
+ const newArray = [];
285
+ const maxLength = Math.max(outputValue.length, sourceValue.length);
286
+ for (let i = 0; i < maxLength; i++) {
287
+ const sourceItem = sourceValue[i];
288
+ const targetItem = outputValue[i];
289
+ if (i >= sourceValue.length) {
290
+ newArray[i] = targetItem;
291
+ } else if (i >= outputValue.length) {
292
+ newArray[i] = sourceItem;
293
+ } else if (sourceItem === null) {
294
+ newArray[i] = targetItem;
295
+ } else if (isObject(sourceItem) && isObject(targetItem)) {
296
+ newArray[i] = mergeDeep(targetItem, sourceItem, ignoreUndefined);
297
+ } else {
298
+ newArray[i] = sourceItem;
299
+ }
300
+ }
301
+ output[key] = newArray;
302
+ } else {
303
+ output[key] = [...sourceValue];
304
+ }
277
305
  } else if (isObject(sourceValue)) {
278
306
  if (isObject(outputValue)) {
279
307
  output[key] = mergeDeep(outputValue, sourceValue, ignoreUndefined);
@@ -6642,7 +6670,7 @@
6642
6670
  const isArrayOrMap = childProperty.dataType === "map" || childProperty === "array";
6643
6671
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls(ui.defaultBorderMixin, "last:border-b-0 border-b"), children: [
6644
6672
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row pt-0.5 pb-0.5 gap-2", children: [
6645
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-[140px] w-[25%] py-1", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", className: "font-mono break-words", color: "secondary", children: childProperty.name }) }),
6673
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-[140px] w-[25%] py-1", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", className: "break-words font-semibold", color: "secondary", children: childProperty.name }) }),
6646
6674
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow max-w-[75%]", children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: !isArrayOrMap && /* @__PURE__ */ jsxRuntime.jsx(PropertyPreview, { propertyKey: key_0, value: value[key_0], property: childProperty, size }) }) })
6647
6675
  ] }),
6648
6676
  isArrayOrMap && /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.defaultBorderMixin, "border-l pl-4 ml-2 my-2"), children: /* @__PURE__ */ jsxRuntime.jsx(PropertyPreview, { propertyKey: key_0, value: value[key_0], property: childProperty, size }) })
@@ -6698,7 +6726,7 @@
6698
6726
  const [key, childValue] = t0;
6699
6727
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls(ui.defaultBorderMixin, "last:border-b-0 border-b"), children: [
6700
6728
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-row pt-0.5 pb-0.5 gap-2", children: [
6701
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-[140px] w-[25%] py-1", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", className: "font-mono break-words", color: "secondary", children: key }) }, `table-cell-title-${key}-${key}`),
6729
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "min-w-[140px] w-[25%] py-1", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", className: "font-semibold break-words", color: "secondary", children: key }) }, `table-cell-title-${key}-${key}`),
6702
6730
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow max-w-[75%]", children: childValue && typeof childValue !== "object" && /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: childValue.toString() }) }) })
6703
6731
  ] }),
6704
6732
  typeof childValue === "object" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.defaultBorderMixin, "border-l pl-4"), children: /* @__PURE__ */ jsxRuntime.jsx(KeyValuePreview, { value: childValue }) })
@@ -6775,7 +6803,7 @@
6775
6803
  return t3;
6776
6804
  }
6777
6805
  function NumberPropertyPreview(t0) {
6778
- const $ = reactCompilerRuntime.c(10);
6806
+ const $ = reactCompilerRuntime.c(12);
6779
6807
  const {
6780
6808
  value,
6781
6809
  property,
@@ -6793,38 +6821,42 @@
6793
6821
  }
6794
6822
  const enumValues = t1;
6795
6823
  if (!enumValues) {
6796
- let t22;
6797
- if ($[2] !== value) {
6798
- t22 = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: value });
6799
- $[2] = value;
6800
- $[3] = t22;
6824
+ const t22 = size === "small" ? "text-sm" : "";
6825
+ let t32;
6826
+ if ($[2] !== t22 || $[3] !== value) {
6827
+ t32 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t22, children: value });
6828
+ $[2] = t22;
6829
+ $[3] = value;
6830
+ $[4] = t32;
6801
6831
  } else {
6802
- t22 = $[3];
6832
+ t32 = $[4];
6803
6833
  }
6804
- return t22;
6834
+ return t32;
6805
6835
  }
6806
6836
  const t2 = size !== "medium" ? "small" : "medium";
6807
6837
  let t3;
6808
- if ($[4] !== enumKey || $[5] !== enumValues || $[6] !== t2) {
6838
+ if ($[5] !== enumKey || $[6] !== enumValues || $[7] !== t2) {
6809
6839
  t3 = /* @__PURE__ */ jsxRuntime.jsx(EnumValuesChip, { enumKey, enumValues, size: t2 });
6810
- $[4] = enumKey;
6811
- $[5] = enumValues;
6812
- $[6] = t2;
6813
- $[7] = t3;
6840
+ $[5] = enumKey;
6841
+ $[6] = enumValues;
6842
+ $[7] = t2;
6843
+ $[8] = t3;
6814
6844
  } else {
6815
- t3 = $[7];
6845
+ t3 = $[8];
6816
6846
  }
6817
6847
  return t3;
6818
6848
  } else {
6819
- let t1;
6820
- if ($[8] !== value) {
6821
- t1 = /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: value });
6822
- $[8] = value;
6849
+ const t1 = size === "small" ? "text-sm" : "";
6850
+ let t2;
6851
+ if ($[9] !== t1 || $[10] !== value) {
6852
+ t2 = /* @__PURE__ */ jsxRuntime.jsx("span", { className: t1, children: value });
6823
6853
  $[9] = t1;
6854
+ $[10] = value;
6855
+ $[11] = t2;
6824
6856
  } else {
6825
- t1 = $[9];
6857
+ t2 = $[11];
6826
6858
  }
6827
- return t1;
6859
+ return t2;
6828
6860
  }
6829
6861
  }
6830
6862
  function UserDisplay(t0) {
@@ -7373,6 +7405,389 @@
7373
7405
  }
7374
7406
  return t3;
7375
7407
  });
7408
+ function buildPropertyLabelAndGetProperty(properties, key) {
7409
+ if (!key) return {
7410
+ label: "",
7411
+ property: void 0
7412
+ };
7413
+ const segments = [];
7414
+ const re = /([^[.\]]+)|\[(\d+)\]/g;
7415
+ let m;
7416
+ while ((m = re.exec(key)) !== null) {
7417
+ if (m[1] !== void 0) segments.push(m[1]);
7418
+ else if (m[2] !== void 0) segments.push(Number(m[2]));
7419
+ }
7420
+ let currentProps = properties;
7421
+ let currentProp;
7422
+ let lastLabel = "";
7423
+ const getArrayOfProp = (p) => {
7424
+ if (!p || p.dataType !== "array") return void 0;
7425
+ return Array.isArray(p.of) ? p.of[0] : p.of;
7426
+ };
7427
+ for (const seg of segments) {
7428
+ if (typeof seg === "number") {
7429
+ lastLabel = `[${seg}]`;
7430
+ if (currentProp?.dataType === "array") {
7431
+ currentProp = getArrayOfProp(currentProp);
7432
+ if (currentProp?.dataType === "map" && currentProp.properties) {
7433
+ currentProps = currentProp.properties;
7434
+ } else {
7435
+ currentProps = void 0;
7436
+ }
7437
+ } else {
7438
+ currentProp = void 0;
7439
+ currentProps = void 0;
7440
+ }
7441
+ continue;
7442
+ }
7443
+ if (currentProps && currentProps[seg]) {
7444
+ const nextProp = currentProps[seg];
7445
+ currentProp = nextProp;
7446
+ lastLabel = nextProp.name || String(seg);
7447
+ if (nextProp.dataType === "map" && nextProp.properties) {
7448
+ currentProps = nextProp.properties;
7449
+ } else if (nextProp.dataType === "array") {
7450
+ currentProps = void 0;
7451
+ } else {
7452
+ currentProps = void 0;
7453
+ }
7454
+ } else {
7455
+ currentProp = void 0;
7456
+ currentProps = void 0;
7457
+ lastLabel = String(seg);
7458
+ }
7459
+ }
7460
+ return {
7461
+ label: lastLabel,
7462
+ property: currentProp
7463
+ };
7464
+ }
7465
+ const pathEndsWithIndex = (p) => /\[\d+\]$/.test(p);
7466
+ const PropertyCollectionView = (t0) => {
7467
+ const $ = reactCompilerRuntime.c(89);
7468
+ const {
7469
+ data,
7470
+ properties,
7471
+ baseKey: t1,
7472
+ suppressHeader: t2,
7473
+ size: t3
7474
+ } = t0;
7475
+ const baseKey = t1 === void 0 ? "" : t1;
7476
+ const suppressHeader = t2 === void 0 ? false : t2;
7477
+ const size = t3 === void 0 ? "small" : t3;
7478
+ const isTopLevel = !!baseKey && !baseKey.includes(".") && !baseKey.includes("[");
7479
+ if (Array.isArray(data)) {
7480
+ let t4;
7481
+ if ($[0] !== baseKey || $[1] !== properties) {
7482
+ t4 = baseKey ? buildPropertyLabelAndGetProperty(properties, baseKey) : {
7483
+ label: "",
7484
+ property: void 0
7485
+ };
7486
+ $[0] = baseKey;
7487
+ $[1] = properties;
7488
+ $[2] = t4;
7489
+ } else {
7490
+ t4 = $[2];
7491
+ }
7492
+ const {
7493
+ label: arrayLabel,
7494
+ property
7495
+ } = t4;
7496
+ const ofProp = property?.dataType === "array" ? Array.isArray(property.of) ? property.of[0] : property.of : void 0;
7497
+ const isArrayOfMaps = ofProp?.dataType === "map";
7498
+ const isArrayOfPrimitives = property?.dataType === "array" && ofProp && ofProp.dataType !== "map";
7499
+ if (baseKey && property && isArrayOfPrimitives) {
7500
+ const t52 = `grid grid-cols-12 gap-x-4 ${isTopLevel ? "py-4" : "py-2"} items-start ${isTopLevel ? `border-b ${ui.defaultBorderMixin}` : ""}`;
7501
+ let t62;
7502
+ if ($[3] !== arrayLabel) {
7503
+ t62 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-4 pr-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", component: "span", className: "break-words", children: arrayLabel }) });
7504
+ $[3] = arrayLabel;
7505
+ $[4] = t62;
7506
+ } else {
7507
+ t62 = $[4];
7508
+ }
7509
+ let t72;
7510
+ if ($[5] !== baseKey || $[6] !== data || $[7] !== property || $[8] !== size) {
7511
+ t72 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-8", children: /* @__PURE__ */ jsxRuntime.jsx(PropertyPreview, { propertyKey: baseKey, value: data, property, size }) });
7512
+ $[5] = baseKey;
7513
+ $[6] = data;
7514
+ $[7] = property;
7515
+ $[8] = size;
7516
+ $[9] = t72;
7517
+ } else {
7518
+ t72 = $[9];
7519
+ }
7520
+ let t82;
7521
+ if ($[10] !== t52 || $[11] !== t62 || $[12] !== t72) {
7522
+ t82 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t52, children: [
7523
+ t62,
7524
+ t72
7525
+ ] });
7526
+ $[10] = t52;
7527
+ $[11] = t62;
7528
+ $[12] = t72;
7529
+ $[13] = t82;
7530
+ } else {
7531
+ t82 = $[13];
7532
+ }
7533
+ return t82;
7534
+ }
7535
+ const t5 = `${isTopLevel ? "py-4" : "py-1"} ${isTopLevel ? `border-b ${ui.defaultBorderMixin}` : ""}`;
7536
+ let t6;
7537
+ if ($[14] !== arrayLabel || $[15] !== baseKey || $[16] !== suppressHeader) {
7538
+ t6 = baseKey && arrayLabel && !suppressHeader && /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", component: "span", children: arrayLabel });
7539
+ $[14] = arrayLabel;
7540
+ $[15] = baseKey;
7541
+ $[16] = suppressHeader;
7542
+ $[17] = t6;
7543
+ } else {
7544
+ t6 = $[17];
7545
+ }
7546
+ const t7 = baseKey ? `pl-4 mt-1 border-l ${ui.defaultBorderMixin}` : "";
7547
+ let t8;
7548
+ if ($[18] !== baseKey || $[19] !== data || $[20] !== isArrayOfMaps || $[21] !== ofProp || $[22] !== properties || $[23] !== size) {
7549
+ let t92;
7550
+ if ($[25] !== baseKey || $[26] !== isArrayOfMaps || $[27] !== ofProp || $[28] !== properties || $[29] !== size) {
7551
+ t92 = (item, index) => {
7552
+ if (item === null || item === void 0) {
7553
+ return null;
7554
+ }
7555
+ const currentKey = baseKey ? `${baseKey}[${index}]` : `[${index}]`;
7556
+ const itemHeader = isArrayOfMaps && ofProp?.name ? `${ofProp.name} [${index}]` : `[${index}]`;
7557
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "py-1", children: [
7558
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", component: "span", children: itemHeader }),
7559
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `pl-4 mt-1 border-l ${ui.defaultBorderMixin}`, children: /* @__PURE__ */ jsxRuntime.jsx(PropertyCollectionView, { data: item, properties, baseKey: currentKey, suppressHeader: true, size }) })
7560
+ ] }, currentKey);
7561
+ };
7562
+ $[25] = baseKey;
7563
+ $[26] = isArrayOfMaps;
7564
+ $[27] = ofProp;
7565
+ $[28] = properties;
7566
+ $[29] = size;
7567
+ $[30] = t92;
7568
+ } else {
7569
+ t92 = $[30];
7570
+ }
7571
+ t8 = data.map(t92);
7572
+ $[18] = baseKey;
7573
+ $[19] = data;
7574
+ $[20] = isArrayOfMaps;
7575
+ $[21] = ofProp;
7576
+ $[22] = properties;
7577
+ $[23] = size;
7578
+ $[24] = t8;
7579
+ } else {
7580
+ t8 = $[24];
7581
+ }
7582
+ let t9;
7583
+ if ($[31] !== t7 || $[32] !== t8) {
7584
+ t9 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: t7, children: t8 });
7585
+ $[31] = t7;
7586
+ $[32] = t8;
7587
+ $[33] = t9;
7588
+ } else {
7589
+ t9 = $[33];
7590
+ }
7591
+ let t10;
7592
+ if ($[34] !== t5 || $[35] !== t6 || $[36] !== t9) {
7593
+ t10 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t5, children: [
7594
+ t6,
7595
+ t9
7596
+ ] });
7597
+ $[34] = t5;
7598
+ $[35] = t6;
7599
+ $[36] = t9;
7600
+ $[37] = t10;
7601
+ } else {
7602
+ t10 = $[37];
7603
+ }
7604
+ return t10;
7605
+ }
7606
+ if (typeof data === "object" && data !== null) {
7607
+ let t4;
7608
+ if ($[38] !== baseKey || $[39] !== properties) {
7609
+ t4 = baseKey ? buildPropertyLabelAndGetProperty(properties, baseKey) : {
7610
+ label: "",
7611
+ property: void 0
7612
+ };
7613
+ $[38] = baseKey;
7614
+ $[39] = properties;
7615
+ $[40] = t4;
7616
+ } else {
7617
+ t4 = $[40];
7618
+ }
7619
+ const {
7620
+ label,
7621
+ property: property_0
7622
+ } = t4;
7623
+ if (baseKey && (!property_0 || property_0.dataType !== "map" || !property_0.properties)) {
7624
+ if (!property_0) {
7625
+ return null;
7626
+ }
7627
+ const t52 = `grid grid-cols-12 gap-x-4 ${isTopLevel ? "py-4" : "py-2"} items-start ${isTopLevel ? `border-b ${ui.defaultBorderMixin}` : ""}`;
7628
+ let t62;
7629
+ if ($[41] !== label) {
7630
+ t62 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-4 pr-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", component: "span", className: "break-words", children: label }) });
7631
+ $[41] = label;
7632
+ $[42] = t62;
7633
+ } else {
7634
+ t62 = $[42];
7635
+ }
7636
+ let t72;
7637
+ if ($[43] !== baseKey || $[44] !== data || $[45] !== property_0 || $[46] !== size) {
7638
+ t72 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-8", children: /* @__PURE__ */ jsxRuntime.jsx(PropertyPreview, { propertyKey: baseKey, value: data, property: property_0, size }) });
7639
+ $[43] = baseKey;
7640
+ $[44] = data;
7641
+ $[45] = property_0;
7642
+ $[46] = size;
7643
+ $[47] = t72;
7644
+ } else {
7645
+ t72 = $[47];
7646
+ }
7647
+ let t82;
7648
+ if ($[48] !== t52 || $[49] !== t62 || $[50] !== t72) {
7649
+ t82 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t52, children: [
7650
+ t62,
7651
+ t72
7652
+ ] });
7653
+ $[48] = t52;
7654
+ $[49] = t62;
7655
+ $[50] = t72;
7656
+ $[51] = t82;
7657
+ } else {
7658
+ t82 = $[51];
7659
+ }
7660
+ return t82;
7661
+ }
7662
+ let t5;
7663
+ if ($[52] !== baseKey || $[53] !== property_0 || $[54] !== suppressHeader) {
7664
+ t5 = baseKey && !suppressHeader && property_0?.dataType === "map" && (property_0.name || !pathEndsWithIndex(baseKey));
7665
+ $[52] = baseKey;
7666
+ $[53] = property_0;
7667
+ $[54] = suppressHeader;
7668
+ $[55] = t5;
7669
+ } else {
7670
+ t5 = $[55];
7671
+ }
7672
+ const showMapHeader = t5;
7673
+ const headerText = property_0?.name || label;
7674
+ const t6 = `${isTopLevel ? "py-4" : "py-1"} ${isTopLevel ? `border-b ${ui.defaultBorderMixin}` : ""}`;
7675
+ let t7;
7676
+ if ($[56] !== headerText || $[57] !== showMapHeader) {
7677
+ t7 = showMapHeader && /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", component: "span", children: headerText });
7678
+ $[56] = headerText;
7679
+ $[57] = showMapHeader;
7680
+ $[58] = t7;
7681
+ } else {
7682
+ t7 = $[58];
7683
+ }
7684
+ const t8 = baseKey ? `pl-4 mt-1 border-l ${ui.defaultBorderMixin}` : "";
7685
+ let t9;
7686
+ if ($[59] !== baseKey || $[60] !== data || $[61] !== properties || $[62] !== size) {
7687
+ let t102;
7688
+ if ($[64] !== baseKey || $[65] !== properties || $[66] !== size) {
7689
+ t102 = (t112) => {
7690
+ const [key, value] = t112;
7691
+ if (value === null || value === void 0) {
7692
+ return null;
7693
+ }
7694
+ const currentKey_0 = baseKey ? `${baseKey}.${key}` : key;
7695
+ return /* @__PURE__ */ jsxRuntime.jsx(PropertyCollectionView, { data: value, properties, baseKey: currentKey_0, size }, currentKey_0);
7696
+ };
7697
+ $[64] = baseKey;
7698
+ $[65] = properties;
7699
+ $[66] = size;
7700
+ $[67] = t102;
7701
+ } else {
7702
+ t102 = $[67];
7703
+ }
7704
+ t9 = Object.entries(data).map(t102);
7705
+ $[59] = baseKey;
7706
+ $[60] = data;
7707
+ $[61] = properties;
7708
+ $[62] = size;
7709
+ $[63] = t9;
7710
+ } else {
7711
+ t9 = $[63];
7712
+ }
7713
+ let t10;
7714
+ if ($[68] !== t8 || $[69] !== t9) {
7715
+ t10 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: t8, children: t9 });
7716
+ $[68] = t8;
7717
+ $[69] = t9;
7718
+ $[70] = t10;
7719
+ } else {
7720
+ t10 = $[70];
7721
+ }
7722
+ let t11;
7723
+ if ($[71] !== t10 || $[72] !== t6 || $[73] !== t7) {
7724
+ t11 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t6, children: [
7725
+ t7,
7726
+ t10
7727
+ ] });
7728
+ $[71] = t10;
7729
+ $[72] = t6;
7730
+ $[73] = t7;
7731
+ $[74] = t11;
7732
+ } else {
7733
+ t11 = $[74];
7734
+ }
7735
+ return t11;
7736
+ }
7737
+ if (baseKey) {
7738
+ let t4;
7739
+ if ($[75] !== baseKey || $[76] !== properties) {
7740
+ t4 = buildPropertyLabelAndGetProperty(properties, baseKey);
7741
+ $[75] = baseKey;
7742
+ $[76] = properties;
7743
+ $[77] = t4;
7744
+ } else {
7745
+ t4 = $[77];
7746
+ }
7747
+ const {
7748
+ label: label_0,
7749
+ property: property_1
7750
+ } = t4;
7751
+ if (!property_1) {
7752
+ return null;
7753
+ }
7754
+ const t5 = `grid grid-cols-12 gap-x-4 ${isTopLevel ? "py-4" : "py-2"} items-start ${isTopLevel ? `border-b ${ui.defaultBorderMixin}` : ""}`;
7755
+ let t6;
7756
+ if ($[78] !== label_0) {
7757
+ t6 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-4 pr-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", component: "span", className: "break-words", children: label_0 }) });
7758
+ $[78] = label_0;
7759
+ $[79] = t6;
7760
+ } else {
7761
+ t6 = $[79];
7762
+ }
7763
+ let t7;
7764
+ if ($[80] !== baseKey || $[81] !== data || $[82] !== property_1 || $[83] !== size) {
7765
+ t7 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-8", children: /* @__PURE__ */ jsxRuntime.jsx(PropertyPreview, { propertyKey: baseKey, value: data, property: property_1, size }) });
7766
+ $[80] = baseKey;
7767
+ $[81] = data;
7768
+ $[82] = property_1;
7769
+ $[83] = size;
7770
+ $[84] = t7;
7771
+ } else {
7772
+ t7 = $[84];
7773
+ }
7774
+ let t8;
7775
+ if ($[85] !== t5 || $[86] !== t6 || $[87] !== t7) {
7776
+ t8 = /* @__PURE__ */ jsxRuntime.jsxs("div", { className: t5, children: [
7777
+ t6,
7778
+ t7
7779
+ ] });
7780
+ $[85] = t5;
7781
+ $[86] = t6;
7782
+ $[87] = t7;
7783
+ $[88] = t8;
7784
+ } else {
7785
+ t8 = $[88];
7786
+ }
7787
+ return t8;
7788
+ }
7789
+ return null;
7790
+ };
7376
7791
  function EntityView({
7377
7792
  entity,
7378
7793
  collection,
@@ -7390,31 +7805,17 @@
7390
7805
  authController
7391
7806
  }), [collection, path, entity, customizationController.propertyConfigs]);
7392
7807
  const properties = resolvedCollection.properties;
7393
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full " + className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full mb-4", children: [
7394
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls(ui.defaultBorderMixin, "flex justify-between py-2 border-b last:border-b-0"), children: [
7395
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center w-1/4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pl-2 text-sm text-surface-600", children: "Id" }) }),
7396
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow p-2 ml-2 w-3/4 text-surface-900 dark:text-white min-h-[56px] flex items-center", children: [
7808
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full " + className, children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full mb-4 p-4", children: [
7809
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: `grid grid-cols-12 gap-x-4 py-4 items-start border-b ${ui.defaultBorderMixin}`, children: [
7810
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-4 pr-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", color: "secondary", component: "span", className: "break-words", children: "Id" }) }),
7811
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-8", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-grow text-surface-900 dark:text-white flex items-center", children: [
7397
7812
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-grow mr-2", children: entity.id }),
7398
7813
  customizationController?.entityLinkBuilder && /* @__PURE__ */ jsxRuntime.jsx("a", { href: customizationController.entityLinkBuilder({
7399
7814
  entity
7400
7815
  }), rel: "noopener noreferrer", target: "_blank", children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.OpenInNewIcon, { size: "small" }) }) })
7401
- ] })
7816
+ ] }) })
7402
7817
  ] }),
7403
- Object.entries(properties).map(([key, property]) => {
7404
- const value = entity.values?.[key];
7405
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls(ui.defaultBorderMixin, "flex justify-between py-2 border-b last:border-b-0"), children: [
7406
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center w-1/4", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "pl-2 text-sm text-surface-600", children: property.name }) }),
7407
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex-grow p-2 ml-2 w-3/4 text-surface-900 dark:text-white min-h-[56px] flex items-center", children: /* @__PURE__ */ jsxRuntime.jsx(
7408
- PropertyPreview,
7409
- {
7410
- propertyKey: key,
7411
- value,
7412
- property,
7413
- size: "medium"
7414
- }
7415
- ) })
7416
- ] }, `reference_previews_${key}`);
7417
- })
7818
+ /* @__PURE__ */ jsxRuntime.jsx(PropertyCollectionView, { data: entity.values, properties, size: "medium" })
7418
7819
  ] }) });
7419
7820
  }
7420
7821
  function VirtualTableInput(props) {
@@ -9765,6 +10166,10 @@
9765
10166
  try {
9766
10167
  const key = LOCAL_STORAGE_PREFIX + path;
9767
10168
  const entityString = JSON.stringify(data, customReplacer);
10169
+ console.log("Saving entity to localStorage:", {
10170
+ key,
10171
+ entityString
10172
+ });
9768
10173
  localStorage.setItem(key, entityString);
9769
10174
  } catch (error) {
9770
10175
  console.error(`Failed to save entity for path "${path}" to localStorage:`, error);
@@ -9787,6 +10192,10 @@
9787
10192
  const entityString = localStorage.getItem(key);
9788
10193
  if (entityString) {
9789
10194
  const entity = JSON.parse(entityString, customReviver);
10195
+ console.log("Loaded entity from localStorage:", {
10196
+ key,
10197
+ entity
10198
+ });
9790
10199
  return entity;
9791
10200
  }
9792
10201
  } catch (error) {
@@ -9805,6 +10214,26 @@
9805
10214
  }
9806
10215
  }
9807
10216
  }
10217
+ function flattenKeys(obj, prefix = "", result = []) {
10218
+ if (isObject(obj) || Array.isArray(obj)) {
10219
+ const plainObject = isPlainObject(obj);
10220
+ if (!plainObject && prefix) {
10221
+ result.push(prefix);
10222
+ } else {
10223
+ for (const key in obj) {
10224
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
10225
+ const newKey = prefix ? Array.isArray(obj) ? `${prefix}[${key}]` : `${prefix}.${key}` : key;
10226
+ if (isObject(obj[key]) || Array.isArray(obj[key])) {
10227
+ flattenKeys(obj[key], newKey, result);
10228
+ } else {
10229
+ result.push(newKey);
10230
+ }
10231
+ }
10232
+ }
10233
+ }
10234
+ }
10235
+ return result;
10236
+ }
9808
10237
  const EntityCollectionRowActions = function EntityCollectionRowActions2({
9809
10238
  entity,
9810
10239
  collection,
@@ -9834,6 +10263,7 @@
9834
10263
  const uncollapsedActions = actions.filter((a_1) => a_1.collapsed === false);
9835
10264
  const enableLocalChangesBackup = collection ? getLocalChangesBackup(collection) : false;
9836
10265
  const hasDraft = enableLocalChangesBackup ? getEntityFromCache(fullPath + "/" + entity.id) : false;
10266
+ const iconSize = largeLayout && (size === "m" || size === "l" || size == "xl") ? "medium" : "small";
9837
10267
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: ui.cls("h-full flex items-center justify-center flex-col bg-surface-50 dark:bg-surface-900 bg-opacity-90 dark:bg-opacity-90 z-10", frozen ? "sticky left-0" : ""), onClick: React.useCallback((event) => {
9838
10268
  event.stopPropagation();
9839
10269
  }, []), style: {
@@ -9843,23 +10273,31 @@
9843
10273
  contain: "strict"
9844
10274
  }, children: [
9845
10275
  (hasActions || selectionEnabled) && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-34 flex justify-center", children: [
9846
- uncollapsedActions.map((action, index) => /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: action.name, asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { onClick: (event_0) => {
9847
- event_0.stopPropagation();
9848
- action.onClick({
9849
- view: "collection",
9850
- entity,
9851
- fullPath,
9852
- fullIdPath,
9853
- collection,
9854
- context,
9855
- selectionController,
9856
- highlightEntity,
9857
- unhighlightEntity,
9858
- onCollectionChange,
9859
- openEntityMode: openEntityMode ?? collection?.openEntityMode
9860
- });
9861
- }, size: largeLayout ? "medium" : "small", children: action.icon }) }, index)),
9862
- hasCollapsedActions && /* @__PURE__ */ jsxRuntime.jsx(ui.Menu, { trigger: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: largeLayout ? "medium" : "small", children: /* @__PURE__ */ jsxRuntime.jsx(ui.MoreVertIcon, {}) }), children: collapsedActions.map((action_0, index_0) => /* @__PURE__ */ jsxRuntime.jsxs(ui.MenuItem, { onClick: (e) => {
10276
+ uncollapsedActions.map((action, index) => {
10277
+ const isEditAction = action.key === "edit";
10278
+ const tooltip = isEditAction && hasDraft ? "Local unsaved changes" : action.name;
10279
+ let iconButton = /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { onClick: (event_0) => {
10280
+ event_0.stopPropagation();
10281
+ action.onClick({
10282
+ view: "collection",
10283
+ entity,
10284
+ fullPath,
10285
+ fullIdPath,
10286
+ collection,
10287
+ context,
10288
+ selectionController,
10289
+ highlightEntity,
10290
+ unhighlightEntity,
10291
+ onCollectionChange,
10292
+ openEntityMode: openEntityMode ?? collection?.openEntityMode
10293
+ });
10294
+ }, size: iconSize, children: action.icon });
10295
+ if (isEditAction && hasDraft) {
10296
+ iconButton = /* @__PURE__ */ jsxRuntime.jsx(ui.Badge, { color: "warning", children: iconButton });
10297
+ }
10298
+ return /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: tooltip, asChild: true, children: iconButton }, index);
10299
+ }),
10300
+ hasCollapsedActions && /* @__PURE__ */ jsxRuntime.jsx(ui.Menu, { trigger: /* @__PURE__ */ jsxRuntime.jsx(ui.IconButton, { size: iconSize, children: /* @__PURE__ */ jsxRuntime.jsx(ui.MoreVertIcon, {}) }), children: collapsedActions.map((action_0, index_0) => /* @__PURE__ */ jsxRuntime.jsxs(ui.MenuItem, { onClick: (e) => {
9863
10301
  e.stopPropagation();
9864
10302
  action_0.onClick({
9865
10303
  view: "collection",
@@ -9878,14 +10316,11 @@
9878
10316
  action_0.icon,
9879
10317
  action_0.name
9880
10318
  ] }, index_0)) }),
9881
- selectionEnabled && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: `Select ${entity.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { size: largeLayout ? "medium" : "small", checked: Boolean(isSelected), onCheckedChange }) })
10319
+ selectionEnabled && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: `Select ${entity.id}`, children: /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { size: iconSize, checked: Boolean(isSelected), onCheckedChange }) })
9882
10320
  ] }),
9883
- !hideId && size !== "xs" && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center justify-center flex items-center gap-1", onClick: (event_1) => {
10321
+ !hideId && size !== "xs" && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-[138px] overflow-hidden truncate font-mono text-xs text-text-secondary dark:text-text-secondary-dark max-w-full text-ellipsis px-2 align-center justify-center flex items-center gap-1", onClick: (event_1) => {
9884
10322
  event_1.stopPropagation();
9885
- }, children: [
9886
- hasDraft && /* @__PURE__ */ jsxRuntime.jsx(ui.Tooltip, { title: "Local unsaved changes", className: "inline", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Chip, { colorScheme: "orangeDarker", className: "p-0.5", children: /* @__PURE__ */ jsxRuntime.jsx(ui.EditIcon, { size: 12 }) }) }),
9887
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 truncate text-center", children: entity ? entity.id : /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, {}) })
9888
- ] })
10323
+ }, children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 truncate text-center", children: entity ? entity.id : /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, {}) }) })
9889
10324
  ] });
9890
10325
  };
9891
10326
  function CollectionTableToolbar(t0) {
@@ -15169,10 +15604,10 @@
15169
15604
  ] });
15170
15605
  }
15171
15606
  function LocalChangesMenu(t0) {
15172
- const $ = reactCompilerRuntime.c(43);
15607
+ const $ = reactCompilerRuntime.c(42);
15173
15608
  const {
15174
15609
  localChangesData,
15175
- formex: formex$1,
15610
+ formex: formex2,
15176
15611
  onClearLocalChanges,
15177
15612
  cacheKey,
15178
15613
  properties
@@ -15182,9 +15617,7 @@
15182
15617
  const [open, setOpen] = React.useState(false);
15183
15618
  let t1;
15184
15619
  if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
15185
- t1 = () => {
15186
- setOpen(true);
15187
- };
15620
+ t1 = () => setOpen(true);
15188
15621
  $[0] = t1;
15189
15622
  } else {
15190
15623
  t1 = $[0];
@@ -15192,9 +15625,7 @@
15192
15625
  const handleOpenMenu = t1;
15193
15626
  let t2;
15194
15627
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
15195
- t2 = () => {
15196
- setOpen(false);
15197
- };
15628
+ t2 = () => setOpen(false);
15198
15629
  $[1] = t2;
15199
15630
  } else {
15200
15631
  t2 = $[1];
@@ -15212,18 +15643,18 @@
15212
15643
  }
15213
15644
  const handlePreview = t3;
15214
15645
  let t4;
15215
- if ($[3] !== formex$1 || $[4] !== localChangesData || $[5] !== onClearLocalChanges || $[6] !== snackbarController) {
15646
+ if ($[3] !== formex2 || $[4] !== localChangesData || $[5] !== onClearLocalChanges || $[6] !== snackbarController) {
15216
15647
  t4 = () => {
15217
- const mergedValues = mergeDeep(formex$1.values, localChangesData);
15648
+ const mergedValues = mergeDeep(formex2.values, localChangesData);
15218
15649
  const touched = {
15219
- ...formex$1.touched
15650
+ ...formex2.touched
15220
15651
  };
15221
- const newTouched = formex.flattenKeys(localChangesData);
15222
- newTouched.forEach((key) => {
15652
+ const previewKeys = flattenKeys(localChangesData);
15653
+ previewKeys.forEach((key) => {
15223
15654
  touched[key] = true;
15224
15655
  });
15225
- formex$1.setTouched(touched);
15226
- formex$1.setValues(mergedValues);
15656
+ formex2.setTouched(touched);
15657
+ formex2.setValues(mergedValues);
15227
15658
  snackbarController.open({
15228
15659
  type: "info",
15229
15660
  message: "Local changes applied to the form"
@@ -15231,7 +15662,7 @@
15231
15662
  handleCloseMenu();
15232
15663
  onClearLocalChanges?.();
15233
15664
  };
15234
- $[3] = formex$1;
15665
+ $[3] = formex2;
15235
15666
  $[4] = localChangesData;
15236
15667
  $[5] = onClearLocalChanges;
15237
15668
  $[6] = snackbarController;
@@ -15279,7 +15710,7 @@
15279
15710
  }
15280
15711
  let t8;
15281
15712
  if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
15282
- t8 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-xs px-4 py-4 text-sm text-gray-700 dark:text-gray-300", children: "This document was edited locally and has unsaved changes." });
15713
+ t8 = /* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-xs px-4 py-4 text-sm text-gray-700 dark:text-gray-300", children: "This document was edited locally and has unsaved changes. These local changes will be lost if you don't apply them." });
15283
15714
  $[14] = t8;
15284
15715
  } else {
15285
15716
  t8 = $[14];
@@ -15357,83 +15788,76 @@
15357
15788
  t16 = $[27];
15358
15789
  }
15359
15790
  let t17;
15360
- if ($[28] !== localChangesData || $[29] !== properties) {
15361
- t17 = formex.flattenKeys(localChangesData).map((key_0) => {
15362
- const value = formex.getIn(localChangesData, key_0);
15363
- const property = getPropertyInPath(properties, key_0);
15364
- if (!property) {
15365
- return null;
15366
- }
15367
- return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 gap-x-4 px-4 py-3 items-center", children: [
15368
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-3 text-right", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Typography, { variant: "caption", className: "text-gray-500 dark:text-gray-400 break-words", children: property.name || key_0 }) }),
15369
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-9", children: /* @__PURE__ */ jsxRuntime.jsx(PropertyPreview, { propertyKey: key_0, value, property, size: "small" }) })
15370
- ] }, key_0);
15371
- });
15372
- $[28] = localChangesData;
15373
- $[29] = properties;
15374
- $[30] = t17;
15791
+ if ($[28] === Symbol.for("react.memo_cache_sentinel")) {
15792
+ t17 = {
15793
+ maxHeight: 520,
15794
+ overflow: "auto"
15795
+ };
15796
+ $[28] = t17;
15375
15797
  } else {
15376
- t17 = $[30];
15798
+ t17 = $[28];
15377
15799
  }
15378
- let t18;
15379
- if ($[31] !== t17) {
15380
- t18 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogContent, { children: [
15800
+ const t18 = properties;
15801
+ let t19;
15802
+ if ($[29] !== localChangesData || $[30] !== t18) {
15803
+ t19 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogContent, { children: [
15381
15804
  t15,
15382
15805
  t16,
15383
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: `border rounded-lg divide-y divide-surface-200 divide-surface-opacity-40 dark:divide-surface-700 dark:divide-opacity-40 ${ui.defaultBorderMixin}`, children: t17 })
15806
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: `border rounded-lg ${ui.defaultBorderMixin}`, style: t17, children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsx(PropertyCollectionView, { data: localChangesData, properties: t18 }) }) })
15384
15807
  ] });
15385
- $[31] = t17;
15386
- $[32] = t18;
15808
+ $[29] = localChangesData;
15809
+ $[30] = t18;
15810
+ $[31] = t19;
15387
15811
  } else {
15388
- t18 = $[32];
15812
+ t19 = $[31];
15389
15813
  }
15390
- let t19;
15391
- if ($[33] === Symbol.for("react.memo_cache_sentinel")) {
15392
- t19 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: () => setPreviewDialogOpen(false), children: "Close" });
15393
- $[33] = t19;
15814
+ let t20;
15815
+ if ($[32] === Symbol.for("react.memo_cache_sentinel")) {
15816
+ t20 = /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { onClick: () => setPreviewDialogOpen(false), children: "Close" });
15817
+ $[32] = t20;
15394
15818
  } else {
15395
- t19 = $[33];
15819
+ t20 = $[32];
15396
15820
  }
15397
- let t20;
15398
- if ($[34] !== handleApply) {
15399
- t20 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogActions, { children: [
15400
- t19,
15821
+ let t21;
15822
+ if ($[33] !== handleApply) {
15823
+ t21 = /* @__PURE__ */ jsxRuntime.jsxs(ui.DialogActions, { children: [
15824
+ t20,
15401
15825
  /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "filled", onClick: () => {
15402
15826
  handleApply();
15403
15827
  setPreviewDialogOpen(false);
15404
15828
  }, children: "Apply changes" })
15405
15829
  ] });
15406
- $[34] = handleApply;
15407
- $[35] = t20;
15830
+ $[33] = handleApply;
15831
+ $[34] = t21;
15408
15832
  } else {
15409
- t20 = $[35];
15833
+ t21 = $[34];
15410
15834
  }
15411
- let t21;
15412
- if ($[36] !== previewDialogOpen || $[37] !== t18 || $[38] !== t20) {
15413
- t21 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Dialog, { open: previewDialogOpen, onOpenChange: setPreviewDialogOpen, maxWidth: "4xl", children: [
15414
- t18,
15415
- t20
15835
+ let t22;
15836
+ if ($[35] !== previewDialogOpen || $[36] !== t19 || $[37] !== t21) {
15837
+ t22 = /* @__PURE__ */ jsxRuntime.jsxs(ui.Dialog, { open: previewDialogOpen, onOpenChange: setPreviewDialogOpen, maxWidth: "4xl", children: [
15838
+ t19,
15839
+ t21
15416
15840
  ] });
15417
- $[36] = previewDialogOpen;
15418
- $[37] = t18;
15419
- $[38] = t20;
15420
- $[39] = t21;
15841
+ $[35] = previewDialogOpen;
15842
+ $[36] = t19;
15843
+ $[37] = t21;
15844
+ $[38] = t22;
15421
15845
  } else {
15422
- t21 = $[39];
15846
+ t22 = $[38];
15423
15847
  }
15424
- let t22;
15425
- if ($[40] !== t14 || $[41] !== t21) {
15426
- t22 = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
15848
+ let t23;
15849
+ if ($[39] !== t14 || $[40] !== t22) {
15850
+ t23 = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
15427
15851
  t14,
15428
- t21
15852
+ t22
15429
15853
  ] });
15430
- $[40] = t14;
15431
- $[41] = t21;
15432
- $[42] = t22;
15854
+ $[39] = t14;
15855
+ $[40] = t22;
15856
+ $[41] = t23;
15433
15857
  } else {
15434
- t22 = $[42];
15858
+ t23 = $[41];
15435
15859
  }
15436
- return t22;
15860
+ return t23;
15437
15861
  }
15438
15862
  function extractTouchedValues(values, touched) {
15439
15863
  let acc = {};
@@ -15447,6 +15871,56 @@
15447
15871
  });
15448
15872
  return acc;
15449
15873
  }
15874
+ function getChanges(source, comparison) {
15875
+ const changes = {};
15876
+ if (!source) {
15877
+ return {};
15878
+ }
15879
+ if (!comparison) {
15880
+ return source;
15881
+ }
15882
+ const allKeys = Array.from(/* @__PURE__ */ new Set([...Object.keys(source), ...Object.keys(comparison)]));
15883
+ for (const key of allKeys) {
15884
+ const sourceValue = source[key];
15885
+ const comparisonValue = comparison[key];
15886
+ if (equal(sourceValue, comparisonValue)) {
15887
+ continue;
15888
+ }
15889
+ const sourceHasKey = source && typeof source === "object" && Object.prototype.hasOwnProperty.call(source, key);
15890
+ const comparisonHasKey = comparison && typeof comparison === "object" && Object.prototype.hasOwnProperty.call(comparison, key);
15891
+ if (comparisonHasKey && !sourceHasKey) {
15892
+ changes[key] = void 0;
15893
+ } else if (Array.isArray(sourceValue)) {
15894
+ const comparisonArray = Array.isArray(comparisonValue) ? comparisonValue : [];
15895
+ if (sourceValue.length < comparisonArray.length) {
15896
+ changes[key] = sourceValue;
15897
+ continue;
15898
+ }
15899
+ const changedArray = sourceValue.map((item, index) => {
15900
+ const comparisonItem = comparisonArray[index];
15901
+ if (equal(item, comparisonItem)) {
15902
+ return null;
15903
+ }
15904
+ if (isObject(item) && item && isObject(comparisonItem) && comparisonItem) {
15905
+ const nestedChanges = getChanges(item, comparisonItem);
15906
+ return Object.keys(nestedChanges).length > 0 ? nestedChanges : item;
15907
+ }
15908
+ return item;
15909
+ });
15910
+ if (changedArray.some((item) => item !== null) || sourceValue.length > comparisonArray.length) {
15911
+ changes[key] = changedArray;
15912
+ }
15913
+ } else if (isObject(sourceValue) && sourceValue && isObject(comparisonValue) && comparisonValue) {
15914
+ const nestedChanges = getChanges(sourceValue, comparisonValue);
15915
+ if (Object.keys(nestedChanges).length > 0) {
15916
+ changes[key] = nestedChanges;
15917
+ }
15918
+ } else {
15919
+ changes[key] = sourceValue;
15920
+ }
15921
+ }
15922
+ return changes;
15923
+ }
15450
15924
  function EntityForm({
15451
15925
  path,
15452
15926
  fullIdPath,
@@ -15568,22 +16042,13 @@
15568
16042
  if (!localChangesDataRaw) {
15569
16043
  return void 0;
15570
16044
  }
15571
- let filteredChanges = {};
15572
- const flattenedKeys = formex.flattenKeys(localChangesDataRaw);
15573
- flattenedKeys.forEach((key) => {
15574
- const localValue = formex.getIn(localChangesDataRaw, key);
15575
- const initialValue = formex.getIn(initialValues_0, key);
15576
- if (!equal(localValue, initialValue)) {
15577
- filteredChanges = formex.setIn(filteredChanges, key, localValue);
15578
- }
15579
- });
15580
- return filteredChanges;
16045
+ return getChanges(localChangesDataRaw, initialValues_0);
15581
16046
  }, [localChangesDataRaw, initialValues_0]);
15582
16047
  const hasLocalChanges = !localChangesCleared && localChangesData && Object.keys(localChangesData).length > 0;
15583
16048
  const formex$1 = formexProp ?? formex.useCreateFormex({
15584
16049
  initialValues: initialValues_0,
15585
16050
  initialDirty: initialDirty_0,
15586
- initialTouched: initialDirtyValues ? formex.flattenKeys(initialDirtyValues).reduce((previousValue, currentValue) => ({
16051
+ initialTouched: initialDirtyValues ? flattenKeys(initialDirtyValues).reduce((previousValue, currentValue) => ({
15587
16052
  ...previousValue,
15588
16053
  [currentValue]: true
15589
16054
  }), {}) : {},
@@ -15593,10 +16058,10 @@
15593
16058
  onValuesModified?.(false, initialValues_0);
15594
16059
  },
15595
16060
  onValuesChangeDeferred: (values_0, controller) => {
15596
- const key_0 = status === "new" || status === "copy" ? path + "#new" : path + "/" + entityId;
16061
+ const key = status === "new" || status === "copy" ? path + "#new" : path + "/" + entityId;
15597
16062
  if (controller.dirty) {
15598
16063
  const touchedValues = extractTouchedValues(values_0, controller.touched);
15599
- saveEntityToCache(key_0, touchedValues);
16064
+ saveEntityToCache(key, touchedValues);
15600
16065
  }
15601
16066
  },
15602
16067
  validation: (values_1) => {
@@ -15830,11 +16295,11 @@
15830
16295
  useOnAutoSave(autoSave, formex$1, lastSavedValues, save);
15831
16296
  React.useEffect(() => {
15832
16297
  if (!autoSave && !formex$1.isSubmitting && underlyingChanges && entity) {
15833
- Object.entries(underlyingChanges).forEach(([key_1, value_0]) => {
15834
- const formValue = formex$1.values[key_1];
15835
- if (!equal(value_0, formValue) && !formex$1.touched[key_1]) {
15836
- console.debug("Updated value from the datasource:", key_1, value_0);
15837
- formex$1.setFieldValue(key_1, value_0 !== void 0 ? value_0 : null);
16298
+ Object.entries(underlyingChanges).forEach(([key_0, value_0]) => {
16299
+ const formValue = formex$1.values[key_0];
16300
+ if (!equal(value_0, formValue) && !formex$1.touched[key_0]) {
16301
+ console.debug("Updated value from the datasource:", key_0, value_0);
16302
+ formex$1.setFieldValue(key_0, value_0 !== void 0 ? value_0 : null);
15838
16303
  }
15839
16304
  });
15840
16305
  }
@@ -15844,16 +16309,16 @@
15844
16309
  if (Builder) {
15845
16310
  return /* @__PURE__ */ jsxRuntime.jsx(Builder, { collection, entity, modifiedValues: formex$1.values, formContext });
15846
16311
  }
15847
- return /* @__PURE__ */ jsxRuntime.jsx(FormLayout, { children: formFieldKeys.map((key_2) => {
15848
- const property = resolvedCollection.properties[key_2];
16312
+ return /* @__PURE__ */ jsxRuntime.jsx(FormLayout, { children: formFieldKeys.map((key_1) => {
16313
+ const property = resolvedCollection.properties[key_1];
15849
16314
  if (property) {
15850
- const underlyingValueHasChanged = !!underlyingChanges && Object.keys(underlyingChanges).includes(key_2) && formex$1.touched[key_2];
16315
+ const underlyingValueHasChanged = !!underlyingChanges && Object.keys(underlyingChanges).includes(key_1) && formex$1.touched[key_1];
15851
16316
  const disabled_0 = disabledProp || !autoSave && formex$1.isSubmitting || isReadOnly(property) || Boolean(property.disabled);
15852
16317
  const hidden = isHidden(property);
15853
16318
  if (hidden) return null;
15854
16319
  const widthPercentage = property.widthPercentage ?? 100;
15855
16320
  const cmsFormFieldProps = {
15856
- propertyKey: key_2,
16321
+ propertyKey: key_1,
15857
16322
  disabled: disabled_0,
15858
16323
  property,
15859
16324
  includeDescription: property.description || property.longDescription,
@@ -15863,9 +16328,9 @@
15863
16328
  minimalistView: false,
15864
16329
  autoFocus: false
15865
16330
  };
15866
- return /* @__PURE__ */ jsxRuntime.jsx(FormEntry, { propertyKey: key_2, widthPercentage, children: /* @__PURE__ */ jsxRuntime.jsx(PropertyFieldBinding, { ...cmsFormFieldProps }) }, `field_${key_2}`);
16331
+ return /* @__PURE__ */ jsxRuntime.jsx(FormEntry, { propertyKey: key_1, widthPercentage, children: /* @__PURE__ */ jsxRuntime.jsx(PropertyFieldBinding, { ...cmsFormFieldProps }) }, `field_${key_1}`);
15867
16332
  }
15868
- const additionalField = resolvedCollection.additionalFields?.find((f) => f.key === key_2);
16333
+ const additionalField = resolvedCollection.additionalFields?.find((f) => f.key === key_1);
15869
16334
  if (additionalField && entity) {
15870
16335
  const Builder_0 = additionalField.Builder;
15871
16336
  if (!Builder_0 && !additionalField.value) {
@@ -15876,11 +16341,11 @@
15876
16341
  context
15877
16342
  })?.toString() });
15878
16343
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full", children: [
15879
- /* @__PURE__ */ jsxRuntime.jsx(LabelWithIconAndTooltip, { propertyKey: key_2, icon: /* @__PURE__ */ jsxRuntime.jsx(ui.NotesIcon, { size: "small" }), title: additionalField.name, className: "text-text-secondary dark:text-text-secondary-dark ml-3.5" }),
16344
+ /* @__PURE__ */ jsxRuntime.jsx(LabelWithIconAndTooltip, { propertyKey: key_1, icon: /* @__PURE__ */ jsxRuntime.jsx(ui.NotesIcon, { size: "small" }), title: additionalField.name, className: "text-text-secondary dark:text-text-secondary-dark ml-3.5" }),
15880
16345
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: ui.cls(ui.paperMixin, "w-full min-h-14 p-4 md:p-6 overflow-x-scroll no-scrollbar"), children: /* @__PURE__ */ jsxRuntime.jsx(ErrorBoundary, { children: child }) })
15881
- ] }, `additional_${key_2}`);
16346
+ ] }, `additional_${key_1}`);
15882
16347
  }
15883
- console.warn(`Property ${key_2} not found in collection ${resolvedCollection.name} in properties or additional fields. Skipping.`);
16348
+ console.warn(`Property ${key_1} not found in collection ${resolvedCollection.name} in properties or additional fields. Skipping.`);
15884
16349
  return null;
15885
16350
  }).filter(Boolean) });
15886
16351
  };
@@ -26556,6 +27021,7 @@
26556
27021
  exports2.isEnumValueDisabled = isEnumValueDisabled;
26557
27022
  exports2.isHidden = isHidden;
26558
27023
  exports2.isObject = isObject;
27024
+ exports2.isPlainObject = isPlainObject;
26559
27025
  exports2.isPropertyBuilder = isPropertyBuilder;
26560
27026
  exports2.isReadOnly = isReadOnly;
26561
27027
  exports2.isReferenceProperty = isReferenceProperty;