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