@object-ui/plugin-grid 3.3.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +82 -0
- package/dist/index.js +823 -602
- package/dist/index.umd.cjs +8 -8
- package/dist/packages/plugin-grid/src/ImportWizard.d.ts +40 -0
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -3,17 +3,17 @@ import t, { createContext as n, useCallback as r, useEffect as i, useMemo as a,
|
|
|
3
3
|
import { ComponentRegistry as c, buildExpandFields as l, evaluatePlainCondition as u } from "@object-ui/core";
|
|
4
4
|
import { SchemaRenderer as d, useAction as f, useDataScope as p, useNavigationOverlay as m, useObjectTranslation as h, useSafeFieldLabel as g, useSchemaContext as _ } from "@object-ui/react";
|
|
5
5
|
import { formatCompactCurrency as v, formatCurrency as y, formatDate as b, formatPercent as x, getCellRenderer as S, humanizeLabel as C } from "@object-ui/fields";
|
|
6
|
-
import { Badge as w, Button as T, Dialog as ee, DialogContent as te, DialogDescription as ne, DialogFooter as re, DialogHeader as E, DialogTitle as ie, DropdownMenu as D, DropdownMenuContent as O, DropdownMenuItem as k, DropdownMenuTrigger as A, EmptyValue as ae, NavigationOverlay as
|
|
7
|
-
import { AlertCircle as
|
|
8
|
-
import { flushSync as
|
|
6
|
+
import { Badge as w, Button as T, Dialog as ee, DialogContent as te, DialogDescription as ne, DialogFooter as re, DialogHeader as E, DialogTitle as ie, DropdownMenu as D, DropdownMenuContent as O, DropdownMenuItem as k, DropdownMenuTrigger as A, EmptyValue as j, ExportProgressDialog as ae, Input as M, NavigationOverlay as oe, Popover as se, PopoverContent as N, PopoverTrigger as P, Progress as ce, Select as F, SelectContent as I, SelectItem as L, SelectTrigger as R, SelectValue as le, Table as ue, TableBody as de, TableCell as z, TableHead as B, TableHeader as fe, TableRow as V, cn as H, useExportJob as pe } from "@object-ui/components";
|
|
7
|
+
import { AlertCircle as U, AlignJustify as me, ArrowLeft as he, ArrowRight as ge, Calendar as _e, Check as ve, CheckCircle2 as ye, CheckSquare as be, ChevronDown as W, ChevronRight as xe, Clock as Se, Download as Ce, Edit as we, FileSpreadsheet as Te, FunctionSquare as Ee, GripVertical as De, Hash as Oe, MoreVertical as ke, Rows2 as Ae, Rows3 as je, Rows4 as Me, Save as Ne, Tag as Pe, Trash2 as Fe, Type as Ie, Upload as G, User as Le, X as K } from "lucide-react";
|
|
8
|
+
import { flushSync as q } from "react-dom";
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
|
-
var
|
|
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
11
|
if (typeof require < "u") return require.apply(this, arguments);
|
|
12
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
13
|
});
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region ../mobile/dist/usePullToRefresh.js
|
|
16
|
-
function
|
|
16
|
+
function Re(e) {
|
|
17
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
18
|
if (!a || l) return;
|
|
19
19
|
let t = c.current;
|
|
@@ -62,7 +62,7 @@ function ze(e) {
|
|
|
62
62
|
}
|
|
63
63
|
//#endregion
|
|
64
64
|
//#region ../../node_modules/.pnpm/react@19.2.5/node_modules/react/cjs/react-jsx-runtime.production.js
|
|
65
|
-
var
|
|
65
|
+
var ze = /* @__PURE__ */ J(((e) => {
|
|
66
66
|
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
67
67
|
function r(e, n, r) {
|
|
68
68
|
var i = null;
|
|
@@ -77,7 +77,7 @@ var G = /* @__PURE__ */ W(((e) => {
|
|
|
77
77
|
};
|
|
78
78
|
}
|
|
79
79
|
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
80
|
-
})),
|
|
80
|
+
})), X = /* @__PURE__ */ J(((e) => {
|
|
81
81
|
process.env.NODE_ENV !== "production" && (function() {
|
|
82
82
|
function t(e) {
|
|
83
83
|
if (e == null) return null;
|
|
@@ -208,7 +208,7 @@ var G = /* @__PURE__ */ W(((e) => {
|
|
|
208
208
|
var m = Object.keys(n).filter(function(e) {
|
|
209
209
|
return e !== "key";
|
|
210
210
|
});
|
|
211
|
-
o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}",
|
|
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
212
|
}
|
|
213
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
214
|
else i = n;
|
|
@@ -220,28 +220,28 @@ var G = /* @__PURE__ */ W(((e) => {
|
|
|
220
220
|
function p(e) {
|
|
221
221
|
return typeof e == "object" && !!e && e.$$typeof === h;
|
|
222
222
|
}
|
|
223
|
-
var m =
|
|
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
224
|
return null;
|
|
225
225
|
};
|
|
226
226
|
m = { react_stack_bottom_frame: function(e) {
|
|
227
227
|
return e();
|
|
228
228
|
} };
|
|
229
|
-
var O, k = {}, A = m.react_stack_bottom_frame.bind(m, o)(),
|
|
229
|
+
var O, k = {}, A = m.react_stack_bottom_frame.bind(m, o)(), j = D(i(o)), ae = {};
|
|
230
230
|
e.Fragment = _, e.jsx = function(e, t, n) {
|
|
231
231
|
var r = 1e4 > re.recentlyCreatedOwnerStacks++;
|
|
232
|
-
return d(e, t, n, !1, r ? Error("react-stack-top-frame") : A, r ? D(i(e)) :
|
|
232
|
+
return d(e, t, n, !1, r ? Error("react-stack-top-frame") : A, r ? D(i(e)) : j);
|
|
233
233
|
}, e.jsxs = function(e, t, n) {
|
|
234
234
|
var r = 1e4 > re.recentlyCreatedOwnerStacks++;
|
|
235
|
-
return d(e, t, n, !0, r ? Error("react-stack-top-frame") : A, r ? D(i(e)) :
|
|
235
|
+
return d(e, t, n, !0, r ? Error("react-stack-top-frame") : A, r ? D(i(e)) : j);
|
|
236
236
|
};
|
|
237
237
|
})();
|
|
238
|
-
})),
|
|
239
|
-
process.env.NODE_ENV === "production" ? t.exports =
|
|
240
|
-
})))(),
|
|
241
|
-
|
|
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
242
|
//#endregion
|
|
243
243
|
//#region src/useRowColor.ts
|
|
244
|
-
var
|
|
244
|
+
var Ve = {
|
|
245
245
|
red: "bg-red-100",
|
|
246
246
|
green: "bg-green-100",
|
|
247
247
|
blue: "bg-blue-100",
|
|
@@ -266,14 +266,14 @@ var q = {
|
|
|
266
266
|
stone: "bg-stone-100",
|
|
267
267
|
neutral: "bg-neutral-100"
|
|
268
268
|
};
|
|
269
|
-
function
|
|
270
|
-
return e.startsWith("bg-") ? e :
|
|
269
|
+
function Q(e) {
|
|
270
|
+
return e.startsWith("bg-") ? e : Ve[e.toLowerCase().trim()];
|
|
271
271
|
}
|
|
272
272
|
function He(e) {
|
|
273
273
|
return r((t) => {
|
|
274
274
|
if (!e?.field || !e.colors) return;
|
|
275
275
|
let n = String(t[e.field] ?? ""), r = e.colors[n];
|
|
276
|
-
if (r) return
|
|
276
|
+
if (r) return Q(r);
|
|
277
277
|
}, [e?.field, e?.colors]);
|
|
278
278
|
}
|
|
279
279
|
//#endregion
|
|
@@ -365,23 +365,23 @@ function qe(e, t, n) {
|
|
|
365
365
|
}
|
|
366
366
|
//#endregion
|
|
367
367
|
//#region src/GroupRow.tsx
|
|
368
|
-
var Je = ({ groupKey: e, label: t, count: n, collapsed: r, aggregations: i, onToggle: a, children: o }) => /* @__PURE__ */ (0,
|
|
368
|
+
var Je = ({ groupKey: e, label: t, count: n, collapsed: r, aggregations: i, onToggle: a, children: o }) => /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
369
369
|
className: "border rounded-md",
|
|
370
370
|
"data-testid": `group-row-${e}`,
|
|
371
|
-
children: [/* @__PURE__ */ (0,
|
|
371
|
+
children: [/* @__PURE__ */ (0, Z.jsxs)("button", {
|
|
372
372
|
type: "button",
|
|
373
373
|
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",
|
|
374
374
|
onClick: () => a(e),
|
|
375
375
|
"aria-expanded": !r,
|
|
376
376
|
children: [
|
|
377
|
-
r ? /* @__PURE__ */ (0,
|
|
378
|
-
/* @__PURE__ */ (0,
|
|
377
|
+
r ? /* @__PURE__ */ (0, Z.jsx)(xe, { className: "h-4 w-4 shrink-0" }) : /* @__PURE__ */ (0, Z.jsx)(W, { className: "h-4 w-4 shrink-0" }),
|
|
378
|
+
/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
379
379
|
className: "group-label",
|
|
380
380
|
children: t
|
|
381
381
|
}),
|
|
382
|
-
i && i.length > 0 && /* @__PURE__ */ (0,
|
|
382
|
+
i && i.length > 0 && /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
383
383
|
className: "ml-2 text-xs text-muted-foreground group-aggregations",
|
|
384
|
-
children: i.map((e) => /* @__PURE__ */ (0,
|
|
384
|
+
children: i.map((e) => /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
385
385
|
className: "mr-2",
|
|
386
386
|
children: [
|
|
387
387
|
e.type,
|
|
@@ -390,7 +390,7 @@ var Je = ({ groupKey: e, label: t, count: n, collapsed: r, aggregations: i, onTo
|
|
|
390
390
|
]
|
|
391
391
|
}, `${e.field}-${e.type}`))
|
|
392
392
|
}),
|
|
393
|
-
/* @__PURE__ */ (0,
|
|
393
|
+
/* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
394
394
|
className: "ml-auto text-xs text-muted-foreground group-count",
|
|
395
395
|
children: [
|
|
396
396
|
"(",
|
|
@@ -466,46 +466,46 @@ function Qe(e, t) {
|
|
|
466
466
|
function $e(e) {
|
|
467
467
|
return e.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
468
468
|
}
|
|
469
|
-
var et = ({ row: e, rowActions: t, canEdit: n, canDelete: r, onEdit: i, onDelete: a, onAction: o }) => /* @__PURE__ */ (0,
|
|
469
|
+
var et = ({ row: e, rowActions: t, canEdit: n, canDelete: r, onEdit: i, onDelete: a, onAction: o }) => /* @__PURE__ */ (0, Z.jsxs)(D, { children: [/* @__PURE__ */ (0, Z.jsx)(A, {
|
|
470
470
|
asChild: !0,
|
|
471
|
-
children: /* @__PURE__ */ (0,
|
|
471
|
+
children: /* @__PURE__ */ (0, Z.jsxs)(T, {
|
|
472
472
|
variant: "ghost",
|
|
473
473
|
size: "icon",
|
|
474
474
|
className: "h-8 w-8 min-h-[44px] min-w-[44px] sm:min-h-0 sm:min-w-0",
|
|
475
475
|
"data-testid": "row-action-trigger",
|
|
476
|
-
children: [/* @__PURE__ */ (0,
|
|
476
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(ke, { className: "h-4 w-4" }), /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
477
477
|
className: "sr-only",
|
|
478
478
|
children: "Open menu"
|
|
479
479
|
})]
|
|
480
480
|
})
|
|
481
|
-
}), /* @__PURE__ */ (0,
|
|
481
|
+
}), /* @__PURE__ */ (0, Z.jsxs)(O, {
|
|
482
482
|
align: "end",
|
|
483
483
|
children: [
|
|
484
|
-
n && i && /* @__PURE__ */ (0,
|
|
484
|
+
n && i && /* @__PURE__ */ (0, Z.jsxs)(k, {
|
|
485
485
|
onClick: () => i(e),
|
|
486
|
-
children: [/* @__PURE__ */ (0,
|
|
486
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(we, { className: "mr-2 h-4 w-4" }), "Edit"]
|
|
487
487
|
}),
|
|
488
|
-
r && a && /* @__PURE__ */ (0,
|
|
488
|
+
r && a && /* @__PURE__ */ (0, Z.jsxs)(k, {
|
|
489
489
|
onClick: () => a(e),
|
|
490
|
-
children: [/* @__PURE__ */ (0,
|
|
490
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(Fe, { className: "mr-2 h-4 w-4" }), "Delete"]
|
|
491
491
|
}),
|
|
492
|
-
t?.map((t) => /* @__PURE__ */ (0,
|
|
492
|
+
t?.map((t) => /* @__PURE__ */ (0, Z.jsx)(k, {
|
|
493
493
|
onClick: () => o?.(t, e),
|
|
494
494
|
"data-testid": `row-action-${t}`,
|
|
495
495
|
children: $e(t)
|
|
496
496
|
}, t))
|
|
497
497
|
]
|
|
498
|
-
})] }), tt = ({ selectedRows: e, actions: t, onAction: n, onClearSelection: r }) => !t || t.length === 0 || e.length === 0 ? null : /* @__PURE__ */ (0,
|
|
498
|
+
})] }), tt = ({ selectedRows: e, actions: t, onAction: n, onClearSelection: r }) => !t || t.length === 0 || e.length === 0 ? null : /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
499
499
|
className: "border-t px-4 py-1.5 flex items-center gap-2 text-xs bg-primary/5 shrink-0",
|
|
500
500
|
"data-testid": "bulk-actions-bar",
|
|
501
501
|
children: [
|
|
502
|
-
/* @__PURE__ */ (0,
|
|
502
|
+
/* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
503
503
|
className: "text-muted-foreground font-medium",
|
|
504
504
|
children: [e.length, " selected"]
|
|
505
505
|
}),
|
|
506
|
-
/* @__PURE__ */ (0,
|
|
506
|
+
/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
507
507
|
className: "flex items-center gap-1 ml-2",
|
|
508
|
-
children: t.map((t) => /* @__PURE__ */ (0,
|
|
508
|
+
children: t.map((t) => /* @__PURE__ */ (0, Z.jsx)(T, {
|
|
509
509
|
variant: "outline",
|
|
510
510
|
size: "sm",
|
|
511
511
|
className: "h-6 px-2 text-xs",
|
|
@@ -514,7 +514,7 @@ var et = ({ row: e, rowActions: t, canEdit: n, canDelete: r, onEdit: i, onDelete
|
|
|
514
514
|
children: $e(t)
|
|
515
515
|
}, t))
|
|
516
516
|
}),
|
|
517
|
-
/* @__PURE__ */ (0,
|
|
517
|
+
/* @__PURE__ */ (0, Z.jsx)(T, {
|
|
518
518
|
variant: "ghost",
|
|
519
519
|
size: "sm",
|
|
520
520
|
className: "h-6 px-2 text-xs ml-auto",
|
|
@@ -522,7 +522,7 @@ var et = ({ row: e, rowActions: t, canEdit: n, canDelete: r, onEdit: i, onDelete
|
|
|
522
522
|
children: "Clear"
|
|
523
523
|
})
|
|
524
524
|
]
|
|
525
|
-
}),
|
|
525
|
+
}), nt = {
|
|
526
526
|
"grid.actions": "Actions",
|
|
527
527
|
"grid.edit": "Edit",
|
|
528
528
|
"grid.delete": "Delete",
|
|
@@ -534,26 +534,26 @@ var et = ({ row: e, rowActions: t, canEdit: n, canDelete: r, onEdit: i, onDelete
|
|
|
534
534
|
"grid.refreshing": "Refreshing…",
|
|
535
535
|
"grid.openRecord": "Open record"
|
|
536
536
|
};
|
|
537
|
-
function
|
|
537
|
+
function rt() {
|
|
538
538
|
try {
|
|
539
539
|
let e = h();
|
|
540
540
|
return e.t("grid.actions") === "grid.actions" ? { t: (e, t) => {
|
|
541
|
-
let n =
|
|
541
|
+
let n = nt[e] || e;
|
|
542
542
|
if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
|
|
543
543
|
return n;
|
|
544
544
|
} } : { t: e.t };
|
|
545
545
|
} catch {
|
|
546
546
|
return { t: (e, t) => {
|
|
547
|
-
let n =
|
|
547
|
+
let n = nt[e] || e;
|
|
548
548
|
if (t) for (let [e, r] of Object.entries(t)) n = n.replace(`{{${e}}}`, String(r));
|
|
549
549
|
return n;
|
|
550
550
|
} };
|
|
551
551
|
}
|
|
552
552
|
}
|
|
553
|
-
function
|
|
553
|
+
function it(e) {
|
|
554
554
|
if (e != null) return typeof e == "string" ? e : void 0;
|
|
555
555
|
}
|
|
556
|
-
function
|
|
556
|
+
function at(e) {
|
|
557
557
|
return e.data ? Array.isArray(e.data) ? {
|
|
558
558
|
provider: "value",
|
|
559
559
|
items: e.data
|
|
@@ -565,101 +565,101 @@ function it(e) {
|
|
|
565
565
|
object: e.objectName
|
|
566
566
|
} : null;
|
|
567
567
|
}
|
|
568
|
-
function
|
|
568
|
+
function ot(e) {
|
|
569
569
|
if (!(!e || e.length === 0)) return typeof e[0] == "object" && e[0], e;
|
|
570
570
|
}
|
|
571
|
-
var
|
|
572
|
-
let [E, ie] = s([]), [D, O] = s(!0), [k, A] = s(null), { t: M } =
|
|
571
|
+
var st = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, onRowClick: h, onCellChange: _, onRowSave: ee, onBatchSave: te, onAddRecord: ne, ...re }) => {
|
|
572
|
+
let [E, ie] = s([]), [D, O] = s(!0), [k, A] = s(null), { t: M } = rt(), { fieldLabel: ce, translateOptions: F } = g(), [I, L] = s(null), [R, le] = s(!1), [ue, de] = s(0), [z, B] = s(!1), [fe, V] = s(!1), H = pe({ dataSource: n }), [U, he] = s(e.rowHeight ?? "compact"), [ge, ve] = s([]), ye = t.useMemo(() => e.id ? `grid-columns-${e.objectName}-${e.id}` : `grid-columns-${e.objectName}`, [e.objectName, e.id]), [W, xe] = s(() => {
|
|
573
573
|
try {
|
|
574
|
-
let e = localStorage.getItem(
|
|
574
|
+
let e = localStorage.getItem(ye);
|
|
575
575
|
return e ? JSON.parse(e) : {};
|
|
576
576
|
} catch {
|
|
577
577
|
return {};
|
|
578
578
|
}
|
|
579
|
-
}),
|
|
580
|
-
|
|
579
|
+
}), we = r((e) => {
|
|
580
|
+
xe(e);
|
|
581
581
|
try {
|
|
582
|
-
localStorage.setItem(
|
|
582
|
+
localStorage.setItem(ye, JSON.stringify(e));
|
|
583
583
|
} catch (e) {
|
|
584
584
|
console.warn("Failed to persist column state:", e);
|
|
585
585
|
}
|
|
586
|
-
}, [
|
|
586
|
+
}, [ye]), { ref: Te, isRefreshing: Ee, pullDistance: De } = Re({
|
|
587
587
|
onRefresh: r(async () => {
|
|
588
|
-
|
|
588
|
+
de((e) => e + 1);
|
|
589
589
|
}, []),
|
|
590
590
|
enabled: !!n && !!e.objectName
|
|
591
591
|
});
|
|
592
592
|
i(() => {
|
|
593
|
-
let e = () =>
|
|
593
|
+
let e = () => le(window.innerWidth < 480);
|
|
594
594
|
return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
|
|
595
595
|
}, []);
|
|
596
|
-
let
|
|
597
|
-
provider: "value",
|
|
598
|
-
items: Oe
|
|
599
|
-
} : ke && Array.isArray(ke) ? {
|
|
596
|
+
let ke = re.data, Ne = p(e.bind), Fe = at(e), G = t.useMemo(() => ke && Array.isArray(ke) ? {
|
|
600
597
|
provider: "value",
|
|
601
598
|
items: ke
|
|
602
|
-
} :
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
599
|
+
} : Ne && Array.isArray(Ne) ? {
|
|
600
|
+
provider: "value",
|
|
601
|
+
items: Ne
|
|
602
|
+
} : Fe, [
|
|
603
|
+
JSON.stringify(Fe),
|
|
604
|
+
Ne,
|
|
605
|
+
ke
|
|
606
|
+
]), K = G?.provider === "value", q = G?.provider === "object" && G && "object" in G ? G.object : e.objectName, J = e.fields, Y = e.columns, ze = e.filter, X = e.sort, Be = e.pagination, Ve = e.pageSize;
|
|
607
607
|
i(() => {
|
|
608
|
-
|
|
609
|
-
let t =
|
|
608
|
+
K && G?.provider === "value" && (ie((e) => {
|
|
609
|
+
let t = G.items;
|
|
610
610
|
return JSON.stringify(e) === JSON.stringify(t) ? e : t;
|
|
611
611
|
}), O(!1));
|
|
612
|
-
}, [
|
|
613
|
-
if (!
|
|
612
|
+
}, [K, G]), i(() => {
|
|
613
|
+
if (!K || !q || !n) return;
|
|
614
614
|
let e = !1;
|
|
615
615
|
return (async () => {
|
|
616
616
|
try {
|
|
617
617
|
if (typeof n.getObjectSchema != "function") return;
|
|
618
|
-
let t = await n.getObjectSchema(
|
|
619
|
-
e ||
|
|
618
|
+
let t = await n.getObjectSchema(q);
|
|
619
|
+
e || L(t);
|
|
620
620
|
} catch (e) {
|
|
621
|
-
console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${
|
|
621
|
+
console.warn(`[ObjectGrid] Failed to fetch objectSchema for inline data (objectName: ${q}):`, e);
|
|
622
622
|
}
|
|
623
623
|
})(), () => {
|
|
624
624
|
e = !0;
|
|
625
625
|
};
|
|
626
626
|
}, [
|
|
627
|
-
|
|
628
|
-
|
|
627
|
+
K,
|
|
628
|
+
q,
|
|
629
629
|
n
|
|
630
630
|
]), i(() => {
|
|
631
|
-
if (
|
|
631
|
+
if (K) return;
|
|
632
632
|
let t = !1;
|
|
633
633
|
return (async () => {
|
|
634
634
|
O(!0), A(null);
|
|
635
635
|
try {
|
|
636
|
-
let r = null, i =
|
|
637
|
-
if (
|
|
638
|
-
let e = await n.getObjectSchema(
|
|
636
|
+
let r = null, i = ot(Y) || J;
|
|
637
|
+
if (q && n) if (typeof n.getObjectSchema == "function") {
|
|
638
|
+
let e = await n.getObjectSchema(q);
|
|
639
639
|
if (t) return;
|
|
640
640
|
r = e;
|
|
641
641
|
} else r = {
|
|
642
|
-
name:
|
|
642
|
+
name: q,
|
|
643
643
|
fields: {}
|
|
644
644
|
};
|
|
645
|
-
else if (i &&
|
|
646
|
-
name:
|
|
645
|
+
else if (i && q) r = {
|
|
646
|
+
name: q,
|
|
647
647
|
fields: {}
|
|
648
648
|
};
|
|
649
|
-
else if (
|
|
649
|
+
else if (q) throw Error("DataSource required");
|
|
650
650
|
else throw Error("Object name required for data fetching");
|
|
651
|
-
if (t ||
|
|
651
|
+
if (t || L(r), n && q) {
|
|
652
652
|
let i = {
|
|
653
653
|
$select: (() => {
|
|
654
|
-
if (
|
|
655
|
-
if (
|
|
654
|
+
if (J) return J;
|
|
655
|
+
if (Y && Array.isArray(Y)) return Y.map((e) => typeof e == "string" ? e : e.field);
|
|
656
656
|
})(),
|
|
657
657
|
$top: Be?.pageSize || Ve || 50
|
|
658
658
|
};
|
|
659
|
-
|
|
660
|
-
let a = l(r?.fields,
|
|
659
|
+
ze && Array.isArray(ze) ? i.$filter = ze : e.defaultFilters && (i.$filter = e.defaultFilters), X ? typeof X == "string" ? i.$orderby = X : Array.isArray(X) && (i.$orderby = X.map((e) => `${e.field} ${e.order}`).join(", ")) : e.defaultSort && (i.$orderby = `${e.defaultSort.field} ${e.defaultSort.order}`);
|
|
660
|
+
let a = l(r?.fields, Y ?? J);
|
|
661
661
|
a.length > 0 && (i.$expand = a);
|
|
662
|
-
let o = await n.find(
|
|
662
|
+
let o = await n.find(q, i);
|
|
663
663
|
if (t) return;
|
|
664
664
|
ie(o.data || []);
|
|
665
665
|
}
|
|
@@ -672,24 +672,24 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
672
672
|
t = !0;
|
|
673
673
|
};
|
|
674
674
|
}, [
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
675
|
+
q,
|
|
676
|
+
J,
|
|
677
|
+
Y,
|
|
678
|
+
ze,
|
|
679
|
+
X,
|
|
680
680
|
Be,
|
|
681
681
|
Ve,
|
|
682
682
|
n,
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
683
|
+
K,
|
|
684
|
+
G,
|
|
685
|
+
ue
|
|
686
686
|
]);
|
|
687
|
-
let
|
|
687
|
+
let Q = m({
|
|
688
688
|
navigation: e.navigation,
|
|
689
689
|
objectName: e.objectName,
|
|
690
690
|
onNavigate: e.onNavigate,
|
|
691
691
|
onRowClick: h
|
|
692
|
-
}), { execute:
|
|
692
|
+
}), { execute: Ue } = f(), We = He(e.rowColor), Ge = r((t) => {
|
|
693
693
|
let n = e.conditionalFormatting;
|
|
694
694
|
if (!(!n || n.length === 0)) for (let e of n) {
|
|
695
695
|
let n = !1, r = ("condition" in e ? e.condition : void 0) || ("expression" in e ? e.expression : void 0) || void 0;
|
|
@@ -722,21 +722,21 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
722
722
|
return "style" in e && e.style && Object.assign(t, e.style), "backgroundColor" in e && e.backgroundColor && (t.backgroundColor = e.backgroundColor), "textColor" in e && e.textColor && (t.color = e.textColor), "borderColor" in e && e.borderColor && (t.borderColor = e.borderColor), t;
|
|
723
723
|
}
|
|
724
724
|
}
|
|
725
|
-
}, [e.conditionalFormatting]), { groups:
|
|
726
|
-
let t =
|
|
725
|
+
}, [e.conditionalFormatting]), { groups: Ke, isGrouped: Ye, toggleGroup: Xe } = qe(e.grouping, E), { summaries: Ze, hasSummary: nt } = Qe(t.useMemo(() => {
|
|
726
|
+
let t = ot(e.columns);
|
|
727
727
|
if (t && t.length > 0 && typeof t[0] == "object") return t;
|
|
728
|
-
}, [e.columns]), E),
|
|
728
|
+
}, [e.columns]), E), st = r(() => {
|
|
729
729
|
let t = (e) => e && {
|
|
730
|
-
text: /* @__PURE__ */ (0,
|
|
731
|
-
number: /* @__PURE__ */ (0,
|
|
732
|
-
currency: /* @__PURE__ */ (0,
|
|
733
|
-
percent: /* @__PURE__ */ (0,
|
|
734
|
-
date: /* @__PURE__ */ (0,
|
|
735
|
-
datetime: /* @__PURE__ */ (0,
|
|
736
|
-
boolean: /* @__PURE__ */ (0,
|
|
737
|
-
user: /* @__PURE__ */ (0,
|
|
738
|
-
select: /* @__PURE__ */ (0,
|
|
739
|
-
}[e] || /* @__PURE__ */ (0,
|
|
730
|
+
text: /* @__PURE__ */ (0, Z.jsx)(Ie, { className: "h-3.5 w-3.5" }),
|
|
731
|
+
number: /* @__PURE__ */ (0, Z.jsx)(Oe, { className: "h-3.5 w-3.5" }),
|
|
732
|
+
currency: /* @__PURE__ */ (0, Z.jsx)(Oe, { className: "h-3.5 w-3.5" }),
|
|
733
|
+
percent: /* @__PURE__ */ (0, Z.jsx)(Oe, { className: "h-3.5 w-3.5" }),
|
|
734
|
+
date: /* @__PURE__ */ (0, Z.jsx)(_e, { className: "h-3.5 w-3.5" }),
|
|
735
|
+
datetime: /* @__PURE__ */ (0, Z.jsx)(Se, { className: "h-3.5 w-3.5" }),
|
|
736
|
+
boolean: /* @__PURE__ */ (0, Z.jsx)(be, { className: "h-3.5 w-3.5" }),
|
|
737
|
+
user: /* @__PURE__ */ (0, Z.jsx)(Le, { className: "h-3.5 w-3.5" }),
|
|
738
|
+
select: /* @__PURE__ */ (0, Z.jsx)(Pe, { className: "h-3.5 w-3.5" })
|
|
739
|
+
}[e] || /* @__PURE__ */ (0, Z.jsx)(Ie, { className: "h-3.5 w-3.5" }), n = (e) => {
|
|
740
740
|
if (e.type) return e.type;
|
|
741
741
|
let t = e.field.toLowerCase();
|
|
742
742
|
if ([
|
|
@@ -815,7 +815,7 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
815
815
|
if (typeof t == "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/.test(t)) return "datetime";
|
|
816
816
|
}
|
|
817
817
|
return null;
|
|
818
|
-
}, r =
|
|
818
|
+
}, r = ot(Y);
|
|
819
819
|
if (r) {
|
|
820
820
|
if (r.length > 0 && typeof r[0] == "object" && r[0] !== null) {
|
|
821
821
|
let i = r[0];
|
|
@@ -837,43 +837,43 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
837
837
|
}))), {
|
|
838
838
|
...r,
|
|
839
839
|
...e.showColumnTypeIcons && { headerIcon: t(i) },
|
|
840
|
-
cell: (e) => /* @__PURE__ */ (0,
|
|
840
|
+
cell: (e) => /* @__PURE__ */ (0, Z.jsx)(a, {
|
|
841
841
|
value: e,
|
|
842
842
|
field: o
|
|
843
843
|
})
|
|
844
844
|
};
|
|
845
845
|
});
|
|
846
846
|
if ("field" in i) return r.filter((e) => e?.field && typeof e.field == "string" && !e.hidden).map((r, i) => {
|
|
847
|
-
let a =
|
|
847
|
+
let a = it(r.label) || r.field.charAt(0).toUpperCase() + r.field.slice(1).replace(/_/g, " "), o = e.objectName ? ce(e.objectName, r.field, a) : a, s, c = I?.fields?.[r.field], l = r.type || c?.type || n({ field: r.field }) || null, u = l ? S(l) : null, d = {
|
|
848
848
|
name: r.field,
|
|
849
849
|
type: l || "text"
|
|
850
850
|
};
|
|
851
|
-
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 =
|
|
851
|
+
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 = F(e.objectName, r.field, c.options))), l === "select" && !d.options && (d.options = Array.from(new Set(E.map((e) => e[r.field]).filter(Boolean))).map((e) => ({
|
|
852
852
|
value: e,
|
|
853
853
|
label: C(String(e))
|
|
854
|
-
}))), r.options && (d.options =
|
|
854
|
+
}))), r.options && (d.options = F(e.objectName, r.field, r.options));
|
|
855
855
|
let f = i === 0 && !r.link && !r.action, p = r.link || f;
|
|
856
|
-
s = r.link && r.action || f && r.action || p ? (e, t) => /* @__PURE__ */ (0,
|
|
856
|
+
s = r.link && r.action || f && r.action || p ? (e, t) => /* @__PURE__ */ (0, Z.jsx)("button", {
|
|
857
857
|
type: "button",
|
|
858
858
|
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
859
859
|
"data-testid": f ? "primary-field-link" : "link-cell",
|
|
860
860
|
onClick: (e) => {
|
|
861
|
-
e.stopPropagation(),
|
|
861
|
+
e.stopPropagation(), Q.handleClick(t);
|
|
862
862
|
},
|
|
863
|
-
children: u ? /* @__PURE__ */ (0,
|
|
863
|
+
children: u ? /* @__PURE__ */ (0, Z.jsx)(u, {
|
|
864
864
|
value: e,
|
|
865
865
|
field: d
|
|
866
|
-
}) : e != null && e !== "" ? String(e) : /* @__PURE__ */ (0,
|
|
866
|
+
}) : e != null && e !== "" ? String(e) : /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
867
867
|
className: "text-muted-foreground/50 text-xs italic",
|
|
868
868
|
children: "—"
|
|
869
869
|
})
|
|
870
|
-
}) : r.action ? (e, t) => /* @__PURE__ */ (0,
|
|
870
|
+
}) : r.action ? (e, t) => /* @__PURE__ */ (0, Z.jsx)(T, {
|
|
871
871
|
variant: "outline",
|
|
872
872
|
size: "sm",
|
|
873
873
|
className: "h-7 text-xs",
|
|
874
874
|
"data-testid": "action-cell",
|
|
875
875
|
onClick: (n) => {
|
|
876
|
-
n.stopPropagation(),
|
|
876
|
+
n.stopPropagation(), Ue({
|
|
877
877
|
type: r.action,
|
|
878
878
|
params: {
|
|
879
879
|
record: t,
|
|
@@ -883,24 +883,24 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
883
883
|
});
|
|
884
884
|
},
|
|
885
885
|
children: $e(r.action)
|
|
886
|
-
}) : u ? (e) => /* @__PURE__ */ (0,
|
|
886
|
+
}) : u ? (e) => /* @__PURE__ */ (0, Z.jsx)(u, {
|
|
887
887
|
value: e,
|
|
888
888
|
field: d
|
|
889
|
-
}) : (e) => e != null && e !== "" ? /* @__PURE__ */ (0,
|
|
889
|
+
}) : (e) => e != null && e !== "" ? /* @__PURE__ */ (0, Z.jsx)("span", { children: String(e) }) : /* @__PURE__ */ (0, Z.jsx)(j, {});
|
|
890
890
|
let m = r.prefix;
|
|
891
891
|
if (m?.field) {
|
|
892
892
|
let e = s, t = m.type === "badge" ? S("select") : null;
|
|
893
893
|
s = (n, r) => {
|
|
894
894
|
let i = r[m.field];
|
|
895
|
-
return /* @__PURE__ */ (0,
|
|
895
|
+
return /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
896
896
|
className: "flex items-center gap-1.5",
|
|
897
|
-
children: [i != null && i !== "" ? t ? /* @__PURE__ */ (0,
|
|
897
|
+
children: [i != null && i !== "" ? t ? /* @__PURE__ */ (0, Z.jsx)(t, {
|
|
898
898
|
value: i,
|
|
899
899
|
field: {
|
|
900
900
|
name: m.field,
|
|
901
901
|
type: "select"
|
|
902
902
|
}
|
|
903
|
-
}) : /* @__PURE__ */ (0,
|
|
903
|
+
}) : /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
904
904
|
className: "text-muted-foreground text-xs mr-1.5",
|
|
905
905
|
children: String(i)
|
|
906
906
|
}) : null, e(n, r)]
|
|
@@ -928,11 +928,11 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
928
928
|
});
|
|
929
929
|
}
|
|
930
930
|
return r.filter((e) => typeof e == "string" && e.trim().length > 0).map((r, i) => {
|
|
931
|
-
let a =
|
|
931
|
+
let a = I?.fields?.[r], o = a?.label || r.charAt(0).toUpperCase() + r.slice(1).replace(/_/g, " "), s = e.objectName ? ce(e.objectName, r, o) : o, c = a?.type || n({ field: r }) || null, l = c ? S(c) : null, u = {
|
|
932
932
|
name: r,
|
|
933
933
|
type: c || "text"
|
|
934
934
|
};
|
|
935
|
-
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 =
|
|
935
|
+
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 = F(e.objectName, r, a.options))), c === "select" && !u.options && (u.options = Array.from(new Set(E.map((e) => e[r]).filter(Boolean))).map((e) => ({
|
|
936
936
|
value: e,
|
|
937
937
|
label: C(String(e))
|
|
938
938
|
})));
|
|
@@ -941,29 +941,29 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
941
941
|
"currency",
|
|
942
942
|
"percent"
|
|
943
943
|
].includes(c) ? "right" : void 0, f = i === 0, p;
|
|
944
|
-
return f && l ? p = (e, t) => /* @__PURE__ */ (0,
|
|
944
|
+
return f && l ? p = (e, t) => /* @__PURE__ */ (0, Z.jsx)("button", {
|
|
945
945
|
type: "button",
|
|
946
946
|
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
947
947
|
"data-testid": "primary-field-link",
|
|
948
948
|
onClick: (e) => {
|
|
949
|
-
e.stopPropagation(),
|
|
949
|
+
e.stopPropagation(), Q.handleClick(t);
|
|
950
950
|
},
|
|
951
|
-
children: /* @__PURE__ */ (0,
|
|
951
|
+
children: /* @__PURE__ */ (0, Z.jsx)(l, {
|
|
952
952
|
value: e,
|
|
953
953
|
field: u
|
|
954
954
|
})
|
|
955
|
-
}) : f ? p = (e, t) => /* @__PURE__ */ (0,
|
|
955
|
+
}) : f ? p = (e, t) => /* @__PURE__ */ (0, Z.jsx)("button", {
|
|
956
956
|
type: "button",
|
|
957
957
|
className: "text-primary font-medium underline-offset-4 hover:underline cursor-pointer bg-transparent border-none p-0 text-left font-inherit",
|
|
958
958
|
"data-testid": "primary-field-link",
|
|
959
959
|
onClick: (e) => {
|
|
960
|
-
e.stopPropagation(),
|
|
960
|
+
e.stopPropagation(), Q.handleClick(t);
|
|
961
961
|
},
|
|
962
|
-
children: e != null && e !== "" ? String(e) : /* @__PURE__ */ (0,
|
|
962
|
+
children: e != null && e !== "" ? String(e) : /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
963
963
|
className: "text-muted-foreground/50 text-xs italic",
|
|
964
964
|
children: "—"
|
|
965
965
|
})
|
|
966
|
-
}) : l && (p = (e) => /* @__PURE__ */ (0,
|
|
966
|
+
}) : l && (p = (e) => /* @__PURE__ */ (0, Z.jsx)(l, {
|
|
967
967
|
value: e,
|
|
968
968
|
field: u
|
|
969
969
|
})), {
|
|
@@ -976,14 +976,14 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
976
976
|
};
|
|
977
977
|
});
|
|
978
978
|
}
|
|
979
|
-
if (
|
|
980
|
-
let r =
|
|
981
|
-
if (r.length > 0) return (
|
|
982
|
-
let i =
|
|
979
|
+
if (K) {
|
|
980
|
+
let r = G?.provider === "value" ? G.items : [];
|
|
981
|
+
if (r.length > 0) return (J || Object.keys(r[0])).map((r) => {
|
|
982
|
+
let i = I?.fields?.[r], a = i?.type || n({ field: r }) || null, o = a ? S(a) : null, s = i?.label || r.charAt(0).toUpperCase() + r.slice(1).replace(/_/g, " "), c = {
|
|
983
983
|
name: r,
|
|
984
984
|
type: a || "text"
|
|
985
985
|
};
|
|
986
|
-
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 =
|
|
986
|
+
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 = F(e.objectName, r, i.options))), a === "select" && !c.options && (c.options = Array.from(new Set(E.map((e) => e[r]).filter(Boolean))).map((e) => ({
|
|
987
987
|
value: e,
|
|
988
988
|
label: C(String(e))
|
|
989
989
|
})));
|
|
@@ -997,7 +997,7 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
997
997
|
accessorKey: r,
|
|
998
998
|
...e.showColumnTypeIcons && a && { headerIcon: t(a) },
|
|
999
999
|
...l && { align: l },
|
|
1000
|
-
...o && { cell: (e) => /* @__PURE__ */ (0,
|
|
1000
|
+
...o && { cell: (e) => /* @__PURE__ */ (0, Z.jsx)(o, {
|
|
1001
1001
|
value: e,
|
|
1002
1002
|
field: c
|
|
1003
1003
|
}) },
|
|
@@ -1005,7 +1005,7 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1005
1005
|
};
|
|
1006
1006
|
});
|
|
1007
1007
|
}
|
|
1008
|
-
if (!
|
|
1008
|
+
if (!I) return [];
|
|
1009
1009
|
let i = [], a = new Set([
|
|
1010
1010
|
"id",
|
|
1011
1011
|
"created_at",
|
|
@@ -1020,18 +1020,18 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1020
1020
|
"updatedBy",
|
|
1021
1021
|
"_version",
|
|
1022
1022
|
"_rev"
|
|
1023
|
-
]), o =
|
|
1024
|
-
if (
|
|
1025
|
-
else if (o?.length) c = o.filter((e) =>
|
|
1023
|
+
]), o = I?.compactLayout, s = Object.keys(I.fields || {}), c;
|
|
1024
|
+
if (J) c = J;
|
|
1025
|
+
else if (o?.length) c = o.filter((e) => I.fields?.[e]);
|
|
1026
1026
|
else {
|
|
1027
1027
|
let e = s.filter((e) => {
|
|
1028
|
-
let t =
|
|
1028
|
+
let t = I.fields?.[e];
|
|
1029
1029
|
return !(!t || t.hidden || t.readonly && a.has(e));
|
|
1030
1030
|
});
|
|
1031
1031
|
c = [...e.filter((e) => !a.has(e)), ...e.filter((e) => a.has(e))];
|
|
1032
1032
|
}
|
|
1033
1033
|
return c.forEach((t) => {
|
|
1034
|
-
let n =
|
|
1034
|
+
let n = I.fields?.[t];
|
|
1035
1035
|
if (!n || n.permissions && n.permissions.read === !1) return;
|
|
1036
1036
|
let r = S(n.type), a = [
|
|
1037
1037
|
"number",
|
|
@@ -1039,13 +1039,13 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1039
1039
|
"percent"
|
|
1040
1040
|
], o = n.options ? {
|
|
1041
1041
|
...n,
|
|
1042
|
-
options:
|
|
1042
|
+
options: F(e.objectName, t, n.options)
|
|
1043
1043
|
} : n;
|
|
1044
1044
|
i.push({
|
|
1045
|
-
header: e.objectName ?
|
|
1045
|
+
header: e.objectName ? ce(e.objectName, t, n.label || t) : n.label || t,
|
|
1046
1046
|
accessorKey: t,
|
|
1047
1047
|
...a.includes(n.type) && { align: "right" },
|
|
1048
|
-
cell: (e) => /* @__PURE__ */ (0,
|
|
1048
|
+
cell: (e) => /* @__PURE__ */ (0, Z.jsx)(r, {
|
|
1049
1049
|
value: e,
|
|
1050
1050
|
field: o
|
|
1051
1051
|
}),
|
|
@@ -1053,19 +1053,30 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1053
1053
|
});
|
|
1054
1054
|
}), i;
|
|
1055
1055
|
}, [
|
|
1056
|
-
|
|
1057
|
-
U,
|
|
1058
|
-
W,
|
|
1059
|
-
B,
|
|
1060
|
-
V,
|
|
1061
|
-
q.handleClick,
|
|
1056
|
+
I,
|
|
1062
1057
|
J,
|
|
1058
|
+
Y,
|
|
1059
|
+
G,
|
|
1060
|
+
K,
|
|
1061
|
+
Q.handleClick,
|
|
1062
|
+
Ue,
|
|
1063
1063
|
E,
|
|
1064
|
-
|
|
1065
|
-
|
|
1064
|
+
ce,
|
|
1065
|
+
F,
|
|
1066
1066
|
e.objectName
|
|
1067
|
-
]),
|
|
1068
|
-
let n = e.exportOptions, r = n?.maxRecords || 0, i = n?.includeHeaders !== !1, a = n?.fileNamePrefix || e.objectName || "export"
|
|
1067
|
+
]), ct = r((t) => {
|
|
1068
|
+
let n = e.exportOptions, r = n?.maxRecords || 0, i = n?.includeHeaders !== !1, a = n?.fileNamePrefix || e.objectName || "export";
|
|
1069
|
+
if ((t === "csv" || t === "xlsx" || t === "json") && H.isSupported && e.objectName && !K && n?.streaming !== !1) {
|
|
1070
|
+
let n = st().filter((e) => e.accessorKey !== "_actions").map((e) => e.accessorKey).filter(Boolean);
|
|
1071
|
+
B(!1), V(!0), H.start(e.objectName, {
|
|
1072
|
+
format: t === "json" ? "json" : t,
|
|
1073
|
+
fields: n.length ? n : void 0,
|
|
1074
|
+
includeHeaders: i,
|
|
1075
|
+
limit: r > 0 ? r : void 0
|
|
1076
|
+
});
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
let o = r > 0 ? E.slice(0, r) : E, s = (e, t) => {
|
|
1069
1080
|
let n = URL.createObjectURL(e), r = document.createElement("a");
|
|
1070
1081
|
r.href = n, r.download = t, r.click(), URL.revokeObjectURL(n);
|
|
1071
1082
|
}, c = (e) => {
|
|
@@ -1073,144 +1084,146 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1073
1084
|
return t.includes(",") || t.includes("\"") || t.includes("\n") || t.includes("\r") ? `"${t.replace(/"/g, "\"\"")}"` : t;
|
|
1074
1085
|
};
|
|
1075
1086
|
if (t === "csv") {
|
|
1076
|
-
let e =
|
|
1087
|
+
let e = st().filter((e) => e.accessorKey !== "_actions"), t = e.map((e) => e.accessorKey), n = e.map((e) => e.header), r = [];
|
|
1077
1088
|
i && r.push(n.join(",")), o.forEach((e) => {
|
|
1078
1089
|
r.push(t.map((t) => c(e[t])).join(","));
|
|
1079
1090
|
}), s(new Blob([r.join("\n")], { type: "text/csv;charset=utf-8;" }), `${a}.csv`);
|
|
1080
1091
|
} else t === "json" && s(new Blob([JSON.stringify(o, null, 2)], { type: "application/json" }), `${a}.json`);
|
|
1081
|
-
|
|
1092
|
+
B(!1);
|
|
1082
1093
|
}, [
|
|
1083
1094
|
E,
|
|
1084
1095
|
e.exportOptions,
|
|
1085
1096
|
e.objectName,
|
|
1086
|
-
|
|
1097
|
+
st,
|
|
1098
|
+
H,
|
|
1099
|
+
K
|
|
1087
1100
|
]);
|
|
1088
|
-
if (k) return /* @__PURE__ */ (0,
|
|
1101
|
+
if (k) return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1089
1102
|
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1090
|
-
children: [/* @__PURE__ */ (0,
|
|
1103
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("h3", {
|
|
1091
1104
|
className: "text-red-800 font-semibold",
|
|
1092
1105
|
children: M("grid.errorLoading")
|
|
1093
|
-
}), /* @__PURE__ */ (0,
|
|
1106
|
+
}), /* @__PURE__ */ (0, Z.jsx)("p", {
|
|
1094
1107
|
className: "text-red-600 text-sm mt-1",
|
|
1095
1108
|
children: k.message
|
|
1096
1109
|
})]
|
|
1097
1110
|
});
|
|
1098
|
-
if (D && E.length === 0) return
|
|
1111
|
+
if (D && E.length === 0) return R ? /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1099
1112
|
className: "space-y-2 p-2",
|
|
1100
1113
|
children: [
|
|
1101
1114
|
1,
|
|
1102
1115
|
2,
|
|
1103
1116
|
3
|
|
1104
|
-
].map((e) => /* @__PURE__ */ (0,
|
|
1117
|
+
].map((e) => /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1105
1118
|
className: "border rounded-lg p-3 bg-card animate-pulse",
|
|
1106
1119
|
children: [
|
|
1107
|
-
/* @__PURE__ */ (0,
|
|
1108
|
-
/* @__PURE__ */ (0,
|
|
1120
|
+
/* @__PURE__ */ (0, Z.jsx)("div", { className: "h-5 bg-muted rounded w-3/4 mb-3" }),
|
|
1121
|
+
/* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1109
1122
|
className: "flex items-center justify-between mb-2",
|
|
1110
|
-
children: [/* @__PURE__ */ (0,
|
|
1123
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("div", { className: "h-4 bg-muted rounded w-1/4" }), /* @__PURE__ */ (0, Z.jsx)("div", { className: "h-5 bg-muted rounded-full w-20" })]
|
|
1111
1124
|
}),
|
|
1112
|
-
/* @__PURE__ */ (0,
|
|
1125
|
+
/* @__PURE__ */ (0, Z.jsx)("div", { className: "h-3 bg-muted rounded w-1/3" })
|
|
1113
1126
|
]
|
|
1114
1127
|
}, e))
|
|
1115
|
-
}) : /* @__PURE__ */ (0,
|
|
1128
|
+
}) : /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1116
1129
|
className: "p-4 sm:p-8 text-center",
|
|
1117
|
-
children: [/* @__PURE__ */ (0,
|
|
1130
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-foreground" }), /* @__PURE__ */ (0, Z.jsx)("p", {
|
|
1118
1131
|
className: "mt-2 text-sm text-muted-foreground",
|
|
1119
1132
|
children: M("grid.loading")
|
|
1120
1133
|
})]
|
|
1121
1134
|
});
|
|
1122
|
-
let
|
|
1123
|
-
if (
|
|
1124
|
-
let t =
|
|
1135
|
+
let lt = [...st()];
|
|
1136
|
+
if (W.widths && (lt = lt.map((e) => {
|
|
1137
|
+
let t = W.widths?.[e.accessorKey];
|
|
1125
1138
|
return t ? {
|
|
1126
1139
|
...e,
|
|
1127
1140
|
size: t
|
|
1128
1141
|
} : e;
|
|
1129
|
-
})),
|
|
1130
|
-
let e = new Map(
|
|
1131
|
-
|
|
1142
|
+
})), W.order && W.order.length > 0) {
|
|
1143
|
+
let e = new Map(W.order.map((e, t) => [e, t]));
|
|
1144
|
+
lt.sort((t, n) => (e.get(t.accessorKey) ?? Infinity) - (e.get(n.accessorKey) ?? Infinity));
|
|
1132
1145
|
}
|
|
1133
|
-
let
|
|
1146
|
+
let $ = "operations" in e ? e.operations : void 0, ut = $ && ($.update || $.delete), dt = e.rowActions && e.rowActions.length > 0, ft = ut || dt ? [...lt, {
|
|
1134
1147
|
header: M("grid.actions"),
|
|
1135
1148
|
accessorKey: "_actions",
|
|
1136
|
-
cell: (t, n) => /* @__PURE__ */ (0,
|
|
1149
|
+
cell: (t, n) => /* @__PURE__ */ (0, Z.jsx)(et, {
|
|
1137
1150
|
row: n,
|
|
1138
1151
|
rowActions: e.rowActions,
|
|
1139
|
-
canEdit: !!(
|
|
1140
|
-
canDelete: !!(
|
|
1152
|
+
canEdit: !!($?.update && a),
|
|
1153
|
+
canDelete: !!($?.delete && o),
|
|
1141
1154
|
onEdit: a,
|
|
1142
1155
|
onDelete: o,
|
|
1143
|
-
onAction: (e, t) =>
|
|
1156
|
+
onAction: (e, t) => Ue({
|
|
1144
1157
|
type: e,
|
|
1145
1158
|
params: { record: t }
|
|
1146
1159
|
})
|
|
1147
1160
|
}),
|
|
1148
1161
|
sortable: !1
|
|
1149
|
-
}] :
|
|
1150
|
-
...
|
|
1151
|
-
...
|
|
1152
|
-
...
|
|
1162
|
+
}] : lt, pt = ft.filter((e) => e.pinned === "left"), mt = ft.filter((e) => e.pinned === "right"), ht = ft.filter((e) => !e.pinned), gt = pt.length > 0 || mt.length > 0, _t = "sticky right-0 z-10 bg-background border-l border-border", vt = gt ? [
|
|
1163
|
+
...pt,
|
|
1164
|
+
...ht,
|
|
1165
|
+
...mt.map((e) => ({
|
|
1153
1166
|
...e,
|
|
1154
|
-
className: [e.className,
|
|
1155
|
-
cellClassName: [e.cellClassName,
|
|
1167
|
+
className: [e.className, _t].filter(Boolean).join(" "),
|
|
1168
|
+
cellClassName: [e.cellClassName, _t].filter(Boolean).join(" ")
|
|
1156
1169
|
}))
|
|
1157
|
-
] :
|
|
1158
|
-
e.selection?.type ?
|
|
1159
|
-
let
|
|
1170
|
+
] : ft, yt = gt ? pt.length : e.frozenColumns ?? 1, bt = e.batchActions ?? e.bulkActions, xt = bt && bt.length > 0, St = !1;
|
|
1171
|
+
e.selection?.type ? St = e.selection.type === "none" ? !1 : e.selection.type : e.selectable === void 0 ? xt && (St = "multiple") : St = e.selectable;
|
|
1172
|
+
let Ct = e.pagination === void 0 ? e.showPagination === void 0 ? !0 : e.showPagination : !0, wt = e.pagination?.pageSize || e.pageSize || 10, Tt = e.searchableFields === void 0 ? e.showSearch === void 0 ? !0 : e.showSearch : e.searchableFields.length > 0, Et = {
|
|
1160
1173
|
type: "data-table",
|
|
1161
1174
|
caption: e.label || e.title,
|
|
1162
|
-
columns:
|
|
1175
|
+
columns: vt,
|
|
1163
1176
|
data: E,
|
|
1164
|
-
pagination:
|
|
1165
|
-
pageSize:
|
|
1166
|
-
searchable:
|
|
1167
|
-
selectable:
|
|
1177
|
+
pagination: Ct,
|
|
1178
|
+
pageSize: wt,
|
|
1179
|
+
searchable: Tt,
|
|
1180
|
+
selectable: St,
|
|
1168
1181
|
sortable: !0,
|
|
1169
|
-
exportable:
|
|
1170
|
-
rowActions: !!(e.editable &&
|
|
1182
|
+
exportable: $?.export,
|
|
1183
|
+
rowActions: !!(e.editable && ut),
|
|
1171
1184
|
resizableColumns: e.resizable ?? e.resizableColumns ?? !0,
|
|
1172
1185
|
reorderableColumns: e.reorderableColumns ?? !1,
|
|
1173
1186
|
editable: e.editable ?? !1,
|
|
1174
1187
|
singleClickEdit: e.singleClickEdit ?? !0,
|
|
1175
1188
|
className: e.className,
|
|
1176
|
-
cellClassName:
|
|
1189
|
+
cellClassName: U === "compact" ? "px-3 py-1 text-[13px] leading-tight" : U === "short" ? "px-3 py-1 text-[13px] leading-normal" : U === "tall" ? "px-3 py-2.5 text-sm" : U === "extra_tall" ? "px-3 py-3.5 text-sm leading-relaxed" : "px-3 py-1.5 text-[13px] leading-normal",
|
|
1177
1190
|
showRowNumbers: !0,
|
|
1178
|
-
showAddRow:
|
|
1191
|
+
showAddRow: !!$?.create,
|
|
1179
1192
|
onAddRecord: ne,
|
|
1180
|
-
rowClassName: e.rowColor ? (e, t) =>
|
|
1181
|
-
rowStyle: e.conditionalFormatting?.length ? (e, t) =>
|
|
1182
|
-
frozenColumns:
|
|
1193
|
+
rowClassName: e.rowColor ? (e, t) => We(e) : void 0,
|
|
1194
|
+
rowStyle: e.conditionalFormatting?.length ? (e, t) => Ge(e) : void 0,
|
|
1195
|
+
frozenColumns: yt,
|
|
1183
1196
|
onSelectionChange: (e) => {
|
|
1184
|
-
|
|
1197
|
+
ve(e), c?.(e);
|
|
1185
1198
|
},
|
|
1186
|
-
onRowClick:
|
|
1199
|
+
onRowClick: Q.handleClick,
|
|
1187
1200
|
onCellChange: _,
|
|
1188
1201
|
onRowSave: ee,
|
|
1189
1202
|
onBatchSave: te,
|
|
1190
1203
|
onColumnResize: (e, t) => {
|
|
1191
|
-
|
|
1192
|
-
...
|
|
1204
|
+
we({
|
|
1205
|
+
...W,
|
|
1193
1206
|
widths: {
|
|
1194
|
-
...
|
|
1207
|
+
...W.widths,
|
|
1195
1208
|
[e]: t
|
|
1196
1209
|
}
|
|
1197
1210
|
});
|
|
1198
1211
|
},
|
|
1199
1212
|
onColumnReorder: (e) => {
|
|
1200
|
-
|
|
1201
|
-
...
|
|
1213
|
+
we({
|
|
1214
|
+
...W,
|
|
1202
1215
|
order: e
|
|
1203
1216
|
});
|
|
1204
1217
|
}
|
|
1205
|
-
},
|
|
1206
|
-
...
|
|
1218
|
+
}, Dt = (e) => ({
|
|
1219
|
+
...Et,
|
|
1207
1220
|
caption: void 0,
|
|
1208
1221
|
data: e,
|
|
1209
1222
|
pagination: !1,
|
|
1210
1223
|
searchable: !1
|
|
1211
|
-
}),
|
|
1212
|
-
if (
|
|
1213
|
-
let e =
|
|
1224
|
+
}), Ot = e.label ? `${e.label} Detail` : e.objectName ? `${e.objectName.charAt(0).toUpperCase() + e.objectName.slice(1)} Detail` : "Record Detail";
|
|
1225
|
+
if (R && E.length > 0 && !Ye) {
|
|
1226
|
+
let e = st().filter((e) => e.accessorKey !== "_actions"), t = /* @__PURE__ */ new Map();
|
|
1214
1227
|
e.forEach((e) => t.set(e.accessorKey, e));
|
|
1215
1228
|
let n = e[0], r = [
|
|
1216
1229
|
"amount",
|
|
@@ -1246,65 +1259,65 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1246
1259
|
"score"
|
|
1247
1260
|
], s = (e) => {
|
|
1248
1261
|
let t = (e || "").toLowerCase();
|
|
1249
|
-
return t.includes("won") || t.includes("completed") || t.includes("done") || t.includes("active") ? "bg-green-
|
|
1262
|
+
return t.includes("won") || t.includes("completed") || t.includes("done") || t.includes("active") || t === "activated" || t === "success" || t === "approved" || t === "paid" ? "bg-green-50 text-green-700 border-green-200 dark:bg-green-950/40 dark:text-green-300 dark:border-green-900/60" : t.includes("lost") || t.includes("cancelled") || t.includes("rejected") || t.includes("closed lost") || t === "expired" || t === "terminated" || t === "failed" || t === "overdue" ? "bg-red-50 text-red-700 border-red-200 dark:bg-red-950/40 dark:text-red-300 dark:border-red-900/60" : t.includes("negotiation") || t.includes("review") || t.includes("in progress") || t.includes("approval") || t === "in_approval" || t === "pending_approval" ? "bg-yellow-50 text-yellow-800 border-yellow-200 dark:bg-yellow-950/40 dark:text-yellow-300 dark:border-yellow-900/60" : t.includes("proposal") || t.includes("pending") ? "bg-blue-50 text-blue-700 border-blue-200 dark:bg-blue-950/40 dark:text-blue-300 dark:border-blue-900/60" : t.includes("qualification") || t.includes("qualified") ? "bg-indigo-50 text-indigo-700 border-indigo-200 dark:bg-indigo-950/40 dark:text-indigo-300 dark:border-indigo-900/60" : t.includes("prospecting") || t.includes("new") || t.includes("open") ? "bg-purple-50 text-purple-700 border-purple-200 dark:bg-purple-950/40 dark:text-purple-300 dark:border-purple-900/60" : t === "draft" || t.includes("draft") ? "bg-slate-50 text-slate-700 border-slate-200 dark:bg-slate-950/40 dark:text-slate-300 dark:border-slate-900/60" : "bg-muted text-muted-foreground border-border";
|
|
1250
1263
|
}, c = (e) => {
|
|
1251
1264
|
let t = (e || "").toLowerCase();
|
|
1252
|
-
return t.includes("won") || t.includes("completed") || t.includes("done") || t.includes("active") ? "border-l-green-500" : t.includes("lost") || t.includes("cancelled") || t.includes("rejected") ? "border-l-red-500" : t.includes("negotiation") || t.includes("review") || t.includes("in progress") ? "border-l-yellow-500" : t.includes("proposal") || t.includes("pending") ? "border-l-blue-500" : t.includes("qualification") || t.includes("qualified") ? "border-l-indigo-500" : t.includes("prospecting") || t.includes("new") || t.includes("open") ? "border-l-purple-500" : "border-l-gray-300";
|
|
1265
|
+
return t.includes("won") || t.includes("completed") || t.includes("done") || t.includes("active") || t === "activated" ? "border-l-green-500" : t.includes("lost") || t.includes("cancelled") || t.includes("rejected") || t === "expired" || t === "terminated" ? "border-l-red-500" : t.includes("negotiation") || t.includes("review") || t.includes("in progress") || t.includes("approval") ? "border-l-yellow-500" : t.includes("proposal") || t.includes("pending") ? "border-l-blue-500" : t.includes("qualification") || t.includes("qualified") ? "border-l-indigo-500" : t.includes("prospecting") || t.includes("new") || t.includes("open") ? "border-l-purple-500" : t === "draft" || t.includes("draft") ? "border-l-slate-400" : "border-l-gray-300";
|
|
1253
1266
|
}, l = (e) => {
|
|
1254
1267
|
let t = e.toLowerCase();
|
|
1255
1268
|
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";
|
|
1256
1269
|
};
|
|
1257
|
-
return /* @__PURE__ */ (0,
|
|
1270
|
+
return /* @__PURE__ */ (0, Z.jsxs)(Z.Fragment, { children: [/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1258
1271
|
className: "space-y-2 p-2",
|
|
1259
1272
|
children: E.map((t, r) => {
|
|
1260
1273
|
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) : "";
|
|
1261
|
-
return /* @__PURE__ */ (0,
|
|
1274
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1262
1275
|
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(" "),
|
|
1263
|
-
onClick: () =>
|
|
1276
|
+
onClick: () => Q.handleClick(t),
|
|
1264
1277
|
children: [
|
|
1265
|
-
n && /* @__PURE__ */ (0,
|
|
1278
|
+
n && /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1266
1279
|
className: "font-semibold text-sm truncate mb-1",
|
|
1267
1280
|
children: t[n.accessorKey] != null && typeof t[n.accessorKey] == "object" ? String(t[n.accessorKey]) : t[n.accessorKey] ?? "—"
|
|
1268
1281
|
}),
|
|
1269
|
-
(a || o) && /* @__PURE__ */ (0,
|
|
1282
|
+
(a || o) && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1270
1283
|
className: "flex items-center justify-between gap-2 mb-1",
|
|
1271
|
-
children: [a && /* @__PURE__ */ (0,
|
|
1284
|
+
children: [a && /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1272
1285
|
className: "text-sm tabular-nums font-medium",
|
|
1273
1286
|
children: typeof t[a.accessorKey] == "number" ? v(t[a.accessorKey]) : t[a.accessorKey] != null && typeof t[a.accessorKey] == "object" ? String(t[a.accessorKey]) : t[a.accessorKey] ?? "—"
|
|
1274
|
-
}), o && t[o.accessorKey] && /* @__PURE__ */ (0,
|
|
1287
|
+
}), o && t[o.accessorKey] && /* @__PURE__ */ (0, Z.jsx)(w, {
|
|
1275
1288
|
variant: "outline",
|
|
1276
1289
|
className: `text-xs shrink-0 max-w-[140px] truncate ${s(String(t[o.accessorKey]))}`,
|
|
1277
1290
|
children: String(t[o.accessorKey])
|
|
1278
1291
|
})]
|
|
1279
1292
|
}),
|
|
1280
|
-
(u.length > 0 || d.length > 0) && /* @__PURE__ */ (0,
|
|
1293
|
+
(u.length > 0 || d.length > 0) && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1281
1294
|
className: "flex items-center justify-between py-0.5 text-xs text-muted-foreground",
|
|
1282
|
-
children: [u[0] && /* @__PURE__ */ (0,
|
|
1295
|
+
children: [u[0] && /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1283
1296
|
className: "tabular-nums",
|
|
1284
1297
|
children: t[u[0].accessorKey] ? b(t[u[0].accessorKey], "short") : "—"
|
|
1285
|
-
}), d[0] && t[d[0].accessorKey] != null && /* @__PURE__ */ (0,
|
|
1298
|
+
}), d[0] && t[d[0].accessorKey] != null && /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1286
1299
|
className: "tabular-nums",
|
|
1287
1300
|
children: x(Number(t[d[0].accessorKey]))
|
|
1288
1301
|
})]
|
|
1289
1302
|
}),
|
|
1290
|
-
u.slice(1).map((e) => /* @__PURE__ */ (0,
|
|
1303
|
+
u.slice(1).map((e) => /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1291
1304
|
className: "flex justify-between items-center py-0.5",
|
|
1292
|
-
children: [/* @__PURE__ */ (0,
|
|
1305
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1293
1306
|
className: "text-xs text-muted-foreground",
|
|
1294
1307
|
children: e.header
|
|
1295
|
-
}), /* @__PURE__ */ (0,
|
|
1308
|
+
}), /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1296
1309
|
className: "text-xs text-muted-foreground tabular-nums",
|
|
1297
1310
|
children: t[e.accessorKey] ? b(t[e.accessorKey], "short") : "—"
|
|
1298
1311
|
})]
|
|
1299
1312
|
}, e.accessorKey)),
|
|
1300
1313
|
f.map((e) => {
|
|
1301
1314
|
let n = t[e.accessorKey];
|
|
1302
|
-
return n == null || n === "" ? null : /* @__PURE__ */ (0,
|
|
1315
|
+
return n == null || n === "" ? null : /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1303
1316
|
className: "flex justify-between items-center py-0.5",
|
|
1304
|
-
children: [/* @__PURE__ */ (0,
|
|
1317
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1305
1318
|
className: "text-xs text-muted-foreground",
|
|
1306
1319
|
children: e.header
|
|
1307
|
-
}), /* @__PURE__ */ (0,
|
|
1320
|
+
}), /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1308
1321
|
className: "text-xs font-medium truncate ml-2 text-right",
|
|
1309
1322
|
children: e.cell ? e.cell(n, t) : String(n)
|
|
1310
1323
|
})]
|
|
@@ -1313,17 +1326,17 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1313
1326
|
]
|
|
1314
1327
|
}, t.id || t._id || r);
|
|
1315
1328
|
})
|
|
1316
|
-
}),
|
|
1317
|
-
...
|
|
1318
|
-
title:
|
|
1319
|
-
children: (e) => /* @__PURE__ */ (0,
|
|
1329
|
+
}), Q.isOverlay && /* @__PURE__ */ (0, Z.jsx)(oe, {
|
|
1330
|
+
...Q,
|
|
1331
|
+
title: Ot,
|
|
1332
|
+
children: (e) => /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1320
1333
|
className: "space-y-3",
|
|
1321
|
-
children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ (0,
|
|
1334
|
+
children: Object.entries(e).map(([e, t]) => /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1322
1335
|
className: "flex flex-col",
|
|
1323
|
-
children: [/* @__PURE__ */ (0,
|
|
1336
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1324
1337
|
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
|
|
1325
1338
|
children: e.replace(/_/g, " ")
|
|
1326
|
-
}), /* @__PURE__ */ (0,
|
|
1339
|
+
}), /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1327
1340
|
className: "text-sm",
|
|
1328
1341
|
children: String(t ?? "—")
|
|
1329
1342
|
})]
|
|
@@ -1331,56 +1344,56 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1331
1344
|
})
|
|
1332
1345
|
})] });
|
|
1333
1346
|
}
|
|
1334
|
-
let
|
|
1335
|
-
|
|
1336
|
-
},
|
|
1337
|
-
compact:
|
|
1338
|
-
short:
|
|
1339
|
-
medium:
|
|
1340
|
-
tall:
|
|
1341
|
-
extra_tall:
|
|
1342
|
-
}[
|
|
1347
|
+
let kt = () => {
|
|
1348
|
+
he((e) => e === "compact" ? "short" : e === "short" ? "medium" : e === "medium" ? "tall" : e === "tall" ? "extra_tall" : "compact");
|
|
1349
|
+
}, At = {
|
|
1350
|
+
compact: Me,
|
|
1351
|
+
short: je,
|
|
1352
|
+
medium: Ae,
|
|
1353
|
+
tall: me,
|
|
1354
|
+
extra_tall: me
|
|
1355
|
+
}[U], jt = e.rowHeight !== void 0, Mt = e.exportOptions || jt ? /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1343
1356
|
className: "flex items-center justify-end gap-1 px-2 py-1",
|
|
1344
|
-
children: [
|
|
1357
|
+
children: [jt && /* @__PURE__ */ (0, Z.jsxs)(T, {
|
|
1345
1358
|
variant: "ghost",
|
|
1346
1359
|
size: "sm",
|
|
1347
1360
|
className: "h-7 px-2 text-muted-foreground hover:text-primary text-xs",
|
|
1348
|
-
onClick:
|
|
1349
|
-
title: `Row height: ${
|
|
1350
|
-
children: [/* @__PURE__ */ (0,
|
|
1361
|
+
onClick: kt,
|
|
1362
|
+
title: `Row height: ${U}`,
|
|
1363
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(At, { className: "h-3.5 w-3.5 mr-1.5" }), /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1351
1364
|
className: "hidden sm:inline capitalize",
|
|
1352
|
-
children:
|
|
1365
|
+
children: U
|
|
1353
1366
|
})]
|
|
1354
|
-
}), e.exportOptions && /* @__PURE__ */ (0,
|
|
1355
|
-
open:
|
|
1356
|
-
onOpenChange:
|
|
1357
|
-
children: [/* @__PURE__ */ (0,
|
|
1367
|
+
}), e.exportOptions && /* @__PURE__ */ (0, Z.jsxs)(se, {
|
|
1368
|
+
open: z,
|
|
1369
|
+
onOpenChange: B,
|
|
1370
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(P, {
|
|
1358
1371
|
asChild: !0,
|
|
1359
|
-
children: /* @__PURE__ */ (0,
|
|
1372
|
+
children: /* @__PURE__ */ (0, Z.jsxs)(T, {
|
|
1360
1373
|
variant: "ghost",
|
|
1361
1374
|
size: "sm",
|
|
1362
1375
|
className: "h-7 px-2 text-muted-foreground hover:text-primary text-xs",
|
|
1363
|
-
children: [/* @__PURE__ */ (0,
|
|
1376
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(Ce, { className: "h-3.5 w-3.5 mr-1.5" }), /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1364
1377
|
className: "hidden sm:inline",
|
|
1365
1378
|
children: M("grid.export")
|
|
1366
1379
|
})]
|
|
1367
1380
|
})
|
|
1368
|
-
}), /* @__PURE__ */ (0,
|
|
1381
|
+
}), /* @__PURE__ */ (0, Z.jsx)(N, {
|
|
1369
1382
|
align: "end",
|
|
1370
1383
|
className: "w-48 p-2",
|
|
1371
|
-
children: /* @__PURE__ */ (0,
|
|
1384
|
+
children: /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1372
1385
|
className: "space-y-1",
|
|
1373
|
-
children: (e.exportOptions.formats || ["csv", "json"]).map((e) => /* @__PURE__ */ (0,
|
|
1386
|
+
children: (e.exportOptions.formats || ["csv", "json"]).map((e) => /* @__PURE__ */ (0, Z.jsxs)(T, {
|
|
1374
1387
|
variant: "ghost",
|
|
1375
1388
|
size: "sm",
|
|
1376
1389
|
className: "w-full justify-start h-8 text-xs",
|
|
1377
|
-
onClick: () =>
|
|
1378
|
-
children: [/* @__PURE__ */ (0,
|
|
1390
|
+
onClick: () => ct(e),
|
|
1391
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(Ce, { className: "h-3.5 w-3.5 mr-2" }), M("grid.exportAs", { format: e.toUpperCase() })]
|
|
1379
1392
|
}, e))
|
|
1380
1393
|
})
|
|
1381
1394
|
})]
|
|
1382
1395
|
})]
|
|
1383
|
-
}) : null,
|
|
1396
|
+
}) : null, Nt = (e) => {
|
|
1384
1397
|
let t = [
|
|
1385
1398
|
"_id",
|
|
1386
1399
|
"id",
|
|
@@ -1389,22 +1402,22 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1389
1402
|
"created_by",
|
|
1390
1403
|
"updated_by"
|
|
1391
1404
|
], 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) => {
|
|
1392
|
-
if (t == null || t === "") return /* @__PURE__ */ (0,
|
|
1405
|
+
if (t == null || t === "") return /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1393
1406
|
className: "text-muted-foreground/50 text-sm italic",
|
|
1394
1407
|
children: "Empty"
|
|
1395
1408
|
});
|
|
1396
|
-
let n =
|
|
1409
|
+
let n = I?.fields?.[e];
|
|
1397
1410
|
if (n?.type) {
|
|
1398
1411
|
let e = S(n.type);
|
|
1399
|
-
if (e) return /* @__PURE__ */ (0,
|
|
1412
|
+
if (e) return /* @__PURE__ */ (0, Z.jsx)(e, {
|
|
1400
1413
|
value: t,
|
|
1401
1414
|
field: n
|
|
1402
1415
|
});
|
|
1403
1416
|
}
|
|
1404
|
-
return typeof t == "boolean" ? /* @__PURE__ */ (0,
|
|
1417
|
+
return typeof t == "boolean" ? /* @__PURE__ */ (0, Z.jsx)(w, {
|
|
1405
1418
|
variant: t ? "default" : "outline",
|
|
1406
1419
|
children: t ? "Yes" : "No"
|
|
1407
|
-
}) : typeof t == "string" && !isNaN(Date.parse(t)) && (e.includes("date") || e.includes("_at") || e.includes("time")) ? /* @__PURE__ */ (0,
|
|
1420
|
+
}) : typeof t == "string" && !isNaN(Date.parse(t)) && (e.includes("date") || e.includes("_at") || e.includes("time")) ? /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1408
1421
|
className: "text-sm tabular-nums",
|
|
1409
1422
|
children: b(t)
|
|
1410
1423
|
}) : typeof t == "number" && [
|
|
@@ -1416,48 +1429,48 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1416
1429
|
"value",
|
|
1417
1430
|
"budget",
|
|
1418
1431
|
"salary"
|
|
1419
|
-
].some((t) => e.toLowerCase().includes(t)) ? /* @__PURE__ */ (0,
|
|
1432
|
+
].some((t) => e.toLowerCase().includes(t)) ? /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1420
1433
|
className: "text-sm tabular-nums font-medium",
|
|
1421
1434
|
children: y(t)
|
|
1422
|
-
}) : /* @__PURE__ */ (0,
|
|
1435
|
+
}) : /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1423
1436
|
className: "text-sm break-words",
|
|
1424
1437
|
children: String(t)
|
|
1425
1438
|
});
|
|
1426
1439
|
};
|
|
1427
|
-
return /* @__PURE__ */ (0,
|
|
1440
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1428
1441
|
className: "space-y-4",
|
|
1429
1442
|
"data-testid": "record-detail-panel",
|
|
1430
|
-
children: [/* @__PURE__ */ (0,
|
|
1443
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1431
1444
|
className: "rounded-lg border bg-card",
|
|
1432
|
-
children: /* @__PURE__ */ (0,
|
|
1445
|
+
children: /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1433
1446
|
className: "divide-y",
|
|
1434
|
-
children: r.map(([e, t]) => /* @__PURE__ */ (0,
|
|
1447
|
+
children: r.map(([e, t]) => /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1435
1448
|
className: "flex flex-col sm:flex-row sm:items-start gap-1 sm:gap-4 px-4 py-3",
|
|
1436
|
-
children: [/* @__PURE__ */ (0,
|
|
1449
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1437
1450
|
className: "text-xs font-medium text-muted-foreground sm:w-1/3 sm:text-right sm:pt-0.5 uppercase tracking-wide shrink-0",
|
|
1438
1451
|
children: a(e)
|
|
1439
|
-
}), /* @__PURE__ */ (0,
|
|
1452
|
+
}), /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1440
1453
|
className: "flex-1 min-w-0",
|
|
1441
1454
|
children: o(e, t)
|
|
1442
1455
|
})]
|
|
1443
1456
|
}, e))
|
|
1444
1457
|
})
|
|
1445
|
-
}), i.length > 0 && /* @__PURE__ */ (0,
|
|
1458
|
+
}), i.length > 0 && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1446
1459
|
className: "rounded-lg border bg-muted/30",
|
|
1447
|
-
children: [/* @__PURE__ */ (0,
|
|
1460
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1448
1461
|
className: "px-4 py-2 border-b",
|
|
1449
|
-
children: /* @__PURE__ */ (0,
|
|
1462
|
+
children: /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1450
1463
|
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
|
|
1451
1464
|
children: "System"
|
|
1452
1465
|
})
|
|
1453
|
-
}), /* @__PURE__ */ (0,
|
|
1466
|
+
}), /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1454
1467
|
className: "divide-y divide-border/50",
|
|
1455
|
-
children: i.map(([e, t]) => /* @__PURE__ */ (0,
|
|
1468
|
+
children: i.map(([e, t]) => /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1456
1469
|
className: "flex items-center gap-4 px-4 py-2",
|
|
1457
|
-
children: [/* @__PURE__ */ (0,
|
|
1470
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1458
1471
|
className: "text-xs text-muted-foreground w-1/3 text-right shrink-0",
|
|
1459
1472
|
children: a(e)
|
|
1460
|
-
}), /* @__PURE__ */ (0,
|
|
1473
|
+
}), /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
1461
1474
|
className: "text-xs text-muted-foreground flex-1 min-w-0 break-words",
|
|
1462
1475
|
children: String(t ?? "")
|
|
1463
1476
|
})]
|
|
@@ -1465,14 +1478,14 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1465
1478
|
})]
|
|
1466
1479
|
})]
|
|
1467
1480
|
});
|
|
1468
|
-
},
|
|
1481
|
+
}, Pt = nt ? /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1469
1482
|
className: "border-t bg-muted/30 px-2 py-1.5",
|
|
1470
1483
|
"data-testid": "column-summary-footer",
|
|
1471
|
-
children: /* @__PURE__ */ (0,
|
|
1484
|
+
children: /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1472
1485
|
className: "flex gap-4 text-xs text-muted-foreground font-medium",
|
|
1473
|
-
children:
|
|
1474
|
-
let t =
|
|
1475
|
-
return /* @__PURE__ */ (0,
|
|
1486
|
+
children: vt.filter((e) => Ze.has(e.accessorKey)).map((e) => {
|
|
1487
|
+
let t = Ze.get(e.accessorKey);
|
|
1488
|
+
return /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
1476
1489
|
"data-testid": `summary-${e.accessorKey}`,
|
|
1477
1490
|
children: [
|
|
1478
1491
|
e.header,
|
|
@@ -1482,66 +1495,73 @@ var ot = ({ schema: e, dataSource: n, onEdit: a, onDelete: o, onRowSelect: c, on
|
|
|
1482
1495
|
}, e.accessorKey);
|
|
1483
1496
|
})
|
|
1484
1497
|
})
|
|
1485
|
-
}) : null,
|
|
1498
|
+
}) : null, Ft = Ye ? /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1486
1499
|
className: "space-y-2",
|
|
1487
|
-
children:
|
|
1500
|
+
children: Ke.map((e) => /* @__PURE__ */ (0, Z.jsx)(Je, {
|
|
1488
1501
|
groupKey: e.key,
|
|
1489
1502
|
label: e.label,
|
|
1490
1503
|
count: e.rows.length,
|
|
1491
1504
|
collapsed: e.collapsed,
|
|
1492
1505
|
aggregations: e.aggregations,
|
|
1493
|
-
onToggle:
|
|
1494
|
-
children: /* @__PURE__ */ (0,
|
|
1506
|
+
onToggle: Xe,
|
|
1507
|
+
children: /* @__PURE__ */ (0, Z.jsx)(d, { schema: Dt(e.rows) })
|
|
1495
1508
|
}, e.key))
|
|
1496
|
-
}) : /* @__PURE__ */ (0,
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1509
|
+
}) : /* @__PURE__ */ (0, Z.jsxs)(Z.Fragment, { children: [/* @__PURE__ */ (0, Z.jsx)(d, { schema: Et }), Pt] }), It = /* @__PURE__ */ (0, Z.jsx)(ae, {
|
|
1510
|
+
open: fe,
|
|
1511
|
+
onOpenChange: V,
|
|
1512
|
+
job: H,
|
|
1513
|
+
filename: `${e.exportOptions?.fileNamePrefix || e.objectName || "export"}.${H.progress?.format || "csv"}`,
|
|
1514
|
+
closeAfterDownloadMs: 400
|
|
1515
|
+
});
|
|
1516
|
+
return Q.isOverlay && Q.mode === "split" ? /* @__PURE__ */ (0, Z.jsxs)(Z.Fragment, { children: [/* @__PURE__ */ (0, Z.jsx)(oe, {
|
|
1517
|
+
...Q,
|
|
1518
|
+
title: Ot,
|
|
1519
|
+
mainContent: /* @__PURE__ */ (0, Z.jsxs)(Z.Fragment, { children: [
|
|
1520
|
+
Mt,
|
|
1521
|
+
Ft,
|
|
1522
|
+
/* @__PURE__ */ (0, Z.jsx)(tt, {
|
|
1523
|
+
selectedRows: ge,
|
|
1524
|
+
actions: bt ?? [],
|
|
1525
|
+
onAction: (e, t) => Ue({
|
|
1507
1526
|
type: e,
|
|
1508
1527
|
params: { records: t }
|
|
1509
1528
|
}),
|
|
1510
|
-
onClearSelection: () =>
|
|
1529
|
+
onClearSelection: () => ve([])
|
|
1511
1530
|
})
|
|
1512
1531
|
] }),
|
|
1513
|
-
children: (e) =>
|
|
1514
|
-
}) : /* @__PURE__ */ (0,
|
|
1515
|
-
ref:
|
|
1532
|
+
children: (e) => Nt(e)
|
|
1533
|
+
}), It] }) : /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
1534
|
+
ref: Te,
|
|
1516
1535
|
className: "relative h-full",
|
|
1517
1536
|
children: [
|
|
1518
|
-
De > 0 && /* @__PURE__ */ (0,
|
|
1537
|
+
De > 0 && /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
1519
1538
|
className: "flex items-center justify-center text-xs text-muted-foreground",
|
|
1520
1539
|
style: { height: De },
|
|
1521
1540
|
children: M(Ee ? "grid.refreshing" : "grid.pullToRefresh")
|
|
1522
1541
|
}),
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
/* @__PURE__ */ (0,
|
|
1526
|
-
selectedRows:
|
|
1527
|
-
actions:
|
|
1528
|
-
onAction: (e, t) =>
|
|
1542
|
+
Mt,
|
|
1543
|
+
Ft,
|
|
1544
|
+
/* @__PURE__ */ (0, Z.jsx)(tt, {
|
|
1545
|
+
selectedRows: ge,
|
|
1546
|
+
actions: bt ?? [],
|
|
1547
|
+
onAction: (e, t) => Ue({
|
|
1529
1548
|
type: e,
|
|
1530
1549
|
params: { records: t }
|
|
1531
1550
|
}),
|
|
1532
|
-
onClearSelection: () =>
|
|
1551
|
+
onClearSelection: () => ve([])
|
|
1533
1552
|
}),
|
|
1534
|
-
|
|
1535
|
-
...
|
|
1536
|
-
title:
|
|
1537
|
-
children: (e) =>
|
|
1538
|
-
})
|
|
1553
|
+
Q.isOverlay && /* @__PURE__ */ (0, Z.jsx)(oe, {
|
|
1554
|
+
...Q,
|
|
1555
|
+
title: Ot,
|
|
1556
|
+
children: (e) => Nt(e)
|
|
1557
|
+
}),
|
|
1558
|
+
It
|
|
1539
1559
|
]
|
|
1540
1560
|
});
|
|
1541
1561
|
};
|
|
1542
1562
|
//#endregion
|
|
1543
1563
|
//#region ../../node_modules/.pnpm/@tanstack+virtual-core@3.14.0/node_modules/@tanstack/virtual-core/dist/esm/utils.js
|
|
1544
|
-
function
|
|
1564
|
+
function ct(e, t, n) {
|
|
1545
1565
|
let r = n.initialDeps ?? [], i, a = !0;
|
|
1546
1566
|
function o() {
|
|
1547
1567
|
let o;
|
|
@@ -1566,26 +1586,26 @@ function X(e, t, n) {
|
|
|
1566
1586
|
r = e;
|
|
1567
1587
|
}, o;
|
|
1568
1588
|
}
|
|
1569
|
-
function
|
|
1589
|
+
function lt(e, t) {
|
|
1570
1590
|
if (e === void 0) throw Error(`Unexpected undefined${t ? `: ${t}` : ""}`);
|
|
1571
1591
|
return e;
|
|
1572
1592
|
}
|
|
1573
|
-
var
|
|
1593
|
+
var $ = (e, t) => Math.abs(e - t) < 1.01, ut = (e, t, n) => {
|
|
1574
1594
|
let r;
|
|
1575
1595
|
return function(...i) {
|
|
1576
1596
|
e.clearTimeout(r), r = e.setTimeout(() => t.apply(this, i), n);
|
|
1577
1597
|
};
|
|
1578
|
-
},
|
|
1598
|
+
}, dt = (e) => {
|
|
1579
1599
|
let { offsetWidth: t, offsetHeight: n } = e;
|
|
1580
1600
|
return {
|
|
1581
1601
|
width: t,
|
|
1582
1602
|
height: n
|
|
1583
1603
|
};
|
|
1584
|
-
},
|
|
1604
|
+
}, ft = (e) => e, pt = (e) => {
|
|
1585
1605
|
let t = Math.max(e.startIndex - e.overscan, 0), n = Math.min(e.endIndex + e.overscan, e.count - 1), r = [];
|
|
1586
1606
|
for (let e = t; e <= n; e++) r.push(e);
|
|
1587
1607
|
return r;
|
|
1588
|
-
},
|
|
1608
|
+
}, mt = (e, t) => {
|
|
1589
1609
|
let n = e.scrollElement;
|
|
1590
1610
|
if (!n) return;
|
|
1591
1611
|
let r = e.targetWindow;
|
|
@@ -1597,7 +1617,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1597
1617
|
height: Math.round(r)
|
|
1598
1618
|
});
|
|
1599
1619
|
};
|
|
1600
|
-
if (i(
|
|
1620
|
+
if (i(dt(n)), !r.ResizeObserver) return () => {};
|
|
1601
1621
|
let a = new r.ResizeObserver((t) => {
|
|
1602
1622
|
let r = () => {
|
|
1603
1623
|
let e = t[0];
|
|
@@ -1611,43 +1631,43 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1611
1631
|
return;
|
|
1612
1632
|
}
|
|
1613
1633
|
}
|
|
1614
|
-
i(
|
|
1634
|
+
i(dt(n));
|
|
1615
1635
|
};
|
|
1616
1636
|
e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(r) : r();
|
|
1617
1637
|
});
|
|
1618
1638
|
return a.observe(n, { box: "border-box" }), () => {
|
|
1619
1639
|
a.unobserve(n);
|
|
1620
1640
|
};
|
|
1621
|
-
},
|
|
1641
|
+
}, ht = { passive: !0 }, gt = typeof window > "u" ? !0 : "onscrollend" in window, _t = (e, t) => {
|
|
1622
1642
|
let n = e.scrollElement;
|
|
1623
1643
|
if (!n) return;
|
|
1624
1644
|
let r = e.targetWindow;
|
|
1625
1645
|
if (!r) return;
|
|
1626
|
-
let i = 0, a = e.options.useScrollendEvent &&
|
|
1646
|
+
let i = 0, a = e.options.useScrollendEvent && gt ? () => void 0 : ut(r, () => {
|
|
1627
1647
|
t(i, !1);
|
|
1628
1648
|
}, e.options.isScrollingResetDelay), o = (r) => () => {
|
|
1629
1649
|
let { horizontal: o, isRtl: s } = e.options;
|
|
1630
1650
|
i = o ? n.scrollLeft * (s && -1 || 1) : n.scrollTop, a(), t(i, r);
|
|
1631
1651
|
}, s = o(!0), c = o(!1);
|
|
1632
|
-
n.addEventListener("scroll", s,
|
|
1633
|
-
let l = e.options.useScrollendEvent &&
|
|
1634
|
-
return l && n.addEventListener("scrollend", c,
|
|
1652
|
+
n.addEventListener("scroll", s, ht);
|
|
1653
|
+
let l = e.options.useScrollendEvent && gt;
|
|
1654
|
+
return l && n.addEventListener("scrollend", c, ht), () => {
|
|
1635
1655
|
n.removeEventListener("scroll", s), l && n.removeEventListener("scrollend", c);
|
|
1636
1656
|
};
|
|
1637
|
-
},
|
|
1657
|
+
}, vt = (e, t, n) => {
|
|
1638
1658
|
if (t?.borderBoxSize) {
|
|
1639
1659
|
let e = t.borderBoxSize[0];
|
|
1640
1660
|
if (e) return Math.round(e[n.options.horizontal ? "inlineSize" : "blockSize"]);
|
|
1641
1661
|
}
|
|
1642
1662
|
return e[n.options.horizontal ? "offsetWidth" : "offsetHeight"];
|
|
1643
|
-
},
|
|
1663
|
+
}, yt = (e, { adjustments: t = 0, behavior: n }, r) => {
|
|
1644
1664
|
var i, a;
|
|
1645
1665
|
let o = e + t;
|
|
1646
1666
|
(a = (i = r.scrollElement)?.scrollTo) == null || a.call(i, {
|
|
1647
1667
|
[r.options.horizontal ? "left" : "top"]: o,
|
|
1648
1668
|
behavior: n
|
|
1649
1669
|
});
|
|
1650
|
-
},
|
|
1670
|
+
}, bt = class {
|
|
1651
1671
|
constructor(e) {
|
|
1652
1672
|
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 = () => {
|
|
1653
1673
|
var e;
|
|
@@ -1686,10 +1706,10 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1686
1706
|
scrollPaddingStart: 0,
|
|
1687
1707
|
scrollPaddingEnd: 0,
|
|
1688
1708
|
horizontal: !1,
|
|
1689
|
-
getItemKey:
|
|
1690
|
-
rangeExtractor:
|
|
1709
|
+
getItemKey: ft,
|
|
1710
|
+
rangeExtractor: pt,
|
|
1691
1711
|
onChange: () => {},
|
|
1692
|
-
measureElement:
|
|
1712
|
+
measureElement: vt,
|
|
1693
1713
|
initialRect: {
|
|
1694
1714
|
width: 0,
|
|
1695
1715
|
height: 0
|
|
@@ -1710,7 +1730,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1710
1730
|
}, this.notify = (e) => {
|
|
1711
1731
|
var t, n;
|
|
1712
1732
|
(n = (t = this.options).onChange) == null || n.call(t, this, e);
|
|
1713
|
-
}, this.maybeNotify =
|
|
1733
|
+
}, this.maybeNotify = ct(() => (this.calculateRange(), [
|
|
1714
1734
|
this.isScrolling,
|
|
1715
1735
|
this.range ? this.range.startIndex : null,
|
|
1716
1736
|
this.range ? this.range.endIndex : null
|
|
@@ -1755,7 +1775,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1755
1775
|
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;
|
|
1756
1776
|
}
|
|
1757
1777
|
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;
|
|
1758
|
-
}, this.getMeasurementOptions =
|
|
1778
|
+
}, this.getMeasurementOptions = ct(() => [
|
|
1759
1779
|
this.options.count,
|
|
1760
1780
|
this.options.paddingStart,
|
|
1761
1781
|
this.options.scrollMargin,
|
|
@@ -1771,7 +1791,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1771
1791
|
enabled: i,
|
|
1772
1792
|
lanes: a,
|
|
1773
1793
|
laneAssignmentMode: o
|
|
1774
|
-
}), { key: !1 }), this.getMeasurements =
|
|
1794
|
+
}), { key: !1 }), this.getMeasurements = ct(() => [this.getMeasurementOptions(), this.itemSizeCache], ({ count: e, paddingStart: t, scrollMargin: n, getItemKey: r, enabled: i, lanes: a, laneAssignmentMode: o }, s) => {
|
|
1775
1795
|
if (!i) return this.measurementsCache = [], this.itemSizeCache.clear(), this.laneAssignments.clear(), [];
|
|
1776
1796
|
if (this.laneAssignments.size > e) for (let t of this.laneAssignments.keys()) t >= e && this.laneAssignments.delete(t);
|
|
1777
1797
|
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) => {
|
|
@@ -1808,12 +1828,12 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1808
1828
|
}, {
|
|
1809
1829
|
key: process.env.NODE_ENV !== "production" && "getMeasurements",
|
|
1810
1830
|
debug: () => this.options.debug
|
|
1811
|
-
}), this.calculateRange =
|
|
1831
|
+
}), this.calculateRange = ct(() => [
|
|
1812
1832
|
this.getMeasurements(),
|
|
1813
1833
|
this.getSize(),
|
|
1814
1834
|
this.getScrollOffset(),
|
|
1815
1835
|
this.options.lanes
|
|
1816
|
-
], (e, t, n, r) => this.range = e.length > 0 && t > 0 ?
|
|
1836
|
+
], (e, t, n, r) => this.range = e.length > 0 && t > 0 ? St({
|
|
1817
1837
|
measurements: e,
|
|
1818
1838
|
outerSize: t,
|
|
1819
1839
|
scrollOffset: n,
|
|
@@ -1821,7 +1841,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1821
1841
|
}) : null, {
|
|
1822
1842
|
key: process.env.NODE_ENV !== "production" && "calculateRange",
|
|
1823
1843
|
debug: () => this.options.debug
|
|
1824
|
-
}), this.getVirtualIndexes =
|
|
1844
|
+
}), this.getVirtualIndexes = ct(() => {
|
|
1825
1845
|
let e = null, t = null, n = this.calculateRange();
|
|
1826
1846
|
return n && (e = n.startIndex, t = n.endIndex), this.maybeNotify.updateDeps([
|
|
1827
1847
|
this.isScrolling,
|
|
@@ -1870,7 +1890,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1870
1890
|
adjustments: this.scrollAdjustments += r,
|
|
1871
1891
|
behavior: void 0
|
|
1872
1892
|
})), this.pendingMeasuredCacheIndexes.push(n.index), this.itemSizeCache = new Map(this.itemSizeCache.set(n.key, t)), this.notify(!1));
|
|
1873
|
-
}, this.getVirtualItems =
|
|
1893
|
+
}, this.getVirtualItems = ct(() => [this.getVirtualIndexes(), this.getMeasurements()], (e, t) => {
|
|
1874
1894
|
let n = [];
|
|
1875
1895
|
for (let r = 0, i = e.length; r < i; r++) {
|
|
1876
1896
|
let i = t[e[r]];
|
|
@@ -1882,7 +1902,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1882
1902
|
debug: () => this.options.debug
|
|
1883
1903
|
}), this.getVirtualItemForOffset = (e) => {
|
|
1884
1904
|
let t = this.getMeasurements();
|
|
1885
|
-
if (t.length !== 0) return
|
|
1905
|
+
if (t.length !== 0) return lt(t[xt(0, t.length - 1, (e) => lt(t[e]).start, e)]);
|
|
1886
1906
|
}, this.getMaxScrollOffset = () => {
|
|
1887
1907
|
if (!this.scrollElement) return 0;
|
|
1888
1908
|
if ("scrollHeight" in this.scrollElement) return this.options.horizontal ? this.scrollElement.scrollWidth - this.scrollElement.clientWidth : this.scrollElement.scrollHeight - this.scrollElement.clientHeight;
|
|
@@ -1986,7 +2006,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1986
2006
|
return;
|
|
1987
2007
|
}
|
|
1988
2008
|
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;
|
|
1989
|
-
if (!n &&
|
|
2009
|
+
if (!n && $(t, this.getScrollOffset())) {
|
|
1990
2010
|
if (this.scrollState.stableFrames++, this.scrollState.stableFrames >= 1) {
|
|
1991
2011
|
this.scrollState = null;
|
|
1992
2012
|
return;
|
|
@@ -1997,7 +2017,7 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
1997
2017
|
}));
|
|
1998
2018
|
this.scheduleScrollReconcile();
|
|
1999
2019
|
}
|
|
2000
|
-
},
|
|
2020
|
+
}, xt = (e, t, n, r) => {
|
|
2001
2021
|
for (; e <= t;) {
|
|
2002
2022
|
let i = (e + t) / 2 | 0, a = n(i);
|
|
2003
2023
|
if (a < r) e = i + 1;
|
|
@@ -2006,13 +2026,13 @@ var st = (e, t) => Math.abs(e - t) < 1.01, ct = (e, t, n) => {
|
|
|
2006
2026
|
}
|
|
2007
2027
|
return e > 0 ? e - 1 : 0;
|
|
2008
2028
|
};
|
|
2009
|
-
function
|
|
2029
|
+
function St({ measurements: e, outerSize: t, scrollOffset: n, lanes: r }) {
|
|
2010
2030
|
let i = e.length - 1, a = (t) => e[t].start;
|
|
2011
2031
|
if (e.length <= r) return {
|
|
2012
2032
|
startIndex: 0,
|
|
2013
2033
|
endIndex: i
|
|
2014
2034
|
};
|
|
2015
|
-
let o =
|
|
2035
|
+
let o = xt(0, i, a, n), s = o;
|
|
2016
2036
|
if (r === 1) for (; s < i && e[s].end < n + t;) s++;
|
|
2017
2037
|
else if (r > 1) {
|
|
2018
2038
|
let a = Array(r).fill(0);
|
|
@@ -2034,53 +2054,53 @@ function vt({ measurements: e, outerSize: t, scrollOffset: n, lanes: r }) {
|
|
|
2034
2054
|
}
|
|
2035
2055
|
//#endregion
|
|
2036
2056
|
//#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
|
|
2037
|
-
var
|
|
2038
|
-
function
|
|
2057
|
+
var Ct = typeof document < "u" ? e.useLayoutEffect : e.useEffect;
|
|
2058
|
+
function wt({ useFlushSync: t = !0, ...n }) {
|
|
2039
2059
|
let r = e.useReducer(() => ({}), {})[1], i = {
|
|
2040
2060
|
...n,
|
|
2041
2061
|
onChange: (e, i) => {
|
|
2042
2062
|
var a;
|
|
2043
|
-
t && i ?
|
|
2063
|
+
t && i ? q(r) : r(), (a = n.onChange) == null || a.call(n, e, i);
|
|
2044
2064
|
}
|
|
2045
|
-
}, [a] = e.useState(() => new
|
|
2046
|
-
return a.setOptions(i),
|
|
2065
|
+
}, [a] = e.useState(() => new bt(i));
|
|
2066
|
+
return a.setOptions(i), Ct(() => a._didMount(), []), Ct(() => a._willUpdate()), a;
|
|
2047
2067
|
}
|
|
2048
|
-
function
|
|
2049
|
-
return
|
|
2050
|
-
observeElementRect:
|
|
2051
|
-
observeElementOffset:
|
|
2052
|
-
scrollToFn:
|
|
2068
|
+
function Tt(e) {
|
|
2069
|
+
return wt({
|
|
2070
|
+
observeElementRect: mt,
|
|
2071
|
+
observeElementOffset: _t,
|
|
2072
|
+
scrollToFn: yt,
|
|
2053
2073
|
...e
|
|
2054
2074
|
});
|
|
2055
2075
|
}
|
|
2056
2076
|
//#endregion
|
|
2057
2077
|
//#region src/VirtualGrid.tsx
|
|
2058
|
-
var
|
|
2059
|
-
let u = o(null), d =
|
|
2078
|
+
var Et = ({ data: e, columns: t, rowHeight: n = 40, height: r = 600, className: i = "", headerClassName: a = "", rowClassName: s, onRowClick: c, overscan: l = 5 }) => {
|
|
2079
|
+
let u = o(null), d = Tt({
|
|
2060
2080
|
count: e.length,
|
|
2061
2081
|
getScrollElement: () => u.current,
|
|
2062
2082
|
estimateSize: () => n,
|
|
2063
2083
|
overscan: l
|
|
2064
2084
|
}), f = d.getVirtualItems();
|
|
2065
|
-
return /* @__PURE__ */ (0,
|
|
2085
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2066
2086
|
className: i,
|
|
2067
2087
|
children: [
|
|
2068
|
-
/* @__PURE__ */ (0,
|
|
2088
|
+
/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2069
2089
|
className: `grid border-b sticky top-0 bg-muted/30 z-10 ${a}`,
|
|
2070
2090
|
style: { gridTemplateColumns: t.map((e) => e.width || "1fr").join(" ") },
|
|
2071
|
-
children: t.map((e, t) => /* @__PURE__ */ (0,
|
|
2091
|
+
children: t.map((e, t) => /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2072
2092
|
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"}`,
|
|
2073
2093
|
children: e.header
|
|
2074
2094
|
}, t))
|
|
2075
2095
|
}),
|
|
2076
|
-
/* @__PURE__ */ (0,
|
|
2096
|
+
/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2077
2097
|
ref: u,
|
|
2078
2098
|
className: "overflow-auto",
|
|
2079
2099
|
style: {
|
|
2080
2100
|
height: typeof r == "number" ? `${r}px` : r,
|
|
2081
2101
|
contain: "strict"
|
|
2082
2102
|
},
|
|
2083
|
-
children: /* @__PURE__ */ (0,
|
|
2103
|
+
children: /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2084
2104
|
style: {
|
|
2085
2105
|
height: `${d.getTotalSize()}px`,
|
|
2086
2106
|
width: "100%",
|
|
@@ -2088,7 +2108,7 @@ var St = ({ data: e, columns: t, rowHeight: n = 40, height: r = 600, className:
|
|
|
2088
2108
|
},
|
|
2089
2109
|
children: f.map((n) => {
|
|
2090
2110
|
let r = e[n.index];
|
|
2091
|
-
return /* @__PURE__ */ (0,
|
|
2111
|
+
return /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2092
2112
|
className: `grid border-b hover:bg-muted/50 cursor-pointer ${typeof s == "function" ? s(r, n.index) : s || ""}`,
|
|
2093
2113
|
style: {
|
|
2094
2114
|
position: "absolute",
|
|
@@ -2102,7 +2122,7 @@ var St = ({ data: e, columns: t, rowHeight: n = 40, height: r = 600, className:
|
|
|
2102
2122
|
onClick: () => c?.(r, n.index),
|
|
2103
2123
|
children: t.map((e, t) => {
|
|
2104
2124
|
let n = r[e.accessorKey], i = e.cell ? e.cell(n, r) : typeof n == "object" && n ? String(n) : n;
|
|
2105
|
-
return /* @__PURE__ */ (0,
|
|
2125
|
+
return /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2106
2126
|
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"}`,
|
|
2107
2127
|
children: i
|
|
2108
2128
|
}, t);
|
|
@@ -2111,7 +2131,7 @@ var St = ({ data: e, columns: t, rowHeight: n = 40, height: r = 600, className:
|
|
|
2111
2131
|
})
|
|
2112
2132
|
})
|
|
2113
2133
|
}),
|
|
2114
|
-
/* @__PURE__ */ (0,
|
|
2134
|
+
/* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2115
2135
|
className: "px-4 py-2 text-xs text-muted-foreground border-t",
|
|
2116
2136
|
children: [
|
|
2117
2137
|
"Showing ",
|
|
@@ -2123,8 +2143,8 @@ var St = ({ data: e, columns: t, rowHeight: n = 40, height: r = 600, className:
|
|
|
2123
2143
|
})
|
|
2124
2144
|
]
|
|
2125
2145
|
});
|
|
2126
|
-
},
|
|
2127
|
-
function
|
|
2146
|
+
}, Dt = 10;
|
|
2147
|
+
function Ot(e) {
|
|
2128
2148
|
let t = [], n = [], r = "", i = !1;
|
|
2129
2149
|
for (let a = 0; a < e.length; a++) {
|
|
2130
2150
|
let o = e[a], s = e[a + 1];
|
|
@@ -2132,7 +2152,7 @@ function wt(e) {
|
|
|
2132
2152
|
}
|
|
2133
2153
|
return n.push(r.trim()), n.some((e) => e !== "") && t.push(n), t;
|
|
2134
2154
|
}
|
|
2135
|
-
function
|
|
2155
|
+
function kt(e, t) {
|
|
2136
2156
|
if (!e) return !0;
|
|
2137
2157
|
switch (t) {
|
|
2138
2158
|
case "number":
|
|
@@ -2151,7 +2171,7 @@ function Tt(e, t) {
|
|
|
2151
2171
|
default: return !0;
|
|
2152
2172
|
}
|
|
2153
2173
|
}
|
|
2154
|
-
function
|
|
2174
|
+
function At(e, t) {
|
|
2155
2175
|
let n = {};
|
|
2156
2176
|
return e.forEach((e, r) => {
|
|
2157
2177
|
let i = e.toLowerCase().replace(/[_\s-]/g, ""), a = t.find((e) => {
|
|
@@ -2161,7 +2181,45 @@ function Et(e, t) {
|
|
|
2161
2181
|
a && (n[r] = a.name);
|
|
2162
2182
|
}), n;
|
|
2163
2183
|
}
|
|
2164
|
-
function
|
|
2184
|
+
function jt() {
|
|
2185
|
+
if (typeof window > "u") return null;
|
|
2186
|
+
try {
|
|
2187
|
+
return window.localStorage;
|
|
2188
|
+
} catch {
|
|
2189
|
+
return null;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
function Mt(e, t) {
|
|
2193
|
+
if (!e) return [];
|
|
2194
|
+
try {
|
|
2195
|
+
let n = e.getItem(t);
|
|
2196
|
+
if (!n) return [];
|
|
2197
|
+
let r = JSON.parse(n);
|
|
2198
|
+
return Array.isArray(r) ? r.filter((e) => e && e.id && e.name && e.mapping) : [];
|
|
2199
|
+
} catch {
|
|
2200
|
+
return [];
|
|
2201
|
+
}
|
|
2202
|
+
}
|
|
2203
|
+
function Nt(e, t, n) {
|
|
2204
|
+
if (e) try {
|
|
2205
|
+
e.setItem(t, JSON.stringify(n));
|
|
2206
|
+
} catch {}
|
|
2207
|
+
}
|
|
2208
|
+
function Pt(e, t) {
|
|
2209
|
+
let n = {};
|
|
2210
|
+
return Object.entries(t).forEach(([t, r]) => {
|
|
2211
|
+
let i = e[Number(t)];
|
|
2212
|
+
i && (n[i.trim().toLowerCase()] = r);
|
|
2213
|
+
}), n;
|
|
2214
|
+
}
|
|
2215
|
+
function Ft(e, t, n) {
|
|
2216
|
+
let r = new Set(n.map((e) => e.name)), i = {};
|
|
2217
|
+
return t.forEach((t, n) => {
|
|
2218
|
+
let a = e.mapping[t.trim().toLowerCase()];
|
|
2219
|
+
a && r.has(a) && (i[n] = a);
|
|
2220
|
+
}), i;
|
|
2221
|
+
}
|
|
2222
|
+
function It(e, t, n) {
|
|
2165
2223
|
let r = [], i = {};
|
|
2166
2224
|
for (let a of t) {
|
|
2167
2225
|
let t = e[a.csvIdx] ?? "";
|
|
@@ -2173,7 +2231,7 @@ function Dt(e, t, n) {
|
|
|
2173
2231
|
});
|
|
2174
2232
|
continue;
|
|
2175
2233
|
}
|
|
2176
|
-
if (t && !
|
|
2234
|
+
if (t && !kt(t, a.field.type)) {
|
|
2177
2235
|
r.push({
|
|
2178
2236
|
row: n,
|
|
2179
2237
|
field: a.field.name,
|
|
@@ -2188,7 +2246,7 @@ function Dt(e, t, n) {
|
|
|
2188
2246
|
errors: r
|
|
2189
2247
|
};
|
|
2190
2248
|
}
|
|
2191
|
-
var
|
|
2249
|
+
var Lt = ({ onFileLoaded: e }) => {
|
|
2192
2250
|
let [t, n] = s(!1), [i, a] = s(null), o = r((t) => {
|
|
2193
2251
|
if (a(null), !t.name.endsWith(".csv")) {
|
|
2194
2252
|
a("Only CSV files are supported.");
|
|
@@ -2196,7 +2254,7 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2196
2254
|
}
|
|
2197
2255
|
let n = new FileReader();
|
|
2198
2256
|
n.onload = (t) => {
|
|
2199
|
-
let n =
|
|
2257
|
+
let n = Ot(t.target?.result);
|
|
2200
2258
|
if (n.length < 2) {
|
|
2201
2259
|
a("File must contain a header row and at least one data row.");
|
|
2202
2260
|
return;
|
|
@@ -2204,10 +2262,10 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2204
2262
|
e(n[0], n.slice(1));
|
|
2205
2263
|
}, n.readAsText(t);
|
|
2206
2264
|
}, [e]);
|
|
2207
|
-
return /* @__PURE__ */ (0,
|
|
2265
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2208
2266
|
className: "flex flex-col items-center gap-4 py-6",
|
|
2209
|
-
children: [/* @__PURE__ */ (0,
|
|
2210
|
-
className:
|
|
2267
|
+
children: [/* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2268
|
+
className: H("flex w-full flex-col items-center justify-center gap-3 rounded-lg border-2 border-dashed p-10 transition-colors", t ? "border-primary bg-primary/5" : "border-muted-foreground/25"),
|
|
2211
2269
|
onDragOver: (e) => {
|
|
2212
2270
|
e.preventDefault(), n(!0);
|
|
2213
2271
|
},
|
|
@@ -2218,12 +2276,12 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2218
2276
|
t && o(t);
|
|
2219
2277
|
},
|
|
2220
2278
|
children: [
|
|
2221
|
-
/* @__PURE__ */ (0,
|
|
2222
|
-
/* @__PURE__ */ (0,
|
|
2279
|
+
/* @__PURE__ */ (0, Z.jsx)(G, { className: "h-10 w-10 text-muted-foreground" }),
|
|
2280
|
+
/* @__PURE__ */ (0, Z.jsx)("p", {
|
|
2223
2281
|
className: "text-sm text-muted-foreground",
|
|
2224
2282
|
children: "Drag & drop a CSV file here, or click to browse"
|
|
2225
2283
|
}),
|
|
2226
|
-
/* @__PURE__ */ (0,
|
|
2284
|
+
/* @__PURE__ */ (0, Z.jsxs)("label", { children: [/* @__PURE__ */ (0, Z.jsx)("input", {
|
|
2227
2285
|
type: "file",
|
|
2228
2286
|
accept: ".csv",
|
|
2229
2287
|
className: "hidden",
|
|
@@ -2231,127 +2289,243 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2231
2289
|
let t = e.target.files?.[0];
|
|
2232
2290
|
t && o(t);
|
|
2233
2291
|
}
|
|
2234
|
-
}), /* @__PURE__ */ (0,
|
|
2292
|
+
}), /* @__PURE__ */ (0, Z.jsx)(T, {
|
|
2235
2293
|
variant: "outline",
|
|
2236
2294
|
size: "sm",
|
|
2237
2295
|
asChild: !0,
|
|
2238
|
-
children: /* @__PURE__ */ (0,
|
|
2296
|
+
children: /* @__PURE__ */ (0, Z.jsx)("span", { children: "Browse Files" })
|
|
2239
2297
|
})] })
|
|
2240
2298
|
]
|
|
2241
|
-
}), i && /* @__PURE__ */ (0,
|
|
2299
|
+
}), i && /* @__PURE__ */ (0, Z.jsxs)("p", {
|
|
2242
2300
|
className: "flex items-center gap-1 text-sm text-destructive",
|
|
2243
2301
|
children: [
|
|
2244
|
-
/* @__PURE__ */ (0,
|
|
2302
|
+
/* @__PURE__ */ (0, Z.jsx)(U, { className: "h-4 w-4" }),
|
|
2245
2303
|
" ",
|
|
2246
2304
|
i
|
|
2247
2305
|
]
|
|
2248
2306
|
})]
|
|
2249
2307
|
});
|
|
2250
|
-
},
|
|
2251
|
-
let o =
|
|
2308
|
+
}, Rt = ({ templates: e, selectedId: t, onSelect: n, onSaveAs: r, onDelete: i, disabled: a }) => {
|
|
2309
|
+
let [o, c] = s(""), [l, u] = s(!1);
|
|
2310
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2311
|
+
className: "mb-3 flex flex-wrap items-center gap-2 rounded-md border bg-muted/30 p-2",
|
|
2312
|
+
"data-testid": "import-template-bar",
|
|
2313
|
+
children: [
|
|
2314
|
+
/* @__PURE__ */ (0, Z.jsx)(Ne, { className: "h-4 w-4 text-muted-foreground" }),
|
|
2315
|
+
/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
2316
|
+
className: "text-xs font-medium text-muted-foreground",
|
|
2317
|
+
children: "Mapping template:"
|
|
2318
|
+
}),
|
|
2319
|
+
/* @__PURE__ */ (0, Z.jsxs)(F, {
|
|
2320
|
+
value: t ?? "__none__",
|
|
2321
|
+
onValueChange: (e) => e !== "__none__" && n(e),
|
|
2322
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(R, {
|
|
2323
|
+
className: "h-7 w-48 text-xs",
|
|
2324
|
+
"data-testid": "import-template-select",
|
|
2325
|
+
children: /* @__PURE__ */ (0, Z.jsx)(le, { placeholder: e.length ? "Choose template…" : "No saved templates" })
|
|
2326
|
+
}), /* @__PURE__ */ (0, Z.jsxs)(I, { children: [/* @__PURE__ */ (0, Z.jsx)(L, {
|
|
2327
|
+
value: "__none__",
|
|
2328
|
+
disabled: e.length === 0,
|
|
2329
|
+
children: e.length ? "— None —" : "No saved templates"
|
|
2330
|
+
}), e.map((e) => /* @__PURE__ */ (0, Z.jsx)(L, {
|
|
2331
|
+
value: e.id,
|
|
2332
|
+
children: e.name
|
|
2333
|
+
}, e.id))] })]
|
|
2334
|
+
}),
|
|
2335
|
+
l ? /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2336
|
+
className: "flex items-center gap-1",
|
|
2337
|
+
children: [
|
|
2338
|
+
/* @__PURE__ */ (0, Z.jsx)(M, {
|
|
2339
|
+
value: o,
|
|
2340
|
+
onChange: (e) => c(e.target.value),
|
|
2341
|
+
placeholder: "Template name",
|
|
2342
|
+
className: "h-7 w-40 text-xs",
|
|
2343
|
+
"data-testid": "import-template-name-input",
|
|
2344
|
+
autoFocus: !0
|
|
2345
|
+
}),
|
|
2346
|
+
/* @__PURE__ */ (0, Z.jsx)(T, {
|
|
2347
|
+
type: "button",
|
|
2348
|
+
size: "sm",
|
|
2349
|
+
onClick: () => {
|
|
2350
|
+
o.trim() && (r(o.trim()), c(""), u(!1));
|
|
2351
|
+
},
|
|
2352
|
+
disabled: !o.trim() || a,
|
|
2353
|
+
"data-testid": "import-template-confirm-save",
|
|
2354
|
+
children: "Save"
|
|
2355
|
+
}),
|
|
2356
|
+
/* @__PURE__ */ (0, Z.jsx)(T, {
|
|
2357
|
+
type: "button",
|
|
2358
|
+
variant: "ghost",
|
|
2359
|
+
size: "sm",
|
|
2360
|
+
onClick: () => {
|
|
2361
|
+
u(!1), c("");
|
|
2362
|
+
},
|
|
2363
|
+
children: "Cancel"
|
|
2364
|
+
})
|
|
2365
|
+
]
|
|
2366
|
+
}) : /* @__PURE__ */ (0, Z.jsx)(T, {
|
|
2367
|
+
type: "button",
|
|
2368
|
+
variant: "outline",
|
|
2369
|
+
size: "sm",
|
|
2370
|
+
onClick: () => u(!0),
|
|
2371
|
+
disabled: a,
|
|
2372
|
+
"data-testid": "import-template-save-btn",
|
|
2373
|
+
children: "Save current"
|
|
2374
|
+
}),
|
|
2375
|
+
t && /* @__PURE__ */ (0, Z.jsx)(T, {
|
|
2376
|
+
type: "button",
|
|
2377
|
+
variant: "ghost",
|
|
2378
|
+
size: "sm",
|
|
2379
|
+
onClick: i,
|
|
2380
|
+
"aria-label": "Delete template",
|
|
2381
|
+
"data-testid": "import-template-delete-btn",
|
|
2382
|
+
children: /* @__PURE__ */ (0, Z.jsx)(Fe, { className: "h-3.5 w-3.5" })
|
|
2383
|
+
})
|
|
2384
|
+
]
|
|
2385
|
+
});
|
|
2386
|
+
}, zt = ({ headers: e, fields: t, mapping: n, onMappingChange: i, templates: o, selectedTemplateId: s, onSelectTemplate: c, onSaveTemplate: l, onDeleteTemplate: u }) => {
|
|
2387
|
+
let d = a(() => new Set(Object.values(n)), [n]), f = r((e, t) => {
|
|
2252
2388
|
let r = { ...n };
|
|
2253
2389
|
t === "__skip__" ? delete r[e] : r[e] = t, i(r);
|
|
2254
2390
|
}, [n, i]);
|
|
2255
|
-
return /* @__PURE__ */ (0,
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2391
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", { children: [/* @__PURE__ */ (0, Z.jsx)(Rt, {
|
|
2392
|
+
templates: o,
|
|
2393
|
+
selectedId: s,
|
|
2394
|
+
onSelect: c,
|
|
2395
|
+
onSaveAs: l,
|
|
2396
|
+
onDelete: u,
|
|
2397
|
+
disabled: Object.keys(n).length === 0
|
|
2398
|
+
}), /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2399
|
+
className: "max-h-[320px] overflow-auto",
|
|
2400
|
+
children: /* @__PURE__ */ (0, Z.jsxs)(ue, { children: [/* @__PURE__ */ (0, Z.jsx)(fe, { children: /* @__PURE__ */ (0, Z.jsxs)(V, { children: [
|
|
2401
|
+
/* @__PURE__ */ (0, Z.jsx)(B, { children: "CSV Column" }),
|
|
2402
|
+
/* @__PURE__ */ (0, Z.jsx)(B, { children: "Maps To" }),
|
|
2403
|
+
/* @__PURE__ */ (0, Z.jsx)(B, {
|
|
2261
2404
|
className: "w-24 text-center",
|
|
2262
2405
|
children: "Status"
|
|
2263
2406
|
})
|
|
2264
|
-
] }) }), /* @__PURE__ */ (0,
|
|
2265
|
-
/* @__PURE__ */ (0,
|
|
2407
|
+
] }) }), /* @__PURE__ */ (0, Z.jsx)(de, { children: e.map((e, r) => /* @__PURE__ */ (0, Z.jsxs)(V, { children: [
|
|
2408
|
+
/* @__PURE__ */ (0, Z.jsx)(z, {
|
|
2266
2409
|
className: "font-medium",
|
|
2267
2410
|
children: e
|
|
2268
2411
|
}),
|
|
2269
|
-
/* @__PURE__ */ (0,
|
|
2412
|
+
/* @__PURE__ */ (0, Z.jsx)(z, { children: /* @__PURE__ */ (0, Z.jsxs)(F, {
|
|
2270
2413
|
value: n[r] ?? "__skip__",
|
|
2271
|
-
onValueChange: (e) =>
|
|
2272
|
-
children: [/* @__PURE__ */ (0,
|
|
2414
|
+
onValueChange: (e) => f(r, e),
|
|
2415
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(R, {
|
|
2273
2416
|
className: "h-8 w-56",
|
|
2274
|
-
children: /* @__PURE__ */ (0,
|
|
2275
|
-
}), /* @__PURE__ */ (0,
|
|
2417
|
+
children: /* @__PURE__ */ (0, Z.jsx)(le, { placeholder: "Skip column" })
|
|
2418
|
+
}), /* @__PURE__ */ (0, Z.jsxs)(I, { children: [/* @__PURE__ */ (0, Z.jsx)(L, {
|
|
2276
2419
|
value: "__skip__",
|
|
2277
2420
|
children: "— Skip —"
|
|
2278
|
-
}), t.map((e) => /* @__PURE__ */ (0,
|
|
2421
|
+
}), t.map((e) => /* @__PURE__ */ (0, Z.jsxs)(L, {
|
|
2279
2422
|
value: e.name,
|
|
2280
|
-
disabled:
|
|
2423
|
+
disabled: d.has(e.name) && n[r] !== e.name,
|
|
2281
2424
|
children: [e.label, e.required ? " *" : ""]
|
|
2282
2425
|
}, e.name))] })]
|
|
2283
2426
|
}) }),
|
|
2284
|
-
/* @__PURE__ */ (0,
|
|
2427
|
+
/* @__PURE__ */ (0, Z.jsx)(z, {
|
|
2285
2428
|
className: "text-center",
|
|
2286
|
-
children: n[r] ? /* @__PURE__ */ (0,
|
|
2429
|
+
children: n[r] ? /* @__PURE__ */ (0, Z.jsx)(w, {
|
|
2287
2430
|
variant: "default",
|
|
2288
2431
|
className: "text-xs",
|
|
2289
2432
|
children: "Mapped"
|
|
2290
|
-
}) : /* @__PURE__ */ (0,
|
|
2433
|
+
}) : /* @__PURE__ */ (0, Z.jsx)(w, {
|
|
2291
2434
|
variant: "secondary",
|
|
2292
2435
|
className: "text-xs",
|
|
2293
2436
|
children: "Skipped"
|
|
2294
2437
|
})
|
|
2295
2438
|
})
|
|
2296
2439
|
] }, r)) })] })
|
|
2297
|
-
});
|
|
2298
|
-
},
|
|
2299
|
-
let
|
|
2440
|
+
})] });
|
|
2441
|
+
}, Bt = ({ headers: e, rows: t, mapping: n, fields: i, corrections: o, onCorrect: s }) => {
|
|
2442
|
+
let c = a(() => Object.entries(n).map(([t, n]) => ({
|
|
2300
2443
|
csvIdx: Number(t),
|
|
2301
2444
|
header: e[Number(t)],
|
|
2302
|
-
field:
|
|
2445
|
+
field: i.find((e) => e.name === n)
|
|
2303
2446
|
})), [
|
|
2304
2447
|
n,
|
|
2305
2448
|
e,
|
|
2306
|
-
|
|
2307
|
-
]),
|
|
2449
|
+
i
|
|
2450
|
+
]), l = t.slice(0, Dt), u = r((e, t) => {
|
|
2451
|
+
let n = o[e]?.[t];
|
|
2452
|
+
return n === void 0 ? l[e]?.[t] ?? "" : n;
|
|
2453
|
+
}, [o, l]), d = a(() => l.map((e, t) => {
|
|
2308
2454
|
let n = {};
|
|
2309
|
-
for (let
|
|
2310
|
-
let r = e
|
|
2311
|
-
|
|
2455
|
+
for (let e of c) {
|
|
2456
|
+
let r = u(t, e.csvIdx);
|
|
2457
|
+
e.field.required && !r ? n[e.csvIdx] = "Required" : r && !kt(r, e.field.type) && (n[e.csvIdx] = `Invalid ${e.field.type}`);
|
|
2312
2458
|
}
|
|
2313
2459
|
return n;
|
|
2314
|
-
}), [
|
|
2315
|
-
|
|
2460
|
+
}), [
|
|
2461
|
+
l,
|
|
2462
|
+
c,
|
|
2463
|
+
u
|
|
2464
|
+
]), f = d.filter((e) => Object.keys(e).length > 0).length, p = Object.keys(o).length;
|
|
2465
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2316
2466
|
className: "max-h-[360px] overflow-auto",
|
|
2317
2467
|
children: [
|
|
2318
|
-
|
|
2319
|
-
className: "mb-2 flex items-center gap-
|
|
2468
|
+
(f > 0 || p > 0) && /* @__PURE__ */ (0, Z.jsxs)("p", {
|
|
2469
|
+
className: "mb-2 flex items-center gap-2 text-xs",
|
|
2470
|
+
"data-testid": "import-preview-status",
|
|
2320
2471
|
children: [
|
|
2321
|
-
/* @__PURE__ */ (0,
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2472
|
+
f > 0 && /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
2473
|
+
className: "flex items-center gap-1 text-destructive",
|
|
2474
|
+
children: [
|
|
2475
|
+
/* @__PURE__ */ (0, Z.jsx)(U, { className: "h-3.5 w-3.5" }),
|
|
2476
|
+
" ",
|
|
2477
|
+
f,
|
|
2478
|
+
" row(s) with errors"
|
|
2479
|
+
]
|
|
2480
|
+
}),
|
|
2481
|
+
p > 0 && /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
2482
|
+
className: "flex items-center gap-1 text-emerald-600",
|
|
2483
|
+
children: [
|
|
2484
|
+
/* @__PURE__ */ (0, Z.jsx)(ye, { className: "h-3.5 w-3.5" }),
|
|
2485
|
+
" ",
|
|
2486
|
+
p,
|
|
2487
|
+
" row(s) corrected"
|
|
2488
|
+
]
|
|
2489
|
+
}),
|
|
2490
|
+
/* @__PURE__ */ (0, Z.jsx)("span", {
|
|
2491
|
+
className: "text-muted-foreground",
|
|
2492
|
+
children: "— click a highlighted cell to fix it inline."
|
|
2493
|
+
})
|
|
2325
2494
|
]
|
|
2326
2495
|
}),
|
|
2327
|
-
/* @__PURE__ */ (0,
|
|
2496
|
+
/* @__PURE__ */ (0, Z.jsxs)(ue, { children: [/* @__PURE__ */ (0, Z.jsx)(fe, { children: /* @__PURE__ */ (0, Z.jsxs)(V, { children: [/* @__PURE__ */ (0, Z.jsx)(B, {
|
|
2328
2497
|
className: "w-12",
|
|
2329
2498
|
children: "#"
|
|
2330
|
-
}),
|
|
2331
|
-
let n =
|
|
2332
|
-
return /* @__PURE__ */ (0,
|
|
2333
|
-
className:
|
|
2334
|
-
|
|
2499
|
+
}), c.map((e) => /* @__PURE__ */ (0, Z.jsx)(B, { children: e.field.label }, e.csvIdx))] }) }), /* @__PURE__ */ (0, Z.jsx)(de, { children: l.map((e, t) => {
|
|
2500
|
+
let n = d[t], r = Object.keys(n).length > 0, i = o[t] !== void 0;
|
|
2501
|
+
return /* @__PURE__ */ (0, Z.jsxs)(V, {
|
|
2502
|
+
className: H(r && "bg-destructive/5", !r && i && "bg-emerald-50 dark:bg-emerald-950/20"),
|
|
2503
|
+
"data-testid": `import-preview-row-${t}`,
|
|
2504
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(z, {
|
|
2335
2505
|
className: "text-xs text-muted-foreground",
|
|
2336
2506
|
children: t + 1
|
|
2337
|
-
}),
|
|
2338
|
-
let r = e
|
|
2339
|
-
return /* @__PURE__ */ (0,
|
|
2340
|
-
className:
|
|
2507
|
+
}), c.map((e) => {
|
|
2508
|
+
let r = u(t, e.csvIdx), i = n[e.csvIdx], a = o[t]?.[e.csvIdx] !== void 0;
|
|
2509
|
+
return /* @__PURE__ */ (0, Z.jsx)(z, {
|
|
2510
|
+
className: H(i && "text-destructive", a && !i && "text-emerald-600"),
|
|
2341
2511
|
title: i,
|
|
2342
|
-
children:
|
|
2343
|
-
|
|
2344
|
-
|
|
2512
|
+
children: /* @__PURE__ */ (0, Z.jsx)(M, {
|
|
2513
|
+
value: r,
|
|
2514
|
+
onChange: (n) => s(t, e.csvIdx, n.target.value),
|
|
2515
|
+
className: H("h-7 px-1 text-xs", i && "border-destructive", a && !i && "border-emerald-500"),
|
|
2516
|
+
"data-testid": `import-preview-cell-${t}-${e.csvIdx}`,
|
|
2517
|
+
"aria-invalid": i ? "true" : "false",
|
|
2518
|
+
"aria-label": `${e.field.label} for row ${t + 1}`
|
|
2345
2519
|
})
|
|
2346
|
-
},
|
|
2520
|
+
}, e.csvIdx);
|
|
2347
2521
|
})]
|
|
2348
2522
|
}, t);
|
|
2349
2523
|
}) })] }),
|
|
2350
|
-
/* @__PURE__ */ (0,
|
|
2524
|
+
/* @__PURE__ */ (0, Z.jsxs)("p", {
|
|
2351
2525
|
className: "mt-2 text-xs text-muted-foreground",
|
|
2352
2526
|
children: [
|
|
2353
2527
|
"Showing ",
|
|
2354
|
-
|
|
2528
|
+
l.length,
|
|
2355
2529
|
" of ",
|
|
2356
2530
|
t.length,
|
|
2357
2531
|
" rows"
|
|
@@ -2359,87 +2533,127 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2359
2533
|
})
|
|
2360
2534
|
]
|
|
2361
2535
|
});
|
|
2362
|
-
},
|
|
2363
|
-
let [
|
|
2364
|
-
|
|
2365
|
-
|
|
2366
|
-
}, [
|
|
2367
|
-
|
|
2368
|
-
|
|
2369
|
-
|
|
2370
|
-
|
|
2536
|
+
}, Vt = ({ objectName: e, objectLabel: n, fields: o, dataSource: c, onComplete: l, onCancel: u, open: d, onOpenChange: f, onErrorMode: p = "skip", templateStorageKey: m, templateStorage: h }) => {
|
|
2537
|
+
let [g, _] = s("upload"), [v, y] = s([]), [b, x] = s([]), [S, C] = s({}), [D, O] = s(!1), [k, A] = s(0), [j, ae] = s(null), [M, oe] = s({}), se = n ?? e, N = a(() => h === void 0 ? jt() : h, [h]), P = m ?? `objectui:import-templates:${e}`, [F, I] = s(() => Mt(N, P)), [L, R] = s(null);
|
|
2538
|
+
i(() => {
|
|
2539
|
+
I(Mt(N, P));
|
|
2540
|
+
}, [N, P]);
|
|
2541
|
+
let le = r((e) => {
|
|
2542
|
+
let t = F.find((t) => t.id === e);
|
|
2543
|
+
t && (R(e), C(Ft(t, v, o)));
|
|
2544
|
+
}, [
|
|
2545
|
+
F,
|
|
2546
|
+
v,
|
|
2547
|
+
o
|
|
2548
|
+
]), ue = r((e) => {
|
|
2549
|
+
let t = {
|
|
2550
|
+
id: `tpl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`,
|
|
2551
|
+
name: e,
|
|
2552
|
+
mapping: Pt(v, S),
|
|
2553
|
+
updatedAt: Date.now()
|
|
2554
|
+
}, n = [...F, t];
|
|
2555
|
+
I(n), R(t.id), Nt(N, P, n);
|
|
2556
|
+
}, [
|
|
2557
|
+
F,
|
|
2558
|
+
v,
|
|
2559
|
+
S,
|
|
2560
|
+
N,
|
|
2561
|
+
P
|
|
2562
|
+
]), de = r(() => {
|
|
2563
|
+
if (!L) return;
|
|
2564
|
+
let e = F.filter((e) => e.id !== L);
|
|
2565
|
+
I(e), R(null), Nt(N, P, e);
|
|
2566
|
+
}, [
|
|
2567
|
+
F,
|
|
2568
|
+
L,
|
|
2569
|
+
N,
|
|
2570
|
+
P
|
|
2571
|
+
]), z = r((e, t, n) => {
|
|
2572
|
+
oe((r) => {
|
|
2573
|
+
let i = { ...r }, a = { ...i[e] ?? {} };
|
|
2574
|
+
return n === (b[e]?.[t] ?? "") ? delete a[t] : a[t] = n, Object.keys(a).length === 0 ? delete i[e] : i[e] = a, i;
|
|
2575
|
+
});
|
|
2576
|
+
}, [b]), B = a(() => {
|
|
2577
|
+
let e = new Set(Object.values(S));
|
|
2578
|
+
return o.filter((t) => t.required && !e.has(t.name));
|
|
2579
|
+
}, [o, S]), fe = r((e, t) => {
|
|
2580
|
+
y(e), x(t), C(At(e, o)), oe({}), _("mapping");
|
|
2581
|
+
}, [o]), V = r(async () => {
|
|
2582
|
+
O(!0), A(0);
|
|
2583
|
+
let t = [], n = 0, r = 0, i = Object.entries(S).map(([e, t]) => ({
|
|
2371
2584
|
csvIdx: Number(e),
|
|
2372
|
-
field:
|
|
2585
|
+
field: o.find((e) => e.name === t)
|
|
2373
2586
|
}));
|
|
2374
|
-
for (let
|
|
2375
|
-
let { record:
|
|
2376
|
-
if (
|
|
2377
|
-
if (r++, t.push(...
|
|
2587
|
+
for (let a = 0; a < b.length; a++) {
|
|
2588
|
+
let o = b[a], s = M[a], { record: l, errors: u } = It(s ? o.map((e, t) => s[t] === void 0 ? e : s[t]) : o, i, a + 1);
|
|
2589
|
+
if (u.length > 0) {
|
|
2590
|
+
if (r++, t.push(...u), p === "stop") break;
|
|
2378
2591
|
} else try {
|
|
2379
|
-
|
|
2592
|
+
c?.create && await c.create(e, l), n++;
|
|
2380
2593
|
} catch (e) {
|
|
2381
2594
|
r++;
|
|
2382
2595
|
let n = e instanceof Error ? e.message : "Failed to create record";
|
|
2383
2596
|
if (t.push({
|
|
2384
|
-
row:
|
|
2597
|
+
row: a + 1,
|
|
2385
2598
|
field: "",
|
|
2386
2599
|
message: n
|
|
2387
|
-
}),
|
|
2600
|
+
}), p === "stop") break;
|
|
2388
2601
|
}
|
|
2389
|
-
|
|
2602
|
+
A(Math.round((a + 1) / b.length * 100));
|
|
2390
2603
|
}
|
|
2391
|
-
let
|
|
2392
|
-
totalRows:
|
|
2604
|
+
let a = {
|
|
2605
|
+
totalRows: b.length,
|
|
2393
2606
|
importedRows: n,
|
|
2394
2607
|
skippedRows: r,
|
|
2395
2608
|
errors: t
|
|
2396
2609
|
};
|
|
2397
|
-
|
|
2610
|
+
ae(a), O(!1), l?.(a);
|
|
2398
2611
|
}, [
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
i,
|
|
2612
|
+
b,
|
|
2613
|
+
S,
|
|
2402
2614
|
o,
|
|
2403
|
-
e,
|
|
2404
2615
|
c,
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2616
|
+
e,
|
|
2617
|
+
l,
|
|
2618
|
+
p,
|
|
2619
|
+
M
|
|
2620
|
+
]), pe = r(() => {
|
|
2621
|
+
_("upload"), y([]), x([]), C({}), A(0), ae(null), oe({}), R(null);
|
|
2622
|
+
}, []), U = r(() => {
|
|
2623
|
+
pe(), f?.(!1), u?.();
|
|
2410
2624
|
}, [
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2625
|
+
pe,
|
|
2626
|
+
f,
|
|
2627
|
+
u
|
|
2414
2628
|
]);
|
|
2415
|
-
return /* @__PURE__ */ (0,
|
|
2416
|
-
open:
|
|
2629
|
+
return /* @__PURE__ */ (0, Z.jsx)(ee, {
|
|
2630
|
+
open: d,
|
|
2417
2631
|
onOpenChange: (e) => {
|
|
2418
|
-
e ?
|
|
2632
|
+
e ? f?.(e) : U();
|
|
2419
2633
|
},
|
|
2420
|
-
children: /* @__PURE__ */ (0,
|
|
2634
|
+
children: /* @__PURE__ */ (0, Z.jsxs)(te, {
|
|
2421
2635
|
className: "sm:max-w-2xl",
|
|
2422
2636
|
children: [
|
|
2423
|
-
/* @__PURE__ */ (0,
|
|
2637
|
+
/* @__PURE__ */ (0, Z.jsxs)(E, { children: [/* @__PURE__ */ (0, Z.jsxs)(ie, {
|
|
2424
2638
|
className: "flex items-center gap-2",
|
|
2425
2639
|
children: [
|
|
2426
|
-
/* @__PURE__ */ (0,
|
|
2640
|
+
/* @__PURE__ */ (0, Z.jsx)(Te, { className: "h-5 w-5" }),
|
|
2427
2641
|
" Import ",
|
|
2428
|
-
|
|
2642
|
+
se
|
|
2429
2643
|
]
|
|
2430
|
-
}), /* @__PURE__ */ (0,
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2644
|
+
}), /* @__PURE__ */ (0, Z.jsxs)(ne, { children: [
|
|
2645
|
+
g === "upload" && "Upload a CSV file to get started.",
|
|
2646
|
+
g === "mapping" && "Map CSV columns to object fields.",
|
|
2647
|
+
g === "preview" && "Review data before importing."
|
|
2434
2648
|
] })] }),
|
|
2435
|
-
/* @__PURE__ */ (0,
|
|
2649
|
+
/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2436
2650
|
className: "flex items-center justify-center gap-2 text-xs text-muted-foreground",
|
|
2437
2651
|
children: [
|
|
2438
2652
|
"upload",
|
|
2439
2653
|
"mapping",
|
|
2440
2654
|
"preview"
|
|
2441
|
-
].map((e, n) => /* @__PURE__ */ (0,
|
|
2442
|
-
className:
|
|
2655
|
+
].map((e, n) => /* @__PURE__ */ (0, Z.jsxs)(t.Fragment, { children: [n > 0 && /* @__PURE__ */ (0, Z.jsx)(ge, { className: "h-3 w-3" }), /* @__PURE__ */ (0, Z.jsxs)("span", {
|
|
2656
|
+
className: H("rounded-full px-3 py-1", g === e ? "bg-primary text-primary-foreground" : "bg-muted"),
|
|
2443
2657
|
children: [
|
|
2444
2658
|
n + 1,
|
|
2445
2659
|
". ",
|
|
@@ -2447,27 +2661,27 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2447
2661
|
]
|
|
2448
2662
|
})] }, e))
|
|
2449
2663
|
}),
|
|
2450
|
-
|
|
2664
|
+
j ? /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2451
2665
|
className: "flex flex-col items-center gap-3 py-4",
|
|
2452
2666
|
children: [
|
|
2453
|
-
/* @__PURE__ */ (0,
|
|
2454
|
-
/* @__PURE__ */ (0,
|
|
2667
|
+
/* @__PURE__ */ (0, Z.jsx)(ye, { className: "h-10 w-10 text-green-500" }),
|
|
2668
|
+
/* @__PURE__ */ (0, Z.jsx)("p", {
|
|
2455
2669
|
className: "text-lg font-semibold",
|
|
2456
2670
|
children: "Import Complete"
|
|
2457
2671
|
}),
|
|
2458
|
-
/* @__PURE__ */ (0,
|
|
2672
|
+
/* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2459
2673
|
className: "flex gap-3",
|
|
2460
|
-
children: [/* @__PURE__ */ (0,
|
|
2674
|
+
children: [/* @__PURE__ */ (0, Z.jsxs)(w, {
|
|
2461
2675
|
variant: "default",
|
|
2462
|
-
children: [
|
|
2463
|
-
}),
|
|
2676
|
+
children: [j.importedRows, " imported"]
|
|
2677
|
+
}), j.skippedRows > 0 && /* @__PURE__ */ (0, Z.jsxs)(w, {
|
|
2464
2678
|
variant: "destructive",
|
|
2465
|
-
children: [
|
|
2679
|
+
children: [j.skippedRows, " skipped"]
|
|
2466
2680
|
})]
|
|
2467
2681
|
}),
|
|
2468
|
-
|
|
2682
|
+
j.errors.length > 0 && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2469
2683
|
className: "max-h-32 w-full overflow-auto rounded border p-2 text-xs",
|
|
2470
|
-
children: [
|
|
2684
|
+
children: [j.errors.slice(0, 10).map((e, t) => /* @__PURE__ */ (0, Z.jsxs)("p", {
|
|
2471
2685
|
className: "text-destructive",
|
|
2472
2686
|
children: [
|
|
2473
2687
|
"Row ",
|
|
@@ -2476,72 +2690,79 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2476
2690
|
": ",
|
|
2477
2691
|
e.message
|
|
2478
2692
|
]
|
|
2479
|
-
}, t)),
|
|
2693
|
+
}, t)), j.errors.length > 10 && /* @__PURE__ */ (0, Z.jsxs)("p", {
|
|
2480
2694
|
className: "text-muted-foreground",
|
|
2481
2695
|
children: [
|
|
2482
2696
|
"…and ",
|
|
2483
|
-
|
|
2697
|
+
j.errors.length - 10,
|
|
2484
2698
|
" more errors"
|
|
2485
2699
|
]
|
|
2486
2700
|
})]
|
|
2487
2701
|
})
|
|
2488
2702
|
]
|
|
2489
|
-
}) : /* @__PURE__ */ (0,
|
|
2490
|
-
|
|
2491
|
-
|
|
2492
|
-
headers:
|
|
2493
|
-
fields:
|
|
2494
|
-
mapping:
|
|
2495
|
-
onMappingChange:
|
|
2703
|
+
}) : /* @__PURE__ */ (0, Z.jsxs)(Z.Fragment, { children: [
|
|
2704
|
+
g === "upload" && /* @__PURE__ */ (0, Z.jsx)(Lt, { onFileLoaded: fe }),
|
|
2705
|
+
g === "mapping" && /* @__PURE__ */ (0, Z.jsx)(zt, {
|
|
2706
|
+
headers: v,
|
|
2707
|
+
fields: o,
|
|
2708
|
+
mapping: S,
|
|
2709
|
+
onMappingChange: C,
|
|
2710
|
+
templates: F,
|
|
2711
|
+
selectedTemplateId: L,
|
|
2712
|
+
onSelectTemplate: le,
|
|
2713
|
+
onSaveTemplate: ue,
|
|
2714
|
+
onDeleteTemplate: de
|
|
2496
2715
|
}),
|
|
2497
|
-
|
|
2498
|
-
headers:
|
|
2499
|
-
rows:
|
|
2500
|
-
mapping:
|
|
2501
|
-
fields:
|
|
2716
|
+
g === "preview" && /* @__PURE__ */ (0, Z.jsx)(Bt, {
|
|
2717
|
+
headers: v,
|
|
2718
|
+
rows: b,
|
|
2719
|
+
mapping: S,
|
|
2720
|
+
fields: o,
|
|
2721
|
+
corrections: M,
|
|
2722
|
+
onCorrect: z
|
|
2502
2723
|
}),
|
|
2503
|
-
|
|
2724
|
+
D && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2504
2725
|
className: "flex flex-col gap-1",
|
|
2505
|
-
children: [/* @__PURE__ */ (0,
|
|
2506
|
-
value:
|
|
2726
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(ce, {
|
|
2727
|
+
value: k,
|
|
2507
2728
|
className: "h-2"
|
|
2508
|
-
}), /* @__PURE__ */ (0,
|
|
2729
|
+
}), /* @__PURE__ */ (0, Z.jsxs)("p", {
|
|
2509
2730
|
className: "text-center text-xs text-muted-foreground",
|
|
2510
2731
|
children: [
|
|
2511
2732
|
"Importing… ",
|
|
2512
|
-
|
|
2733
|
+
k,
|
|
2513
2734
|
"%"
|
|
2514
2735
|
]
|
|
2515
2736
|
})]
|
|
2516
2737
|
})
|
|
2517
2738
|
] }),
|
|
2518
|
-
/* @__PURE__ */ (0,
|
|
2739
|
+
/* @__PURE__ */ (0, Z.jsx)(re, {
|
|
2519
2740
|
className: "gap-2 sm:gap-0",
|
|
2520
|
-
children:
|
|
2521
|
-
onClick:
|
|
2741
|
+
children: j ? /* @__PURE__ */ (0, Z.jsx)(T, {
|
|
2742
|
+
onClick: U,
|
|
2522
2743
|
children: "Close"
|
|
2523
|
-
}) : /* @__PURE__ */ (0,
|
|
2524
|
-
/* @__PURE__ */ (0,
|
|
2744
|
+
}) : /* @__PURE__ */ (0, Z.jsxs)(Z.Fragment, { children: [
|
|
2745
|
+
/* @__PURE__ */ (0, Z.jsxs)(T, {
|
|
2525
2746
|
variant: "ghost",
|
|
2526
|
-
onClick:
|
|
2527
|
-
disabled:
|
|
2528
|
-
children: [/* @__PURE__ */ (0,
|
|
2747
|
+
onClick: U,
|
|
2748
|
+
disabled: D,
|
|
2749
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(K, { className: "mr-1 h-4 w-4" }), " Cancel"]
|
|
2529
2750
|
}),
|
|
2530
|
-
(
|
|
2751
|
+
(g === "mapping" || g === "preview") && /* @__PURE__ */ (0, Z.jsxs)(T, {
|
|
2531
2752
|
variant: "outline",
|
|
2532
|
-
onClick: () =>
|
|
2533
|
-
disabled:
|
|
2534
|
-
children: [/* @__PURE__ */ (0,
|
|
2753
|
+
onClick: () => _(g === "mapping" ? "upload" : "mapping"),
|
|
2754
|
+
disabled: D,
|
|
2755
|
+
children: [/* @__PURE__ */ (0, Z.jsx)(he, { className: "mr-1 h-4 w-4" }), " Back"]
|
|
2535
2756
|
}),
|
|
2536
|
-
|
|
2537
|
-
onClick: () =>
|
|
2538
|
-
disabled: Object.keys(
|
|
2539
|
-
children: ["Next ", /* @__PURE__ */ (0,
|
|
2757
|
+
g === "mapping" && /* @__PURE__ */ (0, Z.jsxs)(T, {
|
|
2758
|
+
onClick: () => _("preview"),
|
|
2759
|
+
disabled: Object.keys(S).length === 0 || B.length > 0,
|
|
2760
|
+
children: ["Next ", /* @__PURE__ */ (0, Z.jsx)(ge, { className: "ml-1 h-4 w-4" })]
|
|
2540
2761
|
}),
|
|
2541
|
-
|
|
2542
|
-
onClick:
|
|
2543
|
-
disabled:
|
|
2544
|
-
children:
|
|
2762
|
+
g === "preview" && /* @__PURE__ */ (0, Z.jsx)(T, {
|
|
2763
|
+
onClick: V,
|
|
2764
|
+
disabled: D,
|
|
2765
|
+
children: D ? "Importing…" : `Import ${b.length} Rows`
|
|
2545
2766
|
})
|
|
2546
2767
|
] })
|
|
2547
2768
|
})
|
|
@@ -2551,7 +2772,7 @@ var Ot = ({ onFileLoaded: e }) => {
|
|
|
2551
2772
|
};
|
|
2552
2773
|
//#endregion
|
|
2553
2774
|
//#region src/InlineEditing.tsx
|
|
2554
|
-
function
|
|
2775
|
+
function Ht({ value: e, onSave: t, onCancel: n, validate: a, type: c = "text", placeholder: l, editing: u = !1, className: d, disabled: f = !1 }) {
|
|
2555
2776
|
let [p, m] = s(u), [h, g] = s(String(e ?? "")), [_, v] = s(), [y, b] = s(!1), x = o(null);
|
|
2556
2777
|
i(() => {
|
|
2557
2778
|
p || g(String(e ?? ""));
|
|
@@ -2592,13 +2813,13 @@ function Mt({ value: e, onSave: t, onCancel: n, validate: a, type: c = "text", p
|
|
|
2592
2813
|
]), T = r((e) => {
|
|
2593
2814
|
e.key === "Enter" ? (e.preventDefault(), w()) : e.key === "Escape" && (e.preventDefault(), C());
|
|
2594
2815
|
}, [w, C]);
|
|
2595
|
-
return p ? /* @__PURE__ */ (0,
|
|
2816
|
+
return p ? /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2596
2817
|
"data-slot": "inline-editing",
|
|
2597
|
-
className:
|
|
2818
|
+
className: H("relative flex items-center gap-1", d),
|
|
2598
2819
|
children: [
|
|
2599
|
-
/* @__PURE__ */ (0,
|
|
2820
|
+
/* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2600
2821
|
className: "flex-1 relative",
|
|
2601
|
-
children: [/* @__PURE__ */ (0,
|
|
2822
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("input", {
|
|
2602
2823
|
ref: x,
|
|
2603
2824
|
"data-slot": "inline-editing-input",
|
|
2604
2825
|
type: c,
|
|
@@ -2611,8 +2832,8 @@ function Mt({ value: e, onSave: t, onCancel: n, validate: a, type: c = "text", p
|
|
|
2611
2832
|
disabled: y,
|
|
2612
2833
|
"aria-invalid": !!_,
|
|
2613
2834
|
"aria-describedby": _ ? "inline-editing-error" : void 0,
|
|
2614
|
-
className:
|
|
2615
|
-
}), _ && /* @__PURE__ */ (0,
|
|
2835
|
+
className: H("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")
|
|
2836
|
+
}), _ && /* @__PURE__ */ (0, Z.jsx)("p", {
|
|
2616
2837
|
id: "inline-editing-error",
|
|
2617
2838
|
"data-slot": "inline-editing-error",
|
|
2618
2839
|
className: "absolute left-0 top-full mt-0.5 text-xs text-destructive",
|
|
@@ -2620,28 +2841,28 @@ function Mt({ value: e, onSave: t, onCancel: n, validate: a, type: c = "text", p
|
|
|
2620
2841
|
children: _
|
|
2621
2842
|
})]
|
|
2622
2843
|
}),
|
|
2623
|
-
/* @__PURE__ */ (0,
|
|
2844
|
+
/* @__PURE__ */ (0, Z.jsx)("button", {
|
|
2624
2845
|
"data-slot": "inline-editing-save",
|
|
2625
2846
|
type: "button",
|
|
2626
2847
|
onClick: w,
|
|
2627
2848
|
disabled: y,
|
|
2628
2849
|
"aria-label": "Save",
|
|
2629
|
-
className:
|
|
2630
|
-
children: /* @__PURE__ */ (0,
|
|
2850
|
+
className: H("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"),
|
|
2851
|
+
children: /* @__PURE__ */ (0, Z.jsx)(ve, { className: "h-3.5 w-3.5" })
|
|
2631
2852
|
}),
|
|
2632
|
-
/* @__PURE__ */ (0,
|
|
2853
|
+
/* @__PURE__ */ (0, Z.jsx)("button", {
|
|
2633
2854
|
"data-slot": "inline-editing-cancel",
|
|
2634
2855
|
type: "button",
|
|
2635
2856
|
onClick: C,
|
|
2636
2857
|
disabled: y,
|
|
2637
2858
|
"aria-label": "Cancel",
|
|
2638
2859
|
className: "inline-flex h-6 w-6 items-center justify-center rounded text-muted-foreground hover:bg-destructive/10 hover:text-destructive transition-colors",
|
|
2639
|
-
children: /* @__PURE__ */ (0,
|
|
2860
|
+
children: /* @__PURE__ */ (0, Z.jsx)(K, { className: "h-3.5 w-3.5" })
|
|
2640
2861
|
})
|
|
2641
2862
|
]
|
|
2642
|
-
}) : /* @__PURE__ */ (0,
|
|
2863
|
+
}) : /* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2643
2864
|
"data-slot": "inline-editing",
|
|
2644
|
-
className:
|
|
2865
|
+
className: H("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),
|
|
2645
2866
|
onClick: S,
|
|
2646
2867
|
role: "button",
|
|
2647
2868
|
tabIndex: f ? -1 : 0,
|
|
@@ -2649,10 +2870,10 @@ function Mt({ value: e, onSave: t, onCancel: n, validate: a, type: c = "text", p
|
|
|
2649
2870
|
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), S());
|
|
2650
2871
|
},
|
|
2651
2872
|
"aria-label": `Edit value: ${String(e ?? "")}`,
|
|
2652
|
-
children: /* @__PURE__ */ (0,
|
|
2873
|
+
children: /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
2653
2874
|
"data-slot": "inline-editing-display",
|
|
2654
2875
|
className: "truncate text-sm",
|
|
2655
|
-
children: e != null && String(e) !== "" ? String(e) : /* @__PURE__ */ (0,
|
|
2876
|
+
children: e != null && String(e) !== "" ? String(e) : /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
2656
2877
|
className: "text-muted-foreground italic",
|
|
2657
2878
|
children: l || "Click to edit"
|
|
2658
2879
|
})
|
|
@@ -2661,7 +2882,7 @@ function Mt({ value: e, onSave: t, onCancel: n, validate: a, type: c = "text", p
|
|
|
2661
2882
|
}
|
|
2662
2883
|
//#endregion
|
|
2663
2884
|
//#region src/useCellClipboard.ts
|
|
2664
|
-
function
|
|
2885
|
+
function Ut(e) {
|
|
2665
2886
|
return {
|
|
2666
2887
|
startRow: Math.min(e.startRow, e.endRow),
|
|
2667
2888
|
startCol: Math.min(e.startCol, e.endCol),
|
|
@@ -2669,10 +2890,10 @@ function Nt(e) {
|
|
|
2669
2890
|
endCol: Math.max(e.startCol, e.endCol)
|
|
2670
2891
|
};
|
|
2671
2892
|
}
|
|
2672
|
-
function
|
|
2893
|
+
function Wt({ data: e, columns: t, onPaste: n, enabled: a = !0 }) {
|
|
2673
2894
|
let [o, c] = s(null), l = r(() => {
|
|
2674
2895
|
if (!a || !o) return;
|
|
2675
|
-
let { startRow: n, startCol: r, endRow: i, endCol: s } =
|
|
2896
|
+
let { startRow: n, startCol: r, endRow: i, endCol: s } = Ut(o), c = [];
|
|
2676
2897
|
for (let a = n; a <= i; a++) {
|
|
2677
2898
|
let n = e[a];
|
|
2678
2899
|
if (!n) continue;
|
|
@@ -2692,7 +2913,7 @@ function Pt({ data: e, columns: t, onPaste: n, enabled: a = !0 }) {
|
|
|
2692
2913
|
t
|
|
2693
2914
|
]), u = r(() => {
|
|
2694
2915
|
if (!a || !o || !n) return;
|
|
2695
|
-
let { startRow: r, startCol: i } =
|
|
2916
|
+
let { startRow: r, startCol: i } = Ut(o);
|
|
2696
2917
|
navigator.clipboard.readText().then((a) => {
|
|
2697
2918
|
let o = [], s = a.split("\n");
|
|
2698
2919
|
for (let n = 0; n < s.length; n++) {
|
|
@@ -2735,7 +2956,7 @@ function Pt({ data: e, columns: t, onPaste: n, enabled: a = !0 }) {
|
|
|
2735
2956
|
}
|
|
2736
2957
|
//#endregion
|
|
2737
2958
|
//#region src/useGradientColor.ts
|
|
2738
|
-
var
|
|
2959
|
+
var Gt = [
|
|
2739
2960
|
{
|
|
2740
2961
|
position: 0,
|
|
2741
2962
|
className: "bg-green-100"
|
|
@@ -2749,7 +2970,7 @@ var Ft = [
|
|
|
2749
2970
|
className: "bg-red-100"
|
|
2750
2971
|
}
|
|
2751
2972
|
];
|
|
2752
|
-
function
|
|
2973
|
+
function Kt(e, t) {
|
|
2753
2974
|
let n = Infinity, r = -Infinity;
|
|
2754
2975
|
for (let i of e) {
|
|
2755
2976
|
let e = Number(i[t]);
|
|
@@ -2757,7 +2978,7 @@ function It(e, t) {
|
|
|
2757
2978
|
}
|
|
2758
2979
|
return Number.isFinite(n) ? [n, r] : [0, 0];
|
|
2759
2980
|
}
|
|
2760
|
-
function
|
|
2981
|
+
function qt(e, t) {
|
|
2761
2982
|
if (t.length === 0) return "";
|
|
2762
2983
|
if (t.length === 1) return t[0].className;
|
|
2763
2984
|
let n = t[0], r = Math.abs(e - n.position);
|
|
@@ -2767,11 +2988,11 @@ function Lt(e, t) {
|
|
|
2767
2988
|
}
|
|
2768
2989
|
return n.className;
|
|
2769
2990
|
}
|
|
2770
|
-
function
|
|
2771
|
-
let { field: t, data: n, min: i, max: o, stops: s =
|
|
2991
|
+
function Jt(e) {
|
|
2992
|
+
let { field: t, data: n, min: i, max: o, stops: s = Gt } = e, [c, l] = a(() => Kt(n, t), [n, t]), u = i ?? c, d = o ?? l;
|
|
2772
2993
|
return r((e) => {
|
|
2773
2994
|
let n = Number(e[t]);
|
|
2774
|
-
if (Number.isFinite(n)) return d === u ? s.length > 0 ? s[0].className : void 0 :
|
|
2995
|
+
if (Number.isFinite(n)) return d === u ? s.length > 0 ? s[0].className : void 0 : qt(Math.max(0, Math.min(1, (n - u) / (d - u))), s);
|
|
2775
2996
|
}, [
|
|
2776
2997
|
t,
|
|
2777
2998
|
u,
|
|
@@ -2781,8 +3002,8 @@ function Rt(e) {
|
|
|
2781
3002
|
}
|
|
2782
3003
|
//#endregion
|
|
2783
3004
|
//#region src/useGroupReorder.ts
|
|
2784
|
-
var
|
|
2785
|
-
function
|
|
3005
|
+
var Yt = "text/x-group-key";
|
|
3006
|
+
function Xt({ groupKeys: e }) {
|
|
2786
3007
|
let [t, n] = s(e), [a, o] = s(null);
|
|
2787
3008
|
return i(() => {
|
|
2788
3009
|
n((t) => {
|
|
@@ -2801,14 +3022,14 @@ function Bt({ groupKeys: e }) {
|
|
|
2801
3022
|
});
|
|
2802
3023
|
}, []),
|
|
2803
3024
|
onDragStart: r((e, t) => {
|
|
2804
|
-
e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData(
|
|
3025
|
+
e.dataTransfer.effectAllowed = "move", e.dataTransfer.setData(Yt, t), o(t);
|
|
2805
3026
|
}, []),
|
|
2806
3027
|
onDragOver: r((e) => {
|
|
2807
3028
|
e.preventDefault(), e.dataTransfer.dropEffect = "move";
|
|
2808
3029
|
}, []),
|
|
2809
3030
|
onDrop: r((e, t) => {
|
|
2810
3031
|
e.preventDefault();
|
|
2811
|
-
let r = e.dataTransfer.getData(
|
|
3032
|
+
let r = e.dataTransfer.getData(Yt);
|
|
2812
3033
|
!r || r === t || n((e) => {
|
|
2813
3034
|
let n = e.indexOf(r), i = e.indexOf(t);
|
|
2814
3035
|
if (n === -1 || i === -1) return e;
|
|
@@ -2824,7 +3045,7 @@ function Bt({ groupKeys: e }) {
|
|
|
2824
3045
|
}
|
|
2825
3046
|
//#endregion
|
|
2826
3047
|
//#region src/FormulaBar.tsx
|
|
2827
|
-
function
|
|
3048
|
+
function Zt({ value: e, onChange: t, onConfirm: n, onCancel: a, activeCell: c, disabled: l = !1, className: u }) {
|
|
2828
3049
|
let [d, f] = s(!1), [p, m] = s(e), h = o(null);
|
|
2829
3050
|
i(() => {
|
|
2830
3051
|
d || m(e);
|
|
@@ -2844,15 +3065,15 @@ function Vt({ value: e, onChange: t, onConfirm: n, onCancel: a, activeCell: c, d
|
|
|
2844
3065
|
}, [e, a]), y = r((e) => {
|
|
2845
3066
|
e.key === "Enter" ? (e.preventDefault(), _()) : e.key === "Escape" && (e.preventDefault(), v());
|
|
2846
3067
|
}, [_, v]);
|
|
2847
|
-
return /* @__PURE__ */ (0,
|
|
2848
|
-
className:
|
|
3068
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
3069
|
+
className: H("flex items-center gap-2 border-b border-border bg-muted/30 px-3 py-1.5", u),
|
|
2849
3070
|
children: [
|
|
2850
|
-
/* @__PURE__ */ (0,
|
|
2851
|
-
c && /* @__PURE__ */ (0,
|
|
3071
|
+
/* @__PURE__ */ (0, Z.jsx)(Ee, { className: "h-4 w-4 shrink-0 text-muted-foreground" }),
|
|
3072
|
+
c && /* @__PURE__ */ (0, Z.jsx)("span", {
|
|
2852
3073
|
className: "min-w-[4rem] shrink-0 rounded bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground",
|
|
2853
3074
|
children: c
|
|
2854
3075
|
}),
|
|
2855
|
-
/* @__PURE__ */ (0,
|
|
3076
|
+
/* @__PURE__ */ (0, Z.jsx)("input", {
|
|
2856
3077
|
ref: h,
|
|
2857
3078
|
type: "text",
|
|
2858
3079
|
value: d ? p : e,
|
|
@@ -2861,22 +3082,22 @@ function Vt({ value: e, onChange: t, onConfirm: n, onCancel: a, activeCell: c, d
|
|
|
2861
3082
|
onClick: g,
|
|
2862
3083
|
onChange: (e) => m(e.target.value),
|
|
2863
3084
|
onKeyDown: y,
|
|
2864
|
-
className:
|
|
3085
|
+
className: H("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")
|
|
2865
3086
|
}),
|
|
2866
|
-
d && /* @__PURE__ */ (0,
|
|
3087
|
+
d && /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2867
3088
|
className: "flex items-center gap-1",
|
|
2868
|
-
children: [/* @__PURE__ */ (0,
|
|
3089
|
+
children: [/* @__PURE__ */ (0, Z.jsx)("button", {
|
|
2869
3090
|
type: "button",
|
|
2870
3091
|
onClick: _,
|
|
2871
3092
|
className: "rounded p-0.5 text-green-600 hover:bg-green-100",
|
|
2872
3093
|
"aria-label": "Confirm",
|
|
2873
|
-
children: /* @__PURE__ */ (0,
|
|
2874
|
-
}), /* @__PURE__ */ (0,
|
|
3094
|
+
children: /* @__PURE__ */ (0, Z.jsx)(ve, { className: "h-4 w-4" })
|
|
3095
|
+
}), /* @__PURE__ */ (0, Z.jsx)("button", {
|
|
2875
3096
|
type: "button",
|
|
2876
3097
|
onClick: v,
|
|
2877
3098
|
className: "rounded p-0.5 text-red-600 hover:bg-red-100",
|
|
2878
3099
|
"aria-label": "Cancel",
|
|
2879
|
-
children: /* @__PURE__ */ (0,
|
|
3100
|
+
children: /* @__PURE__ */ (0, Z.jsx)(K, { className: "h-4 w-4" })
|
|
2880
3101
|
})]
|
|
2881
3102
|
})
|
|
2882
3103
|
]
|
|
@@ -2884,7 +3105,7 @@ function Vt({ value: e, onChange: t, onConfirm: n, onCancel: a, activeCell: c, d
|
|
|
2884
3105
|
}
|
|
2885
3106
|
//#endregion
|
|
2886
3107
|
//#region src/SplitPaneGrid.tsx
|
|
2887
|
-
function
|
|
3108
|
+
function Qt({ frozenWidth: e, onResize: t, minFrozenWidth: n = 100, minScrollableWidth: i = 200, left: a, right: c, className: l }) {
|
|
2888
3109
|
let u = o(null), [d, f] = s(e), p = o(!1), m = o(0), h = o(0), g = t ? e : d, _ = r((e) => {
|
|
2889
3110
|
e.preventDefault(), p.current = !0, m.current = e.clientX, h.current = g;
|
|
2890
3111
|
let r = (e) => {
|
|
@@ -2901,23 +3122,23 @@ function Ht({ frozenWidth: e, onResize: t, minFrozenWidth: n = 100, minScrollabl
|
|
|
2901
3122
|
i,
|
|
2902
3123
|
t
|
|
2903
3124
|
]);
|
|
2904
|
-
return /* @__PURE__ */ (0,
|
|
3125
|
+
return /* @__PURE__ */ (0, Z.jsxs)("div", {
|
|
2905
3126
|
ref: u,
|
|
2906
|
-
className:
|
|
3127
|
+
className: H("flex h-full w-full overflow-hidden", l),
|
|
2907
3128
|
children: [
|
|
2908
|
-
/* @__PURE__ */ (0,
|
|
3129
|
+
/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2909
3130
|
className: "shrink-0 overflow-auto",
|
|
2910
3131
|
style: { width: g },
|
|
2911
3132
|
children: a
|
|
2912
3133
|
}),
|
|
2913
|
-
/* @__PURE__ */ (0,
|
|
3134
|
+
/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2914
3135
|
role: "separator",
|
|
2915
3136
|
"aria-orientation": "vertical",
|
|
2916
3137
|
onPointerDown: _,
|
|
2917
|
-
className:
|
|
2918
|
-
children: /* @__PURE__ */ (0,
|
|
3138
|
+
className: H("flex w-2 cursor-col-resize items-center justify-center", "border-x border-border bg-muted/50 hover:bg-muted", "transition-colors"),
|
|
3139
|
+
children: /* @__PURE__ */ (0, Z.jsx)(De, { className: "h-4 w-4 text-muted-foreground" })
|
|
2919
3140
|
}),
|
|
2920
|
-
/* @__PURE__ */ (0,
|
|
3141
|
+
/* @__PURE__ */ (0, Z.jsx)("div", {
|
|
2921
3142
|
className: "min-w-0 flex-1 overflow-auto",
|
|
2922
3143
|
children: c
|
|
2923
3144
|
})
|
|
@@ -2926,15 +3147,15 @@ function Ht({ frozenWidth: e, onResize: t, minFrozenWidth: n = 100, minScrollabl
|
|
|
2926
3147
|
}
|
|
2927
3148
|
//#endregion
|
|
2928
3149
|
//#region src/index.tsx
|
|
2929
|
-
var
|
|
3150
|
+
var $t = ({ schema: e, ...t }) => {
|
|
2930
3151
|
let { dataSource: n } = _() || {};
|
|
2931
|
-
return /* @__PURE__ */ (0,
|
|
3152
|
+
return /* @__PURE__ */ (0, Z.jsx)(st, {
|
|
2932
3153
|
schema: e,
|
|
2933
3154
|
dataSource: n,
|
|
2934
3155
|
...t
|
|
2935
3156
|
});
|
|
2936
3157
|
};
|
|
2937
|
-
c.register("object-grid",
|
|
3158
|
+
c.register("object-grid", $t, {
|
|
2938
3159
|
namespace: "plugin-grid",
|
|
2939
3160
|
label: "Object Grid",
|
|
2940
3161
|
category: "plugin",
|
|
@@ -2956,7 +3177,7 @@ c.register("object-grid", Ut, {
|
|
|
2956
3177
|
label: "Filters"
|
|
2957
3178
|
}
|
|
2958
3179
|
]
|
|
2959
|
-
}), c.register("grid",
|
|
3180
|
+
}), c.register("grid", $t, {
|
|
2960
3181
|
namespace: "view",
|
|
2961
3182
|
label: "Data Grid",
|
|
2962
3183
|
category: "view",
|
|
@@ -2980,7 +3201,7 @@ c.register("object-grid", Ut, {
|
|
|
2980
3201
|
]
|
|
2981
3202
|
}), c.register("import-wizard", ({ schema: e, ...t }) => {
|
|
2982
3203
|
let { dataSource: n } = _() || {};
|
|
2983
|
-
return /* @__PURE__ */ (0,
|
|
3204
|
+
return /* @__PURE__ */ (0, Z.jsx)(Vt, {
|
|
2984
3205
|
objectName: e.objectName,
|
|
2985
3206
|
objectLabel: e.objectLabel,
|
|
2986
3207
|
fields: e.fields ?? [],
|
|
@@ -3004,4 +3225,4 @@ c.register("object-grid", Ut, {
|
|
|
3004
3225
|
}]
|
|
3005
3226
|
});
|
|
3006
3227
|
//#endregion
|
|
3007
|
-
export { tt as BulkActionBar,
|
|
3228
|
+
export { tt as BulkActionBar, Zt as FormulaBar, Je as GroupRow, Vt as ImportWizard, Ht as InlineEditing, st as ObjectGrid, $t as ObjectGridRenderer, et as RowActionMenu, Qt as SplitPaneGrid, Et as VirtualGrid, $e as formatActionLabel, Wt as useCellClipboard, Qe as useColumnSummary, Jt as useGradientColor, Xt as useGroupReorder, qe as useGroupedData, He as useRowColor };
|