@object-ui/plugin-grid 0.5.0 → 3.0.0

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.
Files changed (35) hide show
  1. package/.turbo/turbo-build.log +51 -6
  2. package/CHANGELOG.md +37 -0
  3. package/README.md +97 -0
  4. package/dist/index.js +994 -584
  5. package/dist/index.umd.cjs +3 -3
  6. package/dist/packages/plugin-grid/src/InlineEditing.d.ts +28 -0
  7. package/dist/packages/plugin-grid/src/ListColumnExtensions.test.d.ts +0 -0
  8. package/dist/packages/plugin-grid/src/ListColumnSchema.test.d.ts +1 -0
  9. package/dist/packages/plugin-grid/src/ObjectGrid.EdgeCases.stories.d.ts +25 -0
  10. package/dist/packages/plugin-grid/src/ObjectGrid.d.ts +7 -1
  11. package/dist/packages/plugin-grid/src/ObjectGrid.stories.d.ts +33 -0
  12. package/dist/packages/plugin-grid/src/__tests__/InlineEditing.test.d.ts +0 -0
  13. package/dist/packages/plugin-grid/src/__tests__/VirtualGrid.test.d.ts +0 -0
  14. package/dist/packages/plugin-grid/src/__tests__/accessibility.test.d.ts +0 -0
  15. package/dist/packages/plugin-grid/src/__tests__/performance-benchmark.test.d.ts +0 -0
  16. package/dist/packages/plugin-grid/src/__tests__/view-states.test.d.ts +0 -0
  17. package/dist/packages/plugin-grid/src/index.d.ts +5 -0
  18. package/dist/packages/plugin-grid/src/useGroupedData.d.ts +30 -0
  19. package/dist/packages/plugin-grid/src/useRowColor.d.ts +8 -0
  20. package/package.json +11 -10
  21. package/src/InlineEditing.tsx +235 -0
  22. package/src/ListColumnExtensions.test.tsx +374 -0
  23. package/src/ListColumnSchema.test.ts +88 -0
  24. package/src/ObjectGrid.EdgeCases.stories.tsx +147 -0
  25. package/src/ObjectGrid.msw.test.tsx +24 -1
  26. package/src/ObjectGrid.stories.tsx +139 -0
  27. package/src/ObjectGrid.tsx +409 -113
  28. package/src/__tests__/InlineEditing.test.tsx +360 -0
  29. package/src/__tests__/VirtualGrid.test.tsx +438 -0
  30. package/src/__tests__/accessibility.test.tsx +254 -0
  31. package/src/__tests__/performance-benchmark.test.tsx +182 -0
  32. package/src/__tests__/view-states.test.tsx +203 -0
  33. package/src/index.tsx +17 -2
  34. package/src/useGroupedData.ts +122 -0
  35. package/src/useRowColor.ts +74 -0
