@object-ui/plugin-grid 2.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,155 +1,155 @@
1
- import * as le from "react";
2
- import Se, { useState as ie, useEffect as ae, useCallback as Ce, useRef as _e } from "react";
3
- import { ComponentRegistry as we } from "@object-ui/core";
4
- import { useDataScope as Re, useNavigationOverlay as Ae, useAction as Te, SchemaRenderer as ce, useSchemaContext as Ne } from "@object-ui/react";
5
- import { getCellRenderer as ue } from "@object-ui/fields";
6
- import { DropdownMenu as ke, DropdownMenuTrigger as ze, Button as Me, DropdownMenuContent as Ie, DropdownMenuItem as de, NavigationOverlay as fe } from "@object-ui/components";
7
- import { MoreVertical as De, Edit as Fe, Trash2 as Pe } from "lucide-react";
8
- import { flushSync as $e } from "react-dom";
9
- var oe = { exports: {} }, te = {};
10
- var he;
11
- function We() {
12
- if (he) return te;
13
- he = 1;
14
- var n = /* @__PURE__ */ Symbol.for("react.transitional.element"), a = /* @__PURE__ */ Symbol.for("react.fragment");
15
- function e(s, t, 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), t.key !== void 0 && (o = "" + t.key), "key" in t) {
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 t)
20
- l !== "key" && (i[l] = t[l]);
21
- } else i = t;
22
- return t = i.ref, {
23
- $$typeof: n,
24
- type: s,
19
+ for (var l in s)
20
+ l !== "key" && (i[l] = s[l]);
21
+ } else i = s;
22
+ return s = i.ref, {
23
+ $$typeof: t,
24
+ type: n,
25
25
  key: o,
26
- ref: t !== void 0 ? t : null,
26
+ ref: s !== void 0 ? s : null,
27
27
  props: i
28
28
  };
29
29
  }
30
- return te.Fragment = a, te.jsx = e, te.jsxs = e, te;
30
+ return ue.Fragment = c, ue.jsx = e, ue.jsxs = e, ue;
31
31
  }
