@object-ui/plugin-grid 3.1.0 → 3.1.2

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,5 +1,5 @@
1
1
 
2
- > @object-ui/plugin-grid@3.1.0 build /home/runner/work/objectui/objectui/packages/plugin-grid
2
+ > @object-ui/plugin-grid@3.1.2 build /home/runner/work/objectui/objectui/packages/plugin-grid
3
3
  > vite build
4
4
 
5
5
  vite v7.3.1 building client environment for production...
@@ -8,20 +8,14 @@ transforming...
8
8
  rendering chunks...
9
9
  
10
10
  [vite:dts] Start generate declaration files...
11
- src/ObjectGrid.tsx:623:98 - error TS2345: Argument of type 'string | { key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }' is not assignable to parameter of type 'string'.
12
- Type '{ key: string; defaultValue?: string | undefined; params?: Record<string, string | number | boolean> | undefined; }' is not assignable to type 'string'.
13
-
14
- 623 const header = schema.objectName ? resolveFieldLabel(schema.objectName, col.field, rawHeader) : rawHeader;
15
-    ~~~~~~~~~
16
-
17
11
  computing gzip size...
18
- dist/index.js 111.38 kB │ gzip: 29.34 kB
19
- [vite:dts] Declaration files built in 26607ms.
12
+ dist/index.js 111.48 kB │ gzip: 29.36 kB
13
+ [vite:dts] Declaration files built in 30226ms.
20
14
  
21
15
  No name was provided for external module "@object-ui/core" in "output.globals" – guessing "core".
22
16
  No name was provided for external module "@object-ui/react" in "output.globals" – guessing "react".
23
17
  No name was provided for external module "@object-ui/fields" in "output.globals" – guessing "fields".
24
18
  No name was provided for external module "@object-ui/components" in "output.globals" – guessing "components".
25
19
  No name was provided for external module "lucide-react" in "output.globals" – guessing "lucideReact".
26
- dist/index.umd.cjs 77.43 kB │ gzip: 25.12 kB
27
- ✓ built in 28.64s
20
+ dist/index.umd.cjs 77.51 kB │ gzip: 25.15 kB
21
+ ✓ built in 33.03s
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @object-ui/plugin-grid
2
2
 
3
+ ## 3.1.2
4
+
5
+ ### Patch Changes
6
+
7
+ - @object-ui/types@3.1.2
8
+ - @object-ui/core@3.1.2
9
+ - @object-ui/react@3.1.2
10
+ - @object-ui/components@3.1.2
11
+ - @object-ui/fields@3.1.2
12
+ - @object-ui/mobile@3.1.2
13
+
14
+ ## 3.1.1
15
+
16
+ ### Patch Changes
17
+
18
+ - Updated dependencies
19
+ - @object-ui/types@3.1.1
20
+ - @object-ui/components@3.1.1
21
+ - @object-ui/core@3.1.1
22
+ - @object-ui/fields@3.1.1
23
+ - @object-ui/mobile@3.1.1
24
+ - @object-ui/react@3.1.1
25
+
3
26
  ## 3.0.3
4
27
 
5
28
  ### Patch Changes
package/dist/index.js CHANGED
@@ -618,6 +618,10 @@ function En() {
618
618
  }
619
619
  }
