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