@object-ui/plugin-detail 3.3.0 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.md +21 -1
- package/dist/AddressField-LgHnO2Lk.js +98 -0
- package/dist/AutoNumberField-xZCrU0eW.js +14 -0
- package/dist/{AvatarField-Xuieq0ZI.js → AvatarField-Dy2XGlPz.js} +16 -15
- package/dist/{BooleanField-DwfMKknK.js → BooleanField-C0Clfka5.js} +11 -10
- package/dist/CodeField-CHUa07B6.js +23 -0
- package/dist/ColorField-vxHqEhcS.js +38 -0
- package/dist/CurrencyField-DiWjYWDo.js +49 -0
- package/dist/DateField-DGaRPM4P.js +22 -0
- package/dist/DateTimeField-8QnpsI_h.js +30 -0
- package/dist/EmailField-CkVgMbpI.js +26 -0
- package/dist/FileField-5UPV7uek.js +149 -0
- package/dist/FormulaField-BUgt6-Pi.js +17 -0
- package/dist/GeolocationField-D9T_jgG6.js +118 -0
- package/dist/GridField-DE_HwiIN.js +49 -0
- package/dist/ImageField-Dswnqtzf.js +73 -0
- package/dist/LocationField-gjqbE6na.js +36 -0
- package/dist/LookupField-BcS3LRKc.js +901 -0
- package/dist/{MasterDetailField-B0HTmmD7.js → MasterDetailField-BF6_-X3A.js} +20 -19
- package/dist/NumberField-Dj2rYmrS.js +27 -0
- package/dist/ObjectField-BymIojwd.js +50 -0
- package/dist/{PasswordField-DVTimsc3.js → PasswordField-ED_Xgqz-.js} +8 -7
- package/dist/PercentField-D-JKOxKC.js +61 -0
- package/dist/PhoneField-DSCaGYq7.js +26 -0
- package/dist/QRCodeField-CtcOUapi.js +73 -0
- package/dist/{RatingField-rRi_P0N0.js → RatingField-BDnyQFWy.js} +10 -9
- package/dist/RichTextField-CH6LVZQA.js +33 -0
- package/dist/SelectField-DE4dpkMV.js +36 -0
- package/dist/{SignatureField-2CnhcWI0.js → SignatureField-B1wh3f5A.js} +18 -17
- package/dist/{SliderField-DEpMVXko.js → SliderField-zoTCKh9n.js} +2 -1
- package/dist/SummaryField-BeBVT6VN.js +22 -0
- package/dist/TextAreaField-rfUGrRxh.js +37 -0
- package/dist/TextField-C_yM7ATQ.js +30 -0
- package/dist/TimeField-BcQmBZi9.js +22 -0
- package/dist/UrlField-BakaF6NI.js +31 -0
- package/dist/UserField-zS7y3eKb.js +76 -0
- package/dist/VectorField-CTZ4myDM.js +34 -0
- package/dist/index.js +1912 -1728
- package/dist/index.umd.cjs +38 -47
- package/dist/packages/plugin-detail/src/DetailSection.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/DetailView.d.ts +24 -0
- package/dist/packages/plugin-detail/src/DetailView.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/RelatedList.d.ts +8 -0
- package/dist/packages/plugin-detail/src/RelatedList.d.ts.map +1 -1
- package/dist/packages/plugin-detail/src/useDetailTranslation.d.ts.map +1 -1
- package/dist/plugin-detail.css +1 -2
- package/dist/rolldown-runtime-DnwLefa7.js +23 -0
- package/dist/{src-C56Ly5uG.js → src-DyUKLvMN.js} +18271 -26636
- package/dist/{useFieldTranslation-CkxqyB82.js → useFieldTranslation-BRgjC1oq.js} +1 -1
- package/package.json +33 -11
- package/.turbo/turbo-build.log +0 -64
- package/dist/AddressField-CDLSeyNx.js +0 -93
- package/dist/AutoNumberField-CtE7suf5.js +0 -14
- package/dist/CodeField-CfwgRxx2.js +0 -22
- package/dist/ColorField-YKHA7dBD.js +0 -37
- package/dist/CurrencyField-tvS3fPAF.js +0 -51
- package/dist/DateField-BKqXpkOh.js +0 -21
- package/dist/DateTimeField-CR-nJCE7.js +0 -32
- package/dist/EmailField-CgvW1Qal.js +0 -28
- package/dist/FileField-BVAme2ML.js +0 -151
- package/dist/FormulaField-DamJ2VaG.js +0 -14
- package/dist/GeolocationField-C99z7ZBM.js +0 -113
- package/dist/GridField-C9JbpTx_.js +0 -51
- package/dist/ImageField-CDANtgVV.js +0 -75
- package/dist/LocationField-ZSyZ0O-h.js +0 -35
- package/dist/LookupField-B3hQJt95.js +0 -903
- package/dist/LookupField-D00z6gn_.js +0 -2
- package/dist/NumberField-DL2QAL7X.js +0 -26
- package/dist/ObjectField-JYvUnuRO.js +0 -52
- package/dist/PercentField-DjR6BSpw.js +0 -63
- package/dist/PhoneField-CX1JL-jp.js +0 -28
- package/dist/QRCodeField-CH_1pU6R.js +0 -72
- package/dist/RichTextField-CJqLWlrb.js +0 -32
- package/dist/SelectField-DGoDoRM_.js +0 -30
- package/dist/SelectField-XBVI50AD.js +0 -2
- package/dist/SummaryField-7ch9aqAu.js +0 -19
- package/dist/TextAreaField-Cmw1oXcw.js +0 -36
- package/dist/TextField-OTLa3p51.js +0 -29
- package/dist/TimeField-DKPoNWoR.js +0 -21
- package/dist/UrlField-CxbmzP9f.js +0 -33
- package/dist/UserField-ChvwUkMK.js +0 -78
- package/dist/VectorField-BVClL8Vw.js +0 -36
- package/src/ActivityTimeline.tsx +0 -184
- package/src/CommentAttachment.tsx +0 -194
- package/src/CommentInput.tsx +0 -81
- package/src/DetailSection.tsx +0 -340
- package/src/DetailTabs.tsx +0 -73
- package/src/DetailView.stories.tsx +0 -334
- package/src/DetailView.tsx +0 -823
- package/src/DiffView.tsx +0 -233
- package/src/FieldChangeItem.tsx +0 -46
- package/src/HeaderHighlight.tsx +0 -88
- package/src/InlineCreateRelated.tsx +0 -291
- package/src/MentionAutocomplete.tsx +0 -123
- package/src/PointInTimeRestore.tsx +0 -261
- package/src/ReactionPicker.tsx +0 -106
- package/src/RecordActivityTimeline.tsx +0 -433
- package/src/RecordChatterPanel.tsx +0 -209
- package/src/RecordComments.tsx +0 -217
- package/src/RecordNavigationEnhanced.tsx +0 -213
- package/src/RelatedList.tsx +0 -413
- package/src/RelationshipGraph.tsx +0 -286
- package/src/RichTextCommentInput.tsx +0 -350
- package/src/SectionGroup.tsx +0 -101
- package/src/SubscriptionToggle.tsx +0 -62
- package/src/ThreadedReplies.tsx +0 -163
- package/src/__tests__/ActivityTimeline.test.tsx +0 -119
- package/src/__tests__/ActivityTimelineFiltering.test.tsx +0 -143
- package/src/__tests__/CommentInput.test.tsx +0 -57
- package/src/__tests__/DetailSection.test.tsx +0 -490
- package/src/__tests__/DetailView.test.tsx +0 -694
- package/src/__tests__/FieldChangeItem.test.tsx +0 -119
- package/src/__tests__/HeaderHighlight.test.tsx +0 -213
- package/src/__tests__/MentionAutocomplete.test.tsx +0 -97
- package/src/__tests__/ReactionPicker.test.tsx +0 -113
- package/src/__tests__/RecordActivityTimeline.test.tsx +0 -395
- package/src/__tests__/RecordChatterPanel.test.tsx +0 -265
- package/src/__tests__/RecordComments.test.tsx +0 -96
- package/src/__tests__/RecordCommentsPinSearch.test.tsx +0 -133
- package/src/__tests__/RelatedList.test.tsx +0 -160
- package/src/__tests__/SectionGroup.test.tsx +0 -101
- package/src/__tests__/SubscriptionToggle.test.tsx +0 -84
- package/src/__tests__/ThreadedReplies.test.tsx +0 -212
- package/src/__tests__/autoLayout.test.ts +0 -228
- package/src/__tests__/phase12-features.test.tsx +0 -583
- package/src/__tests__/roadmap-features.test.tsx +0 -478
- package/src/autoLayout.ts +0 -128
- package/src/index.tsx +0 -149
- package/src/useDetailTranslation.ts +0 -183
- package/tsconfig.json +0 -18
- package/vite.config.ts +0 -57
- package/vitest.config.ts +0 -13
- package/vitest.setup.ts +0 -1
|
@@ -0,0 +1,901 @@
|
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DnwLefa7.js";
|
|
2
|
+
import { $ as t, $t as n, A as r, Bt as i, C as ee, D as a, E as o, Kt as te, M as ne, N as s, O as c, P as l, Qt as re, R as ie, S as ae, T as oe, U as u, Ut as se, Wt as ce, X as le, an as ue, at as de, b as fe, c as pe, d as me, dt as he, f as d, j as ge, k as f, l as p, ln as m, q as h, rn as _e, s as g, st as ve, t as ye, u as _, w as v, x as be, xt as xe, y } from "./src-DyUKLvMN.js";
|
|
3
|
+
import { t as b } from "./useFieldTranslation-BRgjC1oq.js";
|
|
4
|
+
import { useCallback as x, useContext as S, useEffect as C, useMemo as w, useRef as T, useState as E } from "react";
|
|
5
|
+
import { Fragment as Se, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
6
|
+
//#region ../fields/src/widgets/RecordPickerDialog.tsx
|
|
7
|
+
var k = 10, Ce = 60, A = 5;
|
|
8
|
+
function j(e) {
|
|
9
|
+
return typeof e == "string" ? { field: e } : e;
|
|
10
|
+
}
|
|
11
|
+
function M(e) {
|
|
12
|
+
return e.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
13
|
+
}
|
|
14
|
+
function we(e) {
|
|
15
|
+
let t = {};
|
|
16
|
+
for (let n of e) switch (n.operator) {
|
|
17
|
+
case "eq":
|
|
18
|
+
t[n.field] = n.value;
|
|
19
|
+
break;
|
|
20
|
+
case "ne":
|
|
21
|
+
t[n.field] = { $ne: n.value };
|
|
22
|
+
break;
|
|
23
|
+
case "gt":
|
|
24
|
+
t[n.field] = { $gt: n.value };
|
|
25
|
+
break;
|
|
26
|
+
case "lt":
|
|
27
|
+
t[n.field] = { $lt: n.value };
|
|
28
|
+
break;
|
|
29
|
+
case "gte":
|
|
30
|
+
t[n.field] = { $gte: n.value };
|
|
31
|
+
break;
|
|
32
|
+
case "lte":
|
|
33
|
+
t[n.field] = { $lte: n.value };
|
|
34
|
+
break;
|
|
35
|
+
case "contains":
|
|
36
|
+
t[n.field] = { $contains: n.value };
|
|
37
|
+
break;
|
|
38
|
+
case "in":
|
|
39
|
+
t[n.field] = { $in: n.value };
|
|
40
|
+
break;
|
|
41
|
+
case "notIn":
|
|
42
|
+
t[n.field] = { $nin: n.value };
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
return t;
|
|
46
|
+
}
|
|
47
|
+
function Te(e, t) {
|
|
48
|
+
let n = {};
|
|
49
|
+
for (let r of t) {
|
|
50
|
+
let t = e[r.field];
|
|
51
|
+
t == null || t === "" || (r.type === "boolean" ? n[r.field] = !!t : r.type === "text" ? n[r.field] = { $contains: t } : n[r.field] = t);
|
|
52
|
+
}
|
|
53
|
+
return n;
|
|
54
|
+
}
|
|
55
|
+
function Ee({ open: e, onOpenChange: t, title: a = "Select Record", multiple: o = !1, dataSource: oe, objectName: u, columns: he, displayField: m = "name", idField: ye = "id", pageSize: b = k, value: S, onSelect: Ee, onSelectRecords: N, lookupFilters: P, cellRenderer: De, filterColumns: F, renderFilterBar: Oe, renderGrid: ke }) {
|
|
56
|
+
let [I, Ae] = E([]), [L, R] = E(!1), [z, B] = E(null), [V, H] = E(0), [U, je] = E(""), [W, G] = E(1), K = T(null), [q, Me] = E(null), [J, Ne] = E("asc"), [Pe, Fe] = E(/* @__PURE__ */ new Set()), Ie = T(/* @__PURE__ */ new Map()), [Y, Le] = E(-1), Re = T(null), [ze, Be] = E(!1), [X, Ve] = E({}), [He, Ue] = E({}), We = T(null), [Ge, Ke] = E(""), qe = w(() => he && he.length > 0 ? he.map(j) : [{
|
|
57
|
+
field: m,
|
|
58
|
+
label: M(m)
|
|
59
|
+
}], [he, m]), Z = w(() => {
|
|
60
|
+
if (F && F.length > 0) return F;
|
|
61
|
+
if (P && P.length > 0) return P.map((e) => {
|
|
62
|
+
let t = "text";
|
|
63
|
+
return typeof e.value == "boolean" ? t = "boolean" : Array.isArray(e.value) ? t = "select" : typeof e.value == "number" || e.operator === "gt" || e.operator === "lt" || e.operator === "gte" || e.operator === "lte" ? t = "number" : (e.operator === "in" || e.operator === "notIn") && (t = "select"), {
|
|
64
|
+
field: e.field,
|
|
65
|
+
label: M(e.field),
|
|
66
|
+
type: t,
|
|
67
|
+
...Array.isArray(e.value) ? { options: e.value.map((e) => {
|
|
68
|
+
if (typeof e == "object" && e) {
|
|
69
|
+
let t = e;
|
|
70
|
+
return {
|
|
71
|
+
label: String(t.name || t.label || t.title || e),
|
|
72
|
+
value: e
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return {
|
|
76
|
+
label: String(e),
|
|
77
|
+
value: e
|
|
78
|
+
};
|
|
79
|
+
}) } : {}
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
}, [F, P]), Je = w(() => {
|
|
83
|
+
let e = P?.length ? we(P) : {}, t = Z?.length ? Te(X, Z) : {}, n = {
|
|
84
|
+
...e,
|
|
85
|
+
...t
|
|
86
|
+
};
|
|
87
|
+
return Object.keys(n).length > 0 ? n : void 0;
|
|
88
|
+
}, [
|
|
89
|
+
P,
|
|
90
|
+
Z,
|
|
91
|
+
X
|
|
92
|
+
]), Q = Math.max(1, Math.ceil(V / b)), Ye = x(async (e, t = 1, n, r) => {
|
|
93
|
+
if (!(!oe || !u)) {
|
|
94
|
+
R(!0), B(null);
|
|
95
|
+
try {
|
|
96
|
+
let i = {
|
|
97
|
+
$top: b,
|
|
98
|
+
$skip: (t - 1) * b
|
|
99
|
+
};
|
|
100
|
+
e && e.trim() && (i.$search = e.trim()), n && (i.$orderby = { [n.field]: n.direction });
|
|
101
|
+
let ee = r === void 0 ? Je : r;
|
|
102
|
+
ee && Object.keys(ee).length > 0 && (i.$filter = ee);
|
|
103
|
+
let a = await oe.find(u, i), o = a?.data ?? a ?? [];
|
|
104
|
+
Ae(o), H(a?.total ?? o.length), Le(-1);
|
|
105
|
+
} catch (e) {
|
|
106
|
+
B(e instanceof Error ? e.message : String(e)), Ae([]);
|
|
107
|
+
} finally {
|
|
108
|
+
R(!1);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}, [
|
|
112
|
+
oe,
|
|
113
|
+
u,
|
|
114
|
+
b,
|
|
115
|
+
Je
|
|
116
|
+
]), Xe = w(() => q ? {
|
|
117
|
+
field: q,
|
|
118
|
+
direction: J
|
|
119
|
+
} : null, [q, J]);
|
|
120
|
+
C(() => {
|
|
121
|
+
e || (je(""), G(1), B(null), Ae([]), Me(null), Ne("asc"), Le(-1), Be(!1), Ve({}), Ue({}), Ke(""), Fe(new Set(o && Array.isArray(S) ? S : [])), Ie.current.clear());
|
|
122
|
+
}, [e]), C(() => {
|
|
123
|
+
e && Ye(U || void 0, W, Xe);
|
|
124
|
+
}, [
|
|
125
|
+
e,
|
|
126
|
+
W,
|
|
127
|
+
Xe,
|
|
128
|
+
Je
|
|
129
|
+
]), C(() => {
|
|
130
|
+
e && o && Fe(new Set(Array.isArray(S) ? S : []));
|
|
131
|
+
}, [
|
|
132
|
+
e,
|
|
133
|
+
o,
|
|
134
|
+
S
|
|
135
|
+
]);
|
|
136
|
+
let Ze = x((e) => {
|
|
137
|
+
je(e), G(1), K.current && clearTimeout(K.current), K.current = setTimeout(() => {
|
|
138
|
+
Ye(e || void 0, 1, Xe);
|
|
139
|
+
}, 300);
|
|
140
|
+
}, [Ye, Xe]);
|
|
141
|
+
C(() => () => {
|
|
142
|
+
K.current && clearTimeout(K.current);
|
|
143
|
+
}, []);
|
|
144
|
+
let Qe = x((e) => {
|
|
145
|
+
Me((t) => t === e ? (Ne((e) => e === "asc" ? "desc" : "asc"), e) : (Ne("asc"), e)), G(1);
|
|
146
|
+
}, []), $e = x((e) => e[ye] ?? e.id ?? e._id, [ye]), et = x((e) => {
|
|
147
|
+
let t = $e(e);
|
|
148
|
+
return o ? Pe.has(t) : S === t;
|
|
149
|
+
}, [
|
|
150
|
+
o,
|
|
151
|
+
S,
|
|
152
|
+
Pe,
|
|
153
|
+
$e
|
|
154
|
+
]), tt = x((e) => {
|
|
155
|
+
let n = $e(e);
|
|
156
|
+
o ? Fe((t) => {
|
|
157
|
+
let r = new Set(t);
|
|
158
|
+
return r.has(n) ? (r.delete(n), Ie.current.delete(n)) : (r.add(n), Ie.current.set(n, e)), r;
|
|
159
|
+
}) : (Ee(n), N?.([e]), t(!1));
|
|
160
|
+
}, [
|
|
161
|
+
o,
|
|
162
|
+
$e,
|
|
163
|
+
Ee,
|
|
164
|
+
N,
|
|
165
|
+
t
|
|
166
|
+
]), nt = x(() => {
|
|
167
|
+
let e = Array.from(Pe);
|
|
168
|
+
Ee(e);
|
|
169
|
+
let n = e.map((e) => Ie.current.get(e)).filter(Boolean);
|
|
170
|
+
N?.(n), t(!1);
|
|
171
|
+
}, [
|
|
172
|
+
Pe,
|
|
173
|
+
Ee,
|
|
174
|
+
N,
|
|
175
|
+
t
|
|
176
|
+
]), rt = x(() => {
|
|
177
|
+
G((e) => Math.max(1, e - 1));
|
|
178
|
+
}, []), it = x(() => {
|
|
179
|
+
G((e) => Math.min(Q, e + 1));
|
|
180
|
+
}, [Q]), at = x((e) => {
|
|
181
|
+
if (e.key !== "Enter") return;
|
|
182
|
+
let t = parseInt(Ge, 10);
|
|
183
|
+
!isNaN(t) && t >= 1 && t <= Q && G(t), Ke("");
|
|
184
|
+
}, [Ge, Q]), ot = x((e) => {
|
|
185
|
+
I.length !== 0 && (e.key === "ArrowDown" ? (e.preventDefault(), Le((e) => Math.min(e + 1, I.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), Le((e) => Math.max(e - 1, 0))) : (e.key === "Enter" || e.key === " ") && (e.preventDefault(), Y >= 0 && Y < I.length && tt(I[Y])));
|
|
186
|
+
}, [
|
|
187
|
+
I,
|
|
188
|
+
Y,
|
|
189
|
+
tt
|
|
190
|
+
]);
|
|
191
|
+
C(() => {
|
|
192
|
+
if (Y >= 0 && Re.current) {
|
|
193
|
+
let e = Re.current.querySelector(`[data-row-index="${Y}"]`);
|
|
194
|
+
e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
|
|
195
|
+
}
|
|
196
|
+
}, [Y]);
|
|
197
|
+
let st = x((e, t) => {
|
|
198
|
+
let n = e[t.field];
|
|
199
|
+
if (t.type && De) {
|
|
200
|
+
let e = De(t.type);
|
|
201
|
+
if (e) return /* @__PURE__ */ D(e, {
|
|
202
|
+
value: n,
|
|
203
|
+
field: {
|
|
204
|
+
name: t.field,
|
|
205
|
+
type: t.type
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
return n == null ? "" : typeof n == "object" ? n.$numberDecimal ? String(Number(n.$numberDecimal)) : n.$oid ? String(n.$oid) : n.$date ? new Date(n.$date).toLocaleDateString() : n.name || n.label ? String(n.name || n.label) : JSON.stringify(n) : typeof n == "boolean" ? n ? "Yes" : "No" : String(n);
|
|
210
|
+
}, [De]), ct = x((e) => q === e ? D(J === "asc" ? re : _e, { className: "ml-1 size-3" }) : /* @__PURE__ */ D(n, { className: "ml-1 size-3 opacity-40" }), [q, J]), lt = x((e, t, n) => {
|
|
211
|
+
e.preventDefault(), e.stopPropagation(), We.current = {
|
|
212
|
+
field: t,
|
|
213
|
+
startX: e.clientX,
|
|
214
|
+
startWidth: n
|
|
215
|
+
};
|
|
216
|
+
let r = (e) => {
|
|
217
|
+
if (!We.current) return;
|
|
218
|
+
let t = e.clientX - We.current.startX, n = Math.max(Ce, We.current.startWidth + t);
|
|
219
|
+
Ue((e) => ({
|
|
220
|
+
...e,
|
|
221
|
+
[We.current.field]: n
|
|
222
|
+
}));
|
|
223
|
+
}, i = () => {
|
|
224
|
+
We.current = null, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", i);
|
|
225
|
+
};
|
|
226
|
+
document.addEventListener("mousemove", r), document.addEventListener("mouseup", i);
|
|
227
|
+
}, []), $ = x((e, t) => {
|
|
228
|
+
Ve((n) => ({
|
|
229
|
+
...n,
|
|
230
|
+
[e]: t
|
|
231
|
+
})), G(1);
|
|
232
|
+
}, []), ut = x(() => {
|
|
233
|
+
Ve({}), G(1);
|
|
234
|
+
}, []), dt = w(() => Object.values(X).filter((e) => e != null && e !== "").length, [X]), ft = x((e) => {
|
|
235
|
+
let t = X[e.field], n = e.label || M(e.field);
|
|
236
|
+
switch (e.type) {
|
|
237
|
+
case "select": return /* @__PURE__ */ O("div", {
|
|
238
|
+
className: "space-y-1",
|
|
239
|
+
children: [/* @__PURE__ */ D(f, {
|
|
240
|
+
className: "text-xs text-muted-foreground",
|
|
241
|
+
children: n
|
|
242
|
+
}), /* @__PURE__ */ O(fe, {
|
|
243
|
+
value: t == null ? "" : String(t),
|
|
244
|
+
onValueChange: (t) => $(e.field, t),
|
|
245
|
+
children: [/* @__PURE__ */ D(ee, {
|
|
246
|
+
className: "h-8 text-xs",
|
|
247
|
+
children: /* @__PURE__ */ D(v, { placeholder: `Filter ${n}` })
|
|
248
|
+
}), /* @__PURE__ */ D(be, { children: e.options?.map((e) => /* @__PURE__ */ D(ae, {
|
|
249
|
+
value: String(e.value),
|
|
250
|
+
children: e.label
|
|
251
|
+
}, String(e.value))) })]
|
|
252
|
+
})]
|
|
253
|
+
});
|
|
254
|
+
case "number": return /* @__PURE__ */ O("div", {
|
|
255
|
+
className: "space-y-1",
|
|
256
|
+
children: [/* @__PURE__ */ D(f, {
|
|
257
|
+
className: "text-xs text-muted-foreground",
|
|
258
|
+
children: n
|
|
259
|
+
}), /* @__PURE__ */ D(c, {
|
|
260
|
+
type: "number",
|
|
261
|
+
className: "h-8 text-xs",
|
|
262
|
+
value: t ?? "",
|
|
263
|
+
placeholder: `Filter ${n}`,
|
|
264
|
+
onChange: (t) => {
|
|
265
|
+
let n = t.target.value;
|
|
266
|
+
$(e.field, n === "" ? "" : Number(n));
|
|
267
|
+
}
|
|
268
|
+
})]
|
|
269
|
+
});
|
|
270
|
+
case "date": return /* @__PURE__ */ O("div", {
|
|
271
|
+
className: "space-y-1",
|
|
272
|
+
children: [/* @__PURE__ */ D(f, {
|
|
273
|
+
className: "text-xs text-muted-foreground",
|
|
274
|
+
children: n
|
|
275
|
+
}), /* @__PURE__ */ D(c, {
|
|
276
|
+
type: "date",
|
|
277
|
+
className: "h-8 text-xs",
|
|
278
|
+
value: t ?? "",
|
|
279
|
+
onChange: (t) => $(e.field, t.target.value)
|
|
280
|
+
})]
|
|
281
|
+
});
|
|
282
|
+
case "boolean": return /* @__PURE__ */ O("div", {
|
|
283
|
+
className: "space-y-1",
|
|
284
|
+
children: [/* @__PURE__ */ D(f, {
|
|
285
|
+
className: "text-xs text-muted-foreground",
|
|
286
|
+
children: n
|
|
287
|
+
}), /* @__PURE__ */ O("div", {
|
|
288
|
+
className: "flex items-center gap-2 h-8",
|
|
289
|
+
children: [/* @__PURE__ */ D(ie, {
|
|
290
|
+
checked: !!t,
|
|
291
|
+
onCheckedChange: (t) => $(e.field, !!t)
|
|
292
|
+
}), /* @__PURE__ */ D("span", {
|
|
293
|
+
className: "text-xs text-muted-foreground",
|
|
294
|
+
children: "Yes"
|
|
295
|
+
})]
|
|
296
|
+
})]
|
|
297
|
+
});
|
|
298
|
+
default: return /* @__PURE__ */ O("div", {
|
|
299
|
+
className: "space-y-1",
|
|
300
|
+
children: [/* @__PURE__ */ D(f, {
|
|
301
|
+
className: "text-xs text-muted-foreground",
|
|
302
|
+
children: n
|
|
303
|
+
}), /* @__PURE__ */ D(c, {
|
|
304
|
+
className: "h-8 text-xs",
|
|
305
|
+
value: t ?? "",
|
|
306
|
+
placeholder: `Filter ${n}`,
|
|
307
|
+
onChange: (t) => $(e.field, t.target.value)
|
|
308
|
+
})]
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
}, [X, $]), pt = x((e, t) => e ? "bg-primary/5 hover:bg-primary/10" : t % 2 == 1 ? "bg-muted/20 hover:bg-accent/30" : "hover:bg-accent/30", []);
|
|
312
|
+
return /* @__PURE__ */ D(r, {
|
|
313
|
+
open: e,
|
|
314
|
+
onOpenChange: t,
|
|
315
|
+
children: /* @__PURE__ */ O(ge, {
|
|
316
|
+
className: "w-[95vw] sm:max-w-3xl lg:max-w-5xl max-h-[85vh] sm:max-h-[80vh] flex flex-col gap-0",
|
|
317
|
+
"data-testid": "record-picker-dialog",
|
|
318
|
+
children: [
|
|
319
|
+
/* @__PURE__ */ D(s, { children: /* @__PURE__ */ O(l, { children: [a, o && /* @__PURE__ */ D("span", {
|
|
320
|
+
className: "sr-only",
|
|
321
|
+
children: " (multiple selection)"
|
|
322
|
+
})] }) }),
|
|
323
|
+
/* @__PURE__ */ O("div", {
|
|
324
|
+
className: "relative rounded-md border bg-muted/30 mb-3",
|
|
325
|
+
children: [
|
|
326
|
+
/* @__PURE__ */ D(ve, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" }),
|
|
327
|
+
/* @__PURE__ */ D(c, {
|
|
328
|
+
placeholder: "Search...",
|
|
329
|
+
value: U,
|
|
330
|
+
onChange: (e) => Ze(e.target.value),
|
|
331
|
+
className: "pl-9 border-0 bg-transparent shadow-none focus-visible:ring-0",
|
|
332
|
+
"data-testid": "record-picker-search"
|
|
333
|
+
}),
|
|
334
|
+
L && /* @__PURE__ */ D(xe, {
|
|
335
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 size-4 animate-spin text-muted-foreground",
|
|
336
|
+
"data-testid": "record-picker-loading-indicator"
|
|
337
|
+
})
|
|
338
|
+
]
|
|
339
|
+
}),
|
|
340
|
+
Z && Z.length > 0 && /* @__PURE__ */ D("div", {
|
|
341
|
+
className: "py-2",
|
|
342
|
+
children: Oe ? /* @__PURE__ */ D("div", {
|
|
343
|
+
"data-testid": "record-picker-filter-bar",
|
|
344
|
+
children: Oe({
|
|
345
|
+
filterColumns: Z,
|
|
346
|
+
values: X,
|
|
347
|
+
onChange: $,
|
|
348
|
+
onClear: ut,
|
|
349
|
+
activeCount: dt
|
|
350
|
+
})
|
|
351
|
+
}) : /* @__PURE__ */ O(Se, { children: [/* @__PURE__ */ O("div", {
|
|
352
|
+
className: "flex items-center gap-2",
|
|
353
|
+
"data-testid": "record-picker-filter-bar",
|
|
354
|
+
children: [/* @__PURE__ */ O(h, {
|
|
355
|
+
type: "button",
|
|
356
|
+
variant: dt > 0 ? "secondary" : "outline",
|
|
357
|
+
size: "sm",
|
|
358
|
+
className: "gap-1.5 shrink-0",
|
|
359
|
+
onClick: () => Be((e) => !e),
|
|
360
|
+
children: [
|
|
361
|
+
/* @__PURE__ */ D(de, { className: "size-3.5" }),
|
|
362
|
+
"Filters",
|
|
363
|
+
dt > 0 && /* @__PURE__ */ D("span", {
|
|
364
|
+
className: "inline-flex h-5 min-w-[20px] items-center justify-center rounded-full bg-primary/10 px-1 text-xs font-medium text-primary",
|
|
365
|
+
children: dt
|
|
366
|
+
})
|
|
367
|
+
]
|
|
368
|
+
}), dt > 0 && /* @__PURE__ */ O(h, {
|
|
369
|
+
type: "button",
|
|
370
|
+
variant: "ghost",
|
|
371
|
+
size: "sm",
|
|
372
|
+
className: "gap-1 text-xs",
|
|
373
|
+
onClick: ut,
|
|
374
|
+
children: [/* @__PURE__ */ D(le, { className: "size-3" }), "Clear"]
|
|
375
|
+
})]
|
|
376
|
+
}), ze && /* @__PURE__ */ D("div", {
|
|
377
|
+
className: "mt-2 grid gap-3 sm:grid-cols-2 lg:grid-cols-3 border rounded-md p-3 bg-muted/30",
|
|
378
|
+
"data-testid": "record-picker-filter-panel",
|
|
379
|
+
children: Z.map((e) => /* @__PURE__ */ D("div", { children: ft(e) }, e.field))
|
|
380
|
+
})] })
|
|
381
|
+
}),
|
|
382
|
+
z && /* @__PURE__ */ O("div", {
|
|
383
|
+
className: "flex flex-col items-center gap-2 py-4",
|
|
384
|
+
role: "alert",
|
|
385
|
+
children: [
|
|
386
|
+
/* @__PURE__ */ D(i, { className: "size-5 text-destructive" }),
|
|
387
|
+
/* @__PURE__ */ D("p", {
|
|
388
|
+
className: "text-sm text-destructive",
|
|
389
|
+
children: z
|
|
390
|
+
}),
|
|
391
|
+
/* @__PURE__ */ D(h, {
|
|
392
|
+
variant: "outline",
|
|
393
|
+
size: "sm",
|
|
394
|
+
onClick: () => Ye(U || void 0, W, Xe),
|
|
395
|
+
type: "button",
|
|
396
|
+
children: "Retry"
|
|
397
|
+
})
|
|
398
|
+
]
|
|
399
|
+
}),
|
|
400
|
+
ke ? /* @__PURE__ */ D("div", {
|
|
401
|
+
className: "flex-1 min-h-0",
|
|
402
|
+
"data-testid": "record-picker-grid-slot",
|
|
403
|
+
children: ke({
|
|
404
|
+
columns: qe,
|
|
405
|
+
records: I,
|
|
406
|
+
loading: L,
|
|
407
|
+
totalCount: V,
|
|
408
|
+
currentPage: W,
|
|
409
|
+
pageSize: b,
|
|
410
|
+
sortField: q,
|
|
411
|
+
sortDirection: J,
|
|
412
|
+
onSort: Qe,
|
|
413
|
+
onPageChange: G,
|
|
414
|
+
onRowClick: tt,
|
|
415
|
+
isSelected: et,
|
|
416
|
+
multiple: o,
|
|
417
|
+
idField: ye,
|
|
418
|
+
cellRenderer: De
|
|
419
|
+
})
|
|
420
|
+
}) : /* @__PURE__ */ O(Se, { children: [
|
|
421
|
+
L && I.length === 0 && !z && /* @__PURE__ */ D("div", {
|
|
422
|
+
className: "flex-1 overflow-hidden min-h-0 border rounded-md",
|
|
423
|
+
role: "status",
|
|
424
|
+
"aria-live": "polite",
|
|
425
|
+
"data-testid": "record-picker-skeleton",
|
|
426
|
+
children: /* @__PURE__ */ O(g, { children: [/* @__PURE__ */ D(me, { children: /* @__PURE__ */ O(d, {
|
|
427
|
+
className: "bg-muted/40",
|
|
428
|
+
children: [o && /* @__PURE__ */ D(_, { className: "w-10" }), qe.map((e) => /* @__PURE__ */ D(_, { children: /* @__PURE__ */ D(y, { className: "h-4 w-20" }) }, e.field))]
|
|
429
|
+
}) }), /* @__PURE__ */ D(pe, { children: Array.from({ length: A }, (e, t) => /* @__PURE__ */ O(d, { children: [o && /* @__PURE__ */ D(p, {
|
|
430
|
+
className: "w-10",
|
|
431
|
+
children: /* @__PURE__ */ D(y, { className: "size-4 rounded" })
|
|
432
|
+
}), qe.map((e) => /* @__PURE__ */ D(p, { children: /* @__PURE__ */ D(y, { className: "h-4 w-full" }) }, e.field))] }, t)) })] })
|
|
433
|
+
}),
|
|
434
|
+
!L && !z && I.length === 0 && /* @__PURE__ */ D("div", {
|
|
435
|
+
className: "py-8 text-center",
|
|
436
|
+
children: /* @__PURE__ */ D("p", {
|
|
437
|
+
className: "text-sm text-muted-foreground",
|
|
438
|
+
children: "No records found"
|
|
439
|
+
})
|
|
440
|
+
}),
|
|
441
|
+
!z && I.length > 0 && /* @__PURE__ */ O("div", {
|
|
442
|
+
className: "relative flex-1 overflow-auto min-h-0 border rounded-md",
|
|
443
|
+
tabIndex: 0,
|
|
444
|
+
onKeyDown: ot,
|
|
445
|
+
role: "grid",
|
|
446
|
+
"aria-label": "Records",
|
|
447
|
+
children: [L && /* @__PURE__ */ D("div", {
|
|
448
|
+
className: "absolute inset-0 z-10 flex items-center justify-center bg-background/60",
|
|
449
|
+
"data-testid": "record-picker-loading-overlay",
|
|
450
|
+
children: /* @__PURE__ */ D(xe, { className: "size-6 animate-spin text-muted-foreground" })
|
|
451
|
+
}), /* @__PURE__ */ O(g, {
|
|
452
|
+
style: Object.keys(He).length > 0 ? { tableLayout: "fixed" } : void 0,
|
|
453
|
+
children: [/* @__PURE__ */ D(me, {
|
|
454
|
+
className: "sticky top-0 z-[5] bg-muted/50 [&_tr]:border-b",
|
|
455
|
+
"data-testid": "record-picker-sticky-header",
|
|
456
|
+
children: /* @__PURE__ */ O(d, { children: [o && /* @__PURE__ */ D(_, { className: "w-10" }), qe.map((e) => {
|
|
457
|
+
let t = He[e.field];
|
|
458
|
+
return /* @__PURE__ */ O(_, {
|
|
459
|
+
style: t ? {
|
|
460
|
+
width: `${t}px`,
|
|
461
|
+
minWidth: `${t}px`
|
|
462
|
+
} : e.width ? { width: e.width } : void 0,
|
|
463
|
+
className: "cursor-pointer select-none relative group text-xs font-semibold uppercase tracking-wider",
|
|
464
|
+
onClick: () => Qe(e.field),
|
|
465
|
+
"aria-sort": q === e.field ? J === "asc" ? "ascending" : "descending" : "none",
|
|
466
|
+
children: [/* @__PURE__ */ O("span", {
|
|
467
|
+
className: "inline-flex items-center",
|
|
468
|
+
children: [e.label || M(e.field), ct(e.field)]
|
|
469
|
+
}), /* @__PURE__ */ D("span", {
|
|
470
|
+
role: "separator",
|
|
471
|
+
"aria-orientation": "vertical",
|
|
472
|
+
className: "absolute right-0 top-0 bottom-0 w-1 cursor-col-resize opacity-0 group-hover:opacity-100 bg-border hover:bg-primary/50 transition-opacity",
|
|
473
|
+
onMouseDown: (t) => {
|
|
474
|
+
let n = t.currentTarget.parentElement?.getBoundingClientRect();
|
|
475
|
+
lt(t, e.field, n?.width ?? 100);
|
|
476
|
+
},
|
|
477
|
+
onClick: (e) => e.stopPropagation(),
|
|
478
|
+
"data-testid": `resize-handle-${e.field}`
|
|
479
|
+
})]
|
|
480
|
+
}, e.field);
|
|
481
|
+
})] })
|
|
482
|
+
}), /* @__PURE__ */ D(pe, {
|
|
483
|
+
ref: Re,
|
|
484
|
+
children: I.map((e, t) => {
|
|
485
|
+
let n = $e(e), r = et(e), i = t === Y;
|
|
486
|
+
return /* @__PURE__ */ O(d, {
|
|
487
|
+
"data-row-index": t,
|
|
488
|
+
className: ue("cursor-pointer transition-colors", pt(r, t), i && "ring-2 ring-primary ring-inset"),
|
|
489
|
+
onClick: () => tt(e),
|
|
490
|
+
"data-testid": `record-row-${n}`,
|
|
491
|
+
"aria-selected": r,
|
|
492
|
+
children: [o && /* @__PURE__ */ D(p, {
|
|
493
|
+
className: "w-10",
|
|
494
|
+
children: r && /* @__PURE__ */ D(te, { className: "size-4 text-primary" })
|
|
495
|
+
}), qe.map((t) => /* @__PURE__ */ D(p, {
|
|
496
|
+
className: "py-2.5",
|
|
497
|
+
children: st(e, t)
|
|
498
|
+
}, t.field))]
|
|
499
|
+
}, n ?? t);
|
|
500
|
+
})
|
|
501
|
+
})]
|
|
502
|
+
})]
|
|
503
|
+
}),
|
|
504
|
+
!z && V > 0 && /* @__PURE__ */ O("div", {
|
|
505
|
+
className: "flex items-center justify-between text-sm text-muted-foreground border-t pt-3 mt-2 px-1",
|
|
506
|
+
"data-testid": "record-picker-pagination",
|
|
507
|
+
children: [/* @__PURE__ */ O("span", { children: [
|
|
508
|
+
V,
|
|
509
|
+
" ",
|
|
510
|
+
V === 1 ? "record" : "records",
|
|
511
|
+
Q > 1 && ` · Page ${W} of ${Q}`
|
|
512
|
+
] }), Q > 1 && /* @__PURE__ */ O("div", {
|
|
513
|
+
className: "flex items-center gap-1.5",
|
|
514
|
+
children: [
|
|
515
|
+
/* @__PURE__ */ D(h, {
|
|
516
|
+
variant: "outline",
|
|
517
|
+
size: "icon",
|
|
518
|
+
className: "size-7",
|
|
519
|
+
onClick: rt,
|
|
520
|
+
disabled: W <= 1,
|
|
521
|
+
type: "button",
|
|
522
|
+
"aria-label": "Previous page",
|
|
523
|
+
children: /* @__PURE__ */ D(ce, { className: "size-4" })
|
|
524
|
+
}),
|
|
525
|
+
/* @__PURE__ */ D(c, {
|
|
526
|
+
className: "h-7 w-12 text-center text-xs px-1",
|
|
527
|
+
placeholder: String(W),
|
|
528
|
+
value: Ge,
|
|
529
|
+
onChange: (e) => Ke(e.target.value),
|
|
530
|
+
onKeyDown: at,
|
|
531
|
+
"aria-label": "Jump to page",
|
|
532
|
+
"data-testid": "record-picker-page-jump"
|
|
533
|
+
}),
|
|
534
|
+
/* @__PURE__ */ D(h, {
|
|
535
|
+
variant: "outline",
|
|
536
|
+
size: "icon",
|
|
537
|
+
className: "size-7",
|
|
538
|
+
onClick: it,
|
|
539
|
+
disabled: W >= Q,
|
|
540
|
+
type: "button",
|
|
541
|
+
"aria-label": "Next page",
|
|
542
|
+
children: /* @__PURE__ */ D(se, { className: "size-4" })
|
|
543
|
+
})
|
|
544
|
+
]
|
|
545
|
+
})]
|
|
546
|
+
})
|
|
547
|
+
] }),
|
|
548
|
+
o && /* @__PURE__ */ D(ne, { children: /* @__PURE__ */ O("div", {
|
|
549
|
+
className: "flex items-center gap-2 w-full justify-between",
|
|
550
|
+
children: [/* @__PURE__ */ O("span", {
|
|
551
|
+
className: "text-sm text-muted-foreground",
|
|
552
|
+
children: [Pe.size, " selected"]
|
|
553
|
+
}), /* @__PURE__ */ O("div", {
|
|
554
|
+
className: "flex gap-2",
|
|
555
|
+
children: [/* @__PURE__ */ D(h, {
|
|
556
|
+
variant: "outline",
|
|
557
|
+
type: "button",
|
|
558
|
+
onClick: () => t(!1),
|
|
559
|
+
children: "Cancel"
|
|
560
|
+
}), /* @__PURE__ */ D(h, {
|
|
561
|
+
type: "button",
|
|
562
|
+
onClick: nt,
|
|
563
|
+
children: "Confirm"
|
|
564
|
+
})]
|
|
565
|
+
})]
|
|
566
|
+
}) })
|
|
567
|
+
]
|
|
568
|
+
})
|
|
569
|
+
});
|
|
570
|
+
}
|
|
571
|
+
//#endregion
|
|
572
|
+
//#region ../fields/src/widgets/_cell-renderer-bridge.ts
|
|
573
|
+
var N;
|
|
574
|
+
function P(e) {
|
|
575
|
+
N = e;
|
|
576
|
+
}
|
|
577
|
+
function De() {
|
|
578
|
+
return N;
|
|
579
|
+
}
|
|
580
|
+
//#endregion
|
|
581
|
+
//#region ../fields/src/widgets/LookupField.tsx
|
|
582
|
+
var F = /* @__PURE__ */ e({ LookupField: () => L }), Oe = 50, ke = m;
|
|
583
|
+
function I(e, t, n, r) {
|
|
584
|
+
let i = e[n] ?? e.id ?? e._id, ee = e[t] ?? e.label ?? e.name ?? String(i), a = r ? e[r] : void 0;
|
|
585
|
+
return {
|
|
586
|
+
value: i,
|
|
587
|
+
label: String(ee),
|
|
588
|
+
description: a,
|
|
589
|
+
...e
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
function Ae(e) {
|
|
593
|
+
return {
|
|
594
|
+
text: "text",
|
|
595
|
+
number: "number",
|
|
596
|
+
currency: "number",
|
|
597
|
+
percent: "number",
|
|
598
|
+
select: "select",
|
|
599
|
+
status: "select",
|
|
600
|
+
date: "date",
|
|
601
|
+
datetime: "date",
|
|
602
|
+
boolean: "boolean"
|
|
603
|
+
}[e];
|
|
604
|
+
}
|
|
605
|
+
function L({ value: e, onChange: n, field: r, readonly: ee, ...te }) {
|
|
606
|
+
let [ne, s] = E(!1), [l, re] = E(""), { t: ie } = b(), [ae, se] = E([]), [ce, ue] = E(!1), [de, fe] = E(null), [pe, me] = E(0), d = T(null), [ge, f] = E([]), [p, m] = E(-1), _e = T(null), g = r || te.schema, _ = g?.field, v = _ && typeof _ == "object" && ("reference_to" in _ || "reference" in _ || "type" in _) ? _ : g, be = v?.options || [], y = v?.multiple || !1, k = v?.display_field || v?.reference_field || "name", Ce = v?.description_field, A = v?.id_field || "id", j = v?.reference_to || v?.reference, M = v?.lookup_columns, we = v?.lookup_page_size, Te = v?.lookup_filters, N = w(() => {
|
|
607
|
+
if (!M) return;
|
|
608
|
+
let e = [];
|
|
609
|
+
for (let t of M) if (typeof t == "object" && t.type) {
|
|
610
|
+
let n = Ae(t.type);
|
|
611
|
+
n && e.push({
|
|
612
|
+
field: t.field,
|
|
613
|
+
label: t.label,
|
|
614
|
+
type: n
|
|
615
|
+
});
|
|
616
|
+
}
|
|
617
|
+
return e.length > 0 ? e : void 0;
|
|
618
|
+
}, [M]), P = S(ke)?.dataSource ?? null, F = te.dataSource ?? g?.dataSource ?? v?.dataSource ?? P, L = F != null && typeof F.find == "function" && !!j, R = te.onCreateNew ?? g?.onCreateNew, [z, B] = E(!1), V = L ? ae : be, H = w(() => {
|
|
619
|
+
if (L || !l) return V;
|
|
620
|
+
let e = l.toLowerCase();
|
|
621
|
+
return V.filter((t) => t.label.toLowerCase().includes(e) || t.description && t.description.toLowerCase().includes(e));
|
|
622
|
+
}, [
|
|
623
|
+
L,
|
|
624
|
+
V,
|
|
625
|
+
l
|
|
626
|
+
]);
|
|
627
|
+
C(() => {
|
|
628
|
+
m(-1);
|
|
629
|
+
}, [H.length]);
|
|
630
|
+
let U = x(async (e) => {
|
|
631
|
+
if (!(!F || !j)) {
|
|
632
|
+
ue(!0), fe(null);
|
|
633
|
+
try {
|
|
634
|
+
let t = { $top: Oe };
|
|
635
|
+
e && e.trim() && (t.$search = e.trim());
|
|
636
|
+
let n = await F.find(j, t), r = n?.data ?? n ?? [];
|
|
637
|
+
se(r.map((e) => I(e, k, A, Ce))), me(n?.total ?? r.length);
|
|
638
|
+
} catch (e) {
|
|
639
|
+
fe(e instanceof Error ? e.message : String(e)), se([]);
|
|
640
|
+
} finally {
|
|
641
|
+
ue(!1);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
}, [
|
|
645
|
+
F,
|
|
646
|
+
j,
|
|
647
|
+
k,
|
|
648
|
+
A,
|
|
649
|
+
Ce
|
|
650
|
+
]);
|
|
651
|
+
C(() => {
|
|
652
|
+
ne && L && U(l || void 0), ne || (re(""), fe(null), m(-1));
|
|
653
|
+
}, [ne]);
|
|
654
|
+
let je = x((e) => {
|
|
655
|
+
re(e), L && (d.current && clearTimeout(d.current), d.current = setTimeout(() => {
|
|
656
|
+
U(e || void 0);
|
|
657
|
+
}, 300));
|
|
658
|
+
}, [L, U]);
|
|
659
|
+
C(() => () => {
|
|
660
|
+
d.current && clearTimeout(d.current);
|
|
661
|
+
}, []);
|
|
662
|
+
let W = x((e) => be.find((t) => t.value === e) ?? ae.find((t) => t.value === e) ?? ge.find((t) => t.value === e), [
|
|
663
|
+
be,
|
|
664
|
+
ae,
|
|
665
|
+
ge
|
|
666
|
+
]), G = y ? (Array.isArray(e) ? e : []).map(W).filter(Boolean) : e ? [W(e)].filter(Boolean) : [], K = x((t) => {
|
|
667
|
+
if (y) {
|
|
668
|
+
let r = Array.isArray(e) ? e : [];
|
|
669
|
+
r.includes(t.value) ? n(r.filter((e) => e !== t.value)) : n([...r, t.value]);
|
|
670
|
+
} else n(t.value), s(!1);
|
|
671
|
+
}, [
|
|
672
|
+
y,
|
|
673
|
+
e,
|
|
674
|
+
n
|
|
675
|
+
]), q = (t) => {
|
|
676
|
+
n(y ? (Array.isArray(e) ? e : []).filter((e) => e !== t) : null);
|
|
677
|
+
}, Me = x((e) => {
|
|
678
|
+
f(e.map((e) => I(e, k, A, Ce)));
|
|
679
|
+
}, [
|
|
680
|
+
k,
|
|
681
|
+
A,
|
|
682
|
+
Ce
|
|
683
|
+
]), J = x((e) => {
|
|
684
|
+
e.key === "ArrowDown" ? (e.preventDefault(), m((e) => e < H.length - 1 ? e + 1 : e)) : e.key === "ArrowUp" ? (e.preventDefault(), m((e) => e > 0 ? e - 1 : 0)) : e.key === "Enter" && (e.preventDefault(), p >= 0 && p < H.length && K(H[p]));
|
|
685
|
+
}, [
|
|
686
|
+
H,
|
|
687
|
+
p,
|
|
688
|
+
K
|
|
689
|
+
]);
|
|
690
|
+
return C(() => {
|
|
691
|
+
p >= 0 && _e.current && _e.current.querySelector(`[data-lookup-index="${p}"]`)?.scrollIntoView({ block: "nearest" });
|
|
692
|
+
}, [p]), ee ? G.length ? y ? /* @__PURE__ */ D("div", {
|
|
693
|
+
className: "flex flex-wrap gap-1",
|
|
694
|
+
children: G.map((e, t) => /* @__PURE__ */ D(u, {
|
|
695
|
+
variant: "outline",
|
|
696
|
+
children: e?.[k] || e?.label
|
|
697
|
+
}, t))
|
|
698
|
+
}) : /* @__PURE__ */ D("span", {
|
|
699
|
+
className: "text-sm",
|
|
700
|
+
children: G[0]?.[k] || G[0]?.label
|
|
701
|
+
}) : /* @__PURE__ */ D(ye, {}) : /* @__PURE__ */ O("div", {
|
|
702
|
+
className: "space-y-2",
|
|
703
|
+
children: [
|
|
704
|
+
G.length > 0 && /* @__PURE__ */ D("div", {
|
|
705
|
+
className: "flex flex-wrap gap-1",
|
|
706
|
+
children: G.map((e, t) => /* @__PURE__ */ O(u, {
|
|
707
|
+
variant: "outline",
|
|
708
|
+
className: "gap-1",
|
|
709
|
+
children: [e?.[k] || e?.label, /* @__PURE__ */ D("button", {
|
|
710
|
+
onClick: () => q(e?.value),
|
|
711
|
+
className: "ml-1 hover:text-destructive",
|
|
712
|
+
type: "button",
|
|
713
|
+
"aria-label": `Remove ${e?.[k] || e?.label}`,
|
|
714
|
+
children: /* @__PURE__ */ D(le, { className: "size-3" })
|
|
715
|
+
})]
|
|
716
|
+
}, t))
|
|
717
|
+
}),
|
|
718
|
+
/* @__PURE__ */ O("div", {
|
|
719
|
+
className: "flex items-center gap-1.5",
|
|
720
|
+
children: [/* @__PURE__ */ O(oe, {
|
|
721
|
+
open: ne,
|
|
722
|
+
onOpenChange: s,
|
|
723
|
+
children: [/* @__PURE__ */ D(a, {
|
|
724
|
+
asChild: !0,
|
|
725
|
+
children: /* @__PURE__ */ O(h, {
|
|
726
|
+
variant: "outline",
|
|
727
|
+
className: "min-w-0 flex-1 justify-start text-left font-normal",
|
|
728
|
+
type: "button",
|
|
729
|
+
children: [/* @__PURE__ */ D(ve, { className: "mr-2 size-4" }), G.length === 0 ? g?.placeholder || ie("common.select") : y ? ie("table.selected", { count: G.length }) : ie("common.select")]
|
|
730
|
+
})
|
|
731
|
+
}), /* @__PURE__ */ O(o, {
|
|
732
|
+
className: "w-[var(--radix-popover-trigger-width)] p-0",
|
|
733
|
+
align: "start",
|
|
734
|
+
children: [
|
|
735
|
+
/* @__PURE__ */ D("div", {
|
|
736
|
+
className: "p-2",
|
|
737
|
+
children: /* @__PURE__ */ O("div", {
|
|
738
|
+
className: "relative",
|
|
739
|
+
children: [
|
|
740
|
+
/* @__PURE__ */ D(ve, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" }),
|
|
741
|
+
/* @__PURE__ */ D(c, {
|
|
742
|
+
placeholder: ie("common.search") + "...",
|
|
743
|
+
value: l,
|
|
744
|
+
onChange: (e) => je(e.target.value),
|
|
745
|
+
onKeyDown: J,
|
|
746
|
+
className: "w-full pl-9 h-8 text-sm"
|
|
747
|
+
}),
|
|
748
|
+
ce && /* @__PURE__ */ D(xe, {
|
|
749
|
+
className: "absolute right-3 top-1/2 -translate-y-1/2 size-4 animate-spin text-muted-foreground",
|
|
750
|
+
"data-testid": "lookup-loading"
|
|
751
|
+
})
|
|
752
|
+
]
|
|
753
|
+
})
|
|
754
|
+
}),
|
|
755
|
+
de && /* @__PURE__ */ O("div", {
|
|
756
|
+
className: "flex flex-col items-center gap-2 py-4 px-2",
|
|
757
|
+
role: "alert",
|
|
758
|
+
children: [
|
|
759
|
+
/* @__PURE__ */ D(i, { className: "size-5 text-destructive" }),
|
|
760
|
+
/* @__PURE__ */ D("p", {
|
|
761
|
+
className: "text-sm text-destructive",
|
|
762
|
+
children: de
|
|
763
|
+
}),
|
|
764
|
+
/* @__PURE__ */ D(h, {
|
|
765
|
+
variant: "outline",
|
|
766
|
+
size: "sm",
|
|
767
|
+
onClick: () => U(l || void 0),
|
|
768
|
+
type: "button",
|
|
769
|
+
children: "Retry"
|
|
770
|
+
})
|
|
771
|
+
]
|
|
772
|
+
}),
|
|
773
|
+
ce && H.length === 0 && !de && /* @__PURE__ */ O("div", {
|
|
774
|
+
className: "flex flex-col items-center gap-2 py-6",
|
|
775
|
+
role: "status",
|
|
776
|
+
"aria-live": "polite",
|
|
777
|
+
children: [/* @__PURE__ */ D(xe, { className: "size-6 animate-spin text-muted-foreground" }), /* @__PURE__ */ D("p", {
|
|
778
|
+
className: "text-sm text-muted-foreground",
|
|
779
|
+
children: "Loading…"
|
|
780
|
+
})]
|
|
781
|
+
}),
|
|
782
|
+
!de && !(ce && H.length === 0) && /* @__PURE__ */ D("div", {
|
|
783
|
+
ref: _e,
|
|
784
|
+
className: "max-h-64 overflow-y-auto px-1 pb-1",
|
|
785
|
+
role: "listbox",
|
|
786
|
+
children: H.length === 0 ? /* @__PURE__ */ O("div", {
|
|
787
|
+
className: "py-4 text-center",
|
|
788
|
+
children: [/* @__PURE__ */ D("p", {
|
|
789
|
+
className: "text-sm text-muted-foreground",
|
|
790
|
+
children: "No options found"
|
|
791
|
+
}), R && /* @__PURE__ */ O(h, {
|
|
792
|
+
variant: "ghost",
|
|
793
|
+
size: "sm",
|
|
794
|
+
className: "mt-2 gap-1",
|
|
795
|
+
type: "button",
|
|
796
|
+
onClick: () => {
|
|
797
|
+
R(l), s(!1);
|
|
798
|
+
},
|
|
799
|
+
children: [/* @__PURE__ */ D(he, { className: "size-4" }), "Create new"]
|
|
800
|
+
})]
|
|
801
|
+
}) : /* @__PURE__ */ O(Se, { children: [
|
|
802
|
+
H.map((t, n) => {
|
|
803
|
+
let r = y ? (Array.isArray(e) ? e : []).includes(t.value) : e === t.value;
|
|
804
|
+
return /* @__PURE__ */ O("button", {
|
|
805
|
+
"data-lookup-index": n,
|
|
806
|
+
role: "option",
|
|
807
|
+
"aria-selected": r,
|
|
808
|
+
onClick: () => K(t),
|
|
809
|
+
className: `w-full text-left px-3 py-2 rounded-md text-sm hover:bg-accent flex items-center justify-between ${n === p ? "bg-accent text-accent-foreground" : r ? "bg-accent/50 text-accent-foreground" : ""}`,
|
|
810
|
+
type: "button",
|
|
811
|
+
children: [/* @__PURE__ */ O("div", {
|
|
812
|
+
className: "min-w-0 flex-1",
|
|
813
|
+
children: [/* @__PURE__ */ D("span", {
|
|
814
|
+
className: "block truncate",
|
|
815
|
+
children: t.label
|
|
816
|
+
}), t.description && /* @__PURE__ */ D("span", {
|
|
817
|
+
className: "block truncate text-xs text-muted-foreground",
|
|
818
|
+
children: t.description
|
|
819
|
+
})]
|
|
820
|
+
}), r && /* @__PURE__ */ D(u, {
|
|
821
|
+
variant: "default",
|
|
822
|
+
className: "ml-2 shrink-0",
|
|
823
|
+
children: "Selected"
|
|
824
|
+
})]
|
|
825
|
+
}, t.value);
|
|
826
|
+
}),
|
|
827
|
+
L && pe > H.length && /* @__PURE__ */ O("p", {
|
|
828
|
+
className: "text-xs text-muted-foreground text-center py-2",
|
|
829
|
+
children: [
|
|
830
|
+
"Showing ",
|
|
831
|
+
H.length,
|
|
832
|
+
" of ",
|
|
833
|
+
pe,
|
|
834
|
+
" results."
|
|
835
|
+
]
|
|
836
|
+
}),
|
|
837
|
+
L && pe > H.length && /* @__PURE__ */ O("button", {
|
|
838
|
+
type: "button",
|
|
839
|
+
className: "w-full text-center px-3 py-2 rounded-md text-sm font-medium text-primary hover:bg-accent flex items-center justify-center gap-1.5",
|
|
840
|
+
onClick: () => {
|
|
841
|
+
s(!1), B(!0);
|
|
842
|
+
},
|
|
843
|
+
"data-testid": "show-all-results",
|
|
844
|
+
children: [
|
|
845
|
+
/* @__PURE__ */ D(t, { className: "size-3.5" }),
|
|
846
|
+
"Show All Results (",
|
|
847
|
+
pe,
|
|
848
|
+
")"
|
|
849
|
+
]
|
|
850
|
+
}),
|
|
851
|
+
R && /* @__PURE__ */ O("button", {
|
|
852
|
+
type: "button",
|
|
853
|
+
className: "w-full text-left px-3 py-2 rounded-md text-sm hover:bg-accent flex items-center gap-1.5 text-muted-foreground",
|
|
854
|
+
onClick: () => {
|
|
855
|
+
R(l), s(!1);
|
|
856
|
+
},
|
|
857
|
+
children: [
|
|
858
|
+
/* @__PURE__ */ D(he, { className: "size-3.5" }),
|
|
859
|
+
"Create new",
|
|
860
|
+
l ? ` "${l}"` : ""
|
|
861
|
+
]
|
|
862
|
+
})
|
|
863
|
+
] })
|
|
864
|
+
})
|
|
865
|
+
]
|
|
866
|
+
})]
|
|
867
|
+
}), L && /* @__PURE__ */ D(h, {
|
|
868
|
+
variant: "outline",
|
|
869
|
+
size: "icon",
|
|
870
|
+
className: "shrink-0",
|
|
871
|
+
type: "button",
|
|
872
|
+
onClick: () => B(!0),
|
|
873
|
+
"aria-label": "Browse all records",
|
|
874
|
+
title: "Browse all records",
|
|
875
|
+
"data-testid": "browse-all-records",
|
|
876
|
+
children: /* @__PURE__ */ D(t, { className: "size-4" })
|
|
877
|
+
})]
|
|
878
|
+
}),
|
|
879
|
+
L && F && j && /* @__PURE__ */ D(Ee, {
|
|
880
|
+
open: z,
|
|
881
|
+
onOpenChange: B,
|
|
882
|
+
title: g?.label || "Select",
|
|
883
|
+
multiple: y,
|
|
884
|
+
dataSource: F,
|
|
885
|
+
objectName: j,
|
|
886
|
+
columns: M,
|
|
887
|
+
displayField: k,
|
|
888
|
+
idField: A,
|
|
889
|
+
pageSize: we,
|
|
890
|
+
value: e,
|
|
891
|
+
onSelect: n,
|
|
892
|
+
onSelectRecords: Me,
|
|
893
|
+
lookupFilters: Te,
|
|
894
|
+
cellRenderer: De(),
|
|
895
|
+
filterColumns: N
|
|
896
|
+
})
|
|
897
|
+
]
|
|
898
|
+
});
|
|
899
|
+
}
|
|
900
|
+
//#endregion
|
|
901
|
+
export { P as n, F as t };
|