620
620
  function Rn(e) {
621
+ if (e != null)
622
+ return typeof e == "string" ? e : e.defaultValue || e.key;
623
+ }
624
+ function kn(e) {
621
625
  return e.data ? Array.isArray(e.data) ? {
622
626
  provider: "value",
623
627
  items: e.data
@@ -633,7 +637,7 @@ function nt(e) {
633
637
  if (!(!e || e.length === 0))
634
638
  return typeof e[0] == "object" && e[0] !== null, e;
635
639
  }
636
- const kn = ({
640
+ const _n = ({
637
641
  schema: e,
638
642
  dataSource: o,
639
643
  onEdit: t,
@@ -670,7 +674,7 @@ const kn = ({
670
674
  const c = () => H(window.innerWidth < 480);
671
675
  return c(), window.addEventListener("resize", c), () => window.removeEventListener("resize", c);
672
676
  }, []);
673
- const $ = d.data, B = gs(e.bind), Ne = Rn(e), X = Ie.useMemo(() => $ && Array.isArray($) ? {
677
+ const $ = d.data, B = gs(e.bind), Ne = kn(e), X = Ie.useMemo(() => $ && Array.isArray($) ? {
674
678
  provider: "value",
675
679
  items: $
676
680
  } : B && Array.isArray(B) ? {
@@ -845,7 +849,7 @@ const kn = ({
845
849
  });
846
850
  if ("field" in y)
847
851
  return S.filter((g) => g?.field && typeof g.field == "string" && !g.hidden).map((g, N) => {
848
- const w = g.label || g.field.charAt(0).toUpperCase() + g.field.slice(1).replace(/_/g, " "), A = e.objectName ? D(e.objectName, g.field, w) : w;
852
+ const w = Rn(g.label) || g.field.charAt(0).toUpperCase() + g.field.slice(1).replace(/_/g, " "), A = e.objectName ? D(e.objectName, g.field, w) : w;
849
853
  let C;
850
854
  const b = z?.fields?.[g.field], R = g.type || b?.type || O({ field: g.field }) || null, V = R ? Ee(R) : null, E = { name: g.field, type: R || "text" };
851
855
  if (b && (b.label && (E.label = b.label), b.currency && (E.currency = b.currency), b.precision !== void 0 && (E.precision = b.precision), b.format && (E.format = b.format), b.options && (E.options = b.options)), R === "select" && !E.options) {
@@ -1376,7 +1380,7 @@ function Tt(e, o) {
1376
1380
  throw new Error("Unexpected undefined");
1377
1381
  return e;
1378
1382
  }
1379
- const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
1383
+ const On = (e, o) => Math.abs(e - o) < 1.01, Tn = (e, o, t) => {
1380
1384
  let n;
1381
1385
  return function(...r) {
1382
1386
  e.clearTimeout(n), n = e.setTimeout(() => o.apply(this, r), t);
@@ -1384,12 +1388,12 @@ const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
1384
1388
  }, At = (e) => {
1385
1389
  const { offsetWidth: o, offsetHeight: t } = e;
1386
1390
  return { width: o, height: t };
1387
- }, Tn = (e) => e, An = (e) => {
1391
+ }, An = (e) => e, Mn = (e) => {
1388
1392
  const o = Math.max(e.startIndex - e.overscan, 0), t = Math.min(e.endIndex + e.overscan, e.count - 1), n = [];
1389
1393
  for (let r = o; r <= t; r++)
1390
1394
  n.push(r);
1391
1395
  return n;
1392
- }, Mn = (e, o) => {
1396
+ }, Dn = (e, o) => {
1393
1397
  const t = e.scrollElement;
1394
1398
  if (!t)
1395
1399
  return;
@@ -1422,7 +1426,7 @@ const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
1422
1426
  };
1423
1427
  }, Mt = {
1424
1428
  passive: !0
1425
- }, Dt = typeof window > "u" ? !0 : "onscrollend" in window, Dn = (e, o) => {
1429
+ }, Dt = typeof window > "u" ? !0 : "onscrollend" in window, Fn = (e, o) => {
1426
1430
  const t = e.scrollElement;
1427
1431
  if (!t)
1428
1432
  return;
@@ -1431,7 +1435,7 @@ const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
1431
1435
  return;
1432
1436
  let r = 0;
1433
1437
  const i = e.options.useScrollendEvent && Dt ? () => {
1434
- } : On(
1438
+ } : Tn(
1435
1439
  n,
1436
1440
  () => {
1437
1441
  o(r, !1);
@@ -1446,7 +1450,7 @@ const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
1446
1450
  return f && t.addEventListener("scrollend", h, Mt), () => {
1447
1451
  t.removeEventListener("scroll", l), f && t.removeEventListener("scrollend", h);
1448
1452
  };
1449
- }, Fn = (e, o, t) => {
1453
+ }, zn = (e, o, t) => {
1450
1454
  if (o?.borderBoxSize) {
1451
1455
  const n = o.borderBoxSize[0];
1452
1456
  if (n)
@@ -1455,7 +1459,7 @@ const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
1455
1459
  );
1456
1460
  }
1457
1461
  return e[t.options.horizontal ? "offsetWidth" : "offsetHeight"];
1458
- }, zn = (e, {
1462
+ }, In = (e, {
1459
1463
  adjustments: o = 0,
1460
1464
  behavior: t
1461
1465
  }, n) => {
@@ -1466,7 +1470,7 @@ const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
1466
1470
  behavior: t
1467
1471
  });
1468
1472
  };
1469
- class In {
1473
+ class Pn {
1470
1474
  constructor(o) {
1471
1475
  this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.currentScrollToIndex = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.prevLanes = void 0, this.lanesChangedFlag = !1, this.lanesSettling = !1, this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
1472
1476
  let t = null;
@@ -1504,11 +1508,11 @@ class In {
1504
1508
  scrollPaddingStart: 0,
1505
1509
  scrollPaddingEnd: 0,
1506
1510
  horizontal: !1,
1507
- getItemKey: Tn,
1508
- rangeExtractor: An,
1511
+ getItemKey: An,
1512
+ rangeExtractor: Mn,
1509
1513
  onChange: () => {
1510
1514
  },
1511
- measureElement: Fn,
1515
+ measureElement: zn,
1512
1516
  initialRect: { width: 0, height: 0 },
1513
1517
  scrollMargin: 0,
1514
1518
  gap: 0,
@@ -1657,7 +1661,7 @@ class In {
1657
1661
  this.getScrollOffset(),
1658
1662
  this.options.lanes
1659
1663
  ],
1660
- (t, n, r, i) => this.range = t.length > 0 && n > 0 ? Pn({
1664
+ (t, n, r, i) => this.range = t.length > 0 && n > 0 ? Ln({
1661
1665
  measurements: t,
1662
1666
  outerSize: n,
1663
1667
  scrollOffset: r,
@@ -1805,7 +1809,7 @@ class In {
1805
1809
  console.warn("Failed to get offset for index:", t);
1806
1810
  return;
1807
1811
  }
1808
- _n(v[0], j) || h(p);
1812
+ On(v[0], j) || h(p);
1809
1813
  };
1810
1814
  this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(x) : x();
1811
1815
  });
@@ -1865,7 +1869,7 @@ const qt = (e, o, t, n) => {
1865
1869
  }
1866
1870
  return e > 0 ? e - 1 : 0;
1867
1871
  };
1868
- function Pn({
1872
+ function Ln({
1869
1873
  measurements: e,
1870
1874
  outerSize: o,
1871
1875
  scrollOffset: t,
@@ -1902,7 +1906,7 @@ function Pn({
1902
1906
  return { startIndex: a, endIndex: l };
1903
1907
  }
1904
1908
  const Ft = typeof document < "u" ? He.useLayoutEffect : He.useEffect;
1905
- function Ln({
1909
+ function $n({
1906
1910
  useFlushSync: e = !0,
1907
1911
  ...o
1908
1912
  }) {
@@ -1913,19 +1917,19 @@ function Ln({
1913
1917
  e && a ? on(t) : t(), (l = o.onChange) == null || l.call(o, i, a);
1914
1918
  }
1915
1919
  }, [r] = He.useState(
1916
- () => new In(n)
1920
+ () => new Pn(n)
1917
1921
  );
1918
1922
  return r.setOptions(n), Ft(() => r._didMount(), []), Ft(() => r._willUpdate()), r;
1919
1923
  }
1920
- function $n(e) {
1921
- return Ln({
1922
- observeElementRect: Mn,
1923
- observeElementOffset: Dn,
1924
- scrollToFn: zn,
1924
+ function Vn(e) {
1925
+ return $n({
1926
+ observeElementRect: Dn,
1927
+ observeElementOffset: Fn,
1928
+ scrollToFn: In,
1925
1929
  ...e
1926
1930
  });
1927
1931
  }
1928
- const cr = ({
1932
+ const dr = ({
1929
1933
  data: e,
1930
1934
  columns: o,
1931
1935
  rowHeight: t = 40,
@@ -1936,7 +1940,7 @@ const cr = ({
1936
1940
  onRowClick: l,
1937
1941
  overscan: h = 5
1938
1942
  }) => {
1939
- const f = xe(null), d = $n({
1943
+ const f = xe(null), d = Vn({
1940
1944
  count: e.length,
1941
1945
  getScrollElement: () => f.current,
1942
1946
  estimateSize: () => t,
@@ -2020,8 +2024,8 @@ const cr = ({
2020
2024
  " rows (virtual scrolling enabled)"
2021
2025
  ] })
2022
2026
  ] });
2023
- }, Vn = 10;
2024
- function Kn(e) {
2027
+ }, Kn = 10;
2028
+ function Wn(e) {
2025
2029
  const o = [];
2026
2030
  let t = [], n = "", r = !1;
2027
2031
  for (let i = 0; i < e.length; i++) {
@@ -2048,7 +2052,7 @@ function Bt(e, o) {
2048
2052
  return !0;
2049
2053
  }
2050
2054
  }
2051
- function Wn(e, o) {
2055
+ function qn(e, o) {
2052
2056
  const t = {};
2053
2057
  return e.forEach((n, r) => {
2054
2058
  const i = n.toLowerCase().replace(/[_\s-]/g, ""), a = o.find((l) => {
@@ -2058,7 +2062,7 @@ function Wn(e, o) {
2058
2062
  a && (t[r] = a.name);
2059
2063
  }), t;
2060
2064
  }
2061
- function qn(e, o, t) {
2065
+ function Bn(e, o, t) {
2062
2066
  const n = [], r = {};
2063
2067
  for (const i of o) {
2064
2068
  const a = e[i.csvIdx] ?? "";
@@ -2074,7 +2078,7 @@ function qn(e, o, t) {
2074
2078
  }
2075
2079
  return { record: r, errors: n };
2076
2080
  }
2077
- const Bn = ({ onFileLoaded: e }) => {
2081
+ const Un = ({ onFileLoaded: e }) => {
2078
2082
  const [o, t] = F(!1), [n, r] = F(null), i = M((a) => {
2079
2083
  if (r(null), !a.name.endsWith(".csv")) {
2080
2084
  r("Only CSV files are supported.");
@@ -2082,7 +2086,7 @@ const Bn = ({ onFileLoaded: e }) => {
2082
2086
  }
2083
2087
  const l = new FileReader();
2084
2088
  l.onload = (h) => {
2085
- const f = Kn(h.target?.result);
2089
+ const f = Wn(h.target?.result);
2086
2090
  if (f.length < 2) {
2087
2091
  r("File must contain a header row and at least one data row.");
2088
2092
  return;
@@ -2126,7 +2130,7 @@ const Bn = ({ onFileLoaded: e }) => {
2126
2130
  n
2127
2131
  ] })
2128
2132
  ] });
2129
- }, Un = ({ headers: e, fields: o, mapping: t, onMappingChange: n }) => {
2133
+ }, Gn = ({ headers: e, fields: o, mapping: t, onMappingChange: n }) => {
2130
2134
  const r = ve(() => new Set(Object.values(t)), [t]), i = M((a, l) => {
2131
2135
  const h = { ...t };
2132
2136
  l === "__skip__" ? delete h[a] : h[a] = l, n(h);
@@ -2152,12 +2156,12 @@ const Bn = ({ onFileLoaded: e }) => {
2152
2156
  /* @__PURE__ */ s.jsx(Le, { className: "text-center", children: t[l] ? /* @__PURE__ */ s.jsx(Te, { variant: "default", className: "text-xs", children: "Mapped" }) : /* @__PURE__ */ s.jsx(Te, { variant: "secondary", className: "text-xs", children: "Skipped" }) })
2153
2157
  ] }, l)) })
2154
2158
  ] }) });
2155
- }, Gn = ({ headers: e, rows: o, mapping: t, fields: n }) => {
2159
+ }, Hn = ({ headers: e, rows: o, mapping: t, fields: n }) => {
2156
2160
  const r = ve(() => Object.entries(t).map(([h, f]) => ({
2157
2161
  csvIdx: Number(h),
2158
2162
  header: e[Number(h)],
2159
2163
  field: n.find((d) => d.name === f)
2160
- })), [t, e, n]), i = o.slice(0, Vn), a = ve(() => i.map((h, f) => {
2164
+ })), [t, e, n]), i = o.slice(0, Kn), a = ve(() => i.map((h, f) => {
2161
2165
  const d = {};
2162
2166
  for (const m of r) {
2163
2167
  const p = h[m.csvIdx] ?? "";
@@ -2196,7 +2200,7 @@ const Bn = ({ onFileLoaded: e }) => {
2196
2200
  " rows"
2197
2201
  ] })
2198
2202
  ] });
2199
- }, Hn = ({
2203
+ }, Yn = ({
2200
2204
  objectName: e,
2201
2205
  objectLabel: o,
2202
2206
  fields: t,
@@ -2211,7 +2215,7 @@ const Bn = ({ onFileLoaded: e }) => {
2211
2215
  const L = new Set(Object.values(v));
2212
2216
  return t.filter((J) => J.required && !L.has(J.name));
2213
2217
  }, [t, v]), je = M((L, J) => {
2214
- p(L), j(J), k(Wn(L, t)), d("mapping");
2218
+ p(L), j(J), k(qn(L, t)), d("mapping");
2215
2219
  }, [t]), Re = M(async () => {
2216
2220
  D(!0), G(0);
2217
2221
  const L = [];
@@ -2221,7 +2225,7 @@ const Bn = ({ onFileLoaded: e }) => {
2221
2225
  field: t.find((ge) => ge.name === be)
2222
2226
  }));
2223
2227
  for (let ee = 0; ee < x.length; ee++) {
2224
- const { record: be, errors: ge } = qn(x[ee], ie, ee + 1);
2228
+ const { record: be, errors: ge } = Bn(x[ee], ie, ee + 1);
2225
2229
  if (ge.length > 0) {
2226
2230
  if (fe++, L.push(...ge), h === "stop") break;
2227
2231
  } else
@@ -2292,9 +2296,9 @@ const Bn = ({ onFileLoaded: e }) => {
2292
2296
  ] })
2293
2297
  ] })
2294
2298
  ] }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
2295
- f === "upload" && /* @__PURE__ */ s.jsx(Bn, { onFileLoaded: je }),
2296
- f === "mapping" && /* @__PURE__ */ s.jsx(Un, { headers: m, fields: t, mapping: v, onMappingChange: k }),
2297
- f === "preview" && /* @__PURE__ */ s.jsx(Gn, { headers: m, rows: x, mapping: v, fields: t }),
2299
+ f === "upload" && /* @__PURE__ */ s.jsx(Un, { onFileLoaded: je }),
2300
+ f === "mapping" && /* @__PURE__ */ s.jsx(Gn, { headers: m, fields: t, mapping: v, onMappingChange: k }),
2301
+ f === "preview" && /* @__PURE__ */ s.jsx(Hn, { headers: m, rows: x, mapping: v, fields: t }),
2298
2302
  T && /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col gap-1", children: [
2299
2303
  /* @__PURE__ */ s.jsx(Ds, { value: z, className: "h-2" }),
2300
2304
  /* @__PURE__ */ s.jsxs("p", { className: "text-center text-xs text-muted-foreground", children: [
@@ -2321,7 +2325,7 @@ const Bn = ({ onFileLoaded: e }) => {
2321
2325
  ] }) })
2322
2326
  ] }) });
2323
2327
  };
2324
- function dr({
2328
+ function ur({
2325
2329
  value: e,
2326
2330
  onSave: o,
2327
2331
  onCancel: t,
@@ -2468,7 +2472,7 @@ function zt(e) {
2468
2472
  endCol: Math.max(e.startCol, e.endCol)
2469
2473
  };
2470
2474
  }
2471
- function ur({
2475
+ function fr({
2472
2476
  data: e,
2473
2477
  columns: o,
2474
2478
  onPaste: t,
@@ -2517,12 +2521,12 @@ function ur({
2517
2521
  n || i(null);
2518
2522
  }, [n]), { selectedRange: r, setSelectedRange: i, onCopy: a, onPaste: l, onKeyDown: h };
2519
2523
  }
2520
- const Yn = [
2524
+ const Jn = [
2521
2525
  { position: 0, className: "bg-green-100" },
2522
2526
  { position: 0.5, className: "bg-yellow-100" },
2523
2527
  { position: 1, className: "bg-red-100" }
2524
2528
  ];
2525
- function Jn(e, o) {
2529
+ function Xn(e, o) {
2526
2530
  let t = 1 / 0, n = -1 / 0;
2527
2531
  for (const r of e) {
2528
2532
  const i = Number(r[o]);
@@ -2530,7 +2534,7 @@ function Jn(e, o) {
2530
2534
  }
2531
2535
  return Number.isFinite(t) ? [t, n] : [0, 0];
2532
2536
  }
2533
- function Xn(e, o) {
2537
+ function Qn(e, o) {
2534
2538
  if (o.length === 0) return "";
2535
2539
  if (o.length === 1) return o[0].className;
2536
2540
  let t = o[0], n = Math.abs(e - t.position);
@@ -2540,21 +2544,21 @@ function Xn(e, o) {
2540
2544
  }
2541
2545
  return t.className;
2542
2546
  }
2543
- function fr(e) {
2544
- const { field: o, data: t, min: n, max: r, stops: i = Yn } = e, [a, l] = ve(() => Jn(t, o), [t, o]), h = n ?? a, f = r ?? l;
2547
+ function mr(e) {
2548
+ const { field: o, data: t, min: n, max: r, stops: i = Jn } = e, [a, l] = ve(() => Xn(t, o), [t, o]), h = n ?? a, f = r ?? l;
2545
2549
  return M(
2546
2550
  (d) => {
2547
2551
  const m = Number(d[o]);
2548
2552
  if (!Number.isFinite(m)) return;
2549
2553
  if (f === h) return i.length > 0 ? i[0].className : void 0;
2550
2554
  const p = Math.max(0, Math.min(1, (m - h) / (f - h)));
2551
- return Xn(p, i);
2555
+ return Qn(p, i);
2552
2556
  },
2553
2557
  [o, h, f, i]
2554
2558
  );
2555
2559
  }
2556
2560
  const It = "text/x-group-key";
2557
- function mr({ groupKeys: e }) {
2561
+ function hr({ groupKeys: e }) {
2558
2562
  const [o, t] = F(e), [n, r] = F(null);
2559
2563
  me(() => {
2560
2564
  t((d) => {
@@ -2600,7 +2604,7 @@ function mr({ groupKeys: e }) {
2600
2604
  draggingKey: n
2601
2605
  };
2602
2606
  }
2603
- function hr({
2607
+ function pr({
2604
2608
  value: e,
2605
2609
  onChange: o,
2606
2610
  onConfirm: t,
@@ -2681,7 +2685,7 @@ function hr({
2681
2685
  }
2682
2686
  );
2683
2687
  }
2684
- function pr({
2688
+ function gr({
2685
2689
  frozenWidth: e,
2686
2690
  onResize: o,
2687
2691
  minFrozenWidth: t = 100,
@@ -2740,7 +2744,7 @@ function pr({
2740
2744
  }
2741
2745
  const Ut = ({ schema: e, ...o }) => {
2742
2746
  const { dataSource: t } = Pt() || {};
2743
- return /* @__PURE__ */ s.jsx(kn, { schema: e, dataSource: t, ...o });
2747
+ return /* @__PURE__ */ s.jsx(_n, { schema: e, dataSource: t, ...o });
2744
2748
  };
2745
2749
  rt.register("object-grid", Ut, {
2746
2750
  namespace: "plugin-grid",
@@ -2762,10 +2766,10 @@ rt.register("grid", Ut, {
2762
2766
  { name: "filters", type: "array", label: "Filters" }
2763
2767
  ]
2764
2768
  });
2765
- const Qn = ({ schema: e, ...o }) => {
2769
+ const Zn = ({ schema: e, ...o }) => {
2766
2770
  const { dataSource: t } = Pt() || {};
2767
2771
  return /* @__PURE__ */ s.jsx(
2768
- Hn,
2772
+ Yn,
2769
2773
  {
2770
2774
  objectName: e.objectName,
2771
2775
  objectLabel: e.objectLabel,
@@ -2775,7 +2779,7 @@ const Qn = ({ schema: e, ...o }) => {
2775
2779
  }
2776
2780
  );
2777
2781
  };
2778
- rt.register("import-wizard", Qn, {
2782
+ rt.register("import-wizard", Zn, {
2779
2783
  namespace: "plugin-grid",
2780
2784
  label: "Import Wizard",
2781
2785
  category: "plugin",
@@ -2786,20 +2790,20 @@ rt.register("import-wizard", Qn, {
2786
2790
  });
2787
2791
  export {
2788
2792
  _t as BulkActionBar,
2789
- hr as FormulaBar,
2793
+ pr as FormulaBar,
2790
2794
  vn as GroupRow,
2791
- Hn as ImportWizard,
2792
- dr as InlineEditing,
2793
- kn as ObjectGrid,
2795
+ Yn as ImportWizard,
2796
+ ur as InlineEditing,
2797
+ _n as ObjectGrid,
2794
2798
  Ut as ObjectGridRenderer,
2795
2799
  Sn as RowActionMenu,
2796
- pr as SplitPaneGrid,
2797
- cr as VirtualGrid,
2800
+ gr as SplitPaneGrid,
2801
+ dr as VirtualGrid,
2798
2802
  ot as formatActionLabel,
2799
- ur as useCellClipboard,
2803
+ fr as useCellClipboard,
2800
2804
  Cn as useColumnSummary,
2801
- fr as useGradientColor,
2802
- mr as useGroupReorder,
2805
+ mr as useGradientColor,
2806
+ hr as useGroupReorder,
2803
2807
  yn as useGroupedData,
2804
2808
  hn as useRowColor
2805
2809
  };
@@ -1,15 +1,15 @@
1
- (function(P,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/fields"),require("@object-ui/components"),require("lucide-react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core","@object-ui/react","@object-ui/fields","@object-ui/components","lucide-react","react-dom"],f):(P=typeof globalThis<"u"?globalThis:P||self,f(P.ObjectUIPluginGrid={},P.React,P.core,P.react,P.fields,P.components,P.lucideReact,P.ReactDOM))})(this,(function(P,f,_e,pe,Z,v,F,_t){"use strict";function Tt(e){const l=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(l,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return l.default=e,Object.freeze(l)}const ze=Tt(f);var Ie={exports:{}},Te={};var Ye;function At(){if(Ye)return Te;Ye=1;var e=Symbol.for("react.transitional.element"),l=Symbol.for("react.fragment");function t(r,n,i){var a=null;if(i!==void 0&&(a=""+i),n.key!==void 0&&(a=""+n.key),"key"in n){i={};for(var o in n)o!=="key"&&(i[o]=n[o])}else i=n;return n=i.ref,{$$typeof:e,type:r,key:a,ref:n!==void 0?n:null,props:i}}return Te.Fragment=l,Te.jsx=t,Te.jsxs=t,Te}var Ae={};var Je;function Mt(){return Je||(Je=1,process.env.NODE_ENV!=="production"&&(function(){function e(u){if(u==null)return null;if(typeof u=="function")return u.$$typeof===de?null:u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case T:return"Fragment";case I:return"Profiler";case D:return"StrictMode";case J:return"Suspense";case oe:return"SuspenseList";case Ee:return"Activity"}if(typeof u=="object")switch(typeof u.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),u.$$typeof){case w:return"Portal";case Y:return u.displayName||"Context";case L:return(u._context.displayName||"Context")+".Consumer";case q:var A=u.render;return u=u.displayName,u||(u=A.displayName||A.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case Me:return A=u.displayName||null,A!==null?A:e(u.type)||"Memo";case ve:A=u._payload,u=u._init;try{return e(u(A))}catch{}}return null}function l(u){return""+u}function t(u){try{l(u);var A=!1}catch{A=!0}if(A){A=console;var K=A.error,H=typeof Symbol=="function"&&Symbol.toStringTag&&u[Symbol.toStringTag]||u.constructor.name||"Object";return K.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",H),l(u)}}function r(u){if(u===T)return"<>";if(typeof u=="object"&&u!==null&&u.$$typeof===ve)return"<...>";try{var A=e(u);return A?"<"+A+">":"<...>"}catch{return"<...>"}}function n(){var u=ge.A;return u===null?null:u.getOwner()}function i(){return Error("react-stack-top-frame")}function a(u){if(V.call(u,"key")){var A=Object.getOwnPropertyDescriptor(u,"key").get;if(A&&A.isReactWarning)return!1}return u.key!==void 0}function o(u,A){function K(){ae||(ae=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",A))}K.isReactWarning=!0,Object.defineProperty(u,"key",{get:K,configurable:!0})}function p(){var u=e(this.type);return je[u]||(je[u]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),u=this.props.ref,u!==void 0?u:null}function h(u,A,K,H,we,ee){var R=K.ref;return u={$$typeof:C,type:u,key:A,props:K,_owner:H},(R!==void 0?R:null)!==null?Object.defineProperty(u,"ref",{enumerable:!1,get:p}):Object.defineProperty(u,"ref",{enumerable:!1,value:null}),u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(u,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(u,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:we}),Object.defineProperty(u,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u}function d(u,A,K,H,we,ee){var R=A.children;if(R!==void 0)if(H)if(Q(R)){for(H=0;H<R.length;H++)m(R[H]);Object.freeze&&Object.freeze(R)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(R);if(V.call(A,"key")){R=e(u);var X=Object.keys(A).filter(function(me){return me!=="key"});H=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",xe[R+H]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
1
+ (function(P,f){typeof exports=="object"&&typeof module<"u"?f(exports,require("react"),require("@object-ui/core"),require("@object-ui/react"),require("@object-ui/fields"),require("@object-ui/components"),require("lucide-react"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","@object-ui/core","@object-ui/react","@object-ui/fields","@object-ui/components","lucide-react","react-dom"],f):(P=typeof globalThis<"u"?globalThis:P||self,f(P.ObjectUIPluginGrid={},P.React,P.core,P.react,P.fields,P.components,P.lucideReact,P.ReactDOM))})(this,(function(P,f,_e,pe,Z,v,F,_t){"use strict";function Tt(e){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(o,t,r.get?r:{enumerable:!0,get:()=>e[t]})}}return o.default=e,Object.freeze(o)}const ze=Tt(f);var Ie={exports:{}},Te={};var Ye;function At(){if(Ye)return Te;Ye=1;var e=Symbol.for("react.transitional.element"),o=Symbol.for("react.fragment");function t(r,n,i){var a=null;if(i!==void 0&&(a=""+i),n.key!==void 0&&(a=""+n.key),"key"in n){i={};for(var l in n)l!=="key"&&(i[l]=n[l])}else i=n;return n=i.ref,{$$typeof:e,type:r,key:a,ref:n!==void 0?n:null,props:i}}return Te.Fragment=o,Te.jsx=t,Te.jsxs=t,Te}var Ae={};var Je;function Mt(){return Je||(Je=1,process.env.NODE_ENV!=="production"&&(function(){function e(u){if(u==null)return null;if(typeof u=="function")return u.$$typeof===de?null:u.displayName||u.name||null;if(typeof u=="string")return u;switch(u){case T:return"Fragment";case I:return"Profiler";case D:return"StrictMode";case J:return"Suspense";case le:return"SuspenseList";case Ee:return"Activity"}if(typeof u=="object")switch(typeof u.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),u.$$typeof){case w:return"Portal";case Y:return u.displayName||"Context";case L:return(u._context.displayName||"Context")+".Consumer";case q:var A=u.render;return u=u.displayName,u||(u=A.displayName||A.name||"",u=u!==""?"ForwardRef("+u+")":"ForwardRef"),u;case Me:return A=u.displayName||null,A!==null?A:e(u.type)||"Memo";case ve:A=u._payload,u=u._init;try{return e(u(A))}catch{}}return null}function o(u){return""+u}function t(u){try{o(u);var A=!1}catch{A=!0}if(A){A=console;var K=A.error,H=typeof Symbol=="function"&&Symbol.toStringTag&&u[Symbol.toStringTag]||u.constructor.name||"Object";return K.call(A,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",H),o(u)}}function r(u){if(u===T)return"<>";if(typeof u=="object"&&u!==null&&u.$$typeof===ve)return"<...>";try{var A=e(u);return A?"<"+A+">":"<...>"}catch{return"<...>"}}function n(){var u=ge.A;return u===null?null:u.getOwner()}function i(){return Error("react-stack-top-frame")}function a(u){if(V.call(u,"key")){var A=Object.getOwnPropertyDescriptor(u,"key").get;if(A&&A.isReactWarning)return!1}return u.key!==void 0}function l(u,A){function K(){ae||(ae=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",A))}K.isReactWarning=!0,Object.defineProperty(u,"key",{get:K,configurable:!0})}function p(){var u=e(this.type);return je[u]||(je[u]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),u=this.props.ref,u!==void 0?u:null}function h(u,A,K,H,we,ee){var R=K.ref;return u={$$typeof:C,type:u,key:A,props:K,_owner:H},(R!==void 0?R:null)!==null?Object.defineProperty(u,"ref",{enumerable:!1,get:p}):Object.defineProperty(u,"ref",{enumerable:!1,value:null}),u._store={},Object.defineProperty(u._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(u,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(u,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:we}),Object.defineProperty(u,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:ee}),Object.freeze&&(Object.freeze(u.props),Object.freeze(u)),u}function d(u,A,K,H,we,ee){var R=A.children;if(R!==void 0)if(H)if(Q(R)){for(H=0;H<R.length;H++)m(R[H]);Object.freeze&&Object.freeze(R)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else m(R);if(V.call(A,"key")){R=e(u);var X=Object.keys(A).filter(function(me){return me!=="key"});H=0<X.length?"{key: someKey, "+X.join(": ..., ")+": ...}":"{key: someKey}",xe[R+H]||(X=0<X.length?"{"+X.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
2
  let props = %s;
3
3
  <%s {...props} />
4
4
  React keys must be passed directly to JSX without using spread:
5
5
  let props = %s;
6
- <%s key={someKey} {...props} />`,H,R,X,R),xe[R+H]=!0)}if(R=null,K!==void 0&&(t(K),R=""+K),a(A)&&(t(A.key),R=""+A.key),"key"in A){K={};for(var ue in A)ue!=="key"&&(K[ue]=A[ue])}else K=A;return R&&o(K,typeof u=="function"?u.displayName||u.name||"Unknown":u),h(u,R,K,n(),we,ee)}function m(u){g(u)?u._store&&(u._store.validated=1):typeof u=="object"&&u!==null&&u.$$typeof===ve&&(u._payload.status==="fulfilled"?g(u._payload.value)&&u._payload.value._store&&(u._payload.value._store.validated=1):u._store&&(u._store.validated=1))}function g(u){return typeof u=="object"&&u!==null&&u.$$typeof===C}var b=f,C=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),oe=Symbol.for("react.suspense_list"),Me=Symbol.for("react.memo"),ve=Symbol.for("react.lazy"),Ee=Symbol.for("react.activity"),de=Symbol.for("react.client.reference"),ge=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,Q=Array.isArray,he=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(u){return u()}};var ae,je={},re=b.react_stack_bottom_frame.bind(b,i)(),be=he(r(i)),xe={};Ae.Fragment=T,Ae.jsx=function(u,A,K){var H=1e4>ge.recentlyCreatedOwnerStacks++;return d(u,A,K,!1,H?Error("react-stack-top-frame"):re,H?he(r(u)):be)},Ae.jsxs=function(u,A,K){var H=1e4>ge.recentlyCreatedOwnerStacks++;return d(u,A,K,!0,H?Error("react-stack-top-frame"):re,H?he(r(u)):be)}})()),Ae}var Xe;function Dt(){return Xe||(Xe=1,process.env.NODE_ENV==="production"?Ie.exports=At():Ie.exports=Mt()),Ie.exports}var s=Dt();function Ft(e){const{onRefresh:l,threshold:t=80,enabled:r=!0}=e,n=f.useRef(null),[i,a]=f.useState(!1),[o,p]=f.useState(0),h=f.useRef(0),d=f.useCallback(b=>{if(!r||i)return;const C=n.current;C&&C.scrollTop===0&&(h.current=b.touches[0].clientY)},[r,i]),m=f.useCallback(b=>{if(!r||i||!h.current)return;const w=b.touches[0].clientY-h.current;w>0&&p(Math.min(w,t*1.5))},[r,i,t]),g=f.useCallback(async()=>{if(!r||i)return;const b=o;if(p(0),h.current=0,b>=t){a(!0);try{await l()}finally{a(!1)}}},[r,i,o,t,l]);return f.useEffect(()=>{const b=n.current;if(!(!b||!r))return b.addEventListener("touchstart",d,{passive:!0}),b.addEventListener("touchmove",m,{passive:!0}),b.addEventListener("touchend",g,{passive:!0}),()=>{b.removeEventListener("touchstart",d),b.removeEventListener("touchmove",m),b.removeEventListener("touchend",g)}},[d,m,g,r]),{ref:n,isRefreshing:i,pullDistance:o}}const zt=f.createContext(null);zt.displayName="MobileContext";const It={red:"bg-red-100",green:"bg-green-100",blue:"bg-blue-100",yellow:"bg-yellow-100",orange:"bg-orange-100",purple:"bg-purple-100",pink:"bg-pink-100",gray:"bg-gray-100",grey:"bg-gray-100",indigo:"bg-indigo-100",teal:"bg-teal-100",cyan:"bg-cyan-100",amber:"bg-amber-100",lime:"bg-lime-100",emerald:"bg-emerald-100",rose:"bg-rose-100",sky:"bg-sky-100",violet:"bg-violet-100",fuchsia:"bg-fuchsia-100",slate:"bg-slate-100",zinc:"bg-zinc-100",stone:"bg-stone-100",neutral:"bg-neutral-100"};function Pt(e){if(e.startsWith("bg-"))return e;const l=e.toLowerCase().trim();return It[l]}function Qe(e){return f.useCallback(l=>{if(!e?.field||!e.colors)return;const t=String(l[e.field]??""),r=e.colors[t];if(r)return Pt(r)},[e?.field,e?.colors])}function Lt(e,l){return l.map(t=>String(e[t.field]??"")).join(" / ")}function Rt(e,l){return l.map(t=>{const r=e[t.field];return r!=null&&r!==""?String(r):"(empty)"}).join(" / ")}function $t(e,l){return l.map(({field:t,type:r})=>{const n=e.map(a=>Number(a[t])).filter(a=>Number.isFinite(a));let i;switch(r){case"count":i=n.length;break;case"sum":i=n.reduce((a,o)=>a+o,0);break;case"avg":i=n.length>0?n.reduce((a,o)=>a+o,0)/n.length:0;break;case"min":i=n.length>0?Math.min(...n):0;break;case"max":i=n.length>0?Math.max(...n):0;break;default:i=0}return{field:t,type:r,value:i}})}function Vt(e,l,t){const r=e.localeCompare(l,void 0,{numeric:!0,sensitivity:"base"});return t==="desc"?-r:r}function Ze(e,l,t){const r=e?.fields,n=!!(r&&r.length>0),[i,a]=f.useState({}),o=f.useMemo(()=>r?r.some(d=>d.collapsed):!1,[r]),p=f.useMemo(()=>{if(!n||!r)return[];const d=new Map,m=[];for(const b of l){const C=Lt(b,r);d.has(C)||(d.set(C,{label:Rt(b,r),rows:[]}),m.push(C)),d.get(C).rows.push(b)}const g=r[0]?.order??"asc";return m.sort((b,C)=>Vt(b,C,g)),m.map(b=>{const C=d.get(b),w=b in i?i[b]:o,T=t&&t.length>0?$t(C.rows,t):[];return{key:b,label:C.label,rows:C.rows,collapsed:w,aggregations:T}})},[l,r,n,i,o,t]),h=f.useCallback(d=>{a(m=>({...m,[d]:m[d]!==void 0?!m[d]:!o}))},[o]);return{groups:p,isGrouped:n,toggleGroup:h}}const et=({groupKey:e,label:l,count:t,collapsed:r,aggregations:n,onToggle:i,children:a})=>s.jsxs("div",{className:"border rounded-md","data-testid":`group-row-${e}`,children:[s.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors",onClick:()=>i(e),"aria-expanded":!r,children:[r?s.jsx(F.ChevronRight,{className:"h-4 w-4 shrink-0"}):s.jsx(F.ChevronDown,{className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"group-label",children:l}),n&&n.length>0&&s.jsx("span",{className:"ml-2 text-xs text-muted-foreground group-aggregations",children:n.map(o=>s.jsxs("span",{className:"mr-2",children:[o.type,": ",Number.isInteger(o.value)?o.value:o.value.toFixed(2)]},`${o.field}-${o.type}`))}),s.jsxs("span",{className:"ml-auto text-xs text-muted-foreground group-count",children:["(",t,")"]})]}),!r&&a]});function Kt(e){return typeof e=="string"?{type:e}:e}function Bt(e,l){if(l.length===0)return null;switch(e){case"count":return l.length;case"sum":return l.reduce((t,r)=>t+r,0);case"avg":return l.reduce((t,r)=>t+r,0)/l.length;case"min":return Math.min(...l);case"max":return Math.max(...l);default:return null}}function Wt(e,l){if(l===null)return"";const r={count:"Count",sum:"Sum",avg:"Avg",min:"Min",max:"Max"}[e]||e,n=e==="avg"?l.toLocaleString(void 0,{maximumFractionDigits:2}):l.toLocaleString();return`${r}: ${n}`}function tt(e,l){return f.useMemo(()=>{const t=new Map;if(!e||e.length===0||l.length===0)return{summaries:t,hasSummary:!1};for(const r of e){if(!r.summary)continue;const n=Kt(r.summary),i=n.field||r.field,a=[];for(const p of l){const h=p[i];if(h!=null&&typeof h=="number"&&!isNaN(h))a.push(h);else if(h!=null&&typeof h=="string"){const d=parseFloat(h);isNaN(d)||a.push(d)}}let o;if(n.type==="count"){const p=l.filter(h=>h[i]!=null&&h[i]!=="").length;o=p>0?p:null}else o=Bt(n.type,a);t.set(r.field,{field:r.field,value:o,label:Wt(n.type,o)})}return{summaries:t,hasSummary:t.size>0}},[e,l])}function Pe(e){return e.replace(/_/g," ").replace(/\b\w/g,l=>l.toUpperCase())}const st=({row:e,rowActions:l,canEdit:t,canDelete:r,onEdit:n,onDelete:i,onAction:a})=>s.jsxs(v.DropdownMenu,{children:[s.jsx(v.DropdownMenuTrigger,{asChild:!0,children:s.jsxs(v.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0","data-testid":"row-action-trigger",children:[s.jsx(F.MoreVertical,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Open menu"})]})}),s.jsxs(v.DropdownMenuContent,{align:"end",children:[t&&n&&s.jsxs(v.DropdownMenuItem,{onClick:()=>n(e),children:[s.jsx(F.Edit,{className:"mr-2 h-4 w-4"}),"Edit"]}),r&&i&&s.jsxs(v.DropdownMenuItem,{onClick:()=>i(e),children:[s.jsx(F.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]}),l?.map(o=>s.jsx(v.DropdownMenuItem,{onClick:()=>a?.(o,e),"data-testid":`row-action-${o}`,children:Pe(o)},o))]})]}),We=({selectedRows:e,actions:l,onAction:t,onClearSelection:r})=>!l||l.length===0||e.length===0?null:s.jsxs("div",{className:"border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0","data-testid":"bulk-actions-bar",children:[s.jsxs("span",{className:"text-muted-foreground font-medium",children:[e.length," selected"]}),s.jsx("div",{className:"flex items-center gap-1 ml-2",children:l.map(n=>s.jsx(v.Button,{variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>t?.(n,e),"data-testid":`bulk-action-${n}`,children:Pe(n)},n))}),s.jsx(v.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs ml-auto",onClick:r,children:"Clear"})]}),rt={"grid.actions":"Actions","grid.edit":"Edit","grid.delete":"Delete","grid.export":"Export","grid.exportAs":"Export as {{format}}","grid.loading":"Loading grid...","grid.errorLoading":"Error loading grid","grid.pullToRefresh":"Pull to refresh","grid.refreshing":"Refreshing…","grid.openRecord":"Open record"};function qt(){try{const e=pe.useObjectTranslation();return e.t("grid.actions")==="grid.actions"?{t:(t,r)=>{let n=rt[t]||t;if(r)for(const[i,a]of Object.entries(r))n=n.replace(`{{${i}}}`,String(a));return n}}:{t:e.t}}catch{return{t:(e,l)=>{let t=rt[e]||e;if(l)for(const[r,n]of Object.entries(l))t=t.replace(`{{${r}}}`,String(n));return t}}}}function Gt(e){return e.data?Array.isArray(e.data)?{provider:"value",items:e.data}:e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function qe(e){if(!(!e||e.length===0))return typeof e[0]=="object"&&e[0]!==null,e}const nt=({schema:e,dataSource:l,onEdit:t,onDelete:r,onRowSelect:n,onRowClick:i,onCellChange:a,onRowSave:o,onBatchSave:p,onAddRecord:h,...d})=>{const[m,g]=f.useState([]),[b,C]=f.useState(!0),[w,T]=f.useState(null),{t:D}=qt(),{fieldLabel:I}=pe.useSafeFieldLabel(),[L,Y]=f.useState(null),[q,J]=f.useState(!1),[oe,Me]=f.useState(0),[ve,Ee]=f.useState(!1),[de,ge]=f.useState(e.rowHeight??"compact"),[V,Q]=f.useState([]),he=f.useMemo(()=>e.id?`grid-columns-${e.objectName}-${e.id}`:`grid-columns-${e.objectName}`,[e.objectName,e.id]),[ae,je]=f.useState(()=>{try{const c=localStorage.getItem(he);return c?JSON.parse(c):{}}catch{return{}}}),re=f.useCallback(c=>{je(c);try{localStorage.setItem(he,JSON.stringify(c))}catch(M){console.warn("Failed to persist column state:",M)}},[he]),be=f.useCallback(async()=>{Me(c=>c+1)},[]),{ref:xe,isRefreshing:u,pullDistance:A}=Ft({onRefresh:be,enabled:!!l&&!!e.objectName});f.useEffect(()=>{const c=()=>J(window.innerWidth<480);return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]);const K=d.data,H=pe.useDataScope(e.bind),we=Gt(e),ee=f.useMemo(()=>K&&Array.isArray(K)?{provider:"value",items:K}:H&&Array.isArray(H)?{provider:"value",items:H}:we,[JSON.stringify(we),H,K]),R=ee?.provider==="value",X=ee?.provider==="object"&&ee&&"object"in ee?ee.object:e.objectName,ue=e.fields,me=e.columns,Le=e.filter,ke=e.sort,pt=e.pagination,gt=e.pageSize;f.useEffect(()=>{R&&ee?.provider==="value"&&(g(c=>{const M=ee.items;return JSON.stringify(c)!==JSON.stringify(M)?M:c}),C(!1))},[R,ee]),f.useEffect(()=>{if(!R||!X||!l)return;let c=!1;return(async()=>{try{const k=await l.getObjectSchema(X);c||Y(k)}catch(k){console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${X}):`,k)}})(),()=>{c=!0}},[R,X,l]),f.useEffect(()=>{if(R)return;let c=!1;return(async()=>{C(!0),T(null);try{let k=null;const U=qe(me)||ue;if(X&&l){const te=await l.getObjectSchema(X);if(c)return;k=te}else if(U&&X)k={name:X,fields:{}};else throw X?new Error("DataSource required"):new Error("Object name required for data fetching");if(c||Y(k),l&&X){const j={$select:(()=>{if(ue)return ue;if(me&&Array.isArray(me))return me.map(N=>typeof N=="string"?N:N.field)})(),$top:pt?.pageSize||gt||50};Le&&Array.isArray(Le)?j.$filter=Le:e.defaultFilters&&(j.$filter=e.defaultFilters),ke?typeof ke=="string"?j.$orderby=ke:Array.isArray(ke)&&(j.$orderby=ke.map(N=>`${N.field} ${N.order}`).join(", ")):e.defaultSort&&(j.$orderby=`${e.defaultSort.field} ${e.defaultSort.order}`);const x=_e.buildExpandFields(k?.fields,me??ue);x.length>0&&(j.$expand=x);const S=await l.find(X,j);if(c)return;g(S.data||[])}}catch(k){c||T(k)}finally{c||C(!1)}})(),()=>{c=!0}},[X,ue,me,Le,ke,pt,gt,l,R,ee,oe]);const ne=pe.useNavigationOverlay({navigation:e.navigation,objectName:e.objectName,onNavigate:e.onNavigate,onRowClick:i}),{execute:De}=pe.useAction(),Cs=Qe(e.rowColor),Ns=f.useCallback(c=>{const M=e.conditionalFormatting;if(!(!M||M.length===0))for(const k of M){let U=!1;const te=("condition"in k?k.condition:void 0)||("expression"in k?k.expression:void 0)||void 0;if(te)U=_e.evaluatePlainCondition(te,c);else if("field"in k&&"operator"in k&&k.field&&k.operator){const j=k,x=c[j.field];switch(j.operator){case"equals":U=x===j.value;break;case"not_equals":U=x!==j.value;break;case"contains":U=typeof x=="string"&&typeof j.value=="string"&&x.includes(j.value);break;case"greater_than":U=typeof x=="number"&&typeof j.value=="number"&&x>j.value;break;case"less_than":U=typeof x=="number"&&typeof j.value=="number"&&x<j.value;break;case"in":U=Array.isArray(j.value)&&j.value.includes(x);break}}if(U){const j={};return"style"in k&&k.style&&Object.assign(j,k.style),"backgroundColor"in k&&k.backgroundColor&&(j.backgroundColor=k.backgroundColor),"textColor"in k&&k.textColor&&(j.color=k.textColor),"borderColor"in k&&k.borderColor&&(j.borderColor=k.borderColor),j}}},[e.conditionalFormatting]),{groups:Ss,isGrouped:xt,toggleGroup:Es}=Ze(e.grouping,m),ks=f.useMemo(()=>{const c=qe(e.columns);if(c&&c.length>0&&typeof c[0]=="object")return c},[e.columns]),{summaries:bt,hasSummary:Os}=tt(ks,m),Re=f.useCallback(()=>{const c=j=>j?{text:s.jsx(F.Type,{className:"h-3.5 w-3.5"}),number:s.jsx(F.Hash,{className:"h-3.5 w-3.5"}),currency:s.jsx(F.Hash,{className:"h-3.5 w-3.5"}),percent:s.jsx(F.Hash,{className:"h-3.5 w-3.5"}),date:s.jsx(F.Calendar,{className:"h-3.5 w-3.5"}),datetime:s.jsx(F.Clock,{className:"h-3.5 w-3.5"}),boolean:s.jsx(F.CheckSquare,{className:"h-3.5 w-3.5"}),user:s.jsx(F.User,{className:"h-3.5 w-3.5"}),select:s.jsx(F.Tag,{className:"h-3.5 w-3.5"})}[j]||s.jsx(F.Type,{className:"h-3.5 w-3.5"}):s.jsx(F.Type,{className:"h-3.5 w-3.5"}),M=j=>{if(j.type)return j.type;const x=j.field.toLowerCase();if(["completed","is_completed","done","active","enabled","archived"].some(O=>x===O||x===`is_${O}`))return"boolean";if(["created_time","modified_time","updated_time","created_at","updated_at","modified_at","last_login","logged_at"].some(O=>x===O||x.endsWith(`_${O}`)))return"datetime";if(["date","due","created","updated","deadline","start","end","expires"].some(O=>x.includes(O))){if(m.length>0){const O=m.find($=>$[j.field]!=null)?.[j.field];if(typeof O=="string"&&!isNaN(Date.parse(O)))return"date"}return"date"}if(["probability","percent","percentage","completion","progress","rate"].some(O=>x.includes(O))&&m.length>0&&typeof m.find($=>$[j.field]!=null)?.[j.field]=="number")return"percent";if(["status","priority","category","stage","type","severity","level"].some(O=>x.includes(O))&&m.length>0){const O=new Set(m.map($=>$[j.field]).filter(Boolean));if(O.size>0&&O.size<=10)return"select"}if(["assignee","owner","author","reporter","creator","user"].some(O=>x.includes(O)))return"user";if(["amount","price","total","revenue","cost","budget","salary"].some(O=>x.includes(O))&&m.length>0&&typeof m.find($=>$[j.field]!=null)?.[j.field]=="number")return"currency";if(m.length>0){const O=m.find($=>$[j.field]!=null)?.[j.field];if(typeof O=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(O))return"datetime"}return null},k=qe(me);if(k){if(k.length>0&&typeof k[0]=="object"&&k[0]!==null){const j=k[0];if("accessorKey"in j)return k.map(x=>{if(x.cell)return x;const S={field:x.accessorKey,label:x.header,type:x.type},N=M(S);if(!N)return x;const z=Z.getCellRenderer(N),E={name:x.accessorKey,type:N};if(N==="select"){const y=Array.from(new Set(m.map(_=>_[x.accessorKey]).filter(Boolean)));E.options=y.map(_=>({value:_,label:Z.humanizeLabel(String(_))}))}return{...x,headerIcon:c(N),cell:y=>s.jsx(z,{value:y,field:E})}});if("field"in j)return k.filter(x=>x?.field&&typeof x.field=="string"&&!x.hidden).map((x,S)=>{const N=x.label||x.field.charAt(0).toUpperCase()+x.field.slice(1).replace(/_/g," "),z=e.objectName?I(e.objectName,x.field,N):N;let E;const y=L?.fields?.[x.field],_=x.type||y?.type||M({field:x.field})||null,B=_?Z.getCellRenderer(_):null,O={name:x.field,type:_||"text"};if(y&&(y.label&&(O.label=y.label),y.currency&&(O.currency=y.currency),y.precision!==void 0&&(O.precision=y.precision),y.format&&(O.format=y.format),y.options&&(O.options=y.options)),_==="select"&&!O.options){const G=Array.from(new Set(m.map(ce=>ce[x.field]).filter(Boolean)));O.options=G.map(ce=>({value:ce,label:Z.humanizeLabel(String(ce))}))}x.options&&(O.options=x.options);const $=S===0&&!x.link&&!x.action,se=x.link||$;x.link&&x.action||$&&x.action?E=(G,ce)=>{const Ne=B?s.jsx(B,{value:G,field:O}):G!=null&&G!==""?String(G):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});return s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":$?"primary-field-link":"link-cell",onClick:Oe=>{Oe.stopPropagation(),ne.handleClick(ce)},children:Ne})}:se?E=(G,ce)=>{const Ne=B?s.jsx(B,{value:G,field:O}):G!=null&&G!==""?String(G):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});return s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":$?"primary-field-link":"link-cell",onClick:Oe=>{Oe.stopPropagation(),ne.handleClick(ce)},children:Ne})}:x.action?E=(G,ce)=>s.jsx(v.Button,{variant:"outline",size:"sm",className:"h-7 text-xs","data-testid":"action-cell",onClick:Ne=>{Ne.stopPropagation(),De({type:x.action,params:{record:ce,field:x.field,value:G}})},children:Pe(x.action)}):B?E=G=>s.jsx(B,{value:G,field:O}):E=G=>G!=null&&G!==""?s.jsx("span",{children:String(G)}):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});const fe=x.prefix;if(fe?.field){const G=E,ce=fe.type==="badge"?Z.getCellRenderer("select"):null;E=(Ne,Oe)=>{const Be=Oe[fe.field],Vs=Be!=null&&Be!==""?ce?s.jsx(ce,{value:Be,field:{name:fe.field,type:"select"}}):s.jsx("span",{className:"text-muted-foreground text-xs mr-1.5",children:String(Be)}):null;return s.jsxs("span",{className:"flex items-center gap-1.5",children:[Vs,G(Ne,Oe)]})}}const ie=["number","currency","percent"],le=_||x.type,ye=x.align||(le&&ie.includes(le)?"right":void 0),W=S===0||x.essential===!0;return{header:z,accessorKey:x.field,headerIcon:c(_),...!W&&{className:"hidden sm:table-cell"},...x.width&&{width:x.width},...ye&&{align:ye},sortable:x.sortable!==!1,...x.resizable!==void 0&&{resizable:x.resizable},...x.wrap!==void 0&&{wrap:x.wrap},...E&&{cell:E},...x.pinned&&{pinned:x.pinned}}})}return k.filter(j=>typeof j=="string"&&j.trim().length>0).map((j,x)=>{const S=L?.fields?.[j],z=S?.label||j.charAt(0).toUpperCase()+j.slice(1).replace(/_/g," "),E=e.objectName?I(e.objectName,j,z):z,y=S?.type||M({field:j})||null,_=y?Z.getCellRenderer(y):null,B={name:j,type:y||"text"};if(S&&(S.label&&(B.label=S.label),S.currency&&(B.currency=S.currency),S.precision!==void 0&&(B.precision=S.precision),S.format&&(B.format=S.format),S.options&&(B.options=S.options)),y==="select"&&!B.options){const ie=Array.from(new Set(m.map(le=>le[j]).filter(Boolean)));B.options=ie.map(le=>({value:le,label:Z.humanizeLabel(String(le))}))}const $=y&&["number","currency","percent"].includes(y)?"right":void 0,se=x===0;let fe;return se&&_?fe=(ie,le)=>{const ye=s.jsx(_,{value:ie,field:B});return s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":"primary-field-link",onClick:W=>{W.stopPropagation(),ne.handleClick(le)},children:ye})}:se?fe=(ie,le)=>s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":"primary-field-link",onClick:ye=>{ye.stopPropagation(),ne.handleClick(le)},children:ie!=null&&ie!==""?String(ie):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"})}):_&&(fe=ie=>s.jsx(_,{value:ie,field:B})),{header:E,accessorKey:j,...y&&{headerIcon:c(y)},...$&&{align:$},...fe&&{cell:fe},sortable:S?.sortable!==!1}})}if(R){const j=ee?.provider==="value"?ee.items:[];if(j.length>0)return(ue||Object.keys(j[0])).map(S=>{const N=L?.fields?.[S],z=N?.type||M({field:S})||null,E=z?Z.getCellRenderer(z):null,y=N?.label||S.charAt(0).toUpperCase()+S.slice(1).replace(/_/g," "),_={name:S,type:z||"text"};if(N&&(N.label&&(_.label=N.label),N.currency&&(_.currency=N.currency),N.precision!==void 0&&(_.precision=N.precision),N.format&&(_.format=N.format),N.options&&(_.options=N.options)),z==="select"&&!_.options){const $=Array.from(new Set(m.map(se=>se[S]).filter(Boolean)));_.options=$.map(se=>({value:se,label:Z.humanizeLabel(String(se))}))}const O=z&&["number","currency","percent"].includes(z)?"right":void 0;return{header:y,accessorKey:S,...z&&{headerIcon:c(z)},...O&&{align:O},...E&&{cell:$=>s.jsx(E,{value:$,field:_})},sortable:N?.sortable!==!1}})}if(!L)return[];const U=[];return(ue||Object.keys(L.fields||{})).forEach(j=>{const x=L.fields?.[j];if(!x||x.permissions&&x.permissions.read===!1)return;const S=Z.getCellRenderer(x.type),N=["number","currency","percent"];U.push({header:e.objectName?I(e.objectName,j,x.label||j):x.label||j,accessorKey:j,...N.includes(x.type)&&{align:"right"},cell:z=>s.jsx(S,{value:z,field:x}),sortable:x.sortable!==!1})}),U},[L,ue,me,ee,R,ne.handleClick,De,m,I,e.objectName]),_s=f.useCallback(c=>{const M=e.exportOptions,k=M?.maxRecords||0,U=M?.includeHeaders!==!1,te=M?.fileNamePrefix||e.objectName||"export",j=k>0?m.slice(0,k):m,x=(N,z)=>{const E=URL.createObjectURL(N),y=document.createElement("a");y.href=E,y.download=z,y.click(),URL.revokeObjectURL(E)},S=N=>{const z=N==null?"":String(N);return z.includes(",")||z.includes('"')||z.includes(`
6
+ <%s key={someKey} {...props} />`,H,R,X,R),xe[R+H]=!0)}if(R=null,K!==void 0&&(t(K),R=""+K),a(A)&&(t(A.key),R=""+A.key),"key"in A){K={};for(var ue in A)ue!=="key"&&(K[ue]=A[ue])}else K=A;return R&&l(K,typeof u=="function"?u.displayName||u.name||"Unknown":u),h(u,R,K,n(),we,ee)}function m(u){g(u)?u._store&&(u._store.validated=1):typeof u=="object"&&u!==null&&u.$$typeof===ve&&(u._payload.status==="fulfilled"?g(u._payload.value)&&u._payload.value._store&&(u._payload.value._store.validated=1):u._store&&(u._store.validated=1))}function g(u){return typeof u=="object"&&u!==null&&u.$$typeof===C}var b=f,C=Symbol.for("react.transitional.element"),w=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),D=Symbol.for("react.strict_mode"),I=Symbol.for("react.profiler"),L=Symbol.for("react.consumer"),Y=Symbol.for("react.context"),q=Symbol.for("react.forward_ref"),J=Symbol.for("react.suspense"),le=Symbol.for("react.suspense_list"),Me=Symbol.for("react.memo"),ve=Symbol.for("react.lazy"),Ee=Symbol.for("react.activity"),de=Symbol.for("react.client.reference"),ge=b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,V=Object.prototype.hasOwnProperty,Q=Array.isArray,he=console.createTask?console.createTask:function(){return null};b={react_stack_bottom_frame:function(u){return u()}};var ae,je={},re=b.react_stack_bottom_frame.bind(b,i)(),be=he(r(i)),xe={};Ae.Fragment=T,Ae.jsx=function(u,A,K){var H=1e4>ge.recentlyCreatedOwnerStacks++;return d(u,A,K,!1,H?Error("react-stack-top-frame"):re,H?he(r(u)):be)},Ae.jsxs=function(u,A,K){var H=1e4>ge.recentlyCreatedOwnerStacks++;return d(u,A,K,!0,H?Error("react-stack-top-frame"):re,H?he(r(u)):be)}})()),Ae}var Xe;function Dt(){return Xe||(Xe=1,process.env.NODE_ENV==="production"?Ie.exports=At():Ie.exports=Mt()),Ie.exports}var s=Dt();function Ft(e){const{onRefresh:o,threshold:t=80,enabled:r=!0}=e,n=f.useRef(null),[i,a]=f.useState(!1),[l,p]=f.useState(0),h=f.useRef(0),d=f.useCallback(b=>{if(!r||i)return;const C=n.current;C&&C.scrollTop===0&&(h.current=b.touches[0].clientY)},[r,i]),m=f.useCallback(b=>{if(!r||i||!h.current)return;const w=b.touches[0].clientY-h.current;w>0&&p(Math.min(w,t*1.5))},[r,i,t]),g=f.useCallback(async()=>{if(!r||i)return;const b=l;if(p(0),h.current=0,b>=t){a(!0);try{await o()}finally{a(!1)}}},[r,i,l,t,o]);return f.useEffect(()=>{const b=n.current;if(!(!b||!r))return b.addEventListener("touchstart",d,{passive:!0}),b.addEventListener("touchmove",m,{passive:!0}),b.addEventListener("touchend",g,{passive:!0}),()=>{b.removeEventListener("touchstart",d),b.removeEventListener("touchmove",m),b.removeEventListener("touchend",g)}},[d,m,g,r]),{ref:n,isRefreshing:i,pullDistance:l}}const zt=f.createContext(null);zt.displayName="MobileContext";const It={red:"bg-red-100",green:"bg-green-100",blue:"bg-blue-100",yellow:"bg-yellow-100",orange:"bg-orange-100",purple:"bg-purple-100",pink:"bg-pink-100",gray:"bg-gray-100",grey:"bg-gray-100",indigo:"bg-indigo-100",teal:"bg-teal-100",cyan:"bg-cyan-100",amber:"bg-amber-100",lime:"bg-lime-100",emerald:"bg-emerald-100",rose:"bg-rose-100",sky:"bg-sky-100",violet:"bg-violet-100",fuchsia:"bg-fuchsia-100",slate:"bg-slate-100",zinc:"bg-zinc-100",stone:"bg-stone-100",neutral:"bg-neutral-100"};function Pt(e){if(e.startsWith("bg-"))return e;const o=e.toLowerCase().trim();return It[o]}function Qe(e){return f.useCallback(o=>{if(!e?.field||!e.colors)return;const t=String(o[e.field]??""),r=e.colors[t];if(r)return Pt(r)},[e?.field,e?.colors])}function Lt(e,o){return o.map(t=>String(e[t.field]??"")).join(" / ")}function Rt(e,o){return o.map(t=>{const r=e[t.field];return r!=null&&r!==""?String(r):"(empty)"}).join(" / ")}function $t(e,o){return o.map(({field:t,type:r})=>{const n=e.map(a=>Number(a[t])).filter(a=>Number.isFinite(a));let i;switch(r){case"count":i=n.length;break;case"sum":i=n.reduce((a,l)=>a+l,0);break;case"avg":i=n.length>0?n.reduce((a,l)=>a+l,0)/n.length:0;break;case"min":i=n.length>0?Math.min(...n):0;break;case"max":i=n.length>0?Math.max(...n):0;break;default:i=0}return{field:t,type:r,value:i}})}function Vt(e,o,t){const r=e.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"});return t==="desc"?-r:r}function Ze(e,o,t){const r=e?.fields,n=!!(r&&r.length>0),[i,a]=f.useState({}),l=f.useMemo(()=>r?r.some(d=>d.collapsed):!1,[r]),p=f.useMemo(()=>{if(!n||!r)return[];const d=new Map,m=[];for(const b of o){const C=Lt(b,r);d.has(C)||(d.set(C,{label:Rt(b,r),rows:[]}),m.push(C)),d.get(C).rows.push(b)}const g=r[0]?.order??"asc";return m.sort((b,C)=>Vt(b,C,g)),m.map(b=>{const C=d.get(b),w=b in i?i[b]:l,T=t&&t.length>0?$t(C.rows,t):[];return{key:b,label:C.label,rows:C.rows,collapsed:w,aggregations:T}})},[o,r,n,i,l,t]),h=f.useCallback(d=>{a(m=>({...m,[d]:m[d]!==void 0?!m[d]:!l}))},[l]);return{groups:p,isGrouped:n,toggleGroup:h}}const et=({groupKey:e,label:o,count:t,collapsed:r,aggregations:n,onToggle:i,children:a})=>s.jsxs("div",{className:"border rounded-md","data-testid":`group-row-${e}`,children:[s.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 px-3 py-2 text-sm font-medium text-left bg-muted/50 hover:bg-muted transition-colors",onClick:()=>i(e),"aria-expanded":!r,children:[r?s.jsx(F.ChevronRight,{className:"h-4 w-4 shrink-0"}):s.jsx(F.ChevronDown,{className:"h-4 w-4 shrink-0"}),s.jsx("span",{className:"group-label",children:o}),n&&n.length>0&&s.jsx("span",{className:"ml-2 text-xs text-muted-foreground group-aggregations",children:n.map(l=>s.jsxs("span",{className:"mr-2",children:[l.type,": ",Number.isInteger(l.value)?l.value:l.value.toFixed(2)]},`${l.field}-${l.type}`))}),s.jsxs("span",{className:"ml-auto text-xs text-muted-foreground group-count",children:["(",t,")"]})]}),!r&&a]});function Kt(e){return typeof e=="string"?{type:e}:e}function Bt(e,o){if(o.length===0)return null;switch(e){case"count":return o.length;case"sum":return o.reduce((t,r)=>t+r,0);case"avg":return o.reduce((t,r)=>t+r,0)/o.length;case"min":return Math.min(...o);case"max":return Math.max(...o);default:return null}}function Wt(e,o){if(o===null)return"";const r={count:"Count",sum:"Sum",avg:"Avg",min:"Min",max:"Max"}[e]||e,n=e==="avg"?o.toLocaleString(void 0,{maximumFractionDigits:2}):o.toLocaleString();return`${r}: ${n}`}function tt(e,o){return f.useMemo(()=>{const t=new Map;if(!e||e.length===0||o.length===0)return{summaries:t,hasSummary:!1};for(const r of e){if(!r.summary)continue;const n=Kt(r.summary),i=n.field||r.field,a=[];for(const p of o){const h=p[i];if(h!=null&&typeof h=="number"&&!isNaN(h))a.push(h);else if(h!=null&&typeof h=="string"){const d=parseFloat(h);isNaN(d)||a.push(d)}}let l;if(n.type==="count"){const p=o.filter(h=>h[i]!=null&&h[i]!=="").length;l=p>0?p:null}else l=Bt(n.type,a);t.set(r.field,{field:r.field,value:l,label:Wt(n.type,l)})}return{summaries:t,hasSummary:t.size>0}},[e,o])}function Pe(e){return e.replace(/_/g," ").replace(/\b\w/g,o=>o.toUpperCase())}const st=({row:e,rowActions:o,canEdit:t,canDelete:r,onEdit:n,onDelete:i,onAction:a})=>s.jsxs(v.DropdownMenu,{children:[s.jsx(v.DropdownMenuTrigger,{asChild:!0,children:s.jsxs(v.Button,{variant:"ghost",size:"icon",className:"h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0","data-testid":"row-action-trigger",children:[s.jsx(F.MoreVertical,{className:"h-4 w-4"}),s.jsx("span",{className:"sr-only",children:"Open menu"})]})}),s.jsxs(v.DropdownMenuContent,{align:"end",children:[t&&n&&s.jsxs(v.DropdownMenuItem,{onClick:()=>n(e),children:[s.jsx(F.Edit,{className:"mr-2 h-4 w-4"}),"Edit"]}),r&&i&&s.jsxs(v.DropdownMenuItem,{onClick:()=>i(e),children:[s.jsx(F.Trash2,{className:"mr-2 h-4 w-4"}),"Delete"]}),o?.map(l=>s.jsx(v.DropdownMenuItem,{onClick:()=>a?.(l,e),"data-testid":`row-action-${l}`,children:Pe(l)},l))]})]}),We=({selectedRows:e,actions:o,onAction:t,onClearSelection:r})=>!o||o.length===0||e.length===0?null:s.jsxs("div",{className:"border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0","data-testid":"bulk-actions-bar",children:[s.jsxs("span",{className:"text-muted-foreground font-medium",children:[e.length," selected"]}),s.jsx("div",{className:"flex items-center gap-1 ml-2",children:o.map(n=>s.jsx(v.Button,{variant:"outline",size:"sm",className:"h-6 px-2 text-xs",onClick:()=>t?.(n,e),"data-testid":`bulk-action-${n}`,children:Pe(n)},n))}),s.jsx(v.Button,{variant:"ghost",size:"sm",className:"h-6 px-2 text-xs ml-auto",onClick:r,children:"Clear"})]}),rt={"grid.actions":"Actions","grid.edit":"Edit","grid.delete":"Delete","grid.export":"Export","grid.exportAs":"Export as {{format}}","grid.loading":"Loading grid...","grid.errorLoading":"Error loading grid","grid.pullToRefresh":"Pull to refresh","grid.refreshing":"Refreshing…","grid.openRecord":"Open record"};function qt(){try{const e=pe.useObjectTranslation();return e.t("grid.actions")==="grid.actions"?{t:(t,r)=>{let n=rt[t]||t;if(r)for(const[i,a]of Object.entries(r))n=n.replace(`{{${i}}}`,String(a));return n}}:{t:e.t}}catch{return{t:(e,o)=>{let t=rt[e]||e;if(o)for(const[r,n]of Object.entries(o))t=t.replace(`{{${r}}}`,String(n));return t}}}}function Gt(e){if(e!=null)return typeof e=="string"?e:e.defaultValue||e.key}function Ht(e){return e.data?Array.isArray(e.data)?{provider:"value",items:e.data}:e.data:e.staticData?{provider:"value",items:e.staticData}:e.objectName?{provider:"object",object:e.objectName}:null}function qe(e){if(!(!e||e.length===0))return typeof e[0]=="object"&&e[0]!==null,e}const nt=({schema:e,dataSource:o,onEdit:t,onDelete:r,onRowSelect:n,onRowClick:i,onCellChange:a,onRowSave:l,onBatchSave:p,onAddRecord:h,...d})=>{const[m,g]=f.useState([]),[b,C]=f.useState(!0),[w,T]=f.useState(null),{t:D}=qt(),{fieldLabel:I}=pe.useSafeFieldLabel(),[L,Y]=f.useState(null),[q,J]=f.useState(!1),[le,Me]=f.useState(0),[ve,Ee]=f.useState(!1),[de,ge]=f.useState(e.rowHeight??"compact"),[V,Q]=f.useState([]),he=f.useMemo(()=>e.id?`grid-columns-${e.objectName}-${e.id}`:`grid-columns-${e.objectName}`,[e.objectName,e.id]),[ae,je]=f.useState(()=>{try{const c=localStorage.getItem(he);return c?JSON.parse(c):{}}catch{return{}}}),re=f.useCallback(c=>{je(c);try{localStorage.setItem(he,JSON.stringify(c))}catch(M){console.warn("Failed to persist column state:",M)}},[he]),be=f.useCallback(async()=>{Me(c=>c+1)},[]),{ref:xe,isRefreshing:u,pullDistance:A}=Ft({onRefresh:be,enabled:!!o&&!!e.objectName});f.useEffect(()=>{const c=()=>J(window.innerWidth<480);return c(),window.addEventListener("resize",c),()=>window.removeEventListener("resize",c)},[]);const K=d.data,H=pe.useDataScope(e.bind),we=Ht(e),ee=f.useMemo(()=>K&&Array.isArray(K)?{provider:"value",items:K}:H&&Array.isArray(H)?{provider:"value",items:H}:we,[JSON.stringify(we),H,K]),R=ee?.provider==="value",X=ee?.provider==="object"&&ee&&"object"in ee?ee.object:e.objectName,ue=e.fields,me=e.columns,Le=e.filter,ke=e.sort,pt=e.pagination,gt=e.pageSize;f.useEffect(()=>{R&&ee?.provider==="value"&&(g(c=>{const M=ee.items;return JSON.stringify(c)!==JSON.stringify(M)?M:c}),C(!1))},[R,ee]),f.useEffect(()=>{if(!R||!X||!o)return;let c=!1;return(async()=>{try{const k=await o.getObjectSchema(X);c||Y(k)}catch(k){console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${X}):`,k)}})(),()=>{c=!0}},[R,X,o]),f.useEffect(()=>{if(R)return;let c=!1;return(async()=>{C(!0),T(null);try{let k=null;const U=qe(me)||ue;if(X&&o){const te=await o.getObjectSchema(X);if(c)return;k=te}else if(U&&X)k={name:X,fields:{}};else throw X?new Error("DataSource required"):new Error("Object name required for data fetching");if(c||Y(k),o&&X){const j={$select:(()=>{if(ue)return ue;if(me&&Array.isArray(me))return me.map(N=>typeof N=="string"?N:N.field)})(),$top:pt?.pageSize||gt||50};Le&&Array.isArray(Le)?j.$filter=Le:e.defaultFilters&&(j.$filter=e.defaultFilters),ke?typeof ke=="string"?j.$orderby=ke:Array.isArray(ke)&&(j.$orderby=ke.map(N=>`${N.field} ${N.order}`).join(", ")):e.defaultSort&&(j.$orderby=`${e.defaultSort.field} ${e.defaultSort.order}`);const x=_e.buildExpandFields(k?.fields,me??ue);x.length>0&&(j.$expand=x);const S=await o.find(X,j);if(c)return;g(S.data||[])}}catch(k){c||T(k)}finally{c||C(!1)}})(),()=>{c=!0}},[X,ue,me,Le,ke,pt,gt,o,R,ee,le]);const ne=pe.useNavigationOverlay({navigation:e.navigation,objectName:e.objectName,onNavigate:e.onNavigate,onRowClick:i}),{execute:De}=pe.useAction(),Ns=Qe(e.rowColor),Ss=f.useCallback(c=>{const M=e.conditionalFormatting;if(!(!M||M.length===0))for(const k of M){let U=!1;const te=("condition"in k?k.condition:void 0)||("expression"in k?k.expression:void 0)||void 0;if(te)U=_e.evaluatePlainCondition(te,c);else if("field"in k&&"operator"in k&&k.field&&k.operator){const j=k,x=c[j.field];switch(j.operator){case"equals":U=x===j.value;break;case"not_equals":U=x!==j.value;break;case"contains":U=typeof x=="string"&&typeof j.value=="string"&&x.includes(j.value);break;case"greater_than":U=typeof x=="number"&&typeof j.value=="number"&&x>j.value;break;case"less_than":U=typeof x=="number"&&typeof j.value=="number"&&x<j.value;break;case"in":U=Array.isArray(j.value)&&j.value.includes(x);break}}if(U){const j={};return"style"in k&&k.style&&Object.assign(j,k.style),"backgroundColor"in k&&k.backgroundColor&&(j.backgroundColor=k.backgroundColor),"textColor"in k&&k.textColor&&(j.color=k.textColor),"borderColor"in k&&k.borderColor&&(j.borderColor=k.borderColor),j}}},[e.conditionalFormatting]),{groups:Es,isGrouped:xt,toggleGroup:ks}=Ze(e.grouping,m),Os=f.useMemo(()=>{const c=qe(e.columns);if(c&&c.length>0&&typeof c[0]=="object")return c},[e.columns]),{summaries:bt,hasSummary:_s}=tt(Os,m),Re=f.useCallback(()=>{const c=j=>j?{text:s.jsx(F.Type,{className:"h-3.5 w-3.5"}),number:s.jsx(F.Hash,{className:"h-3.5 w-3.5"}),currency:s.jsx(F.Hash,{className:"h-3.5 w-3.5"}),percent:s.jsx(F.Hash,{className:"h-3.5 w-3.5"}),date:s.jsx(F.Calendar,{className:"h-3.5 w-3.5"}),datetime:s.jsx(F.Clock,{className:"h-3.5 w-3.5"}),boolean:s.jsx(F.CheckSquare,{className:"h-3.5 w-3.5"}),user:s.jsx(F.User,{className:"h-3.5 w-3.5"}),select:s.jsx(F.Tag,{className:"h-3.5 w-3.5"})}[j]||s.jsx(F.Type,{className:"h-3.5 w-3.5"}):s.jsx(F.Type,{className:"h-3.5 w-3.5"}),M=j=>{if(j.type)return j.type;const x=j.field.toLowerCase();if(["completed","is_completed","done","active","enabled","archived"].some(O=>x===O||x===`is_${O}`))return"boolean";if(["created_time","modified_time","updated_time","created_at","updated_at","modified_at","last_login","logged_at"].some(O=>x===O||x.endsWith(`_${O}`)))return"datetime";if(["date","due","created","updated","deadline","start","end","expires"].some(O=>x.includes(O))){if(m.length>0){const O=m.find($=>$[j.field]!=null)?.[j.field];if(typeof O=="string"&&!isNaN(Date.parse(O)))return"date"}return"date"}if(["probability","percent","percentage","completion","progress","rate"].some(O=>x.includes(O))&&m.length>0&&typeof m.find($=>$[j.field]!=null)?.[j.field]=="number")return"percent";if(["status","priority","category","stage","type","severity","level"].some(O=>x.includes(O))&&m.length>0){const O=new Set(m.map($=>$[j.field]).filter(Boolean));if(O.size>0&&O.size<=10)return"select"}if(["assignee","owner","author","reporter","creator","user"].some(O=>x.includes(O)))return"user";if(["amount","price","total","revenue","cost","budget","salary"].some(O=>x.includes(O))&&m.length>0&&typeof m.find($=>$[j.field]!=null)?.[j.field]=="number")return"currency";if(m.length>0){const O=m.find($=>$[j.field]!=null)?.[j.field];if(typeof O=="string"&&/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(O))return"datetime"}return null},k=qe(me);if(k){if(k.length>0&&typeof k[0]=="object"&&k[0]!==null){const j=k[0];if("accessorKey"in j)return k.map(x=>{if(x.cell)return x;const S={field:x.accessorKey,label:x.header,type:x.type},N=M(S);if(!N)return x;const z=Z.getCellRenderer(N),E={name:x.accessorKey,type:N};if(N==="select"){const y=Array.from(new Set(m.map(_=>_[x.accessorKey]).filter(Boolean)));E.options=y.map(_=>({value:_,label:Z.humanizeLabel(String(_))}))}return{...x,headerIcon:c(N),cell:y=>s.jsx(z,{value:y,field:E})}});if("field"in j)return k.filter(x=>x?.field&&typeof x.field=="string"&&!x.hidden).map((x,S)=>{const N=Gt(x.label)||x.field.charAt(0).toUpperCase()+x.field.slice(1).replace(/_/g," "),z=e.objectName?I(e.objectName,x.field,N):N;let E;const y=L?.fields?.[x.field],_=x.type||y?.type||M({field:x.field})||null,B=_?Z.getCellRenderer(_):null,O={name:x.field,type:_||"text"};if(y&&(y.label&&(O.label=y.label),y.currency&&(O.currency=y.currency),y.precision!==void 0&&(O.precision=y.precision),y.format&&(O.format=y.format),y.options&&(O.options=y.options)),_==="select"&&!O.options){const G=Array.from(new Set(m.map(ce=>ce[x.field]).filter(Boolean)));O.options=G.map(ce=>({value:ce,label:Z.humanizeLabel(String(ce))}))}x.options&&(O.options=x.options);const $=S===0&&!x.link&&!x.action,se=x.link||$;x.link&&x.action||$&&x.action?E=(G,ce)=>{const Ne=B?s.jsx(B,{value:G,field:O}):G!=null&&G!==""?String(G):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});return s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":$?"primary-field-link":"link-cell",onClick:Oe=>{Oe.stopPropagation(),ne.handleClick(ce)},children:Ne})}:se?E=(G,ce)=>{const Ne=B?s.jsx(B,{value:G,field:O}):G!=null&&G!==""?String(G):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});return s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":$?"primary-field-link":"link-cell",onClick:Oe=>{Oe.stopPropagation(),ne.handleClick(ce)},children:Ne})}:x.action?E=(G,ce)=>s.jsx(v.Button,{variant:"outline",size:"sm",className:"h-7 text-xs","data-testid":"action-cell",onClick:Ne=>{Ne.stopPropagation(),De({type:x.action,params:{record:ce,field:x.field,value:G}})},children:Pe(x.action)}):B?E=G=>s.jsx(B,{value:G,field:O}):E=G=>G!=null&&G!==""?s.jsx("span",{children:String(G)}):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"});const fe=x.prefix;if(fe?.field){const G=E,ce=fe.type==="badge"?Z.getCellRenderer("select"):null;E=(Ne,Oe)=>{const Be=Oe[fe.field],Ks=Be!=null&&Be!==""?ce?s.jsx(ce,{value:Be,field:{name:fe.field,type:"select"}}):s.jsx("span",{className:"text-muted-foreground text-xs mr-1.5",children:String(Be)}):null;return s.jsxs("span",{className:"flex items-center gap-1.5",children:[Ks,G(Ne,Oe)]})}}const ie=["number","currency","percent"],oe=_||x.type,ye=x.align||(oe&&ie.includes(oe)?"right":void 0),W=S===0||x.essential===!0;return{header:z,accessorKey:x.field,headerIcon:c(_),...!W&&{className:"hidden sm:table-cell"},...x.width&&{width:x.width},...ye&&{align:ye},sortable:x.sortable!==!1,...x.resizable!==void 0&&{resizable:x.resizable},...x.wrap!==void 0&&{wrap:x.wrap},...E&&{cell:E},...x.pinned&&{pinned:x.pinned}}})}return k.filter(j=>typeof j=="string"&&j.trim().length>0).map((j,x)=>{const S=L?.fields?.[j],z=S?.label||j.charAt(0).toUpperCase()+j.slice(1).replace(/_/g," "),E=e.objectName?I(e.objectName,j,z):z,y=S?.type||M({field:j})||null,_=y?Z.getCellRenderer(y):null,B={name:j,type:y||"text"};if(S&&(S.label&&(B.label=S.label),S.currency&&(B.currency=S.currency),S.precision!==void 0&&(B.precision=S.precision),S.format&&(B.format=S.format),S.options&&(B.options=S.options)),y==="select"&&!B.options){const ie=Array.from(new Set(m.map(oe=>oe[j]).filter(Boolean)));B.options=ie.map(oe=>({value:oe,label:Z.humanizeLabel(String(oe))}))}const $=y&&["number","currency","percent"].includes(y)?"right":void 0,se=x===0;let fe;return se&&_?fe=(ie,oe)=>{const ye=s.jsx(_,{value:ie,field:B});return s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":"primary-field-link",onClick:W=>{W.stopPropagation(),ne.handleClick(oe)},children:ye})}:se?fe=(ie,oe)=>s.jsx("button",{type:"button",className:"text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit","data-testid":"primary-field-link",onClick:ye=>{ye.stopPropagation(),ne.handleClick(oe)},children:ie!=null&&ie!==""?String(ie):s.jsx("span",{className:"text-muted-foreground/50 text-xs italic",children:"—"})}):_&&(fe=ie=>s.jsx(_,{value:ie,field:B})),{header:E,accessorKey:j,...y&&{headerIcon:c(y)},...$&&{align:$},...fe&&{cell:fe},sortable:S?.sortable!==!1}})}if(R){const j=ee?.provider==="value"?ee.items:[];if(j.length>0)return(ue||Object.keys(j[0])).map(S=>{const N=L?.fields?.[S],z=N?.type||M({field:S})||null,E=z?Z.getCellRenderer(z):null,y=N?.label||S.charAt(0).toUpperCase()+S.slice(1).replace(/_/g," "),_={name:S,type:z||"text"};if(N&&(N.label&&(_.label=N.label),N.currency&&(_.currency=N.currency),N.precision!==void 0&&(_.precision=N.precision),N.format&&(_.format=N.format),N.options&&(_.options=N.options)),z==="select"&&!_.options){const $=Array.from(new Set(m.map(se=>se[S]).filter(Boolean)));_.options=$.map(se=>({value:se,label:Z.humanizeLabel(String(se))}))}const O=z&&["number","currency","percent"].includes(z)?"right":void 0;return{header:y,accessorKey:S,...z&&{headerIcon:c(z)},...O&&{align:O},...E&&{cell:$=>s.jsx(E,{value:$,field:_})},sortable:N?.sortable!==!1}})}if(!L)return[];const U=[];return(ue||Object.keys(L.fields||{})).forEach(j=>{const x=L.fields?.[j];if(!x||x.permissions&&x.permissions.read===!1)return;const S=Z.getCellRenderer(x.type),N=["number","currency","percent"];U.push({header:e.objectName?I(e.objectName,j,x.label||j):x.label||j,accessorKey:j,...N.includes(x.type)&&{align:"right"},cell:z=>s.jsx(S,{value:z,field:x}),sortable:x.sortable!==!1})}),U},[L,ue,me,ee,R,ne.handleClick,De,m,I,e.objectName]),Ts=f.useCallback(c=>{const M=e.exportOptions,k=M?.maxRecords||0,U=M?.includeHeaders!==!1,te=M?.fileNamePrefix||e.objectName||"export",j=k>0?m.slice(0,k):m,x=(N,z)=>{const E=URL.createObjectURL(N),y=document.createElement("a");y.href=E,y.download=z,y.click(),URL.revokeObjectURL(E)},S=N=>{const z=N==null?"":String(N);return z.includes(",")||z.includes('"')||z.includes(`
7
7
  `)||z.includes("\r")?`"${z.replace(/"/g,'""')}"`:z};if(c==="csv"){const N=Re().filter(_=>_.accessorKey!=="_actions"),z=N.map(_=>_.accessorKey),E=N.map(_=>_.header),y=[];U&&y.push(E.join(",")),j.forEach(_=>{y.push(z.map(B=>S(_[B])).join(","))}),x(new Blob([y.join(`
8
- `)],{type:"text/csv;charset=utf-8;"}),`${te}.csv`)}else c==="json"&&x(new Blob([JSON.stringify(j,null,2)],{type:"application/json"}),`${te}.json`);Ee(!1)},[m,e.exportOptions,e.objectName,Re]);if(w)return s.jsxs("div",{className:"p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",children:[s.jsx("h3",{className:"text-red-800 font-semibold",children:D("grid.errorLoading")}),s.jsx("p",{className:"text-red-600 text-sm mt-1",children:w.message})]});if(b&&m.length===0)return q?s.jsx("div",{className:"space-y-2 p-2",children:[1,2,3].map(c=>s.jsxs("div",{className:"border rounded-lg p-3 bg-card animate-pulse",children:[s.jsx("div",{className:"h-5 bg-muted rounded w-3/4 mb-3"}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("div",{className:"h-4 bg-muted rounded w-1/4"}),s.jsx("div",{className:"h-5 bg-muted rounded-full w-20"})]}),s.jsx("div",{className:"h-3 bg-muted rounded w-1/3"})]},c))}):s.jsxs("div",{className:"p-4 sm:p-8 text-center",children:[s.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-foreground"}),s.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:D("grid.loading")})]});let Fe=[...Re()];if(ae.widths&&(Fe=Fe.map(c=>{const M=ae.widths?.[c.accessorKey];return M?{...c,size:M}:c})),ae.order&&ae.order.length>0){const c=new Map(ae.order.map((M,k)=>[M,k]));Fe.sort((M,k)=>{const U=c.get(M.accessorKey)??1/0,te=c.get(k.accessorKey)??1/0;return U-te})}const Ce="operations"in e?e.operations:void 0,yt=Ce&&(Ce.update||Ce.delete),Ts=e.rowActions&&e.rowActions.length>0,$e=yt||Ts?[...Fe,{header:D("grid.actions"),accessorKey:"_actions",cell:(c,M)=>s.jsx(st,{row:M,rowActions:e.rowActions,canEdit:!!(Ce?.update&&t),canDelete:!!(Ce?.delete&&r),onEdit:t,onDelete:r,onAction:(k,U)=>De({type:k,params:{record:U}})}),sortable:!1}]:Fe,He=$e.filter(c=>c.pinned==="left"),vt=$e.filter(c=>c.pinned==="right"),As=$e.filter(c=>!c.pinned),jt=He.length>0||vt.length>0,wt="sticky right-0 z-10 bg-background border-l border-border",Ct=jt?[...He,...As,...vt.map(c=>({...c,className:[c.className,wt].filter(Boolean).join(" "),cellClassName:[c.cellClassName,wt].filter(Boolean).join(" ")}))]:$e,Ms=jt?He.length:e.frozenColumns??1,Ve=e.batchActions??e.bulkActions,Ds=Ve&&Ve.length>0;let Ke=!1;e.selection?.type?Ke=e.selection.type==="none"?!1:e.selection.type:e.selectable!==void 0?Ke=e.selectable:Ds&&(Ke="multiple");const Fs=e.pagination!==void 0?!0:e.showPagination!==void 0?e.showPagination:!0,zs=e.pagination?.pageSize||e.pageSize||10,Is=e.searchableFields!==void 0?e.searchableFields.length>0:e.showSearch!==void 0?e.showSearch:!0,Nt={type:"data-table",caption:e.label||e.title,columns:Ct,data:m,pagination:Fs,pageSize:zs,searchable:Is,selectable:Ke,sortable:!0,exportable:Ce?.export,rowActions:yt,resizableColumns:e.resizable??e.resizableColumns??!0,reorderableColumns:e.reorderableColumns??!1,editable:e.editable??!1,singleClickEdit:e.singleClickEdit??!0,className:e.className,cellClassName:de==="compact"?"px-3 py-1 text-[13px] leading-tight":de==="short"?"px-3 py-1 text-[13px] leading-normal":de==="tall"?"px-3 py-2.5 text-sm":de==="extra_tall"?"px-3 py-3.5 text-sm leading-relaxed":"px-3 py-1.5 text-[13px] leading-normal",showRowNumbers:!0,showAddRow:!!Ce?.create,onAddRecord:h,rowClassName:e.rowColor?(c,M)=>Cs(c):void 0,rowStyle:e.conditionalFormatting?.length?(c,M)=>Ns(c):void 0,frozenColumns:Ms,onSelectionChange:c=>{Q(c),n?.(c)},onRowClick:ne.handleClick,onCellChange:a,onRowSave:o,onBatchSave:p,onColumnResize:(c,M)=>{re({...ae,widths:{...ae.widths,[c]:M}})},onColumnReorder:c=>{re({...ae,order:c})}},Ps=c=>({...Nt,caption:void 0,data:c,pagination:!1,searchable:!1}),Ue=e.label?`${e.label} Detail`:e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1)} Detail`:"Record Detail";if(q&&m.length>0&&!xt){const c=Re().filter(E=>E.accessorKey!=="_actions"),M=new Map;c.forEach(E=>M.set(E.accessorKey,E));const k=c[0],U=["amount","price","total","revenue","cost","value","budget","salary"],te=["stage","status","priority","category","severity","level"],j=["date","due","created","updated","deadline","start","end","expires"],x=["probability","percent","rate","ratio","confidence","score"],S=E=>{const y=(E||"").toLowerCase();return y.includes("won")||y.includes("completed")||y.includes("done")||y.includes("active")?"bg-green-100 text-green-800 border-green-300":y.includes("lost")||y.includes("cancelled")||y.includes("rejected")||y.includes("closed lost")?"bg-red-100 text-red-800 border-red-300":y.includes("negotiation")||y.includes("review")||y.includes("in progress")?"bg-yellow-100 text-yellow-800 border-yellow-300":y.includes("proposal")||y.includes("pending")?"bg-blue-100 text-blue-800 border-blue-300":y.includes("qualification")||y.includes("qualified")?"bg-indigo-100 text-indigo-800 border-indigo-300":y.includes("prospecting")||y.includes("new")||y.includes("open")?"bg-purple-100 text-purple-800 border-purple-300":"bg-muted text-muted-foreground border-border"},N=E=>{const y=(E||"").toLowerCase();return y.includes("won")||y.includes("completed")||y.includes("done")||y.includes("active")?"border-l-green-500":y.includes("lost")||y.includes("cancelled")||y.includes("rejected")?"border-l-red-500":y.includes("negotiation")||y.includes("review")||y.includes("in progress")?"border-l-yellow-500":y.includes("proposal")||y.includes("pending")?"border-l-blue-500":y.includes("qualification")||y.includes("qualified")?"border-l-indigo-500":y.includes("prospecting")||y.includes("new")||y.includes("open")?"border-l-purple-500":"border-l-gray-300"},z=E=>{const y=E.toLowerCase();return U.some(_=>y.includes(_))?"amount":te.some(_=>y.includes(_))?"stage":j.some(_=>y.includes(_))?"date":x.some(_=>y.includes(_))?"percent":"other"};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"space-y-2 p-2",children:m.map((E,y)=>{const _=c.slice(1,5),B=_.find(W=>z(W.accessorKey)==="amount"),O=_.find(W=>z(W.accessorKey)==="stage"),$=_.filter(W=>z(W.accessorKey)==="date"),se=_.filter(W=>z(W.accessorKey)==="percent"),fe=_.filter(W=>W!==B&&W!==O&&!$.includes(W)&&!se.includes(W)),ie=O?String(E[O.accessorKey]??""):"",le=ie?N(ie):"",ye=["border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",le?`border-l-[3px] ${le}`:""].filter(Boolean).join(" ");return s.jsxs("div",{className:ye,onClick:()=>ne.handleClick(E),children:[k&&s.jsx("div",{className:"font-semibold text-sm truncate mb-1",children:E[k.accessorKey]??"—"}),(B||O)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[B&&s.jsx("span",{className:"text-sm tabular-nums font-medium",children:typeof E[B.accessorKey]=="number"?Z.formatCompactCurrency(E[B.accessorKey]):E[B.accessorKey]??"—"}),O&&E[O.accessorKey]&&s.jsx(v.Badge,{variant:"outline",className:`text-xs shrink-0 max-w-[140px] truncate ${S(String(E[O.accessorKey]))}`,children:E[O.accessorKey]})]}),($.length>0||se.length>0)&&s.jsxs("div",{className:"flex items-center justify-between py-0.5 text-xs text-muted-foreground",children:[$[0]&&s.jsx("span",{className:"tabular-nums",children:E[$[0].accessorKey]?Z.formatDate(E[$[0].accessorKey],"short"):"—"}),se[0]&&E[se[0].accessorKey]!=null&&s.jsx("span",{className:"tabular-nums",children:Z.formatPercent(Number(E[se[0].accessorKey]))})]}),$.slice(1).map(W=>s.jsxs("div",{className:"flex justify-between items-center py-0.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:W.header}),s.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:E[W.accessorKey]?Z.formatDate(E[W.accessorKey],"short"):"—"})]},W.accessorKey)),fe.map(W=>{const G=E[W.accessorKey];return G==null||G===""?null:s.jsxs("div",{className:"flex justify-between items-center py-0.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:W.header}),s.jsx("span",{className:"text-xs font-medium truncate ml-2 text-right",children:W.cell?W.cell(G,E):String(G)})]},W.accessorKey)})]},E.id||E._id||y)})}),ne.isOverlay&&s.jsx(v.NavigationOverlay,{...ne,title:Ue,children:E=>s.jsx("div",{className:"space-y-3",children:Object.entries(E).map(([y,_])=>s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:y.replace(/_/g," ")}),s.jsx("span",{className:"text-sm",children:String(_??"—")})]},y))})})]})}const Ls=()=>{ge(c=>c==="compact"?"short":c==="short"?"medium":c==="medium"?"tall":c==="tall"?"extra_tall":"compact")},Rs={compact:F.Rows4,short:F.Rows3,medium:F.Rows2,tall:F.AlignJustify,extra_tall:F.AlignJustify}[de],St=e.rowHeight!==void 0,Et=e.exportOptions||St?s.jsxs("div",{className:"flex items-center justify-end gap-1 px-2 py-1",children:[St&&s.jsxs(v.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-primary text-xs",onClick:Ls,title:`Row height: ${de}`,children:[s.jsx(Rs,{className:"h-3.5 w-3.5 mr-1.5"}),s.jsx("span",{className:"hidden sm:inline capitalize",children:de})]}),e.exportOptions&&s.jsxs(v.Popover,{open:ve,onOpenChange:Ee,children:[s.jsx(v.PopoverTrigger,{asChild:!0,children:s.jsxs(v.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-primary text-xs",children:[s.jsx(F.Download,{className:"h-3.5 w-3.5 mr-1.5"}),s.jsx("span",{className:"hidden sm:inline",children:D("grid.export")})]})}),s.jsx(v.PopoverContent,{align:"end",className:"w-48 p-2",children:s.jsx("div",{className:"space-y-1",children:(e.exportOptions.formats||["csv","json"]).map(c=>s.jsxs(v.Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8 text-xs",onClick:()=>_s(c),children:[s.jsx(F.Download,{className:"h-3.5 w-3.5 mr-2"}),D("grid.exportAs",{format:c.toUpperCase()})]},c))})})]})]}):null,kt=c=>{const M=["_id","id","created_at","updated_at","created_by","updated_by"],k=Object.entries(c),U=k.filter(([S])=>!M.includes(S)),te=k.filter(([S])=>M.includes(S)&&S!=="_id"&&S!=="id"),j=S=>S.charAt(0).toUpperCase()+S.slice(1).replace(/_/g," "),x=(S,N)=>{if(N==null||N==="")return s.jsx("span",{className:"text-muted-foreground/50 text-sm italic",children:"Empty"});const z=L?.fields?.[S];if(z?.type){const y=Z.getCellRenderer(z.type);if(y)return s.jsx(y,{value:N,field:z})}return typeof N=="boolean"?s.jsx(v.Badge,{variant:N?"default":"outline",children:N?"Yes":"No"}):typeof N=="string"&&!isNaN(Date.parse(N))&&(S.includes("date")||S.includes("_at")||S.includes("time"))?s.jsx("span",{className:"text-sm tabular-nums",children:Z.formatDate(N)}):typeof N=="number"&&["amount","price","total","revenue","cost","value","budget","salary"].some(y=>S.toLowerCase().includes(y))?s.jsx("span",{className:"text-sm tabular-nums font-medium",children:Z.formatCurrency(N)}):s.jsx("span",{className:"text-sm break-words",children:String(N)})};return s.jsxs("div",{className:"space-y-4","data-testid":"record-detail-panel",children:[s.jsx("div",{className:"rounded-lg border bg-card",children:s.jsx("div",{className:"divide-y",children:U.map(([S,N])=>s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0",children:j(S)}),s.jsx("div",{className:"flex-1 min-w-0",children:x(S,N)})]},S))})}),te.length>0&&s.jsxs("div",{className:"rounded-lg border bg-muted/30",children:[s.jsx("div",{className:"px-4 py-2 border-b",children:s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"System"})}),s.jsx("div",{className:"divide-y divide-border/50",children:te.map(([S,N])=>s.jsxs("div",{className:"flex items-center gap-4 px-4 py-2",children:[s.jsx("span",{className:"text-xs text-muted-foreground w-1/3 text-right shrink-0",children:j(S)}),s.jsx("span",{className:"text-xs text-muted-foreground flex-1 min-w-0 break-words",children:String(N??"")})]},S))})]})]})},$s=Os?s.jsx("div",{className:"border-t bg-muted/30 px-2 py-1.5","data-testid":"column-summary-footer",children:s.jsx("div",{className:"flex gap-4 text-xs text-muted-foreground font-medium",children:Ct.filter(c=>bt.has(c.accessorKey)).map(c=>{const M=bt.get(c.accessorKey);return s.jsxs("span",{"data-testid":`summary-${c.accessorKey}`,children:[c.header,": ",M.label]},c.accessorKey)})})}):null,Ot=xt?s.jsx("div",{className:"space-y-2",children:Ss.map(c=>s.jsx(et,{groupKey:c.key,label:c.label,count:c.rows.length,collapsed:c.collapsed,aggregations:c.aggregations,onToggle:Es,children:s.jsx(pe.SchemaRenderer,{schema:Ps(c.rows)})},c.key))}):s.jsxs(s.Fragment,{children:[s.jsx(pe.SchemaRenderer,{schema:Nt}),$s]});return ne.isOverlay&&ne.mode==="split"?s.jsx(v.NavigationOverlay,{...ne,title:Ue,mainContent:s.jsxs(s.Fragment,{children:[Et,Ot,s.jsx(We,{selectedRows:V,actions:Ve??[],onAction:(c,M)=>De({type:c,params:{records:M}}),onClearSelection:()=>Q([])})]}),children:c=>kt(c)}):s.jsxs("div",{ref:xe,className:"relative h-full",children:[A>0&&s.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:A},children:D(u?"grid.refreshing":"grid.pullToRefresh")}),Et,Ot,s.jsx(We,{selectedRows:V,actions:Ve??[],onAction:(c,M)=>De({type:c,params:{records:M}}),onClearSelection:()=>Q([])}),ne.isOverlay&&s.jsx(v.NavigationOverlay,{...ne,title:Ue,children:c=>kt(c)})]})};function Se(e,l,t){let r=t.initialDeps??[],n,i=!0;function a(){var o,p,h;let d;t.key&&((o=t.debug)!=null&&o.call(t))&&(d=Date.now());const m=e();if(!(m.length!==r.length||m.some((C,w)=>r[w]!==C)))return n;r=m;let b;if(t.key&&((p=t.debug)!=null&&p.call(t))&&(b=Date.now()),n=l(...m),t.key&&((h=t.debug)!=null&&h.call(t))){const C=Math.round((Date.now()-d)*100)/100,w=Math.round((Date.now()-b)*100)/100,T=w/16,D=(I,L)=>{for(I=String(I);I.length<L;)I=" "+I;return I};console.info(`%c⏱ ${D(w,5)} /${D(C,5)} ms`,`
8
+ `)],{type:"text/csv;charset=utf-8;"}),`${te}.csv`)}else c==="json"&&x(new Blob([JSON.stringify(j,null,2)],{type:"application/json"}),`${te}.json`);Ee(!1)},[m,e.exportOptions,e.objectName,Re]);if(w)return s.jsxs("div",{className:"p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",children:[s.jsx("h3",{className:"text-red-800 font-semibold",children:D("grid.errorLoading")}),s.jsx("p",{className:"text-red-600 text-sm mt-1",children:w.message})]});if(b&&m.length===0)return q?s.jsx("div",{className:"space-y-2 p-2",children:[1,2,3].map(c=>s.jsxs("div",{className:"border rounded-lg p-3 bg-card animate-pulse",children:[s.jsx("div",{className:"h-5 bg-muted rounded w-3/4 mb-3"}),s.jsxs("div",{className:"flex items-center justify-between mb-2",children:[s.jsx("div",{className:"h-4 bg-muted rounded w-1/4"}),s.jsx("div",{className:"h-5 bg-muted rounded-full w-20"})]}),s.jsx("div",{className:"h-3 bg-muted rounded w-1/3"})]},c))}):s.jsxs("div",{className:"p-4 sm:p-8 text-center",children:[s.jsx("div",{className:"inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-foreground"}),s.jsx("p",{className:"mt-2 text-sm text-muted-foreground",children:D("grid.loading")})]});let Fe=[...Re()];if(ae.widths&&(Fe=Fe.map(c=>{const M=ae.widths?.[c.accessorKey];return M?{...c,size:M}:c})),ae.order&&ae.order.length>0){const c=new Map(ae.order.map((M,k)=>[M,k]));Fe.sort((M,k)=>{const U=c.get(M.accessorKey)??1/0,te=c.get(k.accessorKey)??1/0;return U-te})}const Ce="operations"in e?e.operations:void 0,yt=Ce&&(Ce.update||Ce.delete),As=e.rowActions&&e.rowActions.length>0,$e=yt||As?[...Fe,{header:D("grid.actions"),accessorKey:"_actions",cell:(c,M)=>s.jsx(st,{row:M,rowActions:e.rowActions,canEdit:!!(Ce?.update&&t),canDelete:!!(Ce?.delete&&r),onEdit:t,onDelete:r,onAction:(k,U)=>De({type:k,params:{record:U}})}),sortable:!1}]:Fe,He=$e.filter(c=>c.pinned==="left"),vt=$e.filter(c=>c.pinned==="right"),Ms=$e.filter(c=>!c.pinned),jt=He.length>0||vt.length>0,wt="sticky right-0 z-10 bg-background border-l border-border",Ct=jt?[...He,...Ms,...vt.map(c=>({...c,className:[c.className,wt].filter(Boolean).join(" "),cellClassName:[c.cellClassName,wt].filter(Boolean).join(" ")}))]:$e,Ds=jt?He.length:e.frozenColumns??1,Ve=e.batchActions??e.bulkActions,Fs=Ve&&Ve.length>0;let Ke=!1;e.selection?.type?Ke=e.selection.type==="none"?!1:e.selection.type:e.selectable!==void 0?Ke=e.selectable:Fs&&(Ke="multiple");const zs=e.pagination!==void 0?!0:e.showPagination!==void 0?e.showPagination:!0,Is=e.pagination?.pageSize||e.pageSize||10,Ps=e.searchableFields!==void 0?e.searchableFields.length>0:e.showSearch!==void 0?e.showSearch:!0,Nt={type:"data-table",caption:e.label||e.title,columns:Ct,data:m,pagination:zs,pageSize:Is,searchable:Ps,selectable:Ke,sortable:!0,exportable:Ce?.export,rowActions:yt,resizableColumns:e.resizable??e.resizableColumns??!0,reorderableColumns:e.reorderableColumns??!1,editable:e.editable??!1,singleClickEdit:e.singleClickEdit??!0,className:e.className,cellClassName:de==="compact"?"px-3 py-1 text-[13px] leading-tight":de==="short"?"px-3 py-1 text-[13px] leading-normal":de==="tall"?"px-3 py-2.5 text-sm":de==="extra_tall"?"px-3 py-3.5 text-sm leading-relaxed":"px-3 py-1.5 text-[13px] leading-normal",showRowNumbers:!0,showAddRow:!!Ce?.create,onAddRecord:h,rowClassName:e.rowColor?(c,M)=>Ns(c):void 0,rowStyle:e.conditionalFormatting?.length?(c,M)=>Ss(c):void 0,frozenColumns:Ds,onSelectionChange:c=>{Q(c),n?.(c)},onRowClick:ne.handleClick,onCellChange:a,onRowSave:l,onBatchSave:p,onColumnResize:(c,M)=>{re({...ae,widths:{...ae.widths,[c]:M}})},onColumnReorder:c=>{re({...ae,order:c})}},Ls=c=>({...Nt,caption:void 0,data:c,pagination:!1,searchable:!1}),Ue=e.label?`${e.label} Detail`:e.objectName?`${e.objectName.charAt(0).toUpperCase()+e.objectName.slice(1)} Detail`:"Record Detail";if(q&&m.length>0&&!xt){const c=Re().filter(E=>E.accessorKey!=="_actions"),M=new Map;c.forEach(E=>M.set(E.accessorKey,E));const k=c[0],U=["amount","price","total","revenue","cost","value","budget","salary"],te=["stage","status","priority","category","severity","level"],j=["date","due","created","updated","deadline","start","end","expires"],x=["probability","percent","rate","ratio","confidence","score"],S=E=>{const y=(E||"").toLowerCase();return y.includes("won")||y.includes("completed")||y.includes("done")||y.includes("active")?"bg-green-100 text-green-800 border-green-300":y.includes("lost")||y.includes("cancelled")||y.includes("rejected")||y.includes("closed lost")?"bg-red-100 text-red-800 border-red-300":y.includes("negotiation")||y.includes("review")||y.includes("in progress")?"bg-yellow-100 text-yellow-800 border-yellow-300":y.includes("proposal")||y.includes("pending")?"bg-blue-100 text-blue-800 border-blue-300":y.includes("qualification")||y.includes("qualified")?"bg-indigo-100 text-indigo-800 border-indigo-300":y.includes("prospecting")||y.includes("new")||y.includes("open")?"bg-purple-100 text-purple-800 border-purple-300":"bg-muted text-muted-foreground border-border"},N=E=>{const y=(E||"").toLowerCase();return y.includes("won")||y.includes("completed")||y.includes("done")||y.includes("active")?"border-l-green-500":y.includes("lost")||y.includes("cancelled")||y.includes("rejected")?"border-l-red-500":y.includes("negotiation")||y.includes("review")||y.includes("in progress")?"border-l-yellow-500":y.includes("proposal")||y.includes("pending")?"border-l-blue-500":y.includes("qualification")||y.includes("qualified")?"border-l-indigo-500":y.includes("prospecting")||y.includes("new")||y.includes("open")?"border-l-purple-500":"border-l-gray-300"},z=E=>{const y=E.toLowerCase();return U.some(_=>y.includes(_))?"amount":te.some(_=>y.includes(_))?"stage":j.some(_=>y.includes(_))?"date":x.some(_=>y.includes(_))?"percent":"other"};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"space-y-2 p-2",children:m.map((E,y)=>{const _=c.slice(1,5),B=_.find(W=>z(W.accessorKey)==="amount"),O=_.find(W=>z(W.accessorKey)==="stage"),$=_.filter(W=>z(W.accessorKey)==="date"),se=_.filter(W=>z(W.accessorKey)==="percent"),fe=_.filter(W=>W!==B&&W!==O&&!$.includes(W)&&!se.includes(W)),ie=O?String(E[O.accessorKey]??""):"",oe=ie?N(ie):"",ye=["border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",oe?`border-l-[3px] ${oe}`:""].filter(Boolean).join(" ");return s.jsxs("div",{className:ye,onClick:()=>ne.handleClick(E),children:[k&&s.jsx("div",{className:"font-semibold text-sm truncate mb-1",children:E[k.accessorKey]??"—"}),(B||O)&&s.jsxs("div",{className:"flex items-center justify-between gap-2 mb-1",children:[B&&s.jsx("span",{className:"text-sm tabular-nums font-medium",children:typeof E[B.accessorKey]=="number"?Z.formatCompactCurrency(E[B.accessorKey]):E[B.accessorKey]??"—"}),O&&E[O.accessorKey]&&s.jsx(v.Badge,{variant:"outline",className:`text-xs shrink-0 max-w-[140px] truncate ${S(String(E[O.accessorKey]))}`,children:E[O.accessorKey]})]}),($.length>0||se.length>0)&&s.jsxs("div",{className:"flex items-center justify-between py-0.5 text-xs text-muted-foreground",children:[$[0]&&s.jsx("span",{className:"tabular-nums",children:E[$[0].accessorKey]?Z.formatDate(E[$[0].accessorKey],"short"):"—"}),se[0]&&E[se[0].accessorKey]!=null&&s.jsx("span",{className:"tabular-nums",children:Z.formatPercent(Number(E[se[0].accessorKey]))})]}),$.slice(1).map(W=>s.jsxs("div",{className:"flex justify-between items-center py-0.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:W.header}),s.jsx("span",{className:"text-xs text-muted-foreground tabular-nums",children:E[W.accessorKey]?Z.formatDate(E[W.accessorKey],"short"):"—"})]},W.accessorKey)),fe.map(W=>{const G=E[W.accessorKey];return G==null||G===""?null:s.jsxs("div",{className:"flex justify-between items-center py-0.5",children:[s.jsx("span",{className:"text-xs text-muted-foreground",children:W.header}),s.jsx("span",{className:"text-xs font-medium truncate ml-2 text-right",children:W.cell?W.cell(G,E):String(G)})]},W.accessorKey)})]},E.id||E._id||y)})}),ne.isOverlay&&s.jsx(v.NavigationOverlay,{...ne,title:Ue,children:E=>s.jsx("div",{className:"space-y-3",children:Object.entries(E).map(([y,_])=>s.jsxs("div",{className:"flex flex-col",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:y.replace(/_/g," ")}),s.jsx("span",{className:"text-sm",children:String(_??"—")})]},y))})})]})}const Rs=()=>{ge(c=>c==="compact"?"short":c==="short"?"medium":c==="medium"?"tall":c==="tall"?"extra_tall":"compact")},$s={compact:F.Rows4,short:F.Rows3,medium:F.Rows2,tall:F.AlignJustify,extra_tall:F.AlignJustify}[de],St=e.rowHeight!==void 0,Et=e.exportOptions||St?s.jsxs("div",{className:"flex items-center justify-end gap-1 px-2 py-1",children:[St&&s.jsxs(v.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-primary text-xs",onClick:Rs,title:`Row height: ${de}`,children:[s.jsx($s,{className:"h-3.5 w-3.5 mr-1.5"}),s.jsx("span",{className:"hidden sm:inline capitalize",children:de})]}),e.exportOptions&&s.jsxs(v.Popover,{open:ve,onOpenChange:Ee,children:[s.jsx(v.PopoverTrigger,{asChild:!0,children:s.jsxs(v.Button,{variant:"ghost",size:"sm",className:"h-7 px-2 text-muted-foreground hover:text-primary text-xs",children:[s.jsx(F.Download,{className:"h-3.5 w-3.5 mr-1.5"}),s.jsx("span",{className:"hidden sm:inline",children:D("grid.export")})]})}),s.jsx(v.PopoverContent,{align:"end",className:"w-48 p-2",children:s.jsx("div",{className:"space-y-1",children:(e.exportOptions.formats||["csv","json"]).map(c=>s.jsxs(v.Button,{variant:"ghost",size:"sm",className:"w-full justify-start h-8 text-xs",onClick:()=>Ts(c),children:[s.jsx(F.Download,{className:"h-3.5 w-3.5 mr-2"}),D("grid.exportAs",{format:c.toUpperCase()})]},c))})})]})]}):null,kt=c=>{const M=["_id","id","created_at","updated_at","created_by","updated_by"],k=Object.entries(c),U=k.filter(([S])=>!M.includes(S)),te=k.filter(([S])=>M.includes(S)&&S!=="_id"&&S!=="id"),j=S=>S.charAt(0).toUpperCase()+S.slice(1).replace(/_/g," "),x=(S,N)=>{if(N==null||N==="")return s.jsx("span",{className:"text-muted-foreground/50 text-sm italic",children:"Empty"});const z=L?.fields?.[S];if(z?.type){const y=Z.getCellRenderer(z.type);if(y)return s.jsx(y,{value:N,field:z})}return typeof N=="boolean"?s.jsx(v.Badge,{variant:N?"default":"outline",children:N?"Yes":"No"}):typeof N=="string"&&!isNaN(Date.parse(N))&&(S.includes("date")||S.includes("_at")||S.includes("time"))?s.jsx("span",{className:"text-sm tabular-nums",children:Z.formatDate(N)}):typeof N=="number"&&["amount","price","total","revenue","cost","value","budget","salary"].some(y=>S.toLowerCase().includes(y))?s.jsx("span",{className:"text-sm tabular-nums font-medium",children:Z.formatCurrency(N)}):s.jsx("span",{className:"text-sm break-words",children:String(N)})};return s.jsxs("div",{className:"space-y-4","data-testid":"record-detail-panel",children:[s.jsx("div",{className:"rounded-lg border bg-card",children:s.jsx("div",{className:"divide-y",children:U.map(([S,N])=>s.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3",children:[s.jsx("span",{className:"text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0",children:j(S)}),s.jsx("div",{className:"flex-1 min-w-0",children:x(S,N)})]},S))})}),te.length>0&&s.jsxs("div",{className:"rounded-lg border bg-muted/30",children:[s.jsx("div",{className:"px-4 py-2 border-b",children:s.jsx("span",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide",children:"System"})}),s.jsx("div",{className:"divide-y divide-border/50",children:te.map(([S,N])=>s.jsxs("div",{className:"flex items-center gap-4 px-4 py-2",children:[s.jsx("span",{className:"text-xs text-muted-foreground w-1/3 text-right shrink-0",children:j(S)}),s.jsx("span",{className:"text-xs text-muted-foreground flex-1 min-w-0 break-words",children:String(N??"")})]},S))})]})]})},Vs=_s?s.jsx("div",{className:"border-t bg-muted/30 px-2 py-1.5","data-testid":"column-summary-footer",children:s.jsx("div",{className:"flex gap-4 text-xs text-muted-foreground font-medium",children:Ct.filter(c=>bt.has(c.accessorKey)).map(c=>{const M=bt.get(c.accessorKey);return s.jsxs("span",{"data-testid":`summary-${c.accessorKey}`,children:[c.header,": ",M.label]},c.accessorKey)})})}):null,Ot=xt?s.jsx("div",{className:"space-y-2",children:Es.map(c=>s.jsx(et,{groupKey:c.key,label:c.label,count:c.rows.length,collapsed:c.collapsed,aggregations:c.aggregations,onToggle:ks,children:s.jsx(pe.SchemaRenderer,{schema:Ls(c.rows)})},c.key))}):s.jsxs(s.Fragment,{children:[s.jsx(pe.SchemaRenderer,{schema:Nt}),Vs]});return ne.isOverlay&&ne.mode==="split"?s.jsx(v.NavigationOverlay,{...ne,title:Ue,mainContent:s.jsxs(s.Fragment,{children:[Et,Ot,s.jsx(We,{selectedRows:V,actions:Ve??[],onAction:(c,M)=>De({type:c,params:{records:M}}),onClearSelection:()=>Q([])})]}),children:c=>kt(c)}):s.jsxs("div",{ref:xe,className:"relative h-full",children:[A>0&&s.jsx("div",{className:"flex items-center justify-center text-xs text-muted-foreground",style:{height:A},children:D(u?"grid.refreshing":"grid.pullToRefresh")}),Et,Ot,s.jsx(We,{selectedRows:V,actions:Ve??[],onAction:(c,M)=>De({type:c,params:{records:M}}),onClearSelection:()=>Q([])}),ne.isOverlay&&s.jsx(v.NavigationOverlay,{...ne,title:Ue,children:c=>kt(c)})]})};function Se(e,o,t){let r=t.initialDeps??[],n,i=!0;function a(){var l,p,h;let d;t.key&&((l=t.debug)!=null&&l.call(t))&&(d=Date.now());const m=e();if(!(m.length!==r.length||m.some((C,w)=>r[w]!==C)))return n;r=m;let b;if(t.key&&((p=t.debug)!=null&&p.call(t))&&(b=Date.now()),n=o(...m),t.key&&((h=t.debug)!=null&&h.call(t))){const C=Math.round((Date.now()-d)*100)/100,w=Math.round((Date.now()-b)*100)/100,T=w/16,D=(I,L)=>{for(I=String(I);I.length<L;)I=" "+I;return I};console.info(`%c⏱ ${D(w,5)} /${D(C,5)} ms`,`
9
9
  font-size: .6rem;
10
10
  font-weight: bold;
11
- color: hsl(${Math.max(0,Math.min(120-120*T,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(n),i=!1,n}return a.updateDeps=o=>{r=o},a}function it(e,l){if(e===void 0)throw new Error("Unexpected undefined");return e}const Ht=(e,l)=>Math.abs(e-l)<1.01,Ut=(e,l,t)=>{let r;return function(...n){e.clearTimeout(r),r=e.setTimeout(()=>l.apply(this,n),t)}},lt=e=>{const{offsetWidth:l,offsetHeight:t}=e;return{width:l,height:t}},Yt=e=>e,Jt=e=>{const l=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let n=l;n<=t;n++)r.push(n);return r},Xt=(e,l)=>{const t=e.scrollElement;if(!t)return;const r=e.targetWindow;if(!r)return;const n=a=>{const{width:o,height:p}=a;l({width:Math.round(o),height:Math.round(p)})};if(n(lt(t)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(a=>{const o=()=>{const p=a[0];if(p?.borderBoxSize){const h=p.borderBoxSize[0];if(h){n({width:h.inlineSize,height:h.blockSize});return}}n(lt(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(o):o()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},ot={passive:!0},at=typeof window>"u"?!0:"onscrollend"in window,Qt=(e,l)=>{const t=e.scrollElement;if(!t)return;const r=e.targetWindow;if(!r)return;let n=0;const i=e.options.useScrollendEvent&&at?()=>{}:Ut(r,()=>{l(n,!1)},e.options.isScrollingResetDelay),a=d=>()=>{const{horizontal:m,isRtl:g}=e.options;n=m?t.scrollLeft*(g&&-1||1):t.scrollTop,i(),l(n,d)},o=a(!0),p=a(!1);t.addEventListener("scroll",o,ot);const h=e.options.useScrollendEvent&&at;return h&&t.addEventListener("scrollend",p,ot),()=>{t.removeEventListener("scroll",o),h&&t.removeEventListener("scrollend",p)}},Zt=(e,l,t)=>{if(l?.borderBoxSize){const r=l.borderBoxSize[0];if(r)return Math.round(r[t.options.horizontal?"inlineSize":"blockSize"])}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},es=(e,{adjustments:l=0,behavior:t},r)=>{var n,i;const a=e+l;(i=(n=r.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[r.options.horizontal?"left":"top"]:a,behavior:t})};class ts{constructor(l){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const r=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{const a=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var n;(n=r())==null||n.disconnect(),t=null},observe:n=>{var i;return(i=r())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return(i=r())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([r,n])=>{typeof n>"u"&&delete t[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Yt,rangeExtractor:Jt,onChange:()=>{},measureElement:Zt,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var r,n;(n=(r=this.options).onChange)==null||n.call(r,this,t)},this.maybeNotify=Se(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=i,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,r)=>{const n=new Map,i=new Map;for(let a=r-1;a>=0;a--){const o=t[a];if(n.has(o.lane))continue;const p=i.get(o.lane);if(p==null||o.end>p.end?i.set(o.lane,o):o.end<p.end&&n.set(o.lane,!0),n.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((a,o)=>a.end===o.end?a.index-o.index:a.end-o.end)[0]:void 0},this.getMeasurementOptions=Se(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,r,n,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==o&&(this.lanesChangedFlag=!0),this.prevLanes=o,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:r,scrollMargin:n,getItemKey:i,enabled:a,lanes:o}),{key:!1}),this.getMeasurements=Se(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:r,scrollMargin:n,getItemKey:i,enabled:a,lanes:o},p)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const g of this.laneAssignments.keys())g>=t&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,h),m=new Array(o).fill(void 0);for(let g=0;g<h;g++){const b=d[g];b&&(m[b.lane]=g)}for(let g=h;g<t;g++){const b=i(g),C=this.laneAssignments.get(g);let w,T;if(C!==void 0&&this.options.lanes>1){w=C;const Y=m[w],q=Y!==void 0?d[Y]:void 0;T=q?q.end+this.options.gap:r+n}else{const Y=this.options.lanes===1?d[g-1]:this.getFurthestMeasurement(d,g);T=Y?Y.end+this.options.gap:r+n,w=Y?Y.lane:g%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(g,w)}const D=p.get(b),I=typeof D=="number"?D:this.options.estimateSize(g),L=T+I;d[g]={index:g,start:T,size:I,end:L,key:b,lane:w},m[w]=g}return this.measurementsCache=d,d},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Se(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,r,n,i)=>this.range=t.length>0&&r>0?ss({measurements:t,outerSize:r,scrollOffset:n,lanes:i}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Se(()=>{let t=null,r=null;const n=this.calculateRange();return n&&(t=n.startIndex,r=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,r]},(t,r,n,i,a)=>i===null||a===null?[]:t({startIndex:i,endIndex:a,overscan:r,count:n}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=t=>{const r=this.options.indexAttribute,n=t.getAttribute(r);return n?parseInt(n,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(t,r)=>{const n=this.indexFromElement(t),i=this.measurementsCache[n];if(!i)return;const a=i.key,o=this.elementsCache.get(a);o!==t&&(o&&this.observer.unobserve(o),this.observer.observe(t),this.elementsCache.set(a,t)),t.isConnected&&this.resizeItem(n,this.options.measureElement(t,r,this))},this.resizeItem=(t,r)=>{const n=this.measurementsCache[t];if(!n)return;const i=this.itemSizeCache.get(n.key)??n.size,a=r-i;a!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,a,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",a),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,r)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((r,n)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(n))});return}this._measureElement(t,void 0)},this.getVirtualItems=Se(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,r)=>{const n=[];for(let i=0,a=t.length;i<a;i++){const o=t[i],p=r[o];n.push(p)}return n},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const r=this.getMeasurements();if(r.length!==0)return it(r[ct(0,r.length-1,n=>it(r[n]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,r,n=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=t>=a+i?"end":"start"),r==="center"?t+=(n-i)/2:r==="end"&&(t-=i);const o=this.getMaxScrollOffset();return Math.max(Math.min(o,t),0)},this.getOffsetForIndex=(t,r="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.measurementsCache[t];if(!n)return;const i=this.getSize(),a=this.getScrollOffset();if(r==="auto")if(n.end>=a+i-this.options.scrollPaddingEnd)r="end";else if(n.start<=a+this.options.scrollPaddingStart)r="start";else return[a,r];if(r==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),r];const o=r==="end"?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(o,r,n.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:r="start",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,r),{adjustments:void 0,behavior:n})},this.scrollToIndex=(t,{align:r="auto",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1)),this.currentScrollToIndex=t;let i=0;const a=10,o=h=>{if(!this.targetWindow)return;const d=this.getOffsetForIndex(t,h);if(!d){console.warn("Failed to get offset for index:",t);return}const[m,g]=d;this._scrollToOffset(m,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{if(!this.targetWindow)return;const b=()=>{if(this.currentScrollToIndex!==t)return;const C=this.getScrollOffset(),w=this.getOffsetForIndex(t,g);if(!w){console.warn("Failed to get offset for index:",t);return}Ht(w[0],C)||p(g)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(b):b()})},p=h=>{this.targetWindow&&this.currentScrollToIndex===t&&(i++,i<a?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",i,a),this.targetWindow.requestAnimationFrame(()=>o(h))):console.warn(`Failed to scroll to index ${t} after ${a} attempts.`))};o(r)},this.scrollBy=(t,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var t;const r=this.getMeasurements();let n;if(r.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((t=r[r.length-1])==null?void 0:t.end)??0;else{const i=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&i.some(o=>o===null);){const o=r[a];i[o.lane]===null&&(i[o.lane]=o.end),a--}n=Math.max(...i.filter(o=>o!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:r,behavior:n})=>{this.options.scrollToFn(t,{behavior:n,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(l)}}const ct=(e,l,t,r)=>{for(;e<=l;){const n=(e+l)/2|0,i=t(n);if(i<r)e=n+1;else if(i>r)l=n-1;else return n}return e>0?e-1:0};function ss({measurements:e,outerSize:l,scrollOffset:t,lanes:r}){const n=e.length-1,i=p=>e[p].start;if(e.length<=r)return{startIndex:0,endIndex:n};let a=ct(0,n,i,t),o=a;if(r===1)for(;o<n&&e[o].end<t+l;)o++;else if(r>1){const p=Array(r).fill(0);for(;o<n&&p.some(d=>d<t+l);){const d=e[o];p[d.lane]=d.end,o++}const h=Array(r).fill(t+l);for(;a>=0&&h.some(d=>d>=t);){const d=e[a];h[d.lane]=d.start,a--}a=Math.max(0,a-a%r),o=Math.min(n,o+(r-1-o%r))}return{startIndex:a,endIndex:o}}const dt=typeof document<"u"?ze.useLayoutEffect:ze.useEffect;function rs({useFlushSync:e=!0,...l}){const t=ze.useReducer(()=>({}),{})[1],r={...l,onChange:(i,a)=>{var o;e&&a?_t.flushSync(t):t(),(o=l.onChange)==null||o.call(l,i,a)}},[n]=ze.useState(()=>new ts(r));return n.setOptions(r),dt(()=>n._didMount(),[]),dt(()=>n._willUpdate()),n}function ns(e){return rs({observeElementRect:Xt,observeElementOffset:Qt,scrollToFn:es,...e})}const is=({data:e,columns:l,rowHeight:t=40,height:r=600,className:n="",headerClassName:i="",rowClassName:a,onRowClick:o,overscan:p=5})=>{const h=f.useRef(null),d=ns({count:e.length,getScrollElement:()=>h.current,estimateSize:()=>t,overscan:p}),m=d.getVirtualItems();return s.jsxs("div",{className:n,children:[s.jsx("div",{className:`grid border-b sticky top-0 bg-muted/30 z-10 ${i}`,style:{gridTemplateColumns:l.map(g=>g.width||"1fr").join(" ")},children:l.map((g,b)=>s.jsx("div",{className:`px-4 py-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70 ${g.align==="center"?"text-center":g.align==="right"?"text-right":"text-left"}`,children:g.header},b))}),s.jsx("div",{ref:h,className:"overflow-auto",style:{height:typeof r=="number"?`${r}px`:r,contain:"strict"},children:s.jsx("div",{style:{height:`${d.getTotalSize()}px`,width:"100%",position:"relative"},children:m.map(g=>{const b=e[g.index],C=typeof a=="function"?a(b,g.index):a||"";return s.jsx("div",{className:`grid border-b hover:bg-muted/50 cursor-pointer ${C}`,style:{position:"absolute",top:0,left:0,width:"100%",height:`${g.size}px`,transform:`translateY(${g.start}px)`,gridTemplateColumns:l.map(w=>w.width||"1fr").join(" ")},onClick:()=>o?.(b,g.index),children:l.map((w,T)=>{const D=b[w.accessorKey],I=w.cell?w.cell(D,b):D;return s.jsx("div",{className:`px-4 py-2 text-sm flex items-center ${w.align==="center"?"text-center justify-center":w.align==="right"?"text-right justify-end":"text-left justify-start"}`,children:I},T)})},g.key)})})}),s.jsxs("div",{className:"px-4 py-2 text-xs text-muted-foreground border-t",children:["Showing ",m.length," of ",e.length," rows (virtual scrolling enabled)"]})]})},ls=10;function os(e){const l=[];let t=[],r="",n=!1;for(let i=0;i<e.length;i++){const a=e[i],o=e[i+1];n?a==='"'&&o==='"'?(r+='"',i++):a==='"'?n=!1:r+=a:a==='"'?n=!0:a===","?(t.push(r.trim()),r=""):a===`
12
- `||a==="\r"&&o===`
13
- `?(t.push(r.trim()),t.some(p=>p!=="")&&l.push(t),t=[],r="",a==="\r"&&i++):r+=a}return t.push(r.trim()),t.some(i=>i!=="")&&l.push(t),l}function ut(e,l){if(!e)return!0;switch(l){case"number":case"currency":case"percent":return!isNaN(Number(e));case"boolean":return["true","false","1","0","yes","no"].includes(e.toLowerCase());case"date":case"datetime":return!isNaN(Date.parse(e));default:return!0}}function as(e,l){const t={};return e.forEach((r,n)=>{const i=r.toLowerCase().replace(/[_\s-]/g,""),a=l.find(o=>{const p=o.name.toLowerCase().replace(/[_\s-]/g,""),h=o.label.toLowerCase().replace(/[_\s-]/g,"");return p===i||h===i});a&&(t[n]=a.name)}),t}function cs(e,l,t){const r=[],n={};for(const i of l){const a=e[i.csvIdx]??"";if(i.field.required&&!a){r.push({row:t,field:i.field.name,message:"Required field is empty"});continue}if(a&&!ut(a,i.field.type)){r.push({row:t,field:i.field.name,message:`Invalid ${i.field.type} value: "${a}"`});continue}n[i.field.name]=a}return{record:n,errors:r}}const ds=({onFileLoaded:e})=>{const[l,t]=f.useState(!1),[r,n]=f.useState(null),i=f.useCallback(a=>{if(n(null),!a.name.endsWith(".csv")){n("Only CSV files are supported.");return}const o=new FileReader;o.onload=p=>{const h=os(p.target?.result);if(h.length<2){n("File must contain a header row and at least one data row.");return}e(h[0],h.slice(1))},o.readAsText(a)},[e]);return s.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[s.jsxs("div",{className:v.cn("flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors",l?"border-primary bg-primary/5":"border-muted-foreground/25"),onDragOver:a=>{a.preventDefault(),t(!0)},onDragLeave:()=>t(!1),onDrop:a=>{a.preventDefault(),t(!1);const o=a.dataTransfer.files[0];o&&i(o)},children:[s.jsx(F.Upload,{className:"h-10 w-10 text-muted-foreground"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag & drop a CSV file here, or click to browse"}),s.jsxs("label",{children:[s.jsx("input",{type:"file",accept:".csv",className:"hidden",onChange:a=>{const o=a.target.files?.[0];o&&i(o)}}),s.jsx(v.Button,{variant:"outline",size:"sm",asChild:!0,children:s.jsx("span",{children:"Browse Files"})})]})]}),r&&s.jsxs("p",{className:"flex items-center gap-1 text-sm text-destructive",children:[s.jsx(F.AlertCircle,{className:"h-4 w-4"})," ",r]})]})},us=({headers:e,fields:l,mapping:t,onMappingChange:r})=>{const n=f.useMemo(()=>new Set(Object.values(t)),[t]),i=f.useCallback((a,o)=>{const p={...t};o==="__skip__"?delete p[a]:p[a]=o,r(p)},[t,r]);return s.jsx("div",{className:"max-h-[360px] overflow-auto",children:s.jsxs(v.Table,{children:[s.jsx(v.TableHeader,{children:s.jsxs(v.TableRow,{children:[s.jsx(v.TableHead,{children:"CSV Column"}),s.jsx(v.TableHead,{children:"Maps To"}),s.jsx(v.TableHead,{className:"w-24 text-center",children:"Status"})]})}),s.jsx(v.TableBody,{children:e.map((a,o)=>s.jsxs(v.TableRow,{children:[s.jsx(v.TableCell,{className:"font-medium",children:a}),s.jsx(v.TableCell,{children:s.jsxs(v.Select,{value:t[o]??"__skip__",onValueChange:p=>i(o,p),children:[s.jsx(v.SelectTrigger,{className:"h-8 w-56",children:s.jsx(v.SelectValue,{placeholder:"Skip column"})}),s.jsxs(v.SelectContent,{children:[s.jsx(v.SelectItem,{value:"__skip__",children:"— Skip —"}),l.map(p=>s.jsxs(v.SelectItem,{value:p.name,disabled:n.has(p.name)&&t[o]!==p.name,children:[p.label,p.required?" *":""]},p.name))]})]})}),s.jsx(v.TableCell,{className:"text-center",children:t[o]?s.jsx(v.Badge,{variant:"default",className:"text-xs",children:"Mapped"}):s.jsx(v.Badge,{variant:"secondary",className:"text-xs",children:"Skipped"})})]},o))})]})})},fs=({headers:e,rows:l,mapping:t,fields:r})=>{const n=f.useMemo(()=>Object.entries(t).map(([p,h])=>({csvIdx:Number(p),header:e[Number(p)],field:r.find(d=>d.name===h)})),[t,e,r]),i=l.slice(0,ls),a=f.useMemo(()=>i.map((p,h)=>{const d={};for(const m of n){const g=p[m.csvIdx]??"";m.field.required&&!g?d[m.csvIdx]="Required":g&&!ut(g,m.field.type)&&(d[m.csvIdx]=`Invalid ${m.field.type}`)}return d}),[i,n]),o=a.filter(p=>Object.keys(p).length>0).length;return s.jsxs("div",{className:"max-h-[360px] overflow-auto",children:[o>0&&s.jsxs("p",{className:"mb-2 flex items-center gap-1 text-xs text-destructive",children:[s.jsx(F.AlertCircle,{className:"h-3.5 w-3.5"})," ",o," row(s) with errors in preview"]}),s.jsxs(v.Table,{children:[s.jsx(v.TableHeader,{children:s.jsxs(v.TableRow,{children:[s.jsx(v.TableHead,{className:"w-12",children:"#"}),n.map(p=>s.jsx(v.TableHead,{children:p.field.label},p.csvIdx))]})}),s.jsx(v.TableBody,{children:i.map((p,h)=>{const d=a[h],m=Object.keys(d).length>0;return s.jsxs(v.TableRow,{className:v.cn(m&&"bg-destructive/5"),children:[s.jsx(v.TableCell,{className:"text-xs text-muted-foreground",children:h+1}),n.map(g=>{const b=p[g.csvIdx]??"",C=d[g.csvIdx];return s.jsx(v.TableCell,{className:v.cn(C&&"text-destructive"),title:C,children:b||s.jsx("span",{className:"text-muted-foreground/50",children:"—"})},g.csvIdx)})]},h)})})]}),s.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Showing ",i.length," of ",l.length," rows"]})]})},ft=({objectName:e,objectLabel:l,fields:t,dataSource:r,onComplete:n,onCancel:i,open:a,onOpenChange:o,onErrorMode:p="skip"})=>{const[h,d]=f.useState("upload"),[m,g]=f.useState([]),[b,C]=f.useState([]),[w,T]=f.useState({}),[D,I]=f.useState(!1),[L,Y]=f.useState(0),[q,J]=f.useState(null),oe=l??e,Me=f.useMemo(()=>{const V=new Set(Object.values(w));return t.filter(Q=>Q.required&&!V.has(Q.name))},[t,w]),ve=f.useCallback((V,Q)=>{g(V),C(Q),T(as(V,t)),d("mapping")},[t]),Ee=f.useCallback(async()=>{I(!0),Y(0);const V=[];let Q=0,he=0;const ae=Object.entries(w).map(([re,be])=>({csvIdx:Number(re),field:t.find(xe=>xe.name===be)}));for(let re=0;re<b.length;re++){const{record:be,errors:xe}=cs(b[re],ae,re+1);if(xe.length>0){if(he++,V.push(...xe),p==="stop")break}else try{r?.create&&await r.create(e,be),Q++}catch(u){he++;const A=u instanceof Error?u.message:"Failed to create record";if(V.push({row:re+1,field:"",message:A}),p==="stop")break}Y(Math.round((re+1)/b.length*100))}const je={totalRows:b.length,importedRows:Q,skippedRows:he,errors:V};J(je),I(!1),n?.(je)},[b,w,t,r,e,n,p]),de=f.useCallback(()=>{d("upload"),g([]),C([]),T({}),Y(0),J(null)},[]),ge=f.useCallback(()=>{de(),o?.(!1),i?.()},[de,o,i]);return s.jsx(v.Dialog,{open:a,onOpenChange:V=>{V?o?.(V):ge()},children:s.jsxs(v.DialogContent,{className:"sm:max-w-2xl",children:[s.jsxs(v.DialogHeader,{children:[s.jsxs(v.DialogTitle,{className:"flex items-center gap-2",children:[s.jsx(F.FileSpreadsheet,{className:"h-5 w-5"})," Import ",oe]}),s.jsxs(v.DialogDescription,{children:[h==="upload"&&"Upload a CSV file to get started.",h==="mapping"&&"Map CSV columns to object fields.",h==="preview"&&"Review data before importing."]})]}),s.jsx("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:["upload","mapping","preview"].map((V,Q)=>s.jsxs(f.Fragment,{children:[Q>0&&s.jsx(F.ArrowRight,{className:"h-3 w-3"}),s.jsxs("span",{className:v.cn("rounded-full px-3 py-1",h===V?"bg-primary text-primary-foreground":"bg-muted"),children:[Q+1,". ",V==="upload"?"Upload":V==="mapping"?"Mapping":"Preview"]})]},V))}),q?s.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[s.jsx(F.CheckCircle2,{className:"h-10 w-10 text-green-500"}),s.jsx("p",{className:"text-lg font-semibold",children:"Import Complete"}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(v.Badge,{variant:"default",children:[q.importedRows," imported"]}),q.skippedRows>0&&s.jsxs(v.Badge,{variant:"destructive",children:[q.skippedRows," skipped"]})]}),q.errors.length>0&&s.jsxs("div",{className:"max-h-32 w-full overflow-auto rounded border p-2 text-xs",children:[q.errors.slice(0,10).map((V,Q)=>s.jsxs("p",{className:"text-destructive",children:["Row ",V.row,V.field?` (${V.field})`:"",": ",V.message]},Q)),q.errors.length>10&&s.jsxs("p",{className:"text-muted-foreground",children:["…and ",q.errors.length-10," more errors"]})]})]}):s.jsxs(s.Fragment,{children:[h==="upload"&&s.jsx(ds,{onFileLoaded:ve}),h==="mapping"&&s.jsx(us,{headers:m,fields:t,mapping:w,onMappingChange:T}),h==="preview"&&s.jsx(fs,{headers:m,rows:b,mapping:w,fields:t}),D&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(v.Progress,{value:L,className:"h-2"}),s.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:["Importing… ",L,"%"]})]})]}),s.jsx(v.DialogFooter,{className:"gap-2 sm:gap-0",children:q?s.jsx(v.Button,{onClick:ge,children:"Close"}):s.jsxs(s.Fragment,{children:[s.jsxs(v.Button,{variant:"ghost",onClick:ge,disabled:D,children:[s.jsx(F.X,{className:"mr-1 h-4 w-4"})," Cancel"]}),(h==="mapping"||h==="preview")&&s.jsxs(v.Button,{variant:"outline",onClick:()=>d(h==="mapping"?"upload":"mapping"),disabled:D,children:[s.jsx(F.ArrowLeft,{className:"mr-1 h-4 w-4"})," Back"]}),h==="mapping"&&s.jsxs(v.Button,{onClick:()=>d("preview"),disabled:Object.keys(w).length===0||Me.length>0,children:["Next ",s.jsx(F.ArrowRight,{className:"ml-1 h-4 w-4"})]}),h==="preview"&&s.jsx(v.Button,{onClick:Ee,disabled:D,children:D?"Importing…":`Import ${b.length} Rows`})]})})]})})};function hs({value:e,onSave:l,onCancel:t,validate:r,type:n="text",placeholder:i,editing:a=!1,className:o,disabled:p=!1}){const[h,d]=f.useState(a),[m,g]=f.useState(String(e??"")),[b,C]=f.useState(),[w,T]=f.useState(!1),D=f.useRef(null);f.useEffect(()=>{h||g(String(e??""))},[e,h]),f.useEffect(()=>{h&&D.current&&(D.current.focus(),D.current.select())},[h]);const I=f.useCallback(()=>{p||(d(!0),g(String(e??"")),C(void 0))},[p,e]),L=f.useCallback(()=>{d(!1),g(String(e??"")),C(void 0),t?.()},[e,t]),Y=f.useCallback(async()=>{if(r){const oe=r(m);if(oe){C(oe);return}}const J=n==="number"?Number(m):m;T(!0);try{const oe=await l(J);if(typeof oe=="string"){C(oe),T(!1);return}d(!1),C(void 0)}catch(oe){C(oe?.message||"Save failed")}finally{T(!1)}},[m,r,n,l]),q=f.useCallback(J=>{J.key==="Enter"?(J.preventDefault(),Y()):J.key==="Escape"&&(J.preventDefault(),L())},[Y,L]);return h?s.jsxs("div",{"data-slot":"inline-editing",className:v.cn("relative flex items-center gap-1",o),children:[s.jsxs("div",{className:"flex-1 relative",children:[s.jsx("input",{ref:D,"data-slot":"inline-editing-input",type:n,value:m,onChange:J=>{g(J.target.value),b&&C(void 0)},onKeyDown:q,placeholder:i,disabled:w,"aria-invalid":!!b,"aria-describedby":b?"inline-editing-error":void 0,className:v.cn("w-full rounded border px-2 py-1 text-sm outline-none transition-colors","focus:ring-2 focus:ring-ring focus:border-input",b?"border-destructive focus:ring-destructive/30":"border-input",w&&"opacity-50")}),b&&s.jsx("p",{id:"inline-editing-error","data-slot":"inline-editing-error",className:"absolute left-0 top-full mt-0.5 text-xs text-destructive",role:"alert",children:b})]}),s.jsx("button",{"data-slot":"inline-editing-save",type:"button",onClick:Y,disabled:w,"aria-label":"Save",className:v.cn("inline-flex h-6 w-6 items-center justify-center rounded text-primary hover:bg-primary/10 transition-colors",w&&"opacity-50 cursor-not-allowed"),children:s.jsx(F.Check,{className:"h-3.5 w-3.5"})}),s.jsx("button",{"data-slot":"inline-editing-cancel",type:"button",onClick:L,disabled:w,"aria-label":"Cancel",className:"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:s.jsx(F.X,{className:"h-3.5 w-3.5"})})]}):s.jsx("div",{"data-slot":"inline-editing",className:v.cn("group relative cursor-pointer rounded px-2 py-1 hover:bg-muted/50 transition-colors min-h-[1.75rem] flex items-center",p&&"cursor-default opacity-60",o),onClick:I,role:"button",tabIndex:p?-1:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),I())},"aria-label":`Edit value: ${String(e??"")}`,children:s.jsx("span",{"data-slot":"inline-editing-display",className:"truncate text-sm",children:e!=null&&String(e)!==""?String(e):s.jsx("span",{className:"text-muted-foreground italic",children:i||"Click to edit"})})})}function ht(e){return{startRow:Math.min(e.startRow,e.endRow),startCol:Math.min(e.startCol,e.endCol),endRow:Math.max(e.startRow,e.endRow),endCol:Math.max(e.startCol,e.endCol)}}function ms({data:e,columns:l,onPaste:t,enabled:r=!0}){const[n,i]=f.useState(null),a=f.useCallback(()=>{if(!r||!n)return;const{startRow:h,startCol:d,endRow:m,endCol:g}=ht(n),b=[];for(let w=h;w<=m;w++){const T=e[w];if(!T)continue;const D=[];for(let I=d;I<=g;I++){const L=l[I];D.push(L?String(T[L]??""):"")}b.push(D.join(" "))}const C=b.join(`
14
- `);navigator.clipboard.writeText(C)},[r,n,e,l]),o=f.useCallback(()=>{if(!r||!n||!t)return;const{startRow:h,startCol:d}=ht(n);navigator.clipboard.readText().then(m=>{const g=[],b=m.split(`
15
- `);for(let C=0;C<b.length;C++){const w=b[C].split(" ");for(let T=0;T<w.length;T++){const D=h+C,I=d+T,L=l[I];L&&D<e.length&&g.push({rowIndex:D,field:L,value:w[T]})}}g.length>0&&t(g)})},[r,n,l,e.length,t]),p=f.useCallback(h=>{if(!r)return;const d=h.metaKey||h.ctrlKey;d&&h.key==="c"?(h.preventDefault(),a()):d&&h.key==="v"&&(h.preventDefault(),o())},[r,a,o]);return f.useEffect(()=>{r||i(null)},[r]),{selectedRange:n,setSelectedRange:i,onCopy:a,onPaste:o,onKeyDown:p}}const ps=[{position:0,className:"bg-green-100"},{position:.5,className:"bg-yellow-100"},{position:1,className:"bg-red-100"}];function gs(e,l){let t=1/0,r=-1/0;for(const n of e){const i=Number(n[l]);Number.isFinite(i)&&(i<t&&(t=i),i>r&&(r=i))}return Number.isFinite(t)?[t,r]:[0,0]}function xs(e,l){if(l.length===0)return"";if(l.length===1)return l[0].className;let t=l[0],r=Math.abs(e-t.position);for(let n=1;n<l.length;n++){const i=Math.abs(e-l[n].position);i<r&&(t=l[n],r=i)}return t.className}function bs(e){const{field:l,data:t,min:r,max:n,stops:i=ps}=e,[a,o]=f.useMemo(()=>gs(t,l),[t,l]),p=r??a,h=n??o;return f.useCallback(d=>{const m=Number(d[l]);if(!Number.isFinite(m))return;if(h===p)return i.length>0?i[0].className:void 0;const g=Math.max(0,Math.min(1,(m-p)/(h-p)));return xs(g,i)},[l,p,h,i])}const mt="text/x-group-key";function ys({groupKeys:e}){const[l,t]=f.useState(e),[r,n]=f.useState(null);f.useEffect(()=>{t(d=>{const m=new Set(d),g=new Set(e);if(d.length===e.length&&d.every((w,T)=>w===e[T]))return d;const b=d.filter(w=>g.has(w)),C=e.filter(w=>!m.has(w));return[...b,...C]})},[e]);const i=f.useCallback((d,m)=>{t(g=>{if(d<0||d>=g.length||m<0||m>=g.length||d===m)return g;const b=[...g],[C]=b.splice(d,1);return b.splice(m,0,C),b})},[]),a=f.useCallback((d,m)=>{d.dataTransfer.effectAllowed="move",d.dataTransfer.setData(mt,m),n(m)},[]),o=f.useCallback(d=>{d.preventDefault(),d.dataTransfer.dropEffect="move"},[]),p=f.useCallback((d,m)=>{d.preventDefault();const g=d.dataTransfer.getData(mt);!g||g===m||t(b=>{const C=b.indexOf(g),w=b.indexOf(m);if(C===-1||w===-1)return b;const T=[...b],[D]=T.splice(C,1);return T.splice(w,0,D),T})},[]),h=f.useCallback(()=>{n(null)},[]);return{groupOrder:l,moveGroup:i,onDragStart:a,onDragOver:o,onDrop:p,onDragEnd:h,draggingKey:r}}function vs({value:e,onChange:l,onConfirm:t,onCancel:r,activeCell:n,disabled:i=!1,className:a}){const[o,p]=f.useState(!1),[h,d]=f.useState(e),m=f.useRef(null);f.useEffect(()=>{o||d(e)},[e,o]),f.useEffect(()=>{o&&m.current&&(m.current.focus(),m.current.select())},[o]);const g=f.useCallback(()=>{i||(p(!0),d(e))},[i,e]),b=f.useCallback(()=>{p(!1),l?.(h),t?.(h)},[h,l,t]),C=f.useCallback(()=>{p(!1),d(e),r?.()},[e,r]),w=f.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),b()):T.key==="Escape"&&(T.preventDefault(),C())},[b,C]);return s.jsxs("div",{className:v.cn("flex items-center gap-2 border-b border-border bg-muted/30 px-3 py-1.5",a),children:[s.jsx(F.FunctionSquare,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),n&&s.jsx("span",{className:"min-w-[4rem] shrink-0 rounded bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:n}),s.jsx("input",{ref:m,type:"text",value:o?h:e,readOnly:!o,disabled:i,onClick:g,onChange:T=>d(T.target.value),onKeyDown:w,className:v.cn("flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground",o&&"rounded ring-1 ring-ring px-1",i&&"cursor-not-allowed opacity-50")}),o&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:b,className:"rounded p-0.5 text-green-600 hover:bg-green-100","aria-label":"Confirm",children:s.jsx(F.Check,{className:"h-4 w-4"})}),s.jsx("button",{type:"button",onClick:C,className:"rounded p-0.5 text-red-600 hover:bg-red-100","aria-label":"Cancel",children:s.jsx(F.X,{className:"h-4 w-4"})})]})]})}function js({frozenWidth:e,onResize:l,minFrozenWidth:t=100,minScrollableWidth:r=200,left:n,right:i,className:a}){const o=f.useRef(null),[p,h]=f.useState(e),d=f.useRef(!1),m=f.useRef(0),g=f.useRef(0),b=l?e:p,C=f.useCallback(w=>{w.preventDefault(),d.current=!0,m.current=w.clientX,g.current=b;const T=I=>{if(!d.current||!o.current)return;const L=o.current.offsetWidth,Y=I.clientX-m.current;let q=g.current+Y;q=Math.max(q,t),q=Math.min(q,L-r),l?l(q):h(q)},D=()=>{d.current=!1,document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",D)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",D)},[b,t,r,l]);return s.jsxs("div",{ref:o,className:v.cn("flex h-full w-full overflow-hidden",a),children:[s.jsx("div",{className:"shrink-0 overflow-auto",style:{width:b},children:n}),s.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:C,className:v.cn("flex w-2 cursor-col-resize items-center justify-center","border-x border-border bg-muted/50 hover:bg-muted","transition-colors"),children:s.jsx(F.GripVertical,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1 overflow-auto",children:i})]})}const Ge=({schema:e,...l})=>{const{dataSource:t}=pe.useSchemaContext()||{};return s.jsx(nt,{schema:e,dataSource:t,...l})};_e.ComponentRegistry.register("object-grid",Ge,{namespace:"plugin-grid",label:"Object Grid",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"},{name:"filters",type:"array",label:"Filters"}]}),_e.ComponentRegistry.register("grid",Ge,{namespace:"view",label:"Data Grid",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"},{name:"filters",type:"array",label:"Filters"}]});const ws=({schema:e,...l})=>{const{dataSource:t}=pe.useSchemaContext()||{};return s.jsx(ft,{objectName:e.objectName,objectLabel:e.objectLabel,fields:e.fields??[],dataSource:t,...l})};_e.ComponentRegistry.register("import-wizard",ws,{namespace:"plugin-grid",label:"Import Wizard",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"fields",type:"array",label:"Fields",required:!0}]}),P.BulkActionBar=We,P.FormulaBar=vs,P.GroupRow=et,P.ImportWizard=ft,P.InlineEditing=hs,P.ObjectGrid=nt,P.ObjectGridRenderer=Ge,P.RowActionMenu=st,P.SplitPaneGrid=js,P.VirtualGrid=is,P.formatActionLabel=Pe,P.useCellClipboard=ms,P.useColumnSummary=tt,P.useGradientColor=bs,P.useGroupReorder=ys,P.useGroupedData=Ze,P.useRowColor=Qe,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
11
+ color: hsl(${Math.max(0,Math.min(120-120*T,120))}deg 100% 31%);`,t?.key)}return t?.onChange&&!(i&&t.skipInitialOnChange)&&t.onChange(n),i=!1,n}return a.updateDeps=l=>{r=l},a}function it(e,o){if(e===void 0)throw new Error("Unexpected undefined");return e}const Ut=(e,o)=>Math.abs(e-o)<1.01,Yt=(e,o,t)=>{let r;return function(...n){e.clearTimeout(r),r=e.setTimeout(()=>o.apply(this,n),t)}},ot=e=>{const{offsetWidth:o,offsetHeight:t}=e;return{width:o,height:t}},Jt=e=>e,Xt=e=>{const o=Math.max(e.startIndex-e.overscan,0),t=Math.min(e.endIndex+e.overscan,e.count-1),r=[];for(let n=o;n<=t;n++)r.push(n);return r},Qt=(e,o)=>{const t=e.scrollElement;if(!t)return;const r=e.targetWindow;if(!r)return;const n=a=>{const{width:l,height:p}=a;o({width:Math.round(l),height:Math.round(p)})};if(n(ot(t)),!r.ResizeObserver)return()=>{};const i=new r.ResizeObserver(a=>{const l=()=>{const p=a[0];if(p?.borderBoxSize){const h=p.borderBoxSize[0];if(h){n({width:h.inlineSize,height:h.blockSize});return}}n(ot(t))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(l):l()});return i.observe(t,{box:"border-box"}),()=>{i.unobserve(t)}},lt={passive:!0},at=typeof window>"u"?!0:"onscrollend"in window,Zt=(e,o)=>{const t=e.scrollElement;if(!t)return;const r=e.targetWindow;if(!r)return;let n=0;const i=e.options.useScrollendEvent&&at?()=>{}:Yt(r,()=>{o(n,!1)},e.options.isScrollingResetDelay),a=d=>()=>{const{horizontal:m,isRtl:g}=e.options;n=m?t.scrollLeft*(g&&-1||1):t.scrollTop,i(),o(n,d)},l=a(!0),p=a(!1);t.addEventListener("scroll",l,lt);const h=e.options.useScrollendEvent&&at;return h&&t.addEventListener("scrollend",p,lt),()=>{t.removeEventListener("scroll",l),h&&t.removeEventListener("scrollend",p)}},es=(e,o,t)=>{if(o?.borderBoxSize){const r=o.borderBoxSize[0];if(r)return Math.round(r[t.options.horizontal?"inlineSize":"blockSize"])}return e[t.options.horizontal?"offsetWidth":"offsetHeight"]},ts=(e,{adjustments:o=0,behavior:t},r)=>{var n,i;const a=e+o;(i=(n=r.scrollElement)==null?void 0:n.scrollTo)==null||i.call(n,{[r.options.horizontal?"left":"top"]:a,behavior:t})};class ss{constructor(o){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.currentScrollToIndex=null,this.measurementsCache=[],this.itemSizeCache=new Map,this.laneAssignments=new Map,this.pendingMeasuredCacheIndexes=[],this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this.elementsCache=new Map,this.observer=(()=>{let t=null;const r=()=>t||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:t=new this.targetWindow.ResizeObserver(n=>{n.forEach(i=>{const a=()=>{this._measureElement(i.target,i)};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(a):a()})}));return{disconnect:()=>{var n;(n=r())==null||n.disconnect(),t=null},observe:n=>{var i;return(i=r())==null?void 0:i.observe(n,{box:"border-box"})},unobserve:n=>{var i;return(i=r())==null?void 0:i.unobserve(n)}}})(),this.range=null,this.setOptions=t=>{Object.entries(t).forEach(([r,n])=>{typeof n>"u"&&delete t[r]}),this.options={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:Jt,rangeExtractor:Xt,onChange:()=>{},measureElement:es,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:"data-index",initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,...t}},this.notify=t=>{var r,n;(n=(r=this.options).onChange)==null||n.call(r,this,t)},this.maybeNotify=Se(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),t=>{this.notify(t)},{key:process.env.NODE_ENV!=="production"&&"maybeNotify",debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(t=>t()),this.unsubs=[],this.observer.disconnect(),this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{var t;const r=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==r){if(this.cleanup(),!r){this.maybeNotify();return}this.scrollElement=r,this.scrollElement&&"ownerDocument"in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=((t=this.scrollElement)==null?void 0:t.window)??null,this.elementsCache.forEach(n=>{this.observer.observe(n)}),this.unsubs.push(this.options.observeElementRect(this,n=>{this.scrollRect=n,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(n,i)=>{this.scrollAdjustments=0,this.scrollDirection=i?this.getScrollOffset()<n?"forward":"backward":null,this.scrollOffset=n,this.isScrolling=i,this.maybeNotify()})),this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?"width":"height"]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset=="function"?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(t,r)=>{const n=new Map,i=new Map;for(let a=r-1;a>=0;a--){const l=t[a];if(n.has(l.lane))continue;const p=i.get(l.lane);if(p==null||l.end>p.end?i.set(l.lane,l):l.end<p.end&&n.set(l.lane,!0),n.size===this.options.lanes)break}return i.size===this.options.lanes?Array.from(i.values()).sort((a,l)=>a.end===l.end?a.index-l.index:a.end-l.end)[0]:void 0},this.getMeasurementOptions=Se(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes],(t,r,n,i,a,l)=>(this.prevLanes!==void 0&&this.prevLanes!==l&&(this.lanesChangedFlag=!0),this.prevLanes=l,this.pendingMeasuredCacheIndexes=[],{count:t,paddingStart:r,scrollMargin:n,getItemKey:i,enabled:a,lanes:l}),{key:!1}),this.getMeasurements=Se(()=>[this.getMeasurementOptions(),this.itemSizeCache],({count:t,paddingStart:r,scrollMargin:n,getItemKey:i,enabled:a,lanes:l},p)=>{if(!a)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>t)for(const g of this.laneAssignments.keys())g>=t&&this.laneAssignments.delete(g);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMeasuredCacheIndexes=[]),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(g=>{this.itemSizeCache.set(g.key,g.size)}));const h=this.lanesSettling?0:this.pendingMeasuredCacheIndexes.length>0?Math.min(...this.pendingMeasuredCacheIndexes):0;this.pendingMeasuredCacheIndexes=[],this.lanesSettling&&this.measurementsCache.length===t&&(this.lanesSettling=!1);const d=this.measurementsCache.slice(0,h),m=new Array(l).fill(void 0);for(let g=0;g<h;g++){const b=d[g];b&&(m[b.lane]=g)}for(let g=h;g<t;g++){const b=i(g),C=this.laneAssignments.get(g);let w,T;if(C!==void 0&&this.options.lanes>1){w=C;const Y=m[w],q=Y!==void 0?d[Y]:void 0;T=q?q.end+this.options.gap:r+n}else{const Y=this.options.lanes===1?d[g-1]:this.getFurthestMeasurement(d,g);T=Y?Y.end+this.options.gap:r+n,w=Y?Y.lane:g%this.options.lanes,this.options.lanes>1&&this.laneAssignments.set(g,w)}const D=p.get(b),I=typeof D=="number"?D:this.options.estimateSize(g),L=T+I;d[g]={index:g,start:T,size:I,end:L,key:b,lane:w},m[w]=g}return this.measurementsCache=d,d},{key:process.env.NODE_ENV!=="production"&&"getMeasurements",debug:()=>this.options.debug}),this.calculateRange=Se(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(t,r,n,i)=>this.range=t.length>0&&r>0?rs({measurements:t,outerSize:r,scrollOffset:n,lanes:i}):null,{key:process.env.NODE_ENV!=="production"&&"calculateRange",debug:()=>this.options.debug}),this.getVirtualIndexes=Se(()=>{let t=null,r=null;const n=this.calculateRange();return n&&(t=n.startIndex,r=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,t,r]),[this.options.rangeExtractor,this.options.overscan,this.options.count,t,r]},(t,r,n,i,a)=>i===null||a===null?[]:t({startIndex:i,endIndex:a,overscan:r,count:n}),{key:process.env.NODE_ENV!=="production"&&"getVirtualIndexes",debug:()=>this.options.debug}),this.indexFromElement=t=>{const r=this.options.indexAttribute,n=t.getAttribute(r);return n?parseInt(n,10):(console.warn(`Missing attribute name '${r}={index}' on measured element.`),-1)},this._measureElement=(t,r)=>{const n=this.indexFromElement(t),i=this.measurementsCache[n];if(!i)return;const a=i.key,l=this.elementsCache.get(a);l!==t&&(l&&this.observer.unobserve(l),this.observer.observe(t),this.elementsCache.set(a,t)),t.isConnected&&this.resizeItem(n,this.options.measureElement(t,r,this))},this.resizeItem=(t,r)=>{const n=this.measurementsCache[t];if(!n)return;const i=this.itemSizeCache.get(n.key)??n.size,a=r-i;a!==0&&((this.shouldAdjustScrollPositionOnItemSizeChange!==void 0?this.shouldAdjustScrollPositionOnItemSizeChange(n,a,this):n.start<this.getScrollOffset()+this.scrollAdjustments)&&(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("correction",a),this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=a,behavior:void 0})),this.pendingMeasuredCacheIndexes.push(n.index),this.itemSizeCache=new Map(this.itemSizeCache.set(n.key,r)),this.notify(!1))},this.measureElement=t=>{if(!t){this.elementsCache.forEach((r,n)=>{r.isConnected||(this.observer.unobserve(r),this.elementsCache.delete(n))});return}this._measureElement(t,void 0)},this.getVirtualItems=Se(()=>[this.getVirtualIndexes(),this.getMeasurements()],(t,r)=>{const n=[];for(let i=0,a=t.length;i<a;i++){const l=t[i],p=r[l];n.push(p)}return n},{key:process.env.NODE_ENV!=="production"&&"getVirtualItems",debug:()=>this.options.debug}),this.getVirtualItemForOffset=t=>{const r=this.getMeasurements();if(r.length!==0)return it(r[ct(0,r.length-1,n=>it(r[n]).start,t)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if("scrollHeight"in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{const t=this.scrollElement.document.documentElement;return this.options.horizontal?t.scrollWidth-this.scrollElement.innerWidth:t.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(t,r,n=0)=>{if(!this.scrollElement)return 0;const i=this.getSize(),a=this.getScrollOffset();r==="auto"&&(r=t>=a+i?"end":"start"),r==="center"?t+=(n-i)/2:r==="end"&&(t-=i);const l=this.getMaxScrollOffset();return Math.max(Math.min(l,t),0)},this.getOffsetForIndex=(t,r="auto")=>{t=Math.max(0,Math.min(t,this.options.count-1));const n=this.measurementsCache[t];if(!n)return;const i=this.getSize(),a=this.getScrollOffset();if(r==="auto")if(n.end>=a+i-this.options.scrollPaddingEnd)r="end";else if(n.start<=a+this.options.scrollPaddingStart)r="start";else return[a,r];if(r==="end"&&t===this.options.count-1)return[this.getMaxScrollOffset(),r];const l=r==="end"?n.end+this.options.scrollPaddingEnd:n.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(l,r,n.size),r]},this.isDynamicMode=()=>this.elementsCache.size>0,this.scrollToOffset=(t,{align:r="start",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getOffsetForAlignment(t,r),{adjustments:void 0,behavior:n})},this.scrollToIndex=(t,{align:r="auto",behavior:n}={})=>{n==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),t=Math.max(0,Math.min(t,this.options.count-1)),this.currentScrollToIndex=t;let i=0;const a=10,l=h=>{if(!this.targetWindow)return;const d=this.getOffsetForIndex(t,h);if(!d){console.warn("Failed to get offset for index:",t);return}const[m,g]=d;this._scrollToOffset(m,{adjustments:void 0,behavior:n}),this.targetWindow.requestAnimationFrame(()=>{if(!this.targetWindow)return;const b=()=>{if(this.currentScrollToIndex!==t)return;const C=this.getScrollOffset(),w=this.getOffsetForIndex(t,g);if(!w){console.warn("Failed to get offset for index:",t);return}Ut(w[0],C)||p(g)};this.isDynamicMode()?this.targetWindow.requestAnimationFrame(b):b()})},p=h=>{this.targetWindow&&this.currentScrollToIndex===t&&(i++,i<a?(process.env.NODE_ENV!=="production"&&this.options.debug&&console.info("Schedule retry",i,a),this.targetWindow.requestAnimationFrame(()=>l(h))):console.warn(`Failed to scroll to index ${t} after ${a} attempts.`))};l(r)},this.scrollBy=(t,{behavior:r}={})=>{r==="smooth"&&this.isDynamicMode()&&console.warn("The `smooth` scroll behavior is not fully supported with dynamic size."),this._scrollToOffset(this.getScrollOffset()+t,{adjustments:void 0,behavior:r})},this.getTotalSize=()=>{var t;const r=this.getMeasurements();let n;if(r.length===0)n=this.options.paddingStart;else if(this.options.lanes===1)n=((t=r[r.length-1])==null?void 0:t.end)??0;else{const i=Array(this.options.lanes).fill(null);let a=r.length-1;for(;a>=0&&i.some(l=>l===null);){const l=r[a];i[l.lane]===null&&(i[l.lane]=l.end),a--}n=Math.max(...i.filter(l=>l!==null))}return Math.max(n-this.options.scrollMargin+this.options.paddingEnd,0)},this._scrollToOffset=(t,{adjustments:r,behavior:n})=>{this.options.scrollToFn(t,{behavior:n,adjustments:r},this)},this.measure=()=>{this.itemSizeCache=new Map,this.laneAssignments=new Map,this.notify(!1)},this.setOptions(o)}}const ct=(e,o,t,r)=>{for(;e<=o;){const n=(e+o)/2|0,i=t(n);if(i<r)e=n+1;else if(i>r)o=n-1;else return n}return e>0?e-1:0};function rs({measurements:e,outerSize:o,scrollOffset:t,lanes:r}){const n=e.length-1,i=p=>e[p].start;if(e.length<=r)return{startIndex:0,endIndex:n};let a=ct(0,n,i,t),l=a;if(r===1)for(;l<n&&e[l].end<t+o;)l++;else if(r>1){const p=Array(r).fill(0);for(;l<n&&p.some(d=>d<t+o);){const d=e[l];p[d.lane]=d.end,l++}const h=Array(r).fill(t+o);for(;a>=0&&h.some(d=>d>=t);){const d=e[a];h[d.lane]=d.start,a--}a=Math.max(0,a-a%r),l=Math.min(n,l+(r-1-l%r))}return{startIndex:a,endIndex:l}}const dt=typeof document<"u"?ze.useLayoutEffect:ze.useEffect;function ns({useFlushSync:e=!0,...o}){const t=ze.useReducer(()=>({}),{})[1],r={...o,onChange:(i,a)=>{var l;e&&a?_t.flushSync(t):t(),(l=o.onChange)==null||l.call(o,i,a)}},[n]=ze.useState(()=>new ss(r));return n.setOptions(r),dt(()=>n._didMount(),[]),dt(()=>n._willUpdate()),n}function is(e){return ns({observeElementRect:Qt,observeElementOffset:Zt,scrollToFn:ts,...e})}const os=({data:e,columns:o,rowHeight:t=40,height:r=600,className:n="",headerClassName:i="",rowClassName:a,onRowClick:l,overscan:p=5})=>{const h=f.useRef(null),d=is({count:e.length,getScrollElement:()=>h.current,estimateSize:()=>t,overscan:p}),m=d.getVirtualItems();return s.jsxs("div",{className:n,children:[s.jsx("div",{className:`grid border-b sticky top-0 bg-muted/30 z-10 ${i}`,style:{gridTemplateColumns:o.map(g=>g.width||"1fr").join(" ")},children:o.map((g,b)=>s.jsx("div",{className:`px-4 py-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70 ${g.align==="center"?"text-center":g.align==="right"?"text-right":"text-left"}`,children:g.header},b))}),s.jsx("div",{ref:h,className:"overflow-auto",style:{height:typeof r=="number"?`${r}px`:r,contain:"strict"},children:s.jsx("div",{style:{height:`${d.getTotalSize()}px`,width:"100%",position:"relative"},children:m.map(g=>{const b=e[g.index],C=typeof a=="function"?a(b,g.index):a||"";return s.jsx("div",{className:`grid border-b hover:bg-muted/50 cursor-pointer ${C}`,style:{position:"absolute",top:0,left:0,width:"100%",height:`${g.size}px`,transform:`translateY(${g.start}px)`,gridTemplateColumns:o.map(w=>w.width||"1fr").join(" ")},onClick:()=>l?.(b,g.index),children:o.map((w,T)=>{const D=b[w.accessorKey],I=w.cell?w.cell(D,b):D;return s.jsx("div",{className:`px-4 py-2 text-sm flex items-center ${w.align==="center"?"text-center justify-center":w.align==="right"?"text-right justify-end":"text-left justify-start"}`,children:I},T)})},g.key)})})}),s.jsxs("div",{className:"px-4 py-2 text-xs text-muted-foreground border-t",children:["Showing ",m.length," of ",e.length," rows (virtual scrolling enabled)"]})]})},ls=10;function as(e){const o=[];let t=[],r="",n=!1;for(let i=0;i<e.length;i++){const a=e[i],l=e[i+1];n?a==='"'&&l==='"'?(r+='"',i++):a==='"'?n=!1:r+=a:a==='"'?n=!0:a===","?(t.push(r.trim()),r=""):a===`
12
+ `||a==="\r"&&l===`
13
+ `?(t.push(r.trim()),t.some(p=>p!=="")&&o.push(t),t=[],r="",a==="\r"&&i++):r+=a}return t.push(r.trim()),t.some(i=>i!=="")&&o.push(t),o}function ut(e,o){if(!e)return!0;switch(o){case"number":case"currency":case"percent":return!isNaN(Number(e));case"boolean":return["true","false","1","0","yes","no"].includes(e.toLowerCase());case"date":case"datetime":return!isNaN(Date.parse(e));default:return!0}}function cs(e,o){const t={};return e.forEach((r,n)=>{const i=r.toLowerCase().replace(/[_\s-]/g,""),a=o.find(l=>{const p=l.name.toLowerCase().replace(/[_\s-]/g,""),h=l.label.toLowerCase().replace(/[_\s-]/g,"");return p===i||h===i});a&&(t[n]=a.name)}),t}function ds(e,o,t){const r=[],n={};for(const i of o){const a=e[i.csvIdx]??"";if(i.field.required&&!a){r.push({row:t,field:i.field.name,message:"Required field is empty"});continue}if(a&&!ut(a,i.field.type)){r.push({row:t,field:i.field.name,message:`Invalid ${i.field.type} value: "${a}"`});continue}n[i.field.name]=a}return{record:n,errors:r}}const us=({onFileLoaded:e})=>{const[o,t]=f.useState(!1),[r,n]=f.useState(null),i=f.useCallback(a=>{if(n(null),!a.name.endsWith(".csv")){n("Only CSV files are supported.");return}const l=new FileReader;l.onload=p=>{const h=as(p.target?.result);if(h.length<2){n("File must contain a header row and at least one data row.");return}e(h[0],h.slice(1))},l.readAsText(a)},[e]);return s.jsxs("div",{className:"flex flex-col items-center gap-4 py-6",children:[s.jsxs("div",{className:v.cn("flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors",o?"border-primary bg-primary/5":"border-muted-foreground/25"),onDragOver:a=>{a.preventDefault(),t(!0)},onDragLeave:()=>t(!1),onDrop:a=>{a.preventDefault(),t(!1);const l=a.dataTransfer.files[0];l&&i(l)},children:[s.jsx(F.Upload,{className:"h-10 w-10 text-muted-foreground"}),s.jsx("p",{className:"text-sm text-muted-foreground",children:"Drag & drop a CSV file here, or click to browse"}),s.jsxs("label",{children:[s.jsx("input",{type:"file",accept:".csv",className:"hidden",onChange:a=>{const l=a.target.files?.[0];l&&i(l)}}),s.jsx(v.Button,{variant:"outline",size:"sm",asChild:!0,children:s.jsx("span",{children:"Browse Files"})})]})]}),r&&s.jsxs("p",{className:"flex items-center gap-1 text-sm text-destructive",children:[s.jsx(F.AlertCircle,{className:"h-4 w-4"})," ",r]})]})},fs=({headers:e,fields:o,mapping:t,onMappingChange:r})=>{const n=f.useMemo(()=>new Set(Object.values(t)),[t]),i=f.useCallback((a,l)=>{const p={...t};l==="__skip__"?delete p[a]:p[a]=l,r(p)},[t,r]);return s.jsx("div",{className:"max-h-[360px] overflow-auto",children:s.jsxs(v.Table,{children:[s.jsx(v.TableHeader,{children:s.jsxs(v.TableRow,{children:[s.jsx(v.TableHead,{children:"CSV Column"}),s.jsx(v.TableHead,{children:"Maps To"}),s.jsx(v.TableHead,{className:"w-24 text-center",children:"Status"})]})}),s.jsx(v.TableBody,{children:e.map((a,l)=>s.jsxs(v.TableRow,{children:[s.jsx(v.TableCell,{className:"font-medium",children:a}),s.jsx(v.TableCell,{children:s.jsxs(v.Select,{value:t[l]??"__skip__",onValueChange:p=>i(l,p),children:[s.jsx(v.SelectTrigger,{className:"h-8 w-56",children:s.jsx(v.SelectValue,{placeholder:"Skip column"})}),s.jsxs(v.SelectContent,{children:[s.jsx(v.SelectItem,{value:"__skip__",children:"— Skip —"}),o.map(p=>s.jsxs(v.SelectItem,{value:p.name,disabled:n.has(p.name)&&t[l]!==p.name,children:[p.label,p.required?" *":""]},p.name))]})]})}),s.jsx(v.TableCell,{className:"text-center",children:t[l]?s.jsx(v.Badge,{variant:"default",className:"text-xs",children:"Mapped"}):s.jsx(v.Badge,{variant:"secondary",className:"text-xs",children:"Skipped"})})]},l))})]})})},hs=({headers:e,rows:o,mapping:t,fields:r})=>{const n=f.useMemo(()=>Object.entries(t).map(([p,h])=>({csvIdx:Number(p),header:e[Number(p)],field:r.find(d=>d.name===h)})),[t,e,r]),i=o.slice(0,ls),a=f.useMemo(()=>i.map((p,h)=>{const d={};for(const m of n){const g=p[m.csvIdx]??"";m.field.required&&!g?d[m.csvIdx]="Required":g&&!ut(g,m.field.type)&&(d[m.csvIdx]=`Invalid ${m.field.type}`)}return d}),[i,n]),l=a.filter(p=>Object.keys(p).length>0).length;return s.jsxs("div",{className:"max-h-[360px] overflow-auto",children:[l>0&&s.jsxs("p",{className:"mb-2 flex items-center gap-1 text-xs text-destructive",children:[s.jsx(F.AlertCircle,{className:"h-3.5 w-3.5"})," ",l," row(s) with errors in preview"]}),s.jsxs(v.Table,{children:[s.jsx(v.TableHeader,{children:s.jsxs(v.TableRow,{children:[s.jsx(v.TableHead,{className:"w-12",children:"#"}),n.map(p=>s.jsx(v.TableHead,{children:p.field.label},p.csvIdx))]})}),s.jsx(v.TableBody,{children:i.map((p,h)=>{const d=a[h],m=Object.keys(d).length>0;return s.jsxs(v.TableRow,{className:v.cn(m&&"bg-destructive/5"),children:[s.jsx(v.TableCell,{className:"text-xs text-muted-foreground",children:h+1}),n.map(g=>{const b=p[g.csvIdx]??"",C=d[g.csvIdx];return s.jsx(v.TableCell,{className:v.cn(C&&"text-destructive"),title:C,children:b||s.jsx("span",{className:"text-muted-foreground/50",children:"—"})},g.csvIdx)})]},h)})})]}),s.jsxs("p",{className:"mt-2 text-xs text-muted-foreground",children:["Showing ",i.length," of ",o.length," rows"]})]})},ft=({objectName:e,objectLabel:o,fields:t,dataSource:r,onComplete:n,onCancel:i,open:a,onOpenChange:l,onErrorMode:p="skip"})=>{const[h,d]=f.useState("upload"),[m,g]=f.useState([]),[b,C]=f.useState([]),[w,T]=f.useState({}),[D,I]=f.useState(!1),[L,Y]=f.useState(0),[q,J]=f.useState(null),le=o??e,Me=f.useMemo(()=>{const V=new Set(Object.values(w));return t.filter(Q=>Q.required&&!V.has(Q.name))},[t,w]),ve=f.useCallback((V,Q)=>{g(V),C(Q),T(cs(V,t)),d("mapping")},[t]),Ee=f.useCallback(async()=>{I(!0),Y(0);const V=[];let Q=0,he=0;const ae=Object.entries(w).map(([re,be])=>({csvIdx:Number(re),field:t.find(xe=>xe.name===be)}));for(let re=0;re<b.length;re++){const{record:be,errors:xe}=ds(b[re],ae,re+1);if(xe.length>0){if(he++,V.push(...xe),p==="stop")break}else try{r?.create&&await r.create(e,be),Q++}catch(u){he++;const A=u instanceof Error?u.message:"Failed to create record";if(V.push({row:re+1,field:"",message:A}),p==="stop")break}Y(Math.round((re+1)/b.length*100))}const je={totalRows:b.length,importedRows:Q,skippedRows:he,errors:V};J(je),I(!1),n?.(je)},[b,w,t,r,e,n,p]),de=f.useCallback(()=>{d("upload"),g([]),C([]),T({}),Y(0),J(null)},[]),ge=f.useCallback(()=>{de(),l?.(!1),i?.()},[de,l,i]);return s.jsx(v.Dialog,{open:a,onOpenChange:V=>{V?l?.(V):ge()},children:s.jsxs(v.DialogContent,{className:"sm:max-w-2xl",children:[s.jsxs(v.DialogHeader,{children:[s.jsxs(v.DialogTitle,{className:"flex items-center gap-2",children:[s.jsx(F.FileSpreadsheet,{className:"h-5 w-5"})," Import ",le]}),s.jsxs(v.DialogDescription,{children:[h==="upload"&&"Upload a CSV file to get started.",h==="mapping"&&"Map CSV columns to object fields.",h==="preview"&&"Review data before importing."]})]}),s.jsx("div",{className:"flex items-center justify-center gap-2 text-xs text-muted-foreground",children:["upload","mapping","preview"].map((V,Q)=>s.jsxs(f.Fragment,{children:[Q>0&&s.jsx(F.ArrowRight,{className:"h-3 w-3"}),s.jsxs("span",{className:v.cn("rounded-full px-3 py-1",h===V?"bg-primary text-primary-foreground":"bg-muted"),children:[Q+1,". ",V==="upload"?"Upload":V==="mapping"?"Mapping":"Preview"]})]},V))}),q?s.jsxs("div",{className:"flex flex-col items-center gap-3 py-4",children:[s.jsx(F.CheckCircle2,{className:"h-10 w-10 text-green-500"}),s.jsx("p",{className:"text-lg font-semibold",children:"Import Complete"}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs(v.Badge,{variant:"default",children:[q.importedRows," imported"]}),q.skippedRows>0&&s.jsxs(v.Badge,{variant:"destructive",children:[q.skippedRows," skipped"]})]}),q.errors.length>0&&s.jsxs("div",{className:"max-h-32 w-full overflow-auto rounded border p-2 text-xs",children:[q.errors.slice(0,10).map((V,Q)=>s.jsxs("p",{className:"text-destructive",children:["Row ",V.row,V.field?` (${V.field})`:"",": ",V.message]},Q)),q.errors.length>10&&s.jsxs("p",{className:"text-muted-foreground",children:["…and ",q.errors.length-10," more errors"]})]})]}):s.jsxs(s.Fragment,{children:[h==="upload"&&s.jsx(us,{onFileLoaded:ve}),h==="mapping"&&s.jsx(fs,{headers:m,fields:t,mapping:w,onMappingChange:T}),h==="preview"&&s.jsx(hs,{headers:m,rows:b,mapping:w,fields:t}),D&&s.jsxs("div",{className:"flex flex-col gap-1",children:[s.jsx(v.Progress,{value:L,className:"h-2"}),s.jsxs("p",{className:"text-center text-xs text-muted-foreground",children:["Importing… ",L,"%"]})]})]}),s.jsx(v.DialogFooter,{className:"gap-2 sm:gap-0",children:q?s.jsx(v.Button,{onClick:ge,children:"Close"}):s.jsxs(s.Fragment,{children:[s.jsxs(v.Button,{variant:"ghost",onClick:ge,disabled:D,children:[s.jsx(F.X,{className:"mr-1 h-4 w-4"})," Cancel"]}),(h==="mapping"||h==="preview")&&s.jsxs(v.Button,{variant:"outline",onClick:()=>d(h==="mapping"?"upload":"mapping"),disabled:D,children:[s.jsx(F.ArrowLeft,{className:"mr-1 h-4 w-4"})," Back"]}),h==="mapping"&&s.jsxs(v.Button,{onClick:()=>d("preview"),disabled:Object.keys(w).length===0||Me.length>0,children:["Next ",s.jsx(F.ArrowRight,{className:"ml-1 h-4 w-4"})]}),h==="preview"&&s.jsx(v.Button,{onClick:Ee,disabled:D,children:D?"Importing…":`Import ${b.length} Rows`})]})})]})})};function ms({value:e,onSave:o,onCancel:t,validate:r,type:n="text",placeholder:i,editing:a=!1,className:l,disabled:p=!1}){const[h,d]=f.useState(a),[m,g]=f.useState(String(e??"")),[b,C]=f.useState(),[w,T]=f.useState(!1),D=f.useRef(null);f.useEffect(()=>{h||g(String(e??""))},[e,h]),f.useEffect(()=>{h&&D.current&&(D.current.focus(),D.current.select())},[h]);const I=f.useCallback(()=>{p||(d(!0),g(String(e??"")),C(void 0))},[p,e]),L=f.useCallback(()=>{d(!1),g(String(e??"")),C(void 0),t?.()},[e,t]),Y=f.useCallback(async()=>{if(r){const le=r(m);if(le){C(le);return}}const J=n==="number"?Number(m):m;T(!0);try{const le=await o(J);if(typeof le=="string"){C(le),T(!1);return}d(!1),C(void 0)}catch(le){C(le?.message||"Save failed")}finally{T(!1)}},[m,r,n,o]),q=f.useCallback(J=>{J.key==="Enter"?(J.preventDefault(),Y()):J.key==="Escape"&&(J.preventDefault(),L())},[Y,L]);return h?s.jsxs("div",{"data-slot":"inline-editing",className:v.cn("relative flex items-center gap-1",l),children:[s.jsxs("div",{className:"flex-1 relative",children:[s.jsx("input",{ref:D,"data-slot":"inline-editing-input",type:n,value:m,onChange:J=>{g(J.target.value),b&&C(void 0)},onKeyDown:q,placeholder:i,disabled:w,"aria-invalid":!!b,"aria-describedby":b?"inline-editing-error":void 0,className:v.cn("w-full rounded border px-2 py-1 text-sm outline-none transition-colors","focus:ring-2 focus:ring-ring focus:border-input",b?"border-destructive focus:ring-destructive/30":"border-input",w&&"opacity-50")}),b&&s.jsx("p",{id:"inline-editing-error","data-slot":"inline-editing-error",className:"absolute left-0 top-full mt-0.5 text-xs text-destructive",role:"alert",children:b})]}),s.jsx("button",{"data-slot":"inline-editing-save",type:"button",onClick:Y,disabled:w,"aria-label":"Save",className:v.cn("inline-flex h-6 w-6 items-center justify-center rounded text-primary hover:bg-primary/10 transition-colors",w&&"opacity-50 cursor-not-allowed"),children:s.jsx(F.Check,{className:"h-3.5 w-3.5"})}),s.jsx("button",{"data-slot":"inline-editing-cancel",type:"button",onClick:L,disabled:w,"aria-label":"Cancel",className:"inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",children:s.jsx(F.X,{className:"h-3.5 w-3.5"})})]}):s.jsx("div",{"data-slot":"inline-editing",className:v.cn("group relative cursor-pointer rounded px-2 py-1 hover:bg-muted/50 transition-colors min-h-[1.75rem] flex items-center",p&&"cursor-default opacity-60",l),onClick:I,role:"button",tabIndex:p?-1:0,onKeyDown:J=>{(J.key==="Enter"||J.key===" ")&&(J.preventDefault(),I())},"aria-label":`Edit value: ${String(e??"")}`,children:s.jsx("span",{"data-slot":"inline-editing-display",className:"truncate text-sm",children:e!=null&&String(e)!==""?String(e):s.jsx("span",{className:"text-muted-foreground italic",children:i||"Click to edit"})})})}function ht(e){return{startRow:Math.min(e.startRow,e.endRow),startCol:Math.min(e.startCol,e.endCol),endRow:Math.max(e.startRow,e.endRow),endCol:Math.max(e.startCol,e.endCol)}}function ps({data:e,columns:o,onPaste:t,enabled:r=!0}){const[n,i]=f.useState(null),a=f.useCallback(()=>{if(!r||!n)return;const{startRow:h,startCol:d,endRow:m,endCol:g}=ht(n),b=[];for(let w=h;w<=m;w++){const T=e[w];if(!T)continue;const D=[];for(let I=d;I<=g;I++){const L=o[I];D.push(L?String(T[L]??""):"")}b.push(D.join(" "))}const C=b.join(`
14
+ `);navigator.clipboard.writeText(C)},[r,n,e,o]),l=f.useCallback(()=>{if(!r||!n||!t)return;const{startRow:h,startCol:d}=ht(n);navigator.clipboard.readText().then(m=>{const g=[],b=m.split(`
15
+ `);for(let C=0;C<b.length;C++){const w=b[C].split(" ");for(let T=0;T<w.length;T++){const D=h+C,I=d+T,L=o[I];L&&D<e.length&&g.push({rowIndex:D,field:L,value:w[T]})}}g.length>0&&t(g)})},[r,n,o,e.length,t]),p=f.useCallback(h=>{if(!r)return;const d=h.metaKey||h.ctrlKey;d&&h.key==="c"?(h.preventDefault(),a()):d&&h.key==="v"&&(h.preventDefault(),l())},[r,a,l]);return f.useEffect(()=>{r||i(null)},[r]),{selectedRange:n,setSelectedRange:i,onCopy:a,onPaste:l,onKeyDown:p}}const gs=[{position:0,className:"bg-green-100"},{position:.5,className:"bg-yellow-100"},{position:1,className:"bg-red-100"}];function xs(e,o){let t=1/0,r=-1/0;for(const n of e){const i=Number(n[o]);Number.isFinite(i)&&(i<t&&(t=i),i>r&&(r=i))}return Number.isFinite(t)?[t,r]:[0,0]}function bs(e,o){if(o.length===0)return"";if(o.length===1)return o[0].className;let t=o[0],r=Math.abs(e-t.position);for(let n=1;n<o.length;n++){const i=Math.abs(e-o[n].position);i<r&&(t=o[n],r=i)}return t.className}function ys(e){const{field:o,data:t,min:r,max:n,stops:i=gs}=e,[a,l]=f.useMemo(()=>xs(t,o),[t,o]),p=r??a,h=n??l;return f.useCallback(d=>{const m=Number(d[o]);if(!Number.isFinite(m))return;if(h===p)return i.length>0?i[0].className:void 0;const g=Math.max(0,Math.min(1,(m-p)/(h-p)));return bs(g,i)},[o,p,h,i])}const mt="text/x-group-key";function vs({groupKeys:e}){const[o,t]=f.useState(e),[r,n]=f.useState(null);f.useEffect(()=>{t(d=>{const m=new Set(d),g=new Set(e);if(d.length===e.length&&d.every((w,T)=>w===e[T]))return d;const b=d.filter(w=>g.has(w)),C=e.filter(w=>!m.has(w));return[...b,...C]})},[e]);const i=f.useCallback((d,m)=>{t(g=>{if(d<0||d>=g.length||m<0||m>=g.length||d===m)return g;const b=[...g],[C]=b.splice(d,1);return b.splice(m,0,C),b})},[]),a=f.useCallback((d,m)=>{d.dataTransfer.effectAllowed="move",d.dataTransfer.setData(mt,m),n(m)},[]),l=f.useCallback(d=>{d.preventDefault(),d.dataTransfer.dropEffect="move"},[]),p=f.useCallback((d,m)=>{d.preventDefault();const g=d.dataTransfer.getData(mt);!g||g===m||t(b=>{const C=b.indexOf(g),w=b.indexOf(m);if(C===-1||w===-1)return b;const T=[...b],[D]=T.splice(C,1);return T.splice(w,0,D),T})},[]),h=f.useCallback(()=>{n(null)},[]);return{groupOrder:o,moveGroup:i,onDragStart:a,onDragOver:l,onDrop:p,onDragEnd:h,draggingKey:r}}function js({value:e,onChange:o,onConfirm:t,onCancel:r,activeCell:n,disabled:i=!1,className:a}){const[l,p]=f.useState(!1),[h,d]=f.useState(e),m=f.useRef(null);f.useEffect(()=>{l||d(e)},[e,l]),f.useEffect(()=>{l&&m.current&&(m.current.focus(),m.current.select())},[l]);const g=f.useCallback(()=>{i||(p(!0),d(e))},[i,e]),b=f.useCallback(()=>{p(!1),o?.(h),t?.(h)},[h,o,t]),C=f.useCallback(()=>{p(!1),d(e),r?.()},[e,r]),w=f.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),b()):T.key==="Escape"&&(T.preventDefault(),C())},[b,C]);return s.jsxs("div",{className:v.cn("flex items-center gap-2 border-b border-border bg-muted/30 px-3 py-1.5",a),children:[s.jsx(F.FunctionSquare,{className:"h-4 w-4 shrink-0 text-muted-foreground"}),n&&s.jsx("span",{className:"min-w-[4rem] shrink-0 rounded bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",children:n}),s.jsx("input",{ref:m,type:"text",value:l?h:e,readOnly:!l,disabled:i,onClick:g,onChange:T=>d(T.target.value),onKeyDown:w,className:v.cn("flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground",l&&"rounded ring-1 ring-ring px-1",i&&"cursor-not-allowed opacity-50")}),l&&s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("button",{type:"button",onClick:b,className:"rounded p-0.5 text-green-600 hover:bg-green-100","aria-label":"Confirm",children:s.jsx(F.Check,{className:"h-4 w-4"})}),s.jsx("button",{type:"button",onClick:C,className:"rounded p-0.5 text-red-600 hover:bg-red-100","aria-label":"Cancel",children:s.jsx(F.X,{className:"h-4 w-4"})})]})]})}function ws({frozenWidth:e,onResize:o,minFrozenWidth:t=100,minScrollableWidth:r=200,left:n,right:i,className:a}){const l=f.useRef(null),[p,h]=f.useState(e),d=f.useRef(!1),m=f.useRef(0),g=f.useRef(0),b=o?e:p,C=f.useCallback(w=>{w.preventDefault(),d.current=!0,m.current=w.clientX,g.current=b;const T=I=>{if(!d.current||!l.current)return;const L=l.current.offsetWidth,Y=I.clientX-m.current;let q=g.current+Y;q=Math.max(q,t),q=Math.min(q,L-r),o?o(q):h(q)},D=()=>{d.current=!1,document.removeEventListener("pointermove",T),document.removeEventListener("pointerup",D)};document.addEventListener("pointermove",T),document.addEventListener("pointerup",D)},[b,t,r,o]);return s.jsxs("div",{ref:l,className:v.cn("flex h-full w-full overflow-hidden",a),children:[s.jsx("div",{className:"shrink-0 overflow-auto",style:{width:b},children:n}),s.jsx("div",{role:"separator","aria-orientation":"vertical",onPointerDown:C,className:v.cn("flex w-2 cursor-col-resize items-center justify-center","border-x border-border bg-muted/50 hover:bg-muted","transition-colors"),children:s.jsx(F.GripVertical,{className:"h-4 w-4 text-muted-foreground"})}),s.jsx("div",{className:"min-w-0 flex-1 overflow-auto",children:i})]})}const Ge=({schema:e,...o})=>{const{dataSource:t}=pe.useSchemaContext()||{};return s.jsx(nt,{schema:e,dataSource:t,...o})};_e.ComponentRegistry.register("object-grid",Ge,{namespace:"plugin-grid",label:"Object Grid",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"},{name:"filters",type:"array",label:"Filters"}]}),_e.ComponentRegistry.register("grid",Ge,{namespace:"view",label:"Data Grid",category:"view",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"columns",type:"array",label:"Columns"},{name:"filters",type:"array",label:"Filters"}]});const Cs=({schema:e,...o})=>{const{dataSource:t}=pe.useSchemaContext()||{};return s.jsx(ft,{objectName:e.objectName,objectLabel:e.objectLabel,fields:e.fields??[],dataSource:t,...o})};_e.ComponentRegistry.register("import-wizard",Cs,{namespace:"plugin-grid",label:"Import Wizard",category:"plugin",inputs:[{name:"objectName",type:"string",label:"Object Name",required:!0},{name:"fields",type:"array",label:"Fields",required:!0}]}),P.BulkActionBar=We,P.FormulaBar=js,P.GroupRow=et,P.ImportWizard=ft,P.InlineEditing=ms,P.ObjectGrid=nt,P.ObjectGridRenderer=Ge,P.RowActionMenu=st,P.SplitPaneGrid=ws,P.VirtualGrid=os,P.formatActionLabel=Pe,P.useCellClipboard=ps,P.useColumnSummary=tt,P.useGradientColor=ys,P.useGroupReorder=vs,P.useGroupedData=Ze,P.useRowColor=Qe,Object.defineProperty(P,Symbol.toStringTag,{value:"Module"})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-grid",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "Grid plugin for Object UI",
@@ -17,12 +17,12 @@
17
17
  "dependencies": {
18
18
  "@tanstack/react-virtual": "^3.13.19",
19
19
  "lucide-react": "^0.576.0",
20
- "@object-ui/components": "3.1.0",
21
- "@object-ui/core": "3.1.0",
22
- "@object-ui/fields": "3.1.0",
23
- "@object-ui/mobile": "3.1.0",
24
- "@object-ui/react": "3.1.0",
25
- "@object-ui/types": "3.1.0"
20
+ "@object-ui/components": "3.1.2",
21
+ "@object-ui/core": "3.1.2",
22
+ "@object-ui/fields": "3.1.2",
23
+ "@object-ui/react": "3.1.2",
24
+ "@object-ui/types": "3.1.2",
25
+ "@object-ui/mobile": "3.1.2"
26
26
  },
27
27
  "peerDependencies": {
28
28
  "react": "^18.0.0 || ^19.0.0",
@@ -34,7 +34,7 @@
34
34
  "typescript": "^5.9.3",
35
35
  "vite": "^7.3.1",
36
36
  "vite-plugin-dts": "^4.5.4",
37
- "@object-ui/data-objectstack": "3.1.0"
37
+ "@object-ui/data-objectstack": "3.1.2"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "vite build",
@@ -23,6 +23,7 @@
23
23
 
24
24
  import React, { useEffect, useState, useCallback, useMemo } from 'react';
25
25
  import type { ObjectGridSchema, DataSource, ListColumn, ViewData } from '@object-ui/types';
26
+ import type { I18nLabel } from '@objectstack/spec/ui';
26
27
  import { SchemaRenderer, useDataScope, useNavigationOverlay, useAction, useObjectTranslation, useSafeFieldLabel } from '@object-ui/react';
27
28
  import { getCellRenderer, formatCurrency, formatCompactCurrency, formatDate, formatPercent, humanizeLabel } from '@object-ui/fields';
28
29
  import {
@@ -90,6 +91,13 @@ function useGridTranslation() {
90
91
  }
91
92
  }
92
93
 
94
+ /** Resolve an I18nLabel (string | {key, defaultValue}) to a plain string. */
95
+ function resolveColumnLabel(label: string | I18nLabel | undefined): string | undefined {
96
+ if (label == null) return undefined;
97
+ if (typeof label === 'string') return label;
98
+ return label.defaultValue || label.key;
99
+ }
100
+
93
101
  export interface ObjectGridProps {
94
102
  schema: ObjectGridSchema;
95
103
  dataSource?: DataSource;
@@ -619,7 +627,7 @@ export const ObjectGrid: React.FC<ObjectGridProps> = ({
619
627
  return (cols as ListColumn[])
620
628
  .filter((col) => col?.field && typeof col.field === 'string' && !col.hidden)
621
629
  .map((col, colIndex) => {
622
- const rawHeader = col.label || col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' ');
630
+ const rawHeader = resolveColumnLabel(col.label) || col.field.charAt(0).toUpperCase() + col.field.slice(1).replace(/_/g, ' ');
623
631
  const header = schema.objectName ? resolveFieldLabel(schema.objectName, col.field, rawHeader) : rawHeader;
624
632
 
625
633
  // Build custom cell renderer based on column configuration