@object-ui/plugin-grid 3.0.3 → 3.1.1

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