@object-ui/plugin-grid 3.0.3 → 3.1.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 (44) hide show
  1. package/.turbo/turbo-build.log +12 -6
  2. package/dist/index.js +2169 -922
  3. package/dist/index.umd.cjs +9 -3
  4. package/dist/plugin-grid/src/FormulaBar.d.ts +29 -0
  5. package/dist/plugin-grid/src/GroupRow.d.ts +23 -0
  6. package/dist/plugin-grid/src/ImportWizard.d.ts +29 -0
  7. package/dist/plugin-grid/src/ObjectGrid.d.ts +1 -0
  8. package/dist/plugin-grid/src/SplitPaneGrid.d.ts +22 -0
  9. package/dist/plugin-grid/src/components/BulkActionBar.d.ts +12 -0
  10. package/dist/plugin-grid/src/components/RowActionMenu.d.ts +23 -0
  11. package/dist/plugin-grid/src/index.d.ts +22 -2
  12. package/dist/plugin-grid/src/useCellClipboard.d.ts +47 -0
  13. package/dist/plugin-grid/src/useColumnSummary.d.ts +25 -0
  14. package/dist/plugin-grid/src/useGradientColor.d.ts +37 -0
  15. package/dist/plugin-grid/src/useGroupReorder.d.ts +34 -0
  16. package/dist/plugin-grid/src/useGroupedData.d.ts +24 -3
  17. package/package.json +10 -10
  18. package/src/FormulaBar.tsx +151 -0
  19. package/src/GroupRow.tsx +69 -0
  20. package/src/ImportWizard.tsx +412 -0
  21. package/src/ListColumnExtensions.test.tsx +4 -5
  22. package/src/ObjectGrid.tsx +994 -139
  23. package/src/SplitPaneGrid.tsx +120 -0
  24. package/src/VirtualGrid.tsx +2 -2
  25. package/src/__tests__/GroupRow.test.tsx +206 -0
  26. package/src/__tests__/ImportPreview.test.tsx +171 -0
  27. package/src/__tests__/accessorKey-inference.test.tsx +132 -0
  28. package/src/__tests__/airtable-style.test.tsx +508 -0
  29. package/src/__tests__/column-features.test.tsx +490 -0
  30. package/src/__tests__/grid-export.test.tsx +121 -0
  31. package/src/__tests__/mobile-card-view.test.tsx +355 -0
  32. package/src/__tests__/objectdef-enrichment.test.tsx +566 -0
  33. package/src/__tests__/phase11-features.test.tsx +418 -0
  34. package/src/__tests__/row-bulk-actions.test.tsx +413 -0
  35. package/src/__tests__/row-height.test.tsx +160 -0
  36. package/src/__tests__/useGroupedData.test.ts +165 -0
  37. package/src/components/BulkActionBar.tsx +66 -0
  38. package/src/components/RowActionMenu.tsx +91 -0
  39. package/src/index.tsx +46 -2
  40. package/src/useCellClipboard.ts +136 -0
  41. package/src/useColumnSummary.ts +128 -0
  42. package/src/useGradientColor.ts +103 -0
  43. package/src/useGroupReorder.ts +123 -0
  44. package/src/useGroupedData.ts +69 -4
