@object-ui/plugin-aggrid 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.
Files changed (68) hide show
  1. package/.turbo/turbo-build.log +60 -91
  2. package/CHANGELOG.md +22 -0
  3. package/dist/AddressField-DKqaE9pD.js +93 -0
  4. package/dist/AgGridImpl-BD5cjyc0.js +226 -0
  5. package/dist/AutoNumberField-0RU2dNKe.js +13 -0
  6. package/dist/AvatarField-IZTLB0Ye.js +82 -0
  7. package/dist/BooleanField-DRzAZhSq.js +40 -0
  8. package/dist/CodeField-RWhnDMyL.js +22 -0
  9. package/dist/ColorField-B-YAFXdz.js +37 -0
  10. package/dist/CurrencyField-Bu80a-sI.js +51 -0
  11. package/dist/DateField-CV-NpLbM.js +21 -0
  12. package/dist/DateTimeField--YTsgTjw.js +32 -0
  13. package/dist/EmailField-B-3fWJsH.js +28 -0
  14. package/dist/FileField-DxxdESfc.js +160 -0
  15. package/dist/FormulaField-MQXJZOep.js +13 -0
  16. package/dist/GeolocationField-BzKgcWLN.js +156 -0
  17. package/dist/GridField-DHsGo9l2.js +51 -0
  18. package/dist/ImageField-DK7sUV6b.js +77 -0
  19. package/dist/LocationField-DSvhU9Dz.js +35 -0
  20. package/dist/LookupField-Dmzju5Q0.js +1033 -0
  21. package/dist/MasterDetailField-CPLHbe_Y.js +109 -0
  22. package/dist/NumberField-JaSlPVXs.js +26 -0
  23. package/dist/ObjectAgGridImpl-4uephlvO.js +19998 -0
  24. package/dist/ObjectField-FzUYlu-m.js +52 -0
  25. package/dist/PasswordField-d6E-vKBI.js +60 -0
  26. package/dist/PercentField-D2_kMuC_.js +63 -0
  27. package/dist/PhoneField-DOaMivd6.js +28 -0
  28. package/dist/QRCodeField-BIQhc73N.js +144 -0
  29. package/dist/RatingField-BKAGmlzh.js +42 -0
  30. package/dist/RichTextField-D4FIV9V8.js +32 -0
  31. package/dist/SelectField-C2gtlnLZ.js +30 -0
  32. package/dist/SignatureField-fFEb0h_C.js +98 -0
  33. package/dist/SliderField-BlAlK3g2.js +34 -0
  34. package/dist/SummaryField-Dy2Kkj6M.js +18 -0
  35. package/dist/TextAreaField-BCUkjKTc.js +36 -0
  36. package/dist/TextField-XWOnbUrk.js +29 -0
  37. package/dist/TimeField-CZdzdqOO.js +21 -0
  38. package/dist/UrlField-sq1mpRoG.js +33 -0
  39. package/dist/UserField-Dqk38Arc.js +79 -0
  40. package/dist/VectorField-CY70VLiW.js +35 -0
  41. package/dist/createLucideIcon-CWx7zIL1.js +39 -0
  42. package/dist/image-Cm7ExMY2.js +24 -0
  43. package/dist/index.css +2 -1
  44. package/dist/index.js +503 -8
  45. package/dist/index.umd.cjs +116 -112
  46. package/dist/jsx-runtime-CGDkM_Jn.js +189 -0
  47. package/dist/plus-CsEgF66K.js +10 -0
  48. package/dist/upload-B1x-ueFd.js +17 -0
  49. package/dist/x-Bwhzfvtg.js +10 -0
  50. package/package.json +9 -9
  51. package/dist/AddressField-D2Yli537.js +0 -95
  52. package/dist/AgGridImpl-GwI1UT7v.js +0 -229
  53. package/dist/AutoNumberField-Y3hL1ZoW.js +0 -8
  54. package/dist/FileField-BHv22jrG.js +0 -144
  55. package/dist/FormulaField-B-JSCA7E.js +0 -9
  56. package/dist/GeolocationField-DxnVAm8n.js +0 -141
  57. package/dist/GridField-7A4mvr7x.js +0 -29
  58. package/dist/LocationField-o8Z6x8qV.js +0 -33
  59. package/dist/MasterDetailField-CnzHQ-jU.js +0 -117
  60. package/dist/ObjectAgGridImpl-CujXHJ0J.js +0 -28833
  61. package/dist/ObjectField-BAVt0fMs.js +0 -51
  62. package/dist/QRCodeField-VAlAXUkP.js +0 -96
  63. package/dist/RichTextField-DylJITFH.js +0 -37
  64. package/dist/SignatureField-BrGCC7_j.js +0 -96
  65. package/dist/SummaryField-BPPAEVC6.js +0 -9
  66. package/dist/UserField-CWZQprry.js +0 -49
  67. package/dist/VectorField-CIvFEC07.js +0 -25
  68. package/dist/index-BfSjmySi.js +0 -662
