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