package/dist/index.js CHANGED
@@ -1,306 +1,306 @@
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
- var o = null;
17
- if (i !== void 0 && (o = "" + i), s.key !== void 0 && (o = "" + s.key), "key" in s) {
1
+ import * as He from "react";
2
+ import Ie, { useRef as xe, useState as F, useCallback as M, useEffect as me, createContext as fs, useMemo as ve } from "react";
3
+ import { evaluatePlainCondition as ms, buildExpandFields as hs, ComponentRegistry as rt } from "@object-ui/core";
4
+ import { useSafeFieldLabel as ps, useDataScope as gs, useNavigationOverlay as xs, useAction as bs, SchemaRenderer as jt, useObjectTranslation as ys, useSchemaContext as Pt } from "@object-ui/react";
5
+ import { getCellRenderer as Ee, humanizeLabel as Ue, formatCompactCurrency as vs, formatDate as Qe, formatPercent as js, formatCurrency as ws } from "@object-ui/fields";
6
+ import { DropdownMenu as Ns, DropdownMenuTrigger as Cs, Button as le, DropdownMenuContent as Ss, DropdownMenuItem as Ze, Badge as Te, NavigationOverlay as et, Popover as Es, PopoverTrigger as Rs, PopoverContent as ks, Dialog as _s, DialogContent as Os, DialogHeader as Ts, DialogTitle as As, DialogDescription as Ms, cn as ue, Progress as Ds, DialogFooter as Fs, Table as Lt, TableHeader as $t, TableRow as Ye, TableHead as Pe, TableBody as Vt, TableCell as Le, Select as zs, SelectTrigger as Is, SelectValue as Ps, SelectContent as Ls, SelectItem as wt } from "@object-ui/components";
7
+ import { ChevronRight as $s, ChevronDown as Vs, MoreVertical as Ks, Edit as Ws, Trash2 as qs, AlignJustify as Nt, Rows2 as Bs, Rows3 as Us, Rows4 as Gs, Download as Ct, Type as tt, Tag as Hs, User as Ys, CheckSquare as Js, Clock as Xs, Calendar as Qs, Hash as st, FileSpreadsheet as Zs, ArrowRight as St, CheckCircle2 as en, X as it, ArrowLeft as tn, Upload as sn, AlertCircle as Kt, Check as Wt, FunctionSquare as nn, GripVertical as rn } from "lucide-react";
8
+ import { flushSync as on } from "react-dom";
9
+ var Ge = { exports: {} }, Fe = {};
10
+ var Et;
11
+ function ln() {
12
+ if (Et) return Fe;
13
+ Et = 1;
14
+ var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), o = /* @__PURE__ */ Symbol.for("react.fragment");
15
+ function t(n, r, i) {
16
+ var a = null;
17
+ if (i !== void 0 && (a = "" + i), r.key !== void 0 && (a = "" + r.key), "key" in r) {
18
18
  i = {};
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,
19
+ for (var l in r)
20
+ l !== "key" && (i[l] = r[l]);
21
+ } else i = r;
22
+ return r = i.ref, {
23
+ $$typeof: e,
24
24
  type: n,
25
- key: o,
26
- ref: s !== void 0 ? s : null,
25
+ key: a,
26
+ ref: r !== void 0 ? r : null,
27
27
  props: i
28
28
  };
29
29
  }
30
- return ue.Fragment = c, ue.jsx = e, ue.jsxs = e, ue;
30
+ return Fe.Fragment = o, Fe.jsx = t, Fe.jsxs = t, Fe;
31
31
  }
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
- if (r == null) return null;
38
- if (typeof r == "function")
39
- return r.$$typeof === Z ? null : r.displayName || r.name || null;
40
- if (typeof r == "string") return r;
41
- switch (r) {
42
- case S:
32
+ var ze = {};
33
+ var Rt;
34
+ function an() {
35
+ return Rt || (Rt = 1, process.env.NODE_ENV !== "production" && (function() {
36
+ function e(u) {
37
+ if (u == null) return null;
38
+ if (typeof u == "function")
39
+ return u.$$typeof === ae ? null : u.displayName || u.name || null;
40
+ if (typeof u == "string") return u;
41
+ switch (u) {
42
+ case k:
43
43
  return "Fragment";
44
- case _:
44
+ case D:
45
45
  return "Profiler";
46
- case R:
46
+ case T:
47
47
  return "StrictMode";
48
- case k:
48
+ case H:
49
49
  return "Suspense";
50
- case L:
50
+ case re:
51
51
  return "SuspenseList";
52
- case X:
52
+ case Re:
53
53
  return "Activity";
54
54
  }
55
- if (typeof r == "object")
56
- switch (typeof r.tag == "number" && console.error(
55
+ if (typeof u == "object")
56
+ switch (typeof u.tag == "number" && console.error(
57
57
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
58
- ), r.$$typeof) {
59
- case x:
58
+ ), u.$$typeof) {
59
+ case v:
60
60
  return "Portal";
61
- case A:
62
- return r.displayName || "Context";
63
- case F:
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;
61
+ case G:
62
+ return u.displayName || "Context";
63
+ case z:
64
+ return (u._context.displayName || "Context") + ".Consumer";
65
+ case W:
66
+ var _ = u.render;
67
+ return u = u.displayName, u || (u = _.displayName || _.name || "", u = u !== "" ? "ForwardRef(" + u + ")" : "ForwardRef"), u;
68
+ case Ae:
69
+ return _ = u.displayName || null, _ !== null ? _ : e(u.type) || "Memo";
70
+ case je:
71
+ _ = u._payload, u = u._init;
72
72
  try {
73
- return t(r(h));
73
+ return e(u(_));
74
74
  } catch {
75
75
  }
76
76
  }
77
77
  return null;
78
78
  }
79
- function c(r) {
80
- return "" + r;
79
+ function o(u) {
80
+ return "" + u;
81
81
  }
82
- function e(r) {
82
+ function t(u) {
83
83
  try {
84
- c(r);
85
- var h = !1;
84
+ o(u);
85
+ var _ = !1;
86
86
  } catch {
87
- h = !0;
87
+ _ = !0;
88
88
  }
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,
89
+ if (_) {
90
+ _ = console;
91
+ var $ = _.error, B = typeof Symbol == "function" && Symbol.toStringTag && u[Symbol.toStringTag] || u.constructor.name || "Object";
92
+ return $.call(
93
+ _,
94
94
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
95
- C
96
- ), c(r);
95
+ B
96
+ ), o(u);
97
97
  }
98
98
  }
99
- function n(r) {
100
- if (r === S) return "<>";
101
- if (typeof r == "object" && r !== null && r.$$typeof === J)
99
+ function n(u) {
100
+ if (u === k) return "<>";
101
+ if (typeof u == "object" && u !== null && u.$$typeof === je)
102
102
  return "<...>";
103
103
  try {
104
- var h = t(r);
105
- return h ? "<" + h + ">" : "<...>";
104
+ var _ = e(u);
105
+ return _ ? "<" + _ + ">" : "<...>";
106
106
  } catch {
107
107
  return "<...>";
108
108
  }
109
109
  }
110
- function s() {
111
- var r = Q.A;
112
- return r === null ? null : r.getOwner();
110
+ function r() {
111
+ var u = pe.A;
112
+ return u === null ? null : u.getOwner();
113
113
  }
114
114
  function i() {
115
115
  return Error("react-stack-top-frame");
116
116
  }
117
- function o(r) {
118
- if (z.call(r, "key")) {
119
- var h = Object.getOwnPropertyDescriptor(r, "key").get;
120
- if (h && h.isReactWarning) return !1;
117
+ function a(u) {
118
+ if (L.call(u, "key")) {
119
+ var _ = Object.getOwnPropertyDescriptor(u, "key").get;
120
+ if (_ && _.isReactWarning) return !1;
121
121
  }
122
- return r.key !== void 0;
122
+ return u.key !== void 0;
123
123
  }
124
- function l(r, h) {
125
- function j() {
126
- W || (W = !0, console.error(
124
+ function l(u, _) {
125
+ function $() {
126
+ ie || (ie = !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
- h
128
+ _
129
129
  ));
130
130
  }
131
- j.isReactWarning = !0, Object.defineProperty(r, "key", {
132
- get: j,
131
+ $.isReactWarning = !0, Object.defineProperty(u, "key", {
132
+ get: $,
133
133
  configurable: !0
134
134
  });
135
135
  }
136
- function g() {
137
- var r = t(this.type);
138
- return V[r] || (V[r] = !0, console.error(
136
+ function h() {
137
+ var u = e(this.type);
138
+ return we[u] || (we[u] = !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
- )), r = this.props.ref, r !== void 0 ? r : null;
140
+ )), u = this.props.ref, u !== void 0 ? u : null;
141
141
  }
142
- function m(r, h, j, C, ee, te) {
143
- var O = j.ref;
144
- return r = {
145
- $$typeof: y,
146
- type: r,
147
- key: h,
148
- props: j,
149
- _owner: C
150
- }, (O !== void 0 ? O : null) !== null ? Object.defineProperty(r, "ref", {
142
+ function f(u, _, $, B, Ne, X) {
143
+ var I = $.ref;
144
+ return u = {
145
+ $$typeof: j,
146
+ type: u,
147
+ key: _,
148
+ props: $,
149
+ _owner: B
150
+ }, (I !== void 0 ? I : null) !== null ? Object.defineProperty(u, "ref", {
151
151
  enumerable: !1,
152
- get: g
153
- }) : Object.defineProperty(r, "ref", { enumerable: !1, value: null }), r._store = {}, Object.defineProperty(r._store, "validated", {
152
+ get: h
153
+ }) : Object.defineProperty(u, "ref", { enumerable: !1, value: null }), u._store = {}, Object.defineProperty(u._store, "validated", {
154
154
  configurable: !1,
155
155
  enumerable: !1,
156
156
  writable: !0,
157
157
  value: 0
158
- }), Object.defineProperty(r, "_debugInfo", {
158
+ }), Object.defineProperty(u, "_debugInfo", {
159
159
  configurable: !1,
160
160
  enumerable: !1,
161
161
  writable: !0,
162
162
  value: null
163
- }), Object.defineProperty(r, "_debugStack", {
163
+ }), Object.defineProperty(u, "_debugStack", {
164
164
  configurable: !1,
165
165
  enumerable: !1,
166
166
  writable: !0,
167
- value: ee
168
- }), Object.defineProperty(r, "_debugTask", {
167
+ value: Ne
168
+ }), Object.defineProperty(u, "_debugTask", {
169
169
  configurable: !1,
170
170
  enumerable: !1,
171
171
  writable: !0,
172
- value: te
173
- }), Object.freeze && (Object.freeze(r.props), Object.freeze(r)), r;
172
+ value: X
173
+ }), Object.freeze && (Object.freeze(u.props), Object.freeze(u)), u;
174
174
  }
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);
175
+ function d(u, _, $, B, Ne, X) {
176
+ var I = _.children;
177
+ if (I !== void 0)
178
+ if (B)
179
+ if (J(I)) {
180
+ for (B = 0; B < I.length; B++)
181
+ m(I[B]);
182
+ Object.freeze && Object.freeze(I);
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 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";
187
+ else m(I);
188
+ if (L.call(_, "key")) {
189
+ I = e(u);
190
+ var Y = Object.keys(_).filter(function(he) {
191
+ return he !== "key";
192
192
  });
193
- C = 0 < G.length ? "{key: someKey, " + G.join(": ..., ") + ": ...}" : "{key: someKey}", ie[O + C] || (G = 0 < G.length ? "{" + G.join(": ..., ") + ": ...}" : "{}", console.error(
193
+ B = 0 < Y.length ? "{key: someKey, " + Y.join(": ..., ") + ": ...}" : "{key: someKey}", ge[I + B] || (Y = 0 < Y.length ? "{" + Y.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
- C,
201
- O,
202
- G,
203
- O
204
- ), ie[O + C] = !0);
200
+ B,
201
+ I,
202
+ Y,
203
+ I
204
+ ), ge[I + B] = !0);
205
205
  }
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
- typeof r == "function" ? r.displayName || r.name || "Unknown" : r
214
- ), m(
215
- r,
216
- O,
217
- j,
218
- s(),
219
- ee,
220
- te
206
+ if (I = null, $ !== void 0 && (t($), I = "" + $), a(_) && (t(_.key), I = "" + _.key), "key" in _) {
207
+ $ = {};
208
+ for (var ce in _)
209
+ ce !== "key" && ($[ce] = _[ce]);
210
+ } else $ = _;
211
+ return I && l(
212
+ $,
213
+ typeof u == "function" ? u.displayName || u.name || "Unknown" : u
214
+ ), f(
215
+ u,
216
+ I,
217
+ $,
218
+ r(),
219
+ Ne,
220
+ X
221
221
  );
222
222
  }
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));
223
+ function m(u) {
224
+ p(u) ? u._store && (u._store.validated = 1) : typeof u == "object" && u !== null && u.$$typeof === je && (u._payload.status === "fulfilled" ? p(u._payload.value) && u._payload.value._store && (u._payload.value._store.validated = 1) : u._store && (u._store.validated = 1));
225
225
  }
226
- function u(r) {
227
- return typeof r == "object" && r !== null && r.$$typeof === y;
226
+ function p(u) {
227
+ return typeof u == "object" && u !== null && u.$$typeof === j;
228
228
  }
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() {
229
+ var x = Ie, j = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), k = /* @__PURE__ */ Symbol.for("react.fragment"), T = /* @__PURE__ */ Symbol.for("react.strict_mode"), D = /* @__PURE__ */ Symbol.for("react.profiler"), z = /* @__PURE__ */ Symbol.for("react.consumer"), G = /* @__PURE__ */ Symbol.for("react.context"), W = /* @__PURE__ */ Symbol.for("react.forward_ref"), H = /* @__PURE__ */ Symbol.for("react.suspense"), re = /* @__PURE__ */ Symbol.for("react.suspense_list"), Ae = /* @__PURE__ */ Symbol.for("react.memo"), je = /* @__PURE__ */ Symbol.for("react.lazy"), Re = /* @__PURE__ */ Symbol.for("react.activity"), ae = /* @__PURE__ */ Symbol.for("react.client.reference"), pe = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, L = Object.prototype.hasOwnProperty, J = Array.isArray, fe = console.createTask ? console.createTask : function() {
230
230
  return null;
231
231
  };
232
- d = {
233
- react_stack_bottom_frame: function(r) {
234
- return r();
232
+ x = {
233
+ react_stack_bottom_frame: function(u) {
234
+ return u();
235
235
  }
236
236
  };
237
- var W, V = {}, H = d.react_stack_bottom_frame.bind(
238
- d,
237
+ var ie, we = {}, ee = x.react_stack_bottom_frame.bind(
238
+ x,
239
239
  i
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
- r,
245
- h,
246
- j,
240
+ )(), be = fe(n(i)), ge = {};
241
+ ze.Fragment = k, ze.jsx = function(u, _, $) {
242
+ var B = 1e4 > pe.recentlyCreatedOwnerStacks++;
243
+ return d(
244
+ u,
245
+ _,
246
+ $,
247
247
  !1,
248
- C ? Error("react-stack-top-frame") : H,
249
- C ? P(n(r)) : Y
248
+ B ? Error("react-stack-top-frame") : ee,
249
+ B ? fe(n(u)) : be
250
250
  );
251
- }, de.jsxs = function(r, h, j) {
252
- var C = 1e4 > Q.recentlyCreatedOwnerStacks++;
253
- return f(
254
- r,
255
- h,
256
- j,
251
+ }, ze.jsxs = function(u, _, $) {
252
+ var B = 1e4 > pe.recentlyCreatedOwnerStacks++;
253
+ return d(
254
+ u,
255
+ _,
256
+ $,
257
257
  !0,
258
- C ? Error("react-stack-top-frame") : H,
259
- C ? P(n(r)) : Y
258
+ B ? Error("react-stack-top-frame") : ee,
259
+ B ? fe(n(u)) : be
260
260
  );
261
261
  };
262
- })()), de;
262
+ })()), ze;
263
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;
264
+ var kt;
265
+ function cn() {
266
+ return kt || (kt = 1, process.env.NODE_ENV === "production" ? Ge.exports = ln() : Ge.exports = an()), Ge.exports;
267
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) => {
268
+ var s = cn();
269
+ function dn(e) {
270
+ const { onRefresh: o, threshold: t = 80, enabled: n = !0 } = e, r = xe(null), [i, a] = F(!1), [l, h] = F(0), f = xe(0), d = M((x) => {
271
271
  if (!n || i)
272
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)
273
+ const j = r.current;
274
+ j && j.scrollTop === 0 && (f.current = x.touches[0].clientY);
275
+ }, [n, i]), m = M((x) => {
276
+ if (!n || i || !f.current)
277
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
- }
278
+ const v = x.touches[0].clientY - f.current;
279
+ v > 0 && h(Math.min(v, t * 1.5));
280
+ }, [n, i, t]), p = M(async () => {
281
+ if (!n || i)
282
+ return;
283
+ const x = l;
284
+ if (h(0), f.current = 0, x >= t) {
285
+ a(!0);
286
+ try {
287
+ await o();
288
+ } finally {
289
+ a(!1);
289
290
  }
290
- g(0), m.current = 0;
291
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);
292
+ }, [n, i, l, t, o]);
293
+ return me(() => {
294
+ const x = r.current;
295
+ if (!(!x || !n))
296
+ return x.addEventListener("touchstart", d, { passive: !0 }), x.addEventListener("touchmove", m, { passive: !0 }), x.addEventListener("touchend", p, { passive: !0 }), () => {
297
+ x.removeEventListener("touchstart", d), x.removeEventListener("touchmove", m), x.removeEventListener("touchend", p);
298
298
  };
299
- }, [f, v, u, n]), { ref: s, isRefreshing: i, pullDistance: l };
299
+ }, [d, m, p, n]), { ref: r, isRefreshing: i, pullDistance: l };
300
300
  }
301
- const pt = Be(null);
302
- pt.displayName = "MobileContext";
303
- const gt = {
301
+ const un = fs(null);
302
+ un.displayName = "MobileContext";
303
+ const fn = {
304
304
  red: "bg-red-100",
305
305
  green: "bg-green-100",
306
306
  blue: "bg-blue-100",
@@ -325,541 +325,1176 @@ const gt = {
325
325
  stone: "bg-stone-100",
326
326
  neutral: "bg-neutral-100"
327
327
  };
328
- function bt(t) {
329
- if (t.startsWith("bg-")) return t;
330
- const c = t.toLowerCase().trim();
331
- return gt[c];
328
+ function mn(e) {
329
+ if (e.startsWith("bg-")) return e;
330
+ const o = e.toLowerCase().trim();
331
+ return fn[o];
332
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];
333
+ function hn(e) {
334
+ return M(
335
+ (o) => {
336
+ if (!e?.field || !e.colors) return;
337
+ const t = String(o[e.field] ?? ""), n = e.colors[t];
338
338
  if (n)
339
- return bt(n);
339
+ return mn(n);
340
340
  },
341
- [t?.field, t?.colors]
341
+ [e?.field, e?.colors]
342
342
  );
343
343
  }
344
- function vt(t, c) {
345
- return c.map((e) => String(t[e.field] ?? "")).join(" / ");
344
+ function pn(e, o) {
345
+ return o.map((t) => String(e[t.field] ?? "")).join(" / ");
346
346
  }
347
- function yt(t, c) {
348
- return c.map((e) => {
349
- const n = t[e.field];
347
+ function gn(e, o) {
348
+ return o.map((t) => {
349
+ const n = e[t.field];
350
350
  return n != null && n !== "" ? String(n) : "(empty)";
351
351
  }).join(" / ");
352
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;
353
+ function xn(e, o) {
354
+ return o.map(({ field: t, type: n }) => {
355
+ const r = e.map((a) => Number(a[t])).filter((a) => Number.isFinite(a));
356
+ let i;
357
+ switch (n) {
358
+ case "count":
359
+ i = r.length;
360
+ break;
361
+ case "sum":
362
+ i = r.reduce((a, l) => a + l, 0);
363
+ break;
364
+ case "avg":
365
+ i = r.length > 0 ? r.reduce((a, l) => a + l, 0) / r.length : 0;
366
+ break;
367
+ case "min":
368
+ i = r.length > 0 ? Math.min(...r) : 0;
369
+ break;
370
+ case "max":
371
+ i = r.length > 0 ? Math.max(...r) : 0;
372
+ break;
373
+ default:
374
+ i = 0;
375
+ }
376
+ return { field: t, type: n, value: i };
377
+ });
378
+ }
379
+ function bn(e, o, t) {
380
+ const n = e.localeCompare(o, void 0, { numeric: !0, sensitivity: "base" });
381
+ return t === "desc" ? -n : n;
356
382
  }
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);
383
+ function yn(e, o, t) {
384
+ const n = e?.fields, r = !!(n && n.length > 0), [i, a] = F({}), l = ve(() => n ? n.some((d) => d.collapsed) : !1, [n]), h = ve(() => {
385
+ if (!r || !n) return [];
386
+ const d = /* @__PURE__ */ new Map(), m = [];
387
+ for (const x of o) {
388
+ const j = pn(x, n);
389
+ d.has(j) || (d.set(j, { label: gn(x, n), rows: [] }), m.push(j)), d.get(j).rows.push(x);
364
390
  }
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 };
391
+ const p = n[0]?.order ?? "asc";
392
+ return m.sort((x, j) => bn(x, j, p)), m.map((x) => {
393
+ const j = d.get(x), v = x in i ? i[x] : l, k = t && t.length > 0 ? xn(j.rows, t) : [];
394
+ return { key: x, label: j.label, rows: j.rows, collapsed: v, aggregations: k };
369
395
  });
370
- }, [c, e, n, s, o]), g = $((m) => {
371
- i((f) => ({
372
- ...f,
373
- [m]: f[m] !== void 0 ? !f[m] : !o
396
+ }, [o, n, r, i, l, t]), f = M((d) => {
397
+ a((m) => ({
398
+ ...m,
399
+ [d]: m[d] !== void 0 ? !m[d] : !l
374
400
  }));
375
- }, [o]);
376
- return { groups: l, isGrouped: n, toggleGroup: g };
401
+ }, [l]);
402
+ return { groups: h, isGrouped: r, toggleGroup: f };
403
+ }
404
+ const vn = ({
405
+ groupKey: e,
406
+ label: o,
407
+ count: t,
408
+ collapsed: n,
409
+ aggregations: r,
410
+ onToggle: i,
411
+ children: a
412
+ }) => /* @__PURE__ */ s.jsxs("div", { className: "border rounded-md", "data-testid": `group-row-${e}`, children: [
413
+ /* @__PURE__ */ s.jsxs(
414
+ "button",
415
+ {
416
+ type: "button",
417
+ 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",
418
+ onClick: () => i(e),
419
+ "aria-expanded": !n,
420
+ children: [
421
+ n ? /* @__PURE__ */ s.jsx($s, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ s.jsx(Vs, { className: "h-4 w-4 shrink-0" }),
422
+ /* @__PURE__ */ s.jsx("span", { className: "group-label", children: o }),
423
+ r && r.length > 0 && /* @__PURE__ */ s.jsx("span", { className: "ml-2 text-xs text-muted-foreground group-aggregations", children: r.map((l) => /* @__PURE__ */ s.jsxs("span", { className: "mr-2", children: [
424
+ l.type,
425
+ ": ",
426
+ Number.isInteger(l.value) ? l.value : l.value.toFixed(2)
427
+ ] }, `${l.field}-${l.type}`)) }),
428
+ /* @__PURE__ */ s.jsxs("span", { className: "ml-auto text-xs text-muted-foreground group-count", children: [
429
+ "(",
430
+ t,
431
+ ")"
432
+ ] })
433
+ ]
434
+ }
435
+ ),
436
+ !n && a
437
+ ] });
438
+ function jn(e) {
439
+ return typeof e == "string" ? { type: e } : e;
377
440
  }
378
- function jt(t) {
379
- return t.data ? Array.isArray(t.data) ? {
441
+ function wn(e, o) {
442
+ if (o.length === 0) return null;
443
+ switch (e) {
444
+ case "count":
445
+ return o.length;
446
+ case "sum":
447
+ return o.reduce((t, n) => t + n, 0);
448
+ case "avg":
449
+ return o.reduce((t, n) => t + n, 0) / o.length;
450
+ case "min":
451
+ return Math.min(...o);
452
+ case "max":
453
+ return Math.max(...o);
454
+ default:
455
+ return null;
456
+ }
457
+ }
458
+ function Nn(e, o) {
459
+ if (o === null) return "";
460
+ const n = {
461
+ count: "Count",
462
+ sum: "Sum",
463
+ avg: "Avg",
464
+ min: "Min",
465
+ max: "Max"
466
+ }[e] || e, r = e === "avg" ? o.toLocaleString(void 0, { maximumFractionDigits: 2 }) : o.toLocaleString();
467
+ return `${n}: ${r}`;
468
+ }
469
+ function Cn(e, o) {
470
+ return ve(() => {
471
+ const t = /* @__PURE__ */ new Map();
472
+ if (!e || e.length === 0 || o.length === 0)
473
+ return { summaries: t, hasSummary: !1 };
474
+ for (const n of e) {
475
+ if (!n.summary) continue;
476
+ const r = jn(n.summary), i = r.field || n.field, a = [];
477
+ for (const h of o) {
478
+ const f = h[i];
479
+ if (f != null && typeof f == "number" && !isNaN(f))
480
+ a.push(f);
481
+ else if (f != null && typeof f == "string") {
482
+ const d = parseFloat(f);
483
+ isNaN(d) || a.push(d);
484
+ }
485
+ }
486
+ let l;
487
+ if (r.type === "count") {
488
+ const h = o.filter((f) => f[i] != null && f[i] !== "").length;
489
+ l = h > 0 ? h : null;
490
+ } else
491
+ l = wn(r.type, a);
492
+ t.set(n.field, {
493
+ field: n.field,
494
+ value: l,
495
+ label: Nn(r.type, l)
496
+ });
497
+ }
498
+ return { summaries: t, hasSummary: t.size > 0 };
499
+ }, [e, o]);
500
+ }
501
+ function ot(e) {
502
+ return e.replace(/_/g, " ").replace(/\b\w/g, (o) => o.toUpperCase());
503
+ }
504
+ const Sn = ({
505
+ row: e,
506
+ rowActions: o,
507
+ canEdit: t,
508
+ canDelete: n,
509
+ onEdit: r,
510
+ onDelete: i,
511
+ onAction: a
512
+ }) => /* @__PURE__ */ s.jsxs(Ns, { children: [
513
+ /* @__PURE__ */ s.jsx(Cs, { asChild: !0, children: /* @__PURE__ */ s.jsxs(
514
+ le,
515
+ {
516
+ variant: "ghost",
517
+ size: "icon",
518
+ className: "h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0",
519
+ "data-testid": "row-action-trigger",
520
+ children: [
521
+ /* @__PURE__ */ s.jsx(Ks, { className: "h-4 w-4" }),
522
+ /* @__PURE__ */ s.jsx("span", { className: "sr-only", children: "Open menu" })
523
+ ]
524
+ }
525
+ ) }),
526
+ /* @__PURE__ */ s.jsxs(Ss, { align: "end", children: [
527
+ t && r && /* @__PURE__ */ s.jsxs(Ze, { onClick: () => r(e), children: [
528
+ /* @__PURE__ */ s.jsx(Ws, { className: "mr-2 h-4 w-4" }),
529
+ "Edit"
530
+ ] }),
531
+ n && i && /* @__PURE__ */ s.jsxs(Ze, { onClick: () => i(e), children: [
532
+ /* @__PURE__ */ s.jsx(qs, { className: "mr-2 h-4 w-4" }),
533
+ "Delete"
534
+ ] }),
535
+ o?.map((l) => /* @__PURE__ */ s.jsx(
536
+ Ze,
537
+ {
538
+ onClick: () => a?.(l, e),
539
+ "data-testid": `row-action-${l}`,
540
+ children: ot(l)
541
+ },
542
+ l
543
+ ))
544
+ ] })
545
+ ] }), _t = ({
546
+ selectedRows: e,
547
+ actions: o,
548
+ onAction: t,
549
+ onClearSelection: n
550
+ }) => !o || o.length === 0 || e.length === 0 ? null : /* @__PURE__ */ s.jsxs(
551
+ "div",
552
+ {
553
+ className: "border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0",
554
+ "data-testid": "bulk-actions-bar",
555
+ children: [
556
+ /* @__PURE__ */ s.jsxs("span", { className: "text-muted-foreground font-medium", children: [
557
+ e.length,
558
+ " selected"
559
+ ] }),
560
+ /* @__PURE__ */ s.jsx("div", { className: "flex items-center gap-1 ml-2", children: o.map((r) => /* @__PURE__ */ s.jsx(
561
+ le,
562
+ {
563
+ variant: "outline",
564
+ size: "sm",
565
+ className: "h-6 px-2 text-xs",
566
+ onClick: () => t?.(r, e),
567
+ "data-testid": `bulk-action-${r}`,
568
+ children: ot(r)
569
+ },
570
+ r
571
+ )) }),
572
+ /* @__PURE__ */ s.jsx(
573
+ le,
574
+ {
575
+ variant: "ghost",
576
+ size: "sm",
577
+ className: "h-6 px-2 text-xs ml-auto",
578
+ onClick: n,
579
+ children: "Clear"
580
+ }
581
+ )
582
+ ]
583
+ }
584
+ ), Ot = {
585
+ "grid.actions": "Actions",
586
+ "grid.edit": "Edit",
587
+ "grid.delete": "Delete",
588
+ "grid.export": "Export",
589
+ "grid.exportAs": "Export as {{format}}",
590
+ "grid.loading": "Loading grid...",
591
+ "grid.errorLoading": "Error loading grid",
592
+ "grid.pullToRefresh": "Pull to refresh",
593
+ "grid.refreshing": "Refreshing…",
594
+ "grid.openRecord": "Open record"
595
+ };
596
+ function En() {
597
+ try {
598
+ const e = ys();
599
+ return e.t("grid.actions") === "grid.actions" ? {
600
+ t: (t, n) => {
601
+ let r = Ot[t] || t;
602
+ if (n)
603
+ for (const [i, a] of Object.entries(n))
604
+ r = r.replace(`{{${i}}}`, String(a));
605
+ return r;
606
+ }
607
+ } : { t: e.t };
608
+ } catch {
609
+ return {
610
+ t: (e, o) => {
611
+ let t = Ot[e] || e;
612
+ if (o)
613
+ for (const [n, r] of Object.entries(o))
614
+ t = t.replace(`{{${n}}}`, String(r));
615
+ return t;
616
+ }
617
+ };
618
+ }
619
+ }
620
+ function Rn(e) {
621
+ return e.data ? Array.isArray(e.data) ? {
380
622
  provider: "value",
381
- items: t.data
382
- } : t.data : t.staticData ? {
623
+ items: e.data
624
+ } : e.data : e.staticData ? {
383
625
  provider: "value",
384
- items: t.staticData
385
- } : t.objectName ? {
626
+ items: e.staticData
627
+ } : e.objectName ? {
386
628
  provider: "object",
387
- object: t.objectName
629
+ object: e.objectName
388
630
  } : null;
389
631
  }
390
- function Te(t) {
391
- if (!(!t || t.length === 0))
392
- return typeof t[0] == "object" && t[0] !== null, t;
632
+ function nt(e) {
633
+ if (!(!e || e.length === 0))
634
+ return typeof e[0] == "object" && e[0] !== null, e;
393
635
  }
394
- const St = ({
395
- schema: t,
396
- dataSource: c,
397
- onEdit: e,
636
+ const kn = ({
637
+ schema: e,
638
+ dataSource: o,
639
+ onEdit: t,
398
640
  onDelete: n,
399
- onRowSelect: s,
641
+ onRowSelect: r,
400
642
  onRowClick: i,
401
- onCellChange: o,
643
+ onCellChange: a,
402
644
  onRowSave: l,
403
- onBatchSave: g,
404
- ...m
645
+ onBatchSave: h,
646
+ onAddRecord: f,
647
+ ...d
405
648
  }) => {
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
649
+ const [m, p] = F([]), [x, j] = F(!0), [v, k] = F(null), { t: T } = En(), { fieldLabel: D } = ps(), [z, G] = F(null), [W, H] = F(!1), [re, Ae] = F(0), [je, Re] = F(!1), [ae, pe] = F(e.rowHeight ?? "compact"), [L, J] = F([]), fe = Ie.useMemo(() => e.id ? `grid-columns-${e.objectName}-${e.id}` : `grid-columns-${e.objectName}`, [e.objectName, e.id]), [ie, we] = F(() => {
650
+ try {
651
+ const c = localStorage.getItem(fe);
652
+ return c ? JSON.parse(c) : {};
653
+ } catch {
654
+ return {};
655
+ }
656
+ }), ee = M((c) => {
657
+ we(c);
658
+ try {
659
+ localStorage.setItem(fe, JSON.stringify(c));
660
+ } catch (O) {
661
+ console.warn("Failed to persist column state:", O);
662
+ }
663
+ }, [fe]), be = M(async () => {
664
+ Ae((c) => c + 1);
665
+ }, []), { ref: ge, isRefreshing: u, pullDistance: _ } = dn({
666
+ onRefresh: be,
667
+ enabled: !!o && !!e.objectName
411
668
  });
412
- re(() => {
413
- const b = () => F(window.innerWidth < 480);
414
- return b(), window.addEventListener("resize", b), () => window.removeEventListener("resize", b);
669
+ me(() => {
670
+ const c = () => H(window.innerWidth < 480);
671
+ return c(), window.addEventListener("resize", c), () => window.removeEventListener("resize", c);
415
672
  }, []);
416
- const X = m.data, Z = He(t.bind), Q = jt(t), z = Pe.useMemo(() => X && Array.isArray(X) ? {
673
+ const $ = d.data, B = gs(e.bind), Ne = Rn(e), X = Ie.useMemo(() => $ && Array.isArray($) ? {
417
674
  provider: "value",
418
- items: X
419
- } : Z && Array.isArray(Z) ? {
675
+ items: $
676
+ } : B && Array.isArray(B) ? {
420
677
  provider: "value",
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;
678
+ items: B
679
+ } : Ne, [JSON.stringify(Ne), B, $]), I = X?.provider === "value", Y = X?.provider === "object" && X && "object" in X ? X.object : e.objectName, ce = e.fields, he = e.columns, $e = e.filter, ke = e.sort, lt = e.pagination, at = e.pageSize;
680
+ me(() => {
681
+ I && X?.provider === "value" && (p((c) => {
682
+ const O = X.items;
683
+ return JSON.stringify(c) !== JSON.stringify(O) ? O : c;
684
+ }), j(!1));
685
+ }, [I, X]), me(() => {
686
+ if (!I || !Y || !o) return;
687
+ let c = !1;
688
+ return (async () => {
689
+ try {
690
+ const S = await o.getObjectSchema(Y);
691
+ c || G(S);
692
+ } catch (S) {
693
+ console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${Y}):`, S);
694
+ }
695
+ })(), () => {
696
+ c = !0;
697
+ };
698
+ }, [I, Y, o]), me(() => {
699
+ if (I) return;
700
+ let c = !1;
431
701
  return (async () => {
432
- d(!0), x(null);
702
+ j(!0), k(null);
433
703
  try {
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 = {
704
+ let S = null;
705
+ const U = nt(he) || ce;
706
+ if (Y && o) {
707
+ const Q = await o.getObjectSchema(Y);
708
+ if (c) return;
709
+ S = Q;
710
+ } else if (U && Y)
711
+ S = { name: Y, fields: {} };
712
+ else throw Y ? new Error("DataSource required") : new Error("Object name required for data fetching");
713
+ if (c || G(S), o && Y) {
714
+ const y = {
444
715
  $select: (() => {
445
- if (W) return W;
446
- if (V && Array.isArray(V))
447
- return V.map((T) => typeof T == "string" ? T : T.field);
716
+ if (ce) return ce;
717
+ if (he && Array.isArray(he))
718
+ return he.map((w) => typeof w == "string" ? w : w.field);
448
719
  })(),
449
- $top: ie?.pageSize || r || 50
720
+ $top: lt?.pageSize || at || 50
450
721
  };
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 || []);
722
+ $e && Array.isArray($e) ? y.$filter = $e : e.defaultFilters && (y.$filter = e.defaultFilters), ke ? typeof ke == "string" ? y.$orderby = ke : Array.isArray(ke) && (y.$orderby = ke.map((w) => `${w.field} ${w.order}`).join(", ")) : e.defaultSort && (y.$orderby = `${e.defaultSort.field} ${e.defaultSort.order}`);
723
+ const g = hs(S?.fields, he ?? ce);
724
+ g.length > 0 && (y.$expand = g);
725
+ const N = await o.find(Y, y);
726
+ if (c) return;
727
+ p(N.data || []);
455
728
  }
456
- } catch (M) {
457
- b || x(M);
729
+ } catch (S) {
730
+ c || k(S);
458
731
  } finally {
459
- b || d(!1);
732
+ c || j(!1);
460
733
  }
461
734
  })(), () => {
462
- b = !0;
735
+ c = !0;
463
736
  };
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,
737
+ }, [Y, ce, he, $e, ke, lt, at, o, I, X, re]);
738
+ const te = xs({
739
+ navigation: e.navigation,
740
+ objectName: e.objectName,
741
+ onNavigate: e.onNavigate,
469
742
  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(
743
+ }), { execute: Me } = bs(), Gt = hn(e.rowColor), Ht = M((c) => {
744
+ const O = e.conditionalFormatting;
745
+ if (!(!O || O.length === 0))
746
+ for (const S of O) {
747
+ let U = !1;
748
+ const Q = ("condition" in S ? S.condition : void 0) || ("expression" in S ? S.expression : void 0) || void 0;
749
+ if (Q)
750
+ U = ms(Q, c);
751
+ else if ("field" in S && "operator" in S && S.field && S.operator) {
752
+ const y = S, g = c[y.field];
753
+ switch (y.operator) {
754
+ case "equals":
755
+ U = g === y.value;
756
+ break;
757
+ case "not_equals":
758
+ U = g !== y.value;
759
+ break;
760
+ case "contains":
761
+ U = typeof g == "string" && typeof y.value == "string" && g.includes(y.value);
762
+ break;
763
+ case "greater_than":
764
+ U = typeof g == "number" && typeof y.value == "number" && g > y.value;
765
+ break;
766
+ case "less_than":
767
+ U = typeof g == "number" && typeof y.value == "number" && g < y.value;
768
+ break;
769
+ case "in":
770
+ U = Array.isArray(y.value) && y.value.includes(g);
771
+ break;
772
+ }
773
+ }
774
+ if (U) {
775
+ const y = {};
776
+ return "style" in S && S.style && Object.assign(y, S.style), "backgroundColor" in S && S.backgroundColor && (y.backgroundColor = S.backgroundColor), "textColor" in S && S.textColor && (y.color = S.textColor), "borderColor" in S && S.borderColor && (y.borderColor = S.borderColor), y;
777
+ }
778
+ }
779
+ }, [e.conditionalFormatting]), { groups: Yt, isGrouped: ct, toggleGroup: Jt } = yn(e.grouping, m), Xt = Ie.useMemo(() => {
780
+ const c = nt(e.columns);
781
+ if (c && c.length > 0 && typeof c[0] == "object")
782
+ return c;
783
+ }, [e.columns]), { summaries: dt, hasSummary: Qt } = Cn(Xt, m), Ve = M(() => {
784
+ const c = (y) => y ? {
785
+ text: /* @__PURE__ */ s.jsx(tt, { className: "h-3.5 w-3.5" }),
786
+ number: /* @__PURE__ */ s.jsx(st, { className: "h-3.5 w-3.5" }),
787
+ currency: /* @__PURE__ */ s.jsx(st, { className: "h-3.5 w-3.5" }),
788
+ percent: /* @__PURE__ */ s.jsx(st, { className: "h-3.5 w-3.5" }),
789
+ date: /* @__PURE__ */ s.jsx(Qs, { className: "h-3.5 w-3.5" }),
790
+ datetime: /* @__PURE__ */ s.jsx(Xs, { className: "h-3.5 w-3.5" }),
791
+ boolean: /* @__PURE__ */ s.jsx(Js, { className: "h-3.5 w-3.5" }),
792
+ user: /* @__PURE__ */ s.jsx(Ys, { className: "h-3.5 w-3.5" }),
793
+ select: /* @__PURE__ */ s.jsx(Hs, { className: "h-3.5 w-3.5" })
794
+ }[y] || /* @__PURE__ */ s.jsx(tt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ s.jsx(tt, { className: "h-3.5 w-3.5" }), O = (y) => {
795
+ if (y.type) return y.type;
796
+ const g = y.field.toLowerCase();
797
+ if (["completed", "is_completed", "done", "active", "enabled", "archived"].some((E) => g === E || g === `is_${E}`))
798
+ return "boolean";
799
+ if (["created_time", "modified_time", "updated_time", "created_at", "updated_at", "modified_at", "last_login", "logged_at"].some((E) => g === E || g.endsWith(`_${E}`)))
800
+ return "datetime";
801
+ if (["date", "due", "created", "updated", "deadline", "start", "end", "expires"].some((E) => g.includes(E))) {
802
+ if (m.length > 0) {
803
+ const E = m.find((P) => P[y.field] != null)?.[y.field];
804
+ if (typeof E == "string" && !isNaN(Date.parse(E)))
805
+ return "date";
806
+ }
807
+ return "date";
808
+ }
809
+ if (["probability", "percent", "percentage", "completion", "progress", "rate"].some((E) => g.includes(E)) && m.length > 0 && typeof m.find((P) => P[y.field] != null)?.[y.field] == "number")
810
+ return "percent";
811
+ if (["status", "priority", "category", "stage", "type", "severity", "level"].some((E) => g.includes(E)) && m.length > 0) {
812
+ const E = new Set(m.map((P) => P[y.field]).filter(Boolean));
813
+ if (E.size > 0 && E.size <= 10)
814
+ return "select";
815
+ }
816
+ if (["assignee", "owner", "author", "reporter", "creator", "user"].some((E) => g.includes(E)))
817
+ return "user";
818
+ if (["amount", "price", "total", "revenue", "cost", "budget", "salary"].some((E) => g.includes(E)) && m.length > 0 && typeof m.find((P) => P[y.field] != null)?.[y.field] == "number")
819
+ return "currency";
820
+ if (m.length > 0) {
821
+ const E = m.find((P) => P[y.field] != null)?.[y.field];
822
+ if (typeof E == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(E))
823
+ return "datetime";
824
+ }
825
+ return null;
826
+ }, S = nt(he);
827
+ if (S) {
828
+ if (S.length > 0 && typeof S[0] == "object" && S[0] !== null) {
829
+ const y = S[0];
830
+ if ("accessorKey" in y)
831
+ return S.map((g) => {
832
+ if (g.cell) return g;
833
+ const N = { field: g.accessorKey, label: g.header, type: g.type }, w = O(N);
834
+ if (!w) return g;
835
+ const A = Ee(w), C = { name: g.accessorKey, type: w };
836
+ if (w === "select") {
837
+ const b = Array.from(new Set(m.map((R) => R[g.accessorKey]).filter(Boolean)));
838
+ C.options = b.map((R) => ({ value: R, label: Ue(String(R)) }));
839
+ }
840
+ return {
841
+ ...g,
842
+ headerIcon: c(w),
843
+ cell: (b) => /* @__PURE__ */ s.jsx(A, { value: b, field: C })
844
+ };
845
+ });
846
+ if ("field" in y)
847
+ return S.filter((g) => g?.field && typeof g.field == "string" && !g.hidden).map((g, N) => {
848
+ const w = g.label || g.field.charAt(0).toUpperCase() + g.field.slice(1).replace(/_/g, " "), A = e.objectName ? D(e.objectName, g.field, w) : w;
849
+ let C;
850
+ const b = z?.fields?.[g.field], R = g.type || b?.type || O({ field: g.field }) || null, V = R ? Ee(R) : null, E = { name: g.field, type: R || "text" };
851
+ if (b && (b.label && (E.label = b.label), b.currency && (E.currency = b.currency), b.precision !== void 0 && (E.precision = b.precision), b.format && (E.format = b.format), b.options && (E.options = b.options)), R === "select" && !E.options) {
852
+ const q = Array.from(new Set(m.map((oe) => oe[g.field]).filter(Boolean)));
853
+ E.options = q.map((oe) => ({ value: oe, label: Ue(String(oe)) }));
854
+ }
855
+ g.options && (E.options = g.options);
856
+ const P = N === 0 && !g.link && !g.action, Z = g.link || P;
857
+ g.link && g.action || P && g.action ? C = (q, oe) => {
858
+ const Se = V ? /* @__PURE__ */ s.jsx(V, { value: q, field: E }) : q != null && q !== "" ? String(q) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-xs italic", children: "—" });
859
+ return /* @__PURE__ */ s.jsx(
485
860
  "button",
486
861
  {
487
862
  type: "button",
488
863
  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);
864
+ "data-testid": P ? "primary-field-link" : "link-cell",
865
+ onClick: (_e) => {
866
+ _e.stopPropagation(), te.handleClick(oe);
491
867
  },
492
- children: ae
868
+ children: Se
493
869
  }
494
870
  );
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(
871
+ } : Z ? C = (q, oe) => {
872
+ const Se = V ? /* @__PURE__ */ s.jsx(V, { value: q, field: E }) : q != null && q !== "" ? String(q) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-xs italic", children: "" });
873
+ return /* @__PURE__ */ s.jsx(
498
874
  "button",
499
875
  {
500
876
  type: "button",
501
877
  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);
878
+ "data-testid": P ? "primary-field-link" : "link-cell",
879
+ onClick: (_e) => {
880
+ _e.stopPropagation(), te.handleClick(oe);
504
881
  },
505
- children: ae
882
+ children: Se
506
883
  }
507
884
  );
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;
885
+ } : g.action ? C = (q, oe) => /* @__PURE__ */ s.jsx(
886
+ le,
887
+ {
888
+ variant: "outline",
889
+ size: "sm",
890
+ className: "h-7 text-xs",
891
+ "data-testid": "action-cell",
892
+ onClick: (Se) => {
893
+ Se.stopPropagation(), Me({
894
+ type: g.action,
895
+ params: { record: oe, field: g.field, value: q }
896
+ });
897
+ },
898
+ children: ot(g.action)
899
+ }
900
+ ) : V ? C = (q) => /* @__PURE__ */ s.jsx(V, { value: q, field: E }) : C = (q) => q != null && q !== "" ? /* @__PURE__ */ s.jsx("span", { children: String(q) }) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-xs italic", children: "—" });
901
+ const de = g.prefix;
902
+ if (de?.field) {
903
+ const q = C, oe = de.type === "badge" ? Ee("select") : null;
904
+ C = (Se, _e) => {
905
+ const Be = _e[de.field], us = Be != null && Be !== "" ? oe ? /* @__PURE__ */ s.jsx(oe, { value: Be, field: { name: de.field, type: "select" } }) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground text-xs mr-1.5", children: String(Be) }) : null;
906
+ return /* @__PURE__ */ s.jsxs("span", { className: "flex items-center gap-1.5", children: [
907
+ us,
908
+ q(Se, _e)
909
+ ] });
910
+ };
911
+ }
912
+ const se = ["number", "currency", "percent"], ne = R || g.type, ye = g.align || (ne && se.includes(ne) ? "right" : void 0), K = N === 0 || g.essential === !0;
526
913
  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 }
914
+ header: A,
915
+ accessorKey: g.field,
916
+ headerIcon: c(R),
917
+ ...!K && { className: "hidden sm:table-cell" },
918
+ ...g.width && { width: g.width },
919
+ ...ye && { align: ye },
920
+ sortable: g.sortable !== !1,
921
+ ...g.resizable !== void 0 && { resizable: g.resizable },
922
+ ...g.wrap !== void 0 && { wrap: g.wrap },
923
+ ...C && { cell: C },
924
+ ...g.pinned && { pinned: g.pinned }
536
925
  };
537
926
  });
538
927
  }
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
542
- }));
928
+ return S.filter((y) => typeof y == "string" && y.trim().length > 0).map((y, g) => {
929
+ const N = z?.fields?.[y], A = N?.label || y.charAt(0).toUpperCase() + y.slice(1).replace(/_/g, " "), C = e.objectName ? D(e.objectName, y, A) : A, b = N?.type || O({ field: y }) || null, R = b ? Ee(b) : null, V = { name: y, type: b || "text" };
930
+ if (N && (N.label && (V.label = N.label), N.currency && (V.currency = N.currency), N.precision !== void 0 && (V.precision = N.precision), N.format && (V.format = N.format), N.options && (V.options = N.options)), b === "select" && !V.options) {
931
+ const se = Array.from(new Set(m.map((ne) => ne[y]).filter(Boolean)));
932
+ V.options = se.map((ne) => ({ value: ne, label: Ue(String(ne)) }));
933
+ }
934
+ const P = b && ["number", "currency", "percent"].includes(b) ? "right" : void 0, Z = g === 0;
935
+ let de;
936
+ return Z && R ? de = (se, ne) => {
937
+ const ye = /* @__PURE__ */ s.jsx(R, { value: se, field: V });
938
+ return /* @__PURE__ */ s.jsx(
939
+ "button",
940
+ {
941
+ type: "button",
942
+ className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
943
+ "data-testid": "primary-field-link",
944
+ onClick: (K) => {
945
+ K.stopPropagation(), te.handleClick(ne);
946
+ },
947
+ children: ye
948
+ }
949
+ );
950
+ } : Z ? de = (se, ne) => /* @__PURE__ */ s.jsx(
951
+ "button",
952
+ {
953
+ type: "button",
954
+ className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
955
+ "data-testid": "primary-field-link",
956
+ onClick: (ye) => {
957
+ ye.stopPropagation(), te.handleClick(ne);
958
+ },
959
+ children: se != null && se !== "" ? String(se) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-xs italic", children: "—" })
960
+ }
961
+ ) : R && (de = (se) => /* @__PURE__ */ s.jsx(R, { value: se, field: V })), {
962
+ header: C,
963
+ accessorKey: y,
964
+ ...b && { headerIcon: c(b) },
965
+ ...P && { align: P },
966
+ ...de && { cell: de },
967
+ sortable: N?.sortable !== !1
968
+ };
969
+ });
543
970
  }
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
550
- }));
971
+ if (I) {
972
+ const y = X?.provider === "value" ? X.items : [];
973
+ if (y.length > 0)
974
+ return (ce || Object.keys(y[0])).map((N) => {
975
+ const w = z?.fields?.[N], A = w?.type || O({ field: N }) || null, C = A ? Ee(A) : null, b = w?.label || N.charAt(0).toUpperCase() + N.slice(1).replace(/_/g, " "), R = { name: N, type: A || "text" };
976
+ if (w && (w.label && (R.label = w.label), w.currency && (R.currency = w.currency), w.precision !== void 0 && (R.precision = w.precision), w.format && (R.format = w.format), w.options && (R.options = w.options)), A === "select" && !R.options) {
977
+ const P = Array.from(new Set(m.map((Z) => Z[N]).filter(Boolean)));
978
+ R.options = P.map((Z) => ({ value: Z, label: Ue(String(Z)) }));
979
+ }
980
+ const E = A && ["number", "currency", "percent"].includes(A) ? "right" : void 0;
981
+ return {
982
+ header: b,
983
+ accessorKey: N,
984
+ ...A && { headerIcon: c(A) },
985
+ ...E && { align: E },
986
+ ...C && { cell: (P) => /* @__PURE__ */ s.jsx(C, { value: P, field: R }) },
987
+ sortable: w?.sortable !== !1
988
+ };
989
+ });
551
990
  }
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
991
+ if (!z) return [];
992
+ const U = [];
993
+ return (ce || Object.keys(z.fields || {})).forEach((y) => {
994
+ const g = z.fields?.[y];
995
+ if (!g || g.permissions && g.permissions.read === !1) return;
996
+ const N = Ee(g.type), w = ["number", "currency", "percent"];
997
+ U.push({
998
+ header: e.objectName ? D(e.objectName, y, g.label || y) : g.label || y,
999
+ accessorKey: y,
1000
+ ...w.includes(g.type) && { align: "right" },
1001
+ cell: (A) => /* @__PURE__ */ s.jsx(N, { value: A, field: g }),
1002
+ sortable: g.sortable !== !1
564
1003
  });
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 })
1004
+ }), U;
1005
+ }, [z, ce, he, X, I, te.handleClick, Me, m, D, e.objectName]), Zt = M((c) => {
1006
+ const O = e.exportOptions, S = O?.maxRecords || 0, U = O?.includeHeaders !== !1, Q = O?.fileNamePrefix || e.objectName || "export", y = S > 0 ? m.slice(0, S) : m, g = (w, A) => {
1007
+ const C = URL.createObjectURL(w), b = document.createElement("a");
1008
+ b.href = C, b.download = A, b.click(), URL.revokeObjectURL(C);
1009
+ }, N = (w) => {
1010
+ const A = w == null ? "" : String(w);
1011
+ return A.includes(",") || A.includes('"') || A.includes(`
1012
+ `) || A.includes("\r") ? `"${A.replace(/"/g, '""')}"` : A;
1013
+ };
1014
+ if (c === "csv") {
1015
+ const w = Ve().filter((R) => R.accessorKey !== "_actions"), A = w.map((R) => R.accessorKey), C = w.map((R) => R.header), b = [];
1016
+ U && b.push(C.join(",")), y.forEach((R) => {
1017
+ b.push(A.map((V) => N(R[V])).join(","));
1018
+ }), g(new Blob([b.join(`
1019
+ `)], { type: "text/csv;charset=utf-8;" }), `${Q}.csv`);
1020
+ } else c === "json" && g(new Blob([JSON.stringify(y, null, 2)], { type: "application/json" }), `${Q}.json`);
1021
+ Re(!1);
1022
+ }, [m, e.exportOptions, e.objectName, Ve]);
1023
+ if (v)
1024
+ return /* @__PURE__ */ s.jsxs("div", { className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md", children: [
1025
+ /* @__PURE__ */ s.jsx("h3", { className: "text-red-800 font-semibold", children: T("grid.errorLoading") }),
1026
+ /* @__PURE__ */ s.jsx("p", { className: "text-red-600 text-sm mt-1", children: v.message })
571
1027
  ] });
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..." })
1028
+ if (x && m.length === 0)
1029
+ return W ? /* @__PURE__ */ s.jsx("div", { className: "space-y-2 p-2", children: [1, 2, 3].map((c) => /* @__PURE__ */ s.jsxs("div", { className: "border rounded-lg p-3 bg-card animate-pulse", children: [
1030
+ /* @__PURE__ */ s.jsx("div", { className: "h-5 bg-muted rounded w-3/4 mb-3" }),
1031
+ /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between mb-2", children: [
1032
+ /* @__PURE__ */ s.jsx("div", { className: "h-4 bg-muted rounded w-1/4" }),
1033
+ /* @__PURE__ */ s.jsx("div", { className: "h-5 bg-muted rounded-full w-20" })
1034
+ ] }),
1035
+ /* @__PURE__ */ s.jsx("div", { className: "h-3 bg-muted rounded w-1/3" })
1036
+ ] }, c)) }) : /* @__PURE__ */ s.jsxs("div", { className: "p-4 sm:p-8 text-center", children: [
1037
+ /* @__PURE__ */ s.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-foreground" }),
1038
+ /* @__PURE__ */ s.jsx("p", { className: "mt-2 text-sm text-muted-foreground", children: T("grid.loading") })
576
1039
  ] });
577
- const ne = G(), q = "operations" in t ? t.operations : void 0, ye = q && (q.update || q.delete), We = ye ? [
578
- ...ne,
1040
+ let De = [...Ve()];
1041
+ if (ie.widths && (De = De.map((c) => {
1042
+ const O = ie.widths?.[c.accessorKey];
1043
+ return O ? { ...c, size: O } : c;
1044
+ })), ie.order && ie.order.length > 0) {
1045
+ const c = new Map(ie.order.map((O, S) => [O, S]));
1046
+ De.sort((O, S) => {
1047
+ const U = c.get(O.accessorKey) ?? 1 / 0, Q = c.get(S.accessorKey) ?? 1 / 0;
1048
+ return U - Q;
1049
+ });
1050
+ }
1051
+ const Ce = "operations" in e ? e.operations : void 0, ut = Ce && (Ce.update || Ce.delete), es = e.rowActions && e.rowActions.length > 0, Ke = ut || es ? [
1052
+ ...De,
579
1053
  {
580
- header: "Actions",
1054
+ header: T("grid.actions"),
581
1055
  accessorKey: "_actions",
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" })
586
- ] }) }),
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" }),
590
- "Edit"
591
- ] }),
592
- q?.delete && n && /* @__PURE__ */ a.jsxs(Ne, { onClick: () => n(E), children: [
593
- /* @__PURE__ */ a.jsx(it, { className: "mr-2 h-4 w-4" }),
594
- "Delete"
595
- ] })
596
- ] })
597
- ] }),
1056
+ cell: (c, O) => /* @__PURE__ */ s.jsx(
1057
+ Sn,
1058
+ {
1059
+ row: O,
1060
+ rowActions: e.rowActions,
1061
+ canEdit: !!(Ce?.update && t),
1062
+ canDelete: !!(Ce?.delete && n),
1063
+ onEdit: t,
1064
+ onDelete: n,
1065
+ onAction: (S, U) => Me({ type: S, params: { record: U } })
1066
+ }
1067
+ ),
598
1068
  sortable: !1
599
1069
  }
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 = {
1070
+ ] : De, Je = Ke.filter((c) => c.pinned === "left"), ft = Ke.filter((c) => c.pinned === "right"), ts = Ke.filter((c) => !c.pinned), mt = Je.length > 0 || ft.length > 0, ht = "sticky right-0 z-10 bg-background border-l border-border", pt = mt ? [
1071
+ ...Je,
1072
+ ...ts,
1073
+ ...ft.map((c) => ({
1074
+ ...c,
1075
+ className: [c.className, ht].filter(Boolean).join(" "),
1076
+ cellClassName: [c.cellClassName, ht].filter(Boolean).join(" ")
1077
+ }))
1078
+ ] : Ke, ss = mt ? Je.length : e.frozenColumns ?? 1, We = e.batchActions ?? e.bulkActions, ns = We && We.length > 0;
1079
+ let qe = !1;
1080
+ e.selection?.type ? qe = e.selection.type === "none" ? !1 : e.selection.type : e.selectable !== void 0 ? qe = e.selectable : ns && (qe = "multiple");
1081
+ const rs = e.pagination !== void 0 ? !0 : e.showPagination !== void 0 ? e.showPagination : !0, is = e.pagination?.pageSize || e.pageSize || 10, os = e.searchableFields !== void 0 ? e.searchableFields.length > 0 : e.showSearch !== void 0 ? e.showSearch : !0, gt = {
604
1082
  type: "data-table",
605
- caption: t.label || t.title,
606
- columns: We,
607
- data: f,
608
- pagination: Ve,
609
- pageSize: Ye,
610
- searchable: Ge,
611
- selectable: be,
1083
+ caption: e.label || e.title,
1084
+ columns: pt,
1085
+ data: m,
1086
+ pagination: rs,
1087
+ pageSize: is,
1088
+ searchable: os,
1089
+ selectable: qe,
612
1090
  sortable: !0,
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,
623
- onCellChange: o,
1091
+ exportable: Ce?.export,
1092
+ rowActions: ut,
1093
+ resizableColumns: e.resizable ?? e.resizableColumns ?? !0,
1094
+ reorderableColumns: e.reorderableColumns ?? !1,
1095
+ editable: e.editable ?? !1,
1096
+ singleClickEdit: e.singleClickEdit ?? !0,
1097
+ className: e.className,
1098
+ cellClassName: ae === "compact" ? "px-3 py-1 text-[13px] leading-tight" : ae === "short" ? "px-3 py-1 text-[13px] leading-normal" : ae === "tall" ? "px-3 py-2.5 text-sm" : ae === "extra_tall" ? "px-3 py-3.5 text-sm leading-relaxed" : "px-3 py-1.5 text-[13px] leading-normal",
1099
+ showRowNumbers: !0,
1100
+ showAddRow: !!Ce?.create,
1101
+ onAddRecord: f,
1102
+ rowClassName: e.rowColor ? (c, O) => Gt(c) : void 0,
1103
+ rowStyle: e.conditionalFormatting?.length ? (c, O) => Ht(c) : void 0,
1104
+ frozenColumns: ss,
1105
+ onSelectionChange: (c) => {
1106
+ J(c), r?.(c);
1107
+ },
1108
+ onRowClick: te.handleClick,
1109
+ onCellChange: a,
624
1110
  onRowSave: l,
625
- onBatchSave: g
626
- }, Ke = (b) => ({
627
- ...Ee,
1111
+ onBatchSave: h,
1112
+ onColumnResize: (c, O) => {
1113
+ ee({
1114
+ ...ie,
1115
+ widths: { ...ie.widths, [c]: O }
1116
+ });
1117
+ },
1118
+ onColumnReorder: (c) => {
1119
+ ee({
1120
+ ...ie,
1121
+ order: c
1122
+ });
1123
+ }
1124
+ }, ls = (c) => ({
1125
+ ...gt,
628
1126
  caption: void 0,
629
- data: b,
1127
+ data: c,
630
1128
  pagination: !1,
631
1129
  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)) }) })
1130
+ }), Xe = e.label ? `${e.label} Detail` : e.objectName ? `${e.objectName.charAt(0).toUpperCase() + e.objectName.slice(1)} Detail` : "Record Detail";
1131
+ if (W && m.length > 0 && !ct) {
1132
+ const c = Ve().filter((C) => C.accessorKey !== "_actions"), O = /* @__PURE__ */ new Map();
1133
+ c.forEach((C) => O.set(C.accessorKey, C));
1134
+ const S = c[0], U = ["amount", "price", "total", "revenue", "cost", "value", "budget", "salary"], Q = ["stage", "status", "priority", "category", "severity", "level"], y = ["date", "due", "created", "updated", "deadline", "start", "end", "expires"], g = ["probability", "percent", "rate", "ratio", "confidence", "score"], N = (C) => {
1135
+ const b = (C || "").toLowerCase();
1136
+ return b.includes("won") || b.includes("completed") || b.includes("done") || b.includes("active") ? "bg-green-100 text-green-800 border-green-300" : b.includes("lost") || b.includes("cancelled") || b.includes("rejected") || b.includes("closed lost") ? "bg-red-100 text-red-800 border-red-300" : b.includes("negotiation") || b.includes("review") || b.includes("in progress") ? "bg-yellow-100 text-yellow-800 border-yellow-300" : b.includes("proposal") || b.includes("pending") ? "bg-blue-100 text-blue-800 border-blue-300" : b.includes("qualification") || b.includes("qualified") ? "bg-indigo-100 text-indigo-800 border-indigo-300" : b.includes("prospecting") || b.includes("new") || b.includes("open") ? "bg-purple-100 text-purple-800 border-purple-300" : "bg-muted text-muted-foreground border-border";
1137
+ }, w = (C) => {
1138
+ const b = (C || "").toLowerCase();
1139
+ return b.includes("won") || b.includes("completed") || b.includes("done") || b.includes("active") ? "border-l-green-500" : b.includes("lost") || b.includes("cancelled") || b.includes("rejected") ? "border-l-red-500" : b.includes("negotiation") || b.includes("review") || b.includes("in progress") ? "border-l-yellow-500" : b.includes("proposal") || b.includes("pending") ? "border-l-blue-500" : b.includes("qualification") || b.includes("qualified") ? "border-l-indigo-500" : b.includes("prospecting") || b.includes("new") || b.includes("open") ? "border-l-purple-500" : "border-l-gray-300";
1140
+ }, A = (C) => {
1141
+ const b = C.toLowerCase();
1142
+ return U.some((R) => b.includes(R)) ? "amount" : Q.some((R) => b.includes(R)) ? "stage" : y.some((R) => b.includes(R)) ? "date" : g.some((R) => b.includes(R)) ? "percent" : "other";
1143
+ };
1144
+ return /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
1145
+ /* @__PURE__ */ s.jsx("div", { className: "space-y-2 p-2", children: m.map((C, b) => {
1146
+ const R = c.slice(1, 5), V = R.find((K) => A(K.accessorKey) === "amount"), E = R.find((K) => A(K.accessorKey) === "stage"), P = R.filter((K) => A(K.accessorKey) === "date"), Z = R.filter((K) => A(K.accessorKey) === "percent"), de = R.filter(
1147
+ (K) => K !== V && K !== E && !P.includes(K) && !Z.includes(K)
1148
+ ), se = E ? String(C[E.accessorKey] ?? "") : "", ne = se ? w(se) : "", ye = [
1149
+ "border rounded-lg p-2.5 bg-card hover:bg-accent/50 cursor-pointer transition-colors touch-manipulation",
1150
+ ne ? `border-l-[3px] ${ne}` : ""
1151
+ ].filter(Boolean).join(" ");
1152
+ return /* @__PURE__ */ s.jsxs(
1153
+ "div",
1154
+ {
1155
+ className: ye,
1156
+ onClick: () => te.handleClick(C),
1157
+ children: [
1158
+ S && /* @__PURE__ */ s.jsx("div", { className: "font-semibold text-sm truncate mb-1", children: C[S.accessorKey] ?? "—" }),
1159
+ (V || E) && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between gap-2 mb-1", children: [
1160
+ V && /* @__PURE__ */ s.jsx("span", { className: "text-sm tabular-nums font-medium", children: typeof C[V.accessorKey] == "number" ? vs(C[V.accessorKey]) : C[V.accessorKey] ?? "—" }),
1161
+ E && C[E.accessorKey] && /* @__PURE__ */ s.jsx(
1162
+ Te,
1163
+ {
1164
+ variant: "outline",
1165
+ className: `text-xs shrink-0 max-w-[140px] truncate ${N(String(C[E.accessorKey]))}`,
1166
+ children: C[E.accessorKey]
1167
+ }
1168
+ )
1169
+ ] }),
1170
+ (P.length > 0 || Z.length > 0) && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-between py-0.5 text-xs text-muted-foreground", children: [
1171
+ P[0] && /* @__PURE__ */ s.jsx("span", { className: "tabular-nums", children: C[P[0].accessorKey] ? Qe(C[P[0].accessorKey], "short") : "—" }),
1172
+ Z[0] && C[Z[0].accessorKey] != null && /* @__PURE__ */ s.jsx("span", { className: "tabular-nums", children: js(Number(C[Z[0].accessorKey])) })
1173
+ ] }),
1174
+ P.slice(1).map((K) => /* @__PURE__ */ s.jsxs("div", { className: "flex justify-between items-center py-0.5", children: [
1175
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground", children: K.header }),
1176
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground tabular-nums", children: C[K.accessorKey] ? Qe(C[K.accessorKey], "short") : "—" })
1177
+ ] }, K.accessorKey)),
1178
+ de.map((K) => {
1179
+ const q = C[K.accessorKey];
1180
+ return q == null || q === "" ? null : /* @__PURE__ */ s.jsxs("div", { className: "flex justify-between items-center py-0.5", children: [
1181
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground", children: K.header }),
1182
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs font-medium truncate ml-2 text-right", children: K.cell ? K.cell(q, C) : String(q) })
1183
+ ] }, K.accessorKey);
1184
+ })
1185
+ ]
1186
+ },
1187
+ C.id || C._id || b
1188
+ );
1189
+ }) }),
1190
+ te.isOverlay && /* @__PURE__ */ s.jsx(et, { ...te, title: Xe, children: (C) => /* @__PURE__ */ s.jsx("div", { className: "space-y-3", children: Object.entries(C).map(([b, R]) => /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col", children: [
1191
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: b.replace(/_/g, " ") }),
1192
+ /* @__PURE__ */ s.jsx("span", { className: "text-sm", children: String(R ?? "—") })
1193
+ ] }, b)) }) })
652
1194
  ] });