@@ -0,0 +1,1033 @@
1
+ import { r as e, t } from "./jsx-runtime-CGDkM_Jn.js";
2
+ import { t as n } from "./createLucideIcon-CWx7zIL1.js";
3
+ import { t as r } from "./plus-CsEgF66K.js";
4
+ import { t as i } from "./x-Bwhzfvtg.js";
5
+ import { useCallback as a, useContext as ee, useEffect as o, useMemo as s, useRef as c, useState as l } from "react";
6
+ import { Badge as u, Button as d, Checkbox as te, Dialog as ne, DialogContent as re, DialogFooter as f, DialogHeader as p, DialogTitle as ie, Input as m, Label as h, Popover as ae, PopoverContent as oe, PopoverTrigger as se, Select as ce, SelectContent as le, SelectItem as ue, SelectTrigger as de, SelectValue as fe, Skeleton as g, Table as pe, TableBody as _, TableCell as v, TableHead as me, TableHeader as y, TableRow as b, cn as he } from "@object-ui/components";
7
+ import { SchemaRendererContext as x } from "@object-ui/react";
8
+ var S = n("arrow-down", [["path", {
9
+ d: "M12 5v14",
10
+ key: "s699le"
11
+ }], ["path", {
12
+ d: "m19 12-7 7-7-7",
13
+ key: "1idqje"
14
+ }]]), C = n("arrow-up-down", [
15
+ ["path", {
16
+ d: "m21 16-4 4-4-4",
17
+ key: "f6ql7i"
18
+ }],
19
+ ["path", {
20
+ d: "M17 20V4",
21
+ key: "1ejh1v"
22
+ }],
23
+ ["path", {
24
+ d: "m3 8 4-4 4 4",
25
+ key: "11wl7u"
26
+ }],
27
+ ["path", {
28
+ d: "M7 4v16",
29
+ key: "1glfcx"
30
+ }]
31
+ ]), ge = n("arrow-up", [["path", {
32
+ d: "m5 12 7-7 7 7",
33
+ key: "hav0vg"
34
+ }], ["path", {
35
+ d: "M12 19V5",
36
+ key: "x0mq9r"
37
+ }]]), w = n("check", [["path", {
38
+ d: "M20 6 9 17l-5-5",
39
+ key: "1gmf2c"
40
+ }]]), T = n("chevron-left", [["path", {
41
+ d: "m15 18-6-6 6-6",
42
+ key: "1wnfg3"
43
+ }]]), _e = n("chevron-right", [["path", {
44
+ d: "m9 18 6-6-6-6",
45
+ key: "mthhwq"
46
+ }]]), ve = n("circle-alert", [
47
+ ["circle", {
48
+ cx: "12",
49
+ cy: "12",
50
+ r: "10",
51
+ key: "1mglay"
52
+ }],
53
+ ["line", {
54
+ x1: "12",
55
+ x2: "12",
56
+ y1: "8",
57
+ y2: "12",
58
+ key: "1pkeuh"
59
+ }],
60
+ ["line", {
61
+ x1: "12",
62
+ x2: "12.01",
63
+ y1: "16",
64
+ y2: "16",
65
+ key: "4dfq90"
66
+ }]
67
+ ]), ye = n("loader-circle", [["path", {
68
+ d: "M21 12a9 9 0 1 1-6.219-8.56",
69
+ key: "13zald"
70
+ }]]), be = n("search", [["path", {
71
+ d: "m21 21-4.34-4.34",
72
+ key: "14j7rj"
73
+ }], ["circle", {
74
+ cx: "11",
75
+ cy: "11",
76
+ r: "8",
77
+ key: "4ej97u"
78
+ }]]), E = n("sliders-horizontal", [
79
+ ["path", {
80
+ d: "M10 5H3",
81
+ key: "1qgfaw"
82
+ }],
83
+ ["path", {
84
+ d: "M12 19H3",
85
+ key: "yhmn1j"
86
+ }],
87
+ ["path", {
88
+ d: "M14 3v4",
89
+ key: "1sua03"
90
+ }],
91
+ ["path", {
92
+ d: "M16 17v4",
93
+ key: "1q0r14"
94
+ }],
95
+ ["path", {
96
+ d: "M21 12h-9",
97
+ key: "1o4lsq"
98
+ }],
99
+ ["path", {
100
+ d: "M21 19h-5",
101
+ key: "1rlt1p"
102
+ }],
103
+ ["path", {
104
+ d: "M21 5h-7",
105
+ key: "1oszz2"
106
+ }],
107
+ ["path", {
108
+ d: "M8 10v4",
109
+ key: "tgpxqk"
110
+ }],
111
+ ["path", {
112
+ d: "M8 12H3",
113
+ key: "a7s4jb"
114
+ }]
115
+ ]), D = n("table-properties", [
116
+ ["path", {
117
+ d: "M15 3v18",
118
+ key: "14nvp0"
119
+ }],
120
+ ["rect", {
121
+ width: "18",
122
+ height: "18",
123
+ x: "3",
124
+ y: "3",
125
+ rx: "2",
126
+ key: "afitv7"
127
+ }],
128
+ ["path", {
129
+ d: "M21 9H3",
130
+ key: "1338ky"
131
+ }],
132
+ ["path", {
133
+ d: "M21 15H3",
134
+ key: "9uk58r"
135
+ }]
136
+ ]), O = t(), k = 10, xe = 60, Se = 5;
137
+ function Ce(e) {
138
+ return typeof e == "string" ? { field: e } : e;
139
+ }
140
+ function A(e) {
141
+ return e.replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\b\w/g, (e) => e.toUpperCase());
142
+ }
143
+ function we(e) {
144
+ let t = {};
145
+ for (let n of e) switch (n.operator) {
146
+ case "eq":
147
+ t[n.field] = n.value;
148
+ break;
149
+ case "ne":
150
+ t[n.field] = { $ne: n.value };
151
+ break;
152
+ case "gt":
153
+ t[n.field] = { $gt: n.value };
154
+ break;
155
+ case "lt":
156
+ t[n.field] = { $lt: n.value };
157
+ break;
158
+ case "gte":
159
+ t[n.field] = { $gte: n.value };
160
+ break;
161
+ case "lte":
162
+ t[n.field] = { $lte: n.value };
163
+ break;
164
+ case "contains":
165
+ t[n.field] = { $contains: n.value };
166
+ break;
167
+ case "in":
168
+ t[n.field] = { $in: n.value };
169
+ break;
170
+ case "notIn":
171
+ t[n.field] = { $nin: n.value };
172
+ break;
173
+ }
174
+ return t;
175
+ }
176
+ function j(e, t) {
177
+ let n = {};
178
+ for (let r of t) {
179
+ let t = e[r.field];
180
+ t == null || t === "" || (r.type === "boolean" ? n[r.field] = !!t : r.type === "text" ? n[r.field] = { $contains: t } : n[r.field] = t);
181
+ }
182
+ return n;
183
+ }
184
+ function M({ open: e, onOpenChange: t, title: n = "Select Record", multiple: r = !1, dataSource: ee, objectName: u, columns: ae, displayField: oe = "name", idField: se = "id", pageSize: x = k, value: D, onSelect: M, onSelectRecords: N, lookupFilters: P, cellRenderer: Te, filterColumns: F, renderFilterBar: Ee, renderGrid: De }) {
185
+ let [I, Oe] = l([]), [L, R] = l(!1), [z, B] = l(null), [V, ke] = l(0), [H, Ae] = l(""), [U, W] = l(1), G = c(null), [K, je] = l(null), [q, Me] = l("asc"), [Ne, Pe] = l(/* @__PURE__ */ new Set()), Fe = c(/* @__PURE__ */ new Map()), [J, Ie] = l(-1), Le = c(null), [Re, ze] = l(!1), [Y, Be] = l({}), [Ve, He] = l({}), X = c(null), [Ue, We] = l(""), Ge = s(() => ae && ae.length > 0 ? ae.map(Ce) : [{
186
+ field: oe,
187
+ label: A(oe)
188
+ }], [ae, oe]), Z = s(() => {
189
+ if (F && F.length > 0) return F;
190
+ if (P && P.length > 0) return P.map((e) => {
191
+ let t = "text";
192
+ 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"), {
193
+ field: e.field,
194
+ label: A(e.field),
195
+ type: t,
196
+ ...Array.isArray(e.value) ? { options: e.value.map((e) => {
197
+ if (typeof e == "object" && e) {
198
+ let t = e;
199
+ return {
200
+ label: String(t.name || t.label || t.title || e),
201
+ value: e
202
+ };
203
+ }
204
+ return {
205
+ label: String(e),
206
+ value: e
207
+ };
208
+ }) } : {}
209
+ };
210
+ });
211
+ }, [F, P]), Ke = s(() => {
212
+ let e = P?.length ? we(P) : {}, t = Z?.length ? j(Y, Z) : {}, n = {
213
+ ...e,
214
+ ...t
215
+ };
216
+ return Object.keys(n).length > 0 ? n : void 0;
217
+ }, [
218
+ P,
219
+ Z,
220
+ Y
221
+ ]), Q = Math.max(1, Math.ceil(V / x)), qe = a(async (e, t = 1, n, r) => {
222
+ if (!(!ee || !u)) {
223
+ R(!0), B(null);
224
+ try {
225
+ let i = {
226
+ $top: x,
227
+ $skip: (t - 1) * x
228
+ };
229
+ e && e.trim() && (i.$search = e.trim()), n && (i.$orderby = { [n.field]: n.direction });
230
+ let a = r === void 0 ? Ke : r;
231
+ a && Object.keys(a).length > 0 && (i.$filter = a);
232
+ let o = await ee.find(u, i), s = o?.data ?? o ?? [];
233
+ Oe(s), ke(o?.total ?? s.length), Ie(-1);
234
+ } catch (e) {
235
+ B(e instanceof Error ? e.message : String(e)), Oe([]);
236
+ } finally {
237
+ R(!1);
238
+ }
239
+ }
240
+ }, [
241
+ ee,
242
+ u,
243
+ x,
244
+ Ke
245
+ ]), Je = s(() => K ? {
246
+ field: K,
247
+ direction: q
248
+ } : null, [K, q]);
249
+ o(() => {
250
+ e || (Ae(""), W(1), B(null), Oe([]), je(null), Me("asc"), Ie(-1), ze(!1), Be({}), He({}), We(""), Pe(new Set(r && Array.isArray(D) ? D : [])), Fe.current.clear());
251
+ }, [e]), o(() => {
252
+ e && qe(H || void 0, U, Je);
253
+ }, [
254
+ e,
255
+ U,
256
+ Je,
257
+ Ke
258
+ ]), o(() => {
259
+ e && r && Pe(new Set(Array.isArray(D) ? D : []));
260
+ }, [
261
+ e,
262
+ r,
263
+ D
264
+ ]);
265
+ let Ye = a((e) => {
266
+ Ae(e), W(1), G.current && clearTimeout(G.current), G.current = setTimeout(() => {
267
+ qe(e || void 0, 1, Je);
268
+ }, 300);
269
+ }, [qe, Je]);
270
+ o(() => () => {
271
+ G.current && clearTimeout(G.current);
272
+ }, []);
273
+ let Xe = a((e) => {
274
+ je((t) => t === e ? (Me((e) => e === "asc" ? "desc" : "asc"), e) : (Me("asc"), e)), W(1);
275
+ }, []), Ze = a((e) => e[se] ?? e.id ?? e._id, [se]), Qe = a((e) => {
276
+ let t = Ze(e);
277
+ return r ? Ne.has(t) : D === t;
278
+ }, [
279
+ r,
280
+ D,
281
+ Ne,
282
+ Ze
283
+ ]), $e = a((e) => {
284
+ let n = Ze(e);
285
+ r ? Pe((t) => {
286
+ let r = new Set(t);
287
+ return r.has(n) ? (r.delete(n), Fe.current.delete(n)) : (r.add(n), Fe.current.set(n, e)), r;
288
+ }) : (M(n), N?.([e]), t(!1));
289
+ }, [
290
+ r,
291
+ Ze,
292
+ M,
293
+ N,
294
+ t
295
+ ]), et = a(() => {
296
+ let e = Array.from(Ne);
297
+ M(e);
298
+ let n = e.map((e) => Fe.current.get(e)).filter(Boolean);
299
+ N?.(n), t(!1);
300
+ }, [
301
+ Ne,
302
+ M,
303
+ N,
304
+ t
305
+ ]), tt = a(() => {
306
+ W((e) => Math.max(1, e - 1));
307
+ }, []), nt = a(() => {
308
+ W((e) => Math.min(Q, e + 1));
309
+ }, [Q]), rt = a((e) => {
310
+ if (e.key !== "Enter") return;
311
+ let t = parseInt(Ue, 10);
312
+ !isNaN(t) && t >= 1 && t <= Q && W(t), We("");
313
+ }, [Ue, Q]), it = a((e) => {
314
+ I.length !== 0 && (e.key === "ArrowDown" ? (e.preventDefault(), Ie((e) => Math.min(e + 1, I.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), Ie((e) => Math.max(e - 1, 0))) : (e.key === "Enter" || e.key === " ") && (e.preventDefault(), J >= 0 && J < I.length && $e(I[J])));
315
+ }, [
316
+ I,
317
+ J,
318
+ $e
319
+ ]);
320
+ o(() => {
321
+ if (J >= 0 && Le.current) {
322
+ let e = Le.current.querySelector(`[data-row-index="${J}"]`);
323
+ e && typeof e.scrollIntoView == "function" && e.scrollIntoView({ block: "nearest" });
324
+ }
325
+ }, [J]);
326
+ let at = a((e, t) => {
327
+ let n = e[t.field];
328
+ if (t.type && Te) {
329
+ let e = Te(t.type);
330
+ if (e) return /* @__PURE__ */ (0, O.jsx)(e, {
331
+ value: n,
332
+ field: {
333
+ name: t.field,
334
+ type: t.type
335
+ }
336
+ });
337
+ }
338
+ 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);
339
+ }, [Te]), ot = a((e) => K === e ? q === "asc" ? /* @__PURE__ */ (0, O.jsx)(ge, { className: "ml-1 size-3" }) : /* @__PURE__ */ (0, O.jsx)(S, { className: "ml-1 size-3" }) : /* @__PURE__ */ (0, O.jsx)(C, { className: "ml-1 size-3 opacity-40" }), [K, q]), st = a((e, t, n) => {
340
+ e.preventDefault(), e.stopPropagation(), X.current = {
341
+ field: t,
342
+ startX: e.clientX,
343
+ startWidth: n
344
+ };
345
+ let r = (e) => {
346
+ if (!X.current) return;
347
+ let t = e.clientX - X.current.startX, n = Math.max(xe, X.current.startWidth + t);
348
+ He((e) => ({
349
+ ...e,
350
+ [X.current.field]: n
351
+ }));
352
+ }, i = () => {
353
+ X.current = null, document.removeEventListener("mousemove", r), document.removeEventListener("mouseup", i);
354
+ };
355
+ document.addEventListener("mousemove", r), document.addEventListener("mouseup", i);
356
+ }, []), $ = a((e, t) => {
357
+ Be((n) => ({
358
+ ...n,
359
+ [e]: t
360
+ })), W(1);
361
+ }, []), ct = a(() => {
362
+ Be({}), W(1);
363
+ }, []), lt = s(() => Object.values(Y).filter((e) => e != null && e !== "").length, [Y]), ut = a((e) => {
364
+ let t = Y[e.field], n = e.label || A(e.field);
365
+ switch (e.type) {
366
+ case "select": return /* @__PURE__ */ (0, O.jsxs)("div", {
367
+ className: "space-y-1",
368
+ children: [/* @__PURE__ */ (0, O.jsx)(h, {
369
+ className: "text-xs text-muted-foreground",
370
+ children: n
371
+ }), /* @__PURE__ */ (0, O.jsxs)(ce, {
372
+ value: t == null ? "" : String(t),
373
+ onValueChange: (t) => $(e.field, t),
374
+ children: [/* @__PURE__ */ (0, O.jsx)(de, {
375
+ className: "h-8 text-xs",
376
+ children: /* @__PURE__ */ (0, O.jsx)(fe, { placeholder: `Filter ${n}` })
377
+ }), /* @__PURE__ */ (0, O.jsx)(le, { children: e.options?.map((e) => /* @__PURE__ */ (0, O.jsx)(ue, {
378
+ value: String(e.value),
379
+ children: e.label
380
+ }, String(e.value))) })]
381
+ })]
382
+ });
383
+ case "number": return /* @__PURE__ */ (0, O.jsxs)("div", {
384
+ className: "space-y-1",
385
+ children: [/* @__PURE__ */ (0, O.jsx)(h, {
386
+ className: "text-xs text-muted-foreground",
387
+ children: n
388
+ }), /* @__PURE__ */ (0, O.jsx)(m, {
389
+ type: "number",
390
+ className: "h-8 text-xs",
391
+ value: t ?? "",
392
+ placeholder: `Filter ${n}`,
393
+ onChange: (t) => {
394
+ let n = t.target.value;
395
+ $(e.field, n === "" ? "" : Number(n));
396
+ }
397
+ })]
398
+ });
399
+ case "date": return /* @__PURE__ */ (0, O.jsxs)("div", {
400
+ className: "space-y-1",
401
+ children: [/* @__PURE__ */ (0, O.jsx)(h, {
402
+ className: "text-xs text-muted-foreground",
403
+ children: n
404
+ }), /* @__PURE__ */ (0, O.jsx)(m, {
405
+ type: "date",
406
+ className: "h-8 text-xs",
407
+ value: t ?? "",
408
+ onChange: (t) => $(e.field, t.target.value)
409
+ })]
410
+ });
411
+ case "boolean": return /* @__PURE__ */ (0, O.jsxs)("div", {
412
+ className: "space-y-1",
413
+ children: [/* @__PURE__ */ (0, O.jsx)(h, {
414
+ className: "text-xs text-muted-foreground",
415
+ children: n
416
+ }), /* @__PURE__ */ (0, O.jsxs)("div", {
417
+ className: "flex items-center gap-2 h-8",
418
+ children: [/* @__PURE__ */ (0, O.jsx)(te, {
419
+ checked: !!t,
420
+ onCheckedChange: (t) => $(e.field, !!t)
421
+ }), /* @__PURE__ */ (0, O.jsx)("span", {
422
+ className: "text-xs text-muted-foreground",
423
+ children: "Yes"
424
+ })]
425
+ })]
426
+ });
427
+ default: return /* @__PURE__ */ (0, O.jsxs)("div", {
428
+ className: "space-y-1",
429
+ children: [/* @__PURE__ */ (0, O.jsx)(h, {
430
+ className: "text-xs text-muted-foreground",
431
+ children: n
432
+ }), /* @__PURE__ */ (0, O.jsx)(m, {
433
+ className: "h-8 text-xs",
434
+ value: t ?? "",
435
+ placeholder: `Filter ${n}`,
436
+ onChange: (t) => $(e.field, t.target.value)
437
+ })]
438
+ });
439
+ }
440
+ }, [Y, $]), dt = a((e, t) => e ? "bg-primary/5 hover:bg-primary/10" : t % 2 == 1 ? "bg-muted/20 hover:bg-accent/30" : "hover:bg-accent/30", []);
441
+ return /* @__PURE__ */ (0, O.jsx)(ne, {
442
+ open: e,
443
+ onOpenChange: t,
444
+ children: /* @__PURE__ */ (0, O.jsxs)(re, {
445
+ className: "w-[95vw] sm:max-w-3xl lg:max-w-5xl max-h-[85vh] sm:max-h-[80vh] flex flex-col gap-0",
446
+ "data-testid": "record-picker-dialog",
447
+ children: [
448
+ /* @__PURE__ */ (0, O.jsx)(p, { children: /* @__PURE__ */ (0, O.jsxs)(ie, { children: [n, r && /* @__PURE__ */ (0, O.jsx)("span", {
449
+ className: "sr-only",
450
+ children: " (multiple selection)"
451
+ })] }) }),
452
+ /* @__PURE__ */ (0, O.jsxs)("div", {
453
+ className: "relative rounded-md border bg-muted/30 mb-3",
454
+ children: [
455
+ /* @__PURE__ */ (0, O.jsx)(be, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" }),
456
+ /* @__PURE__ */ (0, O.jsx)(m, {
457
+ placeholder: "Search...",
458
+ value: H,
459
+ onChange: (e) => Ye(e.target.value),
460
+ className: "pl-9 border-0 bg-transparent shadow-none focus-visible:ring-0",
461
+ "data-testid": "record-picker-search"
462
+ }),
463
+ L && /* @__PURE__ */ (0, O.jsx)(ye, {
464
+ className: "absolute right-3 top-1/2 -translate-y-1/2 size-4 animate-spin text-muted-foreground",
465
+ "data-testid": "record-picker-loading-indicator"
466
+ })
467
+ ]
468
+ }),
469
+ Z && Z.length > 0 && /* @__PURE__ */ (0, O.jsx)("div", {
470
+ className: "py-2",
471
+ children: Ee ? /* @__PURE__ */ (0, O.jsx)("div", {
472
+ "data-testid": "record-picker-filter-bar",
473
+ children: Ee({
474
+ filterColumns: Z,
475
+ values: Y,
476
+ onChange: $,
477
+ onClear: ct,
478
+ activeCount: lt
479
+ })
480
+ }) : /* @__PURE__ */ (0, O.jsxs)(O.Fragment, { children: [/* @__PURE__ */ (0, O.jsxs)("div", {
481
+ className: "flex items-center gap-2",
482
+ "data-testid": "record-picker-filter-bar",
483
+ children: [/* @__PURE__ */ (0, O.jsxs)(d, {
484
+ type: "button",
485
+ variant: lt > 0 ? "secondary" : "outline",
486
+ size: "sm",
487
+ className: "gap-1.5 shrink-0",
488
+ onClick: () => ze((e) => !e),
489
+ children: [
490
+ /* @__PURE__ */ (0, O.jsx)(E, { className: "size-3.5" }),
491
+ "Filters",
492
+ lt > 0 && /* @__PURE__ */ (0, O.jsx)("span", {
493
+ 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",
494
+ children: lt
495
+ })
496
+ ]
497
+ }), lt > 0 && /* @__PURE__ */ (0, O.jsxs)(d, {
498
+ type: "button",
499
+ variant: "ghost",
500
+ size: "sm",
501
+ className: "gap-1 text-xs",
502
+ onClick: ct,
503
+ children: [/* @__PURE__ */ (0, O.jsx)(i, { className: "size-3" }), "Clear"]
504
+ })]
505
+ }), Re && /* @__PURE__ */ (0, O.jsx)("div", {
506
+ className: "mt-2 grid gap-3 sm:grid-cols-2 lg:grid-cols-3 border rounded-md p-3 bg-muted/30",
507
+ "data-testid": "record-picker-filter-panel",
508
+ children: Z.map((e) => /* @__PURE__ */ (0, O.jsx)("div", { children: ut(e) }, e.field))
509
+ })] })
510
+ }),
511
+ z && /* @__PURE__ */ (0, O.jsxs)("div", {
512
+ className: "flex flex-col items-center gap-2 py-4",
513
+ role: "alert",
514
+ children: [
515
+ /* @__PURE__ */ (0, O.jsx)(ve, { className: "size-5 text-destructive" }),
516
+ /* @__PURE__ */ (0, O.jsx)("p", {
517
+ className: "text-sm text-destructive",
518
+ children: z
519
+ }),
520
+ /* @__PURE__ */ (0, O.jsx)(d, {
521
+ variant: "outline",
522
+ size: "sm",
523
+ onClick: () => qe(H || void 0, U, Je),
524
+ type: "button",
525
+ children: "Retry"
526
+ })
527
+ ]
528
+ }),
529
+ De ? /* @__PURE__ */ (0, O.jsx)("div", {
530
+ className: "flex-1 min-h-0",
531
+ "data-testid": "record-picker-grid-slot",
532
+ children: De({
533
+ columns: Ge,
534
+ records: I,
535
+ loading: L,
536
+ totalCount: V,
537
+ currentPage: U,
538
+ pageSize: x,
539
+ sortField: K,
540
+ sortDirection: q,
541
+ onSort: Xe,
542
+ onPageChange: W,
543
+ onRowClick: $e,
544
+ isSelected: Qe,
545
+ multiple: r,
546
+ idField: se,
547
+ cellRenderer: Te
548
+ })
549
+ }) : /* @__PURE__ */ (0, O.jsxs)(O.Fragment, { children: [
550
+ L && I.length === 0 && !z && /* @__PURE__ */ (0, O.jsx)("div", {
551
+ className: "flex-1 overflow-hidden min-h-0 border rounded-md",
552
+ role: "status",
553
+ "aria-live": "polite",
554
+ "data-testid": "record-picker-skeleton",
555
+ children: /* @__PURE__ */ (0, O.jsxs)(pe, { children: [/* @__PURE__ */ (0, O.jsx)(y, { children: /* @__PURE__ */ (0, O.jsxs)(b, {
556
+ className: "bg-muted/40",
557
+ children: [r && /* @__PURE__ */ (0, O.jsx)(me, { className: "w-10" }), Ge.map((e) => /* @__PURE__ */ (0, O.jsx)(me, { children: /* @__PURE__ */ (0, O.jsx)(g, { className: "h-4 w-20" }) }, e.field))]
558
+ }) }), /* @__PURE__ */ (0, O.jsx)(_, { children: Array.from({ length: Se }, (e, t) => /* @__PURE__ */ (0, O.jsxs)(b, { children: [r && /* @__PURE__ */ (0, O.jsx)(v, {
559
+ className: "w-10",
560
+ children: /* @__PURE__ */ (0, O.jsx)(g, { className: "size-4 rounded" })
561
+ }), Ge.map((e) => /* @__PURE__ */ (0, O.jsx)(v, { children: /* @__PURE__ */ (0, O.jsx)(g, { className: "h-4 w-full" }) }, e.field))] }, t)) })] })
562
+ }),
563
+ !L && !z && I.length === 0 && /* @__PURE__ */ (0, O.jsx)("div", {
564
+ className: "py-8 text-center",
565
+ children: /* @__PURE__ */ (0, O.jsx)("p", {
566
+ className: "text-sm text-muted-foreground",
567
+ children: "No records found"
568
+ })
569
+ }),
570
+ !z && I.length > 0 && /* @__PURE__ */ (0, O.jsxs)("div", {
571
+ className: "relative flex-1 overflow-auto min-h-0 border rounded-md",
572
+ tabIndex: 0,
573
+ onKeyDown: it,
574
+ role: "grid",
575
+ "aria-label": "Records",
576
+ children: [L && /* @__PURE__ */ (0, O.jsx)("div", {
577
+ className: "absolute inset-0 z-10 flex items-center justify-center bg-background/60",
578
+ "data-testid": "record-picker-loading-overlay",
579
+ children: /* @__PURE__ */ (0, O.jsx)(ye, { className: "size-6 animate-spin text-muted-foreground" })
580
+ }), /* @__PURE__ */ (0, O.jsxs)(pe, {
581
+ style: Object.keys(Ve).length > 0 ? { tableLayout: "fixed" } : void 0,
582
+ children: [/* @__PURE__ */ (0, O.jsx)(y, {
583
+ className: "sticky top-0 z-[5] bg-muted/50 [&_tr]:border-b",
584
+ "data-testid": "record-picker-sticky-header",
585
+ children: /* @__PURE__ */ (0, O.jsxs)(b, { children: [r && /* @__PURE__ */ (0, O.jsx)(me, { className: "w-10" }), Ge.map((e) => {
586
+ let t = Ve[e.field];
587
+ return /* @__PURE__ */ (0, O.jsxs)(me, {
588
+ style: t ? {
589
+ width: `${t}px`,
590
+ minWidth: `${t}px`
591
+ } : e.width ? { width: e.width } : void 0,
592
+ className: "cursor-pointer select-none relative group text-xs font-semibold uppercase tracking-wider",
593
+ onClick: () => Xe(e.field),
594
+ "aria-sort": K === e.field ? q === "asc" ? "ascending" : "descending" : "none",
595
+ children: [/* @__PURE__ */ (0, O.jsxs)("span", {
596
+ className: "inline-flex items-center",
597
+ children: [e.label || A(e.field), ot(e.field)]
598
+ }), /* @__PURE__ */ (0, O.jsx)("span", {
599
+ role: "separator",
600
+ "aria-orientation": "vertical",
601
+ 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",
602
+ onMouseDown: (t) => {
603
+ let n = t.currentTarget.parentElement?.getBoundingClientRect();
604
+ st(t, e.field, n?.width ?? 100);
605
+ },
606
+ onClick: (e) => e.stopPropagation(),
607
+ "data-testid": `resize-handle-${e.field}`
608
+ })]
609
+ }, e.field);
610
+ })] })
611
+ }), /* @__PURE__ */ (0, O.jsx)(_, {
612
+ ref: Le,
613
+ children: I.map((e, t) => {
614
+ let n = Ze(e), i = Qe(e), a = t === J;
615
+ return /* @__PURE__ */ (0, O.jsxs)(b, {
616
+ "data-row-index": t,
617
+ className: he("cursor-pointer transition-colors", dt(i, t), a && "ring-2 ring-primary ring-inset"),
618
+ onClick: () => $e(e),
619
+ "data-testid": `record-row-${n}`,
620
+ "aria-selected": i,
621
+ children: [r && /* @__PURE__ */ (0, O.jsx)(v, {
622
+ className: "w-10",
623
+ children: i && /* @__PURE__ */ (0, O.jsx)(w, { className: "size-4 text-primary" })
624
+ }), Ge.map((t) => /* @__PURE__ */ (0, O.jsx)(v, {
625
+ className: "py-2.5",
626
+ children: at(e, t)
627
+ }, t.field))]
628
+ }, n ?? t);
629
+ })
630
+ })]
631
+ })]
632
+ }),
633
+ !z && V > 0 && /* @__PURE__ */ (0, O.jsxs)("div", {
634
+ className: "flex items-center justify-between text-sm text-muted-foreground border-t pt-3 mt-2 px-1",
635
+ "data-testid": "record-picker-pagination",
636
+ children: [/* @__PURE__ */ (0, O.jsxs)("span", { children: [
637
+ V,
638
+ " ",
639
+ V === 1 ? "record" : "records",
640
+ Q > 1 && ` · Page ${U} of ${Q}`
641
+ ] }), Q > 1 && /* @__PURE__ */ (0, O.jsxs)("div", {
642
+ className: "flex items-center gap-1.5",
643
+ children: [
644
+ /* @__PURE__ */ (0, O.jsx)(d, {
645
+ variant: "outline",
646
+ size: "icon",
647
+ className: "size-7",
648
+ onClick: tt,
649
+ disabled: U <= 1,
650
+ type: "button",
651
+ "aria-label": "Previous page",
652
+ children: /* @__PURE__ */ (0, O.jsx)(T, { className: "size-4" })
653
+ }),
654
+ /* @__PURE__ */ (0, O.jsx)(m, {
655
+ className: "h-7 w-12 text-center text-xs px-1",
656
+ placeholder: String(U),
657
+ value: Ue,
658
+ onChange: (e) => We(e.target.value),
659
+ onKeyDown: rt,
660
+ "aria-label": "Jump to page",
661
+ "data-testid": "record-picker-page-jump"
662
+ }),
663
+ /* @__PURE__ */ (0, O.jsx)(d, {
664
+ variant: "outline",
665
+ size: "icon",
666
+ className: "size-7",
667
+ onClick: nt,
668
+ disabled: U >= Q,
669
+ type: "button",
670
+ "aria-label": "Next page",
671
+ children: /* @__PURE__ */ (0, O.jsx)(_e, { className: "size-4" })
672
+ })
673
+ ]
674
+ })]
675
+ })
676
+ ] }),
677
+ r && /* @__PURE__ */ (0, O.jsx)(f, { children: /* @__PURE__ */ (0, O.jsxs)("div", {
678
+ className: "flex items-center gap-2 w-full justify-between",
679
+ children: [/* @__PURE__ */ (0, O.jsxs)("span", {
680
+ className: "text-sm text-muted-foreground",
681
+ children: [Ne.size, " selected"]
682
+ }), /* @__PURE__ */ (0, O.jsxs)("div", {
683
+ className: "flex gap-2",
684
+ children: [/* @__PURE__ */ (0, O.jsx)(d, {
685
+ variant: "outline",
686
+ type: "button",
687
+ onClick: () => t(!1),
688
+ children: "Cancel"
689
+ }), /* @__PURE__ */ (0, O.jsx)(d, {
690
+ type: "button",
691
+ onClick: et,
692
+ children: "Confirm"
693
+ })]
694
+ })]
695
+ }) })
696
+ ]
697
+ })
698
+ });
699
+ }
700
+ //#endregion
701
+ //#region ../fields/src/widgets/_cell-renderer-bridge.ts
702
+ var N;
703
+ function P(e) {
704
+ N = e;
705
+ }
706
+ function Te() {
707
+ return N;
708
+ }
709
+ //#endregion
710
+ //#region ../fields/src/widgets/LookupField.tsx
711
+ var F = /* @__PURE__ */ e({ LookupField: () => L }), Ee = 50, De = x;
712
+ function I(e, t, n, r) {
713
+ let i = e[n] ?? e.id ?? e._id, a = e[t] ?? e.label ?? e.name ?? String(i), ee = r ? e[r] : void 0;
714
+ return {
715
+ value: i,
716
+ label: String(a),
717
+ description: ee,
718
+ ...e
719
+ };
720
+ }
721
+ function Oe(e) {
722
+ return {
723
+ text: "text",
724
+ number: "number",
725
+ currency: "number",
726
+ percent: "number",
727
+ select: "select",
728
+ status: "select",
729
+ date: "date",
730
+ datetime: "date",
731
+ boolean: "boolean"
732
+ }[e];
733
+ }
734
+ function L({ value: e, onChange: t, field: n, readonly: te, ...ne }) {
735
+ let [re, f] = l(!1), [p, ie] = l(""), [h, ce] = l([]), [le, ue] = l(!1), [de, fe] = l(null), [g, pe] = l(0), _ = c(null), [v, me] = l([]), [y, b] = l(-1), he = c(null), x = n || ne.schema, S = x?.field, C = S && typeof S == "object" && ("reference_to" in S || "reference" in S || "type" in S) ? S : x, ge = C?.options || [], w = C?.multiple || !1, T = C?.display_field || C?.reference_field || "name", _e = C?.description_field, E = C?.id_field || "id", k = C?.reference_to || C?.reference, xe = C?.lookup_columns, Se = C?.lookup_page_size, Ce = C?.lookup_filters, A = s(() => {
736
+ if (!xe) return;
737
+ let e = [];
738
+ for (let t of xe) if (typeof t == "object" && t.type) {
739
+ let n = Oe(t.type);
740
+ n && e.push({
741
+ field: t.field,
742
+ label: t.label,
743
+ type: n
744
+ });
745
+ }
746
+ return e.length > 0 ? e : void 0;
747
+ }, [xe]), we = ee(De)?.dataSource ?? null, j = ne.dataSource ?? x?.dataSource ?? C?.dataSource ?? we, N = j != null && typeof j.find == "function" && !!k, P = ne.onCreateNew ?? x?.onCreateNew, [F, L] = l(!1), R = N ? h : ge, z = s(() => {
748
+ if (N || !p) return R;
749
+ let e = p.toLowerCase();
750
+ return R.filter((t) => t.label.toLowerCase().includes(e) || t.description && t.description.toLowerCase().includes(e));
751
+ }, [
752
+ N,
753
+ R,
754
+ p
755
+ ]);
756
+ o(() => {
757
+ b(-1);
758
+ }, [z.length]);
759
+ let B = a(async (e) => {
760
+ if (!(!j || !k)) {
761
+ ue(!0), fe(null);
762
+ try {
763
+ let t = { $top: Ee };
764
+ e && e.trim() && (t.$search = e.trim());
765
+ let n = await j.find(k, t), r = n?.data ?? n ?? [];
766
+ ce(r.map((e) => I(e, T, E, _e))), pe(n?.total ?? r.length);
767
+ } catch (e) {
768
+ fe(e instanceof Error ? e.message : String(e)), ce([]);
769
+ } finally {
770
+ ue(!1);
771
+ }
772
+ }
773
+ }, [
774
+ j,
775
+ k,
776
+ T,
777
+ E,
778
+ _e
779
+ ]);
780
+ o(() => {
781
+ re && N && B(p || void 0), re || (ie(""), fe(null), b(-1));
782
+ }, [re]);
783
+ let V = a((e) => {
784
+ ie(e), N && (_.current && clearTimeout(_.current), _.current = setTimeout(() => {
785
+ B(e || void 0);
786
+ }, 300));
787
+ }, [N, B]);
788
+ o(() => () => {
789
+ _.current && clearTimeout(_.current);
790
+ }, []);
791
+ let ke = a((e) => ge.find((t) => t.value === e) ?? h.find((t) => t.value === e) ?? v.find((t) => t.value === e), [
792
+ ge,
793
+ h,
794
+ v
795
+ ]), H = w ? (Array.isArray(e) ? e : []).map(ke).filter(Boolean) : e ? [ke(e)].filter(Boolean) : [], Ae = a((n) => {
796
+ if (w) {
797
+ let r = Array.isArray(e) ? e : [];
798
+ r.includes(n.value) ? t(r.filter((e) => e !== n.value)) : t([...r, n.value]);
799
+ } else t(n.value), f(!1);
800
+ }, [
801
+ w,
802
+ e,
803
+ t
804
+ ]), U = (n) => {
805
+ t(w ? (Array.isArray(e) ? e : []).filter((e) => e !== n) : null);
806
+ }, W = a((e) => {
807
+ me(e.map((e) => I(e, T, E, _e)));
808
+ }, [
809
+ T,
810
+ E,
811
+ _e
812
+ ]), G = a((e) => {
813
+ e.key === "ArrowDown" ? (e.preventDefault(), b((e) => e < z.length - 1 ? e + 1 : e)) : e.key === "ArrowUp" ? (e.preventDefault(), b((e) => e > 0 ? e - 1 : 0)) : e.key === "Enter" && (e.preventDefault(), y >= 0 && y < z.length && Ae(z[y]));
814
+ }, [
815
+ z,
816
+ y,
817
+ Ae
818
+ ]);
819
+ return o(() => {
820
+ y >= 0 && he.current && he.current.querySelector(`[data-lookup-index="${y}"]`)?.scrollIntoView({ block: "nearest" });
821
+ }, [y]), te ? H.length ? w ? /* @__PURE__ */ (0, O.jsx)("div", {
822
+ className: "flex flex-wrap gap-1",
823
+ children: H.map((e, t) => /* @__PURE__ */ (0, O.jsx)(u, {
824
+ variant: "outline",
825
+ children: e?.[T] || e?.label
826
+ }, t))
827
+ }) : /* @__PURE__ */ (0, O.jsx)("span", {
828
+ className: "text-sm",
829
+ children: H[0]?.[T] || H[0]?.label
830
+ }) : /* @__PURE__ */ (0, O.jsx)("span", {
831
+ className: "text-sm",
832
+ children: "-"
833
+ }) : /* @__PURE__ */ (0, O.jsxs)("div", {
834
+ className: "space-y-2",
835
+ children: [
836
+ H.length > 0 && /* @__PURE__ */ (0, O.jsx)("div", {
837
+ className: "flex flex-wrap gap-1",
838
+ children: H.map((e, t) => /* @__PURE__ */ (0, O.jsxs)(u, {
839
+ variant: "outline",
840
+ className: "gap-1",
841
+ children: [e?.[T] || e?.label, /* @__PURE__ */ (0, O.jsx)("button", {
842
+ onClick: () => U(e?.value),
843
+ className: "ml-1 hover:text-destructive",
844
+ type: "button",
845
+ "aria-label": `Remove ${e?.[T] || e?.label}`,
846
+ children: /* @__PURE__ */ (0, O.jsx)(i, { className: "size-3" })
847
+ })]
848
+ }, t))
849
+ }),
850
+ /* @__PURE__ */ (0, O.jsxs)("div", {
851
+ className: "flex items-center gap-1.5",
852
+ children: [/* @__PURE__ */ (0, O.jsxs)(ae, {
853
+ open: re,
854
+ onOpenChange: f,
855
+ children: [/* @__PURE__ */ (0, O.jsx)(se, {
856
+ asChild: !0,
857
+ children: /* @__PURE__ */ (0, O.jsxs)(d, {
858
+ variant: "outline",
859
+ className: "min-w-0 flex-1 justify-start text-left font-normal",
860
+ type: "button",
861
+ children: [/* @__PURE__ */ (0, O.jsx)(be, { className: "mr-2 size-4" }), H.length === 0 ? x?.placeholder || "Select..." : w ? `${H.length} selected` : "Change selection"]
862
+ })
863
+ }), /* @__PURE__ */ (0, O.jsxs)(oe, {
864
+ className: "w-[var(--radix-popover-trigger-width)] p-0",
865
+ align: "start",
866
+ children: [
867
+ /* @__PURE__ */ (0, O.jsx)("div", {
868
+ className: "p-2",
869
+ children: /* @__PURE__ */ (0, O.jsxs)("div", {
870
+ className: "relative",
871
+ children: [
872
+ /* @__PURE__ */ (0, O.jsx)(be, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 text-muted-foreground" }),
873
+ /* @__PURE__ */ (0, O.jsx)(m, {
874
+ placeholder: "Search...",
875
+ value: p,
876
+ onChange: (e) => V(e.target.value),
877
+ onKeyDown: G,
878
+ className: "w-full pl-9 h-8 text-sm"
879
+ }),
880
+ le && /* @__PURE__ */ (0, O.jsx)(ye, {
881
+ className: "absolute right-3 top-1/2 -translate-y-1/2 size-4 animate-spin text-muted-foreground",
882
+ "data-testid": "lookup-loading"
883
+ })
884
+ ]
885
+ })
886
+ }),
887
+ de && /* @__PURE__ */ (0, O.jsxs)("div", {
888
+ className: "flex flex-col items-center gap-2 py-4 px-2",
889
+ role: "alert",
890
+ children: [
891
+ /* @__PURE__ */ (0, O.jsx)(ve, { className: "size-5 text-destructive" }),
892
+ /* @__PURE__ */ (0, O.jsx)("p", {
893
+ className: "text-sm text-destructive",
894
+ children: de
895
+ }),
896
+ /* @__PURE__ */ (0, O.jsx)(d, {
897
+ variant: "outline",
898
+ size: "sm",
899
+ onClick: () => B(p || void 0),
900
+ type: "button",
901
+ children: "Retry"
902
+ })
903
+ ]
904
+ }),
905
+ le && z.length === 0 && !de && /* @__PURE__ */ (0, O.jsxs)("div", {
906
+ className: "flex flex-col items-center gap-2 py-6",
907
+ role: "status",
908
+ "aria-live": "polite",
909
+ children: [/* @__PURE__ */ (0, O.jsx)(ye, { className: "size-6 animate-spin text-muted-foreground" }), /* @__PURE__ */ (0, O.jsx)("p", {
910
+ className: "text-sm text-muted-foreground",
911
+ children: "Loading…"
912
+ })]
913
+ }),
914
+ !de && !(le && z.length === 0) && /* @__PURE__ */ (0, O.jsx)("div", {
915
+ ref: he,
916
+ className: "max-h-64 overflow-y-auto px-1 pb-1",
917
+ role: "listbox",
918
+ children: z.length === 0 ? /* @__PURE__ */ (0, O.jsxs)("div", {
919
+ className: "py-4 text-center",
920
+ children: [/* @__PURE__ */ (0, O.jsx)("p", {
921
+ className: "text-sm text-muted-foreground",
922
+ children: "No options found"
923
+ }), P && /* @__PURE__ */ (0, O.jsxs)(d, {
924
+ variant: "ghost",
925
+ size: "sm",
926
+ className: "mt-2 gap-1",
927
+ type: "button",
928
+ onClick: () => {
929
+ P(p), f(!1);
930
+ },
931
+ children: [/* @__PURE__ */ (0, O.jsx)(r, { className: "size-4" }), "Create new"]
932
+ })]
933
+ }) : /* @__PURE__ */ (0, O.jsxs)(O.Fragment, { children: [
934
+ z.map((t, n) => {
935
+ let r = w ? (Array.isArray(e) ? e : []).includes(t.value) : e === t.value, i = n === y;
936
+ return /* @__PURE__ */ (0, O.jsxs)("button", {
937
+ "data-lookup-index": n,
938
+ role: "option",
939
+ "aria-selected": r,
940
+ onClick: () => Ae(t),
941
+ className: `w-full text-left px-3 py-2 rounded-md text-sm hover:bg-accent flex items-center justify-between ${i ? "bg-accent text-accent-foreground" : r ? "bg-accent/50 text-accent-foreground" : ""}`,
942
+ type: "button",
943
+ children: [/* @__PURE__ */ (0, O.jsxs)("div", {
944
+ className: "min-w-0 flex-1",
945
+ children: [/* @__PURE__ */ (0, O.jsx)("span", {
946
+ className: "block truncate",
947
+ children: t.label
948
+ }), t.description && /* @__PURE__ */ (0, O.jsx)("span", {
949
+ className: "block truncate text-xs text-muted-foreground",
950
+ children: t.description
951
+ })]
952
+ }), r && /* @__PURE__ */ (0, O.jsx)(u, {
953
+ variant: "default",
954
+ className: "ml-2 shrink-0",
955
+ children: "Selected"
956
+ })]
957
+ }, t.value);
958
+ }),
959
+ N && g > z.length && /* @__PURE__ */ (0, O.jsxs)("p", {
960
+ className: "text-xs text-muted-foreground text-center py-2",
961
+ children: [
962
+ "Showing ",
963
+ z.length,
964
+ " of ",
965
+ g,
966
+ " results."
967
+ ]
968
+ }),
969
+ N && g > z.length && /* @__PURE__ */ (0, O.jsxs)("button", {
970
+ type: "button",
971
+ 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",
972
+ onClick: () => {
973
+ f(!1), L(!0);
974
+ },
975
+ "data-testid": "show-all-results",
976
+ children: [
977
+ /* @__PURE__ */ (0, O.jsx)(D, { className: "size-3.5" }),
978
+ "Show All Results (",
979
+ g,
980
+ ")"
981
+ ]
982
+ }),
983
+ P && /* @__PURE__ */ (0, O.jsxs)("button", {
984
+ type: "button",
985
+ 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",
986
+ onClick: () => {
987
+ P(p), f(!1);
988
+ },
989
+ children: [
990
+ /* @__PURE__ */ (0, O.jsx)(r, { className: "size-3.5" }),
991
+ "Create new",
992
+ p ? ` "${p}"` : ""
993
+ ]
994
+ })
995
+ ] })
996
+ })
997
+ ]
998
+ })]
999
+ }), N && /* @__PURE__ */ (0, O.jsx)(d, {
1000
+ variant: "outline",
1001
+ size: "icon",
1002
+ className: "shrink-0",
1003
+ type: "button",
1004
+ onClick: () => L(!0),
1005
+ "aria-label": "Browse all records",
1006
+ title: "Browse all records",
1007
+ "data-testid": "browse-all-records",
1008
+ children: /* @__PURE__ */ (0, O.jsx)(D, { className: "size-4" })
1009
+ })]
1010
+ }),
1011
+ N && j && k && /* @__PURE__ */ (0, O.jsx)(M, {
1012
+ open: F,
1013
+ onOpenChange: L,
1014
+ title: x?.label || "Select",
1015
+ multiple: w,
1016
+ dataSource: j,
1017
+ objectName: k,
1018
+ columns: xe,
1019
+ displayField: T,
1020
+ idField: E,
1021
+ pageSize: Se,
1022
+ value: e,
1023
+ onSelect: t,
1024
+ onSelectRecords: W,
1025
+ lookupFilters: Ce,
1026
+ cellRenderer: Te(),
1027
+ filterColumns: A
1028
+ })
1029
+ ]
1030
+ });
1031
+ }
1032
+ //#endregion
1033
+ export { w as i, F as n, P as r, L as t };