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