653
1195
  }
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",
1196
+ const as = () => {
1197
+ pe((c) => c === "compact" ? "short" : c === "short" ? "medium" : c === "medium" ? "tall" : c === "tall" ? "extra_tall" : "compact");
1198
+ }, cs = { compact: Gs, short: Us, medium: Bs, tall: Nt, extra_tall: Nt }[ae], xt = e.rowHeight !== void 0, bt = e.exportOptions || xt ? /* @__PURE__ */ s.jsxs("div", { className: "flex items-center justify-end gap-1 px-2 py-1", children: [
1199
+ xt && /* @__PURE__ */ s.jsxs(
1200
+ le,
657
1201
  {
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),
1202
+ variant: "ghost",
1203
+ size: "sm",
1204
+ className: "h-7 px-2 text-muted-foreground hover:text-primary text-xs",
1205
+ onClick: as,
1206
+ title: `Row height: ${ae}`,
661
1207
  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 })
1208
+ /* @__PURE__ */ s.jsx(cs, { className: "h-3.5 w-3.5 mr-1.5" }),
1209
+ /* @__PURE__ */ s.jsx("span", { className: "hidden sm:inline capitalize", children: ae })
665
1210
  ]
666
1211
  }
667
1212
  ),
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,
1213
+ e.exportOptions && /* @__PURE__ */ s.jsxs(Es, { open: je, onOpenChange: Re, children: [
1214
+ /* @__PURE__ */ s.jsx(Rs, { asChild: !0, children: /* @__PURE__ */ s.jsxs(
1215
+ le,
1216
+ {
1217
+ variant: "ghost",
1218
+ size: "sm",
1219
+ className: "h-7 px-2 text-muted-foreground hover:text-primary text-xs",
1220
+ children: [
1221
+ /* @__PURE__ */ s.jsx(Ct, { className: "h-3.5 w-3.5 mr-1.5" }),
1222
+ /* @__PURE__ */ s.jsx("span", { className: "hidden sm:inline", children: T("grid.export") })
1223
+ ]
1224
+ }
1225
+ ) }),
1226
+ /* @__PURE__ */ s.jsx(ks, { align: "end", className: "w-48 p-2", children: /* @__PURE__ */ s.jsx("div", { className: "space-y-1", children: (e.exportOptions.formats || ["csv", "json"]).map((c) => /* @__PURE__ */ s.jsxs(
1227
+ le,
1228
+ {
1229
+ variant: "ghost",
1230
+ size: "sm",
1231
+ className: "w-full justify-start h-8 text-xs",
1232
+ onClick: () => Zt(c),
1233
+ children: [
1234
+ /* @__PURE__ */ s.jsx(Ct, { className: "h-3.5 w-3.5 mr-2" }),
1235
+ T("grid.exportAs", { format: c.toUpperCase() })
1236
+ ]
1237
+ },
1238
+ c
1239
+ )) }) })
1240
+ ] })
1241
+ ] }) : null, yt = (c) => {
1242
+ const O = ["_id", "id", "created_at", "updated_at", "created_by", "updated_by"], S = Object.entries(c), U = S.filter(([N]) => !O.includes(N)), Q = S.filter(([N]) => O.includes(N) && N !== "_id" && N !== "id"), y = (N) => N.charAt(0).toUpperCase() + N.slice(1).replace(/_/g, " "), g = (N, w) => {
1243
+ if (w == null || w === "")
1244
+ return /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50 text-sm italic", children: "Empty" });
1245
+ const A = z?.fields?.[N];
1246
+ if (A?.type) {
1247
+ const b = Ee(A.type);
1248
+ if (b)
1249
+ return /* @__PURE__ */ s.jsx(b, { value: w, field: A });
1250
+ }
1251
+ return typeof w == "boolean" ? /* @__PURE__ */ s.jsx(Te, { variant: w ? "default" : "outline", children: w ? "Yes" : "No" }) : typeof w == "string" && !isNaN(Date.parse(w)) && (N.includes("date") || N.includes("_at") || N.includes("time")) ? /* @__PURE__ */ s.jsx("span", { className: "text-sm tabular-nums", children: Qe(w) }) : typeof w == "number" && ["amount", "price", "total", "revenue", "cost", "value", "budget", "salary"].some((b) => N.toLowerCase().includes(b)) ? /* @__PURE__ */ s.jsx("span", { className: "text-sm tabular-nums font-medium", children: ws(w) }) : /* @__PURE__ */ s.jsx("span", { className: "text-sm break-words", children: String(w) });
1252
+ };
1253
+ return /* @__PURE__ */ s.jsxs("div", { className: "space-y-4", "data-testid": "record-detail-panel", children: [
1254
+ /* @__PURE__ */ s.jsx("div", { className: "rounded-lg border bg-card", children: /* @__PURE__ */ s.jsx("div", { className: "divide-y", children: U.map(([N, w]) => /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3", children: [
1255
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0", children: y(N) }),
1256
+ /* @__PURE__ */ s.jsx("div", { className: "flex-1 min-w-0", children: g(N, w) })
1257
+ ] }, N)) }) }),
1258
+ Q.length > 0 && /* @__PURE__ */ s.jsxs("div", { className: "rounded-lg border bg-muted/30", children: [
1259
+ /* @__PURE__ */ s.jsx("div", { className: "px-4 py-2 border-b", children: /* @__PURE__ */ s.jsx("span", { className: "text-xs font-medium text-muted-foreground uppercase tracking-wide", children: "System" }) }),
1260
+ /* @__PURE__ */ s.jsx("div", { className: "divide-y divide-border/50", children: Q.map(([N, w]) => /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-4 px-4 py-2", children: [
1261
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground w-1/3 text-right shrink-0", children: y(N) }),
1262
+ /* @__PURE__ */ s.jsx("span", { className: "text-xs text-muted-foreground flex-1 min-w-0 break-words", children: String(w ?? "") })
1263
+ ] }, N)) })
1264
+ ] })
1265
+ ] });
1266
+ }, ds = Qt ? /* @__PURE__ */ s.jsx("div", { className: "border-t bg-muted/30 px-2 py-1.5", "data-testid": "column-summary-footer", children: /* @__PURE__ */ s.jsx("div", { className: "flex gap-4 text-xs text-muted-foreground font-medium", children: pt.filter((c) => dt.has(c.accessorKey)).map((c) => {
1267
+ const O = dt.get(c.accessorKey);
1268
+ return /* @__PURE__ */ s.jsxs("span", { "data-testid": `summary-${c.accessorKey}`, children: [
1269
+ c.header,
1270
+ ": ",
1271
+ O.label
1272
+ ] }, c.accessorKey);
1273
+ }) }) }) : null, vt = ct ? /* @__PURE__ */ s.jsx("div", { className: "space-y-2", children: Yt.map((c) => /* @__PURE__ */ s.jsx(
1274
+ vn,
1275
+ {
1276
+ groupKey: c.key,
1277
+ label: c.label,
1278
+ count: c.rows.length,
1279
+ collapsed: c.collapsed,
1280
+ aggregations: c.aggregations,
1281
+ onToggle: Jt,
1282
+ children: /* @__PURE__ */ s.jsx(jt, { schema: ls(c.rows) })
1283
+ },
1284
+ c.key
1285
+ )) }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
1286
+ /* @__PURE__ */ s.jsx(jt, { schema: gt }),
1287
+ ds
1288
+ ] });
1289
+ return te.isOverlay && te.mode === "split" ? /* @__PURE__ */ s.jsx(
1290
+ et,
672
1291
  {
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)) })
1292
+ ...te,
1293
+ title: Xe,
1294
+ mainContent: /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
1295
+ bt,
1296
+ vt,
1297
+ /* @__PURE__ */ s.jsx(
1298
+ _t,
1299
+ {
1300
+ selectedRows: L,
1301
+ actions: We ?? [],
1302
+ onAction: (c, O) => Me({ type: c, params: { records: O } }),
1303
+ onClearSelection: () => J([])
1304
+ }
1305
+ )
1306
+ ] }),
1307
+ children: (c) => yt(c)
680
1308
  }