package/dist/index.js CHANGED
@@ -1,155 +1,155 @@
1
- import * as H from "react";
2
- import de, { useState as B, useEffect as Q, useCallback as ee, useRef as pe } from "react";
3
- import { ComponentRegistry as fe } from "@object-ui/core";
4
- import { useDataScope as be, SchemaRenderer as ve, useSchemaContext as Ee } from "@object-ui/react";
5
- import { getCellRenderer as ye } from "@object-ui/fields";
6
- import { DropdownMenu as xe, DropdownMenuTrigger as Se, Button as we, DropdownMenuContent as Oe, DropdownMenuItem as te } from "@object-ui/components";
7
- import { MoreVertical as _e, Edit as je, Trash2 as Ce } from "lucide-react";
8
- import { flushSync as Re } from "react-dom";
9
- var G = { exports: {} }, W = {};
10
- var ne;
11
- function Ae() {
12
- if (ne) return W;
13
- ne = 1;
14
- var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), a = /* @__PURE__ */ Symbol.for("react.fragment");
15
- function e(s, n, i) {
1
+ import * as me from "react";
2
+ import Pe, { useRef as pe, useState as D, useCallback as $, useEffect as re, createContext as Be, useMemo as Se } from "react";
3
+ import { ComponentRegistry as Fe } from "@object-ui/core";
4
+ import { useDataScope as He, useNavigationOverlay as Je, useAction as Xe, SchemaRenderer as Ce, useSchemaContext as Ze } from "@object-ui/react";
5
+ import { getCellRenderer as Oe } from "@object-ui/fields";
6
+ import { DropdownMenu as Qe, DropdownMenuTrigger as et, Button as tt, DropdownMenuContent as nt, DropdownMenuItem as Ne, NavigationOverlay as ve, cn as fe } from "@object-ui/components";
7
+ import { MoreVertical as st, Edit as rt, Trash2 as it, ChevronRight as ot, ChevronDown as lt, Check as at, X as ct } from "lucide-react";
8
+ import { flushSync as ut } from "react-dom";
9
+ var he = { exports: {} }, ue = {};
10
+ var _e;
11
+ function dt() {
12
+ if (_e) return ue;
13
+ _e = 1;
14
+ var t = /* @__PURE__ */ Symbol.for("react.transitional.element"), c = /* @__PURE__ */ Symbol.for("react.fragment");
15
+ function e(n, s, i) {
16
16
  var o = null;
17
- if (i !== void 0 && (o = "" + i), n.key !== void 0 && (o = "" + n.key), "key" in n) {
17
+ if (i !== void 0 && (o = "" + i), s.key !== void 0 && (o = "" + s.key), "key" in s) {
18
18
  i = {};
19
- for (var l in n)
20
- l !== "key" && (i[l] = n[l]);
21
- } else i = n;
22
- return n = i.ref, {
19
+ for (var l in s)
20
+ l !== "key" && (i[l] = s[l]);
21
+ } else i = s;
22
+ return s = i.ref, {
23
23
  $$typeof: t,
24
- type: s,
24
+ type: n,
25
25
  key: o,
26
- ref: n !== void 0 ? n : null,
26
+ ref: s !== void 0 ? s : null,
27
27
  props: i
28
28
  };
29
29
  }
30
- return W.Fragment = a, W.jsx = e, W.jsxs = e, W;
30
+ return ue.Fragment = c, ue.jsx = e, ue.jsxs = e, ue;
31
31
  }
32
- var L = {};
33
- var se;
34
- function Te() {
35
- return se || (se = 1, process.env.NODE_ENV !== "production" && (function() {
32
+ var de = {};
33
+ var Re;
34
+ function ft() {
35
+ return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
36
36
  function t(r) {
37
37
  if (r == null) return null;
38
38
  if (typeof r == "function")
39
- return r.$$typeof === J ? null : r.displayName || r.name || null;
39
+ return r.$$typeof === Z ? null : r.displayName || r.name || null;
40
40
  if (typeof r == "string") return r;
41
41
  switch (r) {
42
- case _:
42
+ case S:
43
43
  return "Fragment";
44
- case p:
44
+ case _:
45
45
  return "Profiler";
46
- case T:
46
+ case R:
47
47
  return "StrictMode";
48
- case V:
48
+ case k:
49
49
  return "Suspense";
50
- case z:
50
+ case L:
51
51
  return "SuspenseList";
52
- case P:
52
+ case X:
53
53
  return "Activity";
54
54
  }
55
55
  if (typeof r == "object")
56
56
  switch (typeof r.tag == "number" && console.error(
57
57
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
58
58
  ), r.$$typeof) {
59
- case g:
59
+ case x:
60
60
  return "Portal";
61
- case M:
61
+ case A:
62
62
  return r.displayName || "Context";
63
- case j:
64
- return (r._context.displayName || "Context") + ".Consumer";
65
- case N:
66
- var u = r.render;
67
- return r = r.displayName, r || (r = u.displayName || u.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
68
- case Y:
69
- return u = r.displayName || null, u !== null ? u : t(r.type) || "Memo";
70
63
  case F:
71
- u = r._payload, r = r._init;
64
+ return (r._context.displayName || "Context") + ".Consumer";
65
+ case K:
66
+ var h = r.render;
67
+ return r = r.displayName, r || (r = h.displayName || h.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
68
+ case ge:
69
+ return h = r.displayName || null, h !== null ? h : t(r.type) || "Memo";
70
+ case J:
71
+ h = r._payload, r = r._init;
72
72
  try {
73
- return t(r(u));
73
+ return t(r(h));
74
74
  } catch {
75
75
  }
76
76
  }
77
77
  return null;
78
78
  }
79
- function a(r) {
79
+ function c(r) {
80
80
  return "" + r;
81
81
  }
82
82
  function e(r) {
83
83
  try {
84
- a(r);
85
- var u = !1;
84
+ c(r);
85
+ var h = !1;
86
86
  } catch {
87
- u = !0;
87
+ h = !0;
88
88
  }
89
- if (u) {
90
- u = console;
91
- var x = u.error, w = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
92
- return x.call(
93
- u,
89
+ if (h) {
90
+ h = console;
91
+ var j = h.error, C = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
92
+ return j.call(
93
+ h,
94
94
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
95
- w
96
- ), a(r);
95
+ C
96
+ ), c(r);
97
97
  }
98
98
  }
99
- function s(r) {
100
- if (r === _) return "<>";
101
- if (typeof r == "object" && r !== null && r.$$typeof === F)
99
+ function n(r) {
100
+ if (r === S) return "<>";
101
+ if (typeof r == "object" && r !== null && r.$$typeof === J)
102
102
  return "<...>";
103
103
  try {
104
- var u = t(r);
105
- return u ? "<" + u + ">" : "<...>";
104
+ var h = t(r);
105
+ return h ? "<" + h + ">" : "<...>";
106
106
  } catch {
107
107
  return "<...>";
108
108
  }
109
109
  }
110
- function n() {
111
- var r = $.A;
110
+ function s() {
111
+ var r = Q.A;
112
112
  return r === null ? null : r.getOwner();
113
113
  }
114
114
  function i() {
115
115
  return Error("react-stack-top-frame");
116
116
  }
117
117
  function o(r) {
118
- if (U.call(r, "key")) {
119
- var u = Object.getOwnPropertyDescriptor(r, "key").get;
120
- if (u && u.isReactWarning) return !1;
118
+ if (z.call(r, "key")) {
119
+ var h = Object.getOwnPropertyDescriptor(r, "key").get;
120
+ if (h && h.isReactWarning) return !1;
121
121
  }
122
122
  return r.key !== void 0;
123
123
  }
124
- function l(r, u) {
125
- function x() {
126
- A || (A = !0, console.error(
124
+ function l(r, h) {
125
+ function j() {
126
+ W || (W = !0, console.error(
127
127
  "%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)",
128
- u
128
+ h
129
129
  ));
130
130
  }
131
- x.isReactWarning = !0, Object.defineProperty(r, "key", {
132
- get: x,
131
+ j.isReactWarning = !0, Object.defineProperty(r, "key", {
132
+ get: j,
133
133
  configurable: !0
134
134
  });
135
135
  }
136
- function f() {
136
+ function g() {
137
137
  var r = t(this.type);
138
- return R[r] || (R[r] = !0, console.error(
138
+ return V[r] || (V[r] = !0, console.error(
139
139
  "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."
140
140
  )), r = this.props.ref, r !== void 0 ? r : null;
141
141
  }
142
- function b(r, u, x, w, q, X) {
143
- var O = x.ref;
142
+ function m(r, h, j, C, ee, te) {
143
+ var O = j.ref;
144
144
  return r = {
145
- $$typeof: C,
145
+ $$typeof: y,
146
146
  type: r,
147
- key: u,
148
- props: x,
149
- _owner: w
147
+ key: h,
148
+ props: j,
149
+ _owner: C
150
150
  }, (O !== void 0 ? O : null) !== null ? Object.defineProperty(r, "ref", {
151
151
  enumerable: !1,
152
- get: f
152
+ get: g
153
153
  }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
154
154
  configurable: !1,
155
155
  enumerable: !1,
@@ -164,109 +164,218 @@ function Te() {
164
164
  configurable: !1,
165
165
  enumerable: !1,
166
166
  writable: !0,
167
- value: q
167
+ value: ee
168
168
  }), Object.defineProperty(r, "_debugTask", {
169
169
  configurable: !1,
170
170
  enumerable: !1,
171
171
  writable: !0,
172
- value: X
172
+ value: te
173
173
  }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
174
174
  }
175
- function d(r, u, x, w, q, X) {
176
- var O = u.children;
175
+ function f(r, h, j, C, ee, te) {
176
+ var O = h.children;
177
177
  if (O !== void 0)
178
- if (w)
179
- if (K(O)) {
180
- for (w = 0; w < O.length; w++)
181
- S(O[w]);
178
+ if (C)
179
+ if (U(O)) {
180
+ for (C = 0; C < O.length; C++)
181
+ v(O[C]);
182
182
  Object.freeze && Object.freeze(O);
183
183
  } else
184
184
  console.error(
185
185
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
186
186
  );
187
- else S(O);
188
- if (U.call(u, "key")) {
187
+ else v(O);
188
+ if (z.call(h, "key")) {
189
189
  O = t(r);
190
- var I = Object.keys(u).filter(function(ge) {
191
- return ge !== "key";
190
+ var G = Object.keys(h).filter(function(q) {
191
+ return q !== "key";
192
192
  });
193
- w = 0 < I.length ? "{key: someKey, " + I.join(": ..., ") + ": ...}" : "{key: someKey}", k[O + w] || (I = 0 < I.length ? "{" + I.join(": ..., ") + ": ...}" : "{}", console.error(
193
+ C = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", ie[O + C] || (G = 0 < G.length ? "{" + G.join(": ..., ") + ": ...}" : "{}", console.error(
194
194
  `A props object containing a "key" prop is being spread into JSX:
195
195
  let props = %s;
196
196
  <%s {...props} />
197
197
  React keys must be passed directly to JSX without using spread:
198
198
  let props = %s;
199
199
  <%s key={someKey} {...props} />`,
200
- w,
200
+ C,
201
201
  O,
202
- I,
202
+ G,
203
203
  O
204
- ), k[O + w] = !0);
204
+ ), ie[O + C] = !0);
205
205
  }
206
- if (O = null, x !== void 0 && (e(x), O = "" + x), o(u) && (e(u.key), O = "" + u.key), "key" in u) {
207
- x = {};
208
- for (var Z in u)
209
- Z !== "key" && (x[Z] = u[Z]);
210
- } else x = u;
206
+ if (O = null, j !== void 0 && (e(j), O = "" + j), o(h) && (e(h.key), O = "" + h.key), "key" in h) {
207
+ j = {};
208
+ for (var ne in h)
209
+ ne !== "key" && (j[ne] = h[ne]);
210
+ } else j = h;
211
211
  return O && l(
212
- x,
212
+ j,
213
213
  typeof r == "function" ? r.displayName || r.name || "Unknown" : r
214
- ), b(
214
+ ), m(
215
215
  r,
216
216
  O,
217
- x,
218
- n(),
219
- q,
220
- X
217
+ j,
218
+ s(),
219
+ ee,
220
+ te
221
221
  );
222
222
  }
223
- function S(r) {
224
- c(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === F && (r._payload.status === "fulfilled" ? c(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
223
+ function v(r) {
224
+ u(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === J && (r._payload.status === "fulfilled" ? u(r._payload.value) && r._payload.value._store && (r._payload.value._store.validated = 1) : r._store && (r._store.validated = 1));
225
225
  }
226
- function c(r) {
227
- return typeof r == "object" && r !== null && r.$$typeof === C;
226
+ function u(r) {
227
+ return typeof r == "object" && r !== null && r.$$typeof === y;
228
228
  }
229
- var m = de, C = /* @__PURE__ */ Symbol.for("react.transitional.element"), g = /* @__PURE__ */ Symbol.for("react.portal"), _ = /* @__PURE__ */ Symbol.for("react.fragment"), T = /* @__PURE__ */ Symbol.for("react.strict_mode"), p = /* @__PURE__ */ Symbol.for("react.profiler"), j = /* @__PURE__ */ Symbol.for("react.consumer"), M = /* @__PURE__ */ Symbol.for("react.context"), N = /* @__PURE__ */ Symbol.for("react.forward_ref"), V = /* @__PURE__ */ Symbol.for("react.suspense"), z = /* @__PURE__ */ Symbol.for("react.suspense_list"), Y = /* @__PURE__ */ Symbol.for("react.memo"), F = /* @__PURE__ */ Symbol.for("react.lazy"), P = /* @__PURE__ */ Symbol.for("react.activity"), J = /* @__PURE__ */ Symbol.for("react.client.reference"), $ = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, U = Object.prototype.hasOwnProperty, K = Array.isArray, y = console.createTask ? console.createTask : function() {
229
+ var d = Pe, y = /* @__PURE__ */ Symbol.for("react.transitional.element"), x = /* @__PURE__ */ Symbol.for("react.portal"), S = /* @__PURE__ */ Symbol.for("react.fragment"), R = /* @__PURE__ */ Symbol.for("react.strict_mode"), _ = /* @__PURE__ */ Symbol.for("react.profiler"), F = /* @__PURE__ */ Symbol.for("react.consumer"), A = /* @__PURE__ */ Symbol.for("react.context"), K = /* @__PURE__ */ Symbol.for("react.forward_ref"), k = /* @__PURE__ */ Symbol.for("react.suspense"), L = /* @__PURE__ */ Symbol.for("react.suspense_list"), ge = /* @__PURE__ */ Symbol.for("react.memo"), J = /* @__PURE__ */ Symbol.for("react.lazy"), X = /* @__PURE__ */ Symbol.for("react.activity"), Z = /* @__PURE__ */ Symbol.for("react.client.reference"), Q = d.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, z = Object.prototype.hasOwnProperty, U = Array.isArray, P = console.createTask ? console.createTask : function() {
230
230
  return null;
231
231
  };
232
- m = {
232
+ d = {
233
233
  react_stack_bottom_frame: function(r) {
234
234
  return r();
235
235
  }
236
236
  };
237
- var A, R = {}, E = m.react_stack_bottom_frame.bind(
238
- m,
237
+ var W, V = {}, H = d.react_stack_bottom_frame.bind(
238
+ d,
239
239
  i
240
- )(), h = y(s(i)), k = {};
241
- L.Fragment = _, L.jsx = function(r, u, x) {
242
- var w = 1e4 > $.recentlyCreatedOwnerStacks++;
243
- return d(
240
+ )(), Y = P(n(i)), ie = {};
241
+ de.Fragment = S, de.jsx = function(r, h, j) {
242
+ var C = 1e4 > Q.recentlyCreatedOwnerStacks++;
243
+ return f(
244
244
  r,
245
- u,
246
- x,
245
+ h,
246
+ j,
247
247
  !1,
248
- w ? Error("react-stack-top-frame") : E,
249
- w ? y(s(r)) : h
248
+ C ? Error("react-stack-top-frame") : H,
249
+ C ? P(n(r)) : Y
250
250
  );
251
- }, L.jsxs = function(r, u, x) {
252
- var w = 1e4 > $.recentlyCreatedOwnerStacks++;
253
- return d(
251
+ }, de.jsxs = function(r, h, j) {
252
+ var C = 1e4 > Q.recentlyCreatedOwnerStacks++;
253
+ return f(
254
254
  r,
255
- u,
256
- x,
255
+ h,
256
+ j,
257
257
  !0,
258
- w ? Error("react-stack-top-frame") : E,
259
- w ? y(s(r)) : h
258
+ C ? Error("react-stack-top-frame") : H,
259
+ C ? P(n(r)) : Y
260
260
  );
261
261
  };
262
- })()), L;
262
+ })()), de;
263
+ }
264
+ var ke;
265
+ function ht() {
266
+ return ke || (ke = 1, process.env.NODE_ENV === "production" ? he.exports = dt() : he.exports = ft()), he.exports;
267
+ }
268
+ var a = ht();
269
+ function mt(t) {
270
+ const { onRefresh: c, threshold: e = 80, enabled: n = !0 } = t, s = pe(null), [i, o] = D(!1), [l, g] = D(0), m = pe(0), f = $((d) => {
271
+ if (!n || i)
272
+ return;
273
+ const y = s.current;
274
+ y && y.scrollTop === 0 && (m.current = d.touches[0].clientY);
275
+ }, [n, i]), v = $((d) => {
276
+ if (!n || i || !m.current)
277
+ return;
278
+ const x = d.touches[0].clientY - m.current;
279
+ x > 0 && g(Math.min(x, e * 1.5));
280
+ }, [n, i, e]), u = $(async () => {
281
+ if (!(!n || i)) {
282
+ if (l >= e) {
283
+ o(!0);
284
+ try {
285
+ await c();
286
+ } finally {
287
+ o(!1);
288
+ }
289
+ }
290
+ g(0), m.current = 0;
291
+ }
292
+ }, [n, i, l, e, c]);
293
+ return re(() => {
294
+ const d = s.current;
295
+ if (!(!d || !n))
296
+ return d.addEventListener("touchstart", f, { passive: !0 }), d.addEventListener("touchmove", v, { passive: !0 }), d.addEventListener("touchend", u, { passive: !0 }), () => {
297
+ d.removeEventListener("touchstart", f), d.removeEventListener("touchmove", v), d.removeEventListener("touchend", u);
298
+ };
299
+ }, [f, v, u, n]), { ref: s, isRefreshing: i, pullDistance: l };
263
300
  }
264
- var re;
265
- function Me() {
266
- return re || (re = 1, process.env.NODE_ENV === "production" ? G.exports = Ae() : G.exports = Te()), G.exports;
301
+ const pt = Be(null);
302
+ pt.displayName = "MobileContext";
303
+ const gt = {
304
+ red: "bg-red-100",
305
+ green: "bg-green-100",
306
+ blue: "bg-blue-100",
307
+ yellow: "bg-yellow-100",
308
+ orange: "bg-orange-100",
309
+ purple: "bg-purple-100",
310
+ pink: "bg-pink-100",
311
+ gray: "bg-gray-100",
312
+ grey: "bg-gray-100",
313
+ indigo: "bg-indigo-100",
314
+ teal: "bg-teal-100",
315
+ cyan: "bg-cyan-100",
316
+ amber: "bg-amber-100",
317
+ lime: "bg-lime-100",
318
+ emerald: "bg-emerald-100",
319
+ rose: "bg-rose-100",
320
+ sky: "bg-sky-100",
321
+ violet: "bg-violet-100",
322
+ fuchsia: "bg-fuchsia-100",
323
+ slate: "bg-slate-100",
324
+ zinc: "bg-zinc-100",
325
+ stone: "bg-stone-100",
326
+ neutral: "bg-neutral-100"
327
+ };
328
+ function bt(t) {
329
+ if (t.startsWith("bg-")) return t;
330
+ const c = t.toLowerCase().trim();
331
+ return gt[c];
332
+ }
333
+ function xt(t) {
334
+ return $(
335
+ (c) => {
336
+ if (!t?.field || !t.colors) return;
337
+ const e = String(c[t.field] ?? ""), n = t.colors[e];
338
+ if (n)
339
+ return bt(n);
340
+ },
341
+ [t?.field, t?.colors]
342
+ );
343
+ }
344
+ function vt(t, c) {
345
+ return c.map((e) => String(t[e.field] ?? "")).join(" / ");
346
+ }
347
+ function yt(t, c) {
348
+ return c.map((e) => {
349
+ const n = t[e.field];
350
+ return n != null && n !== "" ? String(n) : "(empty)";
351
+ }).join(" / ");
267
352
  }
268
- var v = Me();
269
- function ze(t) {
353
+ function Et(t, c, e) {
354
+ const n = t.localeCompare(c, void 0, { numeric: !0, sensitivity: "base" });
355
+ return e === "desc" ? -n : n;
356
+ }
357
+ function wt(t, c) {
358
+ const e = t?.fields, n = !!(e && e.length > 0), [s, i] = D({}), o = Se(() => e ? e.some((m) => m.collapsed) : !1, [e]), l = Se(() => {
359
+ if (!n || !e) return [];
360
+ const m = /* @__PURE__ */ new Map(), f = [];
361
+ for (const u of c) {
362
+ const d = vt(u, e);
363
+ m.has(d) || (m.set(d, { label: yt(u, e), rows: [] }), f.push(d)), m.get(d).rows.push(u);
364
+ }
365
+ const v = e[0]?.order ?? "asc";
366
+ return f.sort((u, d) => Et(u, d, v)), f.map((u) => {
367
+ const d = m.get(u), y = u in s ? s[u] : o;
368
+ return { key: u, label: d.label, rows: d.rows, collapsed: y };
369
+ });
370
+ }, [c, e, n, s, o]), g = $((m) => {
371
+ i((f) => ({
372
+ ...f,
373
+ [m]: f[m] !== void 0 ? !f[m] : !o
374
+ }));
375
+ }, [o]);
376
+ return { groups: l, isGrouped: n, toggleGroup: g };
377
+ }
378
+ function jt(t) {
270
379
  return t.data ? Array.isArray(t.data) ? {
271
380
  provider: "value",
272
381
  items: t.data
@@ -278,308 +387,456 @@ function ze(t) {
278
387
  object: t.objectName
279
388
  } : null;
280
389
  }
281
- function ie(t) {
390
+ function Te(t) {
282
391
  if (!(!t || t.length === 0))
283
392
  return typeof t[0] == "object" && t[0] !== null, t;
284
393
  }
285
- const ke = ({
394
+ const St = ({
286
395
  schema: t,
287
- dataSource: a,
396
+ dataSource: c,
288
397
  onEdit: e,
289
- onDelete: s,
290
- onRowSelect: n,
398
+ onDelete: n,
399
+ onRowSelect: s,
291
400
  onRowClick: i,
292
- ...o
401
+ onCellChange: o,
402
+ onRowSave: l,
403
+ onBatchSave: g,
404
+ ...m
293
405
  }) => {
294
- const [l, f] = B([]), [b, d] = B(!0), [S, c] = B(null), [m, C] = B(null), g = o.data, _ = be(t.bind), T = ze(t), p = de.useMemo(() => g && Array.isArray(g) ? {
406
+ const [f, v] = D([]), [u, d] = D(!0), [y, x] = D(null), [S, R] = D(null), [_, F] = D(!1), [A, K] = D(0), k = $(async () => {
407
+ K((b) => b + 1);
408
+ }, []), { ref: L, isRefreshing: ge, pullDistance: J } = mt({
409
+ onRefresh: k,
410
+ enabled: !!c && !!t.objectName
411
+ });
412
+ re(() => {
413
+ const b = () => F(window.innerWidth < 480);
414
+ return b(), window.addEventListener("resize", b), () => window.removeEventListener("resize", b);
415
+ }, []);
416
+ const X = m.data, Z = He(t.bind), Q = jt(t), z = Pe.useMemo(() => X && Array.isArray(X) ? {
295
417
  provider: "value",
296
- items: g
297
- } : _ && Array.isArray(_) ? {
418
+ items: X
419
+ } : Z && Array.isArray(Z) ? {
298
420
  provider: "value",
299
- items: _
300
- } : T, [JSON.stringify(T), _, g]), j = p?.provider === "value";
301
- Q(() => {
302
- j && p?.provider === "value" && (f((y) => {
303
- const A = p.items;
304
- return JSON.stringify(y) !== JSON.stringify(A) ? A : y;
421
+ items: Z
422
+ } : Q, [JSON.stringify(Q), Z, X]), U = z?.provider === "value", P = z?.provider === "object" && z && "object" in z ? z.object : t.objectName, W = t.fields, V = t.columns, H = t.filter, Y = t.sort, ie = t.pagination, r = t.pageSize;
423
+ re(() => {
424
+ U && z?.provider === "value" && (v((b) => {
425
+ const E = z.items;
426
+ return JSON.stringify(b) !== JSON.stringify(E) ? E : b;
305
427
  }), d(!1));
306
- }, [j, p]), Q(() => {
307
- const y = async () => {
428
+ }, [U, z]), re(() => {
429
+ if (U) return;
430
+ let b = !1;
431
+ return (async () => {
432
+ d(!0), x(null);
308
433
  try {
309
- if (!a)
310
- throw new Error("DataSource required");
311
- const R = p?.provider === "object" && "object" in p ? p.object : t.objectName;
312
- if (!R)
313
- throw new Error("Object name required for object provider");
314
- const E = await a.getObjectSchema(R);
315
- C(E);
316
- } catch (R) {
317
- c(R);
434
+ let M = null;
435
+ if ((Te(V) || W) && P)
436
+ M = { name: P, fields: {} };
437
+ else if (P && c) {
438
+ const p = await c.getObjectSchema(P);
439
+ if (b) return;
440
+ M = p;
441
+ } else throw P ? new Error("DataSource required") : new Error("Object name required for data fetching");
442
+ if (b || R(M), c && P) {
443
+ const I = {
444
+ $select: (() => {
445
+ if (W) return W;
446
+ if (V && Array.isArray(V))
447
+ return V.map((T) => typeof T == "string" ? T : T.field);
448
+ })(),
449
+ $top: ie?.pageSize || r || 50
450
+ };
451
+ H && Array.isArray(H) ? I.$filter = H : t.defaultFilters && (I.$filter = t.defaultFilters), Y ? typeof Y == "string" ? I.$orderby = Y : Array.isArray(Y) && (I.$orderby = Y.map((T) => `${T.field} ${T.order}`).join(", ")) : t.defaultSort && (I.$orderby = `${t.defaultSort.field} ${t.defaultSort.order}`);
452
+ const oe = await c.find(P, I);
453
+ if (b) return;
454
+ v(oe.data || []);
455
+ }
456
+ } catch (M) {
457
+ b || x(M);
458
+ } finally {
459
+ b || d(!1);
318
460
  }
319
- }, A = ie(t.columns) || t.fields;
320
- j && A ? C({ name: t.objectName, fields: {} }) : t.objectName && !j && a && y();
321
- }, [t.objectName, t.columns, t.fields, a, j, p]);
322
- const M = ee(() => {
323
- const y = ie(t.columns);
324
- if (y) {
325
- if (y.length > 0 && typeof y[0] == "object" && y[0] !== null) {
326
- const E = y[0];
327
- if ("accessorKey" in E)
328
- return y;
329
- if ("field" in E)
330
- return y.filter((h) => h?.field && typeof h.field == "string").map((h) => ({
331
- header: h.label || h.field.charAt(0).toUpperCase() + h.field.slice(1).replace(/_/g, " "),
332
- accessorKey: h.field,
333
- ...h.width && { width: h.width },
334
- ...h.align && { align: h.align },
335
- sortable: h.sortable !== !1
336
- }));
461
+ })(), () => {
462
+ b = !0;
463
+ };
464
+ }, [P, W, V, H, Y, ie, r, c, U, z, A]);
465
+ const h = Je({
466
+ navigation: t.navigation,
467
+ objectName: t.objectName,
468
+ onNavigate: t.onNavigate,
469
+ onRowClick: i
470
+ }), { execute: j } = Xe(), C = xt(t.rowColor), { groups: ee, isGrouped: te, toggleGroup: O } = wt(t.grouping, f), G = $(() => {
471
+ const b = Te(V);
472
+ if (b) {
473
+ if (b.length > 0 && typeof b[0] == "object" && b[0] !== null) {
474
+ const w = b[0];
475
+ if ("accessorKey" in w)
476
+ return b;
477
+ if ("field" in w)
478
+ return b.filter((p) => p?.field && typeof p.field == "string" && !p.hidden).map((p, I) => {
479
+ const oe = p.label || p.field.charAt(0).toUpperCase() + p.field.slice(1).replace(/_/g, " ");
480
+ let T;
481
+ const B = p.type ? Oe(p.type) : null;
482
+ p.link && p.action ? T = (N, le) => {
483
+ const ae = B ? /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : N != null && N !== "" ? String(N) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
484
+ return /* @__PURE__ */ a.jsx(
485
+ "button",
486
+ {
487
+ type: "button",
488
+ className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
489
+ onClick: (ce) => {
490
+ ce.stopPropagation(), h.handleClick(le);
491
+ },
492
+ children: ae
493
+ }
494
+ );
495
+ } : p.link ? T = (N, le) => {
496
+ const ae = B ? /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : N != null && N !== "" ? String(N) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
497
+ return /* @__PURE__ */ a.jsx(
498
+ "button",
499
+ {
500
+ type: "button",
501
+ className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
502
+ onClick: (ce) => {
503
+ ce.stopPropagation(), h.handleClick(le);
504
+ },
505
+ children: ae
506
+ }
507
+ );
508
+ } : p.action ? T = (N, le) => {
509
+ const ae = B ? /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : N != null && N !== "" ? String(N) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
510
+ return /* @__PURE__ */ a.jsx(
511
+ "button",
512
+ {
513
+ type: "button",
514
+ className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
515
+ onClick: (ce) => {
516
+ ce.stopPropagation(), j({
517
+ type: p.action,
518
+ params: { record: le, field: p.field, value: N }
519
+ });
520
+ },
521
+ children: ae
522
+ }
523
+ );
524
+ } : B ? T = (N) => /* @__PURE__ */ a.jsx(B, { value: N, field: { name: p.field, type: p.type || "text" } }) : T = (N) => N != null && N !== "" ? /* @__PURE__ */ a.jsx("span", { children: String(N) }) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground", children: "-" });
525
+ const Ue = ["number", "currency", "percent"], je = p.align || (p.type && Ue.includes(p.type) ? "right" : void 0), qe = I === 0 || p.essential === !0;
526
+ return {
527
+ header: oe,
528
+ accessorKey: p.field,
529
+ ...!qe && { className: "hidden sm:table-cell" },
530
+ ...p.width && { width: p.width },
531
+ ...je && { align: je },
532
+ sortable: p.sortable !== !1,
533
+ ...p.resizable !== void 0 && { resizable: p.resizable },
534
+ ...p.wrap !== void 0 && { wrap: p.wrap },
535
+ ...T && { cell: T }
536
+ };
537
+ });
337
538
  }
338
- return y.filter((E) => typeof E == "string" && E.trim().length > 0).map((E) => ({
339
- header: m?.fields?.[E]?.label || E.charAt(0).toUpperCase() + E.slice(1).replace(/_/g, " "),
340
- accessorKey: E
539
+ return b.filter((w) => typeof w == "string" && w.trim().length > 0).map((w) => ({
540
+ header: S?.fields?.[w]?.label || w.charAt(0).toUpperCase() + w.slice(1).replace(/_/g, " "),
541
+ accessorKey: w
341
542
  }));
342
543
  }
343
- if (j) {
344
- const E = p?.provider === "value" ? p.items : [];
345
- if (E.length > 0)
346
- return (t.fields || Object.keys(E[0])).map((k) => ({
347
- header: k.charAt(0).toUpperCase() + k.slice(1).replace(/_/g, " "),
348
- accessorKey: k
544
+ if (U) {
545
+ const w = z?.provider === "value" ? z.items : [];
546
+ if (w.length > 0)
547
+ return (W || Object.keys(w[0])).map((I) => ({
548
+ header: I.charAt(0).toUpperCase() + I.slice(1).replace(/_/g, " "),
549
+ accessorKey: I
349
550
  }));
350
551
  }
351
- if (!m) return [];
352
- const A = [];
353
- return (t.fields || Object.keys(m.fields || {})).forEach((E) => {
354
- const h = m.fields?.[E];
355
- if (!h || h.permissions && h.permissions.read === !1) return;
356
- const k = ye(h.type);
357
- A.push({
358
- header: h.label || E,
359
- accessorKey: E,
360
- cell: (r) => /* @__PURE__ */ v.jsx(k, { value: r, field: h }),
361
- sortable: h.sortable !== !1
552
+ if (!S) return [];
553
+ const E = [];
554
+ return (W || Object.keys(S.fields || {})).forEach((w) => {
555
+ const p = S.fields?.[w];
556
+ if (!p || p.permissions && p.permissions.read === !1) return;
557
+ const I = Oe(p.type), oe = ["number", "currency", "percent"];
558
+ E.push({
559
+ header: p.label || w,
560
+ accessorKey: w,
561
+ ...oe.includes(p.type) && { align: "right" },
562
+ cell: (T) => /* @__PURE__ */ a.jsx(I, { value: T, field: p }),
563
+ sortable: p.sortable !== !1
362
564
  });
363
- }), A;
364
- }, [m, t.fields, t.columns, p, j]), N = ee(async () => {
365
- if (!(j || !a)) {
366
- d(!0);
367
- try {
368
- const y = p?.provider === "object" && "object" in p ? p.object : t.objectName;
369
- if (!y)
370
- throw new Error("Object name required for data fetching");
371
- const R = {
372
- $select: (() => {
373
- if (t.fields) return t.fields;
374
- if (t.columns && Array.isArray(t.columns))
375
- return t.columns.map((h) => typeof h == "string" ? h : h.field);
376
- })(),
377
- $top: t.pagination?.pageSize || t.pageSize || 50
378
- };
379
- t.filter && Array.isArray(t.filter) ? R.$filter = t.filter : "defaultFilters" in t && t.defaultFilters && (R.$filter = t.defaultFilters), t.sort ? typeof t.sort == "string" ? R.$orderby = t.sort : Array.isArray(t.sort) && (R.$orderby = t.sort.map((h) => `${h.field} ${h.order}`).join(", ")) : "defaultSort" in t && t.defaultSort && (R.$orderby = `${t.defaultSort.field} ${t.defaultSort.order}`);
380
- const E = await a.find(y, R);
381
- f(E.data || []);
382
- } catch (y) {
383
- c(y);
384
- } finally {
385
- d(!1);
386
- }
387
- }
388
- }, [t, a, j, p]);
389
- if (Q(() => {
390
- (m || j) && N();
391
- }, [m, j, N]), S)
392
- return /* @__PURE__ */ v.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
393
- /* @__PURE__ */ v.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
394
- /* @__PURE__ */ v.jsx("p", { className: "text-red-600 text-sm mt-1", children: S.message })
565
+ }), E;
566
+ }, [S, W, V, z, U, h.handleClick, j]);
567
+ if (y)
568
+ return /* @__PURE__ */ a.jsxs("div", { className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md", children: [
569
+ /* @__PURE__ */ a.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
570
+ /* @__PURE__ */ a.jsx("p", { className: "text-red-600 text-sm mt-1", children: y.message })
395
571
  ] });
396
- if (b && l.length === 0)
397
- return /* @__PURE__ */ v.jsxs("div", { className: "p-8 text-center", children: [
398
- /* @__PURE__ */ v.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
399
- /* @__PURE__ */ v.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading grid..." })
572
+ if (u && f.length === 0)
573
+ return /* @__PURE__ */ a.jsxs("div", { className: "p-4 sm:p-8 text-center", children: [
574
+ /* @__PURE__ */ a.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
575
+ /* @__PURE__ */ a.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading grid..." })
400
576
  ] });
401
- const V = M(), z = "operations" in t ? t.operations : void 0, Y = z && (z.update || z.delete), F = Y ? [
402
- ...V,
577
+ const ne = G(), q = "operations" in t ? t.operations : void 0, ye = q && (q.update || q.delete), We = ye ? [
578
+ ...ne,
403
579
  {
404
580
  header: "Actions",
405
581
  accessorKey: "_actions",
406
- cell: (y, A) => /* @__PURE__ */ v.jsxs(xe, { children: [
407
- /* @__PURE__ */ v.jsx(Se, { asChild: !0, children: /* @__PURE__ */ v.jsxs(we, { variant: "ghost", size: "icon", className: "h-8 w-8", children: [
408
- /* @__PURE__ */ v.jsx(_e, { className: "h-4 w-4" }),
409
- /* @__PURE__ */ v.jsx("span", { className: "sr-only", children: "Open menu" })
582
+ cell: (b, E) => /* @__PURE__ */ a.jsxs(Qe, { children: [
583
+ /* @__PURE__ */ a.jsx(et, { asChild: !0, children: /* @__PURE__ */ a.jsxs(tt, { variant: "ghost", size: "icon", className: "h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0", children: [
584
+ /* @__PURE__ */ a.jsx(st, { className: "h-4 w-4" }),
585
+ /* @__PURE__ */ a.jsx("span", { className: "sr-only", children: "Open menu" })
410
586
  ] }) }),
411
- /* @__PURE__ */ v.jsxs(Oe, { align: "end", children: [
412
- z?.update && e && /* @__PURE__ */ v.jsxs(te, { onClick: () => e(A), children: [
413
- /* @__PURE__ */ v.jsx(je, { className: "mr-2 h-4 w-4" }),
587
+ /* @__PURE__ */ a.jsxs(nt, { align: "end", children: [
588
+ q?.update && e && /* @__PURE__ */ a.jsxs(Ne, { onClick: () => e(E), children: [
589
+ /* @__PURE__ */ a.jsx(rt, { className: "mr-2 h-4 w-4" }),
414
590
  "Edit"
415
591
  ] }),
416
- z?.delete && s && /* @__PURE__ */ v.jsxs(te, { onClick: () => s(A), children: [
417
- /* @__PURE__ */ v.jsx(Ce, { className: "mr-2 h-4 w-4" }),
592
+ q?.delete && n && /* @__PURE__ */ a.jsxs(Ne, { onClick: () => n(E), children: [
593
+ /* @__PURE__ */ a.jsx(it, { className: "mr-2 h-4 w-4" }),
418
594
  "Delete"
419
595
  ] })
420
596
  ] })
421
597
  ] }),
422
598
  sortable: !1
423
599
  }
424
- ] : V;
425
- let P = !1;
426
- t.selection?.type ? P = t.selection.type === "none" ? !1 : t.selection.type : t.selectable !== void 0 && (P = t.selectable);
427
- const J = t.pagination !== void 0 ? !0 : t.showPagination !== void 0 ? t.showPagination : !0, $ = t.pagination?.pageSize || t.pageSize || 10, U = t.searchableFields !== void 0 ? t.searchableFields.length > 0 : t.showSearch !== void 0 ? t.showSearch : !0, K = {
600
+ ] : ne;
601
+ let be = !1;
602
+ t.selection?.type ? be = t.selection.type === "none" ? !1 : t.selection.type : t.selectable !== void 0 && (be = t.selectable);
603
+ const Ve = t.pagination !== void 0 ? !0 : t.showPagination !== void 0 ? t.showPagination : !0, Ye = t.pagination?.pageSize || t.pageSize || 10, Ge = t.searchableFields !== void 0 ? t.searchableFields.length > 0 : t.showSearch !== void 0 ? t.showSearch : !0, Ee = {
428
604
  type: "data-table",
429
605
  caption: t.label || t.title,
430
- columns: F,
431
- data: l,
432
- pagination: J,
433
- pageSize: $,
434
- searchable: U,
435
- selectable: P,
606
+ columns: We,
607
+ data: f,
608
+ pagination: Ve,
609
+ pageSize: Ye,
610
+ searchable: Ge,
611
+ selectable: be,
436
612
  sortable: !0,
437
- exportable: z?.export,
438
- rowActions: Y,
613
+ exportable: q?.export,
614
+ rowActions: ye,
439
615
  resizableColumns: t.resizable ?? t.resizableColumns ?? !0,
440
616
  reorderableColumns: t.reorderableColumns ?? !1,
617
+ editable: t.editable ?? !1,
441
618
  className: t.className,
442
- onSelectionChange: n,
443
- onRowClick: i
444
- };
445
- return /* @__PURE__ */ v.jsx(ve, { schema: K });
619
+ cellClassName: "px-2 py-1.5 sm:px-3 sm:py-2 md:px-4 md:py-2.5",
620
+ rowClassName: t.rowColor ? (b, E) => C(b) : void 0,
621
+ onSelectionChange: s,
622
+ onRowClick: h.handleClick,
623
+ onCellChange: o,
624
+ onRowSave: l,
625
+ onBatchSave: g
626
+ }, Ke = (b) => ({
627
+ ...Ee,
628
+ caption: void 0,
629
+ data: b,
630
+ pagination: !1,
631
+ searchable: !1
632
+ }), xe = t.label ? `${t.label} Detail` : t.objectName ? `${t.objectName.charAt(0).toUpperCase() + t.objectName.slice(1)} Detail` : "Record Detail";
633
+ if (_ && f.length > 0 && !te) {
634
+ const b = G().filter((E) => E.accessorKey !== "_actions");
635
+ return /* @__PURE__ */ a.jsxs(a.Fragment, { children: [
636
+ /* @__PURE__ */ a.jsx("div", { className: "space-y-2 p-2", children: f.map((E, M) => /* @__PURE__ */ a.jsx(
637
+ "div",
638
+ {
639
+ className: "border rounded-lg p-3 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",
640
+ onClick: () => h.handleClick(E),
641
+ children: b.slice(0, 4).map((w) => /* @__PURE__ */ a.jsxs("div", { className: "flex justify-between items-center py-1", children: [
642
+ /* @__PURE__ */ a.jsx("span", { className: "text-xs text-muted-foreground", children: w.header }),
643
+ /* @__PURE__ */ a.jsx("span", { className: "text-sm font-medium truncate ml-2 text-right", children: w.cell ? w.cell(E[w.accessorKey], E) : String(E[w.accessorKey] ?? "—") })
644
+ ] }, w.accessorKey))
645
+ },
646
+ E.id || E._id || M
647
+ )) }),
648
+ h.isOverlay && /* @__PURE__ */ a.jsx(ve, { ...h, title: xe, children: (E) => /* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: Object.entries(E).map(([M, w]) => /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col", children: [
649
+ /* @__PURE__ */ a.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: M.replace(/_/g, " ") }),
650
+ /* @__PURE__ */ a.jsx("span", { className: "text-sm", children: String(w ?? "—") })
651
+ ] }, M)) }) })
652
+ ] });
653
+ }
654
+ const we = te ? /* @__PURE__ */ a.jsx("div", { className: "space-y-2", children: ee.map((b) => /* @__PURE__ */ a.jsxs("div", { className: "border rounded-md", children: [
655
+ /* @__PURE__ */ a.jsxs(
656
+ "button",
657
+ {
658
+ type: "button",
659
+ 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",
660
+ onClick: () => O(b.key),
661
+ children: [
662
+ b.collapsed ? /* @__PURE__ */ a.jsx(ot, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ a.jsx(lt, { className: "h-4 w-4 shrink-0" }),
663
+ /* @__PURE__ */ a.jsx("span", { children: b.label }),
664
+ /* @__PURE__ */ a.jsx("span", { className: "ml-auto text-xs text-muted-foreground", children: b.rows.length })
665
+ ]
666
+ }
667
+ ),
668
+ !b.collapsed && /* @__PURE__ */ a.jsx(Ce, { schema: Ke(b.rows) })
669
+ ] }, b.key)) }) : /* @__PURE__ */ a.jsx(Ce, { schema: Ee });
670
+ return h.isOverlay && h.mode === "split" ? /* @__PURE__ */ a.jsx(
671
+ ve,
672
+ {
673
+ ...h,
674
+ title: xe,
675
+ mainContent: we,
676
+ children: (b) => /* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: Object.entries(b).map(([E, M]) => /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col", children: [
677
+ /* @__PURE__ */ a.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: E.replace(/_/g, " ") }),
678
+ /* @__PURE__ */ a.jsx("span", { className: "text-sm", children: String(M ?? "—") })
679
+ ] }, E)) })
680
+ }
681
+ ) : /* @__PURE__ */ a.jsxs("div", { ref: L, className: "relative h-full", children: [
682
+ J > 0 && /* @__PURE__ */ a.jsx(
683
+ "div",
684
+ {
685
+ className: "flex items-center justify-center text-xs text-muted-foreground",
686
+ style: { height: J },
687
+ children: ge ? "Refreshing…" : "Pull to refresh"
688
+ }
689
+ ),
690
+ we,
691
+ h.isOverlay && /* @__PURE__ */ a.jsx(
692
+ ve,
693
+ {
694
+ ...h,
695
+ title: xe,
696
+ children: (b) => /* @__PURE__ */ a.jsx("div", { className: "space-y-3", children: Object.entries(b).map(([E, M]) => /* @__PURE__ */ a.jsxs("div", { className: "flex flex-col", children: [
697
+ /* @__PURE__ */ a.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: E.replace(/_/g, " ") }),
698
+ /* @__PURE__ */ a.jsx("span", { className: "text-sm", children: String(M ?? "—") })
699
+ ] }, E)) })
700
+ }
701
+ )
702
+ ] });
446
703
  };
447
- function D(t, a, e) {
448
- let s = e.initialDeps ?? [], n, i = !0;
704
+ function se(t, c, e) {
705
+ let n = e.initialDeps ?? [], s, i = !0;
449
706
  function o() {
450
- var l, f, b;
707
+ var l, g, m;
708
+ let f;
709
+ e.key && ((l = e.debug) != null && l.call(e)) && (f = Date.now());
710
+ const v = t();
711
+ if (!(v.length !== n.length || v.some((y, x) => n[x] !== y)))
712
+ return s;
713
+ n = v;
451
714
  let d;
452
- e.key && ((l = e.debug) != null && l.call(e)) && (d = Date.now());
453
- const S = t();
454
- if (!(S.length !== s.length || S.some((C, g) => s[g] !== C)))
455
- return n;
456
- s = S;
457
- let m;
458
- if (e.key && ((f = e.debug) != null && f.call(e)) && (m = Date.now()), n = a(...S), e.key && ((b = e.debug) != null && b.call(e))) {
459
- const C = Math.round((Date.now() - d) * 100) / 100, g = Math.round((Date.now() - m) * 100) / 100, _ = g / 16, T = (p, j) => {
460
- for (p = String(p); p.length < j; )
461
- p = " " + p;
462
- return p;
715
+ if (e.key && ((g = e.debug) != null && g.call(e)) && (d = Date.now()), s = c(...v), e.key && ((m = e.debug) != null && m.call(e))) {
716
+ const y = Math.round((Date.now() - f) * 100) / 100, x = Math.round((Date.now() - d) * 100) / 100, S = x / 16, R = (_, F) => {
717
+ for (_ = String(_); _.length < F; )
718
+ _ = " " + _;
719
+ return _;
463
720
  };
464
721
  console.info(
465
- `%c⏱ ${T(g, 5)} /${T(C, 5)} ms`,
722
+ `%c⏱ ${R(x, 5)} /${R(y, 5)} ms`,
466
723
  `
467
724
  font-size: .6rem;
468
725
  font-weight: bold;
469
726
  color: hsl(${Math.max(
470
727
  0,
471
- Math.min(120 - 120 * _, 120)
728
+ Math.min(120 - 120 * S, 120)
472
729
  )}deg 100% 31%);`,
473
730
  e?.key
474
731
  );
475
732
  }
476
- return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(n), i = !1, n;
733
+ return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(s), i = !1, s;
477
734
  }
478
735
  return o.updateDeps = (l) => {
479
- s = l;
736
+ n = l;
480
737
  }, o;
481
738
  }
482
- function oe(t, a) {
739
+ function Ae(t, c) {
483
740
  if (t === void 0)
484
741
  throw new Error("Unexpected undefined");
485
742
  return t;
486
743
  }
487
- const Ne = (t, a) => Math.abs(t - a) < 1.01, Ie = (t, a, e) => {
488
- let s;
489
- return function(...n) {
490
- t.clearTimeout(s), s = t.setTimeout(() => a.apply(this, n), e);
744
+ const Ct = (t, c) => Math.abs(t - c) < 1.01, Ot = (t, c, e) => {
745
+ let n;
746
+ return function(...s) {
747
+ t.clearTimeout(n), n = t.setTimeout(() => c.apply(this, s), e);
491
748
  };
492
- }, le = (t) => {
493
- const { offsetWidth: a, offsetHeight: e } = t;
494
- return { width: a, height: e };
495
- }, De = (t) => t, Fe = (t) => {
496
- const a = Math.max(t.startIndex - t.overscan, 0), e = Math.min(t.endIndex + t.overscan, t.count - 1), s = [];
497
- for (let n = a; n <= e; n++)
498
- s.push(n);
499
- return s;
500
- }, Pe = (t, a) => {
749
+ }, ze = (t) => {
750
+ const { offsetWidth: c, offsetHeight: e } = t;
751
+ return { width: c, height: e };
752
+ }, Nt = (t) => t, _t = (t) => {
753
+ const c = Math.max(t.startIndex - t.overscan, 0), e = Math.min(t.endIndex + t.overscan, t.count - 1), n = [];
754
+ for (let s = c; s <= e; s++)
755
+ n.push(s);
756
+ return n;
757
+ }, Rt = (t, c) => {
501
758
  const e = t.scrollElement;
502
759
  if (!e)
503
760
  return;
504
- const s = t.targetWindow;
505
- if (!s)
761
+ const n = t.targetWindow;
762
+ if (!n)
506
763
  return;
507
- const n = (o) => {
508
- const { width: l, height: f } = o;
509
- a({ width: Math.round(l), height: Math.round(f) });
764
+ const s = (o) => {
765
+ const { width: l, height: g } = o;
766
+ c({ width: Math.round(l), height: Math.round(g) });
510
767
  };
511
- if (n(le(e)), !s.ResizeObserver)
768
+ if (s(ze(e)), !n.ResizeObserver)
512
769
  return () => {
513
770
  };
514
- const i = new s.ResizeObserver((o) => {
771
+ const i = new n.ResizeObserver((o) => {
515
772
  const l = () => {
516
- const f = o[0];
517
- if (f?.borderBoxSize) {
518
- const b = f.borderBoxSize[0];
519
- if (b) {
520
- n({ width: b.inlineSize, height: b.blockSize });
773
+ const g = o[0];
774
+ if (g?.borderBoxSize) {
775
+ const m = g.borderBoxSize[0];
776
+ if (m) {
777
+ s({ width: m.inlineSize, height: m.blockSize });
521
778
  return;
522
779
  }
523
780
  }
524
- n(le(e));
781
+ s(ze(e));
525
782
  };
526
783
  t.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
527
784
  });
528
785
  return i.observe(e, { box: "border-box" }), () => {
529
786
  i.unobserve(e);
530
787
  };
531
- }, ae = {
788
+ }, Me = {
532
789
  passive: !0
533
- }, ce = typeof window > "u" ? !0 : "onscrollend" in window, $e = (t, a) => {
790
+ }, Ie = typeof window > "u" ? !0 : "onscrollend" in window, kt = (t, c) => {
534
791
  const e = t.scrollElement;
535
792
  if (!e)
536
793
  return;
537
- const s = t.targetWindow;
538
- if (!s)
794
+ const n = t.targetWindow;
795
+ if (!n)
539
796
  return;
540
- let n = 0;
541
- const i = t.options.useScrollendEvent && ce ? () => {
542
- } : Ie(
543
- s,
797
+ let s = 0;
798
+ const i = t.options.useScrollendEvent && Ie ? () => {
799
+ } : Ot(
800
+ n,
544
801
  () => {
545
- a(n, !1);
802
+ c(s, !1);
546
803
  },
547
804
  t.options.isScrollingResetDelay
548
- ), o = (d) => () => {
549
- const { horizontal: S, isRtl: c } = t.options;
550
- n = S ? e.scrollLeft * (c && -1 || 1) : e.scrollTop, i(), a(n, d);
551
- }, l = o(!0), f = o(!1);
552
- e.addEventListener("scroll", l, ae);
553
- const b = t.options.useScrollendEvent && ce;
554
- return b && e.addEventListener("scrollend", f, ae), () => {
555
- e.removeEventListener("scroll", l), b && e.removeEventListener("scrollend", f);
805
+ ), o = (f) => () => {
806
+ const { horizontal: v, isRtl: u } = t.options;
807
+ s = v ? e.scrollLeft * (u && -1 || 1) : e.scrollTop, i(), c(s, f);
808
+ }, l = o(!0), g = o(!1);
809
+ e.addEventListener("scroll", l, Me);
810
+ const m = t.options.useScrollendEvent && Ie;
811
+ return m && e.addEventListener("scrollend", g, Me), () => {
812
+ e.removeEventListener("scroll", l), m && e.removeEventListener("scrollend", g);
556
813
  };
557
- }, We = (t, a, e) => {
558
- if (a?.borderBoxSize) {
559
- const s = a.borderBoxSize[0];
560
- if (s)
814
+ }, Tt = (t, c, e) => {
815
+ if (c?.borderBoxSize) {
816
+ const n = c.borderBoxSize[0];
817
+ if (n)
561
818
  return Math.round(
562
- s[e.options.horizontal ? "inlineSize" : "blockSize"]
819
+ n[e.options.horizontal ? "inlineSize" : "blockSize"]
563
820
  );
564
821
  }
565
822
  return t[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
566
- }, Le = (t, {
567
- adjustments: a = 0,
823
+ }, At = (t, {
824
+ adjustments: c = 0,
568
825
  behavior: e
569
- }, s) => {
570
- var n, i;
571
- const o = t + a;
572
- (i = (n = s.scrollElement) == null ? void 0 : n.scrollTo) == null || i.call(n, {
573
- [s.options.horizontal ? "left" : "top"]: o,
826
+ }, n) => {
827
+ var s, i;
828
+ const o = t + c;
829
+ (i = (s = n.scrollElement) == null ? void 0 : s.scrollTo) == null || i.call(s, {
830
+ [n.options.horizontal ? "left" : "top"]: o,
574
831
  behavior: e
575
832
  });
576
833
  };
577
- class Ve {
578
- constructor(a) {
834
+ class zt {
835
+ constructor(c) {
579
836
  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__ */ (() => {
580
837
  let e = null;
581
- const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((n) => {
582
- n.forEach((i) => {
838
+ const n = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((s) => {
839
+ s.forEach((i) => {
583
840
  const o = () => {
584
841
  this._measureElement(i.target, i);
585
842
  };
@@ -588,21 +845,21 @@ class Ve {
588
845
  }));
589
846
  return {
590
847
  disconnect: () => {
591
- var n;
592
- (n = s()) == null || n.disconnect(), e = null;
848
+ var s;
849
+ (s = n()) == null || s.disconnect(), e = null;
593
850
  },
594
- observe: (n) => {
851
+ observe: (s) => {
595
852
  var i;
596
- return (i = s()) == null ? void 0 : i.observe(n, { box: "border-box" });
853
+ return (i = n()) == null ? void 0 : i.observe(s, { box: "border-box" });
597
854
  },
598
- unobserve: (n) => {
855
+ unobserve: (s) => {
599
856
  var i;
600
- return (i = s()) == null ? void 0 : i.unobserve(n);
857
+ return (i = n()) == null ? void 0 : i.unobserve(s);
601
858
  }
602
859
  };
603
860
  })(), this.range = null, this.setOptions = (e) => {
604
- Object.entries(e).forEach(([s, n]) => {
605
- typeof n > "u" && delete e[s];
861
+ Object.entries(e).forEach(([n, s]) => {
862
+ typeof s > "u" && delete e[n];
606
863
  }), this.options = {
607
864
  debug: !1,
608
865
  initialOffset: 0,
@@ -612,11 +869,11 @@ class Ve {
612
869
  scrollPaddingStart: 0,
613
870
  scrollPaddingEnd: 0,
614
871
  horizontal: !1,
615
- getItemKey: De,
616
- rangeExtractor: Fe,
872
+ getItemKey: Nt,
873
+ rangeExtractor: _t,
617
874
  onChange: () => {
618
875
  },
619
- measureElement: We,
876
+ measureElement: Tt,
620
877
  initialRect: { width: 0, height: 0 },
621
878
  scrollMargin: 0,
622
879
  gap: 0,
@@ -631,9 +888,9 @@ class Ve {
631
888
  ...e
632
889
  };
633
890
  }, this.notify = (e) => {
634
- var s, n;
635
- (n = (s = this.options).onChange) == null || n.call(s, this, e);
636
- }, this.maybeNotify = D(
891
+ var n, s;
892
+ (s = (n = this.options).onChange) == null || s.call(n, this, e);
893
+ }, this.maybeNotify = se(
637
894
  () => (this.calculateRange(), [
638
895
  this.isScrolling,
639
896
  this.range ? this.range.startIndex : null,
@@ -657,41 +914,41 @@ class Ve {
657
914
  this.cleanup();
658
915
  }, this._willUpdate = () => {
659
916
  var e;
660
- const s = this.options.enabled ? this.options.getScrollElement() : null;
661
- if (this.scrollElement !== s) {
662
- if (this.cleanup(), !s) {
917
+ const n = this.options.enabled ? this.options.getScrollElement() : null;
918
+ if (this.scrollElement !== n) {
919
+ if (this.cleanup(), !n) {
663
920
  this.maybeNotify();
664
921
  return;
665
922
  }
666
- this.scrollElement = s, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((n) => {
667
- this.observer.observe(n);
923
+ this.scrollElement = n, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((e = this.scrollElement) == null ? void 0 : e.window) ?? null, this.elementsCache.forEach((s) => {
924
+ this.observer.observe(s);
668
925
  }), this.unsubs.push(
669
- this.options.observeElementRect(this, (n) => {
670
- this.scrollRect = n, this.maybeNotify();
926
+ this.options.observeElementRect(this, (s) => {
927
+ this.scrollRect = s, this.maybeNotify();
671
928
  })
672
929
  ), this.unsubs.push(
673
- this.options.observeElementOffset(this, (n, i) => {
674
- this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < n ? "forward" : "backward" : null, this.scrollOffset = n, this.isScrolling = i, this.maybeNotify();
930
+ this.options.observeElementOffset(this, (s, i) => {
931
+ this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < s ? "forward" : "backward" : null, this.scrollOffset = s, this.isScrolling = i, this.maybeNotify();
675
932
  })
676
933
  ), this._scrollToOffset(this.getScrollOffset(), {
677
934
  adjustments: void 0,
678
935
  behavior: void 0
679
936
  });
680
937
  }
681
- }, 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 = (e, s) => {
682
- const n = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
683
- for (let o = s - 1; o >= 0; o--) {
938
+ }, 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 = (e, n) => {
939
+ const s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
940
+ for (let o = n - 1; o >= 0; o--) {
684
941
  const l = e[o];
685
- if (n.has(l.lane))
942
+ if (s.has(l.lane))
686
943
  continue;
687
- const f = i.get(
944
+ const g = i.get(
688
945
  l.lane
689
946
  );
690
- if (f == null || l.end > f.end ? i.set(l.lane, l) : l.end < f.end && n.set(l.lane, !0), n.size === this.options.lanes)
947
+ if (g == null || l.end > g.end ? i.set(l.lane, l) : l.end < g.end && s.set(l.lane, !0), s.size === this.options.lanes)
691
948
  break;
692
949
  }
693
950
  return i.size === this.options.lanes ? Array.from(i.values()).sort((o, l) => o.end === l.end ? o.index - l.index : o.end - l.end)[0] : void 0;
694
- }, this.getMeasurementOptions = D(
951
+ }, this.getMeasurementOptions = se(
695
952
  () => [
696
953
  this.options.count,
697
954
  this.options.paddingStart,
@@ -700,10 +957,10 @@ class Ve {
700
957
  this.options.enabled,
701
958
  this.options.lanes
702
959
  ],
703
- (e, s, n, i, o, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
960
+ (e, n, s, i, o, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
704
961
  count: e,
705
- paddingStart: s,
706
- scrollMargin: n,
962
+ paddingStart: n,
963
+ scrollMargin: s,
707
964
  getItemKey: i,
708
965
  enabled: o,
709
966
  lanes: l
@@ -711,142 +968,142 @@ class Ve {
711
968
  {
712
969
  key: !1
713
970
  }
714
- ), this.getMeasurements = D(
971
+ ), this.getMeasurements = se(
715
972
  () => [this.getMeasurementOptions(), this.itemSizeCache],
716
- ({ count: e, paddingStart: s, scrollMargin: n, getItemKey: i, enabled: o, lanes: l }, f) => {
973
+ ({ count: e, paddingStart: n, scrollMargin: s, getItemKey: i, enabled: o, lanes: l }, g) => {
717
974
  if (!o)
718
975
  return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
719
976
  if (this.laneAssignments.size > e)
720
- for (const c of this.laneAssignments.keys())
721
- c >= e && this.laneAssignments.delete(c);
722
- 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((c) => {
723
- this.itemSizeCache.set(c.key, c.size);
977
+ for (const u of this.laneAssignments.keys())
978
+ u >= e && this.laneAssignments.delete(u);
979
+ 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((u) => {
980
+ this.itemSizeCache.set(u.key, u.size);
724
981
  }));
725
- const b = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
982
+ const m = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
726
983
  this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
727
- const d = this.measurementsCache.slice(0, b), S = new Array(l).fill(
984
+ const f = this.measurementsCache.slice(0, m), v = new Array(l).fill(
728
985
  void 0
729
986
  );
730
- for (let c = 0; c < b; c++) {
731
- const m = d[c];
732
- m && (S[m.lane] = c);
987
+ for (let u = 0; u < m; u++) {
988
+ const d = f[u];
989
+ d && (v[d.lane] = u);
733
990
  }
734
- for (let c = b; c < e; c++) {
735
- const m = i(c), C = this.laneAssignments.get(c);
736
- let g, _;
737
- if (C !== void 0 && this.options.lanes > 1) {
738
- g = C;
739
- const M = S[g], N = M !== void 0 ? d[M] : void 0;
740
- _ = N ? N.end + this.options.gap : s + n;
991
+ for (let u = m; u < e; u++) {
992
+ const d = i(u), y = this.laneAssignments.get(u);
993
+ let x, S;
994
+ if (y !== void 0 && this.options.lanes > 1) {
995
+ x = y;
996
+ const A = v[x], K = A !== void 0 ? f[A] : void 0;
997
+ S = K ? K.end + this.options.gap : n + s;
741
998
  } else {
742
- const M = this.options.lanes === 1 ? d[c - 1] : this.getFurthestMeasurement(d, c);
743
- _ = M ? M.end + this.options.gap : s + n, g = M ? M.lane : c % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(c, g);
999
+ const A = this.options.lanes === 1 ? f[u - 1] : this.getFurthestMeasurement(f, u);
1000
+ S = A ? A.end + this.options.gap : n + s, x = A ? A.lane : u % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(u, x);
744
1001
  }
745
- const T = f.get(m), p = typeof T == "number" ? T : this.options.estimateSize(c), j = _ + p;
746
- d[c] = {
747
- index: c,
748
- start: _,
749
- size: p,
750
- end: j,
751
- key: m,
752
- lane: g
753
- }, S[g] = c;
1002
+ const R = g.get(d), _ = typeof R == "number" ? R : this.options.estimateSize(u), F = S + _;
1003
+ f[u] = {
1004
+ index: u,
1005
+ start: S,
1006
+ size: _,
1007
+ end: F,
1008
+ key: d,
1009
+ lane: x
1010
+ }, v[x] = u;
754
1011
  }
755
- return this.measurementsCache = d, d;
1012
+ return this.measurementsCache = f, f;
756
1013
  },
757
1014
  {
758
1015
  key: process.env.NODE_ENV !== "production" && "getMeasurements",
759
1016
  debug: () => this.options.debug
760
1017
  }
761
- ), this.calculateRange = D(
1018
+ ), this.calculateRange = se(
762
1019
  () => [
763
1020
  this.getMeasurements(),
764
1021
  this.getSize(),
765
1022
  this.getScrollOffset(),
766
1023
  this.options.lanes
767
1024
  ],
768
- (e, s, n, i) => this.range = e.length > 0 && s > 0 ? Ye({
1025
+ (e, n, s, i) => this.range = e.length > 0 && n > 0 ? Mt({
769
1026
  measurements: e,
770
- outerSize: s,
771
- scrollOffset: n,
1027
+ outerSize: n,
1028
+ scrollOffset: s,
772
1029
  lanes: i
773
1030
  }) : null,
774
1031
  {
775
1032
  key: process.env.NODE_ENV !== "production" && "calculateRange",
776
1033
  debug: () => this.options.debug
777
1034
  }
778
- ), this.getVirtualIndexes = D(
1035
+ ), this.getVirtualIndexes = se(
779
1036
  () => {
780
- let e = null, s = null;
781
- const n = this.calculateRange();
782
- return n && (e = n.startIndex, s = n.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, s]), [
1037
+ let e = null, n = null;
1038
+ const s = this.calculateRange();
1039
+ return s && (e = s.startIndex, n = s.endIndex), this.maybeNotify.updateDeps([this.isScrolling, e, n]), [
783
1040
  this.options.rangeExtractor,
784
1041
  this.options.overscan,
785
1042
  this.options.count,
786
1043
  e,
787
- s
1044
+ n
788
1045
  ];
789
1046
  },
790
- (e, s, n, i, o) => i === null || o === null ? [] : e({
1047
+ (e, n, s, i, o) => i === null || o === null ? [] : e({
791
1048
  startIndex: i,
792
1049
  endIndex: o,
793
- overscan: s,
794
- count: n
1050
+ overscan: n,
1051
+ count: s
795
1052
  }),
796
1053
  {
797
1054
  key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
798
1055
  debug: () => this.options.debug
799
1056
  }
800
1057
  ), this.indexFromElement = (e) => {
801
- const s = this.options.indexAttribute, n = e.getAttribute(s);
802
- return n ? parseInt(n, 10) : (console.warn(
803
- `Missing attribute name '${s}={index}' on measured element.`
1058
+ const n = this.options.indexAttribute, s = e.getAttribute(n);
1059
+ return s ? parseInt(s, 10) : (console.warn(
1060
+ `Missing attribute name '${n}={index}' on measured element.`
804
1061
  ), -1);
805
- }, this._measureElement = (e, s) => {
806
- const n = this.indexFromElement(e), i = this.measurementsCache[n];
1062
+ }, this._measureElement = (e, n) => {
1063
+ const s = this.indexFromElement(e), i = this.measurementsCache[s];
807
1064
  if (!i)
808
1065
  return;
809
1066
  const o = i.key, l = this.elementsCache.get(o);
810
- l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(n, this.options.measureElement(e, s, this));
811
- }, this.resizeItem = (e, s) => {
812
- const n = this.measurementsCache[e];
813
- if (!n)
1067
+ l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(s, this.options.measureElement(e, n, this));
1068
+ }, this.resizeItem = (e, n) => {
1069
+ const s = this.measurementsCache[e];
1070
+ if (!s)
814
1071
  return;
815
- const i = this.itemSizeCache.get(n.key) ?? n.size, o = s - i;
816
- o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(n, o, this) : n.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", o), this._scrollToOffset(this.getScrollOffset(), {
1072
+ const i = this.itemSizeCache.get(s.key) ?? s.size, o = n - i;
1073
+ o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(s, o, this) : s.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", o), this._scrollToOffset(this.getScrollOffset(), {
817
1074
  adjustments: this.scrollAdjustments += o,
818
1075
  behavior: void 0
819
- })), this.pendingMeasuredCacheIndexes.push(n.index), this.itemSizeCache = new Map(this.itemSizeCache.set(n.key, s)), this.notify(!1));
1076
+ })), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, n)), this.notify(!1));
820
1077
  }, this.measureElement = (e) => {
821
1078
  if (!e) {
822
- this.elementsCache.forEach((s, n) => {
823
- s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(n));
1079
+ this.elementsCache.forEach((n, s) => {
1080
+ n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(s));
824
1081
  });
825
1082
  return;
826
1083
  }
827
1084
  this._measureElement(e, void 0);
828
- }, this.getVirtualItems = D(
1085
+ }, this.getVirtualItems = se(
829
1086
  () => [this.getVirtualIndexes(), this.getMeasurements()],
830
- (e, s) => {
831
- const n = [];
1087
+ (e, n) => {
1088
+ const s = [];
832
1089
  for (let i = 0, o = e.length; i < o; i++) {
833
- const l = e[i], f = s[l];
834
- n.push(f);
1090
+ const l = e[i], g = n[l];
1091
+ s.push(g);
835
1092
  }
836
- return n;
1093
+ return s;
837
1094
  },
838
1095
  {
839
1096
  key: process.env.NODE_ENV !== "production" && "getVirtualItems",
840
1097
  debug: () => this.options.debug
841
1098
  }
842
1099
  ), this.getVirtualItemForOffset = (e) => {
843
- const s = this.getMeasurements();
844
- if (s.length !== 0)
845
- return oe(
846
- s[he(
1100
+ const n = this.getMeasurements();
1101
+ if (n.length !== 0)
1102
+ return Ae(
1103
+ n[Le(
847
1104
  0,
848
- s.length - 1,
849
- (n) => oe(s[n]).start,
1105
+ n.length - 1,
1106
+ (s) => Ae(n[s]).start,
850
1107
  e
851
1108
  )]
852
1109
  );
@@ -858,291 +1115,444 @@ class Ve {
858
1115
  const e = this.scrollElement.document.documentElement;
859
1116
  return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
860
1117
  }
861
- }, this.getOffsetForAlignment = (e, s, n = 0) => {
1118
+ }, this.getOffsetForAlignment = (e, n, s = 0) => {
862
1119
  if (!this.scrollElement) return 0;
863
1120
  const i = this.getSize(), o = this.getScrollOffset();
864
- s === "auto" && (s = e >= o + i ? "end" : "start"), s === "center" ? e += (n - i) / 2 : s === "end" && (e -= i);
1121
+ n === "auto" && (n = e >= o + i ? "end" : "start"), n === "center" ? e += (s - i) / 2 : n === "end" && (e -= i);
865
1122
  const l = this.getMaxScrollOffset();
866
1123
  return Math.max(Math.min(l, e), 0);
867
- }, this.getOffsetForIndex = (e, s = "auto") => {
1124
+ }, this.getOffsetForIndex = (e, n = "auto") => {
868
1125
  e = Math.max(0, Math.min(e, this.options.count - 1));
869
- const n = this.measurementsCache[e];
870
- if (!n)
1126
+ const s = this.measurementsCache[e];
1127
+ if (!s)
871
1128
  return;
872
1129
  const i = this.getSize(), o = this.getScrollOffset();
873
- if (s === "auto")
874
- if (n.end >= o + i - this.options.scrollPaddingEnd)
875
- s = "end";
876
- else if (n.start <= o + this.options.scrollPaddingStart)
877
- s = "start";
1130
+ if (n === "auto")
1131
+ if (s.end >= o + i - this.options.scrollPaddingEnd)
1132
+ n = "end";
1133
+ else if (s.start <= o + this.options.scrollPaddingStart)
1134
+ n = "start";
878
1135
  else
879
- return [o, s];
880
- if (s === "end" && e === this.options.count - 1)
881
- return [this.getMaxScrollOffset(), s];
882
- const l = s === "end" ? n.end + this.options.scrollPaddingEnd : n.start - this.options.scrollPaddingStart;
1136
+ return [o, n];
1137
+ if (n === "end" && e === this.options.count - 1)
1138
+ return [this.getMaxScrollOffset(), n];
1139
+ const l = n === "end" ? s.end + this.options.scrollPaddingEnd : s.start - this.options.scrollPaddingStart;
883
1140
  return [
884
- this.getOffsetForAlignment(l, s, n.size),
885
- s
1141
+ this.getOffsetForAlignment(l, n, s.size),
1142
+ n
886
1143
  ];
887
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: s = "start", behavior: n } = {}) => {
888
- n === "smooth" && this.isDynamicMode() && console.warn(
1144
+ }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: n = "start", behavior: s } = {}) => {
1145
+ s === "smooth" && this.isDynamicMode() && console.warn(
889
1146
  "The `smooth` scroll behavior is not fully supported with dynamic size."
890
- ), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
1147
+ ), this._scrollToOffset(this.getOffsetForAlignment(e, n), {
891
1148
  adjustments: void 0,
892
- behavior: n
1149
+ behavior: s
893
1150
  });
894
- }, this.scrollToIndex = (e, { align: s = "auto", behavior: n } = {}) => {
895
- n === "smooth" && this.isDynamicMode() && console.warn(
1151
+ }, this.scrollToIndex = (e, { align: n = "auto", behavior: s } = {}) => {
1152
+ s === "smooth" && this.isDynamicMode() && console.warn(
896
1153
  "The `smooth` scroll behavior is not fully supported with dynamic size."
897
1154
  ), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
898
1155
  let i = 0;
899
- const o = 10, l = (b) => {
1156
+ const o = 10, l = (m) => {
900
1157
  if (!this.targetWindow) return;
901
- const d = this.getOffsetForIndex(e, b);
902
- if (!d) {
1158
+ const f = this.getOffsetForIndex(e, m);
1159
+ if (!f) {
903
1160
  console.warn("Failed to get offset for index:", e);
904
1161
  return;
905
1162
  }
906
- const [S, c] = d;
907
- this._scrollToOffset(S, { adjustments: void 0, behavior: n }), this.targetWindow.requestAnimationFrame(() => {
908
- const m = () => {
1163
+ const [v, u] = f;
1164
+ this._scrollToOffset(v, { adjustments: void 0, behavior: s }), this.targetWindow.requestAnimationFrame(() => {
1165
+ const d = () => {
909
1166
  if (this.currentScrollToIndex !== e) return;
910
- const C = this.getScrollOffset(), g = this.getOffsetForIndex(e, c);
911
- if (!g) {
1167
+ const y = this.getScrollOffset(), x = this.getOffsetForIndex(e, u);
1168
+ if (!x) {
912
1169
  console.warn("Failed to get offset for index:", e);
913
1170
  return;
914
1171
  }
915
- Ne(g[0], C) || f(c);
1172
+ Ct(x[0], y) || g(u);
916
1173
  };
917
- this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(m) : m();
1174
+ this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(d) : d();
918
1175
  });
919
- }, f = (b) => {
920
- this.targetWindow && this.currentScrollToIndex === e && (i++, i < o ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, o), this.targetWindow.requestAnimationFrame(() => l(b))) : console.warn(
1176
+ }, g = (m) => {
1177
+ this.targetWindow && this.currentScrollToIndex === e && (i++, i < o ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, o), this.targetWindow.requestAnimationFrame(() => l(m))) : console.warn(
921
1178
  `Failed to scroll to index ${e} after ${o} attempts.`
922
1179
  ));
923
1180
  };
924
- l(s);
925
- }, this.scrollBy = (e, { behavior: s } = {}) => {
926
- s === "smooth" && this.isDynamicMode() && console.warn(
1181
+ l(n);
1182
+ }, this.scrollBy = (e, { behavior: n } = {}) => {
1183
+ n === "smooth" && this.isDynamicMode() && console.warn(
927
1184
  "The `smooth` scroll behavior is not fully supported with dynamic size."
928
1185
  ), this._scrollToOffset(this.getScrollOffset() + e, {
929
1186
  adjustments: void 0,
930
- behavior: s
1187
+ behavior: n
931
1188
  });
932
1189
  }, this.getTotalSize = () => {
933
1190
  var e;
934
- const s = this.getMeasurements();
935
- let n;
936
- if (s.length === 0)
937
- n = this.options.paddingStart;
1191
+ const n = this.getMeasurements();
1192
+ let s;
1193
+ if (n.length === 0)
1194
+ s = this.options.paddingStart;
938
1195
  else if (this.options.lanes === 1)
939
- n = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
1196
+ s = ((e = n[n.length - 1]) == null ? void 0 : e.end) ?? 0;
940
1197
  else {
941
1198
  const i = Array(this.options.lanes).fill(null);
942
- let o = s.length - 1;
1199
+ let o = n.length - 1;
943
1200
  for (; o >= 0 && i.some((l) => l === null); ) {
944
- const l = s[o];
1201
+ const l = n[o];
945
1202
  i[l.lane] === null && (i[l.lane] = l.end), o--;
946
1203
  }
947
- n = Math.max(...i.filter((l) => l !== null));
1204
+ s = Math.max(...i.filter((l) => l !== null));
948
1205
  }
949
1206
  return Math.max(
950
- n - this.options.scrollMargin + this.options.paddingEnd,
1207
+ s - this.options.scrollMargin + this.options.paddingEnd,
951
1208
  0
952
1209
  );
953
1210
  }, this._scrollToOffset = (e, {
954
- adjustments: s,
955
- behavior: n
1211
+ adjustments: n,
1212
+ behavior: s
956
1213
  }) => {
957
- this.options.scrollToFn(e, { behavior: n, adjustments: s }, this);
1214
+ this.options.scrollToFn(e, { behavior: s, adjustments: n }, this);
958
1215
  }, this.measure = () => {
959
1216
  this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
960
- }, this.setOptions(a);
1217
+ }, this.setOptions(c);
961
1218
  }
962
1219
  }
963
- const he = (t, a, e, s) => {
964
- for (; t <= a; ) {
965
- const n = (t + a) / 2 | 0, i = e(n);
966
- if (i < s)
967
- t = n + 1;
968
- else if (i > s)
969
- a = n - 1;
1220
+ const Le = (t, c, e, n) => {
1221
+ for (; t <= c; ) {
1222
+ const s = (t + c) / 2 | 0, i = e(s);
1223
+ if (i < n)
1224
+ t = s + 1;
1225
+ else if (i > n)
1226
+ c = s - 1;
970
1227
  else
971
- return n;
1228
+ return s;
972
1229
  }
973
1230
  return t > 0 ? t - 1 : 0;
974
1231
  };
975
- function Ye({
1232
+ function Mt({
976
1233
  measurements: t,
977
- outerSize: a,
1234
+ outerSize: c,
978
1235
  scrollOffset: e,
979
- lanes: s
1236
+ lanes: n
980
1237
  }) {
981
- const n = t.length - 1, i = (f) => t[f].start;
982
- if (t.length <= s)
1238
+ const s = t.length - 1, i = (g) => t[g].start;
1239
+ if (t.length <= n)
983
1240
  return {
984
1241
  startIndex: 0,
985
- endIndex: n
1242
+ endIndex: s
986
1243
  };
987
- let o = he(
1244
+ let o = Le(
988
1245
  0,
989
- n,
1246
+ s,
990
1247
  i,
991
1248
  e
992
1249
  ), l = o;
993
- if (s === 1)
994
- for (; l < n && t[l].end < e + a; )
1250
+ if (n === 1)
1251
+ for (; l < s && t[l].end < e + c; )
995
1252
  l++;
996
- else if (s > 1) {
997
- const f = Array(s).fill(0);
998
- for (; l < n && f.some((d) => d < e + a); ) {
999
- const d = t[l];
1000
- f[d.lane] = d.end, l++;
1253
+ else if (n > 1) {
1254
+ const g = Array(n).fill(0);
1255
+ for (; l < s && g.some((f) => f < e + c); ) {
1256
+ const f = t[l];
1257
+ g[f.lane] = f.end, l++;
1001
1258
  }
1002
- const b = Array(s).fill(e + a);
1003
- for (; o >= 0 && b.some((d) => d >= e); ) {
1004
- const d = t[o];
1005
- b[d.lane] = d.start, o--;
1259
+ const m = Array(n).fill(e + c);
1260
+ for (; o >= 0 && m.some((f) => f >= e); ) {
1261
+ const f = t[o];
1262
+ m[f.lane] = f.start, o--;
1006
1263
  }
1007
- o = Math.max(0, o - o % s), l = Math.min(n, l + (s - 1 - l % s));
1264
+ o = Math.max(0, o - o % n), l = Math.min(s, l + (n - 1 - l % n));
1008
1265
  }
1009
1266
  return { startIndex: o, endIndex: l };
1010
1267
  }
1011
- const ue = typeof document < "u" ? H.useLayoutEffect : H.useEffect;
1012
- function Ue({
1268
+ const De = typeof document < "u" ? me.useLayoutEffect : me.useEffect;
1269
+ function It({
1013
1270
  useFlushSync: t = !0,
1014
- ...a
1271
+ ...c
1015
1272
  }) {
1016
- const e = H.useReducer(() => ({}), {})[1], s = {
1017
- ...a,
1273
+ const e = me.useReducer(() => ({}), {})[1], n = {
1274
+ ...c,
1018
1275
  onChange: (i, o) => {
1019
1276
  var l;
1020
- t && o ? Re(e) : e(), (l = a.onChange) == null || l.call(a, i, o);
1277
+ t && o ? ut(e) : e(), (l = c.onChange) == null || l.call(c, i, o);
1021
1278
  }
1022
- }, [n] = H.useState(
1023
- () => new Ve(s)
1279
+ }, [s] = me.useState(
1280
+ () => new zt(n)
1024
1281
  );
1025
- return n.setOptions(s), ue(() => n._didMount(), []), ue(() => n._willUpdate()), n;
1282
+ return s.setOptions(n), De(() => s._didMount(), []), De(() => s._willUpdate()), s;
1026
1283
  }
1027
- function qe(t) {
1028
- return Ue({
1029
- observeElementRect: Pe,
1030
- observeElementOffset: $e,
1031
- scrollToFn: Le,
1284
+ function Dt(t) {
1285
+ return It({
1286
+ observeElementRect: Rt,
1287
+ observeElementOffset: kt,
1288
+ scrollToFn: At,
1032
1289
  ...t
1033
1290
  });
1034
1291
  }
1035
- const Qe = ({
1292
+ const Gt = ({
1036
1293
  data: t,
1037
- columns: a,
1294
+ columns: c,
1038
1295
  rowHeight: e = 40,
1039
- height: s = 600,
1040
- className: n = "",
1296
+ height: n = 600,
1297
+ className: s = "",
1041
1298
  headerClassName: i = "",
1042
1299
  rowClassName: o,
1043
1300
  onRowClick: l,
1044
- overscan: f = 5
1301
+ overscan: g = 5
1045
1302
  }) => {
1046
- const b = pe(null), d = qe({
1303
+ const m = pe(null), f = Dt({
1047
1304
  count: t.length,
1048
- getScrollElement: () => b.current,
1305
+ getScrollElement: () => m.current,
1049
1306
  estimateSize: () => e,
1050
- overscan: f
1051
- }), S = d.getVirtualItems();
1052
- return /* @__PURE__ */ v.jsxs("div", { className: n, children: [
1053
- /* @__PURE__ */ v.jsx(
1307
+ overscan: g
1308
+ }), v = f.getVirtualItems();
1309
+ return /* @__PURE__ */ a.jsxs("div", { className: s, children: [
1310
+ /* @__PURE__ */ a.jsx(
1054
1311
  "div",
1055
1312
  {
1056
1313
  className: `grid border-b sticky top-0 bg-background z-10 ${i}`,
1057
1314
  style: {
1058
- gridTemplateColumns: a.map((c) => c.width || "1fr").join(" ")
1315
+ gridTemplateColumns: c.map((u) => u.width || "1fr").join(" ")
1059
1316
  },
1060
- children: a.map((c, m) => /* @__PURE__ */ v.jsx(
1317
+ children: c.map((u, d) => /* @__PURE__ */ a.jsx(
1061
1318
  "div",
1062
1319
  {
1063
- className: `px-4 py-2 font-semibold text-sm ${c.align === "center" ? "text-center" : c.align === "right" ? "text-right" : "text-left"}`,
1064
- children: c.header
1320
+ className: `px-4 py-2 font-semibold text-sm ${u.align === "center" ? "text-center" : u.align === "right" ? "text-right" : "text-left"}`,
1321
+ children: u.header
1065
1322
  },
1066
- m
1323
+ d
1067
1324
  ))
1068
1325
  }
1069
1326
  ),
1070
- /* @__PURE__ */ v.jsx(
1327
+ /* @__PURE__ */ a.jsx(
1071
1328
  "div",
1072
1329
  {
1073
- ref: b,
1330
+ ref: m,
1074
1331
  className: "overflow-auto",
1075
1332
  style: {
1076
- height: typeof s == "number" ? `${s}px` : s,
1333
+ height: typeof n == "number" ? `${n}px` : n,
1077
1334
  contain: "strict"
1078
1335
  },
1079
- children: /* @__PURE__ */ v.jsx(
1336
+ children: /* @__PURE__ */ a.jsx(
1080
1337
  "div",
1081
1338
  {
1082
1339
  style: {
1083
- height: `${d.getTotalSize()}px`,
1340
+ height: `${f.getTotalSize()}px`,
1084
1341
  width: "100%",
1085
1342
  position: "relative"
1086
1343
  },
1087
- children: S.map((c) => {
1088
- const m = t[c.index], C = typeof o == "function" ? o(m, c.index) : o || "";
1089
- return /* @__PURE__ */ v.jsx(
1344
+ children: v.map((u) => {
1345
+ const d = t[u.index], y = typeof o == "function" ? o(d, u.index) : o || "";
1346
+ return /* @__PURE__ */ a.jsx(
1090
1347
  "div",
1091
1348
  {
1092
- className: `grid border-b hover:bg-muted/50 cursor-pointer ${C}`,
1349
+ className: `grid border-b hover:bg-muted/50 cursor-pointer ${y}`,
1093
1350
  style: {
1094
1351
  position: "absolute",
1095
1352
  top: 0,
1096
1353
  left: 0,
1097
1354
  width: "100%",
1098
- height: `${c.size}px`,
1099
- transform: `translateY(${c.start}px)`,
1100
- gridTemplateColumns: a.map((g) => g.width || "1fr").join(" ")
1355
+ height: `${u.size}px`,
1356
+ transform: `translateY(${u.start}px)`,
1357
+ gridTemplateColumns: c.map((x) => x.width || "1fr").join(" ")
1101
1358
  },
1102
- onClick: () => l?.(m, c.index),
1103
- children: a.map((g, _) => {
1104
- const T = m[g.accessorKey], p = g.cell ? g.cell(T, m) : T;
1105
- return /* @__PURE__ */ v.jsx(
1359
+ onClick: () => l?.(d, u.index),
1360
+ children: c.map((x, S) => {
1361
+ const R = d[x.accessorKey], _ = x.cell ? x.cell(R, d) : R;
1362
+ return /* @__PURE__ */ a.jsx(
1106
1363
  "div",
1107
1364
  {
1108
- className: `px-4 py-2 text-sm flex items-center ${g.align === "center" ? "text-center justify-center" : g.align === "right" ? "text-right justify-end" : "text-left justify-start"}`,
1109
- children: p
1365
+ className: `px-4 py-2 text-sm flex items-center ${x.align === "center" ? "text-center justify-center" : x.align === "right" ? "text-right justify-end" : "text-left justify-start"}`,
1366
+ children: _
1110
1367
  },
1111
- _
1368
+ S
1112
1369
  );
1113
1370
  })
1114
1371
  },
1115
- c.key
1372
+ u.key
1116
1373
  );
1117
1374
  })
1118
1375
  }
1119
1376
  )
1120
1377
  }
1121
1378
  ),
1122
- /* @__PURE__ */ v.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
1379
+ /* @__PURE__ */ a.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
1123
1380
  "Showing ",
1124
- S.length,
1381
+ v.length,
1125
1382
  " of ",
1126
1383
  t.length,
1127
1384
  " rows (virtual scrolling enabled)"
1128
1385
  ] })
1129
1386
  ] });
1130
- }, me = ({ schema: t, ...a }) => {
1131
- const { dataSource: e } = Ee() || {};
1132
- return /* @__PURE__ */ v.jsx(ke, { schema: t, dataSource: e, ...a });
1133
1387
  };
1134
- fe.register("object-grid", me, {
1388
+ function Kt({
1389
+ value: t,
1390
+ onSave: c,
1391
+ onCancel: e,
1392
+ validate: n,
1393
+ type: s = "text",
1394
+ placeholder: i,
1395
+ editing: o = !1,
1396
+ className: l,
1397
+ disabled: g = !1
1398
+ }) {
1399
+ const [m, f] = D(o), [v, u] = D(String(t ?? "")), [d, y] = D(), [x, S] = D(!1), R = pe(null);
1400
+ re(() => {
1401
+ m || u(String(t ?? ""));
1402
+ }, [t, m]), re(() => {
1403
+ m && R.current && (R.current.focus(), R.current.select());
1404
+ }, [m]);
1405
+ const _ = $(() => {
1406
+ g || (f(!0), u(String(t ?? "")), y(void 0));
1407
+ }, [g, t]), F = $(() => {
1408
+ f(!1), u(String(t ?? "")), y(void 0), e?.();
1409
+ }, [t, e]), A = $(async () => {
1410
+ if (n) {
1411
+ const L = n(v);
1412
+ if (L) {
1413
+ y(L);
1414
+ return;
1415
+ }
1416
+ }
1417
+ const k = s === "number" ? Number(v) : v;
1418
+ S(!0);
1419
+ try {
1420
+ const L = await c(k);
1421
+ if (typeof L == "string") {
1422
+ y(L), S(!1);
1423
+ return;
1424
+ }
1425
+ f(!1), y(void 0);
1426
+ } catch (L) {
1427
+ y(L?.message || "Save failed");
1428
+ } finally {
1429
+ S(!1);
1430
+ }
1431
+ }, [v, n, s, c]), K = $(
1432
+ (k) => {
1433
+ k.key === "Enter" ? (k.preventDefault(), A()) : k.key === "Escape" && (k.preventDefault(), F());
1434
+ },
1435
+ [A, F]
1436
+ );
1437
+ return m ? /* @__PURE__ */ a.jsxs(
1438
+ "div",
1439
+ {
1440
+ "data-slot": "inline-editing",
1441
+ className: fe("relative flex items-center gap-1", l),
1442
+ children: [
1443
+ /* @__PURE__ */ a.jsxs("div", { className: "flex-1 relative", children: [
1444
+ /* @__PURE__ */ a.jsx(
1445
+ "input",
1446
+ {
1447
+ ref: R,
1448
+ "data-slot": "inline-editing-input",
1449
+ type: s,
1450
+ value: v,
1451
+ onChange: (k) => {
1452
+ u(k.target.value), d && y(void 0);
1453
+ },
1454
+ onKeyDown: K,
1455
+ placeholder: i,
1456
+ disabled: x,
1457
+ "aria-invalid": !!d,
1458
+ "aria-describedby": d ? "inline-editing-error" : void 0,
1459
+ className: fe(
1460
+ "w-full rounded border px-2 py-1 text-sm outline-none transition-colors",
1461
+ "focus:ring-2 focus:ring-ring focus:border-input",
1462
+ d ? "border-destructive focus:ring-destructive/30" : "border-input",
1463
+ x && "opacity-50"
1464
+ )
1465
+ }
1466
+ ),
1467
+ d && /* @__PURE__ */ a.jsx(
1468
+ "p",
1469
+ {
1470
+ id: "inline-editing-error",
1471
+ "data-slot": "inline-editing-error",
1472
+ className: "absolute left-0 top-full mt-0.5 text-xs text-destructive",
1473
+ role: "alert",
1474
+ children: d
1475
+ }
1476
+ )
1477
+ ] }),
1478
+ /* @__PURE__ */ a.jsx(
1479
+ "button",
1480
+ {
1481
+ "data-slot": "inline-editing-save",
1482
+ type: "button",
1483
+ onClick: A,
1484
+ disabled: x,
1485
+ "aria-label": "Save",
1486
+ className: fe(
1487
+ "inline-flex h-6 w-6 items-center justify-center rounded text-primary hover:bg-primary/10 transition-colors",
1488
+ x && "opacity-50 cursor-not-allowed"
1489
+ ),
1490
+ children: /* @__PURE__ */ a.jsx(at, { className: "h-3.5 w-3.5" })
1491
+ }
1492
+ ),
1493
+ /* @__PURE__ */ a.jsx(
1494
+ "button",
1495
+ {
1496
+ "data-slot": "inline-editing-cancel",
1497
+ type: "button",
1498
+ onClick: F,
1499
+ disabled: x,
1500
+ "aria-label": "Cancel",
1501
+ className: "inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",
1502
+ children: /* @__PURE__ */ a.jsx(ct, { className: "h-3.5 w-3.5" })
1503
+ }
1504
+ )
1505
+ ]
1506
+ }
1507
+ ) : /* @__PURE__ */ a.jsx(
1508
+ "div",
1509
+ {
1510
+ "data-slot": "inline-editing",
1511
+ className: fe(
1512
+ "group relative cursor-pointer rounded px-2 py-1 hover:bg-muted/50 transition-colors min-h-[1.75rem] flex items-center",
1513
+ g && "cursor-default opacity-60",
1514
+ l
1515
+ ),
1516
+ onClick: _,
1517
+ role: "button",
1518
+ tabIndex: g ? -1 : 0,
1519
+ onKeyDown: (k) => {
1520
+ (k.key === "Enter" || k.key === " ") && (k.preventDefault(), _());
1521
+ },
1522
+ "aria-label": `Edit value: ${String(t ?? "")}`,
1523
+ children: /* @__PURE__ */ a.jsx("span", { "data-slot": "inline-editing-display", className: "truncate text-sm", children: t != null && String(t) !== "" ? String(t) : /* @__PURE__ */ a.jsx("span", { className: "text-muted-foreground italic", children: i || "Click to edit" }) })
1524
+ }
1525
+ );
1526
+ }
1527
+ const $e = ({ schema: t, ...c }) => {
1528
+ const { dataSource: e } = Ze() || {};
1529
+ return /* @__PURE__ */ a.jsx(St, { schema: t, dataSource: e, ...c });
1530
+ };
1531
+ Fe.register("object-grid", $e, {
1135
1532
  namespace: "plugin-grid",
1136
1533
  label: "Object Grid",
1137
- category: "plugin"
1534
+ category: "plugin",
1535
+ inputs: [
1536
+ { name: "objectName", type: "string", label: "Object Name", required: !0 },
1537
+ { name: "columns", type: "array", label: "Columns" },
1538
+ { name: "filters", type: "array", label: "Filters" }
1539
+ ]
1138
1540
  });
1139
- fe.register("grid", me, {
1541
+ Fe.register("grid", $e, {
1140
1542
  namespace: "view",
1141
1543
  label: "Data Grid",
1142
- category: "view"
1544
+ category: "view",
1545
+ inputs: [
1546
+ { name: "objectName", type: "string", label: "Object Name", required: !0 },
1547
+ { name: "columns", type: "array", label: "Columns" },
1548
+ { name: "filters", type: "array", label: "Filters" }
1549
+ ]
1143
1550
  });
1144
1551
  export {
1145
- ke as ObjectGrid,
1146
- me as ObjectGridRenderer,
1147
- Qe as VirtualGrid
1552
+ Kt as InlineEditing,
1553
+ St as ObjectGrid,
1554
+ $e as ObjectGridRenderer,
1555
+ Gt as VirtualGrid,
1556
+ wt as useGroupedData,
1557
+ xt as useRowColor
1148
1558
  };