32
- var ne = {};
33
- var me;
34
- function Le() {
35
- return me || (me = 1, process.env.NODE_ENV !== "production" && (function() {
36
- function n(r) {
32
+ var de = {};
33
+ var Re;
34
+ function ft() {
35
+ return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
36
+ function t(r) {
37
37
  if (r == null) return null;
38
38
  if (typeof r == "function")
39
- return r.$$typeof === V ? 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 j:
42
+ case S:
43
43
  return "Fragment";
44
- case O:
44
+ case _:
45
45
  return "Profiler";
46
- case N:
46
+ case R:
47
47
  return "StrictMode";
48
- case L:
48
+ case k:
49
49
  return "Suspense";
50
- case F:
50
+ case L:
51
51
  return "SuspenseList";
52
- case U:
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 v:
59
+ case x:
60
60
  return "Portal";
61
- case k:
61
+ case A:
62
62
  return r.displayName || "Context";
63
- case D:
63
+ case F:
64
64
  return (r._context.displayName || "Context") + ".Consumer";
65
- case C:
65
+ case K:
66
66
  var h = r.render;
67
67
  return r = r.displayName, r || (r = h.displayName || h.name || "", r = r !== "" ? "ForwardRef(" + r + ")" : "ForwardRef"), r;
68
- case $:
69
- return h = r.displayName || null, h !== null ? h : n(r.type) || "Memo";
70
- case z:
68
+ case ge:
69
+ return h = r.displayName || null, h !== null ? h : t(r.type) || "Memo";
70
+ case J:
71
71
  h = r._payload, r = r._init;
72
72
  try {
73
- return n(r(h));
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);
84
+ c(r);
85
85
  var h = !1;
86
86
  } catch {
87
87
  h = !0;
88
88
  }
89
89
  if (h) {
90
90
  h = console;
91
- var x = h.error, S = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
92
- return x.call(
91
+ var j = h.error, C = typeof Symbol == "function" && Symbol.toStringTag && r[Symbol.toStringTag] || r.constructor.name || "Object";
92
+ return j.call(
93
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
- S
96
- ), a(r);
95
+ C
96
+ ), c(r);
97
97
  }
98
98
  }
99
- function s(r) {
100
- if (r === j) return "<>";
101
- if (typeof r == "object" && r !== null && r.$$typeof === z)
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 h = n(r);
104
+ var h = t(r);
105
105
  return h ? "<" + h + ">" : "<...>";
106
106
  } catch {
107
107
  return "<...>";
108
108
  }
109
109
  }
110
- function t() {
111
- var r = q.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 (J.call(r, "key")) {
118
+ if (z.call(r, "key")) {
119
119
  var h = Object.getOwnPropertyDescriptor(r, "key").get;
120
120
  if (h && h.isReactWarning) return !1;
121
121
  }
122
122
  return r.key !== void 0;
123
123
  }
124
124
  function l(r, h) {
125
- function x() {
126
- se || (se = !0, console.error(
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
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 p() {
137
- var r = n(this.type);
138
- return K[r] || (K[r] = !0, console.error(
136
+ function g() {
137
+ var r = t(this.type);
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 g(r, h, x, S, Y, G) {
143
- var f = x.ref;
142
+ function m(r, h, j, C, ee, te) {
143
+ var O = j.ref;
144
144
  return r = {
145
- $$typeof: _,
145
+ $$typeof: y,
146
146
  type: r,
147
147
  key: h,
148
- props: x,
149
- _owner: S
150
- }, (f !== void 0 ? f : null) !== null ? Object.defineProperty(r, "ref", {
148
+ props: j,
149
+ _owner: C
150
+ }, (O !== void 0 ? O : null) !== null ? Object.defineProperty(r, "ref", {
151
151
  enumerable: !1,
152
- get: p
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,503 +164,679 @@ function Le() {
164
164
  configurable: !1,
165
165
  enumerable: !1,
166
166
  writable: !0,
167
- value: Y
167
+ value: ee
168
168
  }), Object.defineProperty(r, "_debugTask", {
169
169
  configurable: !1,
170
170
  enumerable: !1,
171
171
  writable: !0,
172
- value: G
172
+ value: te
173
173
  }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
174
174
  }
175
- function m(r, h, x, S, Y, G) {
176
- var f = h.children;
177
- if (f !== void 0)
178
- if (S)
179
- if (M(f)) {
180
- for (S = 0; S < f.length; S++)
181
- E(f[S]);
182
- Object.freeze && Object.freeze(f);
175
+ function f(r, h, j, C, ee, te) {
176
+ var O = h.children;
177
+ if (O !== void 0)
178
+ if (C)
179
+ if (U(O)) {
180
+ for (C = 0; C < O.length; C++)
181
+ v(O[C]);
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 E(f);
188
- if (J.call(h, "key")) {
189
- f = n(r);
190
- var y = Object.keys(h).filter(function(w) {
191
- return w !== "key";
187
+ else v(O);
188
+ if (z.call(h, "key")) {
189
+ O = t(r);
190
+ var G = Object.keys(h).filter(function(q) {
191
+ return q !== "key";
192
192
  });
193
- S = 0 < y.length ? "{key: someKey, " + y.join(": ..., ") + ": ...}" : "{key: someKey}", re[f + S] || (y = 0 < y.length ? "{" + y.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
- S,
201
- f,
202
- y,
203
- f
204
- ), re[f + S] = !0);
200
+ C,
201
+ O,
202
+ G,
203
+ O
204
+ ), ie[O + C] = !0);
205
205
  }
206
- if (f = null, x !== void 0 && (e(x), f = "" + x), o(h) && (e(h.key), f = "" + h.key), "key" in h) {
207
- x = {};
208
- for (var A in h)
209
- A !== "key" && (x[A] = h[A]);
210
- } else x = h;
211
- return f && l(
212
- x,
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
+ return O && l(
212
+ j,
213
213
  typeof r == "function" ? r.displayName || r.name || "Unknown" : r
214
- ), g(
214
+ ), m(
215
215
  r,
216
- f,
217
- x,
218
- t(),
219
- Y,
220
- G
216
+ O,
217
+ j,
218
+ s(),
219
+ ee,
220
+ te
221
221
  );
222
222
  }
223
- function E(r) {
224
- c(r) ? r._store && (r._store.validated = 1) : typeof r == "object" && r !== null && r.$$typeof === z && (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 === _;
226
+ function u(r) {
227
+ return typeof r == "object" && r !== null && r.$$typeof === y;
228
228
  }
229
- var b = Se, _ = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), j = /* @__PURE__ */ Symbol.for("react.fragment"), N = /* @__PURE__ */ Symbol.for("react.strict_mode"), O = /* @__PURE__ */ Symbol.for("react.profiler"), D = /* @__PURE__ */ Symbol.for("react.consumer"), k = /* @__PURE__ */ Symbol.for("react.context"), C = /* @__PURE__ */ Symbol.for("react.forward_ref"), L = /* @__PURE__ */ Symbol.for("react.suspense"), F = /* @__PURE__ */ Symbol.for("react.suspense_list"), $ = /* @__PURE__ */ Symbol.for("react.memo"), z = /* @__PURE__ */ Symbol.for("react.lazy"), U = /* @__PURE__ */ Symbol.for("react.activity"), V = /* @__PURE__ */ Symbol.for("react.client.reference"), q = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, J = Object.prototype.hasOwnProperty, M = Array.isArray, B = 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
- b = {
232
+ d = {
233
233
  react_stack_bottom_frame: function(r) {
234
234
  return r();
235
235
  }
236
236
  };
237
- var se, K = {}, W = b.react_stack_bottom_frame.bind(
238
- b,
237
+ var W, V = {}, H = d.react_stack_bottom_frame.bind(
238
+ d,
239
239
  i
240
- )(), X = B(s(i)), re = {};
241
- ne.Fragment = j, ne.jsx = function(r, h, x) {
242
- var S = 1e4 > q.recentlyCreatedOwnerStacks++;
243
- return m(
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
245
  h,
246
- x,
246
+ j,
247
247
  !1,
248
- S ? Error("react-stack-top-frame") : W,
249
- S ? B(s(r)) : X
248
+ C ? Error("react-stack-top-frame") : H,
249
+ C ? P(n(r)) : Y
250
250
  );
251
- }, ne.jsxs = function(r, h, x) {
252
- var S = 1e4 > q.recentlyCreatedOwnerStacks++;
253
- return m(
251
+ }, de.jsxs = function(r, h, j) {
252
+ var C = 1e4 > Q.recentlyCreatedOwnerStacks++;
253
+ return f(
254
254
  r,
255
255
  h,
256
- x,
256
+ j,
257
257
  !0,
258
- S ? Error("react-stack-top-frame") : W,
259
- S ? B(s(r)) : X
258
+ C ? Error("react-stack-top-frame") : H,
259
+ C ? P(n(r)) : Y
260
260
  );
261
261
  };
262
- })()), ne;
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 };
300
+ }
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
+ );
263
343
  }
264
- var pe;
265
- function Ve() {
266
- return pe || (pe = 1, process.env.NODE_ENV === "production" ? oe.exports = We() : oe.exports = Le()), oe.exports;
344
+ function vt(t, c) {
345
+ return c.map((e) => String(t[e.field] ?? "")).join(" / ");
267
346
  }
268
- var u = Ve();
269
- function Ye(n) {
270
- return n.data ? Array.isArray(n.data) ? {
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(" / ");
352
+ }
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) {
379
+ return t.data ? Array.isArray(t.data) ? {
271
380
  provider: "value",
272
- items: n.data
273
- } : n.data : n.staticData ? {
381
+ items: t.data
382
+ } : t.data : t.staticData ? {
274
383
  provider: "value",
275
- items: n.staticData
276
- } : n.objectName ? {
384
+ items: t.staticData
385
+ } : t.objectName ? {
277
386
  provider: "object",
278
- object: n.objectName
387
+ object: t.objectName
279
388
  } : null;
280
389
  }
281
- function ge(n) {
282
- if (!(!n || n.length === 0))
283
- return typeof n[0] == "object" && n[0] !== null, n;
390
+ function Te(t) {
391
+ if (!(!t || t.length === 0))
392
+ return typeof t[0] == "object" && t[0] !== null, t;
284
393
  }
285
- const Ue = ({
286
- schema: n,
287
- dataSource: a,
394
+ const St = ({
395
+ schema: t,
396
+ dataSource: c,
288
397
  onEdit: e,
289
- onDelete: s,
290
- onRowSelect: t,
398
+ onDelete: n,
399
+ onRowSelect: s,
291
400
  onRowClick: i,
292
401
  onCellChange: o,
293
402
  onRowSave: l,
294
- onBatchSave: p,
295
- ...g
403
+ onBatchSave: g,
404
+ ...m
296
405
  }) => {
297
- const [m, E] = ie([]), [c, b] = ie(!0), [_, v] = ie(null), [j, N] = ie(null), O = g.data, D = Re(n.bind), k = Ye(n), C = Se.useMemo(() => O && Array.isArray(O) ? {
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) ? {
298
417
  provider: "value",
299
- items: O
300
- } : D && Array.isArray(D) ? {
418
+ items: X
419
+ } : Z && Array.isArray(Z) ? {
301
420
  provider: "value",
302
- items: D
303
- } : k, [JSON.stringify(k), D, O]), L = C?.provider === "value", F = C?.provider === "object" && C && "object" in C ? C.object : n.objectName, $ = n.fields, z = n.columns, U = n.filter, V = n.sort, q = n.pagination, J = n.pageSize;
304
- ae(() => {
305
- L && C?.provider === "value" && (E((f) => {
306
- const y = C.items;
307
- return JSON.stringify(f) !== JSON.stringify(y) ? y : f;
308
- }), b(!1));
309
- }, [L, C]), ae(() => {
310
- if (L) return;
311
- let f = !1;
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;
427
+ }), d(!1));
428
+ }, [U, z]), re(() => {
429
+ if (U) return;
430
+ let b = !1;
312
431
  return (async () => {
313
- b(!0), v(null);
432
+ d(!0), x(null);
314
433
  try {
315
- let A = null;
316
- if ((ge(z) || $) && F)
317
- A = { name: F, fields: {} };
318
- else if (F && a) {
319
- const d = await a.getObjectSchema(F);
320
- if (f) return;
321
- A = d;
322
- } else throw F ? new Error("DataSource required") : new Error("Object name required for data fetching");
323
- if (f || N(A), a && F) {
324
- const T = {
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 = {
325
444
  $select: (() => {
326
- if ($) return $;
327
- if (z && Array.isArray(z))
328
- return z.map((R) => typeof R == "string" ? R : R.field);
445
+ if (W) return W;
446
+ if (V && Array.isArray(V))
447
+ return V.map((T) => typeof T == "string" ? T : T.field);
329
448
  })(),
330
- $top: q?.pageSize || J || 50
449
+ $top: ie?.pageSize || r || 50
331
450
  };
332
- U && Array.isArray(U) ? T.$filter = U : n.defaultFilters && (T.$filter = n.defaultFilters), V ? typeof V == "string" ? T.$orderby = V : Array.isArray(V) && (T.$orderby = V.map((R) => `${R.field} ${R.order}`).join(", ")) : n.defaultSort && (T.$orderby = `${n.defaultSort.field} ${n.defaultSort.order}`);
333
- const P = await a.find(F, T);
334
- if (f) return;
335
- E(P.data || []);
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 || []);
336
455
  }
337
- } catch (A) {
338
- f || v(A);
456
+ } catch (M) {
457
+ b || x(M);
339
458
  } finally {
340
- f || b(!1);
459
+ b || d(!1);
341
460
  }
342
461
  })(), () => {
343
- f = !0;
462
+ b = !0;
344
463
  };
345
- }, [F, $, z, U, V, q, J, a, L, C]);
346
- const M = Ae({
347
- navigation: n.navigation,
348
- objectName: n.objectName,
349
- onNavigate: n.onNavigate,
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,
350
469
  onRowClick: i
351
- }), { execute: B } = Te(), se = Ce(() => {
352
- const f = ge(z);
353
- if (f) {
354
- if (f.length > 0 && typeof f[0] == "object" && f[0] !== null) {
355
- const w = f[0];
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];
356
475
  if ("accessorKey" in w)
357
- return f;
476
+ return b;
358
477
  if ("field" in w)
359
- return f.filter((d) => d?.field && typeof d.field == "string" && !d.hidden).map((d) => {
360
- const T = d.label || d.field.charAt(0).toUpperCase() + d.field.slice(1).replace(/_/g, " ");
361
- let P;
362
- const R = d.type ? ue(d.type) : null;
363
- return d.link && d.action ? P = (I, Z) => {
364
- const Q = R ? /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } }) : String(I ?? "");
365
- return /* @__PURE__ */ u.jsx(
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(
366
485
  "button",
367
486
  {
368
487
  type: "button",
369
- className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
370
- onClick: (ee) => {
371
- ee.stopPropagation(), M.handleClick(Z);
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);
372
491
  },
373
- children: Q
492
+ children: ae
374
493
  }
375
494
  );
376
- } : d.link ? P = (I, Z) => {
377
- const Q = R ? /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } }) : String(I ?? "");
378
- return /* @__PURE__ */ u.jsx(
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(
379
498
  "button",
380
499
  {
381
500
  type: "button",
382
- className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
383
- onClick: (ee) => {
384
- ee.stopPropagation(), M.handleClick(Z);
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);
385
504
  },
386
- children: Q
505
+ children: ae
387
506
  }
388
507
  );
389
- } : d.action ? P = (I, Z) => {
390
- const Q = R ? /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } }) : String(I ?? "");
391
- return /* @__PURE__ */ u.jsx(
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(
392
511
  "button",
393
512
  {
394
513
  type: "button",
395
514
  className: "text-primary underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
396
- onClick: (ee) => {
397
- ee.stopPropagation(), B({
398
- type: d.action,
399
- params: { record: Z, field: d.field, value: I }
515
+ onClick: (ce) => {
516
+ ce.stopPropagation(), j({
517
+ type: p.action,
518
+ params: { record: le, field: p.field, value: N }
400
519
  });
401
520
  },
402
- children: Q
521
+ children: ae
403
522
  }
404
523
  );
405
- } : R && (P = (I) => /* @__PURE__ */ u.jsx(R, { value: I, field: { name: d.field, type: d.type || "text" } })), {
406
- header: T,
407
- accessorKey: d.field,
408
- ...d.width && { width: d.width },
409
- ...d.align && { align: d.align },
410
- sortable: d.sortable !== !1,
411
- ...d.resizable !== void 0 && { resizable: d.resizable },
412
- ...d.wrap !== void 0 && { wrap: d.wrap },
413
- ...P && { cell: P }
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 }
414
536
  };
415
537
  });
416
538
  }
417
- return f.filter((w) => typeof w == "string" && w.trim().length > 0).map((w) => ({
418
- header: j?.fields?.[w]?.label || w.charAt(0).toUpperCase() + w.slice(1).replace(/_/g, " "),
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, " "),
419
541
  accessorKey: w
420
542
  }));
421
543
  }
422
- if (L) {
423
- const w = C?.provider === "value" ? C.items : [];
544
+ if (U) {
545
+ const w = z?.provider === "value" ? z.items : [];
424
546
  if (w.length > 0)
425
- return ($ || Object.keys(w[0])).map((T) => ({
426
- header: T.charAt(0).toUpperCase() + T.slice(1).replace(/_/g, " "),
427
- accessorKey: T
547
+ return (W || Object.keys(w[0])).map((I) => ({
548
+ header: I.charAt(0).toUpperCase() + I.slice(1).replace(/_/g, " "),
549
+ accessorKey: I
428
550
  }));
429
551
  }
430
- if (!j) return [];
431
- const y = [];
432
- return ($ || Object.keys(j.fields || {})).forEach((w) => {
433
- const d = j.fields?.[w];
434
- if (!d || d.permissions && d.permissions.read === !1) return;
435
- const T = ue(d.type);
436
- y.push({
437
- header: d.label || w,
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,
438
560
  accessorKey: w,
439
- cell: (P) => /* @__PURE__ */ u.jsx(T, { value: P, field: d }),
440
- sortable: d.sortable !== !1
561
+ ...oe.includes(p.type) && { align: "right" },
562
+ cell: (T) => /* @__PURE__ */ a.jsx(I, { value: T, field: p }),
563
+ sortable: p.sortable !== !1
441
564
  });
442
- }), y;
443
- }, [j, $, z, C, L, M.handleClick, B]);
444
- if (_)
445
- return /* @__PURE__ */ u.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
446
- /* @__PURE__ */ u.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading grid" }),
447
- /* @__PURE__ */ u.jsx("p", { className: "text-red-600 text-sm mt-1", children: _.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 })
448
571
  ] });
449
- if (c && m.length === 0)
450
- return /* @__PURE__ */ u.jsxs("div", { className: "p-8 text-center", children: [
451
- /* @__PURE__ */ u.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
452
- /* @__PURE__ */ u.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..." })
453
576
  ] });
454
- const K = se(), W = "operations" in n ? n.operations : void 0, X = W && (W.update || W.delete), re = X ? [
455
- ...K,
577
+ const ne = G(), q = "operations" in t ? t.operations : void 0, ye = q && (q.update || q.delete), We = ye ? [
578
+ ...ne,
456
579
  {
457
580
  header: "Actions",
458
581
  accessorKey: "_actions",
459
- cell: (f, y) => /* @__PURE__ */ u.jsxs(ke, { children: [
460
- /* @__PURE__ */ u.jsx(ze, { asChild: !0, children: /* @__PURE__ */ u.jsxs(Me, { variant: "ghost", size: "icon", className: "h-8 w-8", children: [
461
- /* @__PURE__ */ u.jsx(De, { className: "h-4 w-4" }),
462
- /* @__PURE__ */ u.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" })
463
586
  ] }) }),
464
- /* @__PURE__ */ u.jsxs(Ie, { align: "end", children: [
465
- W?.update && e && /* @__PURE__ */ u.jsxs(de, { onClick: () => e(y), children: [
466
- /* @__PURE__ */ u.jsx(Fe, { 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" }),
467
590
  "Edit"
468
591
  ] }),
469
- W?.delete && s && /* @__PURE__ */ u.jsxs(de, { onClick: () => s(y), children: [
470
- /* @__PURE__ */ u.jsx(Pe, { 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" }),
471
594
  "Delete"
472
595
  ] })
473
596
  ] })
474
597
  ] }),
475
598
  sortable: !1
476
599
  }
477
- ] : K;
478
- let r = !1;
479
- n.selection?.type ? r = n.selection.type === "none" ? !1 : n.selection.type : n.selectable !== void 0 && (r = n.selectable);
480
- const h = n.pagination !== void 0 ? !0 : n.showPagination !== void 0 ? n.showPagination : !0, x = n.pagination?.pageSize || n.pageSize || 10, S = n.searchableFields !== void 0 ? n.searchableFields.length > 0 : n.showSearch !== void 0 ? n.showSearch : !0, Y = {
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 = {
481
604
  type: "data-table",
482
- caption: n.label || n.title,
483
- columns: re,
484
- data: m,
485
- pagination: h,
486
- pageSize: x,
487
- searchable: S,
488
- selectable: r,
605
+ caption: t.label || t.title,
606
+ columns: We,
607
+ data: f,
608
+ pagination: Ve,
609
+ pageSize: Ye,
610
+ searchable: Ge,
611
+ selectable: be,
489
612
  sortable: !0,
490
- exportable: W?.export,
491
- rowActions: X,
492
- resizableColumns: n.resizable ?? n.resizableColumns ?? !0,
493
- reorderableColumns: n.reorderableColumns ?? !1,
494
- editable: n.editable ?? !1,
495
- className: n.className,
496
- onSelectionChange: t,
497
- onRowClick: M.handleClick,
613
+ exportable: q?.export,
614
+ rowActions: ye,
615
+ resizableColumns: t.resizable ?? t.resizableColumns ?? !0,
616
+ reorderableColumns: t.reorderableColumns ?? !1,
617
+ editable: t.editable ?? !1,
618
+ className: t.className,
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,
498
623
  onCellChange: o,
499
624
  onRowSave: l,
500
- onBatchSave: p
501
- }, G = n.label ? `${n.label} Detail` : n.objectName ? `${n.objectName.charAt(0).toUpperCase() + n.objectName.slice(1)} Detail` : "Record Detail";
502
- return M.isOverlay && M.mode === "split" ? /* @__PURE__ */ u.jsx(
503
- fe,
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,
504
672
  {
505
- ...M,
506
- title: G,
507
- mainContent: /* @__PURE__ */ u.jsx(ce, { schema: Y }),
508
- children: (f) => /* @__PURE__ */ u.jsx("div", { className: "space-y-3", children: Object.entries(f).map(([y, A]) => /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col", children: [
509
- /* @__PURE__ */ u.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: y.replace(/_/g, " ") }),
510
- /* @__PURE__ */ u.jsx("span", { className: "text-sm", children: String(A ?? "—") })
511
- ] }, y)) })
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)) })
512
680
  }
513
- ) : /* @__PURE__ */ u.jsxs(u.Fragment, { children: [
514
- /* @__PURE__ */ u.jsx(ce, { schema: Y }),
515
- M.isOverlay && /* @__PURE__ */ u.jsx(
516
- fe,
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,
517
693
  {
518
- ...M,
519
- title: G,
520
- children: (f) => /* @__PURE__ */ u.jsx("div", { className: "space-y-3", children: Object.entries(f).map(([y, A]) => /* @__PURE__ */ u.jsxs("div", { className: "flex flex-col", children: [
521
- /* @__PURE__ */ u.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: y.replace(/_/g, " ") }),
522
- /* @__PURE__ */ u.jsx("span", { className: "text-sm", children: String(A ?? "—") })
523
- ] }, y)) })
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)) })
524
700
  }
525
701
  )
526
702
  ] });
527
703
  };
528
- function H(n, a, e) {
529
- let s = e.initialDeps ?? [], t, i = !0;
704
+ function se(t, c, e) {
705
+ let n = e.initialDeps ?? [], s, i = !0;
530
706
  function o() {
531
- var l, p, g;
532
- let m;
533
- e.key && ((l = e.debug) != null && l.call(e)) && (m = Date.now());
534
- const E = n();
535
- if (!(E.length !== s.length || E.some((_, v) => s[v] !== _)))
536
- return t;
537
- s = E;
538
- let b;
539
- if (e.key && ((p = e.debug) != null && p.call(e)) && (b = Date.now()), t = a(...E), e.key && ((g = e.debug) != null && g.call(e))) {
540
- const _ = Math.round((Date.now() - m) * 100) / 100, v = Math.round((Date.now() - b) * 100) / 100, j = v / 16, N = (O, D) => {
541
- for (O = String(O); O.length < D; )
542
- O = " " + O;
543
- return O;
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;
714
+ let d;
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 _;
544
720
  };
545
721
  console.info(
546
- `%c⏱ ${N(v, 5)} /${N(_, 5)} ms`,
722
+ `%c⏱ ${R(x, 5)} /${R(y, 5)} ms`,
547
723
  `
548
724
  font-size: .6rem;
549
725
  font-weight: bold;
550
726
  color: hsl(${Math.max(
551
727
  0,
552
- Math.min(120 - 120 * j, 120)
728
+ Math.min(120 - 120 * S, 120)
553
729
  )}deg 100% 31%);`,
554
730
  e?.key
555
731
  );
556
732
  }
557
- return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(t), i = !1, t;
733
+ return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(s), i = !1, s;
558
734
  }
559
735
  return o.updateDeps = (l) => {
560
- s = l;
736
+ n = l;
561
737
  }, o;
562
738
  }
563
- function be(n, a) {
564
- if (n === void 0)
739
+ function Ae(t, c) {
740
+ if (t === void 0)
565
741
  throw new Error("Unexpected undefined");
566
- return n;
742
+ return t;
567
743
  }
568
- const qe = (n, a) => Math.abs(n - a) < 1.01, Be = (n, a, e) => {
569
- let s;
570
- return function(...t) {
571
- n.clearTimeout(s), s = n.setTimeout(() => a.apply(this, t), 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);
572
748
  };
573
- }, ve = (n) => {
574
- const { offsetWidth: a, offsetHeight: e } = n;
575
- return { width: a, height: e };
576
- }, Ge = (n) => n, He = (n) => {
577
- const a = Math.max(n.startIndex - n.overscan, 0), e = Math.min(n.endIndex + n.overscan, n.count - 1), s = [];
578
- for (let t = a; t <= e; t++)
579
- s.push(t);
580
- return s;
581
- }, Je = (n, a) => {
582
- const e = n.scrollElement;
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) => {
758
+ const e = t.scrollElement;
583
759
  if (!e)
584
760
  return;
585
- const s = n.targetWindow;
586
- if (!s)
761
+ const n = t.targetWindow;
762
+ if (!n)
587
763
  return;
588
- const t = (o) => {
589
- const { width: l, height: p } = o;
590
- a({ width: Math.round(l), height: Math.round(p) });
764
+ const s = (o) => {
765
+ const { width: l, height: g } = o;
766
+ c({ width: Math.round(l), height: Math.round(g) });
591
767
  };
592
- if (t(ve(e)), !s.ResizeObserver)
768
+ if (s(ze(e)), !n.ResizeObserver)
593
769
  return () => {
594
770
  };
595
- const i = new s.ResizeObserver((o) => {
771
+ const i = new n.ResizeObserver((o) => {
596
772
  const l = () => {
597
- const p = o[0];
598
- if (p?.borderBoxSize) {
599
- const g = p.borderBoxSize[0];
600
- if (g) {
601
- t({ width: g.inlineSize, height: g.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 });
602
778
  return;
603
779
  }
604
780
  }
605
- t(ve(e));
781
+ s(ze(e));
606
782
  };
607
- n.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
783
+ t.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
608
784
  });
609
785
  return i.observe(e, { box: "border-box" }), () => {
610
786
  i.unobserve(e);
611
787
  };
612
- }, xe = {
788
+ }, Me = {
613
789
  passive: !0
614
- }, ye = typeof window > "u" ? !0 : "onscrollend" in window, Ke = (n, a) => {
615
- const e = n.scrollElement;
790
+ }, Ie = typeof window > "u" ? !0 : "onscrollend" in window, kt = (t, c) => {
791
+ const e = t.scrollElement;
616
792
  if (!e)
617
793
  return;
618
- const s = n.targetWindow;
619
- if (!s)
794
+ const n = t.targetWindow;
795
+ if (!n)
620
796
  return;
621
- let t = 0;
622
- const i = n.options.useScrollendEvent && ye ? () => {
623
- } : Be(
624
- s,
797
+ let s = 0;
798
+ const i = t.options.useScrollendEvent && Ie ? () => {
799
+ } : Ot(
800
+ n,
625
801
  () => {
626
- a(t, !1);
802
+ c(s, !1);
627
803
  },
628
- n.options.isScrollingResetDelay
629
- ), o = (m) => () => {
630
- const { horizontal: E, isRtl: c } = n.options;
631
- t = E ? e.scrollLeft * (c && -1 || 1) : e.scrollTop, i(), a(t, m);
632
- }, l = o(!0), p = o(!1);
633
- e.addEventListener("scroll", l, xe);
634
- const g = n.options.useScrollendEvent && ye;
635
- return g && e.addEventListener("scrollend", p, xe), () => {
636
- e.removeEventListener("scroll", l), g && e.removeEventListener("scrollend", p);
804
+ t.options.isScrollingResetDelay
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);
637
813
  };
638
- }, Xe = (n, a, e) => {
639
- if (a?.borderBoxSize) {
640
- const s = a.borderBoxSize[0];
641
- if (s)
814
+ }, Tt = (t, c, e) => {
815
+ if (c?.borderBoxSize) {
816
+ const n = c.borderBoxSize[0];
817
+ if (n)
642
818
  return Math.round(
643
- s[e.options.horizontal ? "inlineSize" : "blockSize"]
819
+ n[e.options.horizontal ? "inlineSize" : "blockSize"]
644
820
  );
645
821
  }
646
- return n[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
647
- }, Ze = (n, {
648
- adjustments: a = 0,
822
+ return t[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
823
+ }, At = (t, {
824
+ adjustments: c = 0,
649
825
  behavior: e
650
- }, s) => {
651
- var t, i;
652
- const o = n + a;
653
- (i = (t = s.scrollElement) == null ? void 0 : t.scrollTo) == null || i.call(t, {
654
- [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,
655
831
  behavior: e
656
832
  });
657
833
  };
658
- class Qe {
659
- constructor(a) {
834
+ class zt {
835
+ constructor(c) {
660
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__ */ (() => {
661
837
  let e = null;
662
- const s = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((t) => {
663
- t.forEach((i) => {
838
+ const n = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((s) => {
839
+ s.forEach((i) => {
664
840
  const o = () => {
665
841
  this._measureElement(i.target, i);
666
842
  };
@@ -669,21 +845,21 @@ class Qe {
669
845
  }));
670
846
  return {
671
847
  disconnect: () => {
672
- var t;
673
- (t = s()) == null || t.disconnect(), e = null;
848
+ var s;
849
+ (s = n()) == null || s.disconnect(), e = null;
674
850
  },
675
- observe: (t) => {
851
+ observe: (s) => {
676
852
  var i;
677
- return (i = s()) == null ? void 0 : i.observe(t, { box: "border-box" });
853
+ return (i = n()) == null ? void 0 : i.observe(s, { box: "border-box" });
678
854
  },
679
- unobserve: (t) => {
855
+ unobserve: (s) => {
680
856
  var i;
681
- return (i = s()) == null ? void 0 : i.unobserve(t);
857
+ return (i = n()) == null ? void 0 : i.unobserve(s);
682
858
  }
683
859
  };
684
860
  })(), this.range = null, this.setOptions = (e) => {
685
- Object.entries(e).forEach(([s, t]) => {
686
- typeof t > "u" && delete e[s];
861
+ Object.entries(e).forEach(([n, s]) => {
862
+ typeof s > "u" && delete e[n];
687
863
  }), this.options = {
688
864
  debug: !1,
689
865
  initialOffset: 0,
@@ -693,11 +869,11 @@ class Qe {
693
869
  scrollPaddingStart: 0,
694
870
  scrollPaddingEnd: 0,
695
871
  horizontal: !1,
696
- getItemKey: Ge,
697
- rangeExtractor: He,
872
+ getItemKey: Nt,
873
+ rangeExtractor: _t,
698
874
  onChange: () => {
699
875
  },
700
- measureElement: Xe,
876
+ measureElement: Tt,
701
877
  initialRect: { width: 0, height: 0 },
702
878
  scrollMargin: 0,
703
879
  gap: 0,
@@ -712,9 +888,9 @@ class Qe {
712
888
  ...e
713
889
  };
714
890
  }, this.notify = (e) => {
715
- var s, t;
716
- (t = (s = this.options).onChange) == null || t.call(s, this, e);
717
- }, this.maybeNotify = H(
891
+ var n, s;
892
+ (s = (n = this.options).onChange) == null || s.call(n, this, e);
893
+ }, this.maybeNotify = se(
718
894
  () => (this.calculateRange(), [
719
895
  this.isScrolling,
720
896
  this.range ? this.range.startIndex : null,
@@ -738,41 +914,41 @@ class Qe {
738
914
  this.cleanup();
739
915
  }, this._willUpdate = () => {
740
916
  var e;
741
- const s = this.options.enabled ? this.options.getScrollElement() : null;
742
- if (this.scrollElement !== s) {
743
- if (this.cleanup(), !s) {
917
+ const n = this.options.enabled ? this.options.getScrollElement() : null;
918
+ if (this.scrollElement !== n) {
919
+ if (this.cleanup(), !n) {
744
920
  this.maybeNotify();
745
921
  return;
746
922
  }
747
- 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((t) => {
748
- this.observer.observe(t);
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);
749
925
  }), this.unsubs.push(
750
- this.options.observeElementRect(this, (t) => {
751
- this.scrollRect = t, this.maybeNotify();
926
+ this.options.observeElementRect(this, (s) => {
927
+ this.scrollRect = s, this.maybeNotify();
752
928
  })
753
929
  ), this.unsubs.push(
754
- this.options.observeElementOffset(this, (t, i) => {
755
- this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < t ? "forward" : "backward" : null, this.scrollOffset = t, 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();
756
932
  })
757
933
  ), this._scrollToOffset(this.getScrollOffset(), {
758
934
  adjustments: void 0,
759
935
  behavior: void 0
760
936
  });
761
937
  }
762
- }, 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) => {
763
- const t = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
764
- 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--) {
765
941
  const l = e[o];
766
- if (t.has(l.lane))
942
+ if (s.has(l.lane))
767
943
  continue;
768
- const p = i.get(
944
+ const g = i.get(
769
945
  l.lane
770
946
  );
771
- if (p == null || l.end > p.end ? i.set(l.lane, l) : l.end < p.end && t.set(l.lane, !0), t.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)
772
948
  break;
773
949
  }
774
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;
775
- }, this.getMeasurementOptions = H(
951
+ }, this.getMeasurementOptions = se(
776
952
  () => [
777
953
  this.options.count,
778
954
  this.options.paddingStart,
@@ -781,10 +957,10 @@ class Qe {
781
957
  this.options.enabled,
782
958
  this.options.lanes
783
959
  ],
784
- (e, s, t, 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 = [], {
785
961
  count: e,
786
- paddingStart: s,
787
- scrollMargin: t,
962
+ paddingStart: n,
963
+ scrollMargin: s,
788
964
  getItemKey: i,
789
965
  enabled: o,
790
966
  lanes: l
@@ -792,142 +968,142 @@ class Qe {
792
968
  {
793
969
  key: !1
794
970
  }
795
- ), this.getMeasurements = H(
971
+ ), this.getMeasurements = se(
796
972
  () => [this.getMeasurementOptions(), this.itemSizeCache],
797
- ({ count: e, paddingStart: s, scrollMargin: t, getItemKey: i, enabled: o, lanes: l }, p) => {
973
+ ({ count: e, paddingStart: n, scrollMargin: s, getItemKey: i, enabled: o, lanes: l }, g) => {
798
974
  if (!o)
799
975
  return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
800
976
  if (this.laneAssignments.size > e)
801
- for (const c of this.laneAssignments.keys())
802
- c >= e && this.laneAssignments.delete(c);
803
- 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) => {
804
- 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);
805
981
  }));
806
- const g = 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;
807
983
  this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
808
- const m = this.measurementsCache.slice(0, g), E = new Array(l).fill(
984
+ const f = this.measurementsCache.slice(0, m), v = new Array(l).fill(
809
985
  void 0
810
986
  );
811
- for (let c = 0; c < g; c++) {
812
- const b = m[c];
813
- b && (E[b.lane] = c);
987
+ for (let u = 0; u < m; u++) {
988
+ const d = f[u];
989
+ d && (v[d.lane] = u);
814
990
  }
815
- for (let c = g; c < e; c++) {
816
- const b = i(c), _ = this.laneAssignments.get(c);
817
- let v, j;
818
- if (_ !== void 0 && this.options.lanes > 1) {
819
- v = _;
820
- const k = E[v], C = k !== void 0 ? m[k] : void 0;
821
- j = C ? C.end + this.options.gap : s + t;
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;
822
998
  } else {
823
- const k = this.options.lanes === 1 ? m[c - 1] : this.getFurthestMeasurement(m, c);
824
- j = k ? k.end + this.options.gap : s + t, v = k ? k.lane : c % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(c, v);
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);
825
1001
  }
826
- const N = p.get(b), O = typeof N == "number" ? N : this.options.estimateSize(c), D = j + O;
827
- m[c] = {
828
- index: c,
829
- start: j,
830
- size: O,
831
- end: D,
832
- key: b,
833
- lane: v
834
- }, E[v] = 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;
835
1011
  }
836
- return this.measurementsCache = m, m;
1012
+ return this.measurementsCache = f, f;
837
1013
  },
838
1014
  {
839
1015
  key: process.env.NODE_ENV !== "production" && "getMeasurements",
840
1016
  debug: () => this.options.debug
841
1017
  }
842
- ), this.calculateRange = H(
1018
+ ), this.calculateRange = se(
843
1019
  () => [
844
1020
  this.getMeasurements(),
845
1021
  this.getSize(),
846
1022
  this.getScrollOffset(),
847
1023
  this.options.lanes
848
1024
  ],
849
- (e, s, t, i) => this.range = e.length > 0 && s > 0 ? et({
1025
+ (e, n, s, i) => this.range = e.length > 0 && n > 0 ? Mt({
850
1026
  measurements: e,
851
- outerSize: s,
852
- scrollOffset: t,
1027
+ outerSize: n,
1028
+ scrollOffset: s,
853
1029
  lanes: i
854
1030
  }) : null,
855
1031
  {
856
1032
  key: process.env.NODE_ENV !== "production" && "calculateRange",
857
1033
  debug: () => this.options.debug
858
1034
  }
859
- ), this.getVirtualIndexes = H(
1035
+ ), this.getVirtualIndexes = se(
860
1036
  () => {
861
- let e = null, s = null;
862
- const t = this.calculateRange();
863
- return t && (e = t.startIndex, s = t.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]), [
864
1040
  this.options.rangeExtractor,
865
1041
  this.options.overscan,
866
1042
  this.options.count,
867
1043
  e,
868
- s
1044
+ n
869
1045
  ];
870
1046
  },
871
- (e, s, t, i, o) => i === null || o === null ? [] : e({
1047
+ (e, n, s, i, o) => i === null || o === null ? [] : e({
872
1048
  startIndex: i,
873
1049
  endIndex: o,
874
- overscan: s,
875
- count: t
1050
+ overscan: n,
1051
+ count: s
876
1052
  }),
877
1053
  {
878
1054
  key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
879
1055
  debug: () => this.options.debug
880
1056
  }
881
1057
  ), this.indexFromElement = (e) => {
882
- const s = this.options.indexAttribute, t = e.getAttribute(s);
883
- return t ? parseInt(t, 10) : (console.warn(
884
- `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.`
885
1061
  ), -1);
886
- }, this._measureElement = (e, s) => {
887
- const t = this.indexFromElement(e), i = this.measurementsCache[t];
1062
+ }, this._measureElement = (e, n) => {
1063
+ const s = this.indexFromElement(e), i = this.measurementsCache[s];
888
1064
  if (!i)
889
1065
  return;
890
1066
  const o = i.key, l = this.elementsCache.get(o);
891
- l !== e && (l && this.observer.unobserve(l), this.observer.observe(e), this.elementsCache.set(o, e)), e.isConnected && this.resizeItem(t, this.options.measureElement(e, s, this));
892
- }, this.resizeItem = (e, s) => {
893
- const t = this.measurementsCache[e];
894
- if (!t)
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)
895
1071
  return;
896
- const i = this.itemSizeCache.get(t.key) ?? t.size, o = s - i;
897
- o !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(t, o, this) : t.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(), {
898
1074
  adjustments: this.scrollAdjustments += o,
899
1075
  behavior: void 0
900
- })), this.pendingMeasuredCacheIndexes.push(t.index), this.itemSizeCache = new Map(this.itemSizeCache.set(t.key, s)), this.notify(!1));
1076
+ })), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, n)), this.notify(!1));
901
1077
  }, this.measureElement = (e) => {
902
1078
  if (!e) {
903
- this.elementsCache.forEach((s, t) => {
904
- s.isConnected || (this.observer.unobserve(s), this.elementsCache.delete(t));
1079
+ this.elementsCache.forEach((n, s) => {
1080
+ n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(s));
905
1081
  });
906
1082
  return;
907
1083
  }
908
1084
  this._measureElement(e, void 0);
909
- }, this.getVirtualItems = H(
1085
+ }, this.getVirtualItems = se(
910
1086
  () => [this.getVirtualIndexes(), this.getMeasurements()],
911
- (e, s) => {
912
- const t = [];
1087
+ (e, n) => {
1088
+ const s = [];
913
1089
  for (let i = 0, o = e.length; i < o; i++) {
914
- const l = e[i], p = s[l];
915
- t.push(p);
1090
+ const l = e[i], g = n[l];
1091
+ s.push(g);
916
1092
  }
917
- return t;
1093
+ return s;
918
1094
  },
919
1095
  {
920
1096
  key: process.env.NODE_ENV !== "production" && "getVirtualItems",
921
1097
  debug: () => this.options.debug
922
1098
  }
923
1099
  ), this.getVirtualItemForOffset = (e) => {
924
- const s = this.getMeasurements();
925
- if (s.length !== 0)
926
- return be(
927
- s[je(
1100
+ const n = this.getMeasurements();
1101
+ if (n.length !== 0)
1102
+ return Ae(
1103
+ n[Le(
928
1104
  0,
929
- s.length - 1,
930
- (t) => be(s[t]).start,
1105
+ n.length - 1,
1106
+ (s) => Ae(n[s]).start,
931
1107
  e
932
1108
  )]
933
1109
  );
@@ -939,280 +1115,420 @@ class Qe {
939
1115
  const e = this.scrollElement.document.documentElement;
940
1116
  return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
941
1117
  }
942
- }, this.getOffsetForAlignment = (e, s, t = 0) => {
1118
+ }, this.getOffsetForAlignment = (e, n, s = 0) => {
943
1119
  if (!this.scrollElement) return 0;
944
1120
  const i = this.getSize(), o = this.getScrollOffset();
945
- s === "auto" && (s = e >= o + i ? "end" : "start"), s === "center" ? e += (t - 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);
946
1122
  const l = this.getMaxScrollOffset();
947
1123
  return Math.max(Math.min(l, e), 0);
948
- }, this.getOffsetForIndex = (e, s = "auto") => {
1124
+ }, this.getOffsetForIndex = (e, n = "auto") => {
949
1125
  e = Math.max(0, Math.min(e, this.options.count - 1));
950
- const t = this.measurementsCache[e];
951
- if (!t)
1126
+ const s = this.measurementsCache[e];
1127
+ if (!s)
952
1128
  return;
953
1129
  const i = this.getSize(), o = this.getScrollOffset();
954
- if (s === "auto")
955
- if (t.end >= o + i - this.options.scrollPaddingEnd)
956
- s = "end";
957
- else if (t.start <= o + this.options.scrollPaddingStart)
958
- 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";
959
1135
  else
960
- return [o, s];
961
- if (s === "end" && e === this.options.count - 1)
962
- return [this.getMaxScrollOffset(), s];
963
- const l = s === "end" ? t.end + this.options.scrollPaddingEnd : t.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;
964
1140
  return [
965
- this.getOffsetForAlignment(l, s, t.size),
966
- s
1141
+ this.getOffsetForAlignment(l, n, s.size),
1142
+ n
967
1143
  ];
968
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: s = "start", behavior: t } = {}) => {
969
- t === "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(
970
1146
  "The `smooth` scroll behavior is not fully supported with dynamic size."
971
- ), this._scrollToOffset(this.getOffsetForAlignment(e, s), {
1147
+ ), this._scrollToOffset(this.getOffsetForAlignment(e, n), {
972
1148
  adjustments: void 0,
973
- behavior: t
1149
+ behavior: s
974
1150
  });
975
- }, this.scrollToIndex = (e, { align: s = "auto", behavior: t } = {}) => {
976
- t === "smooth" && this.isDynamicMode() && console.warn(
1151
+ }, this.scrollToIndex = (e, { align: n = "auto", behavior: s } = {}) => {
1152
+ s === "smooth" && this.isDynamicMode() && console.warn(
977
1153
  "The `smooth` scroll behavior is not fully supported with dynamic size."
978
1154
  ), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
979
1155
  let i = 0;
980
- const o = 10, l = (g) => {
1156
+ const o = 10, l = (m) => {
981
1157
  if (!this.targetWindow) return;
982
- const m = this.getOffsetForIndex(e, g);
983
- if (!m) {
1158
+ const f = this.getOffsetForIndex(e, m);
1159
+ if (!f) {
984
1160
  console.warn("Failed to get offset for index:", e);
985
1161
  return;
986
1162
  }
987
- const [E, c] = m;
988
- this._scrollToOffset(E, { adjustments: void 0, behavior: t }), this.targetWindow.requestAnimationFrame(() => {
989
- const b = () => {
1163
+ const [v, u] = f;
1164
+ this._scrollToOffset(v, { adjustments: void 0, behavior: s }), this.targetWindow.requestAnimationFrame(() => {
1165
+ const d = () => {
990
1166
  if (this.currentScrollToIndex !== e) return;
991
- const _ = this.getScrollOffset(), v = this.getOffsetForIndex(e, c);
992
- if (!v) {
1167
+ const y = this.getScrollOffset(), x = this.getOffsetForIndex(e, u);
1168
+ if (!x) {
993
1169
  console.warn("Failed to get offset for index:", e);
994
1170
  return;
995
1171
  }
996
- qe(v[0], _) || p(c);
1172
+ Ct(x[0], y) || g(u);
997
1173
  };
998
- this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(b) : b();
1174
+ this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(d) : d();
999
1175
  });
1000
- }, p = (g) => {
1001
- 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(g))) : 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(
1002
1178
  `Failed to scroll to index ${e} after ${o} attempts.`
1003
1179
  ));
1004
1180
  };
1005
- l(s);
1006
- }, this.scrollBy = (e, { behavior: s } = {}) => {
1007
- s === "smooth" && this.isDynamicMode() && console.warn(
1181
+ l(n);
1182
+ }, this.scrollBy = (e, { behavior: n } = {}) => {
1183
+ n === "smooth" && this.isDynamicMode() && console.warn(
1008
1184
  "The `smooth` scroll behavior is not fully supported with dynamic size."
1009
1185
  ), this._scrollToOffset(this.getScrollOffset() + e, {
1010
1186
  adjustments: void 0,
1011
- behavior: s
1187
+ behavior: n
1012
1188
  });
1013
1189
  }, this.getTotalSize = () => {
1014
1190
  var e;
1015
- const s = this.getMeasurements();
1016
- let t;
1017
- if (s.length === 0)
1018
- t = this.options.paddingStart;
1191
+ const n = this.getMeasurements();
1192
+ let s;
1193
+ if (n.length === 0)
1194
+ s = this.options.paddingStart;
1019
1195
  else if (this.options.lanes === 1)
1020
- t = ((e = s[s.length - 1]) == null ? void 0 : e.end) ?? 0;
1196
+ s = ((e = n[n.length - 1]) == null ? void 0 : e.end) ?? 0;
1021
1197
  else {
1022
1198
  const i = Array(this.options.lanes).fill(null);
1023
- let o = s.length - 1;
1199
+ let o = n.length - 1;
1024
1200
  for (; o >= 0 && i.some((l) => l === null); ) {
1025
- const l = s[o];
1201
+ const l = n[o];
1026
1202
  i[l.lane] === null && (i[l.lane] = l.end), o--;
1027
1203
  }
1028
- t = Math.max(...i.filter((l) => l !== null));
1204
+ s = Math.max(...i.filter((l) => l !== null));
1029
1205
  }
1030
1206
  return Math.max(
1031
- t - this.options.scrollMargin + this.options.paddingEnd,
1207
+ s - this.options.scrollMargin + this.options.paddingEnd,
1032
1208
  0
1033
1209
  );
1034
1210
  }, this._scrollToOffset = (e, {
1035
- adjustments: s,
1036
- behavior: t
1211
+ adjustments: n,
1212
+ behavior: s
1037
1213
  }) => {
1038
- this.options.scrollToFn(e, { behavior: t, adjustments: s }, this);
1214
+ this.options.scrollToFn(e, { behavior: s, adjustments: n }, this);
1039
1215
  }, this.measure = () => {
1040
1216
  this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
1041
- }, this.setOptions(a);
1217
+ }, this.setOptions(c);
1042
1218
  }
1043
1219
  }
1044
- const je = (n, a, e, s) => {
1045
- for (; n <= a; ) {
1046
- const t = (n + a) / 2 | 0, i = e(t);
1047
- if (i < s)
1048
- n = t + 1;
1049
- else if (i > s)
1050
- a = t - 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;
1051
1227
  else
1052
- return t;
1228
+ return s;
1053
1229
  }
1054
- return n > 0 ? n - 1 : 0;
1230
+ return t > 0 ? t - 1 : 0;
1055
1231
  };
1056
- function et({
1057
- measurements: n,
1058
- outerSize: a,
1232
+ function Mt({
1233
+ measurements: t,
1234
+ outerSize: c,
1059
1235
  scrollOffset: e,
1060
- lanes: s
1236
+ lanes: n
1061
1237
  }) {
1062
- const t = n.length - 1, i = (p) => n[p].start;
1063
- if (n.length <= s)
1238
+ const s = t.length - 1, i = (g) => t[g].start;
1239
+ if (t.length <= n)
1064
1240
  return {
1065
1241
  startIndex: 0,
1066
- endIndex: t
1242
+ endIndex: s
1067
1243
  };
1068
- let o = je(
1244
+ let o = Le(
1069
1245
  0,
1070
- t,
1246
+ s,
1071
1247
  i,
1072
1248
  e
1073
1249
  ), l = o;
1074
- if (s === 1)
1075
- for (; l < t && n[l].end < e + a; )
1250
+ if (n === 1)
1251
+ for (; l < s && t[l].end < e + c; )
1076
1252
  l++;
1077
- else if (s > 1) {
1078
- const p = Array(s).fill(0);
1079
- for (; l < t && p.some((m) => m < e + a); ) {
1080
- const m = n[l];
1081
- p[m.lane] = m.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++;
1082
1258
  }
1083
- const g = Array(s).fill(e + a);
1084
- for (; o >= 0 && g.some((m) => m >= e); ) {
1085
- const m = n[o];
1086
- g[m.lane] = m.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--;
1087
1263
  }
1088
- o = Math.max(0, o - o % s), l = Math.min(t, l + (s - 1 - l % s));
1264
+ o = Math.max(0, o - o % n), l = Math.min(s, l + (n - 1 - l % n));
1089
1265
  }
1090
1266
  return { startIndex: o, endIndex: l };
1091
1267
  }
1092
- const Ee = typeof document < "u" ? le.useLayoutEffect : le.useEffect;
1093
- function tt({
1094
- useFlushSync: n = !0,
1095
- ...a
1268
+ const De = typeof document < "u" ? me.useLayoutEffect : me.useEffect;
1269
+ function It({
1270
+ useFlushSync: t = !0,
1271
+ ...c
1096
1272
  }) {
1097
- const e = le.useReducer(() => ({}), {})[1], s = {
1098
- ...a,
1273
+ const e = me.useReducer(() => ({}), {})[1], n = {
1274
+ ...c,
1099
1275
  onChange: (i, o) => {
1100
1276
  var l;
1101
- n && o ? $e(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);
1102
1278
  }
1103
- }, [t] = le.useState(
1104
- () => new Qe(s)
1279
+ }, [s] = me.useState(
1280
+ () => new zt(n)
1105
1281
  );
1106
- return t.setOptions(s), Ee(() => t._didMount(), []), Ee(() => t._willUpdate()), t;
1282
+ return s.setOptions(n), De(() => s._didMount(), []), De(() => s._willUpdate()), s;
1107
1283
  }
1108
- function nt(n) {
1109
- return tt({
1110
- observeElementRect: Je,
1111
- observeElementOffset: Ke,
1112
- scrollToFn: Ze,
1113
- ...n
1284
+ function Dt(t) {
1285
+ return It({
1286
+ observeElementRect: Rt,
1287
+ observeElementOffset: kt,
1288
+ scrollToFn: At,
1289
+ ...t
1114
1290
  });
1115
1291
  }
1116
- const ut = ({
1117
- data: n,
1118
- columns: a,
1292
+ const Gt = ({
1293
+ data: t,
1294
+ columns: c,
1119
1295
  rowHeight: e = 40,
1120
- height: s = 600,
1121
- className: t = "",
1296
+ height: n = 600,
1297
+ className: s = "",
1122
1298
  headerClassName: i = "",
1123
1299
  rowClassName: o,
1124
1300
  onRowClick: l,
1125
- overscan: p = 5
1301
+ overscan: g = 5
1126
1302
  }) => {
1127
- const g = _e(null), m = nt({
1128
- count: n.length,
1129
- getScrollElement: () => g.current,
1303
+ const m = pe(null), f = Dt({
1304
+ count: t.length,
1305
+ getScrollElement: () => m.current,
1130
1306
  estimateSize: () => e,
1131
- overscan: p
1132
- }), E = m.getVirtualItems();
1133
- return /* @__PURE__ */ u.jsxs("div", { className: t, children: [
1134
- /* @__PURE__ */ u.jsx(
1307
+ overscan: g
1308
+ }), v = f.getVirtualItems();
1309
+ return /* @__PURE__ */ a.jsxs("div", { className: s, children: [
1310
+ /* @__PURE__ */ a.jsx(
1135
1311
  "div",
1136
1312
  {
1137
1313
  className: `grid border-b sticky top-0 bg-background z-10 ${i}`,
1138
1314
  style: {
1139
- gridTemplateColumns: a.map((c) => c.width || "1fr").join(" ")
1315
+ gridTemplateColumns: c.map((u) => u.width || "1fr").join(" ")
1140
1316
  },
1141
- children: a.map((c, b) => /* @__PURE__ */ u.jsx(
1317
+ children: c.map((u, d) => /* @__PURE__ */ a.jsx(
1142
1318
  "div",
1143
1319
  {
1144
- className: `px-4 py-2 font-semibold text-sm ${c.align === "center" ? "text-center" : c.align === "right" ? "text-right" : "text-left"}`,
1145
- 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
1146
1322
  },
1147
- b
1323
+ d
1148
1324
  ))
1149
1325
  }
1150
1326
  ),
1151
- /* @__PURE__ */ u.jsx(
1327
+ /* @__PURE__ */ a.jsx(
1152
1328
  "div",
1153
1329
  {
1154
- ref: g,
1330
+ ref: m,
1155
1331
  className: "overflow-auto",
1156
1332
  style: {
1157
- height: typeof s == "number" ? `${s}px` : s,
1333
+ height: typeof n == "number" ? `${n}px` : n,
1158
1334
  contain: "strict"
1159
1335
  },
1160
- children: /* @__PURE__ */ u.jsx(
1336
+ children: /* @__PURE__ */ a.jsx(
1161
1337
  "div",
1162
1338
  {
1163
1339
  style: {
1164
- height: `${m.getTotalSize()}px`,
1340
+ height: `${f.getTotalSize()}px`,
1165
1341
  width: "100%",
1166
1342
  position: "relative"
1167
1343
  },
1168
- children: E.map((c) => {
1169
- const b = n[c.index], _ = typeof o == "function" ? o(b, c.index) : o || "";
1170
- return /* @__PURE__ */ u.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(
1171
1347
  "div",
1172
1348
  {
1173
- className: `grid border-b hover:bg-muted/50 cursor-pointer ${_}`,
1349
+ className: `grid border-b hover:bg-muted/50 cursor-pointer ${y}`,
1174
1350
  style: {
1175
1351
  position: "absolute",
1176
1352
  top: 0,
1177
1353
  left: 0,
1178
1354
  width: "100%",
1179
- height: `${c.size}px`,
1180
- transform: `translateY(${c.start}px)`,
1181
- gridTemplateColumns: a.map((v) => v.width || "1fr").join(" ")
1355
+ height: `${u.size}px`,
1356
+ transform: `translateY(${u.start}px)`,
1357
+ gridTemplateColumns: c.map((x) => x.width || "1fr").join(" ")
1182
1358
  },
1183
- onClick: () => l?.(b, c.index),
1184
- children: a.map((v, j) => {
1185
- const N = b[v.accessorKey], O = v.cell ? v.cell(N, b) : N;
1186
- return /* @__PURE__ */ u.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(
1187
1363
  "div",
1188
1364
  {
1189
- className: `px-4 py-2 text-sm flex items-center ${v.align === "center" ? "text-center justify-center" : v.align === "right" ? "text-right justify-end" : "text-left justify-start"}`,
1190
- children: O
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: _
1191
1367
  },
1192
- j
1368
+ S
1193
1369
  );
1194
1370
  })
1195
1371
  },
1196
- c.key
1372
+ u.key
1197
1373
  );
1198
1374
  })
1199
1375
  }
1200
1376
  )
1201
1377
  }
1202
1378
  ),
1203
- /* @__PURE__ */ u.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: [
1204
1380
  "Showing ",
1205
- E.length,
1381
+ v.length,
1206
1382
  " of ",
1207
- n.length,
1383
+ t.length,
1208
1384
  " rows (virtual scrolling enabled)"
1209
1385
  ] })
1210
1386
  ] });
1211
- }, Oe = ({ schema: n, ...a }) => {
1212
- const { dataSource: e } = Ne() || {};
1213
- return /* @__PURE__ */ u.jsx(Ue, { schema: n, dataSource: e, ...a });
1214
1387
  };
1215
- we.register("object-grid", Oe, {
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, {
1216
1532
  namespace: "plugin-grid",
1217
1533
  label: "Object Grid",
1218
1534
  category: "plugin",
@@ -1222,7 +1538,7 @@ we.register("object-grid", Oe, {
1222
1538
  { name: "filters", type: "array", label: "Filters" }
1223
1539
  ]
1224
1540
  });
1225
- we.register("grid", Oe, {
1541
+ Fe.register("grid", $e, {
1226
1542
  namespace: "view",
1227
1543
  label: "Data Grid",
1228
1544
  category: "view",
@@ -1233,7 +1549,10 @@ we.register("grid", Oe, {
1233
1549
  ]
1234
1550
  });
1235
1551
  export {
1236
- Ue as ObjectGrid,
1237
- Oe as ObjectGridRenderer,
1238
- ut 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
1239
1558
  };