681
- ) : /* @__PURE__ */ a.jsxs("div", { ref: L, className: "relative h-full", children: [
682
- J > 0 && /* @__PURE__ */ a.jsx(
1309
+ ) : /* @__PURE__ */ s.jsxs("div", { ref: ge, className: "relative h-full", children: [
1310
+ _ > 0 && /* @__PURE__ */ s.jsx(
683
1311
  "div",
684
1312
  {
685
1313
  className: "flex items-center justify-center text-xs text-muted-foreground",
686
- style: { height: J },
687
- children: ge ? "Refreshing…" : "Pull to refresh"
1314
+ style: { height: _ },
1315
+ children: T(u ? "grid.refreshing" : "grid.pullToRefresh")
688
1316
  }
689
1317
  ),
690
- we,
691
- h.isOverlay && /* @__PURE__ */ a.jsx(
692
- ve,
1318
+ bt,
1319
+ vt,
1320
+ /* @__PURE__ */ s.jsx(
1321
+ _t,
693
1322
  {
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)) })
1323
+ selectedRows: L,
1324
+ actions: We ?? [],
1325
+ onAction: (c, O) => Me({ type: c, params: { records: O } }),
1326
+ onClearSelection: () => J([])
1327
+ }
1328
+ ),
1329
+ te.isOverlay && /* @__PURE__ */ s.jsx(
1330
+ et,
1331
+ {
1332
+ ...te,
1333
+ title: Xe,
1334
+ children: (c) => yt(c)
700
1335
  }
701
1336
  )
702
1337
  ] });
703
1338
  };
