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