@object-ui/plugin-detail 3.1.2 → 3.1.4
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/.turbo/turbo-build.log +53 -47
- package/CHANGELOG.md +20 -0
- package/dist/AddressField-DBkEyMcG.js +93 -0
- package/dist/AutoNumberField-Baa191z-.js +14 -0
- package/dist/AvatarField-YGj51ozd.js +80 -0
- package/dist/BooleanField-CaA898Tk.js +40 -0
- package/dist/CodeField-BU51nl1L.js +22 -0
- package/dist/ColorField-Cnf6ZM7c.js +37 -0
- package/dist/CurrencyField-Wg-XOId2.js +51 -0
- package/dist/DateField-Cth1ky_m.js +21 -0
- package/dist/DateTimeField-B0m6FhHL.js +32 -0
- package/dist/EmailField-Do7qT_L_.js +28 -0
- package/dist/FileField-aRJAdbQb.js +151 -0
- package/dist/FormulaField-DTMkagFx.js +14 -0
- package/dist/GeolocationField-RqpHWTEv.js +113 -0
- package/dist/GridField-D4IH0cpo.js +51 -0
- package/dist/ImageField-BYCFajjr.js +75 -0
- package/dist/LocationField-Bi_ew9sd.js +35 -0
- package/dist/LookupField-BjwlDPtt.js +902 -0
- package/dist/MasterDetailField-I1A9oEGC.js +94 -0
- package/dist/NumberField-D_NucQlp.js +26 -0
- package/dist/ObjectField-CG-LaM65.js +52 -0
- package/dist/PasswordField-DBtluGJ1.js +35 -0
- package/dist/PercentField-B6sO_J3i.js +63 -0
- package/dist/PhoneField-CcQAWwR6.js +28 -0
- package/dist/QRCodeField-CEjWs-J5.js +72 -0
- package/dist/RatingField-B_Mnr63i.js +39 -0
- package/dist/RichTextField-qOEJl5Ai.js +32 -0
- package/dist/SelectField-C8hWu3gm.js +30 -0
- package/dist/SignatureField-CddhEK9u.js +92 -0
- package/dist/SliderField-Df5hMzNc.js +34 -0
- package/dist/SummaryField-DgiFm-Cr.js +19 -0
- package/dist/TextAreaField-DuriTqsD.js +36 -0
- package/dist/TextField-CGNSl7RU.js +29 -0
- package/dist/TimeField-YO58ctFg.js +21 -0
- package/dist/UrlField-1-BMM1jn.js +33 -0
- package/dist/UserField-B6GqxP_S.js +78 -0
- package/dist/VectorField-BkEjbSt0.js +36 -0
- package/dist/index.js +4092 -33
- package/dist/index.umd.cjs +88 -81
- package/dist/plugin-detail.css +3 -1
- package/dist/src/DetailSection.d.ts +10 -0
- package/dist/src/DetailSection.d.ts.map +1 -1
- package/dist/src/HeaderHighlight.d.ts +2 -0
- package/dist/src/HeaderHighlight.d.ts.map +1 -1
- package/dist/src/RecordChatterPanel.d.ts +2 -0
- package/dist/src/RecordChatterPanel.d.ts.map +1 -1
- package/dist/src/autoLayout.d.ts +10 -3
- package/dist/src/autoLayout.d.ts.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src-CXr1-vVl.js +77662 -0
- package/package.json +10 -10
- package/src/DetailSection.tsx +40 -1
- package/src/DetailView.tsx +1 -1
- package/src/HeaderHighlight.tsx +22 -1
- package/src/RecordChatterPanel.tsx +6 -1
- package/src/RelatedList.tsx +1 -1
- package/src/__tests__/DetailSection.test.tsx +61 -0
- package/src/__tests__/HeaderHighlight.test.tsx +145 -0
- package/src/__tests__/RecordChatterPanel.test.tsx +38 -0
- package/src/__tests__/RelatedList.test.tsx +3 -3
- package/src/__tests__/autoLayout.test.ts +44 -0
- package/src/autoLayout.ts +25 -8
- package/src/index.tsx +1 -1
- package/dist/AddressField-QBIlXCFl.js +0 -96
- package/dist/AutoNumberField-BxnFqllo.js +0 -8
- package/dist/AvatarField-BEZuQTAH.js +0 -82
- package/dist/BooleanField-doa93aFX.js +0 -37
- package/dist/CodeField-jVV-hIXg.js +0 -21
- package/dist/ColorField-B53qKQGW.js +0 -42
- package/dist/CurrencyField-og0NJ2ax.js +0 -43
- package/dist/DateField-BFx64AtG.js +0 -21
- package/dist/DateTimeField-Cxs2Rx2f.js +0 -28
- package/dist/EmailField-BfcpzRe7.js +0 -31
- package/dist/FileField-KarqvhYm.js +0 -133
- package/dist/FormulaField-CJkkwIK8.js +0 -9
- package/dist/GeolocationField-B5SKZaqn.js +0 -123
- package/dist/GridField-DOotrUTo.js +0 -30
- package/dist/ImageField-Ddotp4u-.js +0 -90
- package/dist/LocationField-tOkQaPIM.js +0 -31
- package/dist/LookupField-DF36GvIP.js +0 -96
- package/dist/MasterDetailField-CpHw3nTE.js +0 -108
- package/dist/NumberField-CzBb2a28.js +0 -26
- package/dist/ObjectField-BoL-JqE4.js +0 -48
- package/dist/PasswordField-DrTzkYgj.js +0 -38
- package/dist/PercentField-B9ZUQ3zE.js +0 -63
- package/dist/PhoneField-Bf9lhpdu.js +0 -31
- package/dist/QRCodeField-PzMpdBKd.js +0 -77
- package/dist/RatingField-CeBMFe8o.js +0 -47
- package/dist/RichTextField-Ch7CHSQ0.js +0 -38
- package/dist/SelectField-f5Nbi02x.js +0 -26
- package/dist/SignatureField-CpxTX2tR.js +0 -85
- package/dist/SliderField-BoZtzgcr.js +0 -30
- package/dist/SummaryField-ugYPYxjP.js +0 -9
- package/dist/TextAreaField-rT1DLnV2.js +0 -39
- package/dist/TextField-CflRxusu.js +0 -32
- package/dist/TimeField-DeVeCpRu.js +0 -21
- package/dist/UrlField-UWKfhP9T.js +0 -33
- package/dist/UserField-Cp2zQDjz.js +0 -49
- package/dist/VectorField-CKg9jdGa.js +0 -25
- package/dist/index-V_WBvcaA.js +0 -100249
package/dist/index.js
CHANGED
|
@@ -1,34 +1,4093 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
1
|
+
import { $ as e, $t as t, A as n, At as r, B as i, D as a, Dt as o, Et as s, G as c, H as l, Ht as u, It as d, J as f, Jt as p, K as m, Kt as h, M as g, Mt as _, N as v, Nt as y, Ot as b, Pt as x, Q as S, Qt as C, Rt as w, St as T, Tt as E, U as D, Ut as O, V as k, Vt as A, W as j, Wt as M, Xt as ee, Y as N, Yt as te, Z as P, Zt as F, _ as I, _t as ne, a as L, an as R, at as z, bt as B, dn as re, dt as V, en as ie, et as ae, fn as oe, ft as se, g as H, gt as ce, h as U, ht as le, i as ue, in as de, it as fe, j as W, jt as pe, k as me, kt as he, ln as ge, lt as _e, m as G, mn as ve, n as ye, nn as be, on as xe, ot as Se, pt as Ce, q as K, qt as we, r as Te, rt as Ee, sn as De, st as Oe, tn as ke, tt as Ae, un as q, ut as je, v as Me, vt as Ne, wt as Pe, xt as Fe, yt as Ie, z as Le, zt as Re } from "./src-CXr1-vVl.js";
|
|
2
|
+
import "./TextField-CGNSl7RU.js";
|
|
3
|
+
import "./NumberField-D_NucQlp.js";
|
|
4
|
+
import "./BooleanField-CaA898Tk.js";
|
|
5
|
+
import "./SelectField-C8hWu3gm.js";
|
|
6
|
+
import "./DateField-Cth1ky_m.js";
|
|
7
|
+
import "./EmailField-Do7qT_L_.js";
|
|
8
|
+
import "./PhoneField-CcQAWwR6.js";
|
|
9
|
+
import "./UrlField-1-BMM1jn.js";
|
|
10
|
+
import "./CurrencyField-Wg-XOId2.js";
|
|
11
|
+
import "./TextAreaField-DuriTqsD.js";
|
|
12
|
+
import "./RichTextField-qOEJl5Ai.js";
|
|
13
|
+
import { n as ze } from "./LookupField-BjwlDPtt.js";
|
|
14
|
+
import "./DateTimeField-B0m6FhHL.js";
|
|
15
|
+
import "./TimeField-YO58ctFg.js";
|
|
16
|
+
import "./PercentField-B6sO_J3i.js";
|
|
17
|
+
import "./PasswordField-DBtluGJ1.js";
|
|
18
|
+
import "./FileField-aRJAdbQb.js";
|
|
19
|
+
import "./ImageField-BYCFajjr.js";
|
|
20
|
+
import "./LocationField-Bi_ew9sd.js";
|
|
21
|
+
import "./FormulaField-DTMkagFx.js";
|
|
22
|
+
import "./SummaryField-DgiFm-Cr.js";
|
|
23
|
+
import "./AutoNumberField-Baa191z-.js";
|
|
24
|
+
import "./UserField-B6GqxP_S.js";
|
|
25
|
+
import "./ObjectField-CG-LaM65.js";
|
|
26
|
+
import "./VectorField-BkEjbSt0.js";
|
|
27
|
+
import "./GridField-D4IH0cpo.js";
|
|
28
|
+
import "./ColorField-Cnf6ZM7c.js";
|
|
29
|
+
import "./SliderField-Df5hMzNc.js";
|
|
30
|
+
import "./RatingField-B_Mnr63i.js";
|
|
31
|
+
import "./CodeField-BU51nl1L.js";
|
|
32
|
+
import "./AvatarField-YGj51ozd.js";
|
|
33
|
+
import "./AddressField-DBkEyMcG.js";
|
|
34
|
+
import "./GeolocationField-RqpHWTEv.js";
|
|
35
|
+
import "./SignatureField-CddhEK9u.js";
|
|
36
|
+
import "./QRCodeField-CEjWs-J5.js";
|
|
37
|
+
import "./MasterDetailField-I1A9oEGC.js";
|
|
38
|
+
import * as J from "react";
|
|
39
|
+
import Be from "react";
|
|
40
|
+
import { Fragment as Y, jsx as X, jsxs as Z } from "react/jsx-runtime";
|
|
41
|
+
//#region ../core/src/utils/expand-fields.ts
|
|
42
|
+
function Ve(e, t) {
|
|
43
|
+
if (!e || typeof e != "object") return [];
|
|
44
|
+
let n = [];
|
|
45
|
+
for (let [t, r] of Object.entries(e)) r && typeof r == "object" && (r.type === "lookup" || r.type === "master_detail") && n.push(t);
|
|
46
|
+
if (n.length === 0) return [];
|
|
47
|
+
if (t && Array.isArray(t) && t.length > 0) {
|
|
48
|
+
let e = /* @__PURE__ */ new Set();
|
|
49
|
+
for (let n of t) if (typeof n == "string") e.add(n);
|
|
50
|
+
else if (n && typeof n == "object") {
|
|
51
|
+
let t = n.field ?? n.name ?? n.fieldName;
|
|
52
|
+
t && e.add(t);
|
|
53
|
+
}
|
|
54
|
+
return n.filter((t) => e.has(t));
|
|
55
|
+
}
|
|
56
|
+
return n;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region ../i18n/dist/useObjectLabel.js
|
|
60
|
+
var He = new Set([
|
|
61
|
+
"common",
|
|
62
|
+
"validation",
|
|
63
|
+
"form",
|
|
64
|
+
"table",
|
|
65
|
+
"grid",
|
|
66
|
+
"calendar",
|
|
67
|
+
"list",
|
|
68
|
+
"kanban",
|
|
69
|
+
"chart",
|
|
70
|
+
"dashboard",
|
|
71
|
+
"configPanel",
|
|
72
|
+
"appDesigner",
|
|
73
|
+
"console",
|
|
74
|
+
"errors",
|
|
75
|
+
"detail"
|
|
76
|
+
]);
|
|
77
|
+
function Ue() {
|
|
78
|
+
let { t: e, i18n: t } = re(), n = () => {
|
|
79
|
+
if (!t || typeof t.getResourceBundle != "function") return [];
|
|
80
|
+
let e = t.language || "en", n = t.getResourceBundle(e, "translation");
|
|
81
|
+
return n ? Object.keys(n).filter((e) => !He.has(e) && n[e] && typeof n[e] == "object" && (n[e].objects || n[e].fields)) : [];
|
|
82
|
+
}, r = (t, r) => {
|
|
83
|
+
try {
|
|
84
|
+
let r = n();
|
|
85
|
+
for (let n of r) {
|
|
86
|
+
let r = `${n}.${t}`, i = e(r, { defaultValue: "" });
|
|
87
|
+
if (i && i !== r && i !== "") return i;
|
|
88
|
+
}
|
|
89
|
+
} catch {}
|
|
90
|
+
return r;
|
|
91
|
+
};
|
|
92
|
+
return {
|
|
93
|
+
objectLabel: (e) => r(`objects.${e.name}.label`, e.label),
|
|
94
|
+
objectDescription: (e) => {
|
|
95
|
+
if (e.description) return r(`objects.${e.name}.description`, e.description);
|
|
96
|
+
},
|
|
97
|
+
fieldLabel: (e, t, n) => r(`fields.${e}.${t}`, n)
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
function We() {
|
|
101
|
+
try {
|
|
102
|
+
let { fieldLabel: e } = Ue();
|
|
103
|
+
return { fieldLabel: e };
|
|
104
|
+
} catch {
|
|
105
|
+
return { fieldLabel: (e, t, n) => n };
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//#endregion
|
|
109
|
+
//#region ../fields/src/index.tsx
|
|
110
|
+
function Q(e) {
|
|
111
|
+
if (e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean") return e;
|
|
112
|
+
if (e instanceof Date) return e.toISOString();
|
|
113
|
+
if (Array.isArray(e)) return e.map((e) => {
|
|
114
|
+
if (typeof e == "object" && e) {
|
|
115
|
+
let t = e;
|
|
116
|
+
return String(t.name || t.label || t.id || t._id || "[Object]");
|
|
117
|
+
}
|
|
118
|
+
return String(e);
|
|
119
|
+
}).join(", ");
|
|
120
|
+
if (typeof e == "object") {
|
|
121
|
+
let t = e;
|
|
122
|
+
return "$numberDecimal" in t ? Number(t.$numberDecimal) : "$oid" in t ? String(t.$oid) : "$date" in t ? String(t.$date) : String(t.name || t.label || t.id || t._id || "[Object]");
|
|
123
|
+
}
|
|
124
|
+
return String(e);
|
|
125
|
+
}
|
|
126
|
+
function Ge(e, t = "USD") {
|
|
127
|
+
try {
|
|
128
|
+
return new Intl.NumberFormat("en-US", {
|
|
129
|
+
style: "currency",
|
|
130
|
+
currency: t
|
|
131
|
+
}).format(e);
|
|
132
|
+
} catch {
|
|
133
|
+
return `${t} ${e.toFixed(2)}`;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function Ke(e, t = 0) {
|
|
137
|
+
return `${(e > -1 && e < 1 ? e * 100 : e).toFixed(t)}%`;
|
|
138
|
+
}
|
|
139
|
+
function qe(e) {
|
|
140
|
+
return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
141
|
+
}
|
|
142
|
+
function Je(e) {
|
|
143
|
+
if (!e) return "-";
|
|
144
|
+
let t = typeof e == "string" ? new Date(e) : e;
|
|
145
|
+
if (isNaN(t.getTime())) return "-";
|
|
146
|
+
let n = /* @__PURE__ */ new Date(), r = new Date(n.getFullYear(), n.getMonth(), n.getDate()), i = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime() - r.getTime(), a = Math.round(i / (1e3 * 60 * 60 * 24));
|
|
147
|
+
if (a === 0) return "Today";
|
|
148
|
+
if (a === 1) return "Tomorrow";
|
|
149
|
+
if (a === -1) return "Yesterday";
|
|
150
|
+
if (a < -1) {
|
|
151
|
+
let e = Math.abs(a);
|
|
152
|
+
return e <= 7 ? `Overdue ${e}d` : Ye(t);
|
|
153
|
+
}
|
|
154
|
+
return a > 1 && a <= 7 ? `In ${a} days` : Ye(t);
|
|
155
|
+
}
|
|
156
|
+
function Ye(e, t) {
|
|
157
|
+
if (!e) return "-";
|
|
158
|
+
let n = typeof e == "string" ? new Date(e) : e;
|
|
159
|
+
return isNaN(n.getTime()) ? "-" : t === "short" ? `${n.toLocaleDateString("en-US", { month: "short" })} ${n.getDate()}, '${String(n.getFullYear()).slice(-2)}` : t === "relative" ? Je(n) : n.toLocaleDateString(void 0, {
|
|
160
|
+
year: "numeric",
|
|
161
|
+
month: "short",
|
|
162
|
+
day: "numeric"
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
function $({ value: e }) {
|
|
166
|
+
let t = Q(e);
|
|
167
|
+
return /* @__PURE__ */ X("span", {
|
|
168
|
+
className: "truncate",
|
|
169
|
+
children: t != null && t !== "" ? String(t) : "-"
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function Xe({ value: e, field: t }) {
|
|
173
|
+
if (e == null) return /* @__PURE__ */ X("span", {
|
|
174
|
+
className: "text-muted-foreground",
|
|
175
|
+
children: "-"
|
|
176
|
+
});
|
|
177
|
+
let n = Q(e), r = t.precision ?? 0, i = Number(n);
|
|
178
|
+
return /* @__PURE__ */ X("span", {
|
|
179
|
+
className: "tabular-nums",
|
|
180
|
+
children: isNaN(i) ? String(n) : new Intl.NumberFormat("en-US", {
|
|
181
|
+
minimumFractionDigits: r,
|
|
182
|
+
maximumFractionDigits: r
|
|
183
|
+
}).format(i)
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
function Ze({ value: e, field: t }) {
|
|
187
|
+
if (e == null) return /* @__PURE__ */ X("span", {
|
|
188
|
+
className: "text-muted-foreground",
|
|
189
|
+
children: "-"
|
|
190
|
+
});
|
|
191
|
+
let n = Q(e), r = t.currency || "USD", i = Number(n);
|
|
192
|
+
return /* @__PURE__ */ X("span", {
|
|
193
|
+
className: "tabular-nums font-medium whitespace-nowrap",
|
|
194
|
+
children: isNaN(i) ? String(n) : Ge(i, r)
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
var Qe = /progress|completion/;
|
|
198
|
+
function $e({ value: e, field: t }) {
|
|
199
|
+
if (e == null) return /* @__PURE__ */ X("span", {
|
|
200
|
+
className: "text-muted-foreground",
|
|
201
|
+
children: "-"
|
|
202
|
+
});
|
|
203
|
+
let n = Q(e), r = t.precision ?? 0, i = Number(n);
|
|
204
|
+
if (isNaN(i)) return /* @__PURE__ */ X("span", {
|
|
205
|
+
className: "tabular-nums whitespace-nowrap",
|
|
206
|
+
children: String(n)
|
|
207
|
+
});
|
|
208
|
+
let a = Qe.test(t?.name?.toLowerCase() || ""), o = a ? i : i > -1 && i < 1 ? i * 100 : i, s = a ? `${i.toFixed(r)}%` : Ke(i, r), c = Math.max(0, Math.min(100, o));
|
|
209
|
+
return /* @__PURE__ */ Z("div", {
|
|
210
|
+
className: "flex items-center gap-2",
|
|
211
|
+
children: [/* @__PURE__ */ X("div", {
|
|
212
|
+
className: "h-1.5 w-16 rounded-full bg-muted overflow-hidden flex-shrink-0",
|
|
213
|
+
role: "progressbar",
|
|
214
|
+
"aria-valuenow": c,
|
|
215
|
+
"aria-valuemin": 0,
|
|
216
|
+
"aria-valuemax": 100,
|
|
217
|
+
children: /* @__PURE__ */ X("div", {
|
|
218
|
+
className: "h-full rounded-full bg-primary transition-all",
|
|
219
|
+
style: { width: `${c}%` }
|
|
220
|
+
})
|
|
221
|
+
}), /* @__PURE__ */ X("span", {
|
|
222
|
+
className: "tabular-nums whitespace-nowrap",
|
|
223
|
+
children: s
|
|
224
|
+
})]
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
var et = new Set([
|
|
228
|
+
"active",
|
|
229
|
+
"is_active",
|
|
230
|
+
"enabled",
|
|
231
|
+
"is_enabled",
|
|
232
|
+
"verified",
|
|
233
|
+
"is_verified"
|
|
234
|
+
]);
|
|
235
|
+
function tt({ value: e, field: t }) {
|
|
236
|
+
if (e == null) return /* @__PURE__ */ X("span", {
|
|
237
|
+
className: "text-muted-foreground/50 text-xs italic flex items-center justify-center",
|
|
238
|
+
children: "—"
|
|
239
|
+
});
|
|
240
|
+
let n = t?.name?.toLowerCase() || "";
|
|
241
|
+
return n === "completed" || n === "is_completed" || n === "done" || n === "is_done" ? /* @__PURE__ */ X("div", {
|
|
242
|
+
className: "flex items-center justify-center",
|
|
243
|
+
children: e ? /* @__PURE__ */ X("div", {
|
|
244
|
+
className: "size-5 rounded-full bg-green-500 flex items-center justify-center",
|
|
245
|
+
role: "img",
|
|
246
|
+
"aria-label": "Completed",
|
|
247
|
+
"data-testid": "completion-indicator",
|
|
248
|
+
children: /* @__PURE__ */ X(F, { className: "size-3 text-white" })
|
|
249
|
+
}) : /* @__PURE__ */ X("div", {
|
|
250
|
+
className: "size-5 rounded-full border-2 border-muted-foreground/30",
|
|
251
|
+
role: "img",
|
|
252
|
+
"aria-label": "Not completed",
|
|
253
|
+
"data-testid": "completion-indicator"
|
|
254
|
+
})
|
|
255
|
+
}) : et.has(n) && !e ? /* @__PURE__ */ Z(K, {
|
|
256
|
+
variant: "destructive",
|
|
257
|
+
className: "text-xs",
|
|
258
|
+
"data-testid": "boolean-warning-badge",
|
|
259
|
+
children: [t?.label || qe(n), " — Off"]
|
|
260
|
+
}) : /* @__PURE__ */ X("div", {
|
|
261
|
+
className: "flex items-center justify-center",
|
|
262
|
+
children: /* @__PURE__ */ X(l, {
|
|
263
|
+
checked: !!e,
|
|
264
|
+
disabled: !0,
|
|
265
|
+
className: "pointer-events-none"
|
|
266
|
+
})
|
|
267
|
+
});
|
|
268
|
+
}
|
|
269
|
+
function nt({ value: e, field: t }) {
|
|
270
|
+
if (!e) return /* @__PURE__ */ X("span", {
|
|
271
|
+
className: "text-muted-foreground",
|
|
272
|
+
children: "-"
|
|
273
|
+
});
|
|
274
|
+
let n = Q(e), r = Ye(n, t.format || "relative"), i = typeof n == "string" ? new Date(n) : n, a = i instanceof Date && !isNaN(i.getTime()), o = /* @__PURE__ */ new Date();
|
|
275
|
+
o.setHours(0, 0, 0, 0);
|
|
276
|
+
let s = a && i < o, c = a ? i.toISOString() : String(n);
|
|
277
|
+
return /* @__PURE__ */ X("span", {
|
|
278
|
+
className: `tabular-nums${s ? " text-red-600" : ""}`,
|
|
279
|
+
title: c,
|
|
280
|
+
children: r
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
function rt({ value: e }) {
|
|
284
|
+
if (!e) return /* @__PURE__ */ X("span", {
|
|
285
|
+
className: "text-muted-foreground",
|
|
286
|
+
children: "-"
|
|
287
|
+
});
|
|
288
|
+
let t = Q(e), n = typeof t == "string" ? new Date(t) : t;
|
|
289
|
+
if (!(n instanceof Date) || isNaN(n.getTime())) return /* @__PURE__ */ X("span", {
|
|
290
|
+
className: "text-muted-foreground",
|
|
291
|
+
children: "-"
|
|
292
|
+
});
|
|
293
|
+
let r = n.toLocaleDateString(void 0, {
|
|
294
|
+
month: "numeric",
|
|
295
|
+
day: "numeric",
|
|
296
|
+
year: "numeric"
|
|
297
|
+
}), i = n.toLocaleTimeString(void 0, {
|
|
298
|
+
hour: "numeric",
|
|
299
|
+
minute: "2-digit",
|
|
300
|
+
hour12: !0
|
|
301
|
+
}).toLowerCase();
|
|
302
|
+
return /* @__PURE__ */ Z("span", {
|
|
303
|
+
className: "tabular-nums text-sm whitespace-nowrap",
|
|
304
|
+
children: [/* @__PURE__ */ X("span", { children: r }), /* @__PURE__ */ X("span", {
|
|
305
|
+
className: "ml-2 text-muted-foreground",
|
|
306
|
+
children: i
|
|
307
|
+
})]
|
|
308
|
+
});
|
|
309
|
+
}
|
|
310
|
+
var it = {
|
|
311
|
+
critical: "red",
|
|
312
|
+
urgent: "red",
|
|
313
|
+
high: "orange",
|
|
314
|
+
medium: "yellow",
|
|
315
|
+
normal: "blue",
|
|
316
|
+
low: "gray",
|
|
317
|
+
none: "gray",
|
|
318
|
+
paid: "green",
|
|
319
|
+
completed: "green",
|
|
320
|
+
done: "green",
|
|
321
|
+
active: "green",
|
|
322
|
+
approved: "green",
|
|
323
|
+
resolved: "green",
|
|
324
|
+
pending: "yellow",
|
|
325
|
+
waiting: "yellow",
|
|
326
|
+
on_hold: "yellow",
|
|
327
|
+
shipped: "blue",
|
|
328
|
+
in_progress: "blue",
|
|
329
|
+
open: "blue",
|
|
330
|
+
processing: "blue",
|
|
331
|
+
draft: "gray",
|
|
332
|
+
new: "gray",
|
|
333
|
+
inactive: "gray",
|
|
334
|
+
closed: "gray",
|
|
335
|
+
cancelled: "red",
|
|
336
|
+
canceled: "red",
|
|
337
|
+
rejected: "red",
|
|
338
|
+
failed: "red",
|
|
339
|
+
overdue: "red",
|
|
340
|
+
delivered: "purple",
|
|
341
|
+
archived: "indigo"
|
|
342
|
+
}, at = {
|
|
343
|
+
gray: "bg-gray-100 text-gray-800 border-gray-300",
|
|
344
|
+
red: "bg-red-100 text-red-800 border-red-300",
|
|
345
|
+
orange: "bg-orange-100 text-orange-800 border-orange-300",
|
|
346
|
+
yellow: "bg-yellow-100 text-yellow-800 border-yellow-300",
|
|
347
|
+
green: "bg-green-100 text-green-800 border-green-300",
|
|
348
|
+
blue: "bg-blue-100 text-blue-800 border-blue-300",
|
|
349
|
+
indigo: "bg-indigo-100 text-indigo-800 border-indigo-300",
|
|
350
|
+
purple: "bg-purple-100 text-purple-800 border-purple-300",
|
|
351
|
+
pink: "bg-pink-100 text-pink-800 border-pink-300"
|
|
34
352
|
};
|
|
353
|
+
function ot(e, t) {
|
|
354
|
+
return at[e || (t ? it[String(t).toLowerCase().replace(/[\s-]/g, "_")] : void 0) || ""] || "bg-muted text-muted-foreground border-border";
|
|
355
|
+
}
|
|
356
|
+
function st({ value: e, field: t }) {
|
|
357
|
+
let n = t.options || [];
|
|
358
|
+
if (!e) return /* @__PURE__ */ X("span", { children: "-" });
|
|
359
|
+
if (Array.isArray(e)) return /* @__PURE__ */ X("div", {
|
|
360
|
+
className: "flex flex-wrap gap-1",
|
|
361
|
+
children: e.map((e, t) => {
|
|
362
|
+
let r = n.find((t) => t.value === e), i = r?.label || qe(String(e));
|
|
363
|
+
return /* @__PURE__ */ X(K, {
|
|
364
|
+
variant: "outline",
|
|
365
|
+
className: ot(r?.color, e),
|
|
366
|
+
children: i
|
|
367
|
+
}, t);
|
|
368
|
+
})
|
|
369
|
+
});
|
|
370
|
+
let r = n.find((t) => t.value === e), i = r?.label || qe(String(e));
|
|
371
|
+
return /* @__PURE__ */ X(K, {
|
|
372
|
+
variant: "outline",
|
|
373
|
+
className: ot(r?.color, e),
|
|
374
|
+
children: i
|
|
375
|
+
});
|
|
376
|
+
}
|
|
377
|
+
function ct({ value: e }) {
|
|
378
|
+
if (!e) return /* @__PURE__ */ X("span", { children: "-" });
|
|
379
|
+
let t = String(Q(e) ?? ""), [n, r] = Be.useState(!1);
|
|
380
|
+
return /* @__PURE__ */ Z("span", {
|
|
381
|
+
className: "inline-flex items-center gap-1 group/email",
|
|
382
|
+
children: [/* @__PURE__ */ X(P, {
|
|
383
|
+
variant: "link",
|
|
384
|
+
className: "p-0 h-auto font-normal text-blue-600 hover:text-blue-800",
|
|
385
|
+
asChild: !0,
|
|
386
|
+
children: /* @__PURE__ */ X("a", {
|
|
387
|
+
href: `mailto:${t}`,
|
|
388
|
+
onClick: (e) => e.stopPropagation(),
|
|
389
|
+
children: t
|
|
390
|
+
})
|
|
391
|
+
}), /* @__PURE__ */ X("button", {
|
|
392
|
+
type: "button",
|
|
393
|
+
className: "opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",
|
|
394
|
+
onClick: (e) => {
|
|
395
|
+
e.stopPropagation(), e.preventDefault(), navigator.clipboard.writeText(t).then(() => {
|
|
396
|
+
r(!0), setTimeout(() => r(!1), 2e3);
|
|
397
|
+
}).catch(() => {});
|
|
398
|
+
},
|
|
399
|
+
"aria-label": "Copy email",
|
|
400
|
+
children: n ? /* @__PURE__ */ X(F, { className: "h-3 w-3 text-green-600" }) : /* @__PURE__ */ X(A, { className: "h-3 w-3 text-muted-foreground" })
|
|
401
|
+
})]
|
|
402
|
+
});
|
|
403
|
+
}
|
|
404
|
+
function lt({ value: e }) {
|
|
405
|
+
if (!e) return /* @__PURE__ */ X("span", { children: "-" });
|
|
406
|
+
let t = String(Q(e) ?? "");
|
|
407
|
+
return /* @__PURE__ */ X(P, {
|
|
408
|
+
variant: "link",
|
|
409
|
+
className: "p-0 h-auto font-normal text-blue-600 hover:text-blue-800",
|
|
410
|
+
asChild: !0,
|
|
411
|
+
children: /* @__PURE__ */ X("a", {
|
|
412
|
+
href: t,
|
|
413
|
+
target: "_blank",
|
|
414
|
+
rel: "noopener noreferrer",
|
|
415
|
+
onClick: (e) => e.stopPropagation(),
|
|
416
|
+
children: t
|
|
417
|
+
})
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
function ut({ value: e }) {
|
|
421
|
+
if (!e) return /* @__PURE__ */ X("span", { children: "-" });
|
|
422
|
+
let t = String(Q(e) ?? ""), [n, r] = Be.useState(!1);
|
|
423
|
+
return /* @__PURE__ */ Z("span", {
|
|
424
|
+
className: "inline-flex items-center gap-1 group/phone",
|
|
425
|
+
children: [/* @__PURE__ */ Z("a", {
|
|
426
|
+
href: `tel:${t}`,
|
|
427
|
+
className: "inline-flex items-center gap-1 text-blue-600 hover:text-blue-800",
|
|
428
|
+
onClick: (e) => e.stopPropagation(),
|
|
429
|
+
children: [/* @__PURE__ */ X(ne, { className: "h-3 w-3" }), t]
|
|
430
|
+
}), /* @__PURE__ */ X("button", {
|
|
431
|
+
type: "button",
|
|
432
|
+
className: "opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",
|
|
433
|
+
onClick: (e) => {
|
|
434
|
+
e.stopPropagation(), e.preventDefault(), navigator.clipboard.writeText(t).then(() => {
|
|
435
|
+
r(!0), setTimeout(() => r(!1), 2e3);
|
|
436
|
+
}).catch(() => {});
|
|
437
|
+
},
|
|
438
|
+
"aria-label": "Copy phone number",
|
|
439
|
+
children: n ? /* @__PURE__ */ X(F, { className: "h-3 w-3 text-green-600" }) : /* @__PURE__ */ X(A, { className: "h-3 w-3 text-muted-foreground" })
|
|
440
|
+
})]
|
|
441
|
+
});
|
|
442
|
+
}
|
|
443
|
+
function dt({ value: e, field: t }) {
|
|
444
|
+
if (!e) return /* @__PURE__ */ X("span", { children: "-" });
|
|
445
|
+
if (t.multiple, Array.isArray(e)) {
|
|
446
|
+
let t = e.length;
|
|
447
|
+
return /* @__PURE__ */ Z("span", {
|
|
448
|
+
className: "text-sm text-gray-600",
|
|
449
|
+
children: [
|
|
450
|
+
t,
|
|
451
|
+
" ",
|
|
452
|
+
t === 1 ? "file" : "files"
|
|
453
|
+
]
|
|
454
|
+
});
|
|
455
|
+
}
|
|
456
|
+
return /* @__PURE__ */ X("span", {
|
|
457
|
+
className: "text-sm truncate",
|
|
458
|
+
children: e.name || e.original_name || "File"
|
|
459
|
+
});
|
|
460
|
+
}
|
|
461
|
+
function ft({ value: e }) {
|
|
462
|
+
return e ? Array.isArray(e) ? /* @__PURE__ */ Z("div", {
|
|
463
|
+
className: "flex -space-x-2",
|
|
464
|
+
children: [e.slice(0, 3).map((e, t) => /* @__PURE__ */ X("img", {
|
|
465
|
+
src: e.url || "",
|
|
466
|
+
alt: e.name || `Image ${t + 1}`,
|
|
467
|
+
className: "size-8 rounded-md border-2 border-white object-cover"
|
|
468
|
+
}, t)), e.length > 3 && /* @__PURE__ */ Z("div", {
|
|
469
|
+
className: "size-8 rounded-md border-2 border-white bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-600",
|
|
470
|
+
children: ["+", e.length - 3]
|
|
471
|
+
})]
|
|
472
|
+
}) : /* @__PURE__ */ X("img", {
|
|
473
|
+
src: e.url || "",
|
|
474
|
+
alt: e.name || "Image",
|
|
475
|
+
className: "size-10 rounded-md object-cover"
|
|
476
|
+
}) : /* @__PURE__ */ X("span", { children: "-" });
|
|
477
|
+
}
|
|
478
|
+
function pt({ value: e, field: t }) {
|
|
479
|
+
if (e == null || e === "") return /* @__PURE__ */ X("span", { children: "-" });
|
|
480
|
+
let n = t.options || [], r = (e) => {
|
|
481
|
+
if (n.length > 0) {
|
|
482
|
+
let t = n.find((t) => String(t.value) === String(e));
|
|
483
|
+
if (t) return t.label;
|
|
484
|
+
}
|
|
485
|
+
return String(e);
|
|
486
|
+
};
|
|
487
|
+
return Array.isArray(e) ? /* @__PURE__ */ X("div", {
|
|
488
|
+
className: "flex flex-wrap gap-1",
|
|
489
|
+
children: e.map((e, t) => {
|
|
490
|
+
let n;
|
|
491
|
+
return n = typeof e == "object" && e ? e.name || e.label || e.id || e._id || String(e) : r(e), /* @__PURE__ */ X("span", {
|
|
492
|
+
className: "inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800",
|
|
493
|
+
children: n
|
|
494
|
+
}, t);
|
|
495
|
+
})
|
|
496
|
+
}) : typeof e == "object" && e ? /* @__PURE__ */ X("span", {
|
|
497
|
+
className: "truncate",
|
|
498
|
+
children: e.name || e.label || e.id || e._id || "[Object]"
|
|
499
|
+
}) : /* @__PURE__ */ X("span", {
|
|
500
|
+
className: "truncate",
|
|
501
|
+
children: r(e)
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
function mt({ value: e }) {
|
|
505
|
+
let t = Q(e);
|
|
506
|
+
return /* @__PURE__ */ X("span", {
|
|
507
|
+
className: "text-gray-700 font-mono text-sm",
|
|
508
|
+
children: t == null ? "-" : String(t)
|
|
509
|
+
});
|
|
510
|
+
}
|
|
511
|
+
function ht({ value: e }) {
|
|
512
|
+
if (!e) return /* @__PURE__ */ X("span", { children: "-" });
|
|
513
|
+
if (typeof e != "object") return /* @__PURE__ */ X("span", {
|
|
514
|
+
className: "truncate",
|
|
515
|
+
children: String(e)
|
|
516
|
+
});
|
|
517
|
+
if (Array.isArray(e)) return /* @__PURE__ */ Z("div", {
|
|
518
|
+
className: "flex -space-x-2",
|
|
519
|
+
children: [e.slice(0, 3).map((e, t) => {
|
|
520
|
+
if (typeof e != "object" || !e) return /* @__PURE__ */ X("span", {
|
|
521
|
+
className: "truncate text-sm",
|
|
522
|
+
children: String(e)
|
|
523
|
+
}, t);
|
|
524
|
+
let n = e.name || e.username || "User";
|
|
525
|
+
return /* @__PURE__ */ X(f, {
|
|
526
|
+
className: "size-8 border-2 border-white",
|
|
527
|
+
title: n,
|
|
528
|
+
children: /* @__PURE__ */ X(N, {
|
|
529
|
+
className: "bg-blue-500 text-white text-xs",
|
|
530
|
+
children: n.split(" ").map((e) => e[0]).join("").toUpperCase().slice(0, 2)
|
|
531
|
+
})
|
|
532
|
+
}, t);
|
|
533
|
+
}), e.length > 3 && /* @__PURE__ */ X(f, {
|
|
534
|
+
className: "size-8 border-2 border-white",
|
|
535
|
+
children: /* @__PURE__ */ Z(N, {
|
|
536
|
+
className: "bg-gray-200 text-gray-600 text-xs",
|
|
537
|
+
children: ["+", e.length - 3]
|
|
538
|
+
})
|
|
539
|
+
})]
|
|
540
|
+
});
|
|
541
|
+
let t = e.name || e.username || "User";
|
|
542
|
+
return /* @__PURE__ */ Z("div", {
|
|
543
|
+
className: "flex items-center gap-2",
|
|
544
|
+
children: [/* @__PURE__ */ X(f, {
|
|
545
|
+
className: "size-8",
|
|
546
|
+
children: /* @__PURE__ */ X(N, {
|
|
547
|
+
className: "bg-blue-500 text-white text-xs",
|
|
548
|
+
children: t.split(" ").map((e) => e[0]).join("").toUpperCase().slice(0, 2)
|
|
549
|
+
})
|
|
550
|
+
}), /* @__PURE__ */ X("span", {
|
|
551
|
+
className: "truncate",
|
|
552
|
+
children: t
|
|
553
|
+
})]
|
|
554
|
+
});
|
|
555
|
+
}
|
|
556
|
+
var gt = /* @__PURE__ */ new Map();
|
|
557
|
+
function _t(e, t) {
|
|
558
|
+
gt.set(e, t);
|
|
559
|
+
}
|
|
560
|
+
function vt(e) {
|
|
561
|
+
return gt.has(e) ? gt.get(e) : {
|
|
562
|
+
text: $,
|
|
563
|
+
textarea: $,
|
|
564
|
+
markdown: $,
|
|
565
|
+
html: $,
|
|
566
|
+
number: Xe,
|
|
567
|
+
currency: Ze,
|
|
568
|
+
percent: $e,
|
|
569
|
+
boolean: tt,
|
|
570
|
+
date: nt,
|
|
571
|
+
datetime: rt,
|
|
572
|
+
time: $,
|
|
573
|
+
select: st,
|
|
574
|
+
status: st,
|
|
575
|
+
lookup: pt,
|
|
576
|
+
master_detail: pt,
|
|
577
|
+
email: ct,
|
|
578
|
+
url: lt,
|
|
579
|
+
phone: ut,
|
|
580
|
+
file: dt,
|
|
581
|
+
image: ft,
|
|
582
|
+
formula: mt,
|
|
583
|
+
summary: mt,
|
|
584
|
+
auto_number: $,
|
|
585
|
+
user: ht,
|
|
586
|
+
owner: ht,
|
|
587
|
+
password: () => /* @__PURE__ */ X("span", { children: "••••••" }),
|
|
588
|
+
location: $,
|
|
589
|
+
object: () => /* @__PURE__ */ X("span", {
|
|
590
|
+
className: "text-gray-500 italic",
|
|
591
|
+
children: "[Object]"
|
|
592
|
+
}),
|
|
593
|
+
vector: () => /* @__PURE__ */ X("span", {
|
|
594
|
+
className: "text-gray-500 italic",
|
|
595
|
+
children: "[Vector]"
|
|
596
|
+
}),
|
|
597
|
+
grid: () => /* @__PURE__ */ X("span", {
|
|
598
|
+
className: "text-gray-500 italic",
|
|
599
|
+
children: "[Grid]"
|
|
600
|
+
})
|
|
601
|
+
}[e] || $;
|
|
602
|
+
}
|
|
603
|
+
_t("lookup", pt), _t("master_detail", pt), _t("select", st), _t("status", st), _t("user", ht), _t("owner", ht), ze(vt);
|
|
604
|
+
var yt = {
|
|
605
|
+
text: () => import("./TextField-CGNSl7RU.js").then((e) => e.t).then((e) => ({ default: e.TextField })),
|
|
606
|
+
textarea: () => import("./TextAreaField-DuriTqsD.js").then((e) => e.t).then((e) => ({ default: e.TextAreaField })),
|
|
607
|
+
number: () => import("./NumberField-D_NucQlp.js").then((e) => e.t).then((e) => ({ default: e.NumberField })),
|
|
608
|
+
boolean: () => import("./BooleanField-CaA898Tk.js").then((e) => e.t).then((e) => ({ default: e.BooleanField })),
|
|
609
|
+
select: () => import("./SelectField-C8hWu3gm.js").then((e) => e.t).then((e) => ({ default: e.SelectField })),
|
|
610
|
+
date: () => import("./DateField-Cth1ky_m.js").then((e) => e.t).then((e) => ({ default: e.DateField })),
|
|
611
|
+
datetime: () => import("./DateTimeField-B0m6FhHL.js").then((e) => e.t).then((e) => ({ default: e.DateTimeField })),
|
|
612
|
+
time: () => import("./TimeField-YO58ctFg.js").then((e) => e.t).then((e) => ({ default: e.TimeField })),
|
|
613
|
+
email: () => import("./EmailField-Do7qT_L_.js").then((e) => e.t).then((e) => ({ default: e.EmailField })),
|
|
614
|
+
phone: () => import("./PhoneField-CcQAWwR6.js").then((e) => e.t).then((e) => ({ default: e.PhoneField })),
|
|
615
|
+
url: () => import("./UrlField-1-BMM1jn.js").then((e) => e.t).then((e) => ({ default: e.UrlField })),
|
|
616
|
+
currency: () => import("./CurrencyField-Wg-XOId2.js").then((e) => e.t).then((e) => ({ default: e.CurrencyField })),
|
|
617
|
+
percent: () => import("./PercentField-B6sO_J3i.js").then((e) => e.t).then((e) => ({ default: e.PercentField })),
|
|
618
|
+
password: () => import("./PasswordField-DBtluGJ1.js").then((e) => e.t).then((e) => ({ default: e.PasswordField })),
|
|
619
|
+
markdown: () => import("./RichTextField-qOEJl5Ai.js").then((e) => e.t).then((e) => ({ default: e.RichTextField })),
|
|
620
|
+
html: () => import("./RichTextField-qOEJl5Ai.js").then((e) => e.t).then((e) => ({ default: e.RichTextField })),
|
|
621
|
+
lookup: () => import("./LookupField-BjwlDPtt.js").then((e) => e.t).then((e) => ({ default: e.LookupField })),
|
|
622
|
+
master_detail: () => import("./MasterDetailField-I1A9oEGC.js").then((e) => e.t).then((e) => ({ default: e.MasterDetailField })),
|
|
623
|
+
file: () => import("./FileField-aRJAdbQb.js").then((e) => e.t).then((e) => ({ default: e.FileField })),
|
|
624
|
+
image: () => import("./ImageField-BYCFajjr.js").then((e) => e.t).then((e) => ({ default: e.ImageField })),
|
|
625
|
+
location: () => import("./LocationField-Bi_ew9sd.js").then((e) => e.t).then((e) => ({ default: e.LocationField })),
|
|
626
|
+
formula: () => import("./FormulaField-DTMkagFx.js").then((e) => e.t).then((e) => ({ default: e.FormulaField })),
|
|
627
|
+
summary: () => import("./SummaryField-DgiFm-Cr.js").then((e) => e.t).then((e) => ({ default: e.SummaryField })),
|
|
628
|
+
auto_number: () => import("./AutoNumberField-Baa191z-.js").then((e) => e.t).then((e) => ({ default: e.AutoNumberField })),
|
|
629
|
+
user: () => import("./UserField-B6GqxP_S.js").then((e) => e.t).then((e) => ({ default: e.UserField })),
|
|
630
|
+
owner: () => import("./UserField-B6GqxP_S.js").then((e) => e.t).then((e) => ({ default: e.UserField })),
|
|
631
|
+
object: () => import("./ObjectField-CG-LaM65.js").then((e) => e.t).then((e) => ({ default: e.ObjectField })),
|
|
632
|
+
vector: () => import("./VectorField-BkEjbSt0.js").then((e) => e.t).then((e) => ({ default: e.VectorField })),
|
|
633
|
+
grid: () => import("./GridField-D4IH0cpo.js").then((e) => e.t).then((e) => ({ default: e.GridField })),
|
|
634
|
+
color: () => import("./ColorField-Cnf6ZM7c.js").then((e) => e.t).then((e) => ({ default: e.ColorField })),
|
|
635
|
+
slider: () => import("./SliderField-Df5hMzNc.js").then((e) => e.t).then((e) => ({ default: e.SliderField })),
|
|
636
|
+
rating: () => import("./RatingField-B_Mnr63i.js").then((e) => e.t).then((e) => ({ default: e.RatingField })),
|
|
637
|
+
code: () => import("./CodeField-BU51nl1L.js").then((e) => e.t).then((e) => ({ default: e.CodeField })),
|
|
638
|
+
avatar: () => import("./AvatarField-YGj51ozd.js").then((e) => e.t).then((e) => ({ default: e.AvatarField })),
|
|
639
|
+
address: () => import("./AddressField-DBkEyMcG.js").then((e) => e.t).then((e) => ({ default: e.AddressField })),
|
|
640
|
+
geolocation: () => import("./GeolocationField-RqpHWTEv.js").then((e) => e.t).then((e) => ({ default: e.GeolocationField })),
|
|
641
|
+
signature: () => import("./SignatureField-CddhEK9u.js").then((e) => e.t).then((e) => ({ default: e.SignatureField })),
|
|
642
|
+
qrcode: () => import("./QRCodeField-CEjWs-J5.js").then((e) => e.t).then((e) => ({ default: e.QRCodeField }))
|
|
643
|
+
};
|
|
644
|
+
function bt(e) {
|
|
645
|
+
let t = yt[e];
|
|
646
|
+
if (!t) {
|
|
647
|
+
console.warn(`Unknown field type: ${e}`);
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
let n = Be.lazy(t);
|
|
651
|
+
ve.register(e, n, { namespace: "field" });
|
|
652
|
+
}
|
|
653
|
+
function xt() {
|
|
654
|
+
Object.keys(yt).forEach((e) => {
|
|
655
|
+
bt(e);
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
xt();
|
|
659
|
+
//#endregion
|
|
660
|
+
//#region src/autoLayout.ts
|
|
661
|
+
var St = new Set([
|
|
662
|
+
"textarea",
|
|
663
|
+
"markdown",
|
|
664
|
+
"html",
|
|
665
|
+
"grid",
|
|
666
|
+
"rich-text",
|
|
667
|
+
"field:textarea",
|
|
668
|
+
"field:markdown",
|
|
669
|
+
"field:html",
|
|
670
|
+
"field:grid",
|
|
671
|
+
"field:rich-text"
|
|
672
|
+
]);
|
|
673
|
+
function Ct(e) {
|
|
674
|
+
return St.has(e);
|
|
675
|
+
}
|
|
676
|
+
function wt(e, t) {
|
|
677
|
+
let n;
|
|
678
|
+
if (n = e <= 3 ? 1 : e <= 10 ? 2 : 3, t !== void 0) {
|
|
679
|
+
if (t < 640) return Math.min(n, 1);
|
|
680
|
+
if (t < 900) return Math.min(n, 2);
|
|
681
|
+
}
|
|
682
|
+
return n;
|
|
683
|
+
}
|
|
684
|
+
function Tt(e, t) {
|
|
685
|
+
return t <= 1 ? e : e.map((e) => e.span === void 0 && e.type && Ct(e.type) ? {
|
|
686
|
+
...e,
|
|
687
|
+
span: t
|
|
688
|
+
} : e);
|
|
689
|
+
}
|
|
690
|
+
function Et(e, t, n) {
|
|
691
|
+
if (t !== void 0) return {
|
|
692
|
+
fields: Tt(e, t),
|
|
693
|
+
columns: t
|
|
694
|
+
};
|
|
695
|
+
let r = wt(e.length, n);
|
|
696
|
+
return {
|
|
697
|
+
fields: Tt(e, r),
|
|
698
|
+
columns: r
|
|
699
|
+
};
|
|
700
|
+
}
|
|
701
|
+
//#endregion
|
|
702
|
+
//#region src/useDetailTranslation.ts
|
|
703
|
+
function Dt(e, t) {
|
|
704
|
+
return function() {
|
|
705
|
+
try {
|
|
706
|
+
let n = re();
|
|
707
|
+
return n.t(t) === t ? { t: (t, n) => {
|
|
708
|
+
let r = e[t] || t;
|
|
709
|
+
if (n) for (let [e, t] of Object.entries(n)) r = r.replace(`{{${e}}}`, String(t));
|
|
710
|
+
return r;
|
|
711
|
+
} } : { t: n.t };
|
|
712
|
+
} catch {
|
|
713
|
+
return { t: (t, n) => {
|
|
714
|
+
let r = e[t] || t;
|
|
715
|
+
if (n) for (let [e, t] of Object.entries(n)) r = r.replace(`{{${e}}}`, String(t));
|
|
716
|
+
return r;
|
|
717
|
+
} };
|
|
718
|
+
}
|
|
719
|
+
};
|
|
720
|
+
}
|
|
721
|
+
var Ot = {
|
|
722
|
+
"detail.back": "Back",
|
|
723
|
+
"detail.edit": "Edit",
|
|
724
|
+
"detail.editInline": "Edit inline",
|
|
725
|
+
"detail.save": "Save",
|
|
726
|
+
"detail.saveChanges": "Save changes",
|
|
727
|
+
"detail.editFieldsInline": "Edit fields inline",
|
|
728
|
+
"detail.share": "Share",
|
|
729
|
+
"detail.duplicate": "Duplicate",
|
|
730
|
+
"detail.export": "Export",
|
|
731
|
+
"detail.viewHistory": "View history",
|
|
732
|
+
"detail.delete": "Delete",
|
|
733
|
+
"detail.moreActions": "More actions",
|
|
734
|
+
"detail.addToFavorites": "Add to favorites",
|
|
735
|
+
"detail.removeFromFavorites": "Remove from favorites",
|
|
736
|
+
"detail.previousRecord": "Previous record",
|
|
737
|
+
"detail.nextRecord": "Next record",
|
|
738
|
+
"detail.recordOf": "{{current}} of {{total}}",
|
|
739
|
+
"detail.recordNotFound": "Record not found",
|
|
740
|
+
"detail.recordNotFoundDescription": "The record you are looking for does not exist or may have been deleted.",
|
|
741
|
+
"detail.goBack": "Go back",
|
|
742
|
+
"detail.details": "Details",
|
|
743
|
+
"detail.related": "Related",
|
|
744
|
+
"detail.relatedRecords": "{{count}} records",
|
|
745
|
+
"detail.relatedRecordOne": "{{count}} record",
|
|
746
|
+
"detail.noRelatedRecords": "No related records found",
|
|
747
|
+
"detail.loading": "Loading...",
|
|
748
|
+
"detail.copyToClipboard": "Copy to clipboard",
|
|
749
|
+
"detail.copied": "Copied!",
|
|
750
|
+
"detail.deleteConfirmation": "Are you sure you want to delete this record?",
|
|
751
|
+
"detail.editRecord": "Edit record",
|
|
752
|
+
"detail.viewAll": "View All",
|
|
753
|
+
"detail.new": "New",
|
|
754
|
+
"detail.emptyValue": "—",
|
|
755
|
+
"detail.activity": "Activity",
|
|
756
|
+
"detail.editRow": "Edit",
|
|
757
|
+
"detail.deleteRow": "Delete",
|
|
758
|
+
"detail.deleteRowConfirmation": "Are you sure you want to delete this record?",
|
|
759
|
+
"detail.actions": "Actions",
|
|
760
|
+
"detail.previousPage": "Previous",
|
|
761
|
+
"detail.nextPage": "Next",
|
|
762
|
+
"detail.pageOf": "Page {{current}} of {{total}}",
|
|
763
|
+
"detail.sortBy": "Sort by",
|
|
764
|
+
"detail.filterPlaceholder": "Filter...",
|
|
765
|
+
"detail.highlightFields": "Key Fields"
|
|
766
|
+
}, kt = Dt(Ot, "detail.back");
|
|
767
|
+
//#endregion
|
|
768
|
+
//#region src/DetailSection.tsx
|
|
769
|
+
function At(e, t) {
|
|
770
|
+
return !e || e <= 1 || t <= 1 ? "" : t === 2 ? e >= 2 ? "md:col-span-2" : "" : e === 2 ? "md:col-span-2" : e >= 3 ? "md:col-span-2 lg:col-span-3" : "";
|
|
771
|
+
}
|
|
772
|
+
var jt = ({ section: e, data: t, className: n, objectSchema: r, objectName: a, isEditing: o = !1, onFieldChange: s, virtualScroll: l }) => {
|
|
773
|
+
let [u, d] = J.useState(e.defaultCollapsed ?? !1), [f, h] = J.useState(null), [g, _] = J.useState(void 0), { t: v } = kt(), { fieldLabel: y } = We(), b = J.useCallback((e, t) => {
|
|
774
|
+
let n = t == null ? "" : String(t);
|
|
775
|
+
navigator.clipboard.writeText(n).then(() => {
|
|
776
|
+
h(e), setTimeout(() => h(null), 2e3);
|
|
777
|
+
});
|
|
778
|
+
}, []), x = e.hideEmpty ? e.fields.filter((e) => {
|
|
779
|
+
let n = t?.[e.name] ?? e.value;
|
|
780
|
+
return n != null && n !== "";
|
|
781
|
+
}) : e.fields;
|
|
782
|
+
if (x.length === 0) return null;
|
|
783
|
+
let { fields: S, columns: C } = Et(x, e.columns), w = (e) => {
|
|
784
|
+
let n = t?.[e.name] ?? e.value;
|
|
785
|
+
if (e.render) return /* @__PURE__ */ X(oe, {
|
|
786
|
+
schema: e.render,
|
|
787
|
+
data: {
|
|
788
|
+
...t,
|
|
789
|
+
value: n
|
|
790
|
+
}
|
|
791
|
+
});
|
|
792
|
+
let i = At(e.span, C), c = (() => {
|
|
793
|
+
if (n == null) return /* @__PURE__ */ X("span", {
|
|
794
|
+
className: "text-muted-foreground/50 text-xs italic",
|
|
795
|
+
children: "—"
|
|
796
|
+
});
|
|
797
|
+
let t = r?.fields?.[e.name], i = e.type || t?.type, a = { ...e };
|
|
798
|
+
if (t) {
|
|
799
|
+
!e.type && t.type && (a.type = t.type), t.options && !a.options && (a.options = t.options), t.currency && !a.currency && (a.currency = t.currency), t.precision !== void 0 && a.precision === void 0 && (a.precision = t.precision), t.format && !a.format && (a.format = t.format);
|
|
800
|
+
let n = t.reference_to || t.reference;
|
|
801
|
+
n && !a.reference_to && (a.reference_to = n), t.reference_field && !a.reference_field && (a.reference_field = t.reference_field);
|
|
802
|
+
}
|
|
803
|
+
if (i) {
|
|
804
|
+
let e = vt(i);
|
|
805
|
+
if (e) return /* @__PURE__ */ X(e, {
|
|
806
|
+
value: n,
|
|
807
|
+
field: a
|
|
808
|
+
});
|
|
809
|
+
}
|
|
810
|
+
return String(n);
|
|
811
|
+
})(), l = n != null && n !== "", u = f === e.name;
|
|
812
|
+
return /* @__PURE__ */ Z("div", {
|
|
813
|
+
className: q("space-y-1.5 group", i),
|
|
814
|
+
children: [/* @__PURE__ */ X("div", {
|
|
815
|
+
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
|
|
816
|
+
children: y(a || "", e.name, e.label || e.name)
|
|
817
|
+
}), o && !e.readonly ? /* @__PURE__ */ X("div", {
|
|
818
|
+
className: "min-h-[44px] sm:min-h-0",
|
|
819
|
+
children: /* @__PURE__ */ X("input", {
|
|
820
|
+
type: e.type === "number" ? "number" : e.type === "date" ? "date" : "text",
|
|
821
|
+
className: "w-full px-2 py-1.5 text-sm border rounded-md bg-background focus:outline-none focus:ring-2 focus:ring-ring",
|
|
822
|
+
value: n == null ? "" : String(n),
|
|
823
|
+
onChange: (t) => s?.(e.name, t.target.value)
|
|
824
|
+
})
|
|
825
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
826
|
+
className: q("flex items-start justify-between gap-2 min-h-[44px] sm:min-h-0 rounded-md", l && "cursor-pointer active:bg-muted/60 transition-colors"),
|
|
827
|
+
onClick: l ? () => b(e.name, n) : void 0,
|
|
828
|
+
onKeyDown: l ? (t) => {
|
|
829
|
+
(t.key === "Enter" || t.key === " ") && (t.preventDefault(), b(e.name, n));
|
|
830
|
+
} : void 0,
|
|
831
|
+
role: l ? "button" : void 0,
|
|
832
|
+
tabIndex: l ? 0 : void 0,
|
|
833
|
+
children: [/* @__PURE__ */ X("div", {
|
|
834
|
+
className: "text-sm flex-1 break-words py-1",
|
|
835
|
+
children: c
|
|
836
|
+
}), l && /* @__PURE__ */ X(H, { children: /* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
837
|
+
asChild: !0,
|
|
838
|
+
children: /* @__PURE__ */ X(P, {
|
|
839
|
+
variant: "ghost",
|
|
840
|
+
size: "icon",
|
|
841
|
+
className: "h-6 w-6 opacity-0 group-hover:opacity-100 transition-opacity shrink-0",
|
|
842
|
+
onClick: (t) => {
|
|
843
|
+
t.stopPropagation(), b(e.name, n);
|
|
844
|
+
},
|
|
845
|
+
children: u ? /* @__PURE__ */ X(F, { className: "h-3 w-3 text-green-600" }) : /* @__PURE__ */ X(A, { className: "h-3 w-3" })
|
|
846
|
+
})
|
|
847
|
+
}), /* @__PURE__ */ X(U, { children: v(u ? "detail.copied" : "detail.copyToClipboard") })] }) })]
|
|
848
|
+
})]
|
|
849
|
+
}, e.name);
|
|
850
|
+
}, T = l?.enabled === !0, E = l?.batchSize ?? 20;
|
|
851
|
+
J.useEffect(() => {
|
|
852
|
+
if (!T) {
|
|
853
|
+
_(void 0);
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
if (S.length <= E) {
|
|
857
|
+
_(void 0);
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
_(E);
|
|
861
|
+
let e = setTimeout(() => _(void 0), 100);
|
|
862
|
+
return () => clearTimeout(e);
|
|
863
|
+
}, [
|
|
864
|
+
T,
|
|
865
|
+
S.length,
|
|
866
|
+
E
|
|
867
|
+
]);
|
|
868
|
+
let O = g === void 0 ? S : S.slice(0, g), M = /* @__PURE__ */ X("div", {
|
|
869
|
+
className: q("grid gap-3 sm:gap-4", C === 1 ? "grid-cols-1" : C === 2 ? "grid-cols-1 md:grid-cols-2" : "grid-cols-1 md:grid-cols-2 lg:grid-cols-3"),
|
|
870
|
+
children: O.map(w)
|
|
871
|
+
});
|
|
872
|
+
return e.collapsible ? /* @__PURE__ */ X(Le, {
|
|
873
|
+
open: !u,
|
|
874
|
+
onOpenChange: (e) => d(!e),
|
|
875
|
+
className: n,
|
|
876
|
+
children: /* @__PURE__ */ Z(D, { children: [/* @__PURE__ */ X(k, {
|
|
877
|
+
asChild: !0,
|
|
878
|
+
children: /* @__PURE__ */ Z(c, {
|
|
879
|
+
className: q("cursor-pointer hover:bg-muted/50 transition-colors", e.headerColor && `bg-${e.headerColor}`),
|
|
880
|
+
children: [/* @__PURE__ */ Z(m, {
|
|
881
|
+
className: "flex items-center justify-between",
|
|
882
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
883
|
+
className: "flex items-center gap-2",
|
|
884
|
+
children: [
|
|
885
|
+
e.icon && /* @__PURE__ */ X("span", {
|
|
886
|
+
className: "text-muted-foreground",
|
|
887
|
+
children: e.icon
|
|
888
|
+
}),
|
|
889
|
+
/* @__PURE__ */ X("span", { children: e.title }),
|
|
890
|
+
e.fields && /* @__PURE__ */ X(K, {
|
|
891
|
+
variant: "secondary",
|
|
892
|
+
className: "ml-2 text-xs",
|
|
893
|
+
children: e.fields.length
|
|
894
|
+
})
|
|
895
|
+
]
|
|
896
|
+
}), /* @__PURE__ */ X("div", {
|
|
897
|
+
className: "flex items-center gap-2",
|
|
898
|
+
children: X(u ? p : ee, { className: "h-4 w-4 text-muted-foreground" })
|
|
899
|
+
})]
|
|
900
|
+
}), e.description && !u && /* @__PURE__ */ X("p", {
|
|
901
|
+
className: "text-sm text-muted-foreground mt-1.5",
|
|
902
|
+
children: e.description
|
|
903
|
+
})]
|
|
904
|
+
})
|
|
905
|
+
}), /* @__PURE__ */ X(i, { children: /* @__PURE__ */ X(j, {
|
|
906
|
+
className: "pt-4 sm:pt-6 px-3 sm:px-6",
|
|
907
|
+
children: M
|
|
908
|
+
}) })] })
|
|
909
|
+
}) : /* @__PURE__ */ Z(D, {
|
|
910
|
+
className: q(e.showBorder === !1 ? "border-none shadow-none" : "", n),
|
|
911
|
+
children: [e.title && /* @__PURE__ */ Z(c, {
|
|
912
|
+
className: q(e.headerColor && `bg-${e.headerColor}`),
|
|
913
|
+
children: [/* @__PURE__ */ X(m, {
|
|
914
|
+
className: "flex items-center justify-between",
|
|
915
|
+
children: /* @__PURE__ */ Z("div", {
|
|
916
|
+
className: "flex items-center gap-2",
|
|
917
|
+
children: [
|
|
918
|
+
e.icon && /* @__PURE__ */ X("span", {
|
|
919
|
+
className: "text-muted-foreground",
|
|
920
|
+
children: e.icon
|
|
921
|
+
}),
|
|
922
|
+
/* @__PURE__ */ X("span", { children: e.title }),
|
|
923
|
+
e.fields && /* @__PURE__ */ X(K, {
|
|
924
|
+
variant: "secondary",
|
|
925
|
+
className: "ml-2 text-xs",
|
|
926
|
+
children: e.fields.length
|
|
927
|
+
})
|
|
928
|
+
]
|
|
929
|
+
})
|
|
930
|
+
}), e.description && /* @__PURE__ */ X("p", {
|
|
931
|
+
className: "text-sm text-muted-foreground mt-1.5",
|
|
932
|
+
children: e.description
|
|
933
|
+
})]
|
|
934
|
+
}), /* @__PURE__ */ X(j, {
|
|
935
|
+
className: "pt-4 sm:pt-6 px-3 sm:px-6",
|
|
936
|
+
children: M
|
|
937
|
+
})]
|
|
938
|
+
});
|
|
939
|
+
}, Mt = ({ tabs: e, data: t, className: n }) => {
|
|
940
|
+
let [r, i] = J.useState(e[0]?.key), a = e.filter((e) => typeof e.visible == "boolean" ? e.visible : (e.visible, !0));
|
|
941
|
+
return /* @__PURE__ */ Z(ye, {
|
|
942
|
+
value: r,
|
|
943
|
+
onValueChange: i,
|
|
944
|
+
className: n,
|
|
945
|
+
children: [/* @__PURE__ */ X(ue, {
|
|
946
|
+
className: "w-full justify-start border-b rounded-none bg-transparent p-0",
|
|
947
|
+
children: a.map((e) => /* @__PURE__ */ X(L, {
|
|
948
|
+
value: e.key,
|
|
949
|
+
className: "relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",
|
|
950
|
+
children: /* @__PURE__ */ Z("div", {
|
|
951
|
+
className: "flex items-center gap-2",
|
|
952
|
+
children: [
|
|
953
|
+
e.icon && /* @__PURE__ */ X("span", { children: e.icon }),
|
|
954
|
+
/* @__PURE__ */ X("span", { children: e.label }),
|
|
955
|
+
e.badge && /* @__PURE__ */ X(K, {
|
|
956
|
+
variant: "secondary",
|
|
957
|
+
className: "ml-1",
|
|
958
|
+
children: e.badge
|
|
959
|
+
})
|
|
960
|
+
]
|
|
961
|
+
})
|
|
962
|
+
}, e.key))
|
|
963
|
+
}), a.map((e) => /* @__PURE__ */ X(Te, {
|
|
964
|
+
value: e.key,
|
|
965
|
+
className: "mt-4",
|
|
966
|
+
children: Array.isArray(e.content) ? /* @__PURE__ */ X("div", {
|
|
967
|
+
className: "space-y-4",
|
|
968
|
+
children: e.content.map((e, n) => /* @__PURE__ */ X(oe, {
|
|
969
|
+
schema: e,
|
|
970
|
+
data: t
|
|
971
|
+
}, n))
|
|
972
|
+
}) : /* @__PURE__ */ X(oe, {
|
|
973
|
+
schema: e.content,
|
|
974
|
+
data: t
|
|
975
|
+
})
|
|
976
|
+
}, e.key))]
|
|
977
|
+
});
|
|
978
|
+
}, Nt = ({ title: e, type: t, api: n, data: r = [], schema: i, columns: o, className: s, dataSource: l, objectName: u, onNew: f, onViewAll: h, onRowEdit: g, onRowDelete: _, pageSize: v, sortable: y = !1, filterable: b = !1, collapsible: x = !1, defaultCollapsed: S = !1 }) => {
|
|
979
|
+
let [C, w] = J.useState(r), [T, E] = J.useState(!1), [O, k] = J.useState(0), [A, M] = J.useState(null), [N, F] = J.useState("asc"), [I, ne] = J.useState(""), [L, R] = J.useState(null), [B, re] = J.useState(S), { t: V } = kt(), { fieldLabel: ie } = We();
|
|
980
|
+
J.useEffect(() => {
|
|
981
|
+
w(r);
|
|
982
|
+
}, [r]), J.useEffect(() => {
|
|
983
|
+
n && l?.getObjectSchema && !o?.length && l.getObjectSchema(n).then(R).catch((e) => {
|
|
984
|
+
console.warn(`[RelatedList] Failed to fetch schema for ${n}:`, e);
|
|
985
|
+
});
|
|
986
|
+
}, [
|
|
987
|
+
n,
|
|
988
|
+
l,
|
|
989
|
+
o
|
|
990
|
+
]), J.useEffect(() => {
|
|
991
|
+
n && !r.length && (E(!0), l && typeof l.find == "function" ? l.find(n).then((e) => {
|
|
992
|
+
w(Array.isArray(e) ? e : Array.isArray(e?.data) ? e.data : []), E(!1);
|
|
993
|
+
}).catch((e) => {
|
|
994
|
+
console.error("Failed to fetch related data:", e), E(!1);
|
|
995
|
+
}) : fetch(n).then((e) => e.json()).then((e) => {
|
|
996
|
+
w(Array.isArray(e) ? e : e?.data || []);
|
|
997
|
+
}).catch((e) => {
|
|
998
|
+
console.error("Failed to fetch related data:", e);
|
|
999
|
+
}).finally(() => E(!1)));
|
|
1000
|
+
}, [
|
|
1001
|
+
n,
|
|
1002
|
+
r,
|
|
1003
|
+
l
|
|
1004
|
+
]);
|
|
1005
|
+
let ae = J.useMemo(() => {
|
|
1006
|
+
if (!I) return C;
|
|
1007
|
+
let e = I.toLowerCase();
|
|
1008
|
+
return C.filter((t) => Object.values(t).some((t) => t != null && String(t).toLowerCase().includes(e)));
|
|
1009
|
+
}, [C, I]), se = J.useMemo(() => A ? [...ae].sort((e, t) => {
|
|
1010
|
+
let n = e[A], r = t[A];
|
|
1011
|
+
if (n == null && r == null) return 0;
|
|
1012
|
+
if (n == null) return 1;
|
|
1013
|
+
if (r == null) return -1;
|
|
1014
|
+
let i = String(n).localeCompare(String(r), void 0, { numeric: !0 });
|
|
1015
|
+
return N === "asc" ? i : -i;
|
|
1016
|
+
}) : ae, [
|
|
1017
|
+
ae,
|
|
1018
|
+
A,
|
|
1019
|
+
N
|
|
1020
|
+
]), H = v && v > 0 ? v : 0, ce = H ? Math.max(1, Math.ceil(se.length / H)) : 1, U = H ? se.slice(O * H, (O + 1) * H) : se;
|
|
1021
|
+
J.useEffect(() => {
|
|
1022
|
+
k(0);
|
|
1023
|
+
}, [
|
|
1024
|
+
I,
|
|
1025
|
+
A,
|
|
1026
|
+
N
|
|
1027
|
+
]);
|
|
1028
|
+
let ue = J.useCallback((e) => {
|
|
1029
|
+
A === e ? F((e) => e === "asc" ? "desc" : "asc") : (M(e), F("asc"));
|
|
1030
|
+
}, [A]), fe = J.useCallback((e) => {
|
|
1031
|
+
window.confirm(V("detail.deleteRowConfirmation")) && _?.(e);
|
|
1032
|
+
}, [_, V]), W = J.useMemo(() => {
|
|
1033
|
+
if (o && o.length > 0) return o;
|
|
1034
|
+
if (!L?.fields) return [];
|
|
1035
|
+
let e = u || n || "";
|
|
1036
|
+
return Object.entries(L.fields).filter(([e]) => !e.startsWith("_") && e !== "id").map(([t, n]) => {
|
|
1037
|
+
let r = {
|
|
1038
|
+
accessorKey: t,
|
|
1039
|
+
header: ie(e, t, n.label || t)
|
|
1040
|
+
};
|
|
1041
|
+
if (n.type) {
|
|
1042
|
+
let e = vt(n.type);
|
|
1043
|
+
if (e) {
|
|
1044
|
+
let i = {
|
|
1045
|
+
name: t,
|
|
1046
|
+
label: n.label || t,
|
|
1047
|
+
type: n.type,
|
|
1048
|
+
...n.options && { options: n.options },
|
|
1049
|
+
...n.currency && { currency: n.currency },
|
|
1050
|
+
...n.precision !== void 0 && { precision: n.precision },
|
|
1051
|
+
...n.format && { format: n.format },
|
|
1052
|
+
...(n.reference_to || n.reference) && { reference_to: n.reference_to || n.reference },
|
|
1053
|
+
...n.reference_field && { reference_field: n.reference_field }
|
|
1054
|
+
};
|
|
1055
|
+
r.cell = (t) => t == null ? J.createElement("span", { className: "text-muted-foreground/50 text-xs italic" }, "—") : J.createElement(e, {
|
|
1056
|
+
value: t,
|
|
1057
|
+
field: i
|
|
1058
|
+
});
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
return r;
|
|
1062
|
+
});
|
|
1063
|
+
}, [
|
|
1064
|
+
o,
|
|
1065
|
+
L,
|
|
1066
|
+
u,
|
|
1067
|
+
n,
|
|
1068
|
+
ie
|
|
1069
|
+
]), pe = J.useMemo(() => {
|
|
1070
|
+
if (i) return i;
|
|
1071
|
+
switch (t) {
|
|
1072
|
+
case "grid":
|
|
1073
|
+
case "table": return {
|
|
1074
|
+
type: "data-table",
|
|
1075
|
+
data: U,
|
|
1076
|
+
columns: W,
|
|
1077
|
+
pagination: !1,
|
|
1078
|
+
pageSize: H || 10
|
|
1079
|
+
};
|
|
1080
|
+
case "list": return {
|
|
1081
|
+
type: "data-list",
|
|
1082
|
+
data: U
|
|
1083
|
+
};
|
|
1084
|
+
default: return {
|
|
1085
|
+
type: "div",
|
|
1086
|
+
children: "No view configured"
|
|
1087
|
+
};
|
|
1088
|
+
}
|
|
1089
|
+
}, [
|
|
1090
|
+
t,
|
|
1091
|
+
U,
|
|
1092
|
+
W,
|
|
1093
|
+
i,
|
|
1094
|
+
H
|
|
1095
|
+
]), me = !!g || !!_;
|
|
1096
|
+
return /* @__PURE__ */ Z(D, {
|
|
1097
|
+
className: s,
|
|
1098
|
+
children: [/* @__PURE__ */ X(c, {
|
|
1099
|
+
className: x ? "cursor-pointer select-none" : void 0,
|
|
1100
|
+
onClick: x ? () => re((e) => !e) : void 0,
|
|
1101
|
+
children: /* @__PURE__ */ Z(m, {
|
|
1102
|
+
className: "flex items-center justify-between",
|
|
1103
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
1104
|
+
className: "flex items-center gap-2",
|
|
1105
|
+
children: [
|
|
1106
|
+
x && X(B ? p : ee, { className: "h-4 w-4 text-muted-foreground" }),
|
|
1107
|
+
/* @__PURE__ */ X("span", { children: e }),
|
|
1108
|
+
/* @__PURE__ */ X(K, {
|
|
1109
|
+
variant: "secondary",
|
|
1110
|
+
className: "text-xs font-normal",
|
|
1111
|
+
"aria-label": `${C.length} records`,
|
|
1112
|
+
children: C.length
|
|
1113
|
+
})
|
|
1114
|
+
]
|
|
1115
|
+
}), /* @__PURE__ */ Z("div", {
|
|
1116
|
+
className: "flex items-center gap-1",
|
|
1117
|
+
children: [f && /* @__PURE__ */ Z(P, {
|
|
1118
|
+
variant: "ghost",
|
|
1119
|
+
size: "sm",
|
|
1120
|
+
onClick: (e) => {
|
|
1121
|
+
e.stopPropagation(), f();
|
|
1122
|
+
},
|
|
1123
|
+
className: "gap-1 h-7 text-xs",
|
|
1124
|
+
children: [/* @__PURE__ */ X(le, { className: "h-3.5 w-3.5" }), V("detail.new")]
|
|
1125
|
+
}), h && /* @__PURE__ */ Z(P, {
|
|
1126
|
+
variant: "ghost",
|
|
1127
|
+
size: "sm",
|
|
1128
|
+
onClick: (e) => {
|
|
1129
|
+
e.stopPropagation(), h();
|
|
1130
|
+
},
|
|
1131
|
+
className: "gap-1 h-7 text-xs",
|
|
1132
|
+
children: [V("detail.viewAll"), /* @__PURE__ */ X(d, { className: "h-3 w-3" })]
|
|
1133
|
+
})]
|
|
1134
|
+
})]
|
|
1135
|
+
})
|
|
1136
|
+
}), !B && /* @__PURE__ */ Z(j, { children: [
|
|
1137
|
+
b && C.length > 0 && /* @__PURE__ */ X("div", {
|
|
1138
|
+
className: "mb-3",
|
|
1139
|
+
children: /* @__PURE__ */ X(a, {
|
|
1140
|
+
placeholder: V("detail.filterPlaceholder"),
|
|
1141
|
+
value: I,
|
|
1142
|
+
onChange: (e) => ne(e.target.value),
|
|
1143
|
+
className: "h-8 text-sm"
|
|
1144
|
+
})
|
|
1145
|
+
}),
|
|
1146
|
+
y && W && W.length > 0 && C.length > 0 && /* @__PURE__ */ X("div", {
|
|
1147
|
+
className: "flex flex-wrap gap-1 mb-3",
|
|
1148
|
+
children: W.map((e) => {
|
|
1149
|
+
let t = e.accessorKey || e.field || e.name;
|
|
1150
|
+
if (!t) return null;
|
|
1151
|
+
let n = e.header || e.label || t, r = A === t;
|
|
1152
|
+
return /* @__PURE__ */ Z(P, {
|
|
1153
|
+
variant: r ? "secondary" : "ghost",
|
|
1154
|
+
size: "sm",
|
|
1155
|
+
className: "gap-1 h-7 text-xs",
|
|
1156
|
+
onClick: () => ue(t),
|
|
1157
|
+
children: [
|
|
1158
|
+
/* @__PURE__ */ X(de, { className: "h-3 w-3" }),
|
|
1159
|
+
n,
|
|
1160
|
+
r && (N === "asc" ? " ↑" : " ↓")
|
|
1161
|
+
]
|
|
1162
|
+
}, t);
|
|
1163
|
+
})
|
|
1164
|
+
}),
|
|
1165
|
+
T ? /* @__PURE__ */ X("div", {
|
|
1166
|
+
className: "flex items-center justify-center py-8 text-muted-foreground",
|
|
1167
|
+
children: V("detail.loading")
|
|
1168
|
+
}) : C.length === 0 ? /* @__PURE__ */ X("div", {
|
|
1169
|
+
className: "flex items-center justify-center py-8 text-muted-foreground text-sm",
|
|
1170
|
+
children: V("detail.noRelatedRecords")
|
|
1171
|
+
}) : /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(oe, { schema: pe }), me && U.length > 0 && /* @__PURE__ */ X("div", {
|
|
1172
|
+
className: "mt-2 space-y-1",
|
|
1173
|
+
"data-testid": "row-actions",
|
|
1174
|
+
children: U.map((e, t) => /* @__PURE__ */ Z("div", {
|
|
1175
|
+
className: "flex items-center justify-between px-2 py-1 text-xs border-b last:border-b-0",
|
|
1176
|
+
children: [/* @__PURE__ */ X("span", {
|
|
1177
|
+
className: "truncate text-muted-foreground",
|
|
1178
|
+
children: e.name || e.title || e.id || `Row ${t + 1}`
|
|
1179
|
+
}), /* @__PURE__ */ Z("div", {
|
|
1180
|
+
className: "flex items-center gap-1",
|
|
1181
|
+
children: [g && /* @__PURE__ */ Z(P, {
|
|
1182
|
+
variant: "ghost",
|
|
1183
|
+
size: "sm",
|
|
1184
|
+
className: "h-6 text-xs gap-1 px-2",
|
|
1185
|
+
onClick: () => g(e),
|
|
1186
|
+
children: [/* @__PURE__ */ X(z, { className: "h-3 w-3" }), V("detail.editRow")]
|
|
1187
|
+
}), _ && /* @__PURE__ */ Z(P, {
|
|
1188
|
+
variant: "ghost",
|
|
1189
|
+
size: "sm",
|
|
1190
|
+
className: "h-6 text-xs gap-1 px-2 text-destructive hover:text-destructive",
|
|
1191
|
+
onClick: () => fe(e),
|
|
1192
|
+
children: [/* @__PURE__ */ X(Ae, { className: "h-3 w-3" }), V("detail.deleteRow")]
|
|
1193
|
+
})]
|
|
1194
|
+
})]
|
|
1195
|
+
}, e.id || t))
|
|
1196
|
+
})] }),
|
|
1197
|
+
H > 0 && se.length > H && /* @__PURE__ */ Z("div", {
|
|
1198
|
+
className: "flex items-center justify-between mt-3 pt-3 border-t",
|
|
1199
|
+
children: [
|
|
1200
|
+
/* @__PURE__ */ Z(P, {
|
|
1201
|
+
variant: "outline",
|
|
1202
|
+
size: "sm",
|
|
1203
|
+
className: "h-7 text-xs gap-1",
|
|
1204
|
+
disabled: O === 0,
|
|
1205
|
+
onClick: () => k((e) => Math.max(0, e - 1)),
|
|
1206
|
+
children: [/* @__PURE__ */ X(te, { className: "h-3 w-3" }), V("detail.previousPage")]
|
|
1207
|
+
}),
|
|
1208
|
+
/* @__PURE__ */ X("span", {
|
|
1209
|
+
className: "text-xs text-muted-foreground",
|
|
1210
|
+
children: V("detail.pageOf", {
|
|
1211
|
+
current: O + 1,
|
|
1212
|
+
total: ce
|
|
1213
|
+
})
|
|
1214
|
+
}),
|
|
1215
|
+
/* @__PURE__ */ Z(P, {
|
|
1216
|
+
variant: "outline",
|
|
1217
|
+
size: "sm",
|
|
1218
|
+
className: "h-7 text-xs gap-1",
|
|
1219
|
+
disabled: O >= ce - 1,
|
|
1220
|
+
onClick: () => k((e) => Math.min(ce - 1, e + 1)),
|
|
1221
|
+
children: [V("detail.nextPage"), /* @__PURE__ */ X(p, { className: "h-3 w-3" })]
|
|
1222
|
+
})
|
|
1223
|
+
]
|
|
1224
|
+
})
|
|
1225
|
+
] })]
|
|
1226
|
+
});
|
|
1227
|
+
}, Pt = ({ group: e, data: t, className: n, objectSchema: r, objectName: a, isEditing: o = !1, onFieldChange: s }) => {
|
|
1228
|
+
let c = e.collapsible ?? !0, [l, u] = J.useState(e.defaultCollapsed ?? !1), d = /* @__PURE__ */ X("div", {
|
|
1229
|
+
className: "space-y-3 sm:space-y-4",
|
|
1230
|
+
children: e.sections.map((e, n) => /* @__PURE__ */ X(jt, {
|
|
1231
|
+
section: e,
|
|
1232
|
+
data: t,
|
|
1233
|
+
objectSchema: r,
|
|
1234
|
+
objectName: a,
|
|
1235
|
+
isEditing: o,
|
|
1236
|
+
onFieldChange: s
|
|
1237
|
+
}, n))
|
|
1238
|
+
});
|
|
1239
|
+
return c ? /* @__PURE__ */ Z(Le, {
|
|
1240
|
+
open: !l,
|
|
1241
|
+
onOpenChange: (e) => u(!e),
|
|
1242
|
+
className: n,
|
|
1243
|
+
children: [
|
|
1244
|
+
/* @__PURE__ */ X(k, {
|
|
1245
|
+
asChild: !0,
|
|
1246
|
+
children: /* @__PURE__ */ Z("div", {
|
|
1247
|
+
className: "flex items-center gap-2 pb-2 border-b cursor-pointer hover:bg-muted/50 transition-colors rounded-t-md px-2 py-1.5",
|
|
1248
|
+
children: [
|
|
1249
|
+
X(l ? p : ee, { className: "h-4 w-4 text-muted-foreground shrink-0" }),
|
|
1250
|
+
e.icon && /* @__PURE__ */ X("span", {
|
|
1251
|
+
className: "text-muted-foreground",
|
|
1252
|
+
children: e.icon
|
|
1253
|
+
}),
|
|
1254
|
+
/* @__PURE__ */ X("h3", {
|
|
1255
|
+
className: "text-lg font-semibold",
|
|
1256
|
+
children: e.title
|
|
1257
|
+
})
|
|
1258
|
+
]
|
|
1259
|
+
})
|
|
1260
|
+
}),
|
|
1261
|
+
e.description && !l && /* @__PURE__ */ X("p", {
|
|
1262
|
+
className: "text-sm text-muted-foreground mt-1",
|
|
1263
|
+
children: e.description
|
|
1264
|
+
}),
|
|
1265
|
+
/* @__PURE__ */ X(i, { children: /* @__PURE__ */ X("div", {
|
|
1266
|
+
className: "mt-3",
|
|
1267
|
+
children: d
|
|
1268
|
+
}) })
|
|
1269
|
+
]
|
|
1270
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
1271
|
+
className: q("space-y-3", n),
|
|
1272
|
+
children: [
|
|
1273
|
+
/* @__PURE__ */ Z("div", {
|
|
1274
|
+
className: "flex items-center gap-2 pb-2 border-b",
|
|
1275
|
+
children: [e.icon && /* @__PURE__ */ X("span", {
|
|
1276
|
+
className: "text-muted-foreground",
|
|
1277
|
+
children: e.icon
|
|
1278
|
+
}), /* @__PURE__ */ X("h3", {
|
|
1279
|
+
className: "text-lg font-semibold",
|
|
1280
|
+
children: e.title
|
|
1281
|
+
})]
|
|
1282
|
+
}),
|
|
1283
|
+
e.description && /* @__PURE__ */ X("p", {
|
|
1284
|
+
className: "text-sm text-muted-foreground",
|
|
1285
|
+
children: e.description
|
|
1286
|
+
}),
|
|
1287
|
+
d
|
|
1288
|
+
]
|
|
1289
|
+
});
|
|
1290
|
+
}, Ft = ({ fields: e, data: t, className: n, objectName: r, objectSchema: i }) => {
|
|
1291
|
+
let { fieldLabel: a } = We();
|
|
1292
|
+
if (!e.length || !t) return null;
|
|
1293
|
+
let o = e.filter((e) => {
|
|
1294
|
+
let n = t?.[e.name];
|
|
1295
|
+
return n != null && n !== "";
|
|
1296
|
+
});
|
|
1297
|
+
return o.length === 0 ? null : /* @__PURE__ */ X(D, {
|
|
1298
|
+
className: q("bg-muted/30 border-dashed", n),
|
|
1299
|
+
children: /* @__PURE__ */ X(j, {
|
|
1300
|
+
className: "py-3 px-4",
|
|
1301
|
+
children: /* @__PURE__ */ X("div", {
|
|
1302
|
+
className: q("grid gap-4", o.length === 1 ? "grid-cols-1" : o.length === 2 ? "grid-cols-2" : o.length === 3 ? "grid-cols-3" : "grid-cols-2 md:grid-cols-4"),
|
|
1303
|
+
children: o.map((e) => {
|
|
1304
|
+
let n = t[e.name], o = i?.fields?.[e.name], s = e.type || o?.type, c = {
|
|
1305
|
+
name: e.name,
|
|
1306
|
+
label: e.label,
|
|
1307
|
+
type: s || "text",
|
|
1308
|
+
...o?.options && { options: o.options },
|
|
1309
|
+
...o?.currency && { currency: o.currency },
|
|
1310
|
+
...o?.precision !== void 0 && { precision: o.precision },
|
|
1311
|
+
...o?.format && { format: o.format }
|
|
1312
|
+
}, l = vt(s || "text");
|
|
1313
|
+
return /* @__PURE__ */ Z("div", {
|
|
1314
|
+
className: "flex flex-col gap-0.5",
|
|
1315
|
+
children: [/* @__PURE__ */ Z("span", {
|
|
1316
|
+
className: "text-xs font-medium text-muted-foreground uppercase tracking-wide",
|
|
1317
|
+
children: [e.icon && /* @__PURE__ */ X("span", {
|
|
1318
|
+
className: "mr-1",
|
|
1319
|
+
children: e.icon
|
|
1320
|
+
}), a(r || "", e.name, e.label)]
|
|
1321
|
+
}), /* @__PURE__ */ X("span", {
|
|
1322
|
+
className: "text-sm font-semibold truncate",
|
|
1323
|
+
children: /* @__PURE__ */ X(l, {
|
|
1324
|
+
value: n,
|
|
1325
|
+
field: c
|
|
1326
|
+
})
|
|
1327
|
+
})]
|
|
1328
|
+
}, e.name);
|
|
1329
|
+
})
|
|
1330
|
+
})
|
|
1331
|
+
})
|
|
1332
|
+
});
|
|
1333
|
+
};
|
|
1334
|
+
//#endregion
|
|
1335
|
+
//#region src/RecordComments.tsx
|
|
1336
|
+
function It(e) {
|
|
1337
|
+
try {
|
|
1338
|
+
let t = new Date(e), n = (/* @__PURE__ */ new Date()).getTime() - t.getTime(), r = Math.floor(n / 6e4);
|
|
1339
|
+
if (r < 1) return "just now";
|
|
1340
|
+
if (r < 60) return `${r}m ago`;
|
|
1341
|
+
let i = Math.floor(r / 60);
|
|
1342
|
+
if (i < 24) return `${i}h ago`;
|
|
1343
|
+
let a = Math.floor(i / 24);
|
|
1344
|
+
return a < 7 ? `${a}d ago` : t.toLocaleDateString();
|
|
1345
|
+
} catch {
|
|
1346
|
+
return e;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
var Lt = ({ comments: t, onAddComment: n, onTogglePin: r, searchable: i = !1, className: a }) => {
|
|
1350
|
+
let [o, s] = J.useState(""), [l, u] = J.useState(!1), [d, f] = J.useState(""), p = J.useCallback(async () => {
|
|
1351
|
+
let e = o.trim();
|
|
1352
|
+
if (!(!e || !n)) {
|
|
1353
|
+
u(!0);
|
|
1354
|
+
try {
|
|
1355
|
+
await n(e), s("");
|
|
1356
|
+
} finally {
|
|
1357
|
+
u(!1);
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
}, [o, n]), h = J.useCallback((e) => {
|
|
1361
|
+
e.key === "Enter" && (e.ctrlKey || e.metaKey) && (e.preventDefault(), p());
|
|
1362
|
+
}, [p]), g = J.useMemo(() => [...d.trim() ? t.filter((e) => {
|
|
1363
|
+
let t = d.trim().toLowerCase();
|
|
1364
|
+
return e.text.toLowerCase().includes(t) || e.author.toLowerCase().includes(t);
|
|
1365
|
+
}) : t].sort((e, t) => e.pinned && !t.pinned ? -1 : !e.pinned && t.pinned ? 1 : 0), [t, d]);
|
|
1366
|
+
return /* @__PURE__ */ Z(D, {
|
|
1367
|
+
className: q("", a),
|
|
1368
|
+
children: [/* @__PURE__ */ X(c, { children: /* @__PURE__ */ Z(m, {
|
|
1369
|
+
className: "flex items-center gap-2 text-base",
|
|
1370
|
+
children: [
|
|
1371
|
+
/* @__PURE__ */ X(T, { className: "h-4 w-4" }),
|
|
1372
|
+
"Comments",
|
|
1373
|
+
/* @__PURE__ */ Z("span", {
|
|
1374
|
+
className: "text-sm font-normal text-muted-foreground",
|
|
1375
|
+
children: [
|
|
1376
|
+
"(",
|
|
1377
|
+
t.length,
|
|
1378
|
+
")"
|
|
1379
|
+
]
|
|
1380
|
+
})
|
|
1381
|
+
]
|
|
1382
|
+
}) }), /* @__PURE__ */ Z(j, {
|
|
1383
|
+
className: "space-y-4",
|
|
1384
|
+
children: [
|
|
1385
|
+
i && /* @__PURE__ */ X("div", {
|
|
1386
|
+
className: "flex items-center gap-2",
|
|
1387
|
+
children: /* @__PURE__ */ Z("div", {
|
|
1388
|
+
className: "relative flex-1",
|
|
1389
|
+
children: [
|
|
1390
|
+
/* @__PURE__ */ X(V, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" }),
|
|
1391
|
+
/* @__PURE__ */ X("input", {
|
|
1392
|
+
className: "w-full rounded-md border border-input bg-background pl-8 pr-8 py-1.5 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
1393
|
+
placeholder: "Search comments…",
|
|
1394
|
+
value: d,
|
|
1395
|
+
onChange: (e) => f(e.target.value),
|
|
1396
|
+
"aria-label": "Search comments"
|
|
1397
|
+
}),
|
|
1398
|
+
d && /* @__PURE__ */ X("button", {
|
|
1399
|
+
className: "absolute right-2 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",
|
|
1400
|
+
onClick: () => f(""),
|
|
1401
|
+
"aria-label": "Clear search",
|
|
1402
|
+
type: "button",
|
|
1403
|
+
children: /* @__PURE__ */ X(e, { className: "h-3.5 w-3.5" })
|
|
1404
|
+
})
|
|
1405
|
+
]
|
|
1406
|
+
})
|
|
1407
|
+
}),
|
|
1408
|
+
n && /* @__PURE__ */ Z("div", {
|
|
1409
|
+
className: "flex gap-2",
|
|
1410
|
+
children: [/* @__PURE__ */ X("textarea", {
|
|
1411
|
+
className: "flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none",
|
|
1412
|
+
placeholder: "Add a comment… (Ctrl+Enter to submit)",
|
|
1413
|
+
value: o,
|
|
1414
|
+
onChange: (e) => s(e.target.value),
|
|
1415
|
+
onKeyDown: h,
|
|
1416
|
+
disabled: l
|
|
1417
|
+
}), /* @__PURE__ */ X(P, {
|
|
1418
|
+
size: "icon",
|
|
1419
|
+
variant: "default",
|
|
1420
|
+
onClick: p,
|
|
1421
|
+
disabled: !o.trim() || l,
|
|
1422
|
+
className: "shrink-0 self-end",
|
|
1423
|
+
children: /* @__PURE__ */ X(je, { className: "h-4 w-4" })
|
|
1424
|
+
})]
|
|
1425
|
+
}),
|
|
1426
|
+
g.length === 0 ? /* @__PURE__ */ X("p", {
|
|
1427
|
+
className: "text-sm text-muted-foreground text-center py-4",
|
|
1428
|
+
children: d.trim() ? "No matching comments" : "No comments yet"
|
|
1429
|
+
}) : /* @__PURE__ */ X("div", {
|
|
1430
|
+
className: "space-y-3",
|
|
1431
|
+
children: g.map((e) => /* @__PURE__ */ Z("div", {
|
|
1432
|
+
className: q("flex gap-3", e.pinned && "bg-muted/40 rounded-md p-2 -mx-2"),
|
|
1433
|
+
children: [/* @__PURE__ */ X("div", {
|
|
1434
|
+
className: "shrink-0",
|
|
1435
|
+
children: e.avatarUrl ? /* @__PURE__ */ X("img", {
|
|
1436
|
+
src: e.avatarUrl,
|
|
1437
|
+
alt: e.author,
|
|
1438
|
+
className: "h-8 w-8 rounded-full object-cover"
|
|
1439
|
+
}) : /* @__PURE__ */ X("div", {
|
|
1440
|
+
className: "h-8 w-8 rounded-full bg-muted flex items-center justify-center text-xs font-medium text-muted-foreground",
|
|
1441
|
+
children: e.author.charAt(0).toUpperCase()
|
|
1442
|
+
})
|
|
1443
|
+
}), /* @__PURE__ */ Z("div", {
|
|
1444
|
+
className: "flex-1 min-w-0",
|
|
1445
|
+
children: [
|
|
1446
|
+
/* @__PURE__ */ Z("div", {
|
|
1447
|
+
className: "flex items-center gap-2 mb-0.5",
|
|
1448
|
+
children: [
|
|
1449
|
+
/* @__PURE__ */ X("span", {
|
|
1450
|
+
className: "text-sm font-medium truncate",
|
|
1451
|
+
children: e.author
|
|
1452
|
+
}),
|
|
1453
|
+
/* @__PURE__ */ X("span", {
|
|
1454
|
+
className: "text-xs text-muted-foreground",
|
|
1455
|
+
children: It(e.createdAt)
|
|
1456
|
+
}),
|
|
1457
|
+
e.pinned && /* @__PURE__ */ Z("span", {
|
|
1458
|
+
className: "text-xs text-amber-600 flex items-center gap-0.5",
|
|
1459
|
+
children: [/* @__PURE__ */ X(ce, { className: "h-3 w-3" }), "Pinned"]
|
|
1460
|
+
})
|
|
1461
|
+
]
|
|
1462
|
+
}),
|
|
1463
|
+
/* @__PURE__ */ X("p", {
|
|
1464
|
+
className: "text-sm whitespace-pre-wrap break-words",
|
|
1465
|
+
children: e.text
|
|
1466
|
+
}),
|
|
1467
|
+
r && /* @__PURE__ */ Z("button", {
|
|
1468
|
+
type: "button",
|
|
1469
|
+
className: "mt-1 text-xs text-muted-foreground hover:text-foreground flex items-center gap-1",
|
|
1470
|
+
onClick: () => r(e.id),
|
|
1471
|
+
"aria-label": e.pinned ? "Unpin comment" : "Pin comment",
|
|
1472
|
+
children: [/* @__PURE__ */ X(ce, { className: "h-3 w-3" }), e.pinned ? "Unpin" : "Pin"]
|
|
1473
|
+
})
|
|
1474
|
+
]
|
|
1475
|
+
})]
|
|
1476
|
+
}, e.id))
|
|
1477
|
+
})
|
|
1478
|
+
]
|
|
1479
|
+
})]
|
|
1480
|
+
});
|
|
1481
|
+
}, Rt = {
|
|
1482
|
+
field_change: z,
|
|
1483
|
+
create: M,
|
|
1484
|
+
delete: Ae,
|
|
1485
|
+
comment: T,
|
|
1486
|
+
status_change: xe
|
|
1487
|
+
}, zt = {
|
|
1488
|
+
field_change: "bg-blue-100 text-blue-600",
|
|
1489
|
+
create: "bg-green-100 text-green-600",
|
|
1490
|
+
delete: "bg-red-100 text-red-600",
|
|
1491
|
+
comment: "bg-purple-100 text-purple-600",
|
|
1492
|
+
status_change: "bg-amber-100 text-amber-600"
|
|
1493
|
+
};
|
|
1494
|
+
function Bt(e) {
|
|
1495
|
+
try {
|
|
1496
|
+
let t = new Date(e), n = (/* @__PURE__ */ new Date()).getTime() - t.getTime(), r = Math.floor(n / 6e4);
|
|
1497
|
+
if (r < 1) return "just now";
|
|
1498
|
+
if (r < 60) return `${r}m ago`;
|
|
1499
|
+
let i = Math.floor(r / 60);
|
|
1500
|
+
if (i < 24) return `${i}h ago`;
|
|
1501
|
+
let a = Math.floor(i / 24);
|
|
1502
|
+
return a < 7 ? `${a}d ago` : t.toLocaleDateString();
|
|
1503
|
+
} catch {
|
|
1504
|
+
return e;
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
function Vt(e) {
|
|
1508
|
+
return e.description ? e.description : e.type === "field_change" && e.field ? `Changed ${e.field.charAt(0).toUpperCase() + e.field.slice(1).replace(/_/g, " ")} from "${e.oldValue == null ? "(empty)" : String(e.oldValue)}" to "${e.newValue == null ? "(empty)" : String(e.newValue)}"` : e.type === "create" ? "Created this record" : e.type === "delete" ? "Deleted this record" : e.type === "status_change" && e.field ? `Changed status to "${e.newValue == null ? "(empty)" : String(e.newValue)}"` : "Updated record";
|
|
1509
|
+
}
|
|
1510
|
+
var Ht = {
|
|
1511
|
+
all: "All",
|
|
1512
|
+
field_change: "Field Changes",
|
|
1513
|
+
create: "Creates",
|
|
1514
|
+
delete: "Deletes",
|
|
1515
|
+
comment: "Comments",
|
|
1516
|
+
status_change: "Status Changes"
|
|
1517
|
+
}, Ut = ({ activities: e, filterable: t = !1, defaultFilter: n = "all", className: r }) => {
|
|
1518
|
+
let [i, a] = J.useState(n), o = J.useMemo(() => i === "all" ? e : e.filter((e) => e.type === i), [e, i]);
|
|
1519
|
+
return /* @__PURE__ */ Z(D, {
|
|
1520
|
+
className: q("", r),
|
|
1521
|
+
children: [/* @__PURE__ */ X(c, { children: /* @__PURE__ */ Z(m, {
|
|
1522
|
+
className: "flex items-center gap-2 text-base",
|
|
1523
|
+
children: [
|
|
1524
|
+
/* @__PURE__ */ X(ge, { className: "h-4 w-4" }),
|
|
1525
|
+
"Activity",
|
|
1526
|
+
/* @__PURE__ */ Z("span", {
|
|
1527
|
+
className: "text-sm font-normal text-muted-foreground",
|
|
1528
|
+
children: [
|
|
1529
|
+
"(",
|
|
1530
|
+
o.length,
|
|
1531
|
+
")"
|
|
1532
|
+
]
|
|
1533
|
+
})
|
|
1534
|
+
]
|
|
1535
|
+
}) }), /* @__PURE__ */ Z(j, { children: [t && /* @__PURE__ */ X("div", {
|
|
1536
|
+
className: "flex flex-wrap gap-1.5 mb-4",
|
|
1537
|
+
role: "group",
|
|
1538
|
+
"aria-label": "Activity type filter",
|
|
1539
|
+
children: Object.keys(Ht).map((e) => /* @__PURE__ */ Z("button", {
|
|
1540
|
+
type: "button",
|
|
1541
|
+
className: q("inline-flex items-center gap-1 rounded-full px-2.5 py-0.5 text-xs font-medium transition-colors", i === e ? "bg-primary text-primary-foreground" : "bg-muted text-muted-foreground hover:bg-muted/80"),
|
|
1542
|
+
onClick: () => a(e),
|
|
1543
|
+
"aria-pressed": i === e,
|
|
1544
|
+
children: [e !== "all" && J.createElement(Rt[e] || z, { className: "h-3 w-3" }), Ht[e]]
|
|
1545
|
+
}, e))
|
|
1546
|
+
}), o.length === 0 ? /* @__PURE__ */ X("p", {
|
|
1547
|
+
className: "text-sm text-muted-foreground text-center py-4",
|
|
1548
|
+
children: "No activity recorded"
|
|
1549
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
1550
|
+
className: "relative",
|
|
1551
|
+
children: [/* @__PURE__ */ X("div", { className: "absolute left-4 top-2 bottom-2 w-px bg-border" }), /* @__PURE__ */ X("div", {
|
|
1552
|
+
className: "space-y-4",
|
|
1553
|
+
children: o.map((e) => {
|
|
1554
|
+
let t = Rt[e.type] || z;
|
|
1555
|
+
return /* @__PURE__ */ Z("div", {
|
|
1556
|
+
className: "flex gap-3 relative",
|
|
1557
|
+
children: [/* @__PURE__ */ X("div", {
|
|
1558
|
+
className: q("shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10", zt[e.type] || "bg-gray-100 text-gray-600"),
|
|
1559
|
+
children: /* @__PURE__ */ X(t, { className: "h-3.5 w-3.5" })
|
|
1560
|
+
}), /* @__PURE__ */ Z("div", {
|
|
1561
|
+
className: "flex-1 min-w-0 pt-1",
|
|
1562
|
+
children: [/* @__PURE__ */ Z("p", {
|
|
1563
|
+
className: "text-sm",
|
|
1564
|
+
children: [
|
|
1565
|
+
/* @__PURE__ */ X("span", {
|
|
1566
|
+
className: "font-medium",
|
|
1567
|
+
children: e.user
|
|
1568
|
+
}),
|
|
1569
|
+
" ",
|
|
1570
|
+
/* @__PURE__ */ X("span", {
|
|
1571
|
+
className: "text-muted-foreground",
|
|
1572
|
+
children: Vt(e)
|
|
1573
|
+
})
|
|
1574
|
+
]
|
|
1575
|
+
}), /* @__PURE__ */ X("p", {
|
|
1576
|
+
className: "text-xs text-muted-foreground mt-0.5",
|
|
1577
|
+
children: Bt(e.timestamp)
|
|
1578
|
+
})]
|
|
1579
|
+
})]
|
|
1580
|
+
}, e.id);
|
|
1581
|
+
})
|
|
1582
|
+
})]
|
|
1583
|
+
})] })]
|
|
1584
|
+
});
|
|
1585
|
+
}, Wt = 5, Gt = ({ schema: e, dataSource: t, className: i, onEdit: a, onDelete: o, onBack: s, inlineEdit: c = !1, onFieldSave: l }) => {
|
|
1586
|
+
let [u, d] = J.useState(e.data), [f, m] = J.useState(!e.data && !!(e.api && e.resourceId || t && e.objectName && e.resourceId)), [h, _] = J.useState(!1), [y, b] = J.useState(!1), [x, S] = J.useState({}), [C, T] = J.useState(null), { t: E } = kt();
|
|
1587
|
+
J.useEffect(() => {
|
|
1588
|
+
let n = !0;
|
|
1589
|
+
if (e.data) {
|
|
1590
|
+
d(e.data), m(!1);
|
|
1591
|
+
return;
|
|
1592
|
+
}
|
|
1593
|
+
if (t && e.objectName && e.resourceId) {
|
|
1594
|
+
m(!0), T(null), d(null);
|
|
1595
|
+
let r = e.objectName, i = e.resourceId, a = `${r}-`, o = [...e.sections?.flatMap((e) => e.fields) || [], ...e.fields || []];
|
|
1596
|
+
(t.getObjectSchema ? t.getObjectSchema(r).catch(() => null) : Promise.resolve(null)).then((e) => {
|
|
1597
|
+
if (!n) return;
|
|
1598
|
+
T(e);
|
|
1599
|
+
let s = Ve(e?.fields, o), c = s.length > 0 ? { $expand: s } : void 0, l = c ? t.findOne(r, i, c) : t.findOne(r, i), u = () => {
|
|
1600
|
+
let e = String(i), o = e.startsWith(a) ? e.slice(a.length) : `${a}${e}`;
|
|
1601
|
+
return (c ? t.findOne(r, o, c) : t.findOne(r, o)).then((e) => {
|
|
1602
|
+
n && (d(e), m(!1));
|
|
1603
|
+
}).catch(() => {
|
|
1604
|
+
n && (d(null), m(!1));
|
|
1605
|
+
});
|
|
1606
|
+
};
|
|
1607
|
+
return l.catch(() => null).then((e) => {
|
|
1608
|
+
if (n) {
|
|
1609
|
+
if (e) {
|
|
1610
|
+
d(e), m(!1);
|
|
1611
|
+
return;
|
|
1612
|
+
}
|
|
1613
|
+
return u();
|
|
1614
|
+
}
|
|
1615
|
+
});
|
|
1616
|
+
}).catch((e) => {
|
|
1617
|
+
n && (console.error("Failed to fetch detail data:", e), m(!1));
|
|
1618
|
+
});
|
|
1619
|
+
} else e.api && e.resourceId && (m(!0), fetch(`${e.api}/${e.resourceId}`).then((e) => e.json()).then((e) => {
|
|
1620
|
+
n && d(e?.data || e);
|
|
1621
|
+
}).catch((e) => {
|
|
1622
|
+
console.error("Failed to fetch detail data:", e);
|
|
1623
|
+
}).finally(() => {
|
|
1624
|
+
n && m(!1);
|
|
1625
|
+
}));
|
|
1626
|
+
return () => {
|
|
1627
|
+
n = !1;
|
|
1628
|
+
};
|
|
1629
|
+
}, [
|
|
1630
|
+
e.api,
|
|
1631
|
+
e.resourceId,
|
|
1632
|
+
e.objectName,
|
|
1633
|
+
t,
|
|
1634
|
+
e.sections,
|
|
1635
|
+
e.fields
|
|
1636
|
+
]);
|
|
1637
|
+
let D = J.useCallback(() => {
|
|
1638
|
+
if (s) s();
|
|
1639
|
+
else if (e.onNavigate) {
|
|
1640
|
+
let t = e.backUrl || (e.objectName ? `/${e.objectName}` : "/");
|
|
1641
|
+
e.onNavigate(t, { replace: !0 });
|
|
1642
|
+
} else e.backUrl ? window.location.href = e.backUrl : window.history.back();
|
|
1643
|
+
}, [s, e]), O = J.useCallback(() => {
|
|
1644
|
+
a ? a() : e.onNavigate && e.editUrl ? e.onNavigate(e.editUrl) : e.onNavigate && e.objectName && e.resourceId ? e.onNavigate(`/${e.objectName}/${e.resourceId}/edit`) : e.editUrl && (window.location.href = e.editUrl);
|
|
1645
|
+
}, [a, e]), k = J.useCallback(() => {
|
|
1646
|
+
let t = e.deleteConfirmation || E("detail.deleteConfirmation");
|
|
1647
|
+
window.confirm(t) && (o?.(), e.onNavigate && e.objectName && e.onNavigate(`/${e.objectName}`, { replace: !0 }));
|
|
1648
|
+
}, [o, e]), j = J.useCallback(() => {
|
|
1649
|
+
navigator.share && e.objectName && e.resourceId ? navigator.share({
|
|
1650
|
+
title: e.title || E("detail.details"),
|
|
1651
|
+
text: `${e.objectName} #${e.resourceId}`,
|
|
1652
|
+
url: window.location.href
|
|
1653
|
+
}).catch((e) => console.log("Share failed:", e)) : navigator.clipboard.writeText(window.location.href).then(() => {
|
|
1654
|
+
console.log("Link copied to clipboard");
|
|
1655
|
+
});
|
|
1656
|
+
}, [e]), M = J.useCallback(() => {
|
|
1657
|
+
console.log("Duplicate record:", u);
|
|
1658
|
+
}, [u]), ee = J.useCallback(() => {
|
|
1659
|
+
console.log("Export record:", u);
|
|
1660
|
+
}, [u]), N = J.useCallback(() => {
|
|
1661
|
+
console.log("View history for record:", e.resourceId);
|
|
1662
|
+
}, [e]), ne = J.useCallback(() => {
|
|
1663
|
+
_(!h);
|
|
1664
|
+
}, [h]), R = J.useCallback(() => {
|
|
1665
|
+
if (y) {
|
|
1666
|
+
let e = Object.entries(x);
|
|
1667
|
+
if (e.length > 0) {
|
|
1668
|
+
let t = {
|
|
1669
|
+
...u,
|
|
1670
|
+
...x
|
|
1671
|
+
};
|
|
1672
|
+
d(t), e.forEach(([e, n]) => {
|
|
1673
|
+
l?.(e, n, t);
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
S({});
|
|
1677
|
+
}
|
|
1678
|
+
b(!y);
|
|
1679
|
+
}, [
|
|
1680
|
+
y,
|
|
1681
|
+
x,
|
|
1682
|
+
u,
|
|
1683
|
+
l
|
|
1684
|
+
]), B = J.useCallback((e, t) => {
|
|
1685
|
+
S((n) => ({
|
|
1686
|
+
...n,
|
|
1687
|
+
[e]: t
|
|
1688
|
+
}));
|
|
1689
|
+
}, []);
|
|
1690
|
+
J.useEffect(() => {
|
|
1691
|
+
if (!e.recordNavigation) return;
|
|
1692
|
+
let t = e.recordNavigation, n = (e) => {
|
|
1693
|
+
let n = e.target?.tagName;
|
|
1694
|
+
n === "INPUT" || n === "TEXTAREA" || e.target?.isContentEditable || (e.key === "ArrowLeft" && t.currentIndex > 0 ? (e.preventDefault(), t.onNavigate(t.recordIds[t.currentIndex - 1])) : e.key === "ArrowRight" && t.currentIndex < t.recordIds.length - 1 && (e.preventDefault(), t.onNavigate(t.recordIds[t.currentIndex + 1])));
|
|
1695
|
+
};
|
|
1696
|
+
return document.addEventListener("keydown", n), () => document.removeEventListener("keydown", n);
|
|
1697
|
+
}, [e.recordNavigation]);
|
|
1698
|
+
let re = J.useMemo(() => {
|
|
1699
|
+
if (!e.autoDiscoverRelated || !C?.fields || e.related && e.related.length > 0) return [];
|
|
1700
|
+
let t = [], n = C.fields;
|
|
1701
|
+
for (let [e, r] of Object.entries(n)) {
|
|
1702
|
+
let n = r?.reference_to || r?.reference;
|
|
1703
|
+
r && (r.type === "lookup" || r.type === "master_detail") && n && t.push({
|
|
1704
|
+
title: r.label || e.charAt(0).toUpperCase() + e.slice(1),
|
|
1705
|
+
type: "table",
|
|
1706
|
+
objectName: n,
|
|
1707
|
+
referenceField: e
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1710
|
+
return t;
|
|
1711
|
+
}, [
|
|
1712
|
+
e.autoDiscoverRelated,
|
|
1713
|
+
e.related,
|
|
1714
|
+
C
|
|
1715
|
+
]), V = J.useMemo(() => e.related && e.related.length > 0 ? e.related : re.map((e) => ({
|
|
1716
|
+
title: e.title,
|
|
1717
|
+
type: e.type,
|
|
1718
|
+
api: e.objectName,
|
|
1719
|
+
data: []
|
|
1720
|
+
})), [e.related, re]);
|
|
1721
|
+
return f || e.loading ? /* @__PURE__ */ Z("div", {
|
|
1722
|
+
className: q("space-y-4", i),
|
|
1723
|
+
children: [
|
|
1724
|
+
/* @__PURE__ */ X(Me, { className: "h-10 w-full" }),
|
|
1725
|
+
/* @__PURE__ */ X(Me, { className: "h-64 w-full" }),
|
|
1726
|
+
/* @__PURE__ */ X(Me, { className: "h-48 w-full" })
|
|
1727
|
+
]
|
|
1728
|
+
}) : !u && !e.data ? /* @__PURE__ */ Z("div", {
|
|
1729
|
+
className: q("flex flex-col items-center justify-center py-16 text-center", i),
|
|
1730
|
+
children: [
|
|
1731
|
+
/* @__PURE__ */ X("p", {
|
|
1732
|
+
className: "text-lg font-semibold",
|
|
1733
|
+
children: E("detail.recordNotFound")
|
|
1734
|
+
}),
|
|
1735
|
+
/* @__PURE__ */ X("p", {
|
|
1736
|
+
className: "text-sm text-muted-foreground mt-1",
|
|
1737
|
+
children: E("detail.recordNotFoundDescription")
|
|
1738
|
+
}),
|
|
1739
|
+
(e.showBack ?? !0) && /* @__PURE__ */ Z(P, {
|
|
1740
|
+
variant: "outline",
|
|
1741
|
+
size: "sm",
|
|
1742
|
+
onClick: D,
|
|
1743
|
+
className: "mt-4 gap-2",
|
|
1744
|
+
children: [/* @__PURE__ */ X(De, { className: "h-4 w-4" }), E("detail.goBack")]
|
|
1745
|
+
})
|
|
1746
|
+
]
|
|
1747
|
+
}) : /* @__PURE__ */ X(H, { children: /* @__PURE__ */ Z("div", {
|
|
1748
|
+
className: q("space-y-6", i),
|
|
1749
|
+
children: [
|
|
1750
|
+
/* @__PURE__ */ Z("div", {
|
|
1751
|
+
className: "flex flex-col sm:flex-row items-start justify-between gap-3 sm:gap-4 pb-4 border-b",
|
|
1752
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
1753
|
+
className: "flex items-start gap-2 sm:gap-3 flex-1 min-w-0",
|
|
1754
|
+
children: [(e.showBack ?? !0) && /* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1755
|
+
asChild: !0,
|
|
1756
|
+
children: /* @__PURE__ */ X(P, {
|
|
1757
|
+
variant: "ghost",
|
|
1758
|
+
size: "icon",
|
|
1759
|
+
onClick: D,
|
|
1760
|
+
className: "shrink-0 mt-1",
|
|
1761
|
+
children: /* @__PURE__ */ X(De, { className: "h-4 w-4" })
|
|
1762
|
+
})
|
|
1763
|
+
}), /* @__PURE__ */ X(U, { children: E("detail.back") })] }), /* @__PURE__ */ Z("div", {
|
|
1764
|
+
className: "flex-1 min-w-0",
|
|
1765
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
1766
|
+
className: "flex items-center gap-2 flex-wrap",
|
|
1767
|
+
children: [
|
|
1768
|
+
/* @__PURE__ */ X("h1", {
|
|
1769
|
+
className: "text-xl sm:text-2xl font-bold truncate",
|
|
1770
|
+
children: e.primaryField && u?.[e.primaryField] || e.title || E("detail.details")
|
|
1771
|
+
}),
|
|
1772
|
+
e.summaryFields?.map((e) => {
|
|
1773
|
+
let t = u?.[e];
|
|
1774
|
+
return t == null || t === "" ? null : /* @__PURE__ */ X(K, {
|
|
1775
|
+
variant: "secondary",
|
|
1776
|
+
className: "text-xs",
|
|
1777
|
+
"aria-label": `${e}: ${t}`,
|
|
1778
|
+
children: String(t)
|
|
1779
|
+
}, e);
|
|
1780
|
+
}),
|
|
1781
|
+
/* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1782
|
+
asChild: !0,
|
|
1783
|
+
children: /* @__PURE__ */ X(P, {
|
|
1784
|
+
variant: "ghost",
|
|
1785
|
+
size: "icon",
|
|
1786
|
+
className: "h-6 w-6 shrink-0",
|
|
1787
|
+
onClick: ne,
|
|
1788
|
+
children: h ? /* @__PURE__ */ X(Ee, { className: "h-4 w-4 fill-yellow-400 text-yellow-400" }) : /* @__PURE__ */ X(fe, { className: "h-4 w-4 text-muted-foreground" })
|
|
1789
|
+
})
|
|
1790
|
+
}), /* @__PURE__ */ X(U, { children: E(h ? "detail.removeFromFavorites" : "detail.addToFavorites") })] })
|
|
1791
|
+
]
|
|
1792
|
+
}), e.objectName && /* @__PURE__ */ Z("p", {
|
|
1793
|
+
className: "text-sm text-muted-foreground mt-1 flex items-center gap-1.5",
|
|
1794
|
+
children: [
|
|
1795
|
+
/* @__PURE__ */ X("span", {
|
|
1796
|
+
className: "font-medium",
|
|
1797
|
+
children: e.objectName
|
|
1798
|
+
}),
|
|
1799
|
+
/* @__PURE__ */ X("span", {
|
|
1800
|
+
className: "text-muted-foreground/60",
|
|
1801
|
+
children: "•"
|
|
1802
|
+
}),
|
|
1803
|
+
/* @__PURE__ */ Z("span", { children: ["#", e.resourceId] })
|
|
1804
|
+
]
|
|
1805
|
+
})]
|
|
1806
|
+
})]
|
|
1807
|
+
}), /* @__PURE__ */ Z("div", {
|
|
1808
|
+
className: "flex flex-wrap items-center gap-1.5 shrink-0 w-full sm:w-auto",
|
|
1809
|
+
children: [
|
|
1810
|
+
e.recordNavigation && /* @__PURE__ */ Z("div", {
|
|
1811
|
+
className: "flex items-center gap-1 mr-2",
|
|
1812
|
+
children: [
|
|
1813
|
+
/* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1814
|
+
asChild: !0,
|
|
1815
|
+
children: /* @__PURE__ */ X(P, {
|
|
1816
|
+
variant: "outline",
|
|
1817
|
+
size: "icon",
|
|
1818
|
+
className: "h-8 w-8",
|
|
1819
|
+
disabled: e.recordNavigation.currentIndex <= 0,
|
|
1820
|
+
onClick: () => {
|
|
1821
|
+
let t = e.recordNavigation;
|
|
1822
|
+
t.currentIndex > 0 && t.onNavigate(t.recordIds[t.currentIndex - 1]);
|
|
1823
|
+
},
|
|
1824
|
+
children: /* @__PURE__ */ X(te, { className: "h-4 w-4" })
|
|
1825
|
+
})
|
|
1826
|
+
}), /* @__PURE__ */ X(U, { children: E("detail.previousRecord") })] }),
|
|
1827
|
+
/* @__PURE__ */ X("span", {
|
|
1828
|
+
className: "text-xs text-muted-foreground whitespace-nowrap px-1",
|
|
1829
|
+
children: E("detail.recordOf", {
|
|
1830
|
+
current: e.recordNavigation.currentIndex + 1,
|
|
1831
|
+
total: e.recordNavigation.recordIds.length
|
|
1832
|
+
})
|
|
1833
|
+
}),
|
|
1834
|
+
/* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1835
|
+
asChild: !0,
|
|
1836
|
+
children: /* @__PURE__ */ X(P, {
|
|
1837
|
+
variant: "outline",
|
|
1838
|
+
size: "icon",
|
|
1839
|
+
className: "h-8 w-8",
|
|
1840
|
+
disabled: e.recordNavigation.currentIndex >= e.recordNavigation.recordIds.length - 1,
|
|
1841
|
+
onClick: () => {
|
|
1842
|
+
let t = e.recordNavigation;
|
|
1843
|
+
t.currentIndex < t.recordIds.length - 1 && t.onNavigate(t.recordIds[t.currentIndex + 1]);
|
|
1844
|
+
},
|
|
1845
|
+
children: /* @__PURE__ */ X(p, { className: "h-4 w-4" })
|
|
1846
|
+
})
|
|
1847
|
+
}), /* @__PURE__ */ X(U, { children: E("detail.nextRecord") })] })
|
|
1848
|
+
]
|
|
1849
|
+
}),
|
|
1850
|
+
e.actions?.map((e, t) => /* @__PURE__ */ X(oe, {
|
|
1851
|
+
schema: e,
|
|
1852
|
+
data: u
|
|
1853
|
+
}, t)),
|
|
1854
|
+
c && /* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1855
|
+
asChild: !0,
|
|
1856
|
+
children: /* @__PURE__ */ X(P, {
|
|
1857
|
+
variant: y ? "default" : "outline",
|
|
1858
|
+
size: "sm",
|
|
1859
|
+
onClick: R,
|
|
1860
|
+
className: "gap-2 hidden sm:inline-flex",
|
|
1861
|
+
children: y ? /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(F, { className: "h-4 w-4" }), /* @__PURE__ */ X("span", {
|
|
1862
|
+
className: "hidden sm:inline",
|
|
1863
|
+
children: E("detail.save")
|
|
1864
|
+
})] }) : /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(z, { className: "h-4 w-4" }), /* @__PURE__ */ X("span", {
|
|
1865
|
+
className: "hidden sm:inline",
|
|
1866
|
+
children: E("detail.editInline")
|
|
1867
|
+
})] })
|
|
1868
|
+
})
|
|
1869
|
+
}), /* @__PURE__ */ X(U, { children: E(y ? "detail.saveChanges" : "detail.editFieldsInline") })] }),
|
|
1870
|
+
/* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1871
|
+
asChild: !0,
|
|
1872
|
+
children: /* @__PURE__ */ X(P, {
|
|
1873
|
+
variant: "outline",
|
|
1874
|
+
size: "icon",
|
|
1875
|
+
onClick: j,
|
|
1876
|
+
className: "hidden sm:inline-flex",
|
|
1877
|
+
children: /* @__PURE__ */ X(_e, { className: "h-4 w-4" })
|
|
1878
|
+
})
|
|
1879
|
+
}), /* @__PURE__ */ X(U, { children: E("detail.share") })] }),
|
|
1880
|
+
e.showEdit && /* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1881
|
+
asChild: !0,
|
|
1882
|
+
children: /* @__PURE__ */ Z(P, {
|
|
1883
|
+
variant: "default",
|
|
1884
|
+
onClick: O,
|
|
1885
|
+
className: "gap-2 hidden sm:inline-flex",
|
|
1886
|
+
children: [/* @__PURE__ */ X(z, { className: "h-4 w-4" }), /* @__PURE__ */ X("span", {
|
|
1887
|
+
className: "hidden sm:inline",
|
|
1888
|
+
children: E("detail.edit")
|
|
1889
|
+
})]
|
|
1890
|
+
})
|
|
1891
|
+
}), /* @__PURE__ */ X(U, { children: E("detail.editRecord") })] }),
|
|
1892
|
+
/* @__PURE__ */ Z(me, { children: [/* @__PURE__ */ Z(G, { children: [/* @__PURE__ */ X(I, {
|
|
1893
|
+
asChild: !0,
|
|
1894
|
+
children: /* @__PURE__ */ X(v, {
|
|
1895
|
+
asChild: !0,
|
|
1896
|
+
children: /* @__PURE__ */ X(P, {
|
|
1897
|
+
variant: "ghost",
|
|
1898
|
+
size: "icon",
|
|
1899
|
+
children: /* @__PURE__ */ X(w, { className: "h-4 w-4" })
|
|
1900
|
+
})
|
|
1901
|
+
})
|
|
1902
|
+
}), /* @__PURE__ */ X(U, { children: E("detail.moreActions") })] }), /* @__PURE__ */ Z(n, {
|
|
1903
|
+
align: "end",
|
|
1904
|
+
className: "w-[calc(100vw-2rem)] sm:w-48 max-h-[60vh] overflow-y-auto",
|
|
1905
|
+
children: [
|
|
1906
|
+
/* @__PURE__ */ Z(W, {
|
|
1907
|
+
onClick: j,
|
|
1908
|
+
className: "sm:hidden",
|
|
1909
|
+
children: [/* @__PURE__ */ X(_e, { className: "h-4 w-4 mr-2" }), E("detail.share")]
|
|
1910
|
+
}),
|
|
1911
|
+
e.showEdit && /* @__PURE__ */ Z(W, {
|
|
1912
|
+
onClick: O,
|
|
1913
|
+
className: "sm:hidden",
|
|
1914
|
+
children: [/* @__PURE__ */ X(z, { className: "h-4 w-4 mr-2" }), E("detail.edit")]
|
|
1915
|
+
}),
|
|
1916
|
+
c && /* @__PURE__ */ Z(W, {
|
|
1917
|
+
onClick: R,
|
|
1918
|
+
className: "sm:hidden",
|
|
1919
|
+
children: [/* @__PURE__ */ X(z, { className: "h-4 w-4 mr-2" }), E(y ? "detail.save" : "detail.editInline")]
|
|
1920
|
+
}),
|
|
1921
|
+
/* @__PURE__ */ X(g, { className: "sm:hidden" }),
|
|
1922
|
+
/* @__PURE__ */ Z(W, {
|
|
1923
|
+
onClick: M,
|
|
1924
|
+
children: [/* @__PURE__ */ X(A, { className: "h-4 w-4 mr-2" }), E("detail.duplicate")]
|
|
1925
|
+
}),
|
|
1926
|
+
/* @__PURE__ */ Z(W, {
|
|
1927
|
+
onClick: ee,
|
|
1928
|
+
children: [/* @__PURE__ */ X(Re, { className: "h-4 w-4 mr-2" }), E("detail.export")]
|
|
1929
|
+
}),
|
|
1930
|
+
/* @__PURE__ */ Z(W, {
|
|
1931
|
+
onClick: N,
|
|
1932
|
+
children: [/* @__PURE__ */ X(r, { className: "h-4 w-4 mr-2" }), E("detail.viewHistory")]
|
|
1933
|
+
}),
|
|
1934
|
+
e.showDelete && /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(g, {}), /* @__PURE__ */ Z(W, {
|
|
1935
|
+
onClick: k,
|
|
1936
|
+
className: "text-destructive focus:text-destructive",
|
|
1937
|
+
children: [/* @__PURE__ */ X(Ae, { className: "h-4 w-4 mr-2" }), E("detail.delete")]
|
|
1938
|
+
})] })
|
|
1939
|
+
]
|
|
1940
|
+
})] })
|
|
1941
|
+
]
|
|
1942
|
+
})]
|
|
1943
|
+
}),
|
|
1944
|
+
e.header && /* @__PURE__ */ X("div", { children: /* @__PURE__ */ X(oe, {
|
|
1945
|
+
schema: e.header,
|
|
1946
|
+
data: u
|
|
1947
|
+
}) }),
|
|
1948
|
+
e.highlightFields && e.highlightFields.length > 0 && /* @__PURE__ */ X(Ft, {
|
|
1949
|
+
fields: e.highlightFields,
|
|
1950
|
+
data: u,
|
|
1951
|
+
objectName: e.objectName,
|
|
1952
|
+
objectSchema: C
|
|
1953
|
+
}),
|
|
1954
|
+
e.autoTabs && !e.tabs?.length ? /* @__PURE__ */ Z(ye, {
|
|
1955
|
+
defaultValue: "details",
|
|
1956
|
+
className: "w-full",
|
|
1957
|
+
children: [
|
|
1958
|
+
/* @__PURE__ */ Z(ue, {
|
|
1959
|
+
className: "w-full justify-start border-b rounded-none bg-transparent p-0",
|
|
1960
|
+
children: [
|
|
1961
|
+
/* @__PURE__ */ X(L, {
|
|
1962
|
+
value: "details",
|
|
1963
|
+
className: "relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",
|
|
1964
|
+
children: E("detail.details")
|
|
1965
|
+
}),
|
|
1966
|
+
V.length > 0 && /* @__PURE__ */ X(L, {
|
|
1967
|
+
value: "related",
|
|
1968
|
+
className: "relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",
|
|
1969
|
+
children: /* @__PURE__ */ Z("span", {
|
|
1970
|
+
className: "flex items-center gap-1.5",
|
|
1971
|
+
children: [E("detail.related"), /* @__PURE__ */ X(K, {
|
|
1972
|
+
variant: "secondary",
|
|
1973
|
+
className: "text-xs",
|
|
1974
|
+
children: V.length
|
|
1975
|
+
})]
|
|
1976
|
+
})
|
|
1977
|
+
}),
|
|
1978
|
+
e.activities && e.activities.length > 0 && /* @__PURE__ */ X(L, {
|
|
1979
|
+
value: "activity",
|
|
1980
|
+
className: "relative rounded-none border-b-2 border-transparent data-[state=active]:border-primary data-[state=active]:bg-transparent",
|
|
1981
|
+
children: /* @__PURE__ */ Z("span", {
|
|
1982
|
+
className: "flex items-center gap-1.5",
|
|
1983
|
+
children: [E("detail.activity"), /* @__PURE__ */ X(K, {
|
|
1984
|
+
variant: "secondary",
|
|
1985
|
+
className: "text-xs",
|
|
1986
|
+
children: e.activities.length
|
|
1987
|
+
})]
|
|
1988
|
+
})
|
|
1989
|
+
})
|
|
1990
|
+
]
|
|
1991
|
+
}),
|
|
1992
|
+
/* @__PURE__ */ X(Te, {
|
|
1993
|
+
value: "details",
|
|
1994
|
+
className: "mt-4",
|
|
1995
|
+
children: /* @__PURE__ */ Z("div", {
|
|
1996
|
+
className: "space-y-3 sm:space-y-4",
|
|
1997
|
+
children: [
|
|
1998
|
+
e.sectionGroups && e.sectionGroups.length > 0 && e.sectionGroups.map((t, n) => /* @__PURE__ */ X(Pt, {
|
|
1999
|
+
group: t,
|
|
2000
|
+
data: {
|
|
2001
|
+
...u,
|
|
2002
|
+
...x
|
|
2003
|
+
},
|
|
2004
|
+
objectSchema: C,
|
|
2005
|
+
objectName: e.objectName,
|
|
2006
|
+
isEditing: y,
|
|
2007
|
+
onFieldChange: B
|
|
2008
|
+
}, n)),
|
|
2009
|
+
e.sections && e.sections.length > 0 && e.sections.map((t, n) => /* @__PURE__ */ X(jt, {
|
|
2010
|
+
section: t,
|
|
2011
|
+
data: {
|
|
2012
|
+
...u,
|
|
2013
|
+
...x
|
|
2014
|
+
},
|
|
2015
|
+
objectSchema: C,
|
|
2016
|
+
objectName: e.objectName,
|
|
2017
|
+
isEditing: y,
|
|
2018
|
+
onFieldChange: B
|
|
2019
|
+
}, n)),
|
|
2020
|
+
e.fields && e.fields.length > 0 && !e.sections?.length && /* @__PURE__ */ X(jt, {
|
|
2021
|
+
section: {
|
|
2022
|
+
fields: e.fields,
|
|
2023
|
+
columns: e.columns
|
|
2024
|
+
},
|
|
2025
|
+
data: {
|
|
2026
|
+
...u,
|
|
2027
|
+
...x
|
|
2028
|
+
},
|
|
2029
|
+
objectSchema: C,
|
|
2030
|
+
objectName: e.objectName,
|
|
2031
|
+
isEditing: y,
|
|
2032
|
+
onFieldChange: B
|
|
2033
|
+
}),
|
|
2034
|
+
e.comments && /* @__PURE__ */ X(Lt, {
|
|
2035
|
+
comments: e.comments,
|
|
2036
|
+
onAddComment: e.onAddComment
|
|
2037
|
+
})
|
|
2038
|
+
]
|
|
2039
|
+
})
|
|
2040
|
+
}),
|
|
2041
|
+
V.length > 0 && /* @__PURE__ */ X(Te, {
|
|
2042
|
+
value: "related",
|
|
2043
|
+
className: "mt-4",
|
|
2044
|
+
children: /* @__PURE__ */ X("div", {
|
|
2045
|
+
className: "space-y-4",
|
|
2046
|
+
children: V.map((e, n) => /* @__PURE__ */ X(Nt, {
|
|
2047
|
+
title: e.title,
|
|
2048
|
+
type: e.type,
|
|
2049
|
+
api: e.api,
|
|
2050
|
+
data: e.data,
|
|
2051
|
+
columns: e.columns,
|
|
2052
|
+
dataSource: t,
|
|
2053
|
+
objectName: e.api,
|
|
2054
|
+
collapsible: !0,
|
|
2055
|
+
pageSize: Wt
|
|
2056
|
+
}, n))
|
|
2057
|
+
})
|
|
2058
|
+
}),
|
|
2059
|
+
e.activities && e.activities.length > 0 && /* @__PURE__ */ X(Te, {
|
|
2060
|
+
value: "activity",
|
|
2061
|
+
className: "mt-4",
|
|
2062
|
+
children: /* @__PURE__ */ X(Ut, { activities: e.activities })
|
|
2063
|
+
})
|
|
2064
|
+
]
|
|
2065
|
+
}) : /* @__PURE__ */ Z(Y, { children: [
|
|
2066
|
+
e.sectionGroups && e.sectionGroups.length > 0 && /* @__PURE__ */ X("div", {
|
|
2067
|
+
className: "space-y-3 sm:space-y-4",
|
|
2068
|
+
children: e.sectionGroups.map((t, n) => /* @__PURE__ */ X(Pt, {
|
|
2069
|
+
group: t,
|
|
2070
|
+
data: {
|
|
2071
|
+
...u,
|
|
2072
|
+
...x
|
|
2073
|
+
},
|
|
2074
|
+
objectSchema: C,
|
|
2075
|
+
objectName: e.objectName,
|
|
2076
|
+
isEditing: y,
|
|
2077
|
+
onFieldChange: B
|
|
2078
|
+
}, n))
|
|
2079
|
+
}),
|
|
2080
|
+
e.sections && e.sections.length > 0 && /* @__PURE__ */ X("div", {
|
|
2081
|
+
className: "space-y-3 sm:space-y-4",
|
|
2082
|
+
children: e.sections.map((t, n) => /* @__PURE__ */ X(jt, {
|
|
2083
|
+
section: t,
|
|
2084
|
+
data: {
|
|
2085
|
+
...u,
|
|
2086
|
+
...x
|
|
2087
|
+
},
|
|
2088
|
+
objectSchema: C,
|
|
2089
|
+
objectName: e.objectName,
|
|
2090
|
+
isEditing: y,
|
|
2091
|
+
onFieldChange: B
|
|
2092
|
+
}, n))
|
|
2093
|
+
}),
|
|
2094
|
+
e.fields && e.fields.length > 0 && !e.sections?.length && /* @__PURE__ */ X(jt, {
|
|
2095
|
+
section: {
|
|
2096
|
+
fields: e.fields,
|
|
2097
|
+
columns: e.columns
|
|
2098
|
+
},
|
|
2099
|
+
data: {
|
|
2100
|
+
...u,
|
|
2101
|
+
...x
|
|
2102
|
+
},
|
|
2103
|
+
objectSchema: C,
|
|
2104
|
+
objectName: e.objectName,
|
|
2105
|
+
isEditing: y,
|
|
2106
|
+
onFieldChange: B
|
|
2107
|
+
}),
|
|
2108
|
+
e.tabs && e.tabs.length > 0 && /* @__PURE__ */ X(Mt, {
|
|
2109
|
+
tabs: e.tabs,
|
|
2110
|
+
data: u
|
|
2111
|
+
}),
|
|
2112
|
+
V.length > 0 && /* @__PURE__ */ Z("div", {
|
|
2113
|
+
className: "space-y-4",
|
|
2114
|
+
children: [/* @__PURE__ */ X("h2", {
|
|
2115
|
+
className: "text-xl font-semibold",
|
|
2116
|
+
children: E("detail.related")
|
|
2117
|
+
}), V.map((e, n) => /* @__PURE__ */ X(Nt, {
|
|
2118
|
+
title: e.title,
|
|
2119
|
+
type: e.type,
|
|
2120
|
+
api: e.api,
|
|
2121
|
+
data: e.data,
|
|
2122
|
+
columns: e.columns,
|
|
2123
|
+
dataSource: t,
|
|
2124
|
+
objectName: e.api,
|
|
2125
|
+
collapsible: !0,
|
|
2126
|
+
pageSize: Wt
|
|
2127
|
+
}, n))]
|
|
2128
|
+
}),
|
|
2129
|
+
e.comments && /* @__PURE__ */ X(Lt, {
|
|
2130
|
+
comments: e.comments,
|
|
2131
|
+
onAddComment: e.onAddComment
|
|
2132
|
+
}),
|
|
2133
|
+
e.activities && e.activities.length > 0 && /* @__PURE__ */ X(Ut, { activities: e.activities })
|
|
2134
|
+
] }),
|
|
2135
|
+
e.footer && /* @__PURE__ */ X("div", { children: /* @__PURE__ */ X(oe, {
|
|
2136
|
+
schema: e.footer,
|
|
2137
|
+
data: u
|
|
2138
|
+
}) })
|
|
2139
|
+
]
|
|
2140
|
+
}) });
|
|
2141
|
+
}, Kt = ({ objectName: t, relationshipField: n, fields: r, onCreateRecord: i, onLinkRecord: s, onSearch: l, existingRecords: u = [], className: d }) => {
|
|
2142
|
+
let [f, p] = J.useState(!1), [h, g] = J.useState("create"), [_, v] = J.useState({}), [y, b] = J.useState(""), [x, S] = J.useState(u), [C, w] = J.useState(!1), [T, O] = J.useState(!1), k = J.useMemo(() => {
|
|
2143
|
+
if (!y.trim()) return x;
|
|
2144
|
+
let e = y.toLowerCase();
|
|
2145
|
+
return x.filter((t) => t.label.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
|
|
2146
|
+
}, [y, x]), A = J.useCallback(async (e) => {
|
|
2147
|
+
if (b(e), l && e.trim().length >= 2) {
|
|
2148
|
+
O(!0);
|
|
2149
|
+
try {
|
|
2150
|
+
S(await l(e));
|
|
2151
|
+
} finally {
|
|
2152
|
+
O(!1);
|
|
2153
|
+
}
|
|
2154
|
+
}
|
|
2155
|
+
}, [l]), M = J.useCallback((e, t) => {
|
|
2156
|
+
v((n) => ({
|
|
2157
|
+
...n,
|
|
2158
|
+
[e]: t
|
|
2159
|
+
}));
|
|
2160
|
+
}, []), ee = J.useCallback(async () => {
|
|
2161
|
+
if (i) {
|
|
2162
|
+
w(!0);
|
|
2163
|
+
try {
|
|
2164
|
+
await i({
|
|
2165
|
+
..._,
|
|
2166
|
+
[n]: !0
|
|
2167
|
+
}), v({}), p(!1);
|
|
2168
|
+
} finally {
|
|
2169
|
+
w(!1);
|
|
2170
|
+
}
|
|
2171
|
+
}
|
|
2172
|
+
}, [
|
|
2173
|
+
i,
|
|
2174
|
+
_,
|
|
2175
|
+
n
|
|
2176
|
+
]), N = J.useCallback(async (e) => {
|
|
2177
|
+
if (s) {
|
|
2178
|
+
w(!0);
|
|
2179
|
+
try {
|
|
2180
|
+
await s(e), b(""), p(!1);
|
|
2181
|
+
} finally {
|
|
2182
|
+
w(!1);
|
|
2183
|
+
}
|
|
2184
|
+
}
|
|
2185
|
+
}, [s]), te = J.useMemo(() => r.filter((e) => e.required).every((e) => _[e.name]?.toString().trim()), [r, _]);
|
|
2186
|
+
return f ? /* @__PURE__ */ Z(D, {
|
|
2187
|
+
className: q("", d),
|
|
2188
|
+
children: [/* @__PURE__ */ X(c, {
|
|
2189
|
+
className: "pb-3",
|
|
2190
|
+
children: /* @__PURE__ */ Z(m, {
|
|
2191
|
+
className: "flex items-center justify-between text-sm",
|
|
2192
|
+
children: [/* @__PURE__ */ Z("span", { children: [
|
|
2193
|
+
h === "create" ? "Create" : "Link",
|
|
2194
|
+
" ",
|
|
2195
|
+
t
|
|
2196
|
+
] }), /* @__PURE__ */ X(P, {
|
|
2197
|
+
variant: "ghost",
|
|
2198
|
+
size: "icon",
|
|
2199
|
+
className: "h-6 w-6",
|
|
2200
|
+
onClick: () => p(!1),
|
|
2201
|
+
children: /* @__PURE__ */ X(e, { className: "h-3.5 w-3.5" })
|
|
2202
|
+
})]
|
|
2203
|
+
})
|
|
2204
|
+
}), /* @__PURE__ */ X(j, { children: /* @__PURE__ */ Z(ye, {
|
|
2205
|
+
value: h,
|
|
2206
|
+
onValueChange: g,
|
|
2207
|
+
children: [
|
|
2208
|
+
/* @__PURE__ */ Z(ue, {
|
|
2209
|
+
className: "mb-3 w-full",
|
|
2210
|
+
children: [i && /* @__PURE__ */ Z(L, {
|
|
2211
|
+
value: "create",
|
|
2212
|
+
className: "flex-1 gap-1.5",
|
|
2213
|
+
children: [/* @__PURE__ */ X(le, { className: "h-3.5 w-3.5" }), "Create New"]
|
|
2214
|
+
}), s && /* @__PURE__ */ Z(L, {
|
|
2215
|
+
value: "link",
|
|
2216
|
+
className: "flex-1 gap-1.5",
|
|
2217
|
+
children: [/* @__PURE__ */ X(o, { className: "h-3.5 w-3.5" }), "Link Existing"]
|
|
2218
|
+
})]
|
|
2219
|
+
}),
|
|
2220
|
+
i && /* @__PURE__ */ Z(Te, {
|
|
2221
|
+
value: "create",
|
|
2222
|
+
className: "space-y-3 mt-0",
|
|
2223
|
+
children: [r.map((e) => /* @__PURE__ */ Z("div", { children: [/* @__PURE__ */ Z("label", {
|
|
2224
|
+
className: "text-xs font-medium text-muted-foreground mb-1 block",
|
|
2225
|
+
children: [e.label, e.required && /* @__PURE__ */ X("span", {
|
|
2226
|
+
className: "text-destructive ml-0.5",
|
|
2227
|
+
children: "*"
|
|
2228
|
+
})]
|
|
2229
|
+
}), /* @__PURE__ */ X(a, {
|
|
2230
|
+
type: e.type === "number" ? "number" : e.type === "date" ? "date" : "text",
|
|
2231
|
+
placeholder: e.placeholder || `Enter ${e.label.toLowerCase()}`,
|
|
2232
|
+
value: _[e.name] || "",
|
|
2233
|
+
onChange: (t) => M(e.name, t.target.value),
|
|
2234
|
+
className: "h-8 text-sm"
|
|
2235
|
+
})] }, e.name)), /* @__PURE__ */ Z("div", {
|
|
2236
|
+
className: "flex justify-end gap-2 pt-1",
|
|
2237
|
+
children: [/* @__PURE__ */ X(P, {
|
|
2238
|
+
variant: "ghost",
|
|
2239
|
+
size: "sm",
|
|
2240
|
+
onClick: () => p(!1),
|
|
2241
|
+
children: "Cancel"
|
|
2242
|
+
}), /* @__PURE__ */ Z(P, {
|
|
2243
|
+
size: "sm",
|
|
2244
|
+
onClick: ee,
|
|
2245
|
+
disabled: !te || C,
|
|
2246
|
+
className: "gap-1.5",
|
|
2247
|
+
children: [C && /* @__PURE__ */ X(E, { className: "h-3.5 w-3.5 animate-spin" }), "Create"]
|
|
2248
|
+
})]
|
|
2249
|
+
})]
|
|
2250
|
+
}),
|
|
2251
|
+
s && /* @__PURE__ */ Z(Te, {
|
|
2252
|
+
value: "link",
|
|
2253
|
+
className: "space-y-3 mt-0",
|
|
2254
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
2255
|
+
className: "relative",
|
|
2256
|
+
children: [/* @__PURE__ */ X(V, { className: "absolute left-2.5 top-1/2 -translate-y-1/2 h-3.5 w-3.5 text-muted-foreground" }), /* @__PURE__ */ X(a, {
|
|
2257
|
+
placeholder: `Search ${t}…`,
|
|
2258
|
+
value: y,
|
|
2259
|
+
onChange: (e) => A(e.target.value),
|
|
2260
|
+
className: "h-8 text-sm pl-8"
|
|
2261
|
+
})]
|
|
2262
|
+
}), /* @__PURE__ */ X("div", {
|
|
2263
|
+
className: "max-h-48 overflow-y-auto space-y-1",
|
|
2264
|
+
children: T ? /* @__PURE__ */ Z("div", {
|
|
2265
|
+
className: "flex items-center justify-center py-4 text-sm text-muted-foreground",
|
|
2266
|
+
children: [/* @__PURE__ */ X(E, { className: "h-4 w-4 animate-spin mr-2" }), "Searching…"]
|
|
2267
|
+
}) : k.length === 0 ? /* @__PURE__ */ X("p", {
|
|
2268
|
+
className: "text-sm text-muted-foreground text-center py-4",
|
|
2269
|
+
children: y ? "No records found" : "Type to search records"
|
|
2270
|
+
}) : k.map((e) => /* @__PURE__ */ Z("button", {
|
|
2271
|
+
type: "button",
|
|
2272
|
+
className: "w-full text-left px-3 py-2 rounded-md hover:bg-accent text-sm transition-colors",
|
|
2273
|
+
onClick: () => N(e.id),
|
|
2274
|
+
disabled: C,
|
|
2275
|
+
children: [/* @__PURE__ */ X("span", {
|
|
2276
|
+
className: "font-medium",
|
|
2277
|
+
children: e.label
|
|
2278
|
+
}), e.description && /* @__PURE__ */ X("span", {
|
|
2279
|
+
className: "block text-xs text-muted-foreground mt-0.5",
|
|
2280
|
+
children: e.description
|
|
2281
|
+
})]
|
|
2282
|
+
}, e.id))
|
|
2283
|
+
})]
|
|
2284
|
+
})
|
|
2285
|
+
]
|
|
2286
|
+
}) })]
|
|
2287
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
2288
|
+
className: q("flex gap-2", d),
|
|
2289
|
+
children: [i && /* @__PURE__ */ Z(P, {
|
|
2290
|
+
variant: "outline",
|
|
2291
|
+
size: "sm",
|
|
2292
|
+
onClick: () => {
|
|
2293
|
+
g("create"), p(!0);
|
|
2294
|
+
},
|
|
2295
|
+
className: "gap-1.5",
|
|
2296
|
+
children: [
|
|
2297
|
+
/* @__PURE__ */ X(le, { className: "h-3.5 w-3.5" }),
|
|
2298
|
+
"New ",
|
|
2299
|
+
t
|
|
2300
|
+
]
|
|
2301
|
+
}), s && /* @__PURE__ */ Z(P, {
|
|
2302
|
+
variant: "outline",
|
|
2303
|
+
size: "sm",
|
|
2304
|
+
onClick: () => {
|
|
2305
|
+
g("link"), p(!0);
|
|
2306
|
+
},
|
|
2307
|
+
className: "gap-1.5",
|
|
2308
|
+
children: [/* @__PURE__ */ X(o, { className: "h-3.5 w-3.5" }), "Link Existing"]
|
|
2309
|
+
})]
|
|
2310
|
+
});
|
|
2311
|
+
};
|
|
2312
|
+
//#endregion
|
|
2313
|
+
//#region src/RichTextCommentInput.tsx
|
|
2314
|
+
function qt(e) {
|
|
2315
|
+
let t = e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/```([\s\S]*?)```/g, "<pre class=\"bg-muted rounded p-2 text-xs font-mono my-1 overflow-x-auto\">$1</pre>").replace(/`([^`]+)`/g, "<code class=\"bg-muted rounded px-1 py-0.5 text-xs font-mono\">$1</code>").replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/\*(.+?)\*/g, "<em>$1</em>").replace(/@(\w+)/g, "<span class=\"text-primary font-medium\">@$1</span>").replace(/^- (.+)$/gm, "<li class=\"ml-4 list-disc\">$1</li>").replace(/\n/g, "<br/>");
|
|
2316
|
+
return t = t.replace(/(<li[^>]*>.*?<\/li>(?:<br\/>)?)+/g, (e) => `<ul class="my-1">${e.replace(/<br\/>/g, "")}</ul>`), t;
|
|
2317
|
+
}
|
|
2318
|
+
var Jt = ({ value: e, onChange: n, onSubmit: r, mentionSuggestions: i = [], placeholder: a = "Write a comment…", className: o, disabled: c = !1 }) => {
|
|
2319
|
+
let [l, u] = J.useState(!1), [d, f] = J.useState(!1), [p, m] = J.useState(""), [h, g] = J.useState(0), _ = J.useRef(null), v = J.useMemo(() => {
|
|
2320
|
+
if (!p) return i;
|
|
2321
|
+
let e = p.toLowerCase();
|
|
2322
|
+
return i.filter((t) => t.label.toLowerCase().includes(e));
|
|
2323
|
+
}, [p, i]), y = J.useCallback((t, r = "") => {
|
|
2324
|
+
let i = _.current;
|
|
2325
|
+
if (!i) return;
|
|
2326
|
+
let a = i.selectionStart, o = i.selectionEnd, s = e.slice(a, o);
|
|
2327
|
+
n(e.slice(0, a) + t + s + r + e.slice(o)), requestAnimationFrame(() => {
|
|
2328
|
+
i.focus();
|
|
2329
|
+
let e = a + t.length + s.length;
|
|
2330
|
+
i.setSelectionRange(e, e);
|
|
2331
|
+
});
|
|
2332
|
+
}, [e, n]), S = J.useCallback(() => y("**", "**"), [y]), C = J.useCallback(() => y("*", "*"), [y]), w = J.useCallback(() => y("\n- ", ""), [y]), T = J.useCallback(() => y("`", "`"), [y]), E = J.useCallback(() => {
|
|
2333
|
+
y("@", ""), f(!0), m(""), g(0);
|
|
2334
|
+
}, [y]), D = J.useCallback((t) => {
|
|
2335
|
+
let r = _.current;
|
|
2336
|
+
if (!r) return;
|
|
2337
|
+
let i = r.selectionStart, a = e.slice(0, i).lastIndexOf("@");
|
|
2338
|
+
a !== -1 && n(e.slice(0, a) + `@${t.label} ` + e.slice(i)), f(!1), m(""), requestAnimationFrame(() => r.focus());
|
|
2339
|
+
}, [e, n]), k = J.useCallback((e) => {
|
|
2340
|
+
let t = e.target.value;
|
|
2341
|
+
n(t);
|
|
2342
|
+
let r = e.target.selectionStart, i = t.slice(0, r), a = i.lastIndexOf("@");
|
|
2343
|
+
if (a !== -1) {
|
|
2344
|
+
let e = i.slice(a + 1), t = a > 0 ? i[a - 1] : " ";
|
|
2345
|
+
if (/\s/.test(t) && !/\s/.test(e)) {
|
|
2346
|
+
f(!0), m(e), g(0);
|
|
2347
|
+
return;
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
f(!1);
|
|
2351
|
+
}, [n]), A = J.useCallback((e) => {
|
|
2352
|
+
if (d && v.length > 0) {
|
|
2353
|
+
if (e.key === "ArrowDown") {
|
|
2354
|
+
e.preventDefault(), g((e) => e < v.length - 1 ? e + 1 : 0);
|
|
2355
|
+
return;
|
|
2356
|
+
}
|
|
2357
|
+
if (e.key === "ArrowUp") {
|
|
2358
|
+
e.preventDefault(), g((e) => e > 0 ? e - 1 : v.length - 1);
|
|
2359
|
+
return;
|
|
2360
|
+
}
|
|
2361
|
+
if (e.key === "Enter" || e.key === "Tab") {
|
|
2362
|
+
e.preventDefault(), D(v[h]);
|
|
2363
|
+
return;
|
|
2364
|
+
}
|
|
2365
|
+
if (e.key === "Escape") {
|
|
2366
|
+
f(!1);
|
|
2367
|
+
return;
|
|
2368
|
+
}
|
|
2369
|
+
}
|
|
2370
|
+
e.key === "Enter" && (e.ctrlKey || e.metaKey) && (e.preventDefault(), r?.());
|
|
2371
|
+
}, [
|
|
2372
|
+
d,
|
|
2373
|
+
v,
|
|
2374
|
+
h,
|
|
2375
|
+
D,
|
|
2376
|
+
r
|
|
2377
|
+
]);
|
|
2378
|
+
return /* @__PURE__ */ Z("div", {
|
|
2379
|
+
className: q("border rounded-md", o),
|
|
2380
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
2381
|
+
className: "flex items-center gap-0.5 px-2 py-1.5 border-b bg-muted/30",
|
|
2382
|
+
children: [
|
|
2383
|
+
/* @__PURE__ */ X(P, {
|
|
2384
|
+
variant: "ghost",
|
|
2385
|
+
size: "icon",
|
|
2386
|
+
className: "h-7 w-7",
|
|
2387
|
+
onClick: S,
|
|
2388
|
+
disabled: c || l,
|
|
2389
|
+
title: "Bold (Ctrl+B)",
|
|
2390
|
+
children: /* @__PURE__ */ X(t, { className: "h-3.5 w-3.5" })
|
|
2391
|
+
}),
|
|
2392
|
+
/* @__PURE__ */ X(P, {
|
|
2393
|
+
variant: "ghost",
|
|
2394
|
+
size: "icon",
|
|
2395
|
+
className: "h-7 w-7",
|
|
2396
|
+
onClick: C,
|
|
2397
|
+
disabled: c || l,
|
|
2398
|
+
title: "Italic (Ctrl+I)",
|
|
2399
|
+
children: /* @__PURE__ */ X(b, { className: "h-3.5 w-3.5" })
|
|
2400
|
+
}),
|
|
2401
|
+
/* @__PURE__ */ X(P, {
|
|
2402
|
+
variant: "ghost",
|
|
2403
|
+
size: "icon",
|
|
2404
|
+
className: "h-7 w-7",
|
|
2405
|
+
onClick: w,
|
|
2406
|
+
disabled: c || l,
|
|
2407
|
+
title: "List",
|
|
2408
|
+
children: /* @__PURE__ */ X(s, { className: "h-3.5 w-3.5" })
|
|
2409
|
+
}),
|
|
2410
|
+
/* @__PURE__ */ X(P, {
|
|
2411
|
+
variant: "ghost",
|
|
2412
|
+
size: "icon",
|
|
2413
|
+
className: "h-7 w-7",
|
|
2414
|
+
onClick: T,
|
|
2415
|
+
disabled: c || l,
|
|
2416
|
+
title: "Inline code",
|
|
2417
|
+
children: /* @__PURE__ */ X(O, { className: "h-3.5 w-3.5" })
|
|
2418
|
+
}),
|
|
2419
|
+
/* @__PURE__ */ X(P, {
|
|
2420
|
+
variant: "ghost",
|
|
2421
|
+
size: "icon",
|
|
2422
|
+
className: "h-7 w-7",
|
|
2423
|
+
onClick: E,
|
|
2424
|
+
disabled: c || l,
|
|
2425
|
+
title: "Mention someone",
|
|
2426
|
+
children: /* @__PURE__ */ X(be, { className: "h-3.5 w-3.5" })
|
|
2427
|
+
}),
|
|
2428
|
+
/* @__PURE__ */ X("div", { className: "flex-1" }),
|
|
2429
|
+
/* @__PURE__ */ X(P, {
|
|
2430
|
+
variant: "ghost",
|
|
2431
|
+
size: "icon",
|
|
2432
|
+
className: "h-7 w-7",
|
|
2433
|
+
onClick: () => u(!l),
|
|
2434
|
+
title: l ? "Edit" : "Preview",
|
|
2435
|
+
children: X(l ? z : x, { className: "h-3.5 w-3.5" })
|
|
2436
|
+
}),
|
|
2437
|
+
r && /* @__PURE__ */ X(P, {
|
|
2438
|
+
variant: "ghost",
|
|
2439
|
+
size: "icon",
|
|
2440
|
+
className: "h-7 w-7",
|
|
2441
|
+
onClick: r,
|
|
2442
|
+
disabled: c || !e.trim(),
|
|
2443
|
+
title: "Submit (Ctrl+Enter)",
|
|
2444
|
+
children: /* @__PURE__ */ X(je, { className: "h-3.5 w-3.5" })
|
|
2445
|
+
})
|
|
2446
|
+
]
|
|
2447
|
+
}), /* @__PURE__ */ X("div", {
|
|
2448
|
+
className: "relative",
|
|
2449
|
+
children: l ? /* @__PURE__ */ X("div", {
|
|
2450
|
+
className: "min-h-[80px] px-3 py-2 text-sm prose prose-sm max-w-none",
|
|
2451
|
+
dangerouslySetInnerHTML: { __html: qt(e) }
|
|
2452
|
+
}) : /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X("textarea", {
|
|
2453
|
+
ref: _,
|
|
2454
|
+
className: "w-full min-h-[80px] px-3 py-2 text-sm bg-transparent resize-none focus:outline-none placeholder:text-muted-foreground",
|
|
2455
|
+
placeholder: a,
|
|
2456
|
+
value: e,
|
|
2457
|
+
onChange: k,
|
|
2458
|
+
onKeyDown: A,
|
|
2459
|
+
disabled: c
|
|
2460
|
+
}), d && v.length > 0 && /* @__PURE__ */ X("div", {
|
|
2461
|
+
className: "absolute left-2 bottom-full mb-1 w-56 bg-popover border rounded-md shadow-md z-50 max-h-40 overflow-y-auto",
|
|
2462
|
+
children: v.map((e, t) => /* @__PURE__ */ Z("button", {
|
|
2463
|
+
type: "button",
|
|
2464
|
+
className: q("w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors", t === h && "bg-accent"),
|
|
2465
|
+
onMouseDown: (t) => {
|
|
2466
|
+
t.preventDefault(), D(e);
|
|
2467
|
+
},
|
|
2468
|
+
children: [e.avatarUrl ? /* @__PURE__ */ X("img", {
|
|
2469
|
+
src: e.avatarUrl,
|
|
2470
|
+
alt: e.label,
|
|
2471
|
+
className: "h-5 w-5 rounded-full object-cover"
|
|
2472
|
+
}) : /* @__PURE__ */ X("div", {
|
|
2473
|
+
className: "h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium",
|
|
2474
|
+
children: e.label.charAt(0).toUpperCase()
|
|
2475
|
+
}), /* @__PURE__ */ X("span", { children: e.label })]
|
|
2476
|
+
}, e.id))
|
|
2477
|
+
})] })
|
|
2478
|
+
})]
|
|
2479
|
+
});
|
|
2480
|
+
};
|
|
2481
|
+
//#endregion
|
|
2482
|
+
//#region src/DiffView.tsx
|
|
2483
|
+
function Yt(e, t) {
|
|
2484
|
+
if (e == null) return ["(empty)"];
|
|
2485
|
+
switch (t) {
|
|
2486
|
+
case "json": try {
|
|
2487
|
+
let t = typeof e == "string" ? JSON.parse(e) : e;
|
|
2488
|
+
return JSON.stringify(t, null, 2).split("\n");
|
|
2489
|
+
} catch {
|
|
2490
|
+
return String(e).split("\n");
|
|
2491
|
+
}
|
|
2492
|
+
case "boolean": return [String(!!e)];
|
|
2493
|
+
case "number": return [String(e)];
|
|
2494
|
+
case "date": try {
|
|
2495
|
+
return [new Date(e).toLocaleString()];
|
|
2496
|
+
} catch {
|
|
2497
|
+
return [String(e)];
|
|
2498
|
+
}
|
|
2499
|
+
default: return String(e).split("\n");
|
|
2500
|
+
}
|
|
2501
|
+
}
|
|
2502
|
+
function Xt(e, t) {
|
|
2503
|
+
let n = [], r = Math.max(e.length, t.length);
|
|
2504
|
+
for (let i = 0; i < r; i++) {
|
|
2505
|
+
let r = i < e.length ? e[i] : void 0, a = i < t.length ? t[i] : void 0;
|
|
2506
|
+
r === a ? n.push({
|
|
2507
|
+
type: "unchanged",
|
|
2508
|
+
value: r
|
|
2509
|
+
}) : (r !== void 0 && n.push({
|
|
2510
|
+
type: "removed",
|
|
2511
|
+
value: r
|
|
2512
|
+
}), a !== void 0 && n.push({
|
|
2513
|
+
type: "added",
|
|
2514
|
+
value: a
|
|
2515
|
+
}));
|
|
2516
|
+
}
|
|
2517
|
+
return n;
|
|
2518
|
+
}
|
|
2519
|
+
var Zt = {
|
|
2520
|
+
added: "bg-green-50 text-green-800 dark:bg-green-950/30 dark:text-green-300",
|
|
2521
|
+
removed: "bg-red-50 text-red-800 dark:bg-red-950/30 dark:text-red-300",
|
|
2522
|
+
unchanged: "text-muted-foreground"
|
|
2523
|
+
}, Qt = {
|
|
2524
|
+
added: "+",
|
|
2525
|
+
removed: "-",
|
|
2526
|
+
unchanged: " "
|
|
2527
|
+
}, $t = ({ oldValue: e, newValue: t, fieldName: n, fieldType: r = "string", mode: i = "unified", className: a }) => {
|
|
2528
|
+
let [o, s] = J.useState(i), l = J.useMemo(() => Yt(e, r), [e, r]), d = J.useMemo(() => Yt(t, r), [t, r]), f = J.useMemo(() => Xt(l, d), [l, d]), p = f.some((e) => e.type !== "unchanged"), h = J.useMemo(() => {
|
|
2529
|
+
if (o !== "side-by-side") return [];
|
|
2530
|
+
let e = [], t = 0;
|
|
2531
|
+
for (; t < f.length;) {
|
|
2532
|
+
let n = f[t];
|
|
2533
|
+
if (n.type === "unchanged") e.push({
|
|
2534
|
+
left: n,
|
|
2535
|
+
right: n
|
|
2536
|
+
}), t++;
|
|
2537
|
+
else if (n.type === "removed") {
|
|
2538
|
+
let r = t + 1 < f.length ? f[t + 1] : null;
|
|
2539
|
+
r && r.type === "added" ? (e.push({
|
|
2540
|
+
left: n,
|
|
2541
|
+
right: r
|
|
2542
|
+
}), t += 2) : (e.push({
|
|
2543
|
+
left: n,
|
|
2544
|
+
right: null
|
|
2545
|
+
}), t++);
|
|
2546
|
+
} else e.push({
|
|
2547
|
+
left: null,
|
|
2548
|
+
right: n
|
|
2549
|
+
}), t++;
|
|
2550
|
+
}
|
|
2551
|
+
return e;
|
|
2552
|
+
}, [o, f]);
|
|
2553
|
+
return /* @__PURE__ */ Z(D, {
|
|
2554
|
+
className: q("overflow-hidden", a),
|
|
2555
|
+
children: [/* @__PURE__ */ X(c, {
|
|
2556
|
+
className: "pb-2",
|
|
2557
|
+
children: /* @__PURE__ */ Z(m, {
|
|
2558
|
+
className: "flex items-center justify-between text-sm",
|
|
2559
|
+
children: [/* @__PURE__ */ X("span", {
|
|
2560
|
+
className: "font-medium",
|
|
2561
|
+
children: n
|
|
2562
|
+
}), /* @__PURE__ */ Z("div", {
|
|
2563
|
+
className: "flex items-center gap-1",
|
|
2564
|
+
children: [/* @__PURE__ */ X(P, {
|
|
2565
|
+
variant: o === "unified" ? "secondary" : "ghost",
|
|
2566
|
+
size: "icon",
|
|
2567
|
+
className: "h-7 w-7",
|
|
2568
|
+
onClick: () => s("unified"),
|
|
2569
|
+
title: "Unified diff",
|
|
2570
|
+
children: /* @__PURE__ */ X(se, { className: "h-3.5 w-3.5" })
|
|
2571
|
+
}), /* @__PURE__ */ X(P, {
|
|
2572
|
+
variant: o === "side-by-side" ? "secondary" : "ghost",
|
|
2573
|
+
size: "icon",
|
|
2574
|
+
className: "h-7 w-7",
|
|
2575
|
+
onClick: () => s("side-by-side"),
|
|
2576
|
+
title: "Side-by-side diff",
|
|
2577
|
+
children: /* @__PURE__ */ X(u, { className: "h-3.5 w-3.5" })
|
|
2578
|
+
})]
|
|
2579
|
+
})]
|
|
2580
|
+
})
|
|
2581
|
+
}), /* @__PURE__ */ X(j, {
|
|
2582
|
+
className: "p-0",
|
|
2583
|
+
children: p ? o === "unified" ? /* @__PURE__ */ X("div", {
|
|
2584
|
+
className: "font-mono text-xs overflow-x-auto",
|
|
2585
|
+
children: f.map((e, t) => /* @__PURE__ */ Z("div", {
|
|
2586
|
+
className: q("px-4 py-0.5 whitespace-pre-wrap border-l-2", Zt[e.type], e.type === "added" && "border-l-green-500", e.type === "removed" && "border-l-red-500", e.type === "unchanged" && "border-l-transparent"),
|
|
2587
|
+
children: [/* @__PURE__ */ X("span", {
|
|
2588
|
+
className: "select-none mr-2 inline-block w-3 text-center opacity-60",
|
|
2589
|
+
children: Qt[e.type]
|
|
2590
|
+
}), e.value]
|
|
2591
|
+
}, t))
|
|
2592
|
+
}) : /* @__PURE__ */ X("div", {
|
|
2593
|
+
className: "overflow-x-auto",
|
|
2594
|
+
children: /* @__PURE__ */ Z("div", {
|
|
2595
|
+
className: "grid grid-cols-2 divide-x font-mono text-xs min-w-0",
|
|
2596
|
+
children: [
|
|
2597
|
+
/* @__PURE__ */ X("div", {
|
|
2598
|
+
className: "px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50",
|
|
2599
|
+
children: "Previous"
|
|
2600
|
+
}),
|
|
2601
|
+
/* @__PURE__ */ X("div", {
|
|
2602
|
+
className: "px-3 py-1.5 text-xs font-medium text-muted-foreground bg-muted/50",
|
|
2603
|
+
children: "Current"
|
|
2604
|
+
}),
|
|
2605
|
+
h.map((e, t) => /* @__PURE__ */ Z(J.Fragment, { children: [/* @__PURE__ */ X("div", {
|
|
2606
|
+
className: q("px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]", e.left ? Zt[e.left.type] : "bg-muted/20"),
|
|
2607
|
+
children: e.left?.value ?? ""
|
|
2608
|
+
}), /* @__PURE__ */ X("div", {
|
|
2609
|
+
className: q("px-3 py-0.5 whitespace-pre-wrap min-h-[1.5em]", e.right ? Zt[e.right.type] : "bg-muted/20"),
|
|
2610
|
+
children: e.right?.value ?? ""
|
|
2611
|
+
})] }, t))
|
|
2612
|
+
]
|
|
2613
|
+
})
|
|
2614
|
+
}) : /* @__PURE__ */ X("p", {
|
|
2615
|
+
className: "px-4 py-3 text-sm text-muted-foreground",
|
|
2616
|
+
children: "No changes"
|
|
2617
|
+
})
|
|
2618
|
+
})]
|
|
2619
|
+
});
|
|
2620
|
+
}, en = ({ currentIndex: e, totalRecords: t, recordIds: n, onNavigate: r, onSearch: i, className: o }) => {
|
|
2621
|
+
let [s, c] = J.useState(""), [l, u] = J.useState(!1), d = J.useRef(null), f = e > 0, m = e > 0, g = e < t - 1, _ = e < t - 1, v = J.useCallback(() => {
|
|
2622
|
+
f && r(n[0]);
|
|
2623
|
+
}, [
|
|
2624
|
+
f,
|
|
2625
|
+
r,
|
|
2626
|
+
n
|
|
2627
|
+
]), y = J.useCallback(() => {
|
|
2628
|
+
m && r(n[e - 1]);
|
|
2629
|
+
}, [
|
|
2630
|
+
m,
|
|
2631
|
+
r,
|
|
2632
|
+
n,
|
|
2633
|
+
e
|
|
2634
|
+
]), b = J.useCallback(() => {
|
|
2635
|
+
g && r(n[e + 1]);
|
|
2636
|
+
}, [
|
|
2637
|
+
g,
|
|
2638
|
+
r,
|
|
2639
|
+
n,
|
|
2640
|
+
e
|
|
2641
|
+
]), x = J.useCallback(() => {
|
|
2642
|
+
_ && r(n[n.length - 1]);
|
|
2643
|
+
}, [
|
|
2644
|
+
_,
|
|
2645
|
+
r,
|
|
2646
|
+
n
|
|
2647
|
+
]), S = J.useCallback((e) => {
|
|
2648
|
+
let t = e.target.value;
|
|
2649
|
+
c(t), i?.(t);
|
|
2650
|
+
}, [i]), C = J.useCallback(() => {
|
|
2651
|
+
u((e) => (e ? (c(""), i?.("")) : requestAnimationFrame(() => d.current?.focus()), !e));
|
|
2652
|
+
}, [i]);
|
|
2653
|
+
return J.useEffect(() => {
|
|
2654
|
+
let t = (t) => {
|
|
2655
|
+
let a = t.target?.tagName;
|
|
2656
|
+
if (!((a === "INPUT" || a === "TEXTAREA" || t.target?.isContentEditable) && t.target !== d.current)) {
|
|
2657
|
+
if (t.target === d.current) {
|
|
2658
|
+
t.key === "Escape" && (t.preventDefault(), u(!1), c(""), i?.(""), t.target.blur());
|
|
2659
|
+
return;
|
|
2660
|
+
}
|
|
2661
|
+
switch (t.key) {
|
|
2662
|
+
case "Home":
|
|
2663
|
+
t.preventDefault(), f && r(n[0]);
|
|
2664
|
+
break;
|
|
2665
|
+
case "End":
|
|
2666
|
+
t.preventDefault(), _ && r(n[n.length - 1]);
|
|
2667
|
+
break;
|
|
2668
|
+
case "ArrowLeft":
|
|
2669
|
+
t.preventDefault(), m && r(n[e - 1]);
|
|
2670
|
+
break;
|
|
2671
|
+
case "ArrowRight":
|
|
2672
|
+
t.preventDefault(), g && r(n[e + 1]);
|
|
2673
|
+
break;
|
|
2674
|
+
}
|
|
2675
|
+
}
|
|
2676
|
+
};
|
|
2677
|
+
return document.addEventListener("keydown", t), () => document.removeEventListener("keydown", t);
|
|
2678
|
+
}, [
|
|
2679
|
+
e,
|
|
2680
|
+
n,
|
|
2681
|
+
f,
|
|
2682
|
+
m,
|
|
2683
|
+
g,
|
|
2684
|
+
_,
|
|
2685
|
+
r,
|
|
2686
|
+
i
|
|
2687
|
+
]), /* @__PURE__ */ Z("div", {
|
|
2688
|
+
className: q("flex items-center gap-1.5", o),
|
|
2689
|
+
children: [
|
|
2690
|
+
/* @__PURE__ */ X(P, {
|
|
2691
|
+
variant: "outline",
|
|
2692
|
+
size: "icon",
|
|
2693
|
+
className: "h-8 w-8",
|
|
2694
|
+
disabled: !f,
|
|
2695
|
+
onClick: v,
|
|
2696
|
+
title: "First record (Home)",
|
|
2697
|
+
children: /* @__PURE__ */ X(we, { className: "h-4 w-4" })
|
|
2698
|
+
}),
|
|
2699
|
+
/* @__PURE__ */ X(P, {
|
|
2700
|
+
variant: "outline",
|
|
2701
|
+
size: "icon",
|
|
2702
|
+
className: "h-8 w-8",
|
|
2703
|
+
disabled: !m,
|
|
2704
|
+
onClick: y,
|
|
2705
|
+
title: "Previous record (←)",
|
|
2706
|
+
children: /* @__PURE__ */ X(te, { className: "h-4 w-4" })
|
|
2707
|
+
}),
|
|
2708
|
+
/* @__PURE__ */ X("span", {
|
|
2709
|
+
className: "text-xs text-muted-foreground whitespace-nowrap px-1.5 tabular-nums",
|
|
2710
|
+
children: t > 0 ? `${e + 1} of ${t}` : "No records"
|
|
2711
|
+
}),
|
|
2712
|
+
/* @__PURE__ */ X(P, {
|
|
2713
|
+
variant: "outline",
|
|
2714
|
+
size: "icon",
|
|
2715
|
+
className: "h-8 w-8",
|
|
2716
|
+
disabled: !g,
|
|
2717
|
+
onClick: b,
|
|
2718
|
+
title: "Next record (→)",
|
|
2719
|
+
children: /* @__PURE__ */ X(p, { className: "h-4 w-4" })
|
|
2720
|
+
}),
|
|
2721
|
+
/* @__PURE__ */ X(P, {
|
|
2722
|
+
variant: "outline",
|
|
2723
|
+
size: "icon",
|
|
2724
|
+
className: "h-8 w-8",
|
|
2725
|
+
disabled: !_,
|
|
2726
|
+
onClick: x,
|
|
2727
|
+
title: "Last record (End)",
|
|
2728
|
+
children: /* @__PURE__ */ X(h, { className: "h-4 w-4" })
|
|
2729
|
+
}),
|
|
2730
|
+
i && /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X(P, {
|
|
2731
|
+
variant: l ? "secondary" : "ghost",
|
|
2732
|
+
size: "icon",
|
|
2733
|
+
className: "h-8 w-8",
|
|
2734
|
+
onClick: C,
|
|
2735
|
+
title: "Search while navigating",
|
|
2736
|
+
children: /* @__PURE__ */ X(V, { className: "h-4 w-4" })
|
|
2737
|
+
}), l && /* @__PURE__ */ X("div", {
|
|
2738
|
+
className: "relative",
|
|
2739
|
+
children: /* @__PURE__ */ X(a, {
|
|
2740
|
+
ref: d,
|
|
2741
|
+
type: "text",
|
|
2742
|
+
placeholder: "Search records…",
|
|
2743
|
+
value: s,
|
|
2744
|
+
onChange: S,
|
|
2745
|
+
className: "h-8 w-48 text-sm"
|
|
2746
|
+
})
|
|
2747
|
+
})] })
|
|
2748
|
+
]
|
|
2749
|
+
});
|
|
2750
|
+
}, tn = 28, nn = [
|
|
2751
|
+
"fill-primary stroke-primary",
|
|
2752
|
+
"fill-blue-500 stroke-blue-500",
|
|
2753
|
+
"fill-emerald-500 stroke-emerald-500",
|
|
2754
|
+
"fill-amber-500 stroke-amber-500"
|
|
2755
|
+
], rn = [
|
|
2756
|
+
"fill-primary-foreground",
|
|
2757
|
+
"fill-white",
|
|
2758
|
+
"fill-white",
|
|
2759
|
+
"fill-white"
|
|
2760
|
+
];
|
|
2761
|
+
function an(e, t, n, r, i) {
|
|
2762
|
+
let a = [], o = [], s = /* @__PURE__ */ new Set(), c = r / 2, l = i / 2;
|
|
2763
|
+
a.push({
|
|
2764
|
+
id: e.id,
|
|
2765
|
+
label: e.label,
|
|
2766
|
+
type: e.type,
|
|
2767
|
+
x: c,
|
|
2768
|
+
y: l,
|
|
2769
|
+
level: 0
|
|
2770
|
+
}), s.add(e.id);
|
|
2771
|
+
let u = Math.min(r, i) * .32, d = t.filter((e) => !s.has(e.id));
|
|
2772
|
+
if (d.forEach((t, n) => {
|
|
2773
|
+
let r = 2 * Math.PI * n / d.length - Math.PI / 2, i = c + u * Math.cos(r), f = l + u * Math.sin(r);
|
|
2774
|
+
a.push({
|
|
2775
|
+
id: t.id,
|
|
2776
|
+
label: t.label,
|
|
2777
|
+
type: t.type,
|
|
2778
|
+
x: i,
|
|
2779
|
+
y: f,
|
|
2780
|
+
level: 1
|
|
2781
|
+
}), o.push({
|
|
2782
|
+
fromId: e.id,
|
|
2783
|
+
toId: t.id,
|
|
2784
|
+
fromX: c,
|
|
2785
|
+
fromY: l,
|
|
2786
|
+
toX: i,
|
|
2787
|
+
toY: f
|
|
2788
|
+
}), s.add(t.id);
|
|
2789
|
+
}), n >= 2) {
|
|
2790
|
+
let e = Math.min(r, i) * .46, t = [];
|
|
2791
|
+
d.forEach((e) => {
|
|
2792
|
+
let n = a.find((t) => t.id === e.id);
|
|
2793
|
+
n && (e.relatedRecords || []).filter((e) => !s.has(e.id)).forEach((r) => {
|
|
2794
|
+
t.push({
|
|
2795
|
+
node: r,
|
|
2796
|
+
parentX: n.x,
|
|
2797
|
+
parentY: n.y,
|
|
2798
|
+
parentId: e.id
|
|
2799
|
+
}), s.add(r.id);
|
|
2800
|
+
});
|
|
2801
|
+
}), t.forEach((n, r) => {
|
|
2802
|
+
let i = 2 * Math.PI * r / Math.max(t.length, 1) - Math.PI / 2, s = c + e * Math.cos(i), u = l + e * Math.sin(i);
|
|
2803
|
+
a.push({
|
|
2804
|
+
id: n.node.id,
|
|
2805
|
+
label: n.node.label,
|
|
2806
|
+
type: n.node.type,
|
|
2807
|
+
x: s,
|
|
2808
|
+
y: u,
|
|
2809
|
+
level: 2
|
|
2810
|
+
}), o.push({
|
|
2811
|
+
fromId: n.parentId,
|
|
2812
|
+
toId: n.node.id,
|
|
2813
|
+
fromX: n.parentX,
|
|
2814
|
+
fromY: n.parentY,
|
|
2815
|
+
toX: s,
|
|
2816
|
+
toY: u
|
|
2817
|
+
});
|
|
2818
|
+
});
|
|
2819
|
+
}
|
|
2820
|
+
return {
|
|
2821
|
+
nodes: a,
|
|
2822
|
+
edges: o
|
|
2823
|
+
};
|
|
2824
|
+
}
|
|
2825
|
+
function on(e, t = 6) {
|
|
2826
|
+
return e.length <= t ? e : e.slice(0, t - 1) + "…";
|
|
2827
|
+
}
|
|
2828
|
+
var sn = ({ record: e, relatedRecords: t, levels: n = 1, onNodeClick: r, className: i }) => {
|
|
2829
|
+
let a = J.useRef(null), [o, s] = J.useState({
|
|
2830
|
+
width: 500,
|
|
2831
|
+
height: 400
|
|
2832
|
+
}), [l, u] = J.useState(null);
|
|
2833
|
+
J.useEffect(() => {
|
|
2834
|
+
let e = a.current;
|
|
2835
|
+
if (!e) return;
|
|
2836
|
+
let t = e.parentElement;
|
|
2837
|
+
if (!t) return;
|
|
2838
|
+
let n = new ResizeObserver((e) => {
|
|
2839
|
+
for (let t of e) {
|
|
2840
|
+
let { width: e } = t.contentRect;
|
|
2841
|
+
e > 0 && s({
|
|
2842
|
+
width: e,
|
|
2843
|
+
height: Math.max(300, e * .7)
|
|
2844
|
+
});
|
|
2845
|
+
}
|
|
2846
|
+
});
|
|
2847
|
+
return n.observe(t), () => n.disconnect();
|
|
2848
|
+
}, []);
|
|
2849
|
+
let { nodes: d, edges: f } = J.useMemo(() => an(e, t, n, o.width, o.height), [
|
|
2850
|
+
e,
|
|
2851
|
+
t,
|
|
2852
|
+
n,
|
|
2853
|
+
o
|
|
2854
|
+
]);
|
|
2855
|
+
return /* @__PURE__ */ Z(D, {
|
|
2856
|
+
className: q("overflow-hidden", i),
|
|
2857
|
+
children: [/* @__PURE__ */ X(c, {
|
|
2858
|
+
className: "pb-2",
|
|
2859
|
+
children: /* @__PURE__ */ Z(m, {
|
|
2860
|
+
className: "flex items-center gap-2 text-base",
|
|
2861
|
+
children: [
|
|
2862
|
+
/* @__PURE__ */ X(Fe, { className: "h-4 w-4" }),
|
|
2863
|
+
"Relationships",
|
|
2864
|
+
/* @__PURE__ */ Z("span", {
|
|
2865
|
+
className: "text-sm font-normal text-muted-foreground",
|
|
2866
|
+
children: [
|
|
2867
|
+
"(",
|
|
2868
|
+
t.length,
|
|
2869
|
+
" related)"
|
|
2870
|
+
]
|
|
2871
|
+
})
|
|
2872
|
+
]
|
|
2873
|
+
})
|
|
2874
|
+
}), /* @__PURE__ */ X(j, {
|
|
2875
|
+
className: "p-0",
|
|
2876
|
+
children: /* @__PURE__ */ Z("svg", {
|
|
2877
|
+
ref: a,
|
|
2878
|
+
width: "100%",
|
|
2879
|
+
height: o.height,
|
|
2880
|
+
viewBox: `0 0 ${o.width} ${o.height}`,
|
|
2881
|
+
className: "select-none",
|
|
2882
|
+
children: [f.map((e, t) => /* @__PURE__ */ X("line", {
|
|
2883
|
+
x1: e.fromX,
|
|
2884
|
+
y1: e.fromY,
|
|
2885
|
+
x2: e.toX,
|
|
2886
|
+
y2: e.toY,
|
|
2887
|
+
className: "stroke-border",
|
|
2888
|
+
strokeWidth: 1.5,
|
|
2889
|
+
strokeOpacity: .5
|
|
2890
|
+
}, `edge-${t}`)), d.map((e) => {
|
|
2891
|
+
let t = l === e.id, n = nn[Math.min(e.level, nn.length - 1)], i = rn[Math.min(e.level, rn.length - 1)], a = e.level === 0 ? tn + 6 : tn;
|
|
2892
|
+
return /* @__PURE__ */ Z("g", {
|
|
2893
|
+
className: q("cursor-pointer transition-transform", r && "hover:opacity-80"),
|
|
2894
|
+
onClick: () => r?.(e.id),
|
|
2895
|
+
onMouseEnter: () => u(e.id),
|
|
2896
|
+
onMouseLeave: () => u(null),
|
|
2897
|
+
children: [
|
|
2898
|
+
/* @__PURE__ */ X("circle", {
|
|
2899
|
+
cx: e.x,
|
|
2900
|
+
cy: e.y,
|
|
2901
|
+
r: t ? a + 3 : a,
|
|
2902
|
+
className: n,
|
|
2903
|
+
fillOpacity: e.level === 0 ? 1 : .85,
|
|
2904
|
+
strokeWidth: 2,
|
|
2905
|
+
strokeOpacity: .3
|
|
2906
|
+
}),
|
|
2907
|
+
/* @__PURE__ */ X("text", {
|
|
2908
|
+
x: e.x,
|
|
2909
|
+
y: e.y,
|
|
2910
|
+
textAnchor: "middle",
|
|
2911
|
+
dominantBaseline: "central",
|
|
2912
|
+
className: q("text-[10px] font-medium pointer-events-none", i),
|
|
2913
|
+
children: on(e.label)
|
|
2914
|
+
}),
|
|
2915
|
+
e.type && /* @__PURE__ */ X("text", {
|
|
2916
|
+
x: e.x,
|
|
2917
|
+
y: e.y + a + 12,
|
|
2918
|
+
textAnchor: "middle",
|
|
2919
|
+
className: "fill-muted-foreground text-[9px] pointer-events-none",
|
|
2920
|
+
children: e.type
|
|
2921
|
+
}),
|
|
2922
|
+
t && /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ X("rect", {
|
|
2923
|
+
x: e.x - 50,
|
|
2924
|
+
y: e.y - a - 28,
|
|
2925
|
+
width: 100,
|
|
2926
|
+
height: 20,
|
|
2927
|
+
rx: 4,
|
|
2928
|
+
className: "fill-popover stroke-border",
|
|
2929
|
+
strokeWidth: 1
|
|
2930
|
+
}), /* @__PURE__ */ X("text", {
|
|
2931
|
+
x: e.x,
|
|
2932
|
+
y: e.y - a - 16,
|
|
2933
|
+
textAnchor: "middle",
|
|
2934
|
+
dominantBaseline: "central",
|
|
2935
|
+
className: "fill-popover-foreground text-[10px] pointer-events-none",
|
|
2936
|
+
children: e.label
|
|
2937
|
+
})] })
|
|
2938
|
+
]
|
|
2939
|
+
}, e.id);
|
|
2940
|
+
})]
|
|
2941
|
+
})
|
|
2942
|
+
})]
|
|
2943
|
+
});
|
|
2944
|
+
};
|
|
2945
|
+
//#endregion
|
|
2946
|
+
//#region src/CommentAttachment.tsx
|
|
2947
|
+
function cn(e) {
|
|
2948
|
+
return e < 1024 ? `${e} B` : e < 1024 * 1024 ? `${(e / 1024).toFixed(1)} KB` : `${(e / (1024 * 1024)).toFixed(1)} MB`;
|
|
2949
|
+
}
|
|
2950
|
+
function ln(e) {
|
|
2951
|
+
return e.startsWith("image/");
|
|
2952
|
+
}
|
|
2953
|
+
function un(e) {
|
|
2954
|
+
return ln(e) ? he : e.includes("pdf") || e.includes("document") || e.includes("text") ? _ : e.includes("zip") || e.includes("archive") || e.includes("compressed") ? y : pe;
|
|
2955
|
+
}
|
|
2956
|
+
var dn = ({ attachments: t, onUpload: n, onRemove: r, className: i, readOnly: a = !1 }) => {
|
|
2957
|
+
let [o, s] = J.useState(!1), c = J.useRef(null), l = J.useCallback((e) => {
|
|
2958
|
+
e.preventDefault(), e.stopPropagation(), s(!0);
|
|
2959
|
+
}, []), u = J.useCallback((e) => {
|
|
2960
|
+
e.preventDefault(), e.stopPropagation(), s(!1);
|
|
2961
|
+
}, []), d = J.useCallback((e) => {
|
|
2962
|
+
e.preventDefault(), e.stopPropagation(), s(!1), n && e.dataTransfer.files.length > 0 && n(e.dataTransfer.files);
|
|
2963
|
+
}, [n]), f = J.useCallback((e) => {
|
|
2964
|
+
n && e.target.files && e.target.files.length > 0 && (n(e.target.files), e.target.value = "");
|
|
2965
|
+
}, [n]);
|
|
2966
|
+
return /* @__PURE__ */ Z("div", {
|
|
2967
|
+
className: q("space-y-2", i),
|
|
2968
|
+
children: [n && !a && /* @__PURE__ */ Z("div", {
|
|
2969
|
+
className: q("border-2 border-dashed rounded-md px-4 py-3 text-center transition-colors cursor-pointer", o ? "border-primary bg-primary/5" : "border-muted-foreground/25 hover:border-muted-foreground/40"),
|
|
2970
|
+
onDragOver: l,
|
|
2971
|
+
onDragLeave: u,
|
|
2972
|
+
onDrop: d,
|
|
2973
|
+
onClick: () => c.current?.click(),
|
|
2974
|
+
role: "button",
|
|
2975
|
+
tabIndex: 0,
|
|
2976
|
+
onKeyDown: (e) => {
|
|
2977
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), c.current?.click());
|
|
2978
|
+
},
|
|
2979
|
+
children: [
|
|
2980
|
+
/* @__PURE__ */ X(ae, { className: "h-5 w-5 mx-auto text-muted-foreground mb-1" }),
|
|
2981
|
+
/* @__PURE__ */ X("p", {
|
|
2982
|
+
className: "text-xs text-muted-foreground",
|
|
2983
|
+
children: "Drop files here or click to upload"
|
|
2984
|
+
}),
|
|
2985
|
+
/* @__PURE__ */ X("input", {
|
|
2986
|
+
ref: c,
|
|
2987
|
+
type: "file",
|
|
2988
|
+
multiple: !0,
|
|
2989
|
+
className: "hidden",
|
|
2990
|
+
onChange: f
|
|
2991
|
+
})
|
|
2992
|
+
]
|
|
2993
|
+
}), t.length > 0 && /* @__PURE__ */ Z("div", {
|
|
2994
|
+
className: "space-y-1.5",
|
|
2995
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
2996
|
+
className: "flex items-center gap-1.5 text-xs text-muted-foreground",
|
|
2997
|
+
children: [/* @__PURE__ */ X(Ne, { className: "h-3 w-3" }), /* @__PURE__ */ Z("span", { children: [
|
|
2998
|
+
t.length,
|
|
2999
|
+
" attachment",
|
|
3000
|
+
t.length === 1 ? "" : "s"
|
|
3001
|
+
] })]
|
|
3002
|
+
}), /* @__PURE__ */ X("div", {
|
|
3003
|
+
className: "grid grid-cols-1 sm:grid-cols-2 gap-2",
|
|
3004
|
+
children: t.map((t) => {
|
|
3005
|
+
let n = ln(t.type), i = un(t.type);
|
|
3006
|
+
return /* @__PURE__ */ Z("div", {
|
|
3007
|
+
className: "flex items-center gap-2 rounded-md border px-2.5 py-2 bg-muted/30 group",
|
|
3008
|
+
children: [
|
|
3009
|
+
n && (t.thumbnailUrl || t.url) ? /* @__PURE__ */ X("img", {
|
|
3010
|
+
src: t.thumbnailUrl || t.url,
|
|
3011
|
+
alt: t.name,
|
|
3012
|
+
className: "h-10 w-10 rounded object-cover shrink-0"
|
|
3013
|
+
}) : /* @__PURE__ */ X("div", {
|
|
3014
|
+
className: "h-10 w-10 rounded bg-muted flex items-center justify-center shrink-0",
|
|
3015
|
+
children: /* @__PURE__ */ X(i, { className: "h-5 w-5 text-muted-foreground" })
|
|
3016
|
+
}),
|
|
3017
|
+
/* @__PURE__ */ Z("div", {
|
|
3018
|
+
className: "flex-1 min-w-0",
|
|
3019
|
+
children: [/* @__PURE__ */ X("p", {
|
|
3020
|
+
className: "text-xs font-medium truncate",
|
|
3021
|
+
children: t.name
|
|
3022
|
+
}), /* @__PURE__ */ X("p", {
|
|
3023
|
+
className: "text-[10px] text-muted-foreground",
|
|
3024
|
+
children: cn(t.size)
|
|
3025
|
+
})]
|
|
3026
|
+
}),
|
|
3027
|
+
r && !a && /* @__PURE__ */ X(P, {
|
|
3028
|
+
variant: "ghost",
|
|
3029
|
+
size: "icon",
|
|
3030
|
+
className: "h-6 w-6 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity",
|
|
3031
|
+
onClick: () => r(t.id),
|
|
3032
|
+
title: "Remove attachment",
|
|
3033
|
+
children: /* @__PURE__ */ X(e, { className: "h-3.5 w-3.5" })
|
|
3034
|
+
})
|
|
3035
|
+
]
|
|
3036
|
+
}, t.id);
|
|
3037
|
+
})
|
|
3038
|
+
})]
|
|
3039
|
+
})]
|
|
3040
|
+
});
|
|
3041
|
+
};
|
|
3042
|
+
//#endregion
|
|
3043
|
+
//#region src/PointInTimeRestore.tsx
|
|
3044
|
+
function fn(e) {
|
|
3045
|
+
try {
|
|
3046
|
+
let t = new Date(e), n = (/* @__PURE__ */ new Date()).getTime() - t.getTime(), r = Math.floor(n / 6e4);
|
|
3047
|
+
if (r < 1) return "just now";
|
|
3048
|
+
if (r < 60) return `${r}m ago`;
|
|
3049
|
+
let i = Math.floor(r / 60);
|
|
3050
|
+
return i < 24 ? `${i}h ago` : t.toLocaleString();
|
|
3051
|
+
} catch {
|
|
3052
|
+
return e;
|
|
3053
|
+
}
|
|
3054
|
+
}
|
|
3055
|
+
var pn = ({ recordId: e, revisions: t, onRestore: n, className: i }) => {
|
|
3056
|
+
let [a, o] = J.useState(null), [s, l] = J.useState(!1), [u, d] = J.useState(!1), f = J.useMemo(() => t.find((e) => e.id === a) ?? null, [t, a]), h = J.useCallback(async () => {
|
|
3057
|
+
if (!(!f || !n)) {
|
|
3058
|
+
if (!s) {
|
|
3059
|
+
l(!0);
|
|
3060
|
+
return;
|
|
3061
|
+
}
|
|
3062
|
+
d(!0);
|
|
3063
|
+
try {
|
|
3064
|
+
let e = f.snapshot ?? {};
|
|
3065
|
+
await n(f.id, e), l(!1), o(null);
|
|
3066
|
+
} finally {
|
|
3067
|
+
d(!1);
|
|
3068
|
+
}
|
|
3069
|
+
}
|
|
3070
|
+
}, [
|
|
3071
|
+
f,
|
|
3072
|
+
n,
|
|
3073
|
+
s
|
|
3074
|
+
]), g = J.useCallback(() => {
|
|
3075
|
+
l(!1);
|
|
3076
|
+
}, []);
|
|
3077
|
+
return /* @__PURE__ */ Z(D, {
|
|
3078
|
+
className: q("", i),
|
|
3079
|
+
children: [/* @__PURE__ */ X(c, {
|
|
3080
|
+
className: "pb-3",
|
|
3081
|
+
children: /* @__PURE__ */ Z(m, {
|
|
3082
|
+
className: "flex items-center gap-2 text-base",
|
|
3083
|
+
children: [
|
|
3084
|
+
/* @__PURE__ */ X(r, { className: "h-4 w-4" }),
|
|
3085
|
+
"Revision History",
|
|
3086
|
+
/* @__PURE__ */ Z("span", {
|
|
3087
|
+
className: "text-sm font-normal text-muted-foreground",
|
|
3088
|
+
children: [
|
|
3089
|
+
"(",
|
|
3090
|
+
t.length,
|
|
3091
|
+
")"
|
|
3092
|
+
]
|
|
3093
|
+
})
|
|
3094
|
+
]
|
|
3095
|
+
})
|
|
3096
|
+
}), /* @__PURE__ */ X(j, { children: t.length === 0 ? /* @__PURE__ */ X("p", {
|
|
3097
|
+
className: "text-sm text-muted-foreground text-center py-4",
|
|
3098
|
+
children: "No revisions recorded"
|
|
3099
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
3100
|
+
className: "flex flex-col lg:flex-row gap-4",
|
|
3101
|
+
children: [/* @__PURE__ */ X("div", {
|
|
3102
|
+
className: "flex-1 min-w-0",
|
|
3103
|
+
children: /* @__PURE__ */ Z("div", {
|
|
3104
|
+
className: "relative",
|
|
3105
|
+
children: [/* @__PURE__ */ X("div", { className: "absolute left-3 top-2 bottom-2 w-px bg-border" }), /* @__PURE__ */ X("div", {
|
|
3106
|
+
className: "space-y-1",
|
|
3107
|
+
children: t.map((e) => {
|
|
3108
|
+
let t = e.id === a;
|
|
3109
|
+
return /* @__PURE__ */ Z("button", {
|
|
3110
|
+
type: "button",
|
|
3111
|
+
className: q("w-full text-left flex items-start gap-3 py-2 px-2 rounded-md transition-colors relative", t ? "bg-accent" : "hover:bg-accent/50"),
|
|
3112
|
+
onClick: () => {
|
|
3113
|
+
o(e.id), l(!1);
|
|
3114
|
+
},
|
|
3115
|
+
children: [/* @__PURE__ */ X("div", {
|
|
3116
|
+
className: q("shrink-0 h-6 w-6 rounded-full border-2 flex items-center justify-center z-10 mt-0.5", t ? "border-primary bg-primary" : "border-border bg-background"),
|
|
3117
|
+
children: t && /* @__PURE__ */ X(p, { className: "h-3 w-3 text-primary-foreground" })
|
|
3118
|
+
}), /* @__PURE__ */ Z("div", {
|
|
3119
|
+
className: "flex-1 min-w-0",
|
|
3120
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
3121
|
+
className: "flex items-center gap-2",
|
|
3122
|
+
children: [/* @__PURE__ */ X("span", {
|
|
3123
|
+
className: "text-sm font-medium",
|
|
3124
|
+
children: e.user
|
|
3125
|
+
}), /* @__PURE__ */ X("span", {
|
|
3126
|
+
className: "text-xs text-muted-foreground",
|
|
3127
|
+
children: fn(e.timestamp)
|
|
3128
|
+
})]
|
|
3129
|
+
}), /* @__PURE__ */ Z("p", {
|
|
3130
|
+
className: "text-xs text-muted-foreground mt-0.5",
|
|
3131
|
+
children: [
|
|
3132
|
+
e.changes.length,
|
|
3133
|
+
" field",
|
|
3134
|
+
e.changes.length === 1 ? "" : "s",
|
|
3135
|
+
" ",
|
|
3136
|
+
"changed"
|
|
3137
|
+
]
|
|
3138
|
+
})]
|
|
3139
|
+
})]
|
|
3140
|
+
}, e.id);
|
|
3141
|
+
})
|
|
3142
|
+
})]
|
|
3143
|
+
})
|
|
3144
|
+
}), f && /* @__PURE__ */ Z("div", {
|
|
3145
|
+
className: "lg:w-80 border rounded-md p-3 space-y-3",
|
|
3146
|
+
children: [
|
|
3147
|
+
/* @__PURE__ */ Z("div", {
|
|
3148
|
+
className: "flex items-center gap-2 text-sm font-medium",
|
|
3149
|
+
children: [/* @__PURE__ */ X(x, { className: "h-4 w-4 text-muted-foreground" }), "Revision Preview"]
|
|
3150
|
+
}),
|
|
3151
|
+
/* @__PURE__ */ X("div", {
|
|
3152
|
+
className: "space-y-2",
|
|
3153
|
+
children: f.changes.map((e, t) => /* @__PURE__ */ Z("div", {
|
|
3154
|
+
className: "text-xs",
|
|
3155
|
+
children: [/* @__PURE__ */ X("span", {
|
|
3156
|
+
className: "font-medium text-muted-foreground",
|
|
3157
|
+
children: e.field
|
|
3158
|
+
}), /* @__PURE__ */ Z("div", {
|
|
3159
|
+
className: "flex items-center gap-1.5 mt-0.5",
|
|
3160
|
+
children: [
|
|
3161
|
+
/* @__PURE__ */ X("span", {
|
|
3162
|
+
className: "line-through text-red-600 dark:text-red-400 truncate max-w-[120px]",
|
|
3163
|
+
children: e.oldValue == null ? "(empty)" : String(e.oldValue)
|
|
3164
|
+
}),
|
|
3165
|
+
/* @__PURE__ */ X(p, { className: "h-3 w-3 text-muted-foreground shrink-0" }),
|
|
3166
|
+
/* @__PURE__ */ X("span", {
|
|
3167
|
+
className: "text-green-600 dark:text-green-400 truncate max-w-[120px]",
|
|
3168
|
+
children: e.newValue == null ? "(empty)" : String(e.newValue)
|
|
3169
|
+
})
|
|
3170
|
+
]
|
|
3171
|
+
})]
|
|
3172
|
+
}, t))
|
|
3173
|
+
}),
|
|
3174
|
+
f.snapshot && /* @__PURE__ */ Z("div", {
|
|
3175
|
+
className: "border-t pt-2 space-y-1",
|
|
3176
|
+
children: [/* @__PURE__ */ X("p", {
|
|
3177
|
+
className: "text-xs font-medium text-muted-foreground",
|
|
3178
|
+
children: "Record state at this point"
|
|
3179
|
+
}), /* @__PURE__ */ X("div", {
|
|
3180
|
+
className: "max-h-40 overflow-y-auto space-y-1",
|
|
3181
|
+
children: Object.entries(f.snapshot).map(([e, t]) => /* @__PURE__ */ Z("div", {
|
|
3182
|
+
className: "flex justify-between text-xs gap-2",
|
|
3183
|
+
children: [/* @__PURE__ */ X("span", {
|
|
3184
|
+
className: "text-muted-foreground truncate",
|
|
3185
|
+
children: e
|
|
3186
|
+
}), /* @__PURE__ */ X("span", {
|
|
3187
|
+
className: "font-mono truncate max-w-[140px]",
|
|
3188
|
+
children: t == null ? "–" : String(t)
|
|
3189
|
+
})]
|
|
3190
|
+
}, e))
|
|
3191
|
+
})]
|
|
3192
|
+
}),
|
|
3193
|
+
n && /* @__PURE__ */ X("div", {
|
|
3194
|
+
className: "pt-1 space-y-2",
|
|
3195
|
+
children: s ? /* @__PURE__ */ Z(Y, { children: [/* @__PURE__ */ Z("p", {
|
|
3196
|
+
className: "text-xs text-amber-600 dark:text-amber-400",
|
|
3197
|
+
children: [
|
|
3198
|
+
"This will restore the record to its state at",
|
|
3199
|
+
" ",
|
|
3200
|
+
fn(f.timestamp),
|
|
3201
|
+
". Continue?"
|
|
3202
|
+
]
|
|
3203
|
+
}), /* @__PURE__ */ Z("div", {
|
|
3204
|
+
className: "flex gap-2",
|
|
3205
|
+
children: [/* @__PURE__ */ Z(P, {
|
|
3206
|
+
variant: "destructive",
|
|
3207
|
+
size: "sm",
|
|
3208
|
+
className: "gap-1.5 flex-1",
|
|
3209
|
+
onClick: h,
|
|
3210
|
+
disabled: u,
|
|
3211
|
+
children: [/* @__PURE__ */ X(Ce, { className: "h-3.5 w-3.5" }), u ? "Restoring…" : "Confirm Restore"]
|
|
3212
|
+
}), /* @__PURE__ */ X(P, {
|
|
3213
|
+
variant: "ghost",
|
|
3214
|
+
size: "sm",
|
|
3215
|
+
onClick: g,
|
|
3216
|
+
disabled: u,
|
|
3217
|
+
children: "Cancel"
|
|
3218
|
+
})]
|
|
3219
|
+
})] }) : /* @__PURE__ */ Z(P, {
|
|
3220
|
+
variant: "outline",
|
|
3221
|
+
size: "sm",
|
|
3222
|
+
className: "w-full gap-1.5",
|
|
3223
|
+
onClick: h,
|
|
3224
|
+
children: [/* @__PURE__ */ X(Ce, { className: "h-3.5 w-3.5" }), "Restore to this point"]
|
|
3225
|
+
})
|
|
3226
|
+
})
|
|
3227
|
+
]
|
|
3228
|
+
})]
|
|
3229
|
+
}) })]
|
|
3230
|
+
});
|
|
3231
|
+
}, mn = ({ change: e, className: t }) => {
|
|
3232
|
+
let n = e.fieldLabel ?? e.field.charAt(0).toUpperCase() + e.field.slice(1).replace(/_/g, " "), r = e.oldDisplayValue ?? (e.oldValue == null ? "(empty)" : String(e.oldValue)), i = e.newDisplayValue ?? (e.newValue == null ? "(empty)" : String(e.newValue));
|
|
3233
|
+
return /* @__PURE__ */ Z("div", {
|
|
3234
|
+
className: q("flex items-center gap-1.5 text-sm flex-wrap", t),
|
|
3235
|
+
children: [
|
|
3236
|
+
/* @__PURE__ */ X("span", {
|
|
3237
|
+
className: "font-medium text-foreground",
|
|
3238
|
+
children: n
|
|
3239
|
+
}),
|
|
3240
|
+
/* @__PURE__ */ X("span", {
|
|
3241
|
+
className: "text-muted-foreground line-through",
|
|
3242
|
+
children: r
|
|
3243
|
+
}),
|
|
3244
|
+
/* @__PURE__ */ X(R, { className: "h-3 w-3 text-muted-foreground shrink-0" }),
|
|
3245
|
+
/* @__PURE__ */ X("span", {
|
|
3246
|
+
className: "text-foreground",
|
|
3247
|
+
children: i
|
|
3248
|
+
})
|
|
3249
|
+
]
|
|
3250
|
+
});
|
|
3251
|
+
}, hn = [
|
|
3252
|
+
"👍",
|
|
3253
|
+
"❤️",
|
|
3254
|
+
"🎉",
|
|
3255
|
+
"😂",
|
|
3256
|
+
"😮",
|
|
3257
|
+
"😢"
|
|
3258
|
+
], gn = ({ reactions: e, onToggleReaction: t, emojiOptions: n = hn, className: r }) => {
|
|
3259
|
+
let [i, a] = J.useState(!1), o = J.useCallback((e) => {
|
|
3260
|
+
t?.(e), a(!1);
|
|
3261
|
+
}, [t]);
|
|
3262
|
+
return /* @__PURE__ */ Z("div", {
|
|
3263
|
+
className: q("flex items-center gap-1 flex-wrap", r),
|
|
3264
|
+
children: [e.map((e) => /* @__PURE__ */ Z("button", {
|
|
3265
|
+
type: "button",
|
|
3266
|
+
className: q("inline-flex items-center gap-1 rounded-full px-2 py-0.5 text-xs border transition-colors", e.reacted ? "bg-primary/10 border-primary/30 text-primary" : "bg-muted border-border text-muted-foreground hover:bg-muted/80"),
|
|
3267
|
+
onClick: () => o(e.emoji),
|
|
3268
|
+
disabled: !t,
|
|
3269
|
+
"aria-label": `${e.emoji} ${e.count} reaction${e.count === 1 ? "" : "s"}`,
|
|
3270
|
+
children: [/* @__PURE__ */ X("span", { children: e.emoji }), /* @__PURE__ */ X("span", { children: e.count })]
|
|
3271
|
+
}, e.emoji)), t && /* @__PURE__ */ Z("div", {
|
|
3272
|
+
className: "relative",
|
|
3273
|
+
children: [/* @__PURE__ */ X(P, {
|
|
3274
|
+
variant: "ghost",
|
|
3275
|
+
size: "icon",
|
|
3276
|
+
className: "h-6 w-6",
|
|
3277
|
+
onClick: () => a(!i),
|
|
3278
|
+
"aria-label": "Add reaction",
|
|
3279
|
+
children: /* @__PURE__ */ X(Oe, { className: "h-3.5 w-3.5" })
|
|
3280
|
+
}), i && /* @__PURE__ */ X("div", {
|
|
3281
|
+
className: "absolute bottom-full mb-1 left-0 bg-popover border rounded-md shadow-md z-50 p-1.5 flex gap-1",
|
|
3282
|
+
role: "listbox",
|
|
3283
|
+
"aria-label": "Emoji picker",
|
|
3284
|
+
children: n.map((t) => /* @__PURE__ */ X("button", {
|
|
3285
|
+
type: "button",
|
|
3286
|
+
className: "hover:bg-accent rounded p-1 text-base transition-colors",
|
|
3287
|
+
onClick: () => o(t),
|
|
3288
|
+
role: "option",
|
|
3289
|
+
"aria-selected": e.some((e) => e.emoji === t && e.reacted),
|
|
3290
|
+
children: t
|
|
3291
|
+
}, t))
|
|
3292
|
+
})]
|
|
3293
|
+
})]
|
|
3294
|
+
});
|
|
3295
|
+
};
|
|
3296
|
+
//#endregion
|
|
3297
|
+
//#region src/ThreadedReplies.tsx
|
|
3298
|
+
function _n(e) {
|
|
3299
|
+
try {
|
|
3300
|
+
let t = new Date(e), n = (/* @__PURE__ */ new Date()).getTime() - t.getTime(), r = Math.floor(n / 6e4);
|
|
3301
|
+
if (r < 1) return "just now";
|
|
3302
|
+
if (r < 60) return `${r}m ago`;
|
|
3303
|
+
let i = Math.floor(r / 60);
|
|
3304
|
+
if (i < 24) return `${i}h ago`;
|
|
3305
|
+
let a = Math.floor(i / 24);
|
|
3306
|
+
return a < 7 ? `${a}d ago` : t.toLocaleDateString();
|
|
3307
|
+
} catch {
|
|
3308
|
+
return e;
|
|
3309
|
+
}
|
|
3310
|
+
}
|
|
3311
|
+
var vn = ({ parentItem: e, replies: t, onAddReply: n, showReplyInput: r = !0, className: i }) => {
|
|
3312
|
+
let [a, o] = J.useState(!1), [s, c] = J.useState(""), [l, u] = J.useState(!1), d = J.useCallback(async () => {
|
|
3313
|
+
let t = s.trim();
|
|
3314
|
+
if (!(!t || !n)) {
|
|
3315
|
+
u(!0);
|
|
3316
|
+
try {
|
|
3317
|
+
await n(e.id, t), c("");
|
|
3318
|
+
} finally {
|
|
3319
|
+
u(!1);
|
|
3320
|
+
}
|
|
3321
|
+
}
|
|
3322
|
+
}, [
|
|
3323
|
+
s,
|
|
3324
|
+
n,
|
|
3325
|
+
e.id
|
|
3326
|
+
]), f = J.useCallback((e) => {
|
|
3327
|
+
e.key === "Enter" && (e.ctrlKey || e.metaKey) && (e.preventDefault(), d());
|
|
3328
|
+
}, [d]);
|
|
3329
|
+
return t.length === 0 && !r ? null : /* @__PURE__ */ Z("div", {
|
|
3330
|
+
className: q("ml-10 mt-1", i),
|
|
3331
|
+
children: [
|
|
3332
|
+
t.length > 0 && /* @__PURE__ */ Z("button", {
|
|
3333
|
+
type: "button",
|
|
3334
|
+
className: "flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors mb-1",
|
|
3335
|
+
onClick: () => o(!a),
|
|
3336
|
+
"aria-expanded": a,
|
|
3337
|
+
children: [
|
|
3338
|
+
X(a ? ee : p, { className: "h-3 w-3" }),
|
|
3339
|
+
/* @__PURE__ */ X(T, { className: "h-3 w-3" }),
|
|
3340
|
+
/* @__PURE__ */ Z("span", { children: [
|
|
3341
|
+
t.length,
|
|
3342
|
+
" ",
|
|
3343
|
+
t.length === 1 ? "reply" : "replies"
|
|
3344
|
+
] })
|
|
3345
|
+
]
|
|
3346
|
+
}),
|
|
3347
|
+
a && /* @__PURE__ */ X("div", {
|
|
3348
|
+
className: "space-y-2 border-l-2 border-border pl-3",
|
|
3349
|
+
children: t.map((e) => /* @__PURE__ */ Z("div", {
|
|
3350
|
+
className: "flex gap-2",
|
|
3351
|
+
children: [/* @__PURE__ */ X("div", {
|
|
3352
|
+
className: "shrink-0",
|
|
3353
|
+
children: e.actorAvatarUrl ? /* @__PURE__ */ X("img", {
|
|
3354
|
+
src: e.actorAvatarUrl,
|
|
3355
|
+
alt: e.actor,
|
|
3356
|
+
className: "h-6 w-6 rounded-full object-cover"
|
|
3357
|
+
}) : /* @__PURE__ */ X("div", {
|
|
3358
|
+
className: "h-6 w-6 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium text-muted-foreground",
|
|
3359
|
+
children: e.actor.charAt(0).toUpperCase()
|
|
3360
|
+
})
|
|
3361
|
+
}), /* @__PURE__ */ Z("div", {
|
|
3362
|
+
className: "flex-1 min-w-0",
|
|
3363
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
3364
|
+
className: "flex items-center gap-1.5",
|
|
3365
|
+
children: [/* @__PURE__ */ X("span", {
|
|
3366
|
+
className: "text-xs font-medium",
|
|
3367
|
+
children: e.actor
|
|
3368
|
+
}), /* @__PURE__ */ X("span", {
|
|
3369
|
+
className: "text-[10px] text-muted-foreground",
|
|
3370
|
+
children: _n(e.createdAt)
|
|
3371
|
+
})]
|
|
3372
|
+
}), /* @__PURE__ */ X("p", {
|
|
3373
|
+
className: "text-xs whitespace-pre-wrap break-words",
|
|
3374
|
+
children: e.body
|
|
3375
|
+
})]
|
|
3376
|
+
})]
|
|
3377
|
+
}, e.id))
|
|
3378
|
+
}),
|
|
3379
|
+
r && n && /* @__PURE__ */ Z("div", {
|
|
3380
|
+
className: "flex gap-1.5 mt-1.5",
|
|
3381
|
+
children: [/* @__PURE__ */ X("input", {
|
|
3382
|
+
className: "flex-1 rounded-md border border-input bg-background px-2 py-1 text-xs placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
3383
|
+
placeholder: "Reply…",
|
|
3384
|
+
value: s,
|
|
3385
|
+
onChange: (e) => c(e.target.value),
|
|
3386
|
+
onKeyDown: f,
|
|
3387
|
+
disabled: l
|
|
3388
|
+
}), /* @__PURE__ */ X(P, {
|
|
3389
|
+
variant: "ghost",
|
|
3390
|
+
size: "icon",
|
|
3391
|
+
className: "h-6 w-6 shrink-0",
|
|
3392
|
+
onClick: d,
|
|
3393
|
+
disabled: !s.trim() || l,
|
|
3394
|
+
"aria-label": "Send reply",
|
|
3395
|
+
children: /* @__PURE__ */ X(je, { className: "h-3 w-3" })
|
|
3396
|
+
})]
|
|
3397
|
+
})
|
|
3398
|
+
]
|
|
3399
|
+
});
|
|
3400
|
+
}, yn = ({ subscription: e, onToggle: t, className: n }) => {
|
|
3401
|
+
let [r, i] = J.useState(!1), a = J.useCallback(async () => {
|
|
3402
|
+
if (t) {
|
|
3403
|
+
i(!0);
|
|
3404
|
+
try {
|
|
3405
|
+
await t(!e.subscribed);
|
|
3406
|
+
} finally {
|
|
3407
|
+
i(!1);
|
|
3408
|
+
}
|
|
3409
|
+
}
|
|
3410
|
+
}, [t, e.subscribed]);
|
|
3411
|
+
return /* @__PURE__ */ X(P, {
|
|
3412
|
+
variant: "ghost",
|
|
3413
|
+
size: "icon",
|
|
3414
|
+
className: q("h-8 w-8", n),
|
|
3415
|
+
onClick: a,
|
|
3416
|
+
disabled: r || !t,
|
|
3417
|
+
"aria-label": e.subscribed ? "Unsubscribe from notifications" : "Subscribe to notifications",
|
|
3418
|
+
title: e.subscribed ? "Subscribed — click to unsubscribe" : "Subscribe to notifications",
|
|
3419
|
+
children: e.subscribed ? /* @__PURE__ */ X(ie, { className: "h-4 w-4 text-primary" }) : /* @__PURE__ */ X(ke, { className: "h-4 w-4 text-muted-foreground" })
|
|
3420
|
+
});
|
|
3421
|
+
}, bn = {
|
|
3422
|
+
comment: T,
|
|
3423
|
+
field_change: z,
|
|
3424
|
+
task: Se,
|
|
3425
|
+
event: C,
|
|
3426
|
+
system: S,
|
|
3427
|
+
email: Pe,
|
|
3428
|
+
call: ne
|
|
3429
|
+
}, xn = {
|
|
3430
|
+
comment: "bg-purple-100 text-purple-600",
|
|
3431
|
+
field_change: "bg-blue-100 text-blue-600",
|
|
3432
|
+
task: "bg-green-100 text-green-600",
|
|
3433
|
+
event: "bg-amber-100 text-amber-600",
|
|
3434
|
+
system: "bg-gray-100 text-gray-600",
|
|
3435
|
+
email: "bg-indigo-100 text-indigo-600",
|
|
3436
|
+
call: "bg-teal-100 text-teal-600"
|
|
3437
|
+
}, Sn = [
|
|
3438
|
+
{
|
|
3439
|
+
value: "all",
|
|
3440
|
+
label: "All Activity"
|
|
3441
|
+
},
|
|
3442
|
+
{
|
|
3443
|
+
value: "comments_only",
|
|
3444
|
+
label: "Comments Only"
|
|
3445
|
+
},
|
|
3446
|
+
{
|
|
3447
|
+
value: "changes_only",
|
|
3448
|
+
label: "Field Changes"
|
|
3449
|
+
},
|
|
3450
|
+
{
|
|
3451
|
+
value: "tasks_only",
|
|
3452
|
+
label: "Tasks Only"
|
|
3453
|
+
}
|
|
3454
|
+
];
|
|
3455
|
+
function Cn(e) {
|
|
3456
|
+
try {
|
|
3457
|
+
let t = new Date(e), n = (/* @__PURE__ */ new Date()).getTime() - t.getTime(), r = Math.floor(n / 6e4);
|
|
3458
|
+
if (r < 1) return "just now";
|
|
3459
|
+
if (r < 60) return `${r}m ago`;
|
|
3460
|
+
let i = Math.floor(r / 60);
|
|
3461
|
+
if (i < 24) return `${i}h ago`;
|
|
3462
|
+
let a = Math.floor(i / 24);
|
|
3463
|
+
return a < 7 ? `${a}d ago` : t.toLocaleDateString();
|
|
3464
|
+
} catch {
|
|
3465
|
+
return e;
|
|
3466
|
+
}
|
|
3467
|
+
}
|
|
3468
|
+
function wn(e, t) {
|
|
3469
|
+
switch (t) {
|
|
3470
|
+
case "comments_only": return e.filter((e) => e.type === "comment");
|
|
3471
|
+
case "changes_only": return e.filter((e) => e.type === "field_change");
|
|
3472
|
+
case "tasks_only": return e.filter((e) => e.type === "task");
|
|
3473
|
+
default: return e;
|
|
3474
|
+
}
|
|
3475
|
+
}
|
|
3476
|
+
var Tn = ({ items: e, config: t, filterMode: n, onFilterChange: r, hasMore: i = !1, onLoadMore: a, loading: o = !1, onAddComment: s, onAddReply: l, onToggleReaction: u, subscription: d, onToggleSubscription: f, collapseWhenEmpty: p = !1, className: h }) => {
|
|
3477
|
+
let [g, _] = J.useState("all"), [v, y] = J.useState(""), [b, x] = J.useState(!1), [C, w] = J.useState(!1), O = n ?? g, k = t?.showFilterToggle !== !1, A = t?.showCommentInput !== !1 && !!s, M = t?.enableReactions ?? !1, N = t?.enableThreading ?? !1, te = t?.showSubscriptionToggle ?? !1, F = J.useMemo(() => wn(e, O), [e, O]), I = J.useMemo(() => N ? F.filter((e) => !e.parentId) : F, [F, N]), ne = J.useMemo(() => {
|
|
3478
|
+
if (!N) return /* @__PURE__ */ new Map();
|
|
3479
|
+
let e = /* @__PURE__ */ new Map();
|
|
3480
|
+
for (let t of F) if (t.parentId) {
|
|
3481
|
+
let n = e.get(t.parentId) ?? [];
|
|
3482
|
+
n.push(t), e.set(t.parentId, n);
|
|
3483
|
+
}
|
|
3484
|
+
return e;
|
|
3485
|
+
}, [F, N]), L = J.useCallback((e) => {
|
|
3486
|
+
r ? r(e) : _(e);
|
|
3487
|
+
}, [r]), R = J.useCallback(async () => {
|
|
3488
|
+
let e = v.trim();
|
|
3489
|
+
if (!(!e || !s)) {
|
|
3490
|
+
x(!0);
|
|
3491
|
+
try {
|
|
3492
|
+
await s(e), y("");
|
|
3493
|
+
} finally {
|
|
3494
|
+
x(!1);
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
}, [v, s]), z = J.useCallback((e) => {
|
|
3498
|
+
e.key === "Enter" && (e.ctrlKey || e.metaKey) && (e.preventDefault(), R());
|
|
3499
|
+
}, [R]), B = J.useCallback(async () => {
|
|
3500
|
+
if (a) {
|
|
3501
|
+
w(!0);
|
|
3502
|
+
try {
|
|
3503
|
+
await a();
|
|
3504
|
+
} finally {
|
|
3505
|
+
w(!1);
|
|
3506
|
+
}
|
|
3507
|
+
}
|
|
3508
|
+
}, [a]);
|
|
3509
|
+
return /* @__PURE__ */ Z(D, {
|
|
3510
|
+
className: q("", h),
|
|
3511
|
+
children: [/* @__PURE__ */ X(c, { children: /* @__PURE__ */ Z("div", {
|
|
3512
|
+
className: "flex items-center justify-between",
|
|
3513
|
+
children: [/* @__PURE__ */ Z(m, {
|
|
3514
|
+
className: "flex items-center gap-2 text-base",
|
|
3515
|
+
children: [
|
|
3516
|
+
/* @__PURE__ */ X(ge, { className: "h-4 w-4" }),
|
|
3517
|
+
"Activity",
|
|
3518
|
+
/* @__PURE__ */ Z("span", {
|
|
3519
|
+
className: "text-sm font-normal text-muted-foreground",
|
|
3520
|
+
children: [
|
|
3521
|
+
"(",
|
|
3522
|
+
F.length,
|
|
3523
|
+
")"
|
|
3524
|
+
]
|
|
3525
|
+
})
|
|
3526
|
+
]
|
|
3527
|
+
}), /* @__PURE__ */ X("div", {
|
|
3528
|
+
className: "flex items-center gap-1",
|
|
3529
|
+
children: te && d && /* @__PURE__ */ X(yn, {
|
|
3530
|
+
subscription: d,
|
|
3531
|
+
onToggle: f
|
|
3532
|
+
})
|
|
3533
|
+
})]
|
|
3534
|
+
}) }), /* @__PURE__ */ Z(j, {
|
|
3535
|
+
className: "space-y-4",
|
|
3536
|
+
children: [
|
|
3537
|
+
k && /* @__PURE__ */ X("div", {
|
|
3538
|
+
className: "flex items-center gap-2",
|
|
3539
|
+
children: /* @__PURE__ */ X("select", {
|
|
3540
|
+
className: "rounded-md border border-input bg-background px-2.5 py-1.5 text-sm focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring",
|
|
3541
|
+
value: O,
|
|
3542
|
+
onChange: (e) => L(e.target.value),
|
|
3543
|
+
"aria-label": "Filter activity",
|
|
3544
|
+
children: Sn.map((e) => /* @__PURE__ */ X("option", {
|
|
3545
|
+
value: e.value,
|
|
3546
|
+
children: e.label
|
|
3547
|
+
}, e.value))
|
|
3548
|
+
})
|
|
3549
|
+
}),
|
|
3550
|
+
A && /* @__PURE__ */ Z("div", {
|
|
3551
|
+
className: "flex gap-2",
|
|
3552
|
+
children: [/* @__PURE__ */ X("textarea", {
|
|
3553
|
+
className: "flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none",
|
|
3554
|
+
placeholder: "Leave a comment… (Ctrl+Enter to submit)",
|
|
3555
|
+
value: v,
|
|
3556
|
+
onChange: (e) => y(e.target.value),
|
|
3557
|
+
onKeyDown: z,
|
|
3558
|
+
disabled: b
|
|
3559
|
+
}), /* @__PURE__ */ X(P, {
|
|
3560
|
+
size: "icon",
|
|
3561
|
+
variant: "default",
|
|
3562
|
+
onClick: R,
|
|
3563
|
+
disabled: !v.trim() || b,
|
|
3564
|
+
className: "shrink-0 self-end",
|
|
3565
|
+
"aria-label": "Submit comment",
|
|
3566
|
+
children: /* @__PURE__ */ X(T, { className: "h-4 w-4" })
|
|
3567
|
+
})]
|
|
3568
|
+
}),
|
|
3569
|
+
F.length === 0 ? p ? null : /* @__PURE__ */ X("p", {
|
|
3570
|
+
className: "text-sm text-muted-foreground text-center py-4",
|
|
3571
|
+
children: "No activity recorded"
|
|
3572
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
3573
|
+
className: "relative",
|
|
3574
|
+
children: [/* @__PURE__ */ X("div", { className: "absolute left-4 top-2 bottom-2 w-px bg-border" }), /* @__PURE__ */ X("div", {
|
|
3575
|
+
className: "space-y-4",
|
|
3576
|
+
children: I.map((e) => {
|
|
3577
|
+
let t = bn[e.type] || S, n = xn[e.type] || "bg-gray-100 text-gray-600", r = ne.get(e.id) ?? [];
|
|
3578
|
+
return /* @__PURE__ */ Z("div", { children: [/* @__PURE__ */ Z("div", {
|
|
3579
|
+
className: "flex gap-3 relative",
|
|
3580
|
+
children: [/* @__PURE__ */ X("div", {
|
|
3581
|
+
className: q("shrink-0 h-8 w-8 rounded-full flex items-center justify-center z-10", n),
|
|
3582
|
+
children: e.actorAvatarUrl ? /* @__PURE__ */ X("img", {
|
|
3583
|
+
src: e.actorAvatarUrl,
|
|
3584
|
+
alt: e.actor,
|
|
3585
|
+
className: "h-8 w-8 rounded-full object-cover"
|
|
3586
|
+
}) : /* @__PURE__ */ X(t, { className: "h-3.5 w-3.5" })
|
|
3587
|
+
}), /* @__PURE__ */ Z("div", {
|
|
3588
|
+
className: "flex-1 min-w-0 pt-1",
|
|
3589
|
+
children: [
|
|
3590
|
+
/* @__PURE__ */ Z("div", {
|
|
3591
|
+
className: "flex items-center gap-2 mb-0.5",
|
|
3592
|
+
children: [
|
|
3593
|
+
/* @__PURE__ */ X("span", {
|
|
3594
|
+
className: "text-sm font-medium",
|
|
3595
|
+
children: e.actor
|
|
3596
|
+
}),
|
|
3597
|
+
e.source && /* @__PURE__ */ Z("span", {
|
|
3598
|
+
className: "text-xs text-muted-foreground",
|
|
3599
|
+
children: ["via ", e.source]
|
|
3600
|
+
}),
|
|
3601
|
+
/* @__PURE__ */ X("span", {
|
|
3602
|
+
className: "text-xs text-muted-foreground",
|
|
3603
|
+
children: Cn(e.createdAt)
|
|
3604
|
+
}),
|
|
3605
|
+
e.edited && /* @__PURE__ */ X("span", {
|
|
3606
|
+
className: "text-xs text-muted-foreground italic",
|
|
3607
|
+
children: "(edited)"
|
|
3608
|
+
}),
|
|
3609
|
+
e.pinned && /* @__PURE__ */ X("span", {
|
|
3610
|
+
className: "text-xs text-amber-600",
|
|
3611
|
+
children: "📌 Pinned"
|
|
3612
|
+
})
|
|
3613
|
+
]
|
|
3614
|
+
}),
|
|
3615
|
+
e.body && /* @__PURE__ */ X("p", {
|
|
3616
|
+
className: "text-sm whitespace-pre-wrap break-words text-muted-foreground",
|
|
3617
|
+
children: e.body
|
|
3618
|
+
}),
|
|
3619
|
+
e.type === "field_change" && e.fieldChanges && /* @__PURE__ */ X("div", {
|
|
3620
|
+
className: "space-y-1 mt-1",
|
|
3621
|
+
children: e.fieldChanges.map((e, t) => /* @__PURE__ */ X(mn, { change: e }, t))
|
|
3622
|
+
}),
|
|
3623
|
+
M && e.reactions && e.reactions.length > 0 && /* @__PURE__ */ X("div", {
|
|
3624
|
+
className: "mt-1.5",
|
|
3625
|
+
children: /* @__PURE__ */ X(gn, {
|
|
3626
|
+
reactions: e.reactions,
|
|
3627
|
+
onToggleReaction: u ? (t) => u(e.id, t) : void 0
|
|
3628
|
+
})
|
|
3629
|
+
}),
|
|
3630
|
+
M && (!e.reactions || e.reactions.length === 0) && u && /* @__PURE__ */ X("div", {
|
|
3631
|
+
className: "mt-1.5",
|
|
3632
|
+
children: /* @__PURE__ */ X(gn, {
|
|
3633
|
+
reactions: [],
|
|
3634
|
+
onToggleReaction: (t) => u(e.id, t)
|
|
3635
|
+
})
|
|
3636
|
+
})
|
|
3637
|
+
]
|
|
3638
|
+
})]
|
|
3639
|
+
}), N && (e.replyCount ?? 0) > 0 && /* @__PURE__ */ X(vn, {
|
|
3640
|
+
parentItem: e,
|
|
3641
|
+
replies: r,
|
|
3642
|
+
onAddReply: l,
|
|
3643
|
+
showReplyInput: !!l
|
|
3644
|
+
})] }, e.id);
|
|
3645
|
+
})
|
|
3646
|
+
})]
|
|
3647
|
+
}),
|
|
3648
|
+
i && /* @__PURE__ */ X("div", {
|
|
3649
|
+
className: "text-center pt-2",
|
|
3650
|
+
children: /* @__PURE__ */ Z(P, {
|
|
3651
|
+
variant: "ghost",
|
|
3652
|
+
size: "sm",
|
|
3653
|
+
onClick: B,
|
|
3654
|
+
disabled: C,
|
|
3655
|
+
"aria-label": "Load more activity",
|
|
3656
|
+
children: [C ? /* @__PURE__ */ X(E, { className: "h-4 w-4 animate-spin mr-1" }) : /* @__PURE__ */ X(ee, { className: "h-4 w-4 mr-1" }), "Load more"]
|
|
3657
|
+
})
|
|
3658
|
+
})
|
|
3659
|
+
]
|
|
3660
|
+
})]
|
|
3661
|
+
});
|
|
3662
|
+
}, En = ({ config: t, items: n, hasMore: r, onLoadMore: i, loading: a, onAddComment: o, onAddReply: s, onToggleReaction: c, subscription: l, onToggleSubscription: u, filterMode: d, onFilterChange: f, collapseWhenEmpty: p = !1, className: m }) => {
|
|
3663
|
+
let h = t?.position ?? "right", g = t?.width ?? "360px", _ = t?.collapsible ?? !0, v = p && n.length === 0 || (t?.defaultCollapsed ?? !1), [y, b] = J.useState(v);
|
|
3664
|
+
return h === "right" || h === "left" ? y && _ ? /* @__PURE__ */ X("div", {
|
|
3665
|
+
className: q("flex items-start pt-4", h === "right" ? "border-l" : "border-r", m),
|
|
3666
|
+
children: /* @__PURE__ */ X(P, {
|
|
3667
|
+
variant: "ghost",
|
|
3668
|
+
size: "icon",
|
|
3669
|
+
className: "h-8 w-8 mx-1",
|
|
3670
|
+
onClick: () => b(!1),
|
|
3671
|
+
"aria-label": "Open discussion panel",
|
|
3672
|
+
children: /* @__PURE__ */ X(Ie, { className: "h-4 w-4" })
|
|
3673
|
+
})
|
|
3674
|
+
}) : /* @__PURE__ */ Z("div", {
|
|
3675
|
+
className: q("flex flex-col overflow-hidden", h === "right" ? "border-l" : "border-r", m),
|
|
3676
|
+
style: {
|
|
3677
|
+
width: g,
|
|
3678
|
+
minWidth: g
|
|
3679
|
+
},
|
|
3680
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
3681
|
+
className: "flex items-center justify-between px-4 py-3 border-b",
|
|
3682
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
3683
|
+
className: "flex items-center gap-2",
|
|
3684
|
+
children: [/* @__PURE__ */ X(T, { className: "h-4 w-4" }), /* @__PURE__ */ X("span", {
|
|
3685
|
+
className: "text-sm font-medium",
|
|
3686
|
+
children: "Discussion"
|
|
3687
|
+
})]
|
|
3688
|
+
}), _ && /* @__PURE__ */ X(P, {
|
|
3689
|
+
variant: "ghost",
|
|
3690
|
+
size: "icon",
|
|
3691
|
+
className: "h-7 w-7",
|
|
3692
|
+
onClick: () => b(!0),
|
|
3693
|
+
"aria-label": "Close discussion panel",
|
|
3694
|
+
children: /* @__PURE__ */ X(e, { className: "h-3.5 w-3.5" })
|
|
3695
|
+
})]
|
|
3696
|
+
}), /* @__PURE__ */ X("div", {
|
|
3697
|
+
className: "flex-1 overflow-y-auto",
|
|
3698
|
+
children: /* @__PURE__ */ X(Tn, {
|
|
3699
|
+
items: n,
|
|
3700
|
+
config: t?.feed,
|
|
3701
|
+
hasMore: r,
|
|
3702
|
+
onLoadMore: i,
|
|
3703
|
+
loading: a,
|
|
3704
|
+
onAddComment: o,
|
|
3705
|
+
onAddReply: s,
|
|
3706
|
+
onToggleReaction: c,
|
|
3707
|
+
subscription: l,
|
|
3708
|
+
onToggleSubscription: u,
|
|
3709
|
+
filterMode: d,
|
|
3710
|
+
onFilterChange: f,
|
|
3711
|
+
collapseWhenEmpty: p,
|
|
3712
|
+
className: "border-0 shadow-none"
|
|
3713
|
+
})
|
|
3714
|
+
})]
|
|
3715
|
+
}) : /* @__PURE__ */ X("div", {
|
|
3716
|
+
className: q("", m),
|
|
3717
|
+
children: _ && y ? /* @__PURE__ */ Z(P, {
|
|
3718
|
+
variant: "ghost",
|
|
3719
|
+
className: "w-full justify-start gap-2 text-muted-foreground",
|
|
3720
|
+
onClick: () => b(!1),
|
|
3721
|
+
"aria-label": "Show discussion",
|
|
3722
|
+
children: [/* @__PURE__ */ X(T, { className: "h-4 w-4" }), /* @__PURE__ */ Z("span", { children: [
|
|
3723
|
+
"Show Discussion (",
|
|
3724
|
+
n.length,
|
|
3725
|
+
")"
|
|
3726
|
+
] })]
|
|
3727
|
+
}) : /* @__PURE__ */ Z("div", { children: [_ && /* @__PURE__ */ Z("div", {
|
|
3728
|
+
className: "flex items-center justify-between mb-2",
|
|
3729
|
+
children: [/* @__PURE__ */ Z("div", {
|
|
3730
|
+
className: "flex items-center gap-2 text-sm font-medium",
|
|
3731
|
+
children: [/* @__PURE__ */ X(T, { className: "h-4 w-4" }), "Discussion"]
|
|
3732
|
+
}), /* @__PURE__ */ X(P, {
|
|
3733
|
+
variant: "ghost",
|
|
3734
|
+
size: "icon",
|
|
3735
|
+
className: "h-7 w-7",
|
|
3736
|
+
onClick: () => b(!0),
|
|
3737
|
+
"aria-label": "Hide discussion",
|
|
3738
|
+
children: /* @__PURE__ */ X(B, { className: "h-3.5 w-3.5" })
|
|
3739
|
+
})]
|
|
3740
|
+
}), /* @__PURE__ */ X(Tn, {
|
|
3741
|
+
items: n,
|
|
3742
|
+
config: t?.feed,
|
|
3743
|
+
hasMore: r,
|
|
3744
|
+
onLoadMore: i,
|
|
3745
|
+
loading: a,
|
|
3746
|
+
onAddComment: o,
|
|
3747
|
+
onAddReply: s,
|
|
3748
|
+
onToggleReaction: c,
|
|
3749
|
+
subscription: l,
|
|
3750
|
+
onToggleSubscription: u,
|
|
3751
|
+
filterMode: d,
|
|
3752
|
+
onFilterChange: f,
|
|
3753
|
+
collapseWhenEmpty: p
|
|
3754
|
+
})] })
|
|
3755
|
+
});
|
|
3756
|
+
}, Dn = ({ onSubmit: e, placeholder: t = "Leave a comment…", disabled: n = !1, className: r }) => {
|
|
3757
|
+
let [i, a] = J.useState(""), [o, s] = J.useState(!1), c = J.useCallback(async () => {
|
|
3758
|
+
let t = i.trim();
|
|
3759
|
+
if (t) {
|
|
3760
|
+
s(!0);
|
|
3761
|
+
try {
|
|
3762
|
+
await e(t), a("");
|
|
3763
|
+
} finally {
|
|
3764
|
+
s(!1);
|
|
3765
|
+
}
|
|
3766
|
+
}
|
|
3767
|
+
}, [i, e]), l = J.useCallback((e) => {
|
|
3768
|
+
e.key === "Enter" && (e.ctrlKey || e.metaKey) && (e.preventDefault(), c());
|
|
3769
|
+
}, [c]);
|
|
3770
|
+
return /* @__PURE__ */ Z("div", {
|
|
3771
|
+
className: q("flex gap-2", r),
|
|
3772
|
+
children: [/* @__PURE__ */ X("textarea", {
|
|
3773
|
+
className: "flex-1 min-h-[60px] rounded-md border border-input bg-background px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring resize-none",
|
|
3774
|
+
placeholder: t,
|
|
3775
|
+
value: i,
|
|
3776
|
+
onChange: (e) => a(e.target.value),
|
|
3777
|
+
onKeyDown: l,
|
|
3778
|
+
disabled: n || o
|
|
3779
|
+
}), /* @__PURE__ */ X(P, {
|
|
3780
|
+
size: "icon",
|
|
3781
|
+
variant: "default",
|
|
3782
|
+
onClick: c,
|
|
3783
|
+
disabled: !i.trim() || o || n,
|
|
3784
|
+
className: "shrink-0 self-end",
|
|
3785
|
+
"aria-label": "Submit comment",
|
|
3786
|
+
children: /* @__PURE__ */ X(je, { className: "h-4 w-4" })
|
|
3787
|
+
})]
|
|
3788
|
+
});
|
|
3789
|
+
}, On = ({ query: e, suggestions: t, onSelect: n, visible: r = !0, activeIndex: i = 0, className: a }) => {
|
|
3790
|
+
let o = J.useMemo(() => {
|
|
3791
|
+
if (!e) return t;
|
|
3792
|
+
let n = e.toLowerCase();
|
|
3793
|
+
return t.filter((e) => e.name.toLowerCase().includes(n) || e.id.toLowerCase().includes(n));
|
|
3794
|
+
}, [e, t]);
|
|
3795
|
+
return !r || o.length === 0 ? null : /* @__PURE__ */ X("div", {
|
|
3796
|
+
className: q("bg-popover border rounded-md shadow-md z-50 max-h-48 overflow-y-auto w-56", a),
|
|
3797
|
+
role: "listbox",
|
|
3798
|
+
"aria-label": "Mention suggestions",
|
|
3799
|
+
children: o.map((e, t) => /* @__PURE__ */ Z("button", {
|
|
3800
|
+
type: "button",
|
|
3801
|
+
role: "option",
|
|
3802
|
+
"aria-selected": t === i,
|
|
3803
|
+
className: q("w-full text-left px-3 py-1.5 text-sm flex items-center gap-2 hover:bg-accent transition-colors", t === i && "bg-accent"),
|
|
3804
|
+
onMouseDown: (t) => {
|
|
3805
|
+
t.preventDefault(), n(e);
|
|
3806
|
+
},
|
|
3807
|
+
children: [e.avatarUrl ? /* @__PURE__ */ X("img", {
|
|
3808
|
+
src: e.avatarUrl,
|
|
3809
|
+
alt: e.name,
|
|
3810
|
+
className: "h-5 w-5 rounded-full object-cover"
|
|
3811
|
+
}) : /* @__PURE__ */ X("div", {
|
|
3812
|
+
className: "h-5 w-5 rounded-full bg-muted flex items-center justify-center text-[10px] font-medium",
|
|
3813
|
+
children: e.name.charAt(0).toUpperCase()
|
|
3814
|
+
}), /* @__PURE__ */ Z("div", {
|
|
3815
|
+
className: "flex-1 min-w-0",
|
|
3816
|
+
children: [/* @__PURE__ */ X("span", {
|
|
3817
|
+
className: "truncate",
|
|
3818
|
+
children: e.name
|
|
3819
|
+
}), e.type !== "user" && /* @__PURE__ */ Z("span", {
|
|
3820
|
+
className: "ml-1 text-xs text-muted-foreground capitalize",
|
|
3821
|
+
children: [
|
|
3822
|
+
"(",
|
|
3823
|
+
e.type,
|
|
3824
|
+
")"
|
|
3825
|
+
]
|
|
3826
|
+
})]
|
|
3827
|
+
})]
|
|
3828
|
+
}, e.id))
|
|
3829
|
+
});
|
|
3830
|
+
};
|
|
3831
|
+
function kn(e, t, n) {
|
|
3832
|
+
return {
|
|
3833
|
+
type: e.type,
|
|
3834
|
+
id: e.id,
|
|
3835
|
+
name: e.name,
|
|
3836
|
+
offset: t,
|
|
3837
|
+
length: n
|
|
3838
|
+
};
|
|
3839
|
+
}
|
|
3840
|
+
ve.register("detail-view", Gt, {
|
|
3841
|
+
namespace: "plugin-detail",
|
|
3842
|
+
label: "Detail View",
|
|
3843
|
+
category: "Views",
|
|
3844
|
+
icon: "FileText",
|
|
3845
|
+
inputs: [
|
|
3846
|
+
{
|
|
3847
|
+
name: "title",
|
|
3848
|
+
type: "string",
|
|
3849
|
+
label: "Title"
|
|
3850
|
+
},
|
|
3851
|
+
{
|
|
3852
|
+
name: "objectName",
|
|
3853
|
+
type: "string",
|
|
3854
|
+
label: "Object Name"
|
|
3855
|
+
},
|
|
3856
|
+
{
|
|
3857
|
+
name: "resourceId",
|
|
3858
|
+
type: "string",
|
|
3859
|
+
label: "Resource ID"
|
|
3860
|
+
},
|
|
3861
|
+
{
|
|
3862
|
+
name: "api",
|
|
3863
|
+
type: "string",
|
|
3864
|
+
label: "API Endpoint"
|
|
3865
|
+
},
|
|
3866
|
+
{
|
|
3867
|
+
name: "data",
|
|
3868
|
+
type: "object",
|
|
3869
|
+
label: "Data"
|
|
3870
|
+
},
|
|
3871
|
+
{
|
|
3872
|
+
name: "layout",
|
|
3873
|
+
type: "enum",
|
|
3874
|
+
label: "Layout Mode",
|
|
3875
|
+
enum: [
|
|
3876
|
+
"vertical",
|
|
3877
|
+
"horizontal",
|
|
3878
|
+
"grid"
|
|
3879
|
+
]
|
|
3880
|
+
},
|
|
3881
|
+
{
|
|
3882
|
+
name: "columns",
|
|
3883
|
+
type: "number",
|
|
3884
|
+
label: "Grid Columns"
|
|
3885
|
+
},
|
|
3886
|
+
{
|
|
3887
|
+
name: "sections",
|
|
3888
|
+
type: "array",
|
|
3889
|
+
label: "Sections"
|
|
3890
|
+
},
|
|
3891
|
+
{
|
|
3892
|
+
name: "fields",
|
|
3893
|
+
type: "array",
|
|
3894
|
+
label: "Fields"
|
|
3895
|
+
},
|
|
3896
|
+
{
|
|
3897
|
+
name: "tabs",
|
|
3898
|
+
type: "array",
|
|
3899
|
+
label: "Tabs"
|
|
3900
|
+
},
|
|
3901
|
+
{
|
|
3902
|
+
name: "related",
|
|
3903
|
+
type: "array",
|
|
3904
|
+
label: "Related Lists"
|
|
3905
|
+
},
|
|
3906
|
+
{
|
|
3907
|
+
name: "actions",
|
|
3908
|
+
type: "array",
|
|
3909
|
+
label: "Actions"
|
|
3910
|
+
},
|
|
3911
|
+
{
|
|
3912
|
+
name: "showBack",
|
|
3913
|
+
type: "boolean",
|
|
3914
|
+
label: "Show Back Button",
|
|
3915
|
+
defaultValue: !0
|
|
3916
|
+
},
|
|
3917
|
+
{
|
|
3918
|
+
name: "backUrl",
|
|
3919
|
+
type: "string",
|
|
3920
|
+
label: "Back URL"
|
|
3921
|
+
},
|
|
3922
|
+
{
|
|
3923
|
+
name: "showEdit",
|
|
3924
|
+
type: "boolean",
|
|
3925
|
+
label: "Show Edit Button",
|
|
3926
|
+
defaultValue: !1
|
|
3927
|
+
},
|
|
3928
|
+
{
|
|
3929
|
+
name: "editUrl",
|
|
3930
|
+
type: "string",
|
|
3931
|
+
label: "Edit URL"
|
|
3932
|
+
},
|
|
3933
|
+
{
|
|
3934
|
+
name: "showDelete",
|
|
3935
|
+
type: "boolean",
|
|
3936
|
+
label: "Show Delete Button",
|
|
3937
|
+
defaultValue: !1
|
|
3938
|
+
},
|
|
3939
|
+
{
|
|
3940
|
+
name: "deleteConfirmation",
|
|
3941
|
+
type: "string",
|
|
3942
|
+
label: "Delete Confirmation Message"
|
|
3943
|
+
},
|
|
3944
|
+
{
|
|
3945
|
+
name: "loading",
|
|
3946
|
+
type: "boolean",
|
|
3947
|
+
label: "Show Loading State"
|
|
3948
|
+
},
|
|
3949
|
+
{
|
|
3950
|
+
name: "header",
|
|
3951
|
+
type: "object",
|
|
3952
|
+
label: "Custom Header"
|
|
3953
|
+
},
|
|
3954
|
+
{
|
|
3955
|
+
name: "footer",
|
|
3956
|
+
type: "object",
|
|
3957
|
+
label: "Custom Footer"
|
|
3958
|
+
}
|
|
3959
|
+
],
|
|
3960
|
+
defaultProps: {
|
|
3961
|
+
title: "Detail View",
|
|
3962
|
+
showBack: !0,
|
|
3963
|
+
showEdit: !1,
|
|
3964
|
+
showDelete: !1,
|
|
3965
|
+
sections: [],
|
|
3966
|
+
fields: [],
|
|
3967
|
+
tabs: [],
|
|
3968
|
+
related: []
|
|
3969
|
+
}
|
|
3970
|
+
}), ve.register("detail-section", jt, {
|
|
3971
|
+
namespace: "plugin-detail",
|
|
3972
|
+
label: "Detail Section",
|
|
3973
|
+
category: "Detail Components",
|
|
3974
|
+
inputs: [
|
|
3975
|
+
{
|
|
3976
|
+
name: "title",
|
|
3977
|
+
type: "string",
|
|
3978
|
+
label: "Title"
|
|
3979
|
+
},
|
|
3980
|
+
{
|
|
3981
|
+
name: "description",
|
|
3982
|
+
type: "string",
|
|
3983
|
+
label: "Description"
|
|
3984
|
+
},
|
|
3985
|
+
{
|
|
3986
|
+
name: "fields",
|
|
3987
|
+
type: "array",
|
|
3988
|
+
label: "Fields",
|
|
3989
|
+
required: !0
|
|
3990
|
+
},
|
|
3991
|
+
{
|
|
3992
|
+
name: "collapsible",
|
|
3993
|
+
type: "boolean",
|
|
3994
|
+
label: "Collapsible",
|
|
3995
|
+
defaultValue: !1
|
|
3996
|
+
},
|
|
3997
|
+
{
|
|
3998
|
+
name: "defaultCollapsed",
|
|
3999
|
+
type: "boolean",
|
|
4000
|
+
label: "Default Collapsed",
|
|
4001
|
+
defaultValue: !1
|
|
4002
|
+
},
|
|
4003
|
+
{
|
|
4004
|
+
name: "columns",
|
|
4005
|
+
type: "number",
|
|
4006
|
+
label: "Columns",
|
|
4007
|
+
defaultValue: 2
|
|
4008
|
+
},
|
|
4009
|
+
{
|
|
4010
|
+
name: "showBorder",
|
|
4011
|
+
type: "boolean",
|
|
4012
|
+
label: "Show Border",
|
|
4013
|
+
defaultValue: !0
|
|
4014
|
+
},
|
|
4015
|
+
{
|
|
4016
|
+
name: "headerColor",
|
|
4017
|
+
type: "string",
|
|
4018
|
+
label: "Header Color"
|
|
4019
|
+
}
|
|
4020
|
+
]
|
|
4021
|
+
}), ve.register("related-list", Nt, {
|
|
4022
|
+
namespace: "plugin-detail",
|
|
4023
|
+
label: "Related List",
|
|
4024
|
+
category: "Detail Components",
|
|
4025
|
+
inputs: [
|
|
4026
|
+
{
|
|
4027
|
+
name: "title",
|
|
4028
|
+
type: "string",
|
|
4029
|
+
label: "Title",
|
|
4030
|
+
required: !0
|
|
4031
|
+
},
|
|
4032
|
+
{
|
|
4033
|
+
name: "type",
|
|
4034
|
+
type: "enum",
|
|
4035
|
+
label: "Type",
|
|
4036
|
+
enum: [
|
|
4037
|
+
{
|
|
4038
|
+
label: "List",
|
|
4039
|
+
value: "list"
|
|
4040
|
+
},
|
|
4041
|
+
{
|
|
4042
|
+
label: "Grid",
|
|
4043
|
+
value: "grid"
|
|
4044
|
+
},
|
|
4045
|
+
{
|
|
4046
|
+
label: "Table",
|
|
4047
|
+
value: "table"
|
|
4048
|
+
}
|
|
4049
|
+
],
|
|
4050
|
+
defaultValue: "table"
|
|
4051
|
+
},
|
|
4052
|
+
{
|
|
4053
|
+
name: "api",
|
|
4054
|
+
type: "string",
|
|
4055
|
+
label: "API Endpoint"
|
|
4056
|
+
},
|
|
4057
|
+
{
|
|
4058
|
+
name: "data",
|
|
4059
|
+
type: "array",
|
|
4060
|
+
label: "Data"
|
|
4061
|
+
},
|
|
4062
|
+
{
|
|
4063
|
+
name: "columns",
|
|
4064
|
+
type: "array",
|
|
4065
|
+
label: "Columns"
|
|
4066
|
+
}
|
|
4067
|
+
]
|
|
4068
|
+
}), ve.register("detail", Gt, {
|
|
4069
|
+
namespace: "view",
|
|
4070
|
+
category: "view",
|
|
4071
|
+
label: "Detail",
|
|
4072
|
+
icon: "FileText",
|
|
4073
|
+
inputs: [
|
|
4074
|
+
{
|
|
4075
|
+
name: "objectName",
|
|
4076
|
+
type: "string",
|
|
4077
|
+
label: "Object Name",
|
|
4078
|
+
required: !0
|
|
4079
|
+
},
|
|
4080
|
+
{
|
|
4081
|
+
name: "recordId",
|
|
4082
|
+
type: "string",
|
|
4083
|
+
label: "Record ID"
|
|
4084
|
+
},
|
|
4085
|
+
{
|
|
4086
|
+
name: "fields",
|
|
4087
|
+
type: "array",
|
|
4088
|
+
label: "Fields"
|
|
4089
|
+
}
|
|
4090
|
+
]
|
|
4091
|
+
});
|
|
4092
|
+
//#endregion
|
|
4093
|
+
export { Ut as ActivityTimeline, dn as CommentAttachment, Dn as CommentInput, Ot as DETAIL_DEFAULT_TRANSLATIONS, jt as DetailSection, Mt as DetailTabs, Gt as DetailView, $t as DiffView, mn as FieldChangeItem, Ft as HeaderHighlight, Kt as InlineCreateRelated, On as MentionAutocomplete, pn as PointInTimeRestore, gn as ReactionPicker, Tn as RecordActivityTimeline, En as RecordChatterPanel, Lt as RecordComments, en as RecordNavigationEnhanced, Nt as RelatedList, sn as RelationshipGraph, Jt as RichTextCommentInput, Pt as SectionGroup, yn as SubscriptionToggle, vn as ThreadedReplies, Tt as applyAutoSpan, Et as applyDetailAutoLayout, kn as createMentionFromSuggestion, Dt as createSafeTranslationHook, wt as inferDetailColumns, Ct as isWideFieldType, kt as useDetailTranslation };
|