704
- function se(t, c, e) {
705
- let n = e.initialDeps ?? [], s, i = !0;
706
- function 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;
1339
+ function Oe(e, o, t) {
1340
+ let n = t.initialDeps ?? [], r, i = !0;
1341
+ function a() {
1342
+ var l, h, f;
714
1343
  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 _;
1344
+ t.key && ((l = t.debug) != null && l.call(t)) && (d = Date.now());
1345
+ const m = e();
1346
+ if (!(m.length !== n.length || m.some((j, v) => n[v] !== j)))
1347
+ return r;
1348
+ n = m;
1349
+ let x;
1350
+ if (t.key && ((h = t.debug) != null && h.call(t)) && (x = Date.now()), r = o(...m), t.key && ((f = t.debug) != null && f.call(t))) {
1351
+ const j = Math.round((Date.now() - d) * 100) / 100, v = Math.round((Date.now() - x) * 100) / 100, k = v / 16, T = (D, z) => {
1352
+ for (D = String(D); D.length < z; )
1353
+ D = " " + D;
1354
+ return D;
720
1355
  };
721
1356
  console.info(
722
- `%c⏱ ${R(x, 5)} /${R(y, 5)} ms`,
1357
+ `%c⏱ ${T(v, 5)} /${T(j, 5)} ms`,
723
1358
  `
724
1359
  font-size: .6rem;
725
1360
  font-weight: bold;
726
1361
  color: hsl(${Math.max(
727
1362
  0,
728
- Math.min(120 - 120 * S, 120)
1363
+ Math.min(120 - 120 * k, 120)
729
1364
  )}deg 100% 31%);`,
730
- e?.key
1365
+ t?.key
731
1366
  );
732
1367
  }
733
- return e?.onChange && !(i && e.skipInitialOnChange) && e.onChange(s), i = !1, s;
1368
+ return t?.onChange && !(i && t.skipInitialOnChange) && t.onChange(r), i = !1, r;
734
1369
  }
735
- return o.updateDeps = (l) => {
1370
+ return a.updateDeps = (l) => {
736
1371
  n = l;
737
- }, o;
1372
+ }, a;
738
1373
  }
739
- function Ae(t, c) {
740
- if (t === void 0)
1374
+ function Tt(e, o) {
1375
+ if (e === void 0)
741
1376
  throw new Error("Unexpected undefined");
742
- return t;
1377
+ return e;
743
1378
  }
744
- const Ct = (t, c) => Math.abs(t - c) < 1.01, Ot = (t, c, e) => {
1379
+ const _n = (e, o) => Math.abs(e - o) < 1.01, On = (e, o, t) => {
745
1380
  let n;
746
- return function(...s) {
747
- t.clearTimeout(n), n = t.setTimeout(() => c.apply(this, s), e);
1381
+ return function(...r) {
1382
+ e.clearTimeout(n), n = e.setTimeout(() => o.apply(this, r), t);
748
1383
  };
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);
1384
+ }, At = (e) => {
1385
+ const { offsetWidth: o, offsetHeight: t } = e;
1386
+ return { width: o, height: t };
1387
+ }, Tn = (e) => e, An = (e) => {
1388
+ const o = Math.max(e.startIndex - e.overscan, 0), t = Math.min(e.endIndex + e.overscan, e.count - 1), n = [];
1389
+ for (let r = o; r <= t; r++)
1390
+ n.push(r);
756
1391
  return n;
757
- }, Rt = (t, c) => {
758
- const e = t.scrollElement;
759
- if (!e)
1392
+ }, Mn = (e, o) => {
1393
+ const t = e.scrollElement;
1394
+ if (!t)
760
1395
  return;
761
- const n = t.targetWindow;
1396
+ const n = e.targetWindow;
762
1397
  if (!n)
763
1398
  return;
764
- const s = (o) => {
765
- const { width: l, height: g } = o;
766
- c({ width: Math.round(l), height: Math.round(g) });
1399
+ const r = (a) => {
1400
+ const { width: l, height: h } = a;
1401
+ o({ width: Math.round(l), height: Math.round(h) });
767
1402
  };
768
- if (s(ze(e)), !n.ResizeObserver)
1403
+ if (r(At(t)), !n.ResizeObserver)
769
1404
  return () => {
770
1405
  };
771
- const i = new n.ResizeObserver((o) => {
1406
+ const i = new n.ResizeObserver((a) => {
772
1407
  const l = () => {
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 });
1408
+ const h = a[0];
1409
+ if (h?.borderBoxSize) {
1410
+ const f = h.borderBoxSize[0];
1411
+ if (f) {
1412
+ r({ width: f.inlineSize, height: f.blockSize });
778
1413
  return;
779
1414
  }
780
1415
  }
781
- s(ze(e));
1416
+ r(At(t));
782
1417
  };
783
- t.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
1418
+ e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
784
1419
  });
785
- return i.observe(e, { box: "border-box" }), () => {
786
- i.unobserve(e);
1420
+ return i.observe(t, { box: "border-box" }), () => {
1421
+ i.unobserve(t);
787
1422
  };
788
- }, Me = {
1423
+ }, Mt = {
789
1424
  passive: !0
790
- }, Ie = typeof window > "u" ? !0 : "onscrollend" in window, kt = (t, c) => {
791
- const e = t.scrollElement;
792
- if (!e)
1425
+ }, Dt = typeof window > "u" ? !0 : "onscrollend" in window, Dn = (e, o) => {
1426
+ const t = e.scrollElement;
1427
+ if (!t)
793
1428
  return;
794
- const n = t.targetWindow;
1429
+ const n = e.targetWindow;
795
1430
  if (!n)
796
1431
  return;
797
- let s = 0;
798
- const i = t.options.useScrollendEvent && Ie ? () => {
799
- } : Ot(
1432
+ let r = 0;
1433
+ const i = e.options.useScrollendEvent && Dt ? () => {
1434
+ } : On(
800
1435
  n,
801
1436
  () => {
802
- c(s, !1);
1437
+ o(r, !1);
803
1438
  },
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);
1439
+ e.options.isScrollingResetDelay
1440
+ ), a = (d) => () => {
1441
+ const { horizontal: m, isRtl: p } = e.options;
1442
+ r = m ? t.scrollLeft * (p && -1 || 1) : t.scrollTop, i(), o(r, d);
1443
+ }, l = a(!0), h = a(!1);
1444
+ t.addEventListener("scroll", l, Mt);
1445
+ const f = e.options.useScrollendEvent && Dt;
1446
+ return f && t.addEventListener("scrollend", h, Mt), () => {
1447
+ t.removeEventListener("scroll", l), f && t.removeEventListener("scrollend", h);
813
1448
  };
814
- }, Tt = (t, c, e) => {
815
- if (c?.borderBoxSize) {
816
- const n = c.borderBoxSize[0];
1449
+ }, Fn = (e, o, t) => {
1450
+ if (o?.borderBoxSize) {
1451
+ const n = o.borderBoxSize[0];
817
1452
  if (n)
818
1453
  return Math.round(
819
- n[e.options.horizontal ? "inlineSize" : "blockSize"]
1454
+ n[t.options.horizontal ? "inlineSize" : "blockSize"]
820
1455
  );
821
1456
  }
822
- return t[e.options.horizontal ? "offsetWidth" : "offsetHeight"];
823
- }, At = (t, {
824
- adjustments: c = 0,
825
- behavior: e
1457
+ return e[t.options.horizontal ? "offsetWidth" : "offsetHeight"];
1458
+ }, zn = (e, {
1459
+ adjustments: o = 0,
1460
+ behavior: t
826
1461
  }, 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,
831
- behavior: e
1462
+ var r, i;
1463
+ const a = e + o;
1464
+ (i = (r = n.scrollElement) == null ? void 0 : r.scrollTo) == null || i.call(r, {
1465
+ [n.options.horizontal ? "left" : "top"]: a,
1466
+ behavior: t
832
1467
  });
833
1468
  };
834
- class zt {
835
- constructor(c) {
1469
+ class In {
1470
+ constructor(o) {
836
1471
  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__ */ (() => {
837
- let e = null;
838
- const n = () => e || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : e = new this.targetWindow.ResizeObserver((s) => {
839
- s.forEach((i) => {
840
- const o = () => {
1472
+ let t = null;
1473
+ const n = () => t || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : t = new this.targetWindow.ResizeObserver((r) => {
1474
+ r.forEach((i) => {
1475
+ const a = () => {
841
1476
  this._measureElement(i.target, i);
842
1477
  };
843
- this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(o) : o();
1478
+ this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(a) : a();
844
1479
  });
845
1480
  }));
846
1481
  return {
847
1482
  disconnect: () => {
848
- var s;
849
- (s = n()) == null || s.disconnect(), e = null;
1483
+ var r;
1484
+ (r = n()) == null || r.disconnect(), t = null;
850
1485
  },
851
- observe: (s) => {
1486
+ observe: (r) => {
852
1487
  var i;
853
- return (i = n()) == null ? void 0 : i.observe(s, { box: "border-box" });
1488
+ return (i = n()) == null ? void 0 : i.observe(r, { box: "border-box" });
854
1489
  },
855
- unobserve: (s) => {
1490
+ unobserve: (r) => {
856
1491
  var i;
857
- return (i = n()) == null ? void 0 : i.unobserve(s);
1492
+ return (i = n()) == null ? void 0 : i.unobserve(r);
858
1493
  }
859
1494
  };
860
- })(), this.range = null, this.setOptions = (e) => {
861
- Object.entries(e).forEach(([n, s]) => {
862
- typeof s > "u" && delete e[n];
1495
+ })(), this.range = null, this.setOptions = (t) => {
1496
+ Object.entries(t).forEach(([n, r]) => {
1497
+ typeof r > "u" && delete t[n];
863
1498
  }), this.options = {
864
1499
  debug: !1,
865
1500
  initialOffset: 0,
@@ -869,11 +1504,11 @@ class zt {
869
1504
  scrollPaddingStart: 0,
870
1505
  scrollPaddingEnd: 0,
871
1506
  horizontal: !1,
872
- getItemKey: Nt,
873
- rangeExtractor: _t,
1507
+ getItemKey: Tn,
1508
+ rangeExtractor: An,
874
1509
  onChange: () => {
875
1510
  },
876
- measureElement: Tt,
1511
+ measureElement: Fn,
877
1512
  initialRect: { width: 0, height: 0 },
878
1513
  scrollMargin: 0,
879
1514
  gap: 0,
@@ -885,19 +1520,19 @@ class zt {
885
1520
  isRtl: !1,
886
1521
  useScrollendEvent: !1,
887
1522
  useAnimationFrameWithResizeObserver: !1,
888
- ...e
1523
+ ...t
889
1524
  };
890
- }, this.notify = (e) => {
891
- var n, s;
892
- (s = (n = this.options).onChange) == null || s.call(n, this, e);
893
- }, this.maybeNotify = se(
1525
+ }, this.notify = (t) => {
1526
+ var n, r;
1527
+ (r = (n = this.options).onChange) == null || r.call(n, this, t);
1528
+ }, this.maybeNotify = Oe(
894
1529
  () => (this.calculateRange(), [
895
1530
  this.isScrolling,
896
1531
  this.range ? this.range.startIndex : null,
897
1532
  this.range ? this.range.endIndex : null
898
1533
  ]),
899
- (e) => {
900
- this.notify(e);
1534
+ (t) => {
1535
+ this.notify(t);
901
1536
  },
902
1537
  {
903
1538
  key: process.env.NODE_ENV !== "production" && "maybeNotify",
@@ -909,46 +1544,46 @@ class zt {
909
1544
  ]
910
1545
  }
911
1546
  ), this.cleanup = () => {
912
- this.unsubs.filter(Boolean).forEach((e) => e()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
1547
+ this.unsubs.filter(Boolean).forEach((t) => t()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
913
1548
  }, this._didMount = () => () => {
914
1549
  this.cleanup();
915
1550
  }, this._willUpdate = () => {
916
- var e;
1551
+ var t;
917
1552
  const n = this.options.enabled ? this.options.getScrollElement() : null;
918
1553
  if (this.scrollElement !== n) {
919
1554
  if (this.cleanup(), !n) {
920
1555
  this.maybeNotify();
921
1556
  return;
922
1557
  }
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);
1558
+ this.scrollElement = n, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((t = this.scrollElement) == null ? void 0 : t.window) ?? null, this.elementsCache.forEach((r) => {
1559
+ this.observer.observe(r);
925
1560
  }), this.unsubs.push(
926
- this.options.observeElementRect(this, (s) => {
927
- this.scrollRect = s, this.maybeNotify();
1561
+ this.options.observeElementRect(this, (r) => {
1562
+ this.scrollRect = r, this.maybeNotify();
928
1563
  })
929
1564
  ), this.unsubs.push(
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();
1565
+ this.options.observeElementOffset(this, (r, i) => {
1566
+ this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < r ? "forward" : "backward" : null, this.scrollOffset = r, this.isScrolling = i, this.maybeNotify();
932
1567
  })
933
1568
  ), this._scrollToOffset(this.getScrollOffset(), {
934
1569
  adjustments: void 0,
935
1570
  behavior: void 0
936
1571
  });
937
1572
  }
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--) {
941
- const l = e[o];
942
- if (s.has(l.lane))
1573
+ }, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (t, n) => {
1574
+ const r = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
1575
+ for (let a = n - 1; a >= 0; a--) {
1576
+ const l = t[a];
1577
+ if (r.has(l.lane))
943
1578
  continue;
944
- const g = i.get(
1579
+ const h = i.get(
945
1580
  l.lane
946
1581
  );
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)
1582
+ if (h == null || l.end > h.end ? i.set(l.lane, l) : l.end < h.end && r.set(l.lane, !0), r.size === this.options.lanes)
948
1583
  break;
949
1584
  }
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;
951
- }, this.getMeasurementOptions = se(
1585
+ return i.size === this.options.lanes ? Array.from(i.values()).sort((a, l) => a.end === l.end ? a.index - l.index : a.end - l.end)[0] : void 0;
1586
+ }, this.getMeasurementOptions = Oe(
952
1587
  () => [
953
1588
  this.options.count,
954
1589
  this.options.paddingStart,
@@ -957,154 +1592,154 @@ class zt {
957
1592
  this.options.enabled,
958
1593
  this.options.lanes
959
1594
  ],
960
- (e, n, s, i, o, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
961
- count: e,
1595
+ (t, n, r, i, a, l) => (this.prevLanes !== void 0 && this.prevLanes !== l && (this.lanesChangedFlag = !0), this.prevLanes = l, this.pendingMeasuredCacheIndexes = [], {
1596
+ count: t,
962
1597
  paddingStart: n,
963
- scrollMargin: s,
1598
+ scrollMargin: r,
964
1599
  getItemKey: i,
965
- enabled: o,
1600
+ enabled: a,
966
1601
  lanes: l
967
1602
  }),
968
1603
  {
969
1604
  key: !1
970
1605
  }
971
- ), this.getMeasurements = se(
1606
+ ), this.getMeasurements = Oe(
972
1607
  () => [this.getMeasurementOptions(), this.itemSizeCache],
973
- ({ count: e, paddingStart: n, scrollMargin: s, getItemKey: i, enabled: o, lanes: l }, g) => {
974
- if (!o)
1608
+ ({ count: t, paddingStart: n, scrollMargin: r, getItemKey: i, enabled: a, lanes: l }, h) => {
1609
+ if (!a)
975
1610
  return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
976
- if (this.laneAssignments.size > e)
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);
1611
+ if (this.laneAssignments.size > t)
1612
+ for (const p of this.laneAssignments.keys())
1613
+ p >= t && this.laneAssignments.delete(p);
1614
+ 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((p) => {
1615
+ this.itemSizeCache.set(p.key, p.size);
981
1616
  }));
982
- const m = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
983
- this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === e && (this.lanesSettling = !1);
984
- const f = this.measurementsCache.slice(0, m), v = new Array(l).fill(
1617
+ const f = this.lanesSettling ? 0 : this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
1618
+ this.pendingMeasuredCacheIndexes = [], this.lanesSettling && this.measurementsCache.length === t && (this.lanesSettling = !1);
1619
+ const d = this.measurementsCache.slice(0, f), m = new Array(l).fill(
985
1620
  void 0
986
1621
  );
987
- for (let u = 0; u < m; u++) {
988
- const d = f[u];
989
- d && (v[d.lane] = u);
1622
+ for (let p = 0; p < f; p++) {
1623
+ const x = d[p];
1624
+ x && (m[x.lane] = p);
990
1625
  }
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;
1626
+ for (let p = f; p < t; p++) {
1627
+ const x = i(p), j = this.laneAssignments.get(p);
1628
+ let v, k;
1629
+ if (j !== void 0 && this.options.lanes > 1) {
1630
+ v = j;
1631
+ const G = m[v], W = G !== void 0 ? d[G] : void 0;
1632
+ k = W ? W.end + this.options.gap : n + r;
998
1633
  } else {
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);
1634
+ const G = this.options.lanes === 1 ? d[p - 1] : this.getFurthestMeasurement(d, p);
1635
+ k = G ? G.end + this.options.gap : n + r, v = G ? G.lane : p % this.options.lanes, this.options.lanes > 1 && this.laneAssignments.set(p, v);
1001
1636
  }
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;
1637
+ const T = h.get(x), D = typeof T == "number" ? T : this.options.estimateSize(p), z = k + D;
1638
+ d[p] = {
1639
+ index: p,
1640
+ start: k,
1641
+ size: D,
1642
+ end: z,
1643
+ key: x,
1644
+ lane: v
1645
+ }, m[v] = p;
1011
1646
  }
1012
- return this.measurementsCache = f, f;
1647
+ return this.measurementsCache = d, d;
1013
1648
  },
1014
1649
  {
1015
1650
  key: process.env.NODE_ENV !== "production" && "getMeasurements",
1016
1651
  debug: () => this.options.debug
1017
1652
  }
1018
- ), this.calculateRange = se(
1653
+ ), this.calculateRange = Oe(
1019
1654
  () => [
1020
1655
  this.getMeasurements(),
1021
1656
  this.getSize(),
1022
1657
  this.getScrollOffset(),
1023
1658
  this.options.lanes
1024
1659
  ],
1025
- (e, n, s, i) => this.range = e.length > 0 && n > 0 ? Mt({
1026
- measurements: e,
1660
+ (t, n, r, i) => this.range = t.length > 0 && n > 0 ? Pn({
1661
+ measurements: t,
1027
1662
  outerSize: n,
1028
- scrollOffset: s,
1663
+ scrollOffset: r,
1029
1664
  lanes: i
1030
1665
  }) : null,
1031
1666
  {
1032
1667
  key: process.env.NODE_ENV !== "production" && "calculateRange",
1033
1668
  debug: () => this.options.debug
1034
1669
  }
1035
- ), this.getVirtualIndexes = se(
1670
+ ), this.getVirtualIndexes = Oe(
1036
1671
  () => {
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]), [
1672
+ let t = null, n = null;
1673
+ const r = this.calculateRange();
1674
+ return r && (t = r.startIndex, n = r.endIndex), this.maybeNotify.updateDeps([this.isScrolling, t, n]), [
1040
1675
  this.options.rangeExtractor,
1041
1676
  this.options.overscan,
1042
1677
  this.options.count,
1043
- e,
1678
+ t,
1044
1679
  n
1045
1680
  ];
1046
1681
  },
1047
- (e, n, s, i, o) => i === null || o === null ? [] : e({
1682
+ (t, n, r, i, a) => i === null || a === null ? [] : t({
1048
1683
  startIndex: i,
1049
- endIndex: o,
1684
+ endIndex: a,
1050
1685
  overscan: n,
1051
- count: s
1686
+ count: r
1052
1687
  }),
1053
1688
  {
1054
1689
  key: process.env.NODE_ENV !== "production" && "getVirtualIndexes",
1055
1690
  debug: () => this.options.debug
1056
1691
  }
1057
- ), this.indexFromElement = (e) => {
1058
- const n = this.options.indexAttribute, s = e.getAttribute(n);
1059
- return s ? parseInt(s, 10) : (console.warn(
1692
+ ), this.indexFromElement = (t) => {
1693
+ const n = this.options.indexAttribute, r = t.getAttribute(n);
1694
+ return r ? parseInt(r, 10) : (console.warn(
1060
1695
  `Missing attribute name '${n}={index}' on measured element.`
1061
1696
  ), -1);
1062
- }, this._measureElement = (e, n) => {
1063
- const s = this.indexFromElement(e), i = this.measurementsCache[s];
1697
+ }, this._measureElement = (t, n) => {
1698
+ const r = this.indexFromElement(t), i = this.measurementsCache[r];
1064
1699
  if (!i)
1065
1700
  return;
1066
- const o = i.key, l = this.elementsCache.get(o);
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)
1701
+ const a = i.key, l = this.elementsCache.get(a);
1702
+ l !== t && (l && this.observer.unobserve(l), this.observer.observe(t), this.elementsCache.set(a, t)), t.isConnected && this.resizeItem(r, this.options.measureElement(t, n, this));
1703
+ }, this.resizeItem = (t, n) => {
1704
+ const r = this.measurementsCache[t];
1705
+ if (!r)
1071
1706
  return;
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(), {
1074
- adjustments: this.scrollAdjustments += o,
1707
+ const i = this.itemSizeCache.get(r.key) ?? r.size, a = n - i;
1708
+ a !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(r, a, this) : r.start < this.getScrollOffset() + this.scrollAdjustments) && (process.env.NODE_ENV !== "production" && this.options.debug && console.info("correction", a), this._scrollToOffset(this.getScrollOffset(), {
1709
+ adjustments: this.scrollAdjustments += a,
1075
1710
  behavior: void 0
1076
- })), this.pendingMeasuredCacheIndexes.push(s.index), this.itemSizeCache = new Map(this.itemSizeCache.set(s.key, n)), this.notify(!1));
1077
- }, this.measureElement = (e) => {
1078
- if (!e) {
1079
- this.elementsCache.forEach((n, s) => {
1080
- n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(s));
1711
+ })), this.pendingMeasuredCacheIndexes.push(r.index), this.itemSizeCache = new Map(this.itemSizeCache.set(r.key, n)), this.notify(!1));
1712
+ }, this.measureElement = (t) => {
1713
+ if (!t) {
1714
+ this.elementsCache.forEach((n, r) => {
1715
+ n.isConnected || (this.observer.unobserve(n), this.elementsCache.delete(r));
1081
1716
  });
1082
1717
  return;
1083
1718
  }
1084
- this._measureElement(e, void 0);
1085
- }, this.getVirtualItems = se(
1719
+ this._measureElement(t, void 0);
1720
+ }, this.getVirtualItems = Oe(
1086
1721
  () => [this.getVirtualIndexes(), this.getMeasurements()],
1087
- (e, n) => {
1088
- const s = [];
1089
- for (let i = 0, o = e.length; i < o; i++) {
1090
- const l = e[i], g = n[l];
1091
- s.push(g);
1722
+ (t, n) => {
1723
+ const r = [];
1724
+ for (let i = 0, a = t.length; i < a; i++) {
1725
+ const l = t[i], h = n[l];
1726
+ r.push(h);
1092
1727
  }
1093
- return s;
1728
+ return r;
1094
1729
  },
1095
1730
  {
1096
1731
  key: process.env.NODE_ENV !== "production" && "getVirtualItems",
1097
1732
  debug: () => this.options.debug
1098
1733
  }
1099
- ), this.getVirtualItemForOffset = (e) => {
1734
+ ), this.getVirtualItemForOffset = (t) => {
1100
1735
  const n = this.getMeasurements();
1101
1736
  if (n.length !== 0)
1102
- return Ae(
1103
- n[Le(
1737
+ return Tt(
1738
+ n[qt(
1104
1739
  0,
1105
1740
  n.length - 1,
1106
- (s) => Ae(n[s]).start,
1107
- e
1741
+ (r) => Tt(n[r]).start,
1742
+ t
1108
1743
  )]
1109
1744
  );
1110
1745
  }, this.getMaxScrollOffset = () => {
@@ -1112,423 +1747,1002 @@ class zt {
1112
1747
  if ("scrollHeight" in this.scrollElement)
1113
1748
  return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
1114
1749
  {
1115
- const e = this.scrollElement.document.documentElement;
1116
- return this.options.horizontal ? e.scrollWidth - this.scrollElement.innerWidth : e.scrollHeight - this.scrollElement.innerHeight;
1750
+ const t = this.scrollElement.document.documentElement;
1751
+ return this.options.horizontal ? t.scrollWidth - this.scrollElement.innerWidth : t.scrollHeight - this.scrollElement.innerHeight;
1117
1752
  }
1118
- }, this.getOffsetForAlignment = (e, n, s = 0) => {
1753
+ }, this.getOffsetForAlignment = (t, n, r = 0) => {
1119
1754
  if (!this.scrollElement) return 0;
1120
- const i = this.getSize(), o = this.getScrollOffset();
1121
- n === "auto" && (n = e >= o + i ? "end" : "start"), n === "center" ? e += (s - i) / 2 : n === "end" && (e -= i);
1755
+ const i = this.getSize(), a = this.getScrollOffset();
1756
+ n === "auto" && (n = t >= a + i ? "end" : "start"), n === "center" ? t += (r - i) / 2 : n === "end" && (t -= i);
1122
1757
  const l = this.getMaxScrollOffset();
1123
- return Math.max(Math.min(l, e), 0);
1124
- }, this.getOffsetForIndex = (e, n = "auto") => {
1125
- e = Math.max(0, Math.min(e, this.options.count - 1));
1126
- const s = this.measurementsCache[e];
1127
- if (!s)
1758
+ return Math.max(Math.min(l, t), 0);
1759
+ }, this.getOffsetForIndex = (t, n = "auto") => {
1760
+ t = Math.max(0, Math.min(t, this.options.count - 1));
1761
+ const r = this.measurementsCache[t];
1762
+ if (!r)
1128
1763
  return;
1129
- const i = this.getSize(), o = this.getScrollOffset();
1764
+ const i = this.getSize(), a = this.getScrollOffset();
1130
1765
  if (n === "auto")
1131
- if (s.end >= o + i - this.options.scrollPaddingEnd)
1766
+ if (r.end >= a + i - this.options.scrollPaddingEnd)
1132
1767
  n = "end";
1133
- else if (s.start <= o + this.options.scrollPaddingStart)
1768
+ else if (r.start <= a + this.options.scrollPaddingStart)
1134
1769
  n = "start";
1135
1770
  else
1136
- return [o, n];
1137
- if (n === "end" && e === this.options.count - 1)
1771
+ return [a, n];
1772
+ if (n === "end" && t === this.options.count - 1)
1138
1773
  return [this.getMaxScrollOffset(), n];
1139
- const l = n === "end" ? s.end + this.options.scrollPaddingEnd : s.start - this.options.scrollPaddingStart;
1774
+ const l = n === "end" ? r.end + this.options.scrollPaddingEnd : r.start - this.options.scrollPaddingStart;
1140
1775
  return [
1141
- this.getOffsetForAlignment(l, n, s.size),
1776
+ this.getOffsetForAlignment(l, n, r.size),
1142
1777
  n
1143
1778
  ];
1144
- }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (e, { align: n = "start", behavior: s } = {}) => {
1145
- s === "smooth" && this.isDynamicMode() && console.warn(
1779
+ }, this.isDynamicMode = () => this.elementsCache.size > 0, this.scrollToOffset = (t, { align: n = "start", behavior: r } = {}) => {
1780
+ r === "smooth" && this.isDynamicMode() && console.warn(
1146
1781
  "The `smooth` scroll behavior is not fully supported with dynamic size."
1147
- ), this._scrollToOffset(this.getOffsetForAlignment(e, n), {
1782
+ ), this._scrollToOffset(this.getOffsetForAlignment(t, n), {
1148
1783
  adjustments: void 0,
1149
- behavior: s
1784
+ behavior: r
1150
1785
  });
1151
- }, this.scrollToIndex = (e, { align: n = "auto", behavior: s } = {}) => {
1152
- s === "smooth" && this.isDynamicMode() && console.warn(
1786
+ }, this.scrollToIndex = (t, { align: n = "auto", behavior: r } = {}) => {
1787
+ r === "smooth" && this.isDynamicMode() && console.warn(
1153
1788
  "The `smooth` scroll behavior is not fully supported with dynamic size."
1154
- ), e = Math.max(0, Math.min(e, this.options.count - 1)), this.currentScrollToIndex = e;
1789
+ ), t = Math.max(0, Math.min(t, this.options.count - 1)), this.currentScrollToIndex = t;
1155
1790
  let i = 0;
1156
- const o = 10, l = (m) => {
1791
+ const a = 10, l = (f) => {
1157
1792
  if (!this.targetWindow) return;
1158
- const f = this.getOffsetForIndex(e, m);
1159
- if (!f) {
1160
- console.warn("Failed to get offset for index:", e);
1793
+ const d = this.getOffsetForIndex(t, f);
1794
+ if (!d) {
1795
+ console.warn("Failed to get offset for index:", t);
1161
1796
  return;
1162
1797
  }
1163
- const [v, u] = f;
1164
- this._scrollToOffset(v, { adjustments: void 0, behavior: s }), this.targetWindow.requestAnimationFrame(() => {
1165
- const d = () => {
1166
- if (this.currentScrollToIndex !== e) return;
1167
- const y = this.getScrollOffset(), x = this.getOffsetForIndex(e, u);
1168
- if (!x) {
1169
- console.warn("Failed to get offset for index:", e);
1798
+ const [m, p] = d;
1799
+ this._scrollToOffset(m, { adjustments: void 0, behavior: r }), this.targetWindow.requestAnimationFrame(() => {
1800
+ if (!this.targetWindow) return;
1801
+ const x = () => {
1802
+ if (this.currentScrollToIndex !== t) return;
1803
+ const j = this.getScrollOffset(), v = this.getOffsetForIndex(t, p);
1804
+ if (!v) {
1805
+ console.warn("Failed to get offset for index:", t);
1170
1806
  return;
1171
1807
  }
1172
- Ct(x[0], y) || g(u);
1808
+ _n(v[0], j) || h(p);
1173
1809
  };
1174
- this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(d) : d();
1810
+ this.isDynamicMode() ? this.targetWindow.requestAnimationFrame(x) : x();
1175
1811
  });
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(
1178
- `Failed to scroll to index ${e} after ${o} attempts.`
1812
+ }, h = (f) => {
1813
+ this.targetWindow && this.currentScrollToIndex === t && (i++, i < a ? (process.env.NODE_ENV !== "production" && this.options.debug && console.info("Schedule retry", i, a), this.targetWindow.requestAnimationFrame(() => l(f))) : console.warn(
1814
+ `Failed to scroll to index ${t} after ${a} attempts.`
1179
1815
  ));
1180
1816
  };
1181
1817
  l(n);
1182
- }, this.scrollBy = (e, { behavior: n } = {}) => {
1818
+ }, this.scrollBy = (t, { behavior: n } = {}) => {
1183
1819
  n === "smooth" && this.isDynamicMode() && console.warn(
1184
1820
  "The `smooth` scroll behavior is not fully supported with dynamic size."
1185
- ), this._scrollToOffset(this.getScrollOffset() + e, {
1821
+ ), this._scrollToOffset(this.getScrollOffset() + t, {
1186
1822
  adjustments: void 0,
1187
1823
  behavior: n
1188
1824
  });
1189
1825
  }, this.getTotalSize = () => {
1190
- var e;
1826
+ var t;
1191
1827
  const n = this.getMeasurements();
1192
- let s;
1828
+ let r;
1193
1829
  if (n.length === 0)
1194
- s = this.options.paddingStart;
1830
+ r = this.options.paddingStart;
1195
1831
  else if (this.options.lanes === 1)
1196
- s = ((e = n[n.length - 1]) == null ? void 0 : e.end) ?? 0;
1832
+ r = ((t = n[n.length - 1]) == null ? void 0 : t.end) ?? 0;
1197
1833
  else {
1198
1834
  const i = Array(this.options.lanes).fill(null);
1199
- let o = n.length - 1;
1200
- for (; o >= 0 && i.some((l) => l === null); ) {
1201
- const l = n[o];
1202
- i[l.lane] === null && (i[l.lane] = l.end), o--;
1835
+ let a = n.length - 1;
1836
+ for (; a >= 0 && i.some((l) => l === null); ) {
1837
+ const l = n[a];
1838
+ i[l.lane] === null && (i[l.lane] = l.end), a--;
1203
1839
  }
1204
- s = Math.max(...i.filter((l) => l !== null));
1840
+ r = Math.max(...i.filter((l) => l !== null));
1205
1841
  }
1206
1842
  return Math.max(
1207
- s - this.options.scrollMargin + this.options.paddingEnd,
1843
+ r - this.options.scrollMargin + this.options.paddingEnd,
1208
1844
  0
1209
1845
  );
1210
- }, this._scrollToOffset = (e, {
1846
+ }, this._scrollToOffset = (t, {
1211
1847
  adjustments: n,
1212
- behavior: s
1848
+ behavior: r
1213
1849
  }) => {
1214
- this.options.scrollToFn(e, { behavior: s, adjustments: n }, this);
1850
+ this.options.scrollToFn(t, { behavior: r, adjustments: n }, this);
1215
1851
  }, this.measure = () => {
1216
1852
  this.itemSizeCache = /* @__PURE__ */ new Map(), this.laneAssignments = /* @__PURE__ */ new Map(), this.notify(!1);
1217
- }, this.setOptions(c);
1853
+ }, this.setOptions(o);
1218
1854
  }
1219
1855
  }
1220
- const Le = (t, c, e, n) => {
1221
- for (; t <= c; ) {
1222
- const s = (t + c) / 2 | 0, i = e(s);
1856
+ const qt = (e, o, t, n) => {
1857
+ for (; e <= o; ) {
1858
+ const r = (e + o) / 2 | 0, i = t(r);
1223
1859
  if (i < n)
1224
- t = s + 1;
1860
+ e = r + 1;
1225
1861
  else if (i > n)
1226
- c = s - 1;
1862
+ o = r - 1;
1227
1863
  else
1228
- return s;
1864
+ return r;
1229
1865
  }
1230
- return t > 0 ? t - 1 : 0;
1866
+ return e > 0 ? e - 1 : 0;
1231
1867
  };
1232
- function Mt({
1233
- measurements: t,
1234
- outerSize: c,
1235
- scrollOffset: e,
1868
+ function Pn({
1869
+ measurements: e,
1870
+ outerSize: o,
1871
+ scrollOffset: t,
1236
1872
  lanes: n
1237
1873
  }) {
1238
- const s = t.length - 1, i = (g) => t[g].start;
1239
- if (t.length <= n)
1874
+ const r = e.length - 1, i = (h) => e[h].start;
1875
+ if (e.length <= n)
1240
1876
  return {
1241
1877
  startIndex: 0,
1242
- endIndex: s
1878
+ endIndex: r
1243
1879
  };
1244
- let o = Le(
1880
+ let a = qt(
1245
1881
  0,
1246
- s,
1882
+ r,
1247
1883
  i,
1248
- e
1249
- ), l = o;
1884
+ t
1885
+ ), l = a;
1250
1886
  if (n === 1)
1251
- for (; l < s && t[l].end < e + c; )
1887
+ for (; l < r && e[l].end < t + o; )
1252
1888
  l++;
1253
1889
  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++;
1890
+ const h = Array(n).fill(0);
1891
+ for (; l < r && h.some((d) => d < t + o); ) {
1892
+ const d = e[l];
1893
+ h[d.lane] = d.end, l++;
1258
1894
  }
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--;
1895
+ const f = Array(n).fill(t + o);
1896
+ for (; a >= 0 && f.some((d) => d >= t); ) {
1897
+ const d = e[a];
1898
+ f[d.lane] = d.start, a--;
1263
1899
  }
1264
- o = Math.max(0, o - o % n), l = Math.min(s, l + (n - 1 - l % n));
1900
+ a = Math.max(0, a - a % n), l = Math.min(r, l + (n - 1 - l % n));
1265
1901
  }
1266
- return { startIndex: o, endIndex: l };
1902
+ return { startIndex: a, endIndex: l };
1267
1903
  }
1268
- const De = typeof document < "u" ? me.useLayoutEffect : me.useEffect;
1269
- function It({
1270
- useFlushSync: t = !0,
1271
- ...c
1904
+ const Ft = typeof document < "u" ? He.useLayoutEffect : He.useEffect;
1905
+ function Ln({
1906
+ useFlushSync: e = !0,
1907
+ ...o
1272
1908
  }) {
1273
- const e = me.useReducer(() => ({}), {})[1], n = {
1274
- ...c,
1275
- onChange: (i, o) => {
1909
+ const t = He.useReducer(() => ({}), {})[1], n = {
1910
+ ...o,
1911
+ onChange: (i, a) => {
1276
1912
  var l;
1277
- t && o ? ut(e) : e(), (l = c.onChange) == null || l.call(c, i, o);
1913
+ e && a ? on(t) : t(), (l = o.onChange) == null || l.call(o, i, a);
1278
1914
  }
1279
- }, [s] = me.useState(
1280
- () => new zt(n)
1915
+ }, [r] = He.useState(
1916
+ () => new In(n)
1281
1917
  );
1282
- return s.setOptions(n), De(() => s._didMount(), []), De(() => s._willUpdate()), s;
1918
+ return r.setOptions(n), Ft(() => r._didMount(), []), Ft(() => r._willUpdate()), r;
1283
1919
  }
1284
- function Dt(t) {
1285
- return It({
1286
- observeElementRect: Rt,
1287
- observeElementOffset: kt,
1288
- scrollToFn: At,
1289
- ...t
1920
+ function $n(e) {
1921
+ return Ln({
1922
+ observeElementRect: Mn,
1923
+ observeElementOffset: Dn,
1924
+ scrollToFn: zn,
1925
+ ...e
1290
1926
  });
1291
1927
  }
1292
- const Gt = ({
1293
- data: t,
1294
- columns: c,
1295
- rowHeight: e = 40,
1928
+ const cr = ({
1929
+ data: e,
1930
+ columns: o,
1931
+ rowHeight: t = 40,
1296
1932
  height: n = 600,
1297
- className: s = "",
1933
+ className: r = "",
1298
1934
  headerClassName: i = "",
1299
- rowClassName: o,
1935
+ rowClassName: a,
1300
1936
  onRowClick: l,
1301
- overscan: g = 5
1937
+ overscan: h = 5
1302
1938
  }) => {
1303
- const m = pe(null), f = Dt({
1304
- count: t.length,
1305
- getScrollElement: () => m.current,
1306
- estimateSize: () => e,
1307
- overscan: g
1308
- }), v = f.getVirtualItems();
1309
- return /* @__PURE__ */ a.jsxs("div", { className: s, children: [
1310
- /* @__PURE__ */ a.jsx(
1939
+ const f = xe(null), d = $n({
1940
+ count: e.length,
1941
+ getScrollElement: () => f.current,
1942
+ estimateSize: () => t,
1943
+ overscan: h
1944
+ }), m = d.getVirtualItems();
1945
+ return /* @__PURE__ */ s.jsxs("div", { className: r, children: [
1946
+ /* @__PURE__ */ s.jsx(
1311
1947
  "div",
1312
1948
  {
1313
- className: `grid border-b sticky top-0 bg-background z-10 ${i}`,
1949
+ className: `grid border-b sticky top-0 bg-muted/30 z-10 ${i}`,
1314
1950
  style: {
1315
- gridTemplateColumns: c.map((u) => u.width || "1fr").join(" ")
1951
+ gridTemplateColumns: o.map((p) => p.width || "1fr").join(" ")
1316
1952
  },
1317
- children: c.map((u, d) => /* @__PURE__ */ a.jsx(
1953
+ children: o.map((p, x) => /* @__PURE__ */ s.jsx(
1318
1954
  "div",
1319
1955
  {
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
1956
+ className: `px-4 py-2 text-[11px] font-semibold uppercase tracking-wider text-muted-foreground/70 ${p.align === "center" ? "text-center" : p.align === "right" ? "text-right" : "text-left"}`,
1957
+ children: p.header
1322
1958
  },
1323
- d
1959
+ x
1324
1960
  ))
1325
1961
  }
1326
1962
  ),
1327
- /* @__PURE__ */ a.jsx(
1963
+ /* @__PURE__ */ s.jsx(
1328
1964
  "div",
1329
1965
  {
1330
- ref: m,
1966
+ ref: f,
1331
1967
  className: "overflow-auto",
1332
1968
  style: {
1333
1969
  height: typeof n == "number" ? `${n}px` : n,
1334
1970
  contain: "strict"
1335
1971
  },
1336
- children: /* @__PURE__ */ a.jsx(
1972
+ children: /* @__PURE__ */ s.jsx(
1337
1973
  "div",
1338
1974
  {
1339
1975
  style: {
1340
- height: `${f.getTotalSize()}px`,
1976
+ height: `${d.getTotalSize()}px`,
1341
1977
  width: "100%",
1342
1978
  position: "relative"
1343
1979
  },
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(
1980
+ children: m.map((p) => {
1981
+ const x = e[p.index], j = typeof a == "function" ? a(x, p.index) : a || "";
1982
+ return /* @__PURE__ */ s.jsx(
1347
1983
  "div",
1348
1984
  {
1349
- className: `grid border-b hover:bg-muted/50 cursor-pointer ${y}`,
1985
+ className: `grid border-b hover:bg-muted/50 cursor-pointer ${j}`,
1350
1986
  style: {
1351
1987
  position: "absolute",
1352
1988
  top: 0,
1353
1989
  left: 0,
1354
1990
  width: "100%",
1355
- height: `${u.size}px`,
1356
- transform: `translateY(${u.start}px)`,
1357
- gridTemplateColumns: c.map((x) => x.width || "1fr").join(" ")
1991
+ height: `${p.size}px`,
1992
+ transform: `translateY(${p.start}px)`,
1993
+ gridTemplateColumns: o.map((v) => v.width || "1fr").join(" ")
1358
1994
  },
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(
1995
+ onClick: () => l?.(x, p.index),
1996
+ children: o.map((v, k) => {
1997
+ const T = x[v.accessorKey], D = v.cell ? v.cell(T, x) : T;
1998
+ return /* @__PURE__ */ s.jsx(
1363
1999
  "div",
1364
2000
  {
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: _
2001
+ 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"}`,
2002
+ children: D
1367
2003
  },
1368
- S
2004
+ k
1369
2005
  );
1370
2006
  })
1371
2007
  },
1372
- u.key
2008
+ p.key
1373
2009
  );
1374
2010
  })
1375
2011
  }
1376
2012
  )
1377
2013
  }
1378
2014
  ),
1379
- /* @__PURE__ */ a.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
2015
+ /* @__PURE__ */ s.jsxs("div", { className: "px-4 py-2 text-xs text-muted-foreground border-t", children: [
1380
2016
  "Showing ",
1381
- v.length,
2017
+ m.length,
1382
2018
  " of ",
1383
- t.length,
2019
+ e.length,
1384
2020
  " rows (virtual scrolling enabled)"
1385
2021
  ] })
1386
2022
  ] });
2023
+ }, Vn = 10;
2024
+ function Kn(e) {
2025
+ const o = [];
2026
+ let t = [], n = "", r = !1;
2027
+ for (let i = 0; i < e.length; i++) {
2028
+ const a = e[i], l = e[i + 1];
2029
+ r ? a === '"' && l === '"' ? (n += '"', i++) : a === '"' ? r = !1 : n += a : a === '"' ? r = !0 : a === "," ? (t.push(n.trim()), n = "") : a === `
2030
+ ` || a === "\r" && l === `
2031
+ ` ? (t.push(n.trim()), t.some((h) => h !== "") && o.push(t), t = [], n = "", a === "\r" && i++) : n += a;
2032
+ }
2033
+ return t.push(n.trim()), t.some((i) => i !== "") && o.push(t), o;
2034
+ }
2035
+ function Bt(e, o) {
2036
+ if (!e) return !0;
2037
+ switch (o) {
2038
+ case "number":
2039
+ case "currency":
2040
+ case "percent":
2041
+ return !isNaN(Number(e));
2042
+ case "boolean":
2043
+ return ["true", "false", "1", "0", "yes", "no"].includes(e.toLowerCase());
2044
+ case "date":
2045
+ case "datetime":
2046
+ return !isNaN(Date.parse(e));
2047
+ default:
2048
+ return !0;
2049
+ }
2050
+ }
2051
+ function Wn(e, o) {
2052
+ const t = {};
2053
+ return e.forEach((n, r) => {
2054
+ const i = n.toLowerCase().replace(/[_\s-]/g, ""), a = o.find((l) => {
2055
+ const h = l.name.toLowerCase().replace(/[_\s-]/g, ""), f = l.label.toLowerCase().replace(/[_\s-]/g, "");
2056
+ return h === i || f === i;
2057
+ });
2058
+ a && (t[r] = a.name);
2059
+ }), t;
2060
+ }
2061
+ function qn(e, o, t) {
2062
+ const n = [], r = {};
2063
+ for (const i of o) {
2064
+ const a = e[i.csvIdx] ?? "";
2065
+ if (i.field.required && !a) {
2066
+ n.push({ row: t, field: i.field.name, message: "Required field is empty" });
2067
+ continue;
2068
+ }
2069
+ if (a && !Bt(a, i.field.type)) {
2070
+ n.push({ row: t, field: i.field.name, message: `Invalid ${i.field.type} value: "${a}"` });
2071
+ continue;
2072
+ }
2073
+ r[i.field.name] = a;
2074
+ }
2075
+ return { record: r, errors: n };
2076
+ }
2077
+ const Bn = ({ onFileLoaded: e }) => {
2078
+ const [o, t] = F(!1), [n, r] = F(null), i = M((a) => {
2079
+ if (r(null), !a.name.endsWith(".csv")) {
2080
+ r("Only CSV files are supported.");
2081
+ return;
2082
+ }
2083
+ const l = new FileReader();
2084
+ l.onload = (h) => {
2085
+ const f = Kn(h.target?.result);
2086
+ if (f.length < 2) {
2087
+ r("File must contain a header row and at least one data row.");
2088
+ return;
2089
+ }
2090
+ e(f[0], f.slice(1));
2091
+ }, l.readAsText(a);
2092
+ }, [e]);
2093
+ return /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col items-center gap-4 py-6", children: [
2094
+ /* @__PURE__ */ s.jsxs(
2095
+ "div",
2096
+ {
2097
+ className: ue(
2098
+ "flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors",
2099
+ o ? "border-primary bg-primary/5" : "border-muted-foreground/25"
2100
+ ),
2101
+ onDragOver: (a) => {
2102
+ a.preventDefault(), t(!0);
2103
+ },
2104
+ onDragLeave: () => t(!1),
2105
+ onDrop: (a) => {
2106
+ a.preventDefault(), t(!1);
2107
+ const l = a.dataTransfer.files[0];
2108
+ l && i(l);
2109
+ },
2110
+ children: [
2111
+ /* @__PURE__ */ s.jsx(sn, { className: "h-10 w-10 text-muted-foreground" }),
2112
+ /* @__PURE__ */ s.jsx("p", { className: "text-sm text-muted-foreground", children: "Drag & drop a CSV file here, or click to browse" }),
2113
+ /* @__PURE__ */ s.jsxs("label", { children: [
2114
+ /* @__PURE__ */ s.jsx("input", { type: "file", accept: ".csv", className: "hidden", onChange: (a) => {
2115
+ const l = a.target.files?.[0];
2116
+ l && i(l);
2117
+ } }),
2118
+ /* @__PURE__ */ s.jsx(le, { variant: "outline", size: "sm", asChild: !0, children: /* @__PURE__ */ s.jsx("span", { children: "Browse Files" }) })
2119
+ ] })
2120
+ ]
2121
+ }
2122
+ ),
2123
+ n && /* @__PURE__ */ s.jsxs("p", { className: "flex items-center gap-1 text-sm text-destructive", children: [
2124
+ /* @__PURE__ */ s.jsx(Kt, { className: "h-4 w-4" }),
2125
+ " ",
2126
+ n
2127
+ ] })
2128
+ ] });
2129
+ }, Un = ({ headers: e, fields: o, mapping: t, onMappingChange: n }) => {
2130
+ const r = ve(() => new Set(Object.values(t)), [t]), i = M((a, l) => {
2131
+ const h = { ...t };
2132
+ l === "__skip__" ? delete h[a] : h[a] = l, n(h);
2133
+ }, [t, n]);
2134
+ return /* @__PURE__ */ s.jsx("div", { className: "max-h-[360px] overflow-auto", children: /* @__PURE__ */ s.jsxs(Lt, { children: [
2135
+ /* @__PURE__ */ s.jsx($t, { children: /* @__PURE__ */ s.jsxs(Ye, { children: [
2136
+ /* @__PURE__ */ s.jsx(Pe, { children: "CSV Column" }),
2137
+ /* @__PURE__ */ s.jsx(Pe, { children: "Maps To" }),
2138
+ /* @__PURE__ */ s.jsx(Pe, { className: "w-24 text-center", children: "Status" })
2139
+ ] }) }),
2140
+ /* @__PURE__ */ s.jsx(Vt, { children: e.map((a, l) => /* @__PURE__ */ s.jsxs(Ye, { children: [
2141
+ /* @__PURE__ */ s.jsx(Le, { className: "font-medium", children: a }),
2142
+ /* @__PURE__ */ s.jsx(Le, { children: /* @__PURE__ */ s.jsxs(zs, { value: t[l] ?? "__skip__", onValueChange: (h) => i(l, h), children: [
2143
+ /* @__PURE__ */ s.jsx(Is, { className: "h-8 w-56", children: /* @__PURE__ */ s.jsx(Ps, { placeholder: "Skip column" }) }),
2144
+ /* @__PURE__ */ s.jsxs(Ls, { children: [
2145
+ /* @__PURE__ */ s.jsx(wt, { value: "__skip__", children: "— Skip —" }),
2146
+ o.map((h) => /* @__PURE__ */ s.jsxs(wt, { value: h.name, disabled: r.has(h.name) && t[l] !== h.name, children: [
2147
+ h.label,
2148
+ h.required ? " *" : ""
2149
+ ] }, h.name))
2150
+ ] })
2151
+ ] }) }),
2152
+ /* @__PURE__ */ s.jsx(Le, { className: "text-center", children: t[l] ? /* @__PURE__ */ s.jsx(Te, { variant: "default", className: "text-xs", children: "Mapped" }) : /* @__PURE__ */ s.jsx(Te, { variant: "secondary", className: "text-xs", children: "Skipped" }) })
2153
+ ] }, l)) })
2154
+ ] }) });
2155
+ }, Gn = ({ headers: e, rows: o, mapping: t, fields: n }) => {
2156
+ const r = ve(() => Object.entries(t).map(([h, f]) => ({
2157
+ csvIdx: Number(h),
2158
+ header: e[Number(h)],
2159
+ field: n.find((d) => d.name === f)
2160
+ })), [t, e, n]), i = o.slice(0, Vn), a = ve(() => i.map((h, f) => {
2161
+ const d = {};
2162
+ for (const m of r) {
2163
+ const p = h[m.csvIdx] ?? "";
2164
+ m.field.required && !p ? d[m.csvIdx] = "Required" : p && !Bt(p, m.field.type) && (d[m.csvIdx] = `Invalid ${m.field.type}`);
2165
+ }
2166
+ return d;
2167
+ }), [i, r]), l = a.filter((h) => Object.keys(h).length > 0).length;
2168
+ return /* @__PURE__ */ s.jsxs("div", { className: "max-h-[360px] overflow-auto", children: [
2169
+ l > 0 && /* @__PURE__ */ s.jsxs("p", { className: "mb-2 flex items-center gap-1 text-xs text-destructive", children: [
2170
+ /* @__PURE__ */ s.jsx(Kt, { className: "h-3.5 w-3.5" }),
2171
+ " ",
2172
+ l,
2173
+ " row(s) with errors in preview"
2174
+ ] }),
2175
+ /* @__PURE__ */ s.jsxs(Lt, { children: [
2176
+ /* @__PURE__ */ s.jsx($t, { children: /* @__PURE__ */ s.jsxs(Ye, { children: [
2177
+ /* @__PURE__ */ s.jsx(Pe, { className: "w-12", children: "#" }),
2178
+ r.map((h) => /* @__PURE__ */ s.jsx(Pe, { children: h.field.label }, h.csvIdx))
2179
+ ] }) }),
2180
+ /* @__PURE__ */ s.jsx(Vt, { children: i.map((h, f) => {
2181
+ const d = a[f], m = Object.keys(d).length > 0;
2182
+ return /* @__PURE__ */ s.jsxs(Ye, { className: ue(m && "bg-destructive/5"), children: [
2183
+ /* @__PURE__ */ s.jsx(Le, { className: "text-xs text-muted-foreground", children: f + 1 }),
2184
+ r.map((p) => {
2185
+ const x = h[p.csvIdx] ?? "", j = d[p.csvIdx];
2186
+ return /* @__PURE__ */ s.jsx(Le, { className: ue(j && "text-destructive"), title: j, children: x || /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground/50", children: "—" }) }, p.csvIdx);
2187
+ })
2188
+ ] }, f);
2189
+ }) })
2190
+ ] }),
2191
+ /* @__PURE__ */ s.jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: [
2192
+ "Showing ",
2193
+ i.length,
2194
+ " of ",
2195
+ o.length,
2196
+ " rows"
2197
+ ] })
2198
+ ] });
2199
+ }, Hn = ({
2200
+ objectName: e,
2201
+ objectLabel: o,
2202
+ fields: t,
2203
+ dataSource: n,
2204
+ onComplete: r,
2205
+ onCancel: i,
2206
+ open: a,
2207
+ onOpenChange: l,
2208
+ onErrorMode: h = "skip"
2209
+ }) => {
2210
+ const [f, d] = F("upload"), [m, p] = F([]), [x, j] = F([]), [v, k] = F({}), [T, D] = F(!1), [z, G] = F(0), [W, H] = F(null), re = o ?? e, Ae = ve(() => {
2211
+ const L = new Set(Object.values(v));
2212
+ return t.filter((J) => J.required && !L.has(J.name));
2213
+ }, [t, v]), je = M((L, J) => {
2214
+ p(L), j(J), k(Wn(L, t)), d("mapping");
2215
+ }, [t]), Re = M(async () => {
2216
+ D(!0), G(0);
2217
+ const L = [];
2218
+ let J = 0, fe = 0;
2219
+ const ie = Object.entries(v).map(([ee, be]) => ({
2220
+ csvIdx: Number(ee),
2221
+ field: t.find((ge) => ge.name === be)
2222
+ }));
2223
+ for (let ee = 0; ee < x.length; ee++) {
2224
+ const { record: be, errors: ge } = qn(x[ee], ie, ee + 1);
2225
+ if (ge.length > 0) {
2226
+ if (fe++, L.push(...ge), h === "stop") break;
2227
+ } else
2228
+ try {
2229
+ n?.create && await n.create(e, be), J++;
2230
+ } catch (u) {
2231
+ fe++;
2232
+ const _ = u instanceof Error ? u.message : "Failed to create record";
2233
+ if (L.push({ row: ee + 1, field: "", message: _ }), h === "stop") break;
2234
+ }
2235
+ G(Math.round((ee + 1) / x.length * 100));
2236
+ }
2237
+ const we = { totalRows: x.length, importedRows: J, skippedRows: fe, errors: L };
2238
+ H(we), D(!1), r?.(we);
2239
+ }, [x, v, t, n, e, r, h]), ae = M(() => {
2240
+ d("upload"), p([]), j([]), k({}), G(0), H(null);
2241
+ }, []), pe = M(() => {
2242
+ ae(), l?.(!1), i?.();
2243
+ }, [ae, l, i]);
2244
+ return /* @__PURE__ */ s.jsx(_s, { open: a, onOpenChange: (L) => {
2245
+ L ? l?.(L) : pe();
2246
+ }, children: /* @__PURE__ */ s.jsxs(Os, { className: "sm:max-w-2xl", children: [
2247
+ /* @__PURE__ */ s.jsxs(Ts, { children: [
2248
+ /* @__PURE__ */ s.jsxs(As, { className: "flex items-center gap-2", children: [
2249
+ /* @__PURE__ */ s.jsx(Zs, { className: "h-5 w-5" }),
2250
+ " Import ",
2251
+ re
2252
+ ] }),
2253
+ /* @__PURE__ */ s.jsxs(Ms, { children: [
2254
+ f === "upload" && "Upload a CSV file to get started.",
2255
+ f === "mapping" && "Map CSV columns to object fields.",
2256
+ f === "preview" && "Review data before importing."
2257
+ ] })
2258
+ ] }),
2259
+ /* @__PURE__ */ s.jsx("div", { className: "flex items-center justify-center gap-2 text-xs text-muted-foreground", children: ["upload", "mapping", "preview"].map((L, J) => /* @__PURE__ */ s.jsxs(Ie.Fragment, { children: [
2260
+ J > 0 && /* @__PURE__ */ s.jsx(St, { className: "h-3 w-3" }),
2261
+ /* @__PURE__ */ s.jsxs("span", { className: ue("rounded-full px-3 py-1", f === L ? "bg-primary text-primary-foreground" : "bg-muted"), children: [
2262
+ J + 1,
2263
+ ". ",
2264
+ L === "upload" ? "Upload" : L === "mapping" ? "Mapping" : "Preview"
2265
+ ] })
2266
+ ] }, L)) }),
2267
+ W ? /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col items-center gap-3 py-4", children: [
2268
+ /* @__PURE__ */ s.jsx(en, { className: "h-10 w-10 text-green-500" }),
2269
+ /* @__PURE__ */ s.jsx("p", { className: "text-lg font-semibold", children: "Import Complete" }),
2270
+ /* @__PURE__ */ s.jsxs("div", { className: "flex gap-3", children: [
2271
+ /* @__PURE__ */ s.jsxs(Te, { variant: "default", children: [
2272
+ W.importedRows,
2273
+ " imported"
2274
+ ] }),
2275
+ W.skippedRows > 0 && /* @__PURE__ */ s.jsxs(Te, { variant: "destructive", children: [
2276
+ W.skippedRows,
2277
+ " skipped"
2278
+ ] })
2279
+ ] }),
2280
+ W.errors.length > 0 && /* @__PURE__ */ s.jsxs("div", { className: "max-h-32 w-full overflow-auto rounded border p-2 text-xs", children: [
2281
+ W.errors.slice(0, 10).map((L, J) => /* @__PURE__ */ s.jsxs("p", { className: "text-destructive", children: [
2282
+ "Row ",
2283
+ L.row,
2284
+ L.field ? ` (${L.field})` : "",
2285
+ ": ",
2286
+ L.message
2287
+ ] }, J)),
2288
+ W.errors.length > 10 && /* @__PURE__ */ s.jsxs("p", { className: "text-muted-foreground", children: [
2289
+ "…and ",
2290
+ W.errors.length - 10,
2291
+ " more errors"
2292
+ ] })
2293
+ ] })
2294
+ ] }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
2295
+ f === "upload" && /* @__PURE__ */ s.jsx(Bn, { onFileLoaded: je }),
2296
+ f === "mapping" && /* @__PURE__ */ s.jsx(Un, { headers: m, fields: t, mapping: v, onMappingChange: k }),
2297
+ f === "preview" && /* @__PURE__ */ s.jsx(Gn, { headers: m, rows: x, mapping: v, fields: t }),
2298
+ T && /* @__PURE__ */ s.jsxs("div", { className: "flex flex-col gap-1", children: [
2299
+ /* @__PURE__ */ s.jsx(Ds, { value: z, className: "h-2" }),
2300
+ /* @__PURE__ */ s.jsxs("p", { className: "text-center text-xs text-muted-foreground", children: [
2301
+ "Importing… ",
2302
+ z,
2303
+ "%"
2304
+ ] })
2305
+ ] })
2306
+ ] }),
2307
+ /* @__PURE__ */ s.jsx(Fs, { className: "gap-2 sm:gap-0", children: W ? /* @__PURE__ */ s.jsx(le, { onClick: pe, children: "Close" }) : /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
2308
+ /* @__PURE__ */ s.jsxs(le, { variant: "ghost", onClick: pe, disabled: T, children: [
2309
+ /* @__PURE__ */ s.jsx(it, { className: "mr-1 h-4 w-4" }),
2310
+ " Cancel"
2311
+ ] }),
2312
+ (f === "mapping" || f === "preview") && /* @__PURE__ */ s.jsxs(le, { variant: "outline", onClick: () => d(f === "mapping" ? "upload" : "mapping"), disabled: T, children: [
2313
+ /* @__PURE__ */ s.jsx(tn, { className: "mr-1 h-4 w-4" }),
2314
+ " Back"
2315
+ ] }),
2316
+ f === "mapping" && /* @__PURE__ */ s.jsxs(le, { onClick: () => d("preview"), disabled: Object.keys(v).length === 0 || Ae.length > 0, children: [
2317
+ "Next ",
2318
+ /* @__PURE__ */ s.jsx(St, { className: "ml-1 h-4 w-4" })
2319
+ ] }),
2320
+ f === "preview" && /* @__PURE__ */ s.jsx(le, { onClick: Re, disabled: T, children: T ? "Importing…" : `Import ${x.length} Rows` })
2321
+ ] }) })
2322
+ ] }) });
1387
2323
  };
1388
- function Kt({
1389
- value: t,
1390
- onSave: c,
1391
- onCancel: e,
2324
+ function dr({
2325
+ value: e,
2326
+ onSave: o,
2327
+ onCancel: t,
1392
2328
  validate: n,
1393
- type: s = "text",
2329
+ type: r = "text",
1394
2330
  placeholder: i,
1395
- editing: o = !1,
2331
+ editing: a = !1,
1396
2332
  className: l,
1397
- disabled: g = !1
2333
+ disabled: h = !1
1398
2334
  }) {
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 () => {
2335
+ const [f, d] = F(a), [m, p] = F(String(e ?? "")), [x, j] = F(), [v, k] = F(!1), T = xe(null);
2336
+ me(() => {
2337
+ f || p(String(e ?? ""));
2338
+ }, [e, f]), me(() => {
2339
+ f && T.current && (T.current.focus(), T.current.select());
2340
+ }, [f]);
2341
+ const D = M(() => {
2342
+ h || (d(!0), p(String(e ?? "")), j(void 0));
2343
+ }, [h, e]), z = M(() => {
2344
+ d(!1), p(String(e ?? "")), j(void 0), t?.();
2345
+ }, [e, t]), G = M(async () => {
1410
2346
  if (n) {
1411
- const L = n(v);
1412
- if (L) {
1413
- y(L);
2347
+ const re = n(m);
2348
+ if (re) {
2349
+ j(re);
1414
2350
  return;
1415
2351
  }
1416
2352
  }
1417
- const k = s === "number" ? Number(v) : v;
1418
- S(!0);
2353
+ const H = r === "number" ? Number(m) : m;
2354
+ k(!0);
1419
2355
  try {
1420
- const L = await c(k);
1421
- if (typeof L == "string") {
1422
- y(L), S(!1);
2356
+ const re = await o(H);
2357
+ if (typeof re == "string") {
2358
+ j(re), k(!1);
1423
2359
  return;
1424
2360
  }
1425
- f(!1), y(void 0);
1426
- } catch (L) {
1427
- y(L?.message || "Save failed");
2361
+ d(!1), j(void 0);
2362
+ } catch (re) {
2363
+ j(re?.message || "Save failed");
1428
2364
  } finally {
1429
- S(!1);
2365
+ k(!1);
1430
2366
  }
1431
- }, [v, n, s, c]), K = $(
1432
- (k) => {
1433
- k.key === "Enter" ? (k.preventDefault(), A()) : k.key === "Escape" && (k.preventDefault(), F());
2367
+ }, [m, n, r, o]), W = M(
2368
+ (H) => {
2369
+ H.key === "Enter" ? (H.preventDefault(), G()) : H.key === "Escape" && (H.preventDefault(), z());
1434
2370
  },
1435
- [A, F]
2371
+ [G, z]
1436
2372
  );
1437
- return m ? /* @__PURE__ */ a.jsxs(
2373
+ return f ? /* @__PURE__ */ s.jsxs(
1438
2374
  "div",
1439
2375
  {
1440
2376
  "data-slot": "inline-editing",
1441
- className: fe("relative flex items-center gap-1", l),
2377
+ className: ue("relative flex items-center gap-1", l),
1442
2378
  children: [
1443
- /* @__PURE__ */ a.jsxs("div", { className: "flex-1 relative", children: [
1444
- /* @__PURE__ */ a.jsx(
2379
+ /* @__PURE__ */ s.jsxs("div", { className: "flex-1 relative", children: [
2380
+ /* @__PURE__ */ s.jsx(
1445
2381
  "input",
1446
2382
  {
1447
- ref: R,
2383
+ ref: T,
1448
2384
  "data-slot": "inline-editing-input",
1449
- type: s,
1450
- value: v,
1451
- onChange: (k) => {
1452
- u(k.target.value), d && y(void 0);
2385
+ type: r,
2386
+ value: m,
2387
+ onChange: (H) => {
2388
+ p(H.target.value), x && j(void 0);
1453
2389
  },
1454
- onKeyDown: K,
2390
+ onKeyDown: W,
1455
2391
  placeholder: i,
1456
- disabled: x,
1457
- "aria-invalid": !!d,
1458
- "aria-describedby": d ? "inline-editing-error" : void 0,
1459
- className: fe(
2392
+ disabled: v,
2393
+ "aria-invalid": !!x,
2394
+ "aria-describedby": x ? "inline-editing-error" : void 0,
2395
+ className: ue(
1460
2396
  "w-full rounded border px-2 py-1 text-sm outline-none transition-colors",
1461
2397
  "focus:ring-2 focus:ring-ring focus:border-input",
1462
- d ? "border-destructive focus:ring-destructive/30" : "border-input",
1463
- x && "opacity-50"
2398
+ x ? "border-destructive focus:ring-destructive/30" : "border-input",
2399
+ v && "opacity-50"
1464
2400
  )
1465
2401
  }
1466
2402
  ),
1467
- d && /* @__PURE__ */ a.jsx(
2403
+ x && /* @__PURE__ */ s.jsx(
1468
2404
  "p",
1469
2405
  {
1470
2406
  id: "inline-editing-error",
1471
2407
  "data-slot": "inline-editing-error",
1472
2408
  className: "absolute left-0 top-full mt-0.5 text-xs text-destructive",
1473
2409
  role: "alert",
1474
- children: d
2410
+ children: x
1475
2411
  }
1476
2412
  )
1477
2413
  ] }),
1478
- /* @__PURE__ */ a.jsx(
2414
+ /* @__PURE__ */ s.jsx(
1479
2415
  "button",
1480
2416
  {
1481
2417
  "data-slot": "inline-editing-save",
1482
2418
  type: "button",
1483
- onClick: A,
1484
- disabled: x,
2419
+ onClick: G,
2420
+ disabled: v,
1485
2421
  "aria-label": "Save",
1486
- className: fe(
2422
+ className: ue(
1487
2423
  "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"
2424
+ v && "opacity-50 cursor-not-allowed"
1489
2425
  ),
1490
- children: /* @__PURE__ */ a.jsx(at, { className: "h-3.5 w-3.5" })
2426
+ children: /* @__PURE__ */ s.jsx(Wt, { className: "h-3.5 w-3.5" })
1491
2427
  }
1492
2428
  ),
1493
- /* @__PURE__ */ a.jsx(
2429
+ /* @__PURE__ */ s.jsx(
1494
2430
  "button",
1495
2431
  {
1496
2432
  "data-slot": "inline-editing-cancel",
1497
2433
  type: "button",
1498
- onClick: F,
1499
- disabled: x,
2434
+ onClick: z,
2435
+ disabled: v,
1500
2436
  "aria-label": "Cancel",
1501
2437
  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" })
2438
+ children: /* @__PURE__ */ s.jsx(it, { className: "h-3.5 w-3.5" })
1503
2439
  }
1504
2440
  )
1505
2441
  ]
1506
2442
  }
1507
- ) : /* @__PURE__ */ a.jsx(
2443
+ ) : /* @__PURE__ */ s.jsx(
1508
2444
  "div",
1509
2445
  {
1510
2446
  "data-slot": "inline-editing",
1511
- className: fe(
2447
+ className: ue(
1512
2448
  "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",
2449
+ h && "cursor-default opacity-60",
1514
2450
  l
1515
2451
  ),
1516
- onClick: _,
2452
+ onClick: D,
1517
2453
  role: "button",
1518
- tabIndex: g ? -1 : 0,
1519
- onKeyDown: (k) => {
1520
- (k.key === "Enter" || k.key === " ") && (k.preventDefault(), _());
2454
+ tabIndex: h ? -1 : 0,
2455
+ onKeyDown: (H) => {
2456
+ (H.key === "Enter" || H.key === " ") && (H.preventDefault(), D());
1521
2457
  },
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" }) })
2458
+ "aria-label": `Edit value: ${String(e ?? "")}`,
2459
+ children: /* @__PURE__ */ s.jsx("span", { "data-slot": "inline-editing-display", className: "truncate text-sm", children: e != null && String(e) !== "" ? String(e) : /* @__PURE__ */ s.jsx("span", { className: "text-muted-foreground italic", children: i || "Click to edit" }) })
2460
+ }
2461
+ );
2462
+ }
2463
+ function zt(e) {
2464
+ return {
2465
+ startRow: Math.min(e.startRow, e.endRow),
2466
+ startCol: Math.min(e.startCol, e.endCol),
2467
+ endRow: Math.max(e.startRow, e.endRow),
2468
+ endCol: Math.max(e.startCol, e.endCol)
2469
+ };
2470
+ }
2471
+ function ur({
2472
+ data: e,
2473
+ columns: o,
2474
+ onPaste: t,
2475
+ enabled: n = !0
2476
+ }) {
2477
+ const [r, i] = F(null), a = M(() => {
2478
+ if (!n || !r) return;
2479
+ const { startRow: f, startCol: d, endRow: m, endCol: p } = zt(r), x = [];
2480
+ for (let v = f; v <= m; v++) {
2481
+ const k = e[v];
2482
+ if (!k) continue;
2483
+ const T = [];
2484
+ for (let D = d; D <= p; D++) {
2485
+ const z = o[D];
2486
+ T.push(z ? String(k[z] ?? "") : "");
2487
+ }
2488
+ x.push(T.join(" "));
1524
2489
  }
2490
+ const j = x.join(`
2491
+ `);
2492
+ navigator.clipboard.writeText(j);
2493
+ }, [n, r, e, o]), l = M(() => {
2494
+ if (!n || !r || !t) return;
2495
+ const { startRow: f, startCol: d } = zt(r);
2496
+ navigator.clipboard.readText().then((m) => {
2497
+ const p = [], x = m.split(`
2498
+ `);
2499
+ for (let j = 0; j < x.length; j++) {
2500
+ const v = x[j].split(" ");
2501
+ for (let k = 0; k < v.length; k++) {
2502
+ const T = f + j, D = d + k, z = o[D];
2503
+ z && T < e.length && p.push({ rowIndex: T, field: z, value: v[k] });
2504
+ }
2505
+ }
2506
+ p.length > 0 && t(p);
2507
+ });
2508
+ }, [n, r, o, e.length, t]), h = M(
2509
+ (f) => {
2510
+ if (!n) return;
2511
+ const d = f.metaKey || f.ctrlKey;
2512
+ d && f.key === "c" ? (f.preventDefault(), a()) : d && f.key === "v" && (f.preventDefault(), l());
2513
+ },
2514
+ [n, a, l]
1525
2515
  );
2516
+ return me(() => {
2517
+ n || i(null);
2518
+ }, [n]), { selectedRange: r, setSelectedRange: i, onCopy: a, onPaste: l, onKeyDown: h };
2519
+ }
2520
+ const Yn = [
2521
+ { position: 0, className: "bg-green-100" },
2522
+ { position: 0.5, className: "bg-yellow-100" },
2523
+ { position: 1, className: "bg-red-100" }
2524
+ ];
2525
+ function Jn(e, o) {
2526
+ let t = 1 / 0, n = -1 / 0;
2527
+ for (const r of e) {
2528
+ const i = Number(r[o]);
2529
+ Number.isFinite(i) && (i < t && (t = i), i > n && (n = i));
2530
+ }
2531
+ return Number.isFinite(t) ? [t, n] : [0, 0];
1526
2532
  }
1527
- const $e = ({ schema: t, ...c }) => {
1528
- const { dataSource: e } = Ze() || {};
1529
- return /* @__PURE__ */ a.jsx(St, { schema: t, dataSource: e, ...c });
2533
+ function Xn(e, o) {
2534
+ if (o.length === 0) return "";
2535
+ if (o.length === 1) return o[0].className;
2536
+ let t = o[0], n = Math.abs(e - t.position);
2537
+ for (let r = 1; r < o.length; r++) {
2538
+ const i = Math.abs(e - o[r].position);
2539
+ i < n && (t = o[r], n = i);
2540
+ }
2541
+ return t.className;
2542
+ }
2543
+ function fr(e) {
2544
+ const { field: o, data: t, min: n, max: r, stops: i = Yn } = e, [a, l] = ve(() => Jn(t, o), [t, o]), h = n ?? a, f = r ?? l;
2545
+ return M(
2546
+ (d) => {
2547
+ const m = Number(d[o]);
2548
+ if (!Number.isFinite(m)) return;
2549
+ if (f === h) return i.length > 0 ? i[0].className : void 0;
2550
+ const p = Math.max(0, Math.min(1, (m - h) / (f - h)));
2551
+ return Xn(p, i);
2552
+ },
2553
+ [o, h, f, i]
2554
+ );
2555
+ }
2556
+ const It = "text/x-group-key";
2557
+ function mr({ groupKeys: e }) {
2558
+ const [o, t] = F(e), [n, r] = F(null);
2559
+ me(() => {
2560
+ t((d) => {
2561
+ const m = new Set(d), p = new Set(e);
2562
+ if (d.length === e.length && d.every((v, k) => v === e[k]))
2563
+ return d;
2564
+ const x = d.filter((v) => p.has(v)), j = e.filter((v) => !m.has(v));
2565
+ return [...x, ...j];
2566
+ });
2567
+ }, [e]);
2568
+ const i = M((d, m) => {
2569
+ t((p) => {
2570
+ if (d < 0 || d >= p.length || m < 0 || m >= p.length || d === m) return p;
2571
+ const x = [...p], [j] = x.splice(d, 1);
2572
+ return x.splice(m, 0, j), x;
2573
+ });
2574
+ }, []), a = M((d, m) => {
2575
+ d.dataTransfer.effectAllowed = "move", d.dataTransfer.setData(It, m), r(m);
2576
+ }, []), l = M((d) => {
2577
+ d.preventDefault(), d.dataTransfer.dropEffect = "move";
2578
+ }, []), h = M(
2579
+ (d, m) => {
2580
+ d.preventDefault();
2581
+ const p = d.dataTransfer.getData(It);
2582
+ !p || p === m || t((x) => {
2583
+ const j = x.indexOf(p), v = x.indexOf(m);
2584
+ if (j === -1 || v === -1) return x;
2585
+ const k = [...x], [T] = k.splice(j, 1);
2586
+ return k.splice(v, 0, T), k;
2587
+ });
2588
+ },
2589
+ []
2590
+ ), f = M(() => {
2591
+ r(null);
2592
+ }, []);
2593
+ return {
2594
+ groupOrder: o,
2595
+ moveGroup: i,
2596
+ onDragStart: a,
2597
+ onDragOver: l,
2598
+ onDrop: h,
2599
+ onDragEnd: f,
2600
+ draggingKey: n
2601
+ };
2602
+ }
2603
+ function hr({
2604
+ value: e,
2605
+ onChange: o,
2606
+ onConfirm: t,
2607
+ onCancel: n,
2608
+ activeCell: r,
2609
+ disabled: i = !1,
2610
+ className: a
2611
+ }) {
2612
+ const [l, h] = F(!1), [f, d] = F(e), m = xe(null);
2613
+ me(() => {
2614
+ l || d(e);
2615
+ }, [e, l]), me(() => {
2616
+ l && m.current && (m.current.focus(), m.current.select());
2617
+ }, [l]);
2618
+ const p = M(() => {
2619
+ i || (h(!0), d(e));
2620
+ }, [i, e]), x = M(() => {
2621
+ h(!1), o?.(f), t?.(f);
2622
+ }, [f, o, t]), j = M(() => {
2623
+ h(!1), d(e), n?.();
2624
+ }, [e, n]), v = M(
2625
+ (k) => {
2626
+ k.key === "Enter" ? (k.preventDefault(), x()) : k.key === "Escape" && (k.preventDefault(), j());
2627
+ },
2628
+ [x, j]
2629
+ );
2630
+ return /* @__PURE__ */ s.jsxs(
2631
+ "div",
2632
+ {
2633
+ className: ue(
2634
+ "flex items-center gap-2 border-b border-border bg-muted/30 px-3 py-1.5",
2635
+ a
2636
+ ),
2637
+ children: [
2638
+ /* @__PURE__ */ s.jsx(nn, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
2639
+ r && /* @__PURE__ */ s.jsx("span", { className: "min-w-[4rem] shrink-0 rounded bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground", children: r }),
2640
+ /* @__PURE__ */ s.jsx(
2641
+ "input",
2642
+ {
2643
+ ref: m,
2644
+ type: "text",
2645
+ value: l ? f : e,
2646
+ readOnly: !l,
2647
+ disabled: i,
2648
+ onClick: p,
2649
+ onChange: (k) => d(k.target.value),
2650
+ onKeyDown: v,
2651
+ className: ue(
2652
+ "flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground",
2653
+ l && "rounded ring-1 ring-ring px-1",
2654
+ i && "cursor-not-allowed opacity-50"
2655
+ )
2656
+ }
2657
+ ),
2658
+ l && /* @__PURE__ */ s.jsxs("div", { className: "flex items-center gap-1", children: [
2659
+ /* @__PURE__ */ s.jsx(
2660
+ "button",
2661
+ {
2662
+ type: "button",
2663
+ onClick: x,
2664
+ className: "rounded p-0.5 text-green-600 hover:bg-green-100",
2665
+ "aria-label": "Confirm",
2666
+ children: /* @__PURE__ */ s.jsx(Wt, { className: "h-4 w-4" })
2667
+ }
2668
+ ),
2669
+ /* @__PURE__ */ s.jsx(
2670
+ "button",
2671
+ {
2672
+ type: "button",
2673
+ onClick: j,
2674
+ className: "rounded p-0.5 text-red-600 hover:bg-red-100",
2675
+ "aria-label": "Cancel",
2676
+ children: /* @__PURE__ */ s.jsx(it, { className: "h-4 w-4" })
2677
+ }
2678
+ )
2679
+ ] })
2680
+ ]
2681
+ }
2682
+ );
2683
+ }
2684
+ function pr({
2685
+ frozenWidth: e,
2686
+ onResize: o,
2687
+ minFrozenWidth: t = 100,
2688
+ minScrollableWidth: n = 200,
2689
+ left: r,
2690
+ right: i,
2691
+ className: a
2692
+ }) {
2693
+ const l = xe(null), [h, f] = F(e), d = xe(!1), m = xe(0), p = xe(0), x = o ? e : h, j = M(
2694
+ (v) => {
2695
+ v.preventDefault(), d.current = !0, m.current = v.clientX, p.current = x;
2696
+ const k = (D) => {
2697
+ if (!d.current || !l.current) return;
2698
+ const z = l.current.offsetWidth, G = D.clientX - m.current;
2699
+ let W = p.current + G;
2700
+ W = Math.max(W, t), W = Math.min(W, z - n), o ? o(W) : f(W);
2701
+ }, T = () => {
2702
+ d.current = !1, document.removeEventListener("pointermove", k), document.removeEventListener("pointerup", T);
2703
+ };
2704
+ document.addEventListener("pointermove", k), document.addEventListener("pointerup", T);
2705
+ },
2706
+ [x, t, n, o]
2707
+ );
2708
+ return /* @__PURE__ */ s.jsxs(
2709
+ "div",
2710
+ {
2711
+ ref: l,
2712
+ className: ue("flex h-full w-full overflow-hidden", a),
2713
+ children: [
2714
+ /* @__PURE__ */ s.jsx(
2715
+ "div",
2716
+ {
2717
+ className: "shrink-0 overflow-auto",
2718
+ style: { width: x },
2719
+ children: r
2720
+ }
2721
+ ),
2722
+ /* @__PURE__ */ s.jsx(
2723
+ "div",
2724
+ {
2725
+ role: "separator",
2726
+ "aria-orientation": "vertical",
2727
+ onPointerDown: j,
2728
+ className: ue(
2729
+ "flex w-2 cursor-col-resize items-center justify-center",
2730
+ "border-x border-border bg-muted/50 hover:bg-muted",
2731
+ "transition-colors"
2732
+ ),
2733
+ children: /* @__PURE__ */ s.jsx(rn, { className: "h-4 w-4 text-muted-foreground" })
2734
+ }
2735
+ ),
2736
+ /* @__PURE__ */ s.jsx("div", { className: "min-w-0 flex-1 overflow-auto", children: i })
2737
+ ]
2738
+ }
2739
+ );
2740
+ }
2741
+ const Ut = ({ schema: e, ...o }) => {
2742
+ const { dataSource: t } = Pt() || {};
2743
+ return /* @__PURE__ */ s.jsx(kn, { schema: e, dataSource: t, ...o });
1530
2744
  };
1531
- Fe.register("object-grid", $e, {
2745
+ rt.register("object-grid", Ut, {
1532
2746
  namespace: "plugin-grid",
1533
2747
  label: "Object Grid",
1534
2748
  category: "plugin",
@@ -1538,7 +2752,7 @@ Fe.register("object-grid", $e, {
1538
2752
  { name: "filters", type: "array", label: "Filters" }
1539
2753
  ]
1540
2754
  });
1541
- Fe.register("grid", $e, {
2755
+ rt.register("grid", Ut, {
1542
2756
  namespace: "view",
1543
2757
  label: "Data Grid",
1544
2758
  category: "view",
@@ -1548,11 +2762,44 @@ Fe.register("grid", $e, {
1548
2762
  { name: "filters", type: "array", label: "Filters" }
1549
2763
  ]
1550
2764
  });
2765
+ const Qn = ({ schema: e, ...o }) => {
2766
+ const { dataSource: t } = Pt() || {};
2767
+ return /* @__PURE__ */ s.jsx(
2768
+ Hn,
2769
+ {
2770
+ objectName: e.objectName,
2771
+ objectLabel: e.objectLabel,
2772
+ fields: e.fields ?? [],
2773
+ dataSource: t,
2774
+ ...o
2775
+ }
2776
+ );
2777
+ };
2778
+ rt.register("import-wizard", Qn, {
2779
+ namespace: "plugin-grid",
2780
+ label: "Import Wizard",
2781
+ category: "plugin",
2782
+ inputs: [
2783
+ { name: "objectName", type: "string", label: "Object Name", required: !0 },
2784
+ { name: "fields", type: "array", label: "Fields", required: !0 }
2785
+ ]
2786
+ });
1551
2787
  export {
1552
- Kt as InlineEditing,
1553
- St as ObjectGrid,
1554
- $e as ObjectGridRenderer,
1555
- Gt as VirtualGrid,
1556
- wt as useGroupedData,
1557
- xt as useRowColor
2788
+ _t as BulkActionBar,
2789
+ hr as FormulaBar,
2790
+ vn as GroupRow,
2791
+ Hn as ImportWizard,
2792
+ dr as InlineEditing,
2793
+ kn as ObjectGrid,
2794
+ Ut as ObjectGridRenderer,
2795
+ Sn as RowActionMenu,
2796
+ pr as SplitPaneGrid,
2797
+ cr as VirtualGrid,
2798
+ ot as formatActionLabel,
2799
+ ur as useCellClipboard,
2800
+ Cn as useColumnSummary,
2801
+ fr as useGradientColor,
2802
+ mr as useGroupReorder,
2803
+ yn as useGroupedData,
2804
+ hn as useRowColor
1558
2805
  };