@object-ui/fields 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/AddressField-B6fPb2Fs.js +3 -0
  2. package/dist/AddressField-Ctsxkj35.cjs +1 -0
  3. package/dist/AutoNumberField-DXIYJfiB.js +3 -0
  4. package/dist/AutoNumberField-f76XU1bR.cjs +1 -0
  5. package/dist/AvatarField-BHpex3Wa.js +3 -0
  6. package/dist/AvatarField-CXOdYavl.cjs +1 -0
  7. package/dist/BooleanField-Bs0urhsx.js +3 -0
  8. package/dist/BooleanField-DeexI_O2.cjs +1 -0
  9. package/dist/CodeField-DDOMH8E8.cjs +1 -0
  10. package/dist/CodeField-tRACqngO.js +3 -0
  11. package/dist/ColorField-Bar6bOJw.js +3 -0
  12. package/dist/ColorField-CM9CxZ9h.cjs +1 -0
  13. package/dist/CurrencyField-CezTX_rA.cjs +1 -0
  14. package/dist/CurrencyField-D4VwXI9k.js +3 -0
  15. package/dist/DateField-DDUllj7w.cjs +1 -0
  16. package/dist/DateField-DjGiK6BH.js +3 -0
  17. package/dist/DateTimeField-DBh-dYdR.js +3 -0
  18. package/dist/DateTimeField-DDqgVN3b.cjs +1 -0
  19. package/dist/EmailField-B-3nY8Pr.cjs +1 -0
  20. package/dist/EmailField-Cp6yJlpH.js +3 -0
  21. package/dist/FileField-C1bcL7tu.cjs +1 -0
  22. package/dist/FileField-DUgt6ai3.js +3 -0
  23. package/dist/FormulaField-BLV1KgkQ.js +3 -0
  24. package/dist/FormulaField-CsbQIZ7S.cjs +1 -0
  25. package/dist/GeolocationField-BbIRH51u.js +3 -0
  26. package/dist/GeolocationField-UFu9VR-x.cjs +1 -0
  27. package/dist/GridField-2m74haE0.cjs +1 -0
  28. package/dist/GridField-O3Jd1NuJ.js +3 -0
  29. package/dist/ImageField-Cna7g6KL.cjs +1 -0
  30. package/dist/ImageField-rc1Nzcvb.js +3 -0
  31. package/dist/LocationField-DpRe9QlH.cjs +1 -0
  32. package/dist/LocationField-QZPPYo0J.js +3 -0
  33. package/dist/LookupField-BX4sK8NG.js +904 -0
  34. package/dist/LookupField-C9rPrHi_.cjs +1 -0
  35. package/dist/MasterDetailField-BXncIT1s.js +3 -0
  36. package/dist/MasterDetailField-TNP2825Z.cjs +1 -0
  37. package/dist/NumberField-DCHTzmDG.js +3 -0
  38. package/dist/NumberField-SqRwbcY8.cjs +1 -0
  39. package/dist/ObjectField-BEUHpn_X.js +3 -0
  40. package/dist/ObjectField-BWZwaFIG.cjs +1 -0
  41. package/dist/PasswordField-BZ_OeQyw.js +3 -0
  42. package/dist/PasswordField-kLp-ZyPm.cjs +1 -0
  43. package/dist/PercentField-B2t2knlc.js +3 -0
  44. package/dist/PercentField-BzhD6tQm.cjs +1 -0
  45. package/dist/PhoneField-CirvuysP.cjs +1 -0
  46. package/dist/PhoneField-CkrCFmcO.js +3 -0
  47. package/dist/QRCodeField-C4OOLCbE.cjs +1 -0
  48. package/dist/QRCodeField-CQoGow8y.js +3 -0
  49. package/dist/RatingField-CZG8SgQ8.cjs +1 -0
  50. package/dist/RatingField-DecDJkou.js +3 -0
  51. package/dist/RichTextField-Bog2i4NN.cjs +1 -0
  52. package/dist/RichTextField-b-8QbNCJ.js +3 -0
  53. package/dist/SelectField-CAa6c0cB.cjs +1 -0
  54. package/dist/SelectField-DMy5IxRc.js +3 -0
  55. package/dist/SignatureField-BvTPE7Dn.js +3 -0
  56. package/dist/SignatureField-jsb-0AYp.cjs +1 -0
  57. package/dist/SliderField-B7WvKFv7.js +3 -0
  58. package/dist/SliderField-DRjEJSxK.cjs +1 -0
  59. package/dist/SummaryField-DA16Edq3.cjs +1 -0
  60. package/dist/SummaryField-DVSVfKmY.js +3 -0
  61. package/dist/TextAreaField--ut87UiB.js +3 -0
  62. package/dist/TextAreaField-Cxp3DFC6.cjs +1 -0
  63. package/dist/TextField-CkEDGbkQ.js +3 -0
  64. package/dist/TextField-aLAzBaLZ.cjs +1 -0
  65. package/dist/TimeField-D0lF0y_I.cjs +1 -0
  66. package/dist/TimeField-DA_S6lQV.js +3 -0
  67. package/dist/UrlField-D0ugmD3f.cjs +1 -0
  68. package/dist/UrlField-DCnXHR1A.js +3 -0
  69. package/dist/UserField-DGlorzyG.cjs +1 -0
  70. package/dist/UserField-V0GmvyGV.js +3 -0
  71. package/dist/VectorField-BSD85ntU.cjs +1 -0
  72. package/dist/VectorField-CVi5yrrc.js +3 -0
  73. package/dist/fields/src/index.d.ts +8 -0
  74. package/dist/fields/src/record-picker-dialog.stories.d.ts +25 -0
  75. package/dist/fields/src/record-picker.test.d.ts +1 -0
  76. package/dist/fields/src/widgets/LookupField.d.ts +13 -2
  77. package/dist/fields/src/widgets/RecordPickerDialog.d.ts +166 -0
  78. package/dist/fields/src/widgets/_cell-renderer-bridge.d.ts +3 -0
  79. package/dist/index.cjs +4 -9
  80. package/dist/index.js +2229 -2682
  81. package/dist/jsx-runtime-DHCF5ANT.cjs +6 -0
  82. package/dist/jsx-runtime-MxADXuRH.js +189 -0
  83. package/package.json +8 -7
  84. package/src/__tests__/cell-renderers.test.tsx +133 -4
  85. package/src/complex-widgets.test.tsx +426 -2
  86. package/src/index.tsx +76 -22
  87. package/src/record-picker-dialog.stories.tsx +160 -0
  88. package/src/record-picker.test.tsx +1696 -0
  89. package/src/widgets/LookupField.tsx +485 -80
  90. package/src/widgets/RecordPickerDialog.tsx +1182 -0
  91. package/src/widgets/_cell-renderer-bridge.ts +19 -0
package/dist/index.js CHANGED
@@ -1,2690 +1,2237 @@
1
- import k, { useId as vt, useState as B, useRef as xe, useCallback as te, useEffect as ze } from "react";
2
- import { ComponentRegistry as g } from "@object-ui/core";
3
- import { Textarea as Z, Input as w, Checkbox as Ee, Label as E, Switch as _t, Select as wt, SelectTrigger as Ft, SelectValue as St, SelectContent as Ct, SelectItem as Pt, Badge as M, Dialog as Tt, DialogTrigger as Ot, Button as P, DialogContent as Rt, DialogHeader as kt, DialogTitle as At, Slider as De, Avatar as L, AvatarFallback as I, cn as z, AvatarImage as ve } from "@object-ui/components";
4
- import { X as W, Search as $t, EyeOff as zt, Eye as Et, Upload as Me, ImageIcon as Dt, File as Mt, Image as Lt, Star as _e, MapPin as we, Crosshair as It, Eraser as Ut, QrCode as Fe, Copy as pe, ExternalLink as Se, Plus as Vt, Check as he, Phone as Bt } from "lucide-react";
5
- var re = { exports: {} }, H = {};
6
- var Ce;
7
- function Yt() {
8
- if (Ce) return H;
9
- Ce = 1;
10
- var e = /* @__PURE__ */ Symbol.for("react.transitional.element"), r = /* @__PURE__ */ Symbol.for("react.fragment");
11
- function n(a, s, i) {
12
- var l = null;
13
- if (i !== void 0 && (l = "" + i), s.key !== void 0 && (l = "" + s.key), "key" in s) {
14
- i = {};
15
- for (var o in s)
16
- o !== "key" && (i[o] = s[o]);
17
- } else i = s;
18
- return s = i.ref, {
19
- $$typeof: e,
20
- type: a,
21
- key: l,
22
- ref: s !== void 0 ? s : null,
23
- props: i
24
- };
25
- }
26
- return H.Fragment = r, H.jsx = n, H.jsxs = n, H;
27
- }
28
- var X = {};
29
- var Pe;
30
- function qt() {
31
- return Pe || (Pe = 1, process.env.NODE_ENV !== "production" && (function() {
32
- function e(d) {
33
- if (d == null) return null;
34
- if (typeof d == "function")
35
- return d.$$typeof === Y ? null : d.displayName || d.name || null;
36
- if (typeof d == "string") return d;
37
- switch (d) {
38
- case R:
39
- return "Fragment";
40
- case T:
41
- return "Profiler";
42
- case N:
43
- return "StrictMode";
44
- case b:
45
- return "Suspense";
46
- case F:
47
- return "SuspenseList";
48
- case O:
49
- return "Activity";
50
- }
51
- if (typeof d == "object")
52
- switch (typeof d.tag == "number" && console.error(
53
- "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
54
- ), d.$$typeof) {
55
- case v:
56
- return "Portal";
57
- case Q:
58
- return d.displayName || "Context";
59
- case U:
60
- return (d._context.displayName || "Context") + ".Consumer";
61
- case K:
62
- var j = d.render;
63
- return d = d.displayName, d || (d = j.displayName || j.name || "", d = d !== "" ? "ForwardRef(" + d + ")" : "ForwardRef"), d;
64
- case A:
65
- return j = d.displayName || null, j !== null ? j : e(d.type) || "Memo";
66
- case $:
67
- j = d._payload, d = d._init;
68
- try {
69
- return e(d(j));
70
- } catch {
71
- }
72
- }
73
- return null;
74
- }
75
- function r(d) {
76
- return "" + d;
77
- }
78
- function n(d) {
79
- try {
80
- r(d);
81
- var j = !1;
82
- } catch {
83
- j = !0;
84
- }
85
- if (j) {
86
- j = console;
87
- var _ = j.error, S = typeof Symbol == "function" && Symbol.toStringTag && d[Symbol.toStringTag] || d.constructor.name || "Object";
88
- return _.call(
89
- j,
90
- "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
91
- S
92
- ), r(d);
93
- }
94
- }
95
- function a(d) {
96
- if (d === R) return "<>";
97
- if (typeof d == "object" && d !== null && d.$$typeof === $)
98
- return "<...>";
99
- try {
100
- var j = e(d);
101
- return j ? "<" + j + ">" : "<...>";
102
- } catch {
103
- return "<...>";
104
- }
105
- }
106
- function s() {
107
- var d = q.A;
108
- return d === null ? null : d.getOwner();
109
- }
110
- function i() {
111
- return Error("react-stack-top-frame");
112
- }
113
- function l(d) {
114
- if (V.call(d, "key")) {
115
- var j = Object.getOwnPropertyDescriptor(d, "key").get;
116
- if (j && j.isReactWarning) return !1;
117
- }
118
- return d.key !== void 0;
119
- }
120
- function o(d, j) {
121
- function _() {
122
- ge || (ge = !0, console.error(
123
- "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
124
- j
125
- ));
126
- }
127
- _.isReactWarning = !0, Object.defineProperty(d, "key", {
128
- get: _,
129
- configurable: !0
130
- });
131
- }
132
- function c() {
133
- var d = e(this.type);
134
- return be[d] || (be[d] = !0, console.error(
135
- "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
136
- )), d = this.props.ref, d !== void 0 ? d : null;
137
- }
138
- function m(d, j, _, S, ee, ie) {
139
- var C = _.ref;
140
- return d = {
141
- $$typeof: h,
142
- type: d,
143
- key: j,
144
- props: _,
145
- _owner: S
146
- }, (C !== void 0 ? C : null) !== null ? Object.defineProperty(d, "ref", {
147
- enumerable: !1,
148
- get: c
149
- }) : Object.defineProperty(d, "ref", { enumerable: !1, value: null }), d._store = {}, Object.defineProperty(d._store, "validated", {
150
- configurable: !1,
151
- enumerable: !1,
152
- writable: !0,
153
- value: 0
154
- }), Object.defineProperty(d, "_debugInfo", {
155
- configurable: !1,
156
- enumerable: !1,
157
- writable: !0,
158
- value: null
159
- }), Object.defineProperty(d, "_debugStack", {
160
- configurable: !1,
161
- enumerable: !1,
162
- writable: !0,
163
- value: ee
164
- }), Object.defineProperty(d, "_debugTask", {
165
- configurable: !1,
166
- enumerable: !1,
167
- writable: !0,
168
- value: ie
169
- }), Object.freeze && (Object.freeze(d.props), Object.freeze(d)), d;
170
- }
171
- function p(d, j, _, S, ee, ie) {
172
- var C = j.children;
173
- if (C !== void 0)
174
- if (S)
175
- if (yt(C)) {
176
- for (S = 0; S < C.length; S++)
177
- f(C[S]);
178
- Object.freeze && Object.freeze(C);
179
- } else
180
- console.error(
181
- "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
182
- );
183
- else f(C);
184
- if (V.call(j, "key")) {
185
- C = e(d);
186
- var J = Object.keys(j).filter(function(Nt) {
187
- return Nt !== "key";
188
- });
189
- S = 0 < J.length ? "{key: someKey, " + J.join(": ..., ") + ": ...}" : "{key: someKey}", Ne[C + S] || (J = 0 < J.length ? "{" + J.join(": ..., ") + ": ...}" : "{}", console.error(
190
- `A props object containing a "key" prop is being spread into JSX:
191
- let props = %s;
192
- <%s {...props} />
193
- React keys must be passed directly to JSX without using spread:
194
- let props = %s;
195
- <%s key={someKey} {...props} />`,
196
- S,
197
- C,
198
- J,
199
- C
200
- ), Ne[C + S] = !0);
201
- }
202
- if (C = null, _ !== void 0 && (n(_), C = "" + _), l(j) && (n(j.key), C = "" + j.key), "key" in j) {
203
- _ = {};
204
- for (var oe in j)
205
- oe !== "key" && (_[oe] = j[oe]);
206
- } else _ = j;
207
- return C && o(
208
- _,
209
- typeof d == "function" ? d.displayName || d.name || "Unknown" : d
210
- ), m(
211
- d,
212
- C,
213
- _,
214
- s(),
215
- ee,
216
- ie
217
- );
218
- }
219
- function f(d) {
220
- u(d) ? d._store && (d._store.validated = 1) : typeof d == "object" && d !== null && d.$$typeof === $ && (d._payload.status === "fulfilled" ? u(d._payload.value) && d._payload.value._store && (d._payload.value._store.validated = 1) : d._store && (d._store.validated = 1));
221
- }
222
- function u(d) {
223
- return typeof d == "object" && d !== null && d.$$typeof === h;
224
- }
225
- var x = k, h = /* @__PURE__ */ Symbol.for("react.transitional.element"), v = /* @__PURE__ */ Symbol.for("react.portal"), R = /* @__PURE__ */ Symbol.for("react.fragment"), N = /* @__PURE__ */ Symbol.for("react.strict_mode"), T = /* @__PURE__ */ Symbol.for("react.profiler"), U = /* @__PURE__ */ Symbol.for("react.consumer"), Q = /* @__PURE__ */ Symbol.for("react.context"), K = /* @__PURE__ */ Symbol.for("react.forward_ref"), b = /* @__PURE__ */ Symbol.for("react.suspense"), F = /* @__PURE__ */ Symbol.for("react.suspense_list"), A = /* @__PURE__ */ Symbol.for("react.memo"), $ = /* @__PURE__ */ Symbol.for("react.lazy"), O = /* @__PURE__ */ Symbol.for("react.activity"), Y = /* @__PURE__ */ Symbol.for("react.client.reference"), q = x.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, V = Object.prototype.hasOwnProperty, yt = Array.isArray, le = console.createTask ? console.createTask : function() {
226
- return null;
227
- };
228
- x = {
229
- react_stack_bottom_frame: function(d) {
230
- return d();
231
- }
232
- };
233
- var ge, be = {}, je = x.react_stack_bottom_frame.bind(
234
- x,
235
- i
236
- )(), ye = le(a(i)), Ne = {};
237
- X.Fragment = R, X.jsx = function(d, j, _) {
238
- var S = 1e4 > q.recentlyCreatedOwnerStacks++;
239
- return p(
240
- d,
241
- j,
242
- _,
243
- !1,
244
- S ? Error("react-stack-top-frame") : je,
245
- S ? le(a(d)) : ye
246
- );
247
- }, X.jsxs = function(d, j, _) {
248
- var S = 1e4 > q.recentlyCreatedOwnerStacks++;
249
- return p(
250
- d,
251
- j,
252
- _,
253
- !0,
254
- S ? Error("react-stack-top-frame") : je,
255
- S ? le(a(d)) : ye
256
- );
257
- };
258
- })()), X;
259
- }
260
- var Te;
261
- function Jt() {
262
- return Te || (Te = 1, process.env.NODE_ENV === "production" ? re.exports = Yt() : re.exports = qt()), re.exports;
263
- }
264
- var t = Jt();
265
- function Le({ value: e, onChange: r, field: n, readonly: a, ...s }) {
266
- const i = n || s.schema;
267
- if (a)
268
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: e || "-" });
269
- const l = i?.rows, { inputType: o, ...c } = s;
270
- return l && l > 1 ? /* @__PURE__ */ t.jsx(
271
- Z,
272
- {
273
- ...c,
274
- value: e || "",
275
- onChange: (m) => r(m.target.value),
276
- placeholder: i?.placeholder,
277
- disabled: a || c.disabled
278
- }
279
- ) : /* @__PURE__ */ t.jsx(
280
- w,
281
- {
282
- ...c,
283
- type: i?.type === "password" ? "password" : "text",
284
- value: e || "",
285
- onChange: (m) => r(m.target.value),
286
- placeholder: i?.placeholder,
287
- disabled: a || c.disabled
288
- }
289
- );
290
- }
291
- const Wt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
292
- __proto__: null,
293
- TextField: Le
294
- }, Symbol.toStringTag, { value: "Module" }));
295
- function Ie({ value: e, onChange: r, field: n, readonly: a, ...s }) {
296
- if (a)
297
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: e ?? "-" });
298
- const i = n || s.schema, l = i?.precision, { inputType: o, ...c } = s;
299
- return /* @__PURE__ */ t.jsx(
300
- w,
301
- {
302
- ...c,
303
- type: "number",
304
- value: e ?? "",
305
- onChange: (m) => {
306
- const p = m.target.value;
307
- r(p === "" ? null : Number(p));
308
- },
309
- placeholder: i?.placeholder,
310
- disabled: a || c.disabled,
311
- step: l ? Math.pow(10, -l) : "any"
312
- }
313
- );
314
- }
315
- const Gt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
316
- __proto__: null,
317
- NumberField: Ie
318
- }, Symbol.toStringTag, { value: "Module" }));
319
- function Ue({ value: e, onChange: r, field: n, readonly: a, ...s }) {
320
- const i = n || s.schema, l = i?.widget, o = vt(), c = i?.name || o, m = i?.label || "Checkbox";
321
- if (a)
322
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: e ? "Yes" : "No" });
323
- const { inputType: p, ...f } = s;
324
- return l === "checkbox" ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-2", children: [
325
- /* @__PURE__ */ t.jsx(
326
- Ee,
327
- {
328
- ...f,
329
- id: c,
330
- checked: !!e,
331
- onCheckedChange: (u) => r(!!u),
332
- disabled: a || f.disabled
333
- }
334
- ),
335
- /* @__PURE__ */ t.jsx(E, { htmlFor: c, children: m })
336
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: "flex items-center space-x-2", children: [
337
- /* @__PURE__ */ t.jsx(
338
- _t,
339
- {
340
- ...f,
341
- id: c,
342
- checked: !!e,
343
- onCheckedChange: r,
344
- disabled: a || f.disabled
345
- }
346
- ),
347
- /* @__PURE__ */ t.jsx(E, { htmlFor: c, children: m })
348
- ] });
349
- }
350
- const Qt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
351
- __proto__: null,
352
- BooleanField: Ue
353
- }, Symbol.toStringTag, { value: "Module" }));
354
- function Ve({ value: e, onChange: r, field: n, readonly: a, ...s }) {
355
- const i = n || s.schema, l = i?.options || [];
356
- if (a) {
357
- const o = l.find((c) => c.value === e);
358
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: o?.label || e || "-" });
359
- }
360
- return /* @__PURE__ */ t.jsxs(
361
- wt,
362
- {
363
- ...s,
364
- value: e,
365
- onValueChange: r,
366
- disabled: a || s.disabled,
367
- children: [
368
- /* @__PURE__ */ t.jsx(Ft, { className: s.className, id: s.id, children: /* @__PURE__ */ t.jsx(St, { placeholder: i?.placeholder || "Select an option" }) }),
369
- /* @__PURE__ */ t.jsx(Ct, { position: "popper", children: l.map((o) => /* @__PURE__ */ t.jsx(Pt, { value: o.value, children: o.label }, o.value)) })
370
- ]
371
- }
372
- );
373
- }
374
- const Ht = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
375
- __proto__: null,
376
- SelectField: Ve
377
- }, Symbol.toStringTag, { value: "Module" }));
378
- function Be({ value: e, onChange: r, field: n, readonly: a, ...s }) {
379
- if (a)
380
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: e ? new Date(e).toLocaleDateString() : "-" });
381
- const { inputType: i, ...l } = s;
382
- return /* @__PURE__ */ t.jsx(
383
- w,
384
- {
385
- ...l,
386
- type: "date",
387
- value: e || "",
388
- onChange: (o) => r(o.target.value),
389
- disabled: a || l.disabled
390
- }
391
- );
392
- }
393
- const Xt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
394
- __proto__: null,
395
- DateField: Be
396
- }, Symbol.toStringTag, { value: "Module" }));
397
- function Ye({ value: e, onChange: r, field: n, readonly: a, errorMessage: s, ...i }) {
398
- const l = n || i.schema;
399
- if (a)
400
- return e ? /* @__PURE__ */ t.jsx(
401
- "a",
402
- {
403
- href: `mailto:${e}`,
404
- className: "text-sm text-blue-600 hover:text-blue-800 hover:underline",
405
- children: e
406
- }
407
- ) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
408
- const { inputType: o, ...c } = i;
409
- return /* @__PURE__ */ t.jsx(
410
- w,
411
- {
412
- ...c,
413
- type: "email",
414
- value: e || "",
415
- onChange: (m) => r(m.target.value),
416
- placeholder: l?.placeholder || "email@example.com",
417
- disabled: a || c.disabled,
418
- "aria-invalid": !!s
419
- }
420
- );
421
- }
422
- const Zt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
423
- __proto__: null,
424
- EmailField: Ye
425
- }, Symbol.toStringTag, { value: "Module" }));
426
- function qe({ value: e, onChange: r, field: n, readonly: a, errorMessage: s, ...i }) {
427
- const l = n || i.schema;
428
- if (a)
429
- return e ? /* @__PURE__ */ t.jsx(
430
- "a",
431
- {
432
- href: `tel:${e}`,
433
- className: "text-sm text-blue-600 hover:text-blue-800 hover:underline",
434
- children: e
435
- }
436
- ) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
437
- const { inputType: o, ...c } = i;
438
- return /* @__PURE__ */ t.jsx(
439
- w,
440
- {
441
- ...c,
442
- type: "tel",
443
- value: e || "",
444
- onChange: (m) => r(m.target.value),
445
- placeholder: l?.placeholder || "(555) 123-4567",
446
- disabled: a || c.disabled,
447
- "aria-invalid": !!s
448
- }
449
- );
450
- }
451
- const Kt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
452
- __proto__: null,
453
- PhoneField: qe
454
- }, Symbol.toStringTag, { value: "Module" }));
455
- function Je({ value: e, onChange: r, field: n, readonly: a, errorMessage: s, ...i }) {
456
- const l = n || i.schema;
457
- if (a)
458
- return e ? e.startsWith("http://") || e.startsWith("https://") ? /* @__PURE__ */ t.jsx(
459
- "a",
460
- {
461
- href: e,
462
- target: "_blank",
463
- rel: "noopener noreferrer",
464
- className: "text-sm text-blue-600 hover:text-blue-800 hover:underline",
465
- children: e
466
- }
467
- ) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: e }) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
468
- const { inputType: o, ...c } = i;
469
- return /* @__PURE__ */ t.jsx(
470
- w,
471
- {
472
- ...c,
473
- type: "url",
474
- value: e || "",
475
- onChange: (m) => r(m.target.value),
476
- placeholder: l?.placeholder || "https://example.com",
477
- disabled: a || c.disabled,
478
- "aria-invalid": !!s
479
- }
480
- );
481
- }
482
- const er = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
483
- __proto__: null,
484
- UrlField: Je
485
- }, Symbol.toStringTag, { value: "Module" }));
486
- function tr(e, r = "USD") {
487
- try {
488
- return new Intl.NumberFormat("en-US", {
489
- style: "currency",
490
- currency: r
491
- }).format(e);
492
- } catch {
493
- return `${r} ${e.toFixed(2)}`;
494
- }
495
- }
496
- function We({ value: e, onChange: r, field: n, readonly: a, errorMessage: s, className: i, ...l }) {
497
- const o = n || l.schema, c = o?.currency || "USD", m = o?.precision ?? 2;
498
- if (a)
499
- return e == null ? /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" }) : /* @__PURE__ */ t.jsx("span", { className: "text-sm font-medium tabular-nums", children: tr(Number(e), c) });
500
- const p = (f) => {
501
- const u = parseFloat(f.target.value);
502
- isNaN(u) || r(parseFloat(u.toFixed(m)));
503
- };
504
- return /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
505
- /* @__PURE__ */ t.jsx("span", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-500", children: c === "USD" ? "$" : c }),
506
- /* @__PURE__ */ t.jsx(
507
- w,
508
- {
509
- ...l,
510
- type: "number",
511
- value: e ?? "",
512
- onChange: (f) => {
513
- const u = f.target.value === "" ? null : parseFloat(f.target.value);
514
- r(u);
515
- },
516
- onBlur: p,
517
- placeholder: o?.placeholder || "0.00",
518
- disabled: a || l.disabled,
519
- className: `pl-8 ${i || ""}`,
520
- step: Math.pow(10, -m).toFixed(m),
521
- "aria-invalid": !!s
522
- }
523
- )
524
- ] });
525
- }
526
- const rr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
527
- __proto__: null,
528
- CurrencyField: We
529
- }, Symbol.toStringTag, { value: "Module" }));
530
- function Ge({ value: e, onChange: r, field: n, readonly: a, errorMessage: s, ...i }) {
531
- if (a)
532
- return /* @__PURE__ */ t.jsx("div", { className: "text-sm whitespace-pre-wrap", children: e || "-" });
533
- const l = n || i.schema, o = l?.rows || 4, c = l?.max_length, { inputType: m, ...p } = i;
534
- return /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
535
- /* @__PURE__ */ t.jsx(
536
- Z,
537
- {
538
- ...p,
539
- value: e || "",
540
- onChange: (f) => r(f.target.value),
541
- placeholder: l?.placeholder,
542
- disabled: a || p.disabled,
543
- rows: o,
544
- maxLength: c,
545
- "aria-invalid": !!s
546
- }
547
- ),
548
- c && /* @__PURE__ */ t.jsxs(
549
- "div",
550
- {
551
- className: "absolute bottom-2 right-2 text-xs text-gray-400",
552
- "aria-live": "polite",
553
- "aria-label": `Character count: ${(e || "").length} of ${c}`,
554
- children: [
555
- (e || "").length,
556
- "/",
557
- c
558
- ]
559
- }
560
- )
561
- ] });
562
- }
563
- const sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
564
- __proto__: null,
565
- TextAreaField: Ge
566
- }, Symbol.toStringTag, { value: "Module" }));
567
- function ce({ value: e, onChange: r, field: n, readonly: a, errorMessage: s, ...i }) {
568
- if (a)
569
- return /* @__PURE__ */ t.jsx(
570
- "div",
571
- {
572
- className: "text-sm prose prose-sm max-w-none",
573
- children: e || "-"
574
- }
575
- );
576
- const l = n || i.schema, o = l?.rows || 8, c = l?.format || "markdown";
577
- return /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
578
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center justify-between text-xs text-gray-500", children: [
579
- /* @__PURE__ */ t.jsxs("span", { children: [
580
- "Format: ",
581
- c
582
- ] }),
583
- /* @__PURE__ */ t.jsx("span", { className: "italic", children: "Rich text editor (basic)" })
584
- ] }),
585
- /* @__PURE__ */ t.jsx(
586
- Z,
587
- {
588
- value: e || "",
589
- onChange: (m) => r(m.target.value),
590
- placeholder: l?.placeholder || "Enter text...",
591
- disabled: a || i.disabled,
592
- rows: o,
593
- className: `font-mono text-sm ${i.className || ""}`,
594
- "aria-invalid": !!s
595
- }
596
- )
597
- ] });
598
- }
599
- const Oe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
600
- __proto__: null,
601
- RichTextField: ce
602
- }, Symbol.toStringTag, { value: "Module" }));
603
- function Qe({ value: e, onChange: r, field: n, readonly: a, ...s }) {
604
- const [i, l] = B(!1), [o, c] = B(""), m = n || s.schema, p = m?.options || [], f = m.multiple || !1, u = m.display_field || "label", x = p.filter(
605
- (N) => N.label.toLowerCase().includes(o.toLowerCase())
606
- ), h = f ? (Array.isArray(e) ? e : []).map(
607
- (N) => p.find((T) => T.value === N)
608
- ).filter(Boolean) : e ? [p.find((N) => N.value === e)].filter(Boolean) : [], v = (N) => {
609
- if (f) {
610
- const T = Array.isArray(e) ? e : [], U = T.includes(N.value);
611
- r(U ? T.filter((Q) => Q !== N.value) : [...T, N.value]);
612
- } else
613
- r(N.value), l(!1);
614
- }, R = (N) => {
615
- if (f) {
616
- const T = Array.isArray(e) ? e : [];
617
- r(T.filter((U) => U !== N));
618
- } else
619
- r(null);
620
- };
621
- return a ? h.length ? f ? /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-1", children: h.map((N, T) => /* @__PURE__ */ t.jsx(M, { variant: "outline", children: N?.[u] || N?.label }, T)) }) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: h[0]?.[u] || h[0]?.label }) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" }) : /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
622
- h.length > 0 && /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-1", children: h.map((N, T) => /* @__PURE__ */ t.jsxs(
623
- M,
624
- {
625
- variant: "outline",
626
- className: "gap-1",
627
- children: [
628
- N?.[u] || N?.label,
629
- /* @__PURE__ */ t.jsx(
630
- "button",
631
- {
632
- onClick: () => R(N?.value),
633
- className: "ml-1 hover:text-destructive",
634
- type: "button",
635
- "aria-label": `Remove ${N?.[u] || N?.label}`,
636
- children: /* @__PURE__ */ t.jsx(W, { className: "size-3" })
637
- }
638
- )
639
- ]
640
- },
641
- T
642
- )) }),
643
- /* @__PURE__ */ t.jsxs(Tt, { open: i, onOpenChange: l, children: [
644
- /* @__PURE__ */ t.jsx(Ot, { asChild: !0, children: /* @__PURE__ */ t.jsxs(
645
- P,
646
- {
647
- variant: "outline",
648
- className: "w-full justify-start text-left font-normal",
649
- type: "button",
650
- children: [
651
- /* @__PURE__ */ t.jsx($t, { className: "mr-2 size-4" }),
652
- h.length === 0 ? m?.placeholder || "Select..." : f ? `${h.length} selected` : "Change selection"
653
- ]
654
- }
655
- ) }),
656
- /* @__PURE__ */ t.jsxs(Rt, { className: "max-w-md", children: [
657
- /* @__PURE__ */ t.jsx(kt, { children: /* @__PURE__ */ t.jsxs(At, { children: [
658
- m?.label || "Select",
659
- " ",
660
- f && "(multiple)"
661
- ] }) }),
662
- /* @__PURE__ */ t.jsxs("div", { className: "space-y-4", children: [
663
- /* @__PURE__ */ t.jsx(
664
- w,
665
- {
666
- placeholder: "Search...",
667
- value: o,
668
- onChange: (N) => c(N.target.value),
669
- className: "w-full"
670
- }
671
- ),
672
- /* @__PURE__ */ t.jsx("div", { className: "max-h-64 overflow-y-auto space-y-1", children: x.length === 0 ? /* @__PURE__ */ t.jsx("p", { className: "text-sm text-gray-500 text-center py-4", children: "No options found" }) : x.map((N) => {
673
- const T = f ? (Array.isArray(e) ? e : []).includes(N.value) : e === N.value;
674
- return /* @__PURE__ */ t.jsxs(
675
- "button",
676
- {
677
- onClick: () => v(N),
678
- className: `w-full text-left px-3 py-2 rounded-md text-sm hover:bg-gray-100 flex items-center justify-between ${T ? "bg-blue-50 text-blue-700" : ""}`,
679
- type: "button",
680
- children: [
681
- /* @__PURE__ */ t.jsx("span", { children: N.label }),
682
- T && /* @__PURE__ */ t.jsx(M, { variant: "default", className: "ml-2", children: "Selected" })
683
- ]
684
- },
685
- N.value
686
- );
687
- }) })
688
- ] })
689
- ] })
690
- ] })
691
- ] });
692
- }
693
- const nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
694
- __proto__: null,
695
- LookupField: Qe
696
- }, Symbol.toStringTag, { value: "Module" }));
697
- function He({ value: e, onChange: r, field: n, readonly: a, ...s }) {
698
- if (a) {
699
- if (!e) return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
700
- const o = new Date(e);
701
- return /* @__PURE__ */ t.jsxs("span", { className: "text-sm", children: [
702
- o.toLocaleDateString(),
703
- " ",
704
- o.toLocaleTimeString()
705
- ] });
706
- }
707
- const { inputType: i, ...l } = s;
708
- return /* @__PURE__ */ t.jsx(
709
- w,
710
- {
711
- ...l,
712
- type: "datetime-local",
713
- value: e || "",
714
- onChange: (o) => r(o.target.value),
715
- disabled: a || l.disabled
716
- }
717
- );
718
- }
719
- const ar = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
720
- __proto__: null,
721
- DateTimeField: He
722
- }, Symbol.toStringTag, { value: "Module" }));
723
- function Xe({ value: e, onChange: r, field: n, readonly: a, ...s }) {
724
- if (a)
725
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: e || "-" });
726
- const { inputType: i, ...l } = s;
727
- return /* @__PURE__ */ t.jsx(
728
- w,
729
- {
730
- ...l,
731
- type: "time",
732
- value: e || "",
733
- onChange: (o) => r(o.target.value),
734
- disabled: a || l.disabled
735
- }
736
- );
737
- }
738
- const lr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
739
- __proto__: null,
740
- TimeField: Xe
741
- }, Symbol.toStringTag, { value: "Module" }));
742
- function Ze({ value: e, onChange: r, field: n, readonly: a, errorMessage: s, className: i, ...l }) {
743
- const o = n || l.schema, c = o?.precision ?? 2;
744
- if (a)
745
- return e == null ? /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" }) : /* @__PURE__ */ t.jsxs("span", { className: "text-sm font-medium tabular-nums", children: [
746
- (e * 100).toFixed(c),
747
- "%"
748
- ] });
749
- const m = e != null ? e * 100 : "", p = e != null ? e * 100 : 0, f = (h) => {
750
- if (h.target.value === "") {
751
- r(null);
752
- return;
753
- }
754
- const v = parseFloat(h.target.value), R = isNaN(v) ? null : v / 100;
755
- r(R);
756
- }, u = (h) => {
757
- if (a || l.disabled) return;
758
- if (!Array.isArray(h) || h.length === 0) {
759
- r(null);
760
- return;
761
- }
762
- const v = h[0], R = typeof v == "number" ? v / 100 : null;
763
- r(R);
764
- }, x = Math.pow(10, -c);
765
- return /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
766
- /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
767
- /* @__PURE__ */ t.jsx(
768
- w,
769
- {
770
- ...l,
771
- type: "number",
772
- value: m,
773
- onChange: f,
774
- placeholder: o?.placeholder || "0",
775
- disabled: a || l.disabled,
776
- className: `pr-8 ${i || ""}`,
777
- step: Math.pow(10, -c).toFixed(c),
778
- "aria-invalid": !!s
779
- }
780
- ),
781
- /* @__PURE__ */ t.jsx("span", { className: "absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500", children: "%" })
782
- ] }),
783
- /* @__PURE__ */ t.jsx(
784
- De,
785
- {
786
- value: [p],
787
- onValueChange: u,
788
- min: 0,
789
- max: 100,
790
- step: x,
791
- disabled: a || l.disabled,
792
- className: "w-full",
793
- "aria-label": "Percentage",
794
- "data-testid": "percent-slider"
795
- }
796
- )
797
- ] });
798
- }
799
- const ir = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
800
- __proto__: null,
801
- PercentField: Ze
802
- }, Symbol.toStringTag, { value: "Module" }));
803
- function Ke({ value: e, onChange: r, field: n, readonly: a, className: s, ...i }) {
804
- const [l, o] = B(!1), c = n || i.schema;
805
- if (a)
806
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "••••••••" });
807
- const { inputType: m, ...p } = i;
808
- return /* @__PURE__ */ t.jsxs("div", { className: "relative", children: [
809
- /* @__PURE__ */ t.jsx(
810
- w,
811
- {
812
- ...p,
813
- type: l ? "text" : "password",
814
- value: e || "",
815
- onChange: (f) => r(f.target.value),
816
- placeholder: c?.placeholder,
817
- disabled: a || p.disabled,
818
- className: `pr-10 ${s || ""}`
819
- }
820
- ),
821
- /* @__PURE__ */ t.jsx(
822
- P,
823
- {
824
- type: "button",
825
- variant: "ghost",
826
- size: "sm",
827
- className: "absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",
828
- onClick: () => o(!l),
829
- tabIndex: -1,
830
- children: l ? /* @__PURE__ */ t.jsx(zt, { className: "size-4 text-gray-500" }) : /* @__PURE__ */ t.jsx(Et, { className: "size-4 text-gray-500" })
831
- }
832
- )
833
- ] });
834
- }
835
- const or = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
836
- __proto__: null,
837
- PasswordField: Ke
838
- }, Symbol.toStringTag, { value: "Module" }));
839
- function et({ value: e, onChange: r, field: n, readonly: a, ...s }) {
840
- const i = xe(null), l = n || s.schema, o = l?.multiple || !1, c = l?.accept ? l.accept.join(",") : void 0, m = l?.maxSize, [p, f] = B(!1), [u, x] = B([]), h = e ? Array.isArray(e) ? e : [e] : [], v = te((b) => {
841
- if (b.length === 0) return;
842
- const F = [], A = b.filter((O) => {
843
- if (m && O.size > m) {
844
- const Y = (m / 1048576).toFixed(1);
845
- return F.push(`"${O.name}" exceeds max size (${Y} MB)`), !1;
846
- }
847
- return !0;
848
- });
849
- if (x(F), A.length === 0) return;
850
- const $ = A.map((O) => ({
851
- name: O.name,
852
- original_name: O.name,
853
- size: O.size,
854
- mime_type: O.type,
855
- // In a real implementation, this would upload the file and return a URL
856
- url: URL.createObjectURL(O)
857
- }));
858
- r(o ? [...h, ...$] : $[0]);
859
- }, [h, o, r, m]), R = te((b) => {
860
- b.preventDefault(), b.stopPropagation(), f(!0);
861
- }, []), N = te((b) => {
862
- b.preventDefault(), b.stopPropagation(), f(!1);
863
- }, []), T = te((b) => {
864
- b.preventDefault(), b.stopPropagation(), f(!1);
865
- const F = Array.from(b.dataTransfer.files);
866
- if (c) {
867
- const A = c.split(",").map((O) => O.trim().toLowerCase()), $ = F.filter((O) => {
868
- const Y = O.name.split("."), q = Y.length > 1 ? "." + Y.pop()?.toLowerCase() : "";
869
- return A.some(
870
- (V) => V === O.type || q && V === q || V.endsWith("/*") && O.type.startsWith(V.replace("/*", "/"))
871
- );
872
- });
873
- v($);
874
- } else
875
- v(F);
876
- }, [c, v]);
877
- if (a) {
878
- if (!e) return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
879
- const b = Array.isArray(e) ? e : [e];
880
- return /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-2", children: b.map((F, A) => /* @__PURE__ */ t.jsx("span", { className: "text-sm truncate max-w-xs", children: F.name || F.original_name || "File" }, A)) });
881
- }
882
- const U = (b) => {
883
- v(Array.from(b.target.files || []));
884
- }, Q = (b) => {
885
- if (o) {
886
- const F = h.filter((A, $) => $ !== b);
887
- r(F.length > 0 ? F : null);
888
- } else
889
- r(null);
890
- }, K = (b) => (b.mime_type || "").startsWith("image/");
891
- return /* @__PURE__ */ t.jsxs("div", { className: s.className, children: [
892
- /* @__PURE__ */ t.jsx(
893
- "input",
894
- {
895
- ref: i,
896
- type: "file",
897
- multiple: o,
898
- accept: c,
899
- onChange: U,
900
- className: "hidden"
901
- }
902
- ),
903
- /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
904
- /* @__PURE__ */ t.jsxs(
905
- "div",
906
- {
907
- onDragOver: R,
908
- onDragLeave: N,
909
- onDrop: T,
910
- onClick: () => i.current?.click(),
911
- className: `
1
+ import { t as e } from "./jsx-runtime-MxADXuRH.js";
2
+ import { i as t, r as n, t as r } from "./LookupField-BX4sK8NG.js";
3
+ import i, { useCallback as a, useEffect as o, useId as s, useRef as c, useState as l } from "react";
4
+ import { ComponentRegistry as u } from "@object-ui/core";
5
+ import { Avatar as d, AvatarFallback as f, AvatarImage as p, Badge as m, Button as h, Checkbox as g, Input as _, Label as v, Select as y, SelectContent as ee, SelectItem as te, SelectTrigger as b, SelectValue as x, Slider as S, Switch as C, Textarea as w, cn as T } from "@object-ui/components";
6
+ import { Check as E, Copy as D, Crosshair as ne, Eraser as re, ExternalLink as ie, Eye as ae, EyeOff as oe, File as se, Image as ce, ImageIcon as le, MapPin as O, Phone as ue, Plus as de, QrCode as fe, Star as pe, Upload as me, X as k } from "lucide-react";
7
+ //#region src/widgets/TextField.tsx
8
+ var A = e();
9
+ function j({ value: e, onChange: t, field: n, readonly: r, ...i }) {
10
+ let a = n || i.schema;
11
+ if (r) return /* @__PURE__ */ (0, A.jsx)("span", {
12
+ className: "text-sm",
13
+ children: e || "-"
14
+ });
15
+ let o = a?.rows, { inputType: s, ...c } = i;
16
+ return o && o > 1 ? /* @__PURE__ */ (0, A.jsx)(w, {
17
+ ...c,
18
+ value: e || "",
19
+ onChange: (e) => t(e.target.value),
20
+ placeholder: a?.placeholder,
21
+ disabled: r || c.disabled
22
+ }) : /* @__PURE__ */ (0, A.jsx)(_, {
23
+ ...c,
24
+ type: a?.type === "password" ? "password" : "text",
25
+ value: e || "",
26
+ onChange: (e) => t(e.target.value),
27
+ placeholder: a?.placeholder,
28
+ disabled: r || c.disabled
29
+ });
30
+ }
31
+ //#endregion
32
+ //#region src/widgets/NumberField.tsx
33
+ function M({ value: e, onChange: t, field: n, readonly: r, ...i }) {
34
+ if (r) return /* @__PURE__ */ (0, A.jsx)("span", {
35
+ className: "text-sm",
36
+ children: e ?? "-"
37
+ });
38
+ let a = n || i.schema, o = a?.precision, { inputType: s, ...c } = i;
39
+ return /* @__PURE__ */ (0, A.jsx)(_, {
40
+ ...c,
41
+ type: "number",
42
+ value: e ?? "",
43
+ onChange: (e) => {
44
+ let n = e.target.value;
45
+ t(n === "" ? null : Number(n));
46
+ },
47
+ placeholder: a?.placeholder,
48
+ disabled: r || c.disabled,
49
+ step: o ? 10 ** -o : "any"
50
+ });
51
+ }
52
+ //#endregion
53
+ //#region src/widgets/BooleanField.tsx
54
+ function N({ value: e, onChange: t, field: n, readonly: r, ...i }) {
55
+ let a = n || i.schema, o = a?.widget, c = s(), l = a?.name || c, u = a?.label || "Checkbox";
56
+ if (r) return /* @__PURE__ */ (0, A.jsx)("span", {
57
+ className: "text-sm",
58
+ children: e ? "Yes" : "No"
59
+ });
60
+ let { inputType: d, ...f } = i;
61
+ return o === "checkbox" ? /* @__PURE__ */ (0, A.jsxs)("div", {
62
+ className: "flex items-center space-x-2",
63
+ children: [/* @__PURE__ */ (0, A.jsx)(g, {
64
+ ...f,
65
+ id: l,
66
+ checked: !!e,
67
+ onCheckedChange: (e) => t(!!e),
68
+ disabled: r || f.disabled
69
+ }), /* @__PURE__ */ (0, A.jsx)(v, {
70
+ htmlFor: l,
71
+ children: u
72
+ })]
73
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
74
+ className: "flex items-center space-x-2",
75
+ children: [/* @__PURE__ */ (0, A.jsx)(C, {
76
+ ...f,
77
+ id: l,
78
+ checked: !!e,
79
+ onCheckedChange: t,
80
+ disabled: r || f.disabled
81
+ }), /* @__PURE__ */ (0, A.jsx)(v, {
82
+ htmlFor: l,
83
+ children: u
84
+ })]
85
+ });
86
+ }
87
+ //#endregion
88
+ //#region src/widgets/SelectField.tsx
89
+ function P({ value: e, onChange: t, field: n, readonly: r, ...i }) {
90
+ let a = n || i.schema, o = a?.options || [];
91
+ return r ? /* @__PURE__ */ (0, A.jsx)("span", {
92
+ className: "text-sm",
93
+ children: o.find((t) => t.value === e)?.label || e || "-"
94
+ }) : /* @__PURE__ */ (0, A.jsxs)(y, {
95
+ ...i,
96
+ value: e,
97
+ onValueChange: t,
98
+ disabled: r || i.disabled,
99
+ children: [/* @__PURE__ */ (0, A.jsx)(b, {
100
+ className: i.className,
101
+ id: i.id,
102
+ children: /* @__PURE__ */ (0, A.jsx)(x, { placeholder: a?.placeholder || "Select an option" })
103
+ }), /* @__PURE__ */ (0, A.jsx)(ee, {
104
+ position: "popper",
105
+ children: o.map((e) => /* @__PURE__ */ (0, A.jsx)(te, {
106
+ value: e.value,
107
+ children: e.label
108
+ }, e.value))
109
+ })]
110
+ });
111
+ }
112
+ //#endregion
113
+ //#region src/widgets/DateField.tsx
114
+ function F({ value: e, onChange: t, field: n, readonly: r, ...i }) {
115
+ if (r) return /* @__PURE__ */ (0, A.jsx)("span", {
116
+ className: "text-sm",
117
+ children: e ? new Date(e).toLocaleDateString() : "-"
118
+ });
119
+ let { inputType: a, ...o } = i;
120
+ return /* @__PURE__ */ (0, A.jsx)(_, {
121
+ ...o,
122
+ type: "date",
123
+ value: e || "",
124
+ onChange: (e) => t(e.target.value),
125
+ disabled: r || o.disabled
126
+ });
127
+ }
128
+ //#endregion
129
+ //#region src/widgets/EmailField.tsx
130
+ function I({ value: e, onChange: t, field: n, readonly: r, errorMessage: i, ...a }) {
131
+ let o = n || a.schema;
132
+ if (r) return e ? /* @__PURE__ */ (0, A.jsx)("a", {
133
+ href: `mailto:${e}`,
134
+ className: "text-sm text-blue-600 hover:text-blue-800 hover:underline",
135
+ children: e
136
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
137
+ className: "text-sm",
138
+ children: "-"
139
+ });
140
+ let { inputType: s, ...c } = a;
141
+ return /* @__PURE__ */ (0, A.jsx)(_, {
142
+ ...c,
143
+ type: "email",
144
+ value: e || "",
145
+ onChange: (e) => t(e.target.value),
146
+ placeholder: o?.placeholder || "email@example.com",
147
+ disabled: r || c.disabled,
148
+ "aria-invalid": !!i
149
+ });
150
+ }
151
+ //#endregion
152
+ //#region src/widgets/PhoneField.tsx
153
+ function L({ value: e, onChange: t, field: n, readonly: r, errorMessage: i, ...a }) {
154
+ let o = n || a.schema;
155
+ if (r) return e ? /* @__PURE__ */ (0, A.jsx)("a", {
156
+ href: `tel:${e}`,
157
+ className: "text-sm text-blue-600 hover:text-blue-800 hover:underline",
158
+ children: e
159
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
160
+ className: "text-sm",
161
+ children: "-"
162
+ });
163
+ let { inputType: s, ...c } = a;
164
+ return /* @__PURE__ */ (0, A.jsx)(_, {
165
+ ...c,
166
+ type: "tel",
167
+ value: e || "",
168
+ onChange: (e) => t(e.target.value),
169
+ placeholder: o?.placeholder || "(555) 123-4567",
170
+ disabled: r || c.disabled,
171
+ "aria-invalid": !!i
172
+ });
173
+ }
174
+ //#endregion
175
+ //#region src/widgets/UrlField.tsx
176
+ function R({ value: e, onChange: t, field: n, readonly: r, errorMessage: i, ...a }) {
177
+ let o = n || a.schema;
178
+ if (r) return e ? e.startsWith("http://") || e.startsWith("https://") ? /* @__PURE__ */ (0, A.jsx)("a", {
179
+ href: e,
180
+ target: "_blank",
181
+ rel: "noopener noreferrer",
182
+ className: "text-sm text-blue-600 hover:text-blue-800 hover:underline",
183
+ children: e
184
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
185
+ className: "text-sm",
186
+ children: e
187
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
188
+ className: "text-sm",
189
+ children: "-"
190
+ });
191
+ let { inputType: s, ...c } = a;
192
+ return /* @__PURE__ */ (0, A.jsx)(_, {
193
+ ...c,
194
+ type: "url",
195
+ value: e || "",
196
+ onChange: (e) => t(e.target.value),
197
+ placeholder: o?.placeholder || "https://example.com",
198
+ disabled: r || c.disabled,
199
+ "aria-invalid": !!i
200
+ });
201
+ }
202
+ //#endregion
203
+ //#region src/widgets/CurrencyField.tsx
204
+ function he(e, t = "USD") {
205
+ try {
206
+ return new Intl.NumberFormat("en-US", {
207
+ style: "currency",
208
+ currency: t
209
+ }).format(e);
210
+ } catch {
211
+ return `${t} ${e.toFixed(2)}`;
212
+ }
213
+ }
214
+ function z({ value: e, onChange: t, field: n, readonly: r, errorMessage: i, className: a, ...o }) {
215
+ let s = n || o.schema, c = s?.currency || "USD", l = s?.precision ?? 2;
216
+ if (r) return e == null ? /* @__PURE__ */ (0, A.jsx)("span", {
217
+ className: "text-sm",
218
+ children: "-"
219
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
220
+ className: "text-sm font-medium tabular-nums",
221
+ children: he(Number(e), c)
222
+ });
223
+ let u = (e) => {
224
+ let n = parseFloat(e.target.value);
225
+ isNaN(n) || t(parseFloat(n.toFixed(l)));
226
+ };
227
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
228
+ className: "relative",
229
+ children: [/* @__PURE__ */ (0, A.jsx)("span", {
230
+ className: "absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-500",
231
+ children: c === "USD" ? "$" : c
232
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
233
+ ...o,
234
+ type: "number",
235
+ value: e ?? "",
236
+ onChange: (e) => {
237
+ t(e.target.value === "" ? null : parseFloat(e.target.value));
238
+ },
239
+ onBlur: u,
240
+ placeholder: s?.placeholder || "0.00",
241
+ disabled: r || o.disabled,
242
+ className: `pl-8 ${a || ""}`,
243
+ step: (10 ** -l).toFixed(l),
244
+ "aria-invalid": !!i
245
+ })]
246
+ });
247
+ }
248
+ //#endregion
249
+ //#region src/widgets/TextAreaField.tsx
250
+ function ge({ value: e, onChange: t, field: n, readonly: r, errorMessage: i, ...a }) {
251
+ if (r) return /* @__PURE__ */ (0, A.jsx)("div", {
252
+ className: "text-sm whitespace-pre-wrap",
253
+ children: e || "-"
254
+ });
255
+ let o = n || a.schema, s = o?.rows || 4, c = o?.max_length, { inputType: l, ...u } = a;
256
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
257
+ className: "relative",
258
+ children: [/* @__PURE__ */ (0, A.jsx)(w, {
259
+ ...u,
260
+ value: e || "",
261
+ onChange: (e) => t(e.target.value),
262
+ placeholder: o?.placeholder,
263
+ disabled: r || u.disabled,
264
+ rows: s,
265
+ maxLength: c,
266
+ "aria-invalid": !!i
267
+ }), c && /* @__PURE__ */ (0, A.jsxs)("div", {
268
+ className: "absolute bottom-2 right-2 text-xs text-gray-400",
269
+ "aria-live": "polite",
270
+ "aria-label": `Character count: ${(e || "").length} of ${c}`,
271
+ children: [
272
+ (e || "").length,
273
+ "/",
274
+ c
275
+ ]
276
+ })]
277
+ });
278
+ }
279
+ //#endregion
280
+ //#region src/widgets/RichTextField.tsx
281
+ function B({ value: e, onChange: t, field: n, readonly: r, errorMessage: i, ...a }) {
282
+ if (r) return /* @__PURE__ */ (0, A.jsx)("div", {
283
+ className: "text-sm prose prose-sm max-w-none",
284
+ children: e || "-"
285
+ });
286
+ let o = n || a.schema, s = o?.rows || 8;
287
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
288
+ className: "space-y-2",
289
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", {
290
+ className: "flex items-center justify-between text-xs text-gray-500",
291
+ children: [/* @__PURE__ */ (0, A.jsxs)("span", { children: ["Format: ", o?.format || "markdown"] }), /* @__PURE__ */ (0, A.jsx)("span", {
292
+ className: "italic",
293
+ children: "Rich text editor (basic)"
294
+ })]
295
+ }), /* @__PURE__ */ (0, A.jsx)(w, {
296
+ value: e || "",
297
+ onChange: (e) => t(e.target.value),
298
+ placeholder: o?.placeholder || "Enter text...",
299
+ disabled: r || a.disabled,
300
+ rows: s,
301
+ className: `font-mono text-sm ${a.className || ""}`,
302
+ "aria-invalid": !!i
303
+ })]
304
+ });
305
+ }
306
+ //#endregion
307
+ //#region src/widgets/DateTimeField.tsx
308
+ function _e({ value: e, onChange: t, field: n, readonly: r, ...i }) {
309
+ if (r) {
310
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", {
311
+ className: "text-sm",
312
+ children: "-"
313
+ });
314
+ let t = new Date(e);
315
+ return /* @__PURE__ */ (0, A.jsxs)("span", {
316
+ className: "text-sm",
317
+ children: [
318
+ t.toLocaleDateString(),
319
+ " ",
320
+ t.toLocaleTimeString()
321
+ ]
322
+ });
323
+ }
324
+ let { inputType: a, ...o } = i;
325
+ return /* @__PURE__ */ (0, A.jsx)(_, {
326
+ ...o,
327
+ type: "datetime-local",
328
+ value: e || "",
329
+ onChange: (e) => t(e.target.value),
330
+ disabled: r || o.disabled
331
+ });
332
+ }
333
+ //#endregion
334
+ //#region src/widgets/TimeField.tsx
335
+ function ve({ value: e, onChange: t, field: n, readonly: r, ...i }) {
336
+ if (r) return /* @__PURE__ */ (0, A.jsx)("span", {
337
+ className: "text-sm",
338
+ children: e || "-"
339
+ });
340
+ let { inputType: a, ...o } = i;
341
+ return /* @__PURE__ */ (0, A.jsx)(_, {
342
+ ...o,
343
+ type: "time",
344
+ value: e || "",
345
+ onChange: (e) => t(e.target.value),
346
+ disabled: r || o.disabled
347
+ });
348
+ }
349
+ //#endregion
350
+ //#region src/widgets/PercentField.tsx
351
+ function ye({ value: e, onChange: t, field: n, readonly: r, errorMessage: i, className: a, ...o }) {
352
+ let s = n || o.schema, c = s?.precision ?? 2;
353
+ if (r) return e == null ? /* @__PURE__ */ (0, A.jsx)("span", {
354
+ className: "text-sm",
355
+ children: "-"
356
+ }) : /* @__PURE__ */ (0, A.jsxs)("span", {
357
+ className: "text-sm font-medium tabular-nums",
358
+ children: [(e * 100).toFixed(c), "%"]
359
+ });
360
+ let l = e == null ? "" : e * 100, u = e == null ? 0 : e * 100, d = (e) => {
361
+ if (e.target.value === "") {
362
+ t(null);
363
+ return;
364
+ }
365
+ let n = parseFloat(e.target.value);
366
+ t(isNaN(n) ? null : n / 100);
367
+ }, f = (e) => {
368
+ if (r || o.disabled) return;
369
+ if (!Array.isArray(e) || e.length === 0) {
370
+ t(null);
371
+ return;
372
+ }
373
+ let n = e[0];
374
+ t(typeof n == "number" ? n / 100 : null);
375
+ }, p = 10 ** -c;
376
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
377
+ className: "space-y-2",
378
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", {
379
+ className: "relative",
380
+ children: [/* @__PURE__ */ (0, A.jsx)(_, {
381
+ ...o,
382
+ type: "number",
383
+ value: l,
384
+ onChange: d,
385
+ placeholder: s?.placeholder || "0",
386
+ disabled: r || o.disabled,
387
+ className: `pr-8 ${a || ""}`,
388
+ step: (10 ** -c).toFixed(c),
389
+ "aria-invalid": !!i
390
+ }), /* @__PURE__ */ (0, A.jsx)("span", {
391
+ className: "absolute right-3 top-1/2 -translate-y-1/2 text-sm text-gray-500",
392
+ children: "%"
393
+ })]
394
+ }), /* @__PURE__ */ (0, A.jsx)(S, {
395
+ value: [u],
396
+ onValueChange: f,
397
+ min: 0,
398
+ max: 100,
399
+ step: p,
400
+ disabled: r || o.disabled,
401
+ className: "w-full",
402
+ "aria-label": "Percentage",
403
+ "data-testid": "percent-slider"
404
+ })]
405
+ });
406
+ }
407
+ //#endregion
408
+ //#region src/widgets/PasswordField.tsx
409
+ function be({ value: e, onChange: t, field: n, readonly: r, className: i, ...a }) {
410
+ let [o, s] = l(!1), c = n || a.schema;
411
+ if (r) return /* @__PURE__ */ (0, A.jsx)("span", {
412
+ className: "text-sm",
413
+ children: "••••••••"
414
+ });
415
+ let { inputType: u, ...d } = a;
416
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
417
+ className: "relative",
418
+ children: [/* @__PURE__ */ (0, A.jsx)(_, {
419
+ ...d,
420
+ type: o ? "text" : "password",
421
+ value: e || "",
422
+ onChange: (e) => t(e.target.value),
423
+ placeholder: c?.placeholder,
424
+ disabled: r || d.disabled,
425
+ className: `pr-10 ${i || ""}`
426
+ }), /* @__PURE__ */ (0, A.jsx)(h, {
427
+ type: "button",
428
+ variant: "ghost",
429
+ size: "sm",
430
+ className: "absolute right-0 top-0 h-full px-3 py-2 hover:bg-transparent",
431
+ onClick: () => s(!o),
432
+ tabIndex: -1,
433
+ children: o ? /* @__PURE__ */ (0, A.jsx)(oe, { className: "size-4 text-gray-500" }) : /* @__PURE__ */ (0, A.jsx)(ae, { className: "size-4 text-gray-500" })
434
+ })]
435
+ });
436
+ }
437
+ //#endregion
438
+ //#region src/widgets/FileField.tsx
439
+ function xe({ value: e, onChange: t, field: n, readonly: r, ...i }) {
440
+ let o = c(null), s = n || i.schema, u = s?.multiple || !1, d = s?.accept ? s.accept.join(",") : void 0, f = s?.maxSize, [p, m] = l(!1), [g, _] = l([]), v = e ? Array.isArray(e) ? e : [e] : [], y = a((e) => {
441
+ if (e.length === 0) return;
442
+ let n = [], r = e.filter((e) => {
443
+ if (f && e.size > f) {
444
+ let t = (f / (1024 * 1024)).toFixed(1);
445
+ return n.push(`"${e.name}" exceeds max size (${t} MB)`), !1;
446
+ }
447
+ return !0;
448
+ });
449
+ if (_(n), r.length === 0) return;
450
+ let i = r.map((e) => ({
451
+ name: e.name,
452
+ original_name: e.name,
453
+ size: e.size,
454
+ mime_type: e.type,
455
+ url: URL.createObjectURL(e)
456
+ }));
457
+ t(u ? [...v, ...i] : i[0]);
458
+ }, [
459
+ v,
460
+ u,
461
+ t,
462
+ f
463
+ ]), ee = a((e) => {
464
+ e.preventDefault(), e.stopPropagation(), m(!0);
465
+ }, []), te = a((e) => {
466
+ e.preventDefault(), e.stopPropagation(), m(!1);
467
+ }, []), b = a((e) => {
468
+ e.preventDefault(), e.stopPropagation(), m(!1);
469
+ let t = Array.from(e.dataTransfer.files);
470
+ if (d) {
471
+ let e = d.split(",").map((e) => e.trim().toLowerCase());
472
+ y(t.filter((t) => {
473
+ let n = t.name.split("."), r = n.length > 1 ? "." + n.pop()?.toLowerCase() : "";
474
+ return e.some((e) => e === t.type || r && e === r || e.endsWith("/*") && t.type.startsWith(e.replace("/*", "/")));
475
+ }));
476
+ } else y(t);
477
+ }, [d, y]);
478
+ if (r) return e ? /* @__PURE__ */ (0, A.jsx)("div", {
479
+ className: "flex flex-wrap gap-2",
480
+ children: (Array.isArray(e) ? e : [e]).map((e, t) => /* @__PURE__ */ (0, A.jsx)("span", {
481
+ className: "text-sm truncate max-w-xs",
482
+ children: e.name || e.original_name || "File"
483
+ }, t))
484
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
485
+ className: "text-sm",
486
+ children: "-"
487
+ });
488
+ let x = (e) => {
489
+ y(Array.from(e.target.files || []));
490
+ }, S = (e) => {
491
+ if (u) {
492
+ let n = v.filter((t, n) => n !== e);
493
+ t(n.length > 0 ? n : null);
494
+ } else t(null);
495
+ }, C = (e) => (e.mime_type || "").startsWith("image/");
496
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
497
+ className: i.className,
498
+ children: [/* @__PURE__ */ (0, A.jsx)("input", {
499
+ ref: o,
500
+ type: "file",
501
+ multiple: u,
502
+ accept: d,
503
+ onChange: x,
504
+ className: "hidden"
505
+ }), /* @__PURE__ */ (0, A.jsxs)("div", {
506
+ className: "space-y-2",
507
+ children: [
508
+ /* @__PURE__ */ (0, A.jsxs)("div", {
509
+ onDragOver: ee,
510
+ onDragLeave: te,
511
+ onDrop: b,
512
+ onClick: () => o.current?.click(),
513
+ className: `
912
514
  flex flex-col items-center justify-center gap-2 p-6
913
515
  border-2 border-dashed rounded-lg cursor-pointer
914
516
  transition-colors duration-200
915
517
  ${p ? "border-primary bg-primary/5 text-primary" : "border-muted-foreground/25 hover:border-primary/50 text-muted-foreground hover:text-foreground"}
916
518
  `,
917
- role: "button",
918
- tabIndex: 0,
919
- onKeyDown: (b) => {
920
- (b.key === "Enter" || b.key === " ") && (b.preventDefault(), i.current?.click());
921
- },
922
- children: [
923
- /* @__PURE__ */ t.jsx(Me, { className: `size-8 ${p ? "text-primary" : "text-muted-foreground"}` }),
924
- /* @__PURE__ */ t.jsxs("div", { className: "text-center", children: [
925
- /* @__PURE__ */ t.jsx("p", { className: "text-sm font-medium", children: p ? "Drop files here" : "Drag & drop files here" }),
926
- /* @__PURE__ */ t.jsx("p", { className: "text-xs text-muted-foreground mt-1", children: "or click to browse" })
927
- ] })
928
- ]
929
- }
930
- ),
931
- u.length > 0 && /* @__PURE__ */ t.jsx("div", { className: "space-y-0.5", children: u.map((b, F) => /* @__PURE__ */ t.jsx("p", { className: "text-xs text-destructive", children: b }, F)) }),
932
- h.length > 0 && /* @__PURE__ */ t.jsx("div", { className: "space-y-1", children: h.map((b, F) => /* @__PURE__ */ t.jsxs(
933
- "div",
934
- {
935
- className: "flex items-center justify-between gap-2 p-2 bg-muted/50 rounded-md border",
936
- children: [
937
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
938
- K(b) && b.url ? /* @__PURE__ */ t.jsx("img", { src: b.url, alt: b.name, className: "size-8 object-cover rounded flex-shrink-0" }) : K(b) ? /* @__PURE__ */ t.jsx(Dt, { className: "size-4 text-muted-foreground flex-shrink-0" }) : /* @__PURE__ */ t.jsx(Mt, { className: "size-4 text-muted-foreground flex-shrink-0" }),
939
- /* @__PURE__ */ t.jsx("span", { className: "text-sm truncate", children: b.name || b.original_name || "File" }),
940
- b.size && /* @__PURE__ */ t.jsxs("span", { className: "text-xs text-muted-foreground", children: [
941
- "(",
942
- (b.size / 1024).toFixed(1),
943
- " KB)"
944
- ] })
945
- ] }),
946
- /* @__PURE__ */ t.jsx(
947
- P,
948
- {
949
- type: "button",
950
- variant: "ghost",
951
- size: "sm",
952
- onClick: (A) => {
953
- A.stopPropagation(), Q(F);
954
- },
955
- className: "h-6 w-6 p-0",
956
- children: /* @__PURE__ */ t.jsx(W, { className: "size-3" })
957
- }
958
- )
959
- ]
960
- },
961
- F
962
- )) })
963
- ] })
964
- ] });
965
- }
966
- const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
967
- __proto__: null,
968
- FileField: et
969
- }, Symbol.toStringTag, { value: "Module" }));
970
- function tt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
971
- const i = xe(null), l = n || s.schema, o = l?.multiple || !1, c = l?.accept ? l.accept.join(",") : "image/*";
972
- if (a) {
973
- if (!e) return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
974
- const u = Array.isArray(e) ? e : [e];
975
- return /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-2", children: u.map((x, h) => /* @__PURE__ */ t.jsx(
976
- "img",
977
- {
978
- src: x.url || "",
979
- alt: x.name || `Image ${h + 1}`,
980
- className: "size-20 rounded-md object-cover border border-gray-200"
981
- },
982
- h
983
- )) });
984
- }
985
- const m = e ? Array.isArray(e) ? e : [e] : [], p = (u) => {
986
- const x = Array.from(u.target.files || []);
987
- if (x.length === 0) return;
988
- const h = x.map((v) => ({
989
- name: v.name,
990
- original_name: v.name,
991
- size: v.size,
992
- mime_type: v.type,
993
- // In a real implementation, this would upload the image and return a URL
994
- url: URL.createObjectURL(v)
995
- }));
996
- r(o ? [...m, ...h] : h[0]);
997
- }, f = (u) => {
998
- if (o) {
999
- const x = m.filter((h, v) => v !== u);
1000
- r(x.length > 0 ? x : null);
1001
- } else
1002
- r(null);
1003
- };
1004
- return /* @__PURE__ */ t.jsxs("div", { className: s.className, children: [
1005
- /* @__PURE__ */ t.jsx(
1006
- "input",
1007
- {
1008
- ref: i,
1009
- type: "file",
1010
- multiple: o,
1011
- accept: c,
1012
- onChange: p,
1013
- className: "hidden"
1014
- }
1015
- ),
1016
- /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
1017
- m.length > 0 && /* @__PURE__ */ t.jsx("div", { className: "grid grid-cols-4 gap-2", children: m.map((u, x) => /* @__PURE__ */ t.jsxs("div", { className: "relative group", children: [
1018
- /* @__PURE__ */ t.jsx(
1019
- "img",
1020
- {
1021
- src: u.url || "",
1022
- alt: u.name || `Image ${x + 1}`,
1023
- className: "size-20 rounded-md object-cover border border-gray-200"
1024
- }
1025
- ),
1026
- /* @__PURE__ */ t.jsx(
1027
- P,
1028
- {
1029
- type: "button",
1030
- variant: "destructive",
1031
- size: "sm",
1032
- onClick: () => f(x),
1033
- className: "absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
1034
- children: /* @__PURE__ */ t.jsx(W, { className: "size-3" })
1035
- }
1036
- )
1037
- ] }, x)) }),
1038
- /* @__PURE__ */ t.jsxs(
1039
- P,
1040
- {
1041
- type: "button",
1042
- variant: "outline",
1043
- onClick: () => i.current?.click(),
1044
- className: "w-full",
1045
- children: [
1046
- /* @__PURE__ */ t.jsx(Lt, { className: "size-4 mr-2" }),
1047
- m.length > 0 ? "Add More Images" : "Upload Image"
1048
- ]
1049
- }
1050
- )
1051
- ] })
1052
- ] });
1053
- }
1054
- const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1055
- __proto__: null,
1056
- ImageField: tt
1057
- }, Symbol.toStringTag, { value: "Module" }));
1058
- function rt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1059
- const i = n || s.schema, l = e && typeof e == "object" ? `${e.latitude || 0}, ${e.longitude || 0}` : "";
1060
- if (a)
1061
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: l || "-" });
1062
- const o = (c) => {
1063
- const m = c.target.value;
1064
- if (!m.trim()) {
1065
- r(null);
1066
- return;
1067
- }
1068
- const p = m.split(",").map((f) => f.trim());
1069
- if (p.length === 2) {
1070
- const f = parseFloat(p[0]), u = parseFloat(p[1]);
1071
- !isNaN(f) && !isNaN(u) && r({ latitude: f, longitude: u });
1072
- }
1073
- };
1074
- return /* @__PURE__ */ t.jsx(
1075
- w,
1076
- {
1077
- type: "text",
1078
- value: l,
1079
- onChange: o,
1080
- placeholder: i?.placeholder || "latitude, longitude",
1081
- disabled: a || s.disabled,
1082
- className: s.className
1083
- }
1084
- );
1085
- }
1086
- const ur = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1087
- __proto__: null,
1088
- LocationField: rt
1089
- }, Symbol.toStringTag, { value: "Module" }));
1090
- function st({ value: e, field: r, ...n }) {
1091
- const s = (r || n.schema)?.return_type || "text";
1092
- let i = "-";
1093
- return e != null && (s === "number" || s === "currency" ? i = typeof e == "number" ? e.toFixed(2) : String(e) : s === "boolean" ? i = e ? "Yes" : "No" : s === "date" ? i = new Date(e).toLocaleDateString() : i = String(e)), /* @__PURE__ */ t.jsx("span", { className: `text-sm font-mono text-gray-700 ${n.className || ""}`, children: i });
1094
- }
1095
- const mr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1096
- __proto__: null,
1097
- FormulaField: st
1098
- }, Symbol.toStringTag, { value: "Module" }));
1099
- function nt({ value: e, field: r, ...n }) {
1100
- const s = (r || n.schema)?.summary_type || "count";
1101
- let i = "-";
1102
- return e != null && (s === "count" ? i = String(e) : ["sum", "avg", "min", "max"].includes(s) ? i = typeof e == "number" ? e.toFixed(2) : String(e) : i = String(e)), /* @__PURE__ */ t.jsx("span", { className: `text-sm font-medium tabular-nums text-gray-700 ${n.className || ""}`, children: i });
1103
- }
1104
- const fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1105
- __proto__: null,
1106
- SummaryField: nt
1107
- }, Symbol.toStringTag, { value: "Module" }));
1108
- function at({ value: e, field: r, ...n }) {
1109
- const a = e != null ? String(e) : "-";
1110
- return /* @__PURE__ */ t.jsx("span", { className: `text-sm font-mono text-gray-700 ${n.className || ""}`, children: a });
1111
- }
1112
- const xr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1113
- __proto__: null,
1114
- AutoNumberField: at
1115
- }, Symbol.toStringTag, { value: "Module" }));
1116
- function de({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1117
- const l = (n || s.schema)?.multiple || !1;
1118
- if (a) {
1119
- if (!e) return /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
1120
- const m = Array.isArray(e) ? e : [e];
1121
- return /* @__PURE__ */ t.jsxs("div", { className: "flex -space-x-2", children: [
1122
- m.slice(0, 3).map((p, f) => {
1123
- const u = p.name || p.username || "User", x = u.split(" ").map((h) => h[0]).join("").toUpperCase().slice(0, 2);
1124
- return /* @__PURE__ */ t.jsx(L, { className: "size-8 border-2 border-white", title: u, children: /* @__PURE__ */ t.jsx(I, { className: "bg-blue-500 text-white text-xs", children: x }) }, f);
1125
- }),
1126
- m.length > 3 && /* @__PURE__ */ t.jsx(L, { className: "size-8 border-2 border-white", children: /* @__PURE__ */ t.jsxs(I, { className: "bg-gray-200 text-gray-600 text-xs", children: [
1127
- "+",
1128
- m.length - 3
1129
- ] }) })
1130
- ] });
1131
- }
1132
- const o = e ? Array.isArray(e) ? e : [e] : [], c = (m) => {
1133
- if (l) {
1134
- const p = o.filter((f, u) => u !== m);
1135
- r(p.length > 0 ? p : null);
1136
- } else
1137
- r(null);
1138
- };
1139
- return /* @__PURE__ */ t.jsxs("div", { className: s.className, children: [
1140
- o.length > 0 && /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-2 mb-2", children: o.map((m, p) => {
1141
- const f = m.name || m.username || "User", u = f.split(" ").map((x) => x[0]).join("").toUpperCase().slice(0, 2);
1142
- return /* @__PURE__ */ t.jsxs(M, { variant: "outline", className: "gap-2 pr-1", children: [
1143
- /* @__PURE__ */ t.jsx(L, { className: "size-5", children: /* @__PURE__ */ t.jsx(I, { className: "bg-blue-500 text-white text-xs", children: u }) }),
1144
- /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: f }),
1145
- /* @__PURE__ */ t.jsx(
1146
- "button",
1147
- {
1148
- type: "button",
1149
- onClick: () => c(p),
1150
- className: "ml-1 rounded-full hover:bg-gray-200 p-0.5",
1151
- children: /* @__PURE__ */ t.jsx(W, { className: "size-3" })
1152
- }
1153
- )
1154
- ] }, p);
1155
- }) }),
1156
- /* @__PURE__ */ t.jsx("div", { className: "text-sm text-gray-500 italic", children: "User selection component requires integration with user management system" })
1157
- ] });
1158
- }
1159
- const Re = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1160
- __proto__: null,
1161
- UserField: de
1162
- }, Symbol.toStringTag, { value: "Module" }));
1163
- function lt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1164
- const i = n || s.schema, l = () => e == null ? "" : JSON.stringify(e, null, 2), [o, c] = B(l), [m, p] = B(null);
1165
- if (ze(() => {
1166
- try {
1167
- if (e == null) {
1168
- c("");
1169
- return;
1170
- }
1171
- const u = o ? JSON.parse(o) : null;
1172
- JSON.stringify(u) !== JSON.stringify(e) && c(JSON.stringify(e, null, 2));
1173
- } catch {
1174
- c(JSON.stringify(e, null, 2));
1175
- }
1176
- }, [e, o]), a)
1177
- return e ? /* @__PURE__ */ t.jsx("pre", { className: z("text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-auto max-h-40", s.className), children: JSON.stringify(e, null, 2) }) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
1178
- const f = (u) => {
1179
- const x = u.target.value;
1180
- if (c(x), p(null), !x.trim()) {
1181
- r(null);
1182
- return;
1183
- }
1184
- try {
1185
- const h = JSON.parse(x);
1186
- r(h);
1187
- } catch {
1188
- p("Invalid JSON");
1189
- }
1190
- };
1191
- return /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
1192
- /* @__PURE__ */ t.jsx(
1193
- Z,
1194
- {
1195
- value: o,
1196
- onChange: f,
1197
- placeholder: i?.placeholder || `{
1198
- "key": "value"
1199
- }`,
1200
- disabled: a || s.disabled,
1201
- className: z("font-mono text-xs", m ? "border-red-500 focus-visible:ring-red-500" : "", s.className),
1202
- rows: 6
1203
- }
1204
- ),
1205
- m && /* @__PURE__ */ t.jsx("p", { className: "text-xs text-red-500", children: m })
1206
- ] });
1207
- }
1208
- const pr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1209
- __proto__: null,
1210
- ObjectField: lt
1211
- }, Symbol.toStringTag, { value: "Module" }));
1212
- function it({ value: e, field: r, ...n }) {
1213
- const s = (r || n.schema)?.dimensions || (Array.isArray(e) ? e.length : 0);
1214
- if (!e || !Array.isArray(e))
1215
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm text-gray-500", children: "-" });
1216
- const i = e.slice(0, 3).map((l) => {
1217
- const o = Number(l);
1218
- return isNaN(o) ? "0" : o.toFixed(4);
1219
- }).join(", ");
1220
- return /* @__PURE__ */ t.jsxs("div", { className: `text-sm ${n.className || ""}`, children: [
1221
- /* @__PURE__ */ t.jsxs("span", { className: "font-mono text-gray-700", children: [
1222
- "[",
1223
- i,
1224
- "...]"
1225
- ] }),
1226
- /* @__PURE__ */ t.jsxs("span", { className: "text-gray-500 ml-2", children: [
1227
- "(",
1228
- s,
1229
- "D)"
1230
- ] })
1231
- ] });
1232
- }
1233
- const hr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1234
- __proto__: null,
1235
- VectorField: it
1236
- }, Symbol.toStringTag, { value: "Module" }));
1237
- function ot({ value: e, field: r, readonly: n, ...a }) {
1238
- const i = (r || a.schema)?.columns || [];
1239
- return !e || !Array.isArray(e) ? /* @__PURE__ */ t.jsx("span", { className: "text-sm text-muted-foreground", children: "-" }) : n ? /* @__PURE__ */ t.jsx("div", { className: z("text-sm", a.className), children: /* @__PURE__ */ t.jsxs("span", { className: "text-foreground", children: [
1240
- e.length,
1241
- " rows"
1242
- ] }) }) : /* @__PURE__ */ t.jsxs("div", { className: z("border border-border rounded-lg overflow-hidden", a.className), children: [
1243
- /* @__PURE__ */ t.jsx("div", { className: "overflow-auto max-h-60", children: /* @__PURE__ */ t.jsxs("table", { className: "w-full text-sm", children: [
1244
- /* @__PURE__ */ t.jsx("thead", { className: "bg-muted border-b border-border", children: /* @__PURE__ */ t.jsx("tr", { children: i.map((l, o) => /* @__PURE__ */ t.jsx(
1245
- "th",
1246
- {
1247
- className: "px-3 py-2 text-left text-xs font-medium text-muted-foreground",
1248
- children: l.label || l.name
1249
- },
1250
- o
1251
- )) }) }),
1252
- /* @__PURE__ */ t.jsx("tbody", { className: "divide-y divide-border", children: e.slice(0, 5).map((l, o) => /* @__PURE__ */ t.jsx("tr", { className: "hover:bg-muted/50 transition-colors", children: i.map((c, m) => /* @__PURE__ */ t.jsx("td", { className: "px-3 py-2 text-foreground", children: l[c.name] != null ? String(l[c.name]) : "-" }, m)) }, o)) })
1253
- ] }) }),
1254
- e.length > 5 && /* @__PURE__ */ t.jsxs("div", { className: "bg-muted px-3 py-2 text-xs text-muted-foreground border-t border-border", children: [
1255
- "Showing 5 of ",
1256
- e.length,
1257
- " rows"
1258
- ] })
1259
- ] });
1260
- }
1261
- const gr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1262
- __proto__: null,
1263
- GridField: ot
1264
- }, Symbol.toStringTag, { value: "Module" }));
1265
- function ct({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1266
- const i = n || s.schema;
1267
- return a ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
1268
- /* @__PURE__ */ t.jsx(
1269
- "div",
1270
- {
1271
- className: "w-6 h-6 rounded border border-input",
1272
- style: { backgroundColor: e || "#000000" }
1273
- }
1274
- ),
1275
- /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: e || "-" })
1276
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
1277
- /* @__PURE__ */ t.jsx(
1278
- "input",
1279
- {
1280
- type: "color",
1281
- value: e || "#000000",
1282
- onChange: (l) => r(l.target.value),
1283
- disabled: a || s.disabled,
1284
- className: "w-10 h-10 rounded border border-input cursor-pointer"
1285
- }
1286
- ),
1287
- /* @__PURE__ */ t.jsx(
1288
- w,
1289
- {
1290
- type: "text",
1291
- value: e || "",
1292
- onChange: (l) => r(l.target.value),
1293
- placeholder: i?.placeholder || "#000000",
1294
- disabled: a || s.disabled,
1295
- className: s.className,
1296
- pattern: "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"
1297
- }
1298
- )
1299
- ] });
1300
- }
1301
- const br = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1302
- __proto__: null,
1303
- ColorField: ct
1304
- }, Symbol.toStringTag, { value: "Module" }));
1305
- function dt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1306
- const i = n || s.schema, l = i?.min ?? 0, o = i?.max ?? 100, c = i?.step ?? 1;
1307
- return a ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
1308
- /* @__PURE__ */ t.jsx("span", { className: "text-sm font-medium", children: e ?? l }),
1309
- /* @__PURE__ */ t.jsxs("span", { className: "text-xs text-muted-foreground", children: [
1310
- "/ ",
1311
- o
1312
- ] })
1313
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
1314
- /* @__PURE__ */ t.jsx(
1315
- De,
1316
- {
1317
- value: [e ?? l],
1318
- onValueChange: (m) => r(m[0]),
1319
- min: l,
1320
- max: o,
1321
- step: c,
1322
- disabled: a || s.disabled,
1323
- className: s.className
1324
- }
1325
- ),
1326
- /* @__PURE__ */ t.jsx("span", { className: "text-sm font-medium w-12 text-right", children: e ?? l })
1327
- ] });
1328
- }
1329
- const jr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1330
- __proto__: null,
1331
- SliderField: dt
1332
- }, Symbol.toStringTag, { value: "Module" }));
1333
- function ut({ value: e, onChange: r, field: n, readonly: a, className: s, ...i }) {
1334
- const o = (n || i.schema)?.max ?? 5, c = e ?? 0, [m, p] = k.useState(null), f = m !== null ? m : c;
1335
- return a ? /* @__PURE__ */ t.jsxs("div", { className: z("flex items-center gap-1", s), children: [
1336
- Array.from({ length: o }, (u, x) => /* @__PURE__ */ t.jsx(
1337
- _e,
1338
- {
1339
- className: `w-5 h-5 ${x < c ? "fill-yellow-400 text-yellow-400" : "text-muted-foreground"}`
1340
- },
1341
- x
1342
- )),
1343
- /* @__PURE__ */ t.jsxs("span", { className: "ml-2 text-sm text-muted-foreground", children: [
1344
- c,
1345
- " / ",
1346
- o
1347
- ] })
1348
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: z("flex items-center gap-1", s), children: [
1349
- Array.from({ length: o }, (u, x) => /* @__PURE__ */ t.jsx(
1350
- "button",
1351
- {
1352
- type: "button",
1353
- onClick: () => r(x + 1),
1354
- onMouseEnter: () => p(x + 1),
1355
- onMouseLeave: () => p(null),
1356
- className: "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded",
1357
- disabled: a || i.disabled,
1358
- children: /* @__PURE__ */ t.jsx(
1359
- _e,
1360
- {
1361
- className: `w-5 h-5 transition-colors ${x < f ? "fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500" : "text-muted-foreground hover:text-yellow-400"}`
1362
- }
1363
- )
1364
- },
1365
- x
1366
- )),
1367
- /* @__PURE__ */ t.jsxs("span", { className: "ml-2 text-sm text-muted-foreground", children: [
1368
- c,
1369
- " / ",
1370
- o
1371
- ] })
1372
- ] });
1373
- }
1374
- const yr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1375
- __proto__: null,
1376
- RatingField: ut
1377
- }, Symbol.toStringTag, { value: "Module" }));
1378
- function mt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1379
- const i = n || s.schema, l = i?.language ?? "javascript";
1380
- return a ? /* @__PURE__ */ t.jsx("pre", { className: z("text-sm bg-muted p-2 rounded overflow-x-auto border", s.className), children: /* @__PURE__ */ t.jsx("code", { children: e || "-" }) }) : /* @__PURE__ */ t.jsx(
1381
- Z,
1382
- {
1383
- value: e || "",
1384
- onChange: (o) => r(o.target.value),
1385
- placeholder: i?.placeholder || `// Write ${l} code here...`,
1386
- disabled: a || s.disabled,
1387
- className: z("font-mono text-sm", s.className),
1388
- rows: 12,
1389
- spellCheck: !1
1390
- }
1391
- );
1392
- }
1393
- const Nr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1394
- __proto__: null,
1395
- CodeField: mt
1396
- }, Symbol.toStringTag, { value: "Module" }));
1397
- function ft({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1398
- const [i, l] = k.useState(!1), o = k.useRef(null), c = n || s.schema, m = (u) => {
1399
- const x = u.target.files?.[0];
1400
- if (!x) return;
1401
- if (!x.type.startsWith("image/")) {
1402
- console.error("Please select an image file");
1403
- return;
1404
- }
1405
- if (x.size > 5 * 1024 * 1024) {
1406
- console.error("File size must be less than 5MB");
1407
- return;
1408
- }
1409
- const h = new FileReader();
1410
- h.onloadend = () => {
1411
- r(h.result);
1412
- }, h.readAsDataURL(x);
1413
- }, p = () => {
1414
- r("");
1415
- }, f = () => (c?.defaultName || c?.label || "User").split(" ").map((x) => x[0]).join("").toUpperCase().slice(0, 2);
1416
- return a ? /* @__PURE__ */ t.jsxs(L, { className: "w-16 h-16", children: [
1417
- e && /* @__PURE__ */ t.jsx(ve, { src: e, alt: c?.label }),
1418
- /* @__PURE__ */ t.jsx(I, { children: f() })
1419
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-4", children: [
1420
- /* @__PURE__ */ t.jsxs(
1421
- "div",
1422
- {
1423
- className: "relative",
1424
- onMouseEnter: () => l(!0),
1425
- onMouseLeave: () => l(!1),
1426
- children: [
1427
- /* @__PURE__ */ t.jsxs(L, { className: "w-16 h-16", children: [
1428
- e && /* @__PURE__ */ t.jsx(ve, { src: e, alt: c?.label }),
1429
- /* @__PURE__ */ t.jsx(I, { children: f() })
1430
- ] }),
1431
- !a && i && e && /* @__PURE__ */ t.jsx(
1432
- "button",
1433
- {
1434
- type: "button",
1435
- onClick: p,
1436
- className: "absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90",
1437
- children: /* @__PURE__ */ t.jsx(W, { className: "w-3 h-3" })
1438
- }
1439
- )
1440
- ]
1441
- }
1442
- ),
1443
- /* @__PURE__ */ t.jsxs("div", { className: "flex flex-col gap-2", children: [
1444
- /* @__PURE__ */ t.jsx(
1445
- "input",
1446
- {
1447
- ref: o,
1448
- type: "file",
1449
- accept: "image/*",
1450
- onChange: m,
1451
- className: "hidden"
1452
- }
1453
- ),
1454
- /* @__PURE__ */ t.jsxs(
1455
- P,
1456
- {
1457
- type: "button",
1458
- variant: "outline",
1459
- size: "sm",
1460
- onClick: () => o.current?.click(),
1461
- disabled: a || s.disabled,
1462
- children: [
1463
- /* @__PURE__ */ t.jsx(Me, { className: "w-4 h-4 mr-2" }),
1464
- e ? "Change" : "Upload",
1465
- " Avatar"
1466
- ]
1467
- }
1468
- ),
1469
- /* @__PURE__ */ t.jsx("p", { className: "text-xs text-muted-foreground", children: "PNG, JPG up to 5MB" })
1470
- ] })
1471
- ] });
1472
- }
1473
- const vr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1474
- __proto__: null,
1475
- AvatarField: ft
1476
- }, Symbol.toStringTag, { value: "Module" }));
1477
- function xt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1478
- const i = e || {}, l = (c, m) => {
1479
- r({
1480
- ...i,
1481
- [c]: m
1482
- });
1483
- }, o = (c) => [
1484
- c.street,
1485
- c.city,
1486
- [c.state, c.zipCode].filter(Boolean).join(" "),
1487
- c.country
1488
- ].filter(Boolean).join(", ") || "-";
1489
- return a ? /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: o(i) }) : /* @__PURE__ */ t.jsxs("div", { className: "space-y-3", children: [
1490
- /* @__PURE__ */ t.jsxs("div", { children: [
1491
- /* @__PURE__ */ t.jsx(E, { htmlFor: "street", className: "text-xs", children: "Street Address" }),
1492
- /* @__PURE__ */ t.jsx(
1493
- w,
1494
- {
1495
- id: "street",
1496
- type: "text",
1497
- value: i.street || "",
1498
- onChange: (c) => l("street", c.target.value),
1499
- placeholder: "123 Main St",
1500
- disabled: a || s.disabled,
1501
- className: s.className
1502
- }
1503
- )
1504
- ] }),
1505
- /* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
1506
- /* @__PURE__ */ t.jsxs("div", { children: [
1507
- /* @__PURE__ */ t.jsx(E, { htmlFor: "city", className: "text-xs", children: "City" }),
1508
- /* @__PURE__ */ t.jsx(
1509
- w,
1510
- {
1511
- id: "city",
1512
- type: "text",
1513
- value: i.city || "",
1514
- onChange: (c) => l("city", c.target.value),
1515
- placeholder: "San Francisco",
1516
- disabled: a || s.disabled
1517
- }
1518
- )
1519
- ] }),
1520
- /* @__PURE__ */ t.jsxs("div", { children: [
1521
- /* @__PURE__ */ t.jsx(E, { htmlFor: "state", className: "text-xs", children: "State / Province" }),
1522
- /* @__PURE__ */ t.jsx(
1523
- w,
1524
- {
1525
- id: "state",
1526
- type: "text",
1527
- value: i.state || "",
1528
- onChange: (c) => l("state", c.target.value),
1529
- placeholder: "CA",
1530
- disabled: a || s.disabled
1531
- }
1532
- )
1533
- ] })
1534
- ] }),
1535
- /* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
1536
- /* @__PURE__ */ t.jsxs("div", { children: [
1537
- /* @__PURE__ */ t.jsx(E, { htmlFor: "zipCode", className: "text-xs", children: "ZIP / Postal Code" }),
1538
- /* @__PURE__ */ t.jsx(
1539
- w,
1540
- {
1541
- id: "zipCode",
1542
- type: "text",
1543
- value: i.zipCode || "",
1544
- onChange: (c) => l("zipCode", c.target.value),
1545
- placeholder: "94102",
1546
- disabled: a || s.disabled
1547
- }
1548
- )
1549
- ] }),
1550
- /* @__PURE__ */ t.jsxs("div", { children: [
1551
- /* @__PURE__ */ t.jsx(E, { htmlFor: "country", className: "text-xs", children: "Country" }),
1552
- /* @__PURE__ */ t.jsx(
1553
- w,
1554
- {
1555
- id: "country",
1556
- type: "text",
1557
- value: i.country || "",
1558
- onChange: (c) => l("country", c.target.value),
1559
- placeholder: "United States",
1560
- disabled: a || s.disabled
1561
- }
1562
- )
1563
- ] })
1564
- ] })
1565
- ] });
1566
- }
1567
- const _r = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1568
- __proto__: null,
1569
- AddressField: xt
1570
- }, Symbol.toStringTag, { value: "Module" }));
1571
- function pt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1572
- const [i, l] = k.useState(!1), o = e || {}, c = (u, x) => {
1573
- r({
1574
- ...o,
1575
- [u]: x ? Number(x) : void 0
1576
- });
1577
- }, m = () => {
1578
- if (!navigator.geolocation) {
1579
- console.error("Geolocation is not supported by this browser");
1580
- return;
1581
- }
1582
- l(!0), navigator.geolocation.getCurrentPosition(
1583
- (u) => {
1584
- r({
1585
- latitude: u.coords.latitude,
1586
- longitude: u.coords.longitude,
1587
- accuracy: u.coords.accuracy
1588
- }), l(!1);
1589
- },
1590
- (u) => {
1591
- console.error("Error getting location:", u.message), l(!1);
1592
- },
1593
- {
1594
- enableHighAccuracy: !0,
1595
- timeout: 5e3,
1596
- maximumAge: 0
1597
- }
1598
- );
1599
- }, p = (u) => !u.latitude || !u.longitude ? "-" : `${u.latitude.toFixed(6)}, ${u.longitude.toFixed(6)}`, f = () => {
1600
- if (!o.latitude || !o.longitude) return;
1601
- const u = `https://www.google.com/maps?q=${o.latitude},${o.longitude}`;
1602
- window.open(u, "_blank");
1603
- };
1604
- return a ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
1605
- /* @__PURE__ */ t.jsx(we, { className: "w-4 h-4 text-muted-foreground" }),
1606
- /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: p(o) }),
1607
- o.latitude && o.longitude && /* @__PURE__ */ t.jsx(
1608
- P,
1609
- {
1610
- type: "button",
1611
- variant: "link",
1612
- size: "sm",
1613
- onClick: f,
1614
- className: "p-0 h-auto",
1615
- children: "View on map"
1616
- }
1617
- )
1618
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: "space-y-3", children: [
1619
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
1620
- /* @__PURE__ */ t.jsxs(
1621
- P,
1622
- {
1623
- type: "button",
1624
- variant: "outline",
1625
- size: "sm",
1626
- onClick: m,
1627
- disabled: a || i,
1628
- children: [
1629
- /* @__PURE__ */ t.jsx(It, { className: "w-4 h-4 mr-2" }),
1630
- i ? "Getting location..." : "Use Current Location"
1631
- ]
1632
- }
1633
- ),
1634
- o.latitude && o.longitude && /* @__PURE__ */ t.jsxs(
1635
- P,
1636
- {
1637
- type: "button",
1638
- variant: "link",
1639
- size: "sm",
1640
- onClick: f,
1641
- children: [
1642
- /* @__PURE__ */ t.jsx(we, { className: "w-4 h-4 mr-2" }),
1643
- "View on map"
1644
- ]
1645
- }
1646
- )
1647
- ] }),
1648
- /* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
1649
- /* @__PURE__ */ t.jsxs("div", { children: [
1650
- /* @__PURE__ */ t.jsx(E, { htmlFor: "latitude", className: "text-xs", children: "Latitude" }),
1651
- /* @__PURE__ */ t.jsx(
1652
- w,
1653
- {
1654
- id: "latitude",
1655
- type: "number",
1656
- value: o.latitude ?? "",
1657
- onChange: (u) => c("latitude", u.target.value),
1658
- placeholder: "37.7749",
1659
- disabled: a || s.disabled,
1660
- step: "any",
1661
- className: s.className
1662
- }
1663
- )
1664
- ] }),
1665
- /* @__PURE__ */ t.jsxs("div", { children: [
1666
- /* @__PURE__ */ t.jsx(E, { htmlFor: "longitude", className: "text-xs", children: "Longitude" }),
1667
- /* @__PURE__ */ t.jsx(
1668
- w,
1669
- {
1670
- id: "longitude",
1671
- type: "number",
1672
- value: o.longitude ?? "",
1673
- onChange: (u) => c("longitude", u.target.value),
1674
- placeholder: "-122.4194",
1675
- disabled: a || s.disabled,
1676
- step: "any"
1677
- }
1678
- )
1679
- ] })
1680
- ] }),
1681
- o.accuracy && /* @__PURE__ */ t.jsxs("p", { className: "text-xs text-muted-foreground", children: [
1682
- "Accuracy: ±",
1683
- o.accuracy.toFixed(0),
1684
- "m"
1685
- ] })
1686
- ] });
1687
- }
1688
- const wr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1689
- __proto__: null,
1690
- GeolocationField: pt
1691
- }, Symbol.toStringTag, { value: "Module" }));
1692
- function ht({ value: e, onChange: r, readonly: n }) {
1693
- const a = xe(null), [s, i] = k.useState(!1), [l, o] = k.useState(!e);
1694
- ze(() => {
1695
- if (e && a.current) {
1696
- const x = a.current.getContext("2d");
1697
- if (x) {
1698
- const h = new Image();
1699
- h.onload = () => {
1700
- x.drawImage(h, 0, 0), o(!1);
1701
- }, h.src = e;
1702
- }
1703
- }
1704
- }, [e]);
1705
- const c = (u) => {
1706
- if (n) return;
1707
- i(!0), o(!1);
1708
- const x = a.current;
1709
- if (!x) return;
1710
- const h = x.getContext("2d");
1711
- if (!h) return;
1712
- const v = x.getBoundingClientRect(), R = "touches" in u ? u.touches[0].clientX - v.left : u.clientX - v.left, N = "touches" in u ? u.touches[0].clientY - v.top : u.clientY - v.top;
1713
- h.beginPath(), h.moveTo(R, N);
1714
- }, m = (u) => {
1715
- if (!s || n) return;
1716
- const x = a.current;
1717
- if (!x) return;
1718
- const h = x.getContext("2d");
1719
- if (!h) return;
1720
- const v = x.getBoundingClientRect(), R = "touches" in u ? u.touches[0].clientX - v.left : u.clientX - v.left, N = "touches" in u ? u.touches[0].clientY - v.top : u.clientY - v.top;
1721
- h.lineTo(R, N), h.strokeStyle = "#000", h.lineWidth = 2, h.lineCap = "round", h.lineJoin = "round", h.stroke();
1722
- }, p = () => {
1723
- if (!s) return;
1724
- i(!1);
1725
- const u = a.current;
1726
- if (!u) return;
1727
- const x = u.toDataURL("image/png");
1728
- r(x);
1729
- }, f = () => {
1730
- const u = a.current;
1731
- if (!u) return;
1732
- const x = u.getContext("2d");
1733
- x && (x.clearRect(0, 0, u.width, u.height), o(!0), r(""));
1734
- };
1735
- return n && e ? /* @__PURE__ */ t.jsx("div", { className: "border rounded p-2 bg-white", children: /* @__PURE__ */ t.jsx("img", { src: e, alt: "Signature", loading: "lazy", className: "max-w-full h-auto" }) }) : n && !e ? /* @__PURE__ */ t.jsx("span", { className: "text-sm text-muted-foreground", children: "No signature" }) : /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
1736
- /* @__PURE__ */ t.jsx("div", { className: "border rounded bg-white", children: /* @__PURE__ */ t.jsx(
1737
- "canvas",
1738
- {
1739
- ref: a,
1740
- width: 400,
1741
- height: 200,
1742
- className: "w-full touch-none cursor-crosshair",
1743
- onMouseDown: c,
1744
- onMouseMove: m,
1745
- onMouseUp: p,
1746
- onMouseLeave: p,
1747
- onTouchStart: c,
1748
- onTouchMove: m,
1749
- onTouchEnd: p
1750
- }
1751
- ) }),
1752
- /* @__PURE__ */ t.jsxs("div", { className: "flex justify-between items-center", children: [
1753
- /* @__PURE__ */ t.jsx("p", { className: "text-xs text-muted-foreground", children: l ? "Sign above" : "Signature captured" }),
1754
- /* @__PURE__ */ t.jsxs(
1755
- P,
1756
- {
1757
- type: "button",
1758
- variant: "outline",
1759
- size: "sm",
1760
- onClick: f,
1761
- disabled: n || l,
1762
- children: [
1763
- /* @__PURE__ */ t.jsx(Ut, { className: "w-4 h-4 mr-2" }),
1764
- "Clear"
1765
- ]
1766
- }
1767
- )
1768
- ] })
1769
- ] });
1770
- }
1771
- const Fr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1772
- __proto__: null,
1773
- SignatureField: ht
1774
- }, Symbol.toStringTag, { value: "Module" }));
1775
- function gt({ value: e, onChange: r, field: n, readonly: a, ...s }) {
1776
- const [i, l] = k.useState(!1), o = n || s.schema, c = (p) => `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(p)}`, m = () => {
1777
- e && navigator.clipboard.writeText(e);
1778
- };
1779
- return a ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-3", children: [
1780
- /* @__PURE__ */ t.jsx("span", { className: "text-sm flex-1 truncate", children: e || "-" }),
1781
- e && /* @__PURE__ */ t.jsxs(
1782
- P,
1783
- {
1784
- type: "button",
1785
- variant: "outline",
1786
- size: "sm",
1787
- onClick: () => l(!i),
1788
- children: [
1789
- /* @__PURE__ */ t.jsx(Fe, { className: "w-4 h-4 mr-2" }),
1790
- i ? "Hide" : "Show",
1791
- " QR"
1792
- ]
1793
- }
1794
- )
1795
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: "space-y-3", children: [
1796
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
1797
- /* @__PURE__ */ t.jsx(
1798
- w,
1799
- {
1800
- type: "text",
1801
- value: e || "",
1802
- onChange: (p) => r(p.target.value),
1803
- placeholder: o?.placeholder || "Enter text for QR code",
1804
- disabled: a || s.disabled,
1805
- className: s.className
1806
- }
1807
- ),
1808
- e && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
1809
- /* @__PURE__ */ t.jsx(
1810
- P,
1811
- {
1812
- type: "button",
1813
- variant: "outline",
1814
- size: "sm",
1815
- onClick: m,
1816
- children: /* @__PURE__ */ t.jsx(pe, { className: "w-4 h-4" })
1817
- }
1818
- ),
1819
- /* @__PURE__ */ t.jsx(
1820
- P,
1821
- {
1822
- type: "button",
1823
- variant: "outline",
1824
- size: "sm",
1825
- onClick: () => l(!i),
1826
- children: /* @__PURE__ */ t.jsx(Fe, { className: "w-4 h-4" })
1827
- }
1828
- )
1829
- ] })
1830
- ] }),
1831
- i && e && /* @__PURE__ */ t.jsx("div", { className: "border rounded p-4 bg-white flex justify-center", children: /* @__PURE__ */ t.jsx(
1832
- "img",
1833
- {
1834
- src: c(e),
1835
- alt: "QR Code",
1836
- className: "w-48 h-48"
1837
- }
1838
- ) }),
1839
- e && /* @__PURE__ */ t.jsxs("p", { className: "text-xs text-muted-foreground", children: [
1840
- "QR code contains: ",
1841
- e.length,
1842
- " characters"
1843
- ] })
1844
- ] });
1845
- }
1846
- const Sr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1847
- __proto__: null,
1848
- QRCodeField: gt
1849
- }, Symbol.toStringTag, { value: "Module" }));
1850
- function bt({
1851
- value: e,
1852
- onChange: r,
1853
- field: n,
1854
- readonly: a,
1855
- className: s,
1856
- ...i
1857
- }) {
1858
- const l = e || [], o = n || i.schema, c = () => {
1859
- const f = {
1860
- id: `new-${Date.now()}`,
1861
- label: "New Related Record"
1862
- };
1863
- r([...l, f]);
1864
- }, m = (f) => {
1865
- r(l.filter((u) => u.id !== f));
1866
- }, p = (f) => {
1867
- console.log("View detail:", f);
1868
- };
1869
- return a ? /* @__PURE__ */ t.jsxs("div", { className: z("space-y-2", s), children: [
1870
- l.length === 0 ? /* @__PURE__ */ t.jsx("span", { className: "text-sm text-muted-foreground", children: "No related records" }) : l.map((f) => /* @__PURE__ */ t.jsxs(
1871
- "div",
1872
- {
1873
- className: "flex items-center justify-between p-2 border rounded hover:bg-muted/50",
1874
- children: [
1875
- /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: f.label }),
1876
- /* @__PURE__ */ t.jsx(
1877
- P,
1878
- {
1879
- type: "button",
1880
- variant: "ghost",
1881
- size: "sm",
1882
- onClick: () => p(f),
1883
- children: /* @__PURE__ */ t.jsx(Se, { className: "w-4 h-4" })
1884
- }
1885
- )
1886
- ]
1887
- },
1888
- f.id
1889
- )),
1890
- /* @__PURE__ */ t.jsxs("p", { className: "text-xs text-muted-foreground", children: [
1891
- l.length,
1892
- " ",
1893
- l.length === 1 ? "record" : "records"
1894
- ] })
1895
- ] }) : /* @__PURE__ */ t.jsxs("div", { className: z("space-y-3", s), children: [
1896
- /* @__PURE__ */ t.jsxs("div", { className: "space-y-2", children: [
1897
- l.map((f) => /* @__PURE__ */ t.jsxs(
1898
- "div",
1899
- {
1900
- className: "flex items-center justify-between gap-2 p-2 border rounded hover:bg-muted/50",
1901
- children: [
1902
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2 flex-1", children: [
1903
- /* @__PURE__ */ t.jsx(M, { variant: "outline", children: f.id }),
1904
- /* @__PURE__ */ t.jsx("span", { className: "text-sm flex-1", children: f.label })
1905
- ] }),
1906
- /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-1", children: [
1907
- /* @__PURE__ */ t.jsx(
1908
- P,
1909
- {
1910
- type: "button",
1911
- variant: "ghost",
1912
- size: "sm",
1913
- onClick: () => p(f),
1914
- children: /* @__PURE__ */ t.jsx(Se, { className: "w-4 h-4" })
1915
- }
1916
- ),
1917
- /* @__PURE__ */ t.jsx(
1918
- P,
1919
- {
1920
- type: "button",
1921
- variant: "ghost",
1922
- size: "sm",
1923
- onClick: () => m(f.id),
1924
- disabled: i.disabled,
1925
- children: /* @__PURE__ */ t.jsx(W, { className: "w-4 h-4" })
1926
- }
1927
- )
1928
- ] })
1929
- ]
1930
- },
1931
- f.id
1932
- )),
1933
- l.length === 0 && /* @__PURE__ */ t.jsx("div", { className: "text-sm text-muted-foreground text-center py-4 border border-dashed rounded bg-muted/20", children: "No related records" })
1934
- ] }),
1935
- /* @__PURE__ */ t.jsxs(
1936
- P,
1937
- {
1938
- type: "button",
1939
- variant: "outline",
1940
- className: "w-full",
1941
- onClick: c,
1942
- disabled: i.disabled,
1943
- children: [
1944
- /* @__PURE__ */ t.jsx(Vt, { className: "w-4 h-4 mr-2" }),
1945
- "Add ",
1946
- o?.label || "Record"
1947
- ]
1948
- }
1949
- )
1950
- ] });
1951
- }
1952
- const Cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1953
- __proto__: null,
1954
- MasterDetailField: bt
1955
- }, Symbol.toStringTag, { value: "Module" }));
1956
- function Pr(e, r = "USD") {
1957
- try {
1958
- return new Intl.NumberFormat("en-US", {
1959
- style: "currency",
1960
- currency: r
1961
- }).format(e);
1962
- } catch {
1963
- return `${r} ${e.toFixed(2)}`;
1964
- }
1965
- }
1966
- function Zr(e, r = "USD") {
1967
- try {
1968
- return new Intl.NumberFormat("en-US", {
1969
- style: "currency",
1970
- currency: r,
1971
- notation: "compact",
1972
- maximumFractionDigits: 1
1973
- }).format(e).replace(/\.0(?=[KMBT])/, "");
1974
- } catch {
1975
- return `${r} ${e}`;
1976
- }
1977
- }
1978
- function Tr(e, r = 0) {
1979
- return `${(e > -1 && e < 1 ? e * 100 : e).toFixed(r)}%`;
1980
- }
1981
- function ue(e) {
1982
- return e.replace(/[_-]/g, " ").replace(/\b\w/g, (r) => r.toUpperCase());
1983
- }
1984
- function Or(e) {
1985
- if (!e) return "-";
1986
- const r = typeof e == "string" ? new Date(e) : e;
1987
- if (isNaN(r.getTime())) return "-";
1988
- const n = /* @__PURE__ */ new Date(), a = new Date(n.getFullYear(), n.getMonth(), n.getDate()), i = new Date(r.getFullYear(), r.getMonth(), r.getDate()).getTime() - a.getTime(), l = Math.round(i / (1e3 * 60 * 60 * 24));
1989
- if (l === 0) return "Today";
1990
- if (l === 1) return "Tomorrow";
1991
- if (l === -1) return "Yesterday";
1992
- if (l < -1) {
1993
- const o = Math.abs(l);
1994
- return o <= 7 ? `Overdue ${o}d` : me(r);
1995
- }
1996
- return l > 1 && l <= 7 ? `In ${l} days` : me(r);
1997
- }
1998
- function me(e, r) {
1999
- if (!e) return "-";
2000
- const n = typeof e == "string" ? new Date(e) : e;
2001
- if (isNaN(n.getTime())) return "-";
2002
- if (r === "short") {
2003
- const a = n.toLocaleDateString("en-US", { month: "short" }), s = n.getDate(), i = String(n.getFullYear()).slice(-2);
2004
- return `${a} ${s}, '${i}`;
2005
- }
2006
- return r === "relative" ? Or(n) : n.toLocaleDateString(void 0, {
2007
- year: "numeric",
2008
- month: "short",
2009
- day: "numeric"
2010
- });
2011
- }
2012
- function Kr(e) {
2013
- if (!e) return "-";
2014
- const r = typeof e == "string" ? new Date(e) : e;
2015
- return isNaN(r.getTime()) ? "-" : r.toLocaleDateString(void 0, {
2016
- year: "numeric",
2017
- month: "short",
2018
- day: "numeric",
2019
- hour: "2-digit",
2020
- minute: "2-digit"
2021
- });
2022
- }
2023
- function D({ value: e }) {
2024
- return /* @__PURE__ */ t.jsx("span", { className: "truncate", children: e != null && e !== "" ? String(e) : "-" });
2025
- }
2026
- function Rr({ value: e, field: r }) {
2027
- if (e == null) return /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: "-" });
2028
- const a = r.precision ?? 0, s = typeof e == "number" ? new Intl.NumberFormat("en-US", { minimumFractionDigits: a, maximumFractionDigits: a }).format(e) : e;
2029
- return /* @__PURE__ */ t.jsx("span", { className: "tabular-nums", children: s });
2030
- }
2031
- function kr({ value: e, field: r }) {
2032
- if (e == null) return /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: "-" });
2033
- const a = r.currency || "USD", s = Pr(Number(e), a);
2034
- return /* @__PURE__ */ t.jsx("span", { className: "tabular-nums font-medium whitespace-nowrap", children: s });
2035
- }
2036
- const Ar = /progress|completion/;
2037
- function $r({ value: e, field: r }) {
2038
- if (e == null) return /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: "-" });
2039
- const a = r.precision ?? 0, s = Number(e), i = Ar.test(r?.name?.toLowerCase() || ""), l = i ? s : s > -1 && s < 1 ? s * 100 : s, o = i ? `${s.toFixed(a)}%` : Tr(s, a), c = Math.max(0, Math.min(100, l));
2040
- return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
2041
- /* @__PURE__ */ t.jsx(
2042
- "div",
2043
- {
2044
- className: "h-1.5 w-16 rounded-full bg-muted overflow-hidden flex-shrink-0",
2045
- role: "progressbar",
2046
- "aria-valuenow": c,
2047
- "aria-valuemin": 0,
2048
- "aria-valuemax": 100,
2049
- children: /* @__PURE__ */ t.jsx(
2050
- "div",
2051
- {
2052
- className: "h-full rounded-full bg-primary transition-all",
2053
- style: { width: `${c}%` }
2054
- }
2055
- )
2056
- }
2057
- ),
2058
- /* @__PURE__ */ t.jsx("span", { className: "tabular-nums whitespace-nowrap", children: o })
2059
- ] });
2060
- }
2061
- const zr = /* @__PURE__ */ new Set([
2062
- "active",
2063
- "is_active",
2064
- "enabled",
2065
- "is_enabled",
2066
- "verified",
2067
- "is_verified"
519
+ role: "button",
520
+ tabIndex: 0,
521
+ onKeyDown: (e) => {
522
+ (e.key === "Enter" || e.key === " ") && (e.preventDefault(), o.current?.click());
523
+ },
524
+ children: [/* @__PURE__ */ (0, A.jsx)(me, { className: `size-8 ${p ? "text-primary" : "text-muted-foreground"}` }), /* @__PURE__ */ (0, A.jsxs)("div", {
525
+ className: "text-center",
526
+ children: [/* @__PURE__ */ (0, A.jsx)("p", {
527
+ className: "text-sm font-medium",
528
+ children: p ? "Drop files here" : "Drag & drop files here"
529
+ }), /* @__PURE__ */ (0, A.jsx)("p", {
530
+ className: "text-xs text-muted-foreground mt-1",
531
+ children: "or click to browse"
532
+ })]
533
+ })]
534
+ }),
535
+ g.length > 0 && /* @__PURE__ */ (0, A.jsx)("div", {
536
+ className: "space-y-0.5",
537
+ children: g.map((e, t) => /* @__PURE__ */ (0, A.jsx)("p", {
538
+ className: "text-xs text-destructive",
539
+ children: e
540
+ }, t))
541
+ }),
542
+ v.length > 0 && /* @__PURE__ */ (0, A.jsx)("div", {
543
+ className: "space-y-1",
544
+ children: v.map((e, t) => /* @__PURE__ */ (0, A.jsxs)("div", {
545
+ className: "flex items-center justify-between gap-2 p-2 bg-muted/50 rounded-md border",
546
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", {
547
+ className: "flex items-center gap-2 flex-1 min-w-0",
548
+ children: [
549
+ C(e) && e.url ? /* @__PURE__ */ (0, A.jsx)("img", {
550
+ src: e.url,
551
+ alt: e.name,
552
+ className: "size-8 object-cover rounded flex-shrink-0"
553
+ }) : C(e) ? /* @__PURE__ */ (0, A.jsx)(le, { className: "size-4 text-muted-foreground flex-shrink-0" }) : /* @__PURE__ */ (0, A.jsx)(se, { className: "size-4 text-muted-foreground flex-shrink-0" }),
554
+ /* @__PURE__ */ (0, A.jsx)("span", {
555
+ className: "text-sm truncate",
556
+ children: e.name || e.original_name || "File"
557
+ }),
558
+ e.size && /* @__PURE__ */ (0, A.jsxs)("span", {
559
+ className: "text-xs text-muted-foreground",
560
+ children: [
561
+ "(",
562
+ (e.size / 1024).toFixed(1),
563
+ " KB)"
564
+ ]
565
+ })
566
+ ]
567
+ }), /* @__PURE__ */ (0, A.jsx)(h, {
568
+ type: "button",
569
+ variant: "ghost",
570
+ size: "sm",
571
+ onClick: (e) => {
572
+ e.stopPropagation(), S(t);
573
+ },
574
+ className: "h-6 w-6 p-0",
575
+ children: /* @__PURE__ */ (0, A.jsx)(k, { className: "size-3" })
576
+ })]
577
+ }, t))
578
+ })
579
+ ]
580
+ })]
581
+ });
582
+ }
583
+ //#endregion
584
+ //#region src/widgets/ImageField.tsx
585
+ function Se({ value: e, onChange: t, field: n, readonly: r, ...i }) {
586
+ let a = c(null), o = n || i.schema, s = o?.multiple || !1, l = o?.accept ? o.accept.join(",") : "image/*";
587
+ if (r) return e ? /* @__PURE__ */ (0, A.jsx)("div", {
588
+ className: "flex flex-wrap gap-2",
589
+ children: (Array.isArray(e) ? e : [e]).map((e, t) => /* @__PURE__ */ (0, A.jsx)("img", {
590
+ src: e.url || "",
591
+ alt: e.name || `Image ${t + 1}`,
592
+ className: "size-20 rounded-md object-cover border border-gray-200"
593
+ }, t))
594
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
595
+ className: "text-sm",
596
+ children: "-"
597
+ });
598
+ let u = e ? Array.isArray(e) ? e : [e] : [], d = (e) => {
599
+ let n = Array.from(e.target.files || []);
600
+ if (n.length === 0) return;
601
+ let r = n.map((e) => ({
602
+ name: e.name,
603
+ original_name: e.name,
604
+ size: e.size,
605
+ mime_type: e.type,
606
+ url: URL.createObjectURL(e)
607
+ }));
608
+ t(s ? [...u, ...r] : r[0]);
609
+ }, f = (e) => {
610
+ if (s) {
611
+ let n = u.filter((t, n) => n !== e);
612
+ t(n.length > 0 ? n : null);
613
+ } else t(null);
614
+ };
615
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
616
+ className: i.className,
617
+ children: [/* @__PURE__ */ (0, A.jsx)("input", {
618
+ ref: a,
619
+ type: "file",
620
+ multiple: s,
621
+ accept: l,
622
+ onChange: d,
623
+ className: "hidden"
624
+ }), /* @__PURE__ */ (0, A.jsxs)("div", {
625
+ className: "space-y-2",
626
+ children: [u.length > 0 && /* @__PURE__ */ (0, A.jsx)("div", {
627
+ className: "grid grid-cols-4 gap-2",
628
+ children: u.map((e, t) => /* @__PURE__ */ (0, A.jsxs)("div", {
629
+ className: "relative group",
630
+ children: [/* @__PURE__ */ (0, A.jsx)("img", {
631
+ src: e.url || "",
632
+ alt: e.name || `Image ${t + 1}`,
633
+ className: "size-20 rounded-md object-cover border border-gray-200"
634
+ }), /* @__PURE__ */ (0, A.jsx)(h, {
635
+ type: "button",
636
+ variant: "destructive",
637
+ size: "sm",
638
+ onClick: () => f(t),
639
+ className: "absolute top-1 right-1 h-6 w-6 p-0 opacity-0 group-hover:opacity-100 transition-opacity",
640
+ children: /* @__PURE__ */ (0, A.jsx)(k, { className: "size-3" })
641
+ })]
642
+ }, t))
643
+ }), /* @__PURE__ */ (0, A.jsxs)(h, {
644
+ type: "button",
645
+ variant: "outline",
646
+ onClick: () => a.current?.click(),
647
+ className: "w-full",
648
+ children: [/* @__PURE__ */ (0, A.jsx)(ce, { className: "size-4 mr-2" }), u.length > 0 ? "Add More Images" : "Upload Image"]
649
+ })]
650
+ })]
651
+ });
652
+ }
653
+ //#endregion
654
+ //#region src/widgets/LocationField.tsx
655
+ function Ce({ value: e, onChange: t, field: n, readonly: r, ...i }) {
656
+ let a = n || i.schema, o = e && typeof e == "object" ? `${e.latitude || 0}, ${e.longitude || 0}` : "";
657
+ return r ? /* @__PURE__ */ (0, A.jsx)("span", {
658
+ className: "text-sm",
659
+ children: o || "-"
660
+ }) : /* @__PURE__ */ (0, A.jsx)(_, {
661
+ type: "text",
662
+ value: o,
663
+ onChange: (e) => {
664
+ let n = e.target.value;
665
+ if (!n.trim()) {
666
+ t(null);
667
+ return;
668
+ }
669
+ let r = n.split(",").map((e) => e.trim());
670
+ if (r.length === 2) {
671
+ let e = parseFloat(r[0]), n = parseFloat(r[1]);
672
+ !isNaN(e) && !isNaN(n) && t({
673
+ latitude: e,
674
+ longitude: n
675
+ });
676
+ }
677
+ },
678
+ placeholder: a?.placeholder || "latitude, longitude",
679
+ disabled: r || i.disabled,
680
+ className: i.className
681
+ });
682
+ }
683
+ //#endregion
684
+ //#region src/widgets/FormulaField.tsx
685
+ function we({ value: e, field: t, ...n }) {
686
+ let r = (t || n.schema)?.return_type || "text", i = "-";
687
+ return e != null && (i = r === "number" || r === "currency" ? typeof e == "number" ? e.toFixed(2) : String(e) : r === "boolean" ? e ? "Yes" : "No" : r === "date" ? new Date(e).toLocaleDateString() : String(e)), /* @__PURE__ */ (0, A.jsx)("span", {
688
+ className: `text-sm font-mono text-gray-700 ${n.className || ""}`,
689
+ children: i
690
+ });
691
+ }
692
+ //#endregion
693
+ //#region src/widgets/SummaryField.tsx
694
+ function Te({ value: e, field: t, ...n }) {
695
+ let r = (t || n.schema)?.summary_type || "count", i = "-";
696
+ return e != null && (i = r === "count" ? String(e) : [
697
+ "sum",
698
+ "avg",
699
+ "min",
700
+ "max"
701
+ ].includes(r) && typeof e == "number" ? e.toFixed(2) : String(e)), /* @__PURE__ */ (0, A.jsx)("span", {
702
+ className: `text-sm font-medium tabular-nums text-gray-700 ${n.className || ""}`,
703
+ children: i
704
+ });
705
+ }
706
+ //#endregion
707
+ //#region src/widgets/AutoNumberField.tsx
708
+ function Ee({ value: e, field: t, ...n }) {
709
+ let r = e == null ? "-" : String(e);
710
+ return /* @__PURE__ */ (0, A.jsx)("span", {
711
+ className: `text-sm font-mono text-gray-700 ${n.className || ""}`,
712
+ children: r
713
+ });
714
+ }
715
+ //#endregion
716
+ //#region src/widgets/UserField.tsx
717
+ function V({ value: e, onChange: t, field: n, readonly: r, ...i }) {
718
+ let a = (n || i.schema)?.multiple || !1;
719
+ if (r) {
720
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", {
721
+ className: "text-sm",
722
+ children: "-"
723
+ });
724
+ let t = Array.isArray(e) ? e : [e];
725
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
726
+ className: "flex -space-x-2",
727
+ children: [t.slice(0, 3).map((e, t) => {
728
+ let n = e.name || e.username || "User";
729
+ return /* @__PURE__ */ (0, A.jsx)(d, {
730
+ className: "size-8 border-2 border-white",
731
+ title: n,
732
+ children: /* @__PURE__ */ (0, A.jsx)(f, {
733
+ className: "bg-blue-500 text-white text-xs",
734
+ children: n.split(" ").map((e) => e[0]).join("").toUpperCase().slice(0, 2)
735
+ })
736
+ }, t);
737
+ }), t.length > 3 && /* @__PURE__ */ (0, A.jsx)(d, {
738
+ className: "size-8 border-2 border-white",
739
+ children: /* @__PURE__ */ (0, A.jsxs)(f, {
740
+ className: "bg-gray-200 text-gray-600 text-xs",
741
+ children: ["+", t.length - 3]
742
+ })
743
+ })]
744
+ });
745
+ }
746
+ let o = e ? Array.isArray(e) ? e : [e] : [], s = (e) => {
747
+ if (a) {
748
+ let n = o.filter((t, n) => n !== e);
749
+ t(n.length > 0 ? n : null);
750
+ } else t(null);
751
+ };
752
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
753
+ className: i.className,
754
+ children: [o.length > 0 && /* @__PURE__ */ (0, A.jsx)("div", {
755
+ className: "flex flex-wrap gap-2 mb-2",
756
+ children: o.map((e, t) => {
757
+ let n = e.name || e.username || "User";
758
+ return /* @__PURE__ */ (0, A.jsxs)(m, {
759
+ variant: "outline",
760
+ className: "gap-2 pr-1",
761
+ children: [
762
+ /* @__PURE__ */ (0, A.jsx)(d, {
763
+ className: "size-5",
764
+ children: /* @__PURE__ */ (0, A.jsx)(f, {
765
+ className: "bg-blue-500 text-white text-xs",
766
+ children: n.split(" ").map((e) => e[0]).join("").toUpperCase().slice(0, 2)
767
+ })
768
+ }),
769
+ /* @__PURE__ */ (0, A.jsx)("span", {
770
+ className: "text-sm",
771
+ children: n
772
+ }),
773
+ /* @__PURE__ */ (0, A.jsx)("button", {
774
+ type: "button",
775
+ onClick: () => s(t),
776
+ className: "ml-1 rounded-full hover:bg-gray-200 p-0.5",
777
+ children: /* @__PURE__ */ (0, A.jsx)(k, { className: "size-3" })
778
+ })
779
+ ]
780
+ }, t);
781
+ })
782
+ }), /* @__PURE__ */ (0, A.jsx)("div", {
783
+ className: "text-sm text-gray-500 italic",
784
+ children: "User selection component requires integration with user management system"
785
+ })]
786
+ });
787
+ }
788
+ //#endregion
789
+ //#region src/widgets/ObjectField.tsx
790
+ function De({ value: e, onChange: t, field: n, readonly: r, ...i }) {
791
+ let a = n || i.schema, [s, c] = l(() => e == null ? "" : JSON.stringify(e, null, 2)), [u, d] = l(null);
792
+ return o(() => {
793
+ try {
794
+ if (e == null) {
795
+ c("");
796
+ return;
797
+ }
798
+ let t = s ? JSON.parse(s) : null;
799
+ JSON.stringify(t) !== JSON.stringify(e) && c(JSON.stringify(e, null, 2));
800
+ } catch {
801
+ c(JSON.stringify(e, null, 2));
802
+ }
803
+ }, [e, s]), r ? e ? /* @__PURE__ */ (0, A.jsx)("pre", {
804
+ className: T("text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-auto max-h-40", i.className),
805
+ children: JSON.stringify(e, null, 2)
806
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
807
+ className: "text-sm",
808
+ children: "-"
809
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
810
+ className: "space-y-1",
811
+ children: [/* @__PURE__ */ (0, A.jsx)(w, {
812
+ value: s,
813
+ onChange: (e) => {
814
+ let n = e.target.value;
815
+ if (c(n), d(null), !n.trim()) {
816
+ t(null);
817
+ return;
818
+ }
819
+ try {
820
+ t(JSON.parse(n));
821
+ } catch {
822
+ d("Invalid JSON");
823
+ }
824
+ },
825
+ placeholder: a?.placeholder || "{\n \"key\": \"value\"\n}",
826
+ disabled: r || i.disabled,
827
+ className: T("font-mono text-xs", u ? "border-red-500 focus-visible:ring-red-500" : "", i.className),
828
+ rows: 6
829
+ }), u && /* @__PURE__ */ (0, A.jsx)("p", {
830
+ className: "text-xs text-red-500",
831
+ children: u
832
+ })]
833
+ });
834
+ }
835
+ //#endregion
836
+ //#region src/widgets/VectorField.tsx
837
+ function Oe({ value: e, field: t, ...n }) {
838
+ let r = (t || n.schema)?.dimensions || (Array.isArray(e) ? e.length : 0);
839
+ if (!e || !Array.isArray(e)) return /* @__PURE__ */ (0, A.jsx)("span", {
840
+ className: "text-sm text-gray-500",
841
+ children: "-"
842
+ });
843
+ let i = e.slice(0, 3).map((e) => {
844
+ let t = Number(e);
845
+ return isNaN(t) ? "0" : t.toFixed(4);
846
+ }).join(", ");
847
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
848
+ className: `text-sm ${n.className || ""}`,
849
+ children: [/* @__PURE__ */ (0, A.jsxs)("span", {
850
+ className: "font-mono text-gray-700",
851
+ children: [
852
+ "[",
853
+ i,
854
+ "...]"
855
+ ]
856
+ }), /* @__PURE__ */ (0, A.jsxs)("span", {
857
+ className: "text-gray-500 ml-2",
858
+ children: [
859
+ "(",
860
+ r,
861
+ "D)"
862
+ ]
863
+ })]
864
+ });
865
+ }
866
+ //#endregion
867
+ //#region src/widgets/GridField.tsx
868
+ function ke({ value: e, field: t, readonly: n, ...r }) {
869
+ let i = (t || r.schema)?.columns || [];
870
+ return !e || !Array.isArray(e) ? /* @__PURE__ */ (0, A.jsx)("span", {
871
+ className: "text-sm text-muted-foreground",
872
+ children: "-"
873
+ }) : n ? /* @__PURE__ */ (0, A.jsx)("div", {
874
+ className: T("text-sm", r.className),
875
+ children: /* @__PURE__ */ (0, A.jsxs)("span", {
876
+ className: "text-foreground",
877
+ children: [e.length, " rows"]
878
+ })
879
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
880
+ className: T("border border-border rounded-lg overflow-hidden", r.className),
881
+ children: [/* @__PURE__ */ (0, A.jsx)("div", {
882
+ className: "overflow-auto max-h-60",
883
+ children: /* @__PURE__ */ (0, A.jsxs)("table", {
884
+ className: "w-full text-sm",
885
+ children: [/* @__PURE__ */ (0, A.jsx)("thead", {
886
+ className: "bg-muted border-b border-border",
887
+ children: /* @__PURE__ */ (0, A.jsx)("tr", { children: i.map((e, t) => /* @__PURE__ */ (0, A.jsx)("th", {
888
+ className: "px-3 py-2 text-left text-xs font-medium text-muted-foreground",
889
+ children: e.label || e.name
890
+ }, t)) })
891
+ }), /* @__PURE__ */ (0, A.jsx)("tbody", {
892
+ className: "divide-y divide-border",
893
+ children: e.slice(0, 5).map((e, t) => /* @__PURE__ */ (0, A.jsx)("tr", {
894
+ className: "hover:bg-muted/50 transition-colors",
895
+ children: i.map((t, n) => /* @__PURE__ */ (0, A.jsx)("td", {
896
+ className: "px-3 py-2 text-foreground",
897
+ children: e[t.name] == null ? "-" : String(e[t.name])
898
+ }, n))
899
+ }, t))
900
+ })]
901
+ })
902
+ }), e.length > 5 && /* @__PURE__ */ (0, A.jsxs)("div", {
903
+ className: "bg-muted px-3 py-2 text-xs text-muted-foreground border-t border-border",
904
+ children: [
905
+ "Showing 5 of ",
906
+ e.length,
907
+ " rows"
908
+ ]
909
+ })]
910
+ });
911
+ }
912
+ //#endregion
913
+ //#region src/widgets/ColorField.tsx
914
+ function Ae({ value: e, onChange: t, field: n, readonly: r, ...i }) {
915
+ let a = n || i.schema;
916
+ return r ? /* @__PURE__ */ (0, A.jsxs)("div", {
917
+ className: "flex items-center gap-2",
918
+ children: [/* @__PURE__ */ (0, A.jsx)("div", {
919
+ className: "w-6 h-6 rounded border border-input",
920
+ style: { backgroundColor: e || "#000000" }
921
+ }), /* @__PURE__ */ (0, A.jsx)("span", {
922
+ className: "text-sm",
923
+ children: e || "-"
924
+ })]
925
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
926
+ className: "flex items-center gap-2",
927
+ children: [/* @__PURE__ */ (0, A.jsx)("input", {
928
+ type: "color",
929
+ value: e || "#000000",
930
+ onChange: (e) => t(e.target.value),
931
+ disabled: r || i.disabled,
932
+ className: "w-10 h-10 rounded border border-input cursor-pointer"
933
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
934
+ type: "text",
935
+ value: e || "",
936
+ onChange: (e) => t(e.target.value),
937
+ placeholder: a?.placeholder || "#000000",
938
+ disabled: r || i.disabled,
939
+ className: i.className,
940
+ pattern: "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"
941
+ })]
942
+ });
943
+ }
944
+ //#endregion
945
+ //#region src/widgets/SliderField.tsx
946
+ function je({ value: e, onChange: t, field: n, readonly: r, ...i }) {
947
+ let a = n || i.schema, o = a?.min ?? 0, s = a?.max ?? 100, c = a?.step ?? 1;
948
+ return r ? /* @__PURE__ */ (0, A.jsxs)("div", {
949
+ className: "flex items-center gap-2",
950
+ children: [/* @__PURE__ */ (0, A.jsx)("span", {
951
+ className: "text-sm font-medium",
952
+ children: e ?? o
953
+ }), /* @__PURE__ */ (0, A.jsxs)("span", {
954
+ className: "text-xs text-muted-foreground",
955
+ children: ["/ ", s]
956
+ })]
957
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
958
+ className: "flex items-center gap-4",
959
+ children: [/* @__PURE__ */ (0, A.jsx)(S, {
960
+ value: [e ?? o],
961
+ onValueChange: (e) => t(e[0]),
962
+ min: o,
963
+ max: s,
964
+ step: c,
965
+ disabled: r || i.disabled,
966
+ className: i.className
967
+ }), /* @__PURE__ */ (0, A.jsx)("span", {
968
+ className: "text-sm font-medium w-12 text-right",
969
+ children: e ?? o
970
+ })]
971
+ });
972
+ }
973
+ //#endregion
974
+ //#region src/widgets/RatingField.tsx
975
+ function Me({ value: e, onChange: t, field: n, readonly: r, className: a, ...o }) {
976
+ let s = (n || o.schema)?.max ?? 5, c = e ?? 0, [l, u] = i.useState(null), d = l === null ? c : l;
977
+ return r ? /* @__PURE__ */ (0, A.jsxs)("div", {
978
+ className: T("flex items-center gap-1", a),
979
+ children: [Array.from({ length: s }, (e, t) => /* @__PURE__ */ (0, A.jsx)(pe, { className: `w-5 h-5 ${t < c ? "fill-yellow-400 text-yellow-400" : "text-muted-foreground"}` }, t)), /* @__PURE__ */ (0, A.jsxs)("span", {
980
+ className: "ml-2 text-sm text-muted-foreground",
981
+ children: [
982
+ c,
983
+ " / ",
984
+ s
985
+ ]
986
+ })]
987
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
988
+ className: T("flex items-center gap-1", a),
989
+ children: [Array.from({ length: s }, (e, n) => /* @__PURE__ */ (0, A.jsx)("button", {
990
+ type: "button",
991
+ onClick: () => t(n + 1),
992
+ onMouseEnter: () => u(n + 1),
993
+ onMouseLeave: () => u(null),
994
+ className: "focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 rounded",
995
+ disabled: r || o.disabled,
996
+ children: /* @__PURE__ */ (0, A.jsx)(pe, { className: `w-5 h-5 transition-colors ${n < d ? "fill-yellow-400 text-yellow-400 hover:fill-yellow-500 hover:text-yellow-500" : "text-muted-foreground hover:text-yellow-400"}` })
997
+ }, n)), /* @__PURE__ */ (0, A.jsxs)("span", {
998
+ className: "ml-2 text-sm text-muted-foreground",
999
+ children: [
1000
+ c,
1001
+ " / ",
1002
+ s
1003
+ ]
1004
+ })]
1005
+ });
1006
+ }
1007
+ //#endregion
1008
+ //#region src/widgets/CodeField.tsx
1009
+ function Ne({ value: e, onChange: t, field: n, readonly: r, ...i }) {
1010
+ let a = n || i.schema, o = a?.language ?? "javascript";
1011
+ return r ? /* @__PURE__ */ (0, A.jsx)("pre", {
1012
+ className: T("text-sm bg-muted p-2 rounded overflow-x-auto border", i.className),
1013
+ children: /* @__PURE__ */ (0, A.jsx)("code", { children: e || "-" })
1014
+ }) : /* @__PURE__ */ (0, A.jsx)(w, {
1015
+ value: e || "",
1016
+ onChange: (e) => t(e.target.value),
1017
+ placeholder: a?.placeholder || `// Write ${o} code here...`,
1018
+ disabled: r || i.disabled,
1019
+ className: T("font-mono text-sm", i.className),
1020
+ rows: 12,
1021
+ spellCheck: !1
1022
+ });
1023
+ }
1024
+ //#endregion
1025
+ //#region src/widgets/AvatarField.tsx
1026
+ function Pe({ value: e, onChange: t, field: n, readonly: r, ...a }) {
1027
+ let [o, s] = i.useState(!1), c = i.useRef(null), l = n || a.schema, u = (e) => {
1028
+ let n = e.target.files?.[0];
1029
+ if (!n) return;
1030
+ if (!n.type.startsWith("image/")) {
1031
+ console.error("Please select an image file");
1032
+ return;
1033
+ }
1034
+ if (n.size > 5 * 1024 * 1024) {
1035
+ console.error("File size must be less than 5MB");
1036
+ return;
1037
+ }
1038
+ let r = new FileReader();
1039
+ r.onloadend = () => {
1040
+ t(r.result);
1041
+ }, r.readAsDataURL(n);
1042
+ }, m = () => {
1043
+ t("");
1044
+ }, g = () => (l?.defaultName || l?.label || "User").split(" ").map((e) => e[0]).join("").toUpperCase().slice(0, 2);
1045
+ return r ? /* @__PURE__ */ (0, A.jsxs)(d, {
1046
+ className: "w-16 h-16",
1047
+ children: [e && /* @__PURE__ */ (0, A.jsx)(p, {
1048
+ src: e,
1049
+ alt: l?.label
1050
+ }), /* @__PURE__ */ (0, A.jsx)(f, { children: g() })]
1051
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
1052
+ className: "flex items-center gap-4",
1053
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", {
1054
+ className: "relative",
1055
+ onMouseEnter: () => s(!0),
1056
+ onMouseLeave: () => s(!1),
1057
+ children: [/* @__PURE__ */ (0, A.jsxs)(d, {
1058
+ className: "w-16 h-16",
1059
+ children: [e && /* @__PURE__ */ (0, A.jsx)(p, {
1060
+ src: e,
1061
+ alt: l?.label
1062
+ }), /* @__PURE__ */ (0, A.jsx)(f, { children: g() })]
1063
+ }), !r && o && e && /* @__PURE__ */ (0, A.jsx)("button", {
1064
+ type: "button",
1065
+ onClick: m,
1066
+ className: "absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90",
1067
+ children: /* @__PURE__ */ (0, A.jsx)(k, { className: "w-3 h-3" })
1068
+ })]
1069
+ }), /* @__PURE__ */ (0, A.jsxs)("div", {
1070
+ className: "flex flex-col gap-2",
1071
+ children: [
1072
+ /* @__PURE__ */ (0, A.jsx)("input", {
1073
+ ref: c,
1074
+ type: "file",
1075
+ accept: "image/*",
1076
+ onChange: u,
1077
+ className: "hidden"
1078
+ }),
1079
+ /* @__PURE__ */ (0, A.jsxs)(h, {
1080
+ type: "button",
1081
+ variant: "outline",
1082
+ size: "sm",
1083
+ onClick: () => c.current?.click(),
1084
+ disabled: r || a.disabled,
1085
+ children: [
1086
+ /* @__PURE__ */ (0, A.jsx)(me, { className: "w-4 h-4 mr-2" }),
1087
+ e ? "Change" : "Upload",
1088
+ " Avatar"
1089
+ ]
1090
+ }),
1091
+ /* @__PURE__ */ (0, A.jsx)("p", {
1092
+ className: "text-xs text-muted-foreground",
1093
+ children: "PNG, JPG up to 5MB"
1094
+ })
1095
+ ]
1096
+ })]
1097
+ });
1098
+ }
1099
+ //#endregion
1100
+ //#region src/widgets/AddressField.tsx
1101
+ function Fe({ value: e, onChange: t, field: n, readonly: r, ...i }) {
1102
+ let a = e || {}, o = (e, n) => {
1103
+ t({
1104
+ ...a,
1105
+ [e]: n
1106
+ });
1107
+ };
1108
+ return r ? /* @__PURE__ */ (0, A.jsx)("span", {
1109
+ className: "text-sm",
1110
+ children: ((e) => [
1111
+ e.street,
1112
+ e.city,
1113
+ [e.state, e.zipCode].filter(Boolean).join(" "),
1114
+ e.country
1115
+ ].filter(Boolean).join(", ") || "-")(a)
1116
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
1117
+ className: "space-y-3",
1118
+ children: [
1119
+ /* @__PURE__ */ (0, A.jsxs)("div", { children: [/* @__PURE__ */ (0, A.jsx)(v, {
1120
+ htmlFor: "street",
1121
+ className: "text-xs",
1122
+ children: "Street Address"
1123
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
1124
+ id: "street",
1125
+ type: "text",
1126
+ value: a.street || "",
1127
+ onChange: (e) => o("street", e.target.value),
1128
+ placeholder: "123 Main St",
1129
+ disabled: r || i.disabled,
1130
+ className: i.className
1131
+ })] }),
1132
+ /* @__PURE__ */ (0, A.jsxs)("div", {
1133
+ className: "grid grid-cols-2 gap-3",
1134
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", { children: [/* @__PURE__ */ (0, A.jsx)(v, {
1135
+ htmlFor: "city",
1136
+ className: "text-xs",
1137
+ children: "City"
1138
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
1139
+ id: "city",
1140
+ type: "text",
1141
+ value: a.city || "",
1142
+ onChange: (e) => o("city", e.target.value),
1143
+ placeholder: "San Francisco",
1144
+ disabled: r || i.disabled
1145
+ })] }), /* @__PURE__ */ (0, A.jsxs)("div", { children: [/* @__PURE__ */ (0, A.jsx)(v, {
1146
+ htmlFor: "state",
1147
+ className: "text-xs",
1148
+ children: "State / Province"
1149
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
1150
+ id: "state",
1151
+ type: "text",
1152
+ value: a.state || "",
1153
+ onChange: (e) => o("state", e.target.value),
1154
+ placeholder: "CA",
1155
+ disabled: r || i.disabled
1156
+ })] })]
1157
+ }),
1158
+ /* @__PURE__ */ (0, A.jsxs)("div", {
1159
+ className: "grid grid-cols-2 gap-3",
1160
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", { children: [/* @__PURE__ */ (0, A.jsx)(v, {
1161
+ htmlFor: "zipCode",
1162
+ className: "text-xs",
1163
+ children: "ZIP / Postal Code"
1164
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
1165
+ id: "zipCode",
1166
+ type: "text",
1167
+ value: a.zipCode || "",
1168
+ onChange: (e) => o("zipCode", e.target.value),
1169
+ placeholder: "94102",
1170
+ disabled: r || i.disabled
1171
+ })] }), /* @__PURE__ */ (0, A.jsxs)("div", { children: [/* @__PURE__ */ (0, A.jsx)(v, {
1172
+ htmlFor: "country",
1173
+ className: "text-xs",
1174
+ children: "Country"
1175
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
1176
+ id: "country",
1177
+ type: "text",
1178
+ value: a.country || "",
1179
+ onChange: (e) => o("country", e.target.value),
1180
+ placeholder: "United States",
1181
+ disabled: r || i.disabled
1182
+ })] })]
1183
+ })
1184
+ ]
1185
+ });
1186
+ }
1187
+ //#endregion
1188
+ //#region src/widgets/GeolocationField.tsx
1189
+ function Ie({ value: e, onChange: t, field: n, readonly: r, ...a }) {
1190
+ let [o, s] = i.useState(!1), c = e || {}, l = (e, n) => {
1191
+ t({
1192
+ ...c,
1193
+ [e]: n ? Number(n) : void 0
1194
+ });
1195
+ }, u = () => {
1196
+ if (!navigator.geolocation) {
1197
+ console.error("Geolocation is not supported by this browser");
1198
+ return;
1199
+ }
1200
+ s(!0), navigator.geolocation.getCurrentPosition((e) => {
1201
+ t({
1202
+ latitude: e.coords.latitude,
1203
+ longitude: e.coords.longitude,
1204
+ accuracy: e.coords.accuracy
1205
+ }), s(!1);
1206
+ }, (e) => {
1207
+ console.error("Error getting location:", e.message), s(!1);
1208
+ }, {
1209
+ enableHighAccuracy: !0,
1210
+ timeout: 5e3,
1211
+ maximumAge: 0
1212
+ });
1213
+ }, d = (e) => !e.latitude || !e.longitude ? "-" : `${e.latitude.toFixed(6)}, ${e.longitude.toFixed(6)}`, f = () => {
1214
+ if (!c.latitude || !c.longitude) return;
1215
+ let e = `https://www.google.com/maps?q=${c.latitude},${c.longitude}`;
1216
+ window.open(e, "_blank");
1217
+ };
1218
+ return r ? /* @__PURE__ */ (0, A.jsxs)("div", {
1219
+ className: "flex items-center gap-2",
1220
+ children: [
1221
+ /* @__PURE__ */ (0, A.jsx)(O, { className: "w-4 h-4 text-muted-foreground" }),
1222
+ /* @__PURE__ */ (0, A.jsx)("span", {
1223
+ className: "text-sm",
1224
+ children: d(c)
1225
+ }),
1226
+ c.latitude && c.longitude && /* @__PURE__ */ (0, A.jsx)(h, {
1227
+ type: "button",
1228
+ variant: "link",
1229
+ size: "sm",
1230
+ onClick: f,
1231
+ className: "p-0 h-auto",
1232
+ children: "View on map"
1233
+ })
1234
+ ]
1235
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
1236
+ className: "space-y-3",
1237
+ children: [
1238
+ /* @__PURE__ */ (0, A.jsxs)("div", {
1239
+ className: "flex items-center gap-2",
1240
+ children: [/* @__PURE__ */ (0, A.jsxs)(h, {
1241
+ type: "button",
1242
+ variant: "outline",
1243
+ size: "sm",
1244
+ onClick: u,
1245
+ disabled: r || o,
1246
+ children: [/* @__PURE__ */ (0, A.jsx)(ne, { className: "w-4 h-4 mr-2" }), o ? "Getting location..." : "Use Current Location"]
1247
+ }), c.latitude && c.longitude && /* @__PURE__ */ (0, A.jsxs)(h, {
1248
+ type: "button",
1249
+ variant: "link",
1250
+ size: "sm",
1251
+ onClick: f,
1252
+ children: [/* @__PURE__ */ (0, A.jsx)(O, { className: "w-4 h-4 mr-2" }), "View on map"]
1253
+ })]
1254
+ }),
1255
+ /* @__PURE__ */ (0, A.jsxs)("div", {
1256
+ className: "grid grid-cols-2 gap-3",
1257
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", { children: [/* @__PURE__ */ (0, A.jsx)(v, {
1258
+ htmlFor: "latitude",
1259
+ className: "text-xs",
1260
+ children: "Latitude"
1261
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
1262
+ id: "latitude",
1263
+ type: "number",
1264
+ value: c.latitude ?? "",
1265
+ onChange: (e) => l("latitude", e.target.value),
1266
+ placeholder: "37.7749",
1267
+ disabled: r || a.disabled,
1268
+ step: "any",
1269
+ className: a.className
1270
+ })] }), /* @__PURE__ */ (0, A.jsxs)("div", { children: [/* @__PURE__ */ (0, A.jsx)(v, {
1271
+ htmlFor: "longitude",
1272
+ className: "text-xs",
1273
+ children: "Longitude"
1274
+ }), /* @__PURE__ */ (0, A.jsx)(_, {
1275
+ id: "longitude",
1276
+ type: "number",
1277
+ value: c.longitude ?? "",
1278
+ onChange: (e) => l("longitude", e.target.value),
1279
+ placeholder: "-122.4194",
1280
+ disabled: r || a.disabled,
1281
+ step: "any"
1282
+ })] })]
1283
+ }),
1284
+ c.accuracy && /* @__PURE__ */ (0, A.jsxs)("p", {
1285
+ className: "text-xs text-muted-foreground",
1286
+ children: [
1287
+ "Accuracy: ±",
1288
+ c.accuracy.toFixed(0),
1289
+ "m"
1290
+ ]
1291
+ })
1292
+ ]
1293
+ });
1294
+ }
1295
+ //#endregion
1296
+ //#region src/widgets/SignatureField.tsx
1297
+ function Le({ value: e, onChange: t, readonly: n }) {
1298
+ let r = c(null), [a, s] = i.useState(!1), [l, u] = i.useState(!e);
1299
+ o(() => {
1300
+ if (e && r.current) {
1301
+ let t = r.current.getContext("2d");
1302
+ if (t) {
1303
+ let n = new Image();
1304
+ n.onload = () => {
1305
+ t.drawImage(n, 0, 0), u(!1);
1306
+ }, n.src = e;
1307
+ }
1308
+ }
1309
+ }, [e]);
1310
+ let d = (e) => {
1311
+ if (n) return;
1312
+ s(!0), u(!1);
1313
+ let t = r.current;
1314
+ if (!t) return;
1315
+ let i = t.getContext("2d");
1316
+ if (!i) return;
1317
+ let a = t.getBoundingClientRect(), o = "touches" in e ? e.touches[0].clientX - a.left : e.clientX - a.left, c = "touches" in e ? e.touches[0].clientY - a.top : e.clientY - a.top;
1318
+ i.beginPath(), i.moveTo(o, c);
1319
+ }, f = (e) => {
1320
+ if (!a || n) return;
1321
+ let t = r.current;
1322
+ if (!t) return;
1323
+ let i = t.getContext("2d");
1324
+ if (!i) return;
1325
+ let o = t.getBoundingClientRect(), s = "touches" in e ? e.touches[0].clientX - o.left : e.clientX - o.left, c = "touches" in e ? e.touches[0].clientY - o.top : e.clientY - o.top;
1326
+ i.lineTo(s, c), i.strokeStyle = "#000", i.lineWidth = 2, i.lineCap = "round", i.lineJoin = "round", i.stroke();
1327
+ }, p = () => {
1328
+ if (!a) return;
1329
+ s(!1);
1330
+ let e = r.current;
1331
+ e && t(e.toDataURL("image/png"));
1332
+ };
1333
+ return n && e ? /* @__PURE__ */ (0, A.jsx)("div", {
1334
+ className: "border rounded p-2 bg-white",
1335
+ children: /* @__PURE__ */ (0, A.jsx)("img", {
1336
+ src: e,
1337
+ alt: "Signature",
1338
+ loading: "lazy",
1339
+ className: "max-w-full h-auto"
1340
+ })
1341
+ }) : n && !e ? /* @__PURE__ */ (0, A.jsx)("span", {
1342
+ className: "text-sm text-muted-foreground",
1343
+ children: "No signature"
1344
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
1345
+ className: "space-y-2",
1346
+ children: [/* @__PURE__ */ (0, A.jsx)("div", {
1347
+ className: "border rounded bg-white",
1348
+ children: /* @__PURE__ */ (0, A.jsx)("canvas", {
1349
+ ref: r,
1350
+ width: 400,
1351
+ height: 200,
1352
+ className: "w-full touch-none cursor-crosshair",
1353
+ onMouseDown: d,
1354
+ onMouseMove: f,
1355
+ onMouseUp: p,
1356
+ onMouseLeave: p,
1357
+ onTouchStart: d,
1358
+ onTouchMove: f,
1359
+ onTouchEnd: p
1360
+ })
1361
+ }), /* @__PURE__ */ (0, A.jsxs)("div", {
1362
+ className: "flex justify-between items-center",
1363
+ children: [/* @__PURE__ */ (0, A.jsx)("p", {
1364
+ className: "text-xs text-muted-foreground",
1365
+ children: l ? "Sign above" : "Signature captured"
1366
+ }), /* @__PURE__ */ (0, A.jsxs)(h, {
1367
+ type: "button",
1368
+ variant: "outline",
1369
+ size: "sm",
1370
+ onClick: () => {
1371
+ let e = r.current;
1372
+ if (!e) return;
1373
+ let n = e.getContext("2d");
1374
+ n && (n.clearRect(0, 0, e.width, e.height), u(!0), t(""));
1375
+ },
1376
+ disabled: n || l,
1377
+ children: [/* @__PURE__ */ (0, A.jsx)(re, { className: "w-4 h-4 mr-2" }), "Clear"]
1378
+ })]
1379
+ })]
1380
+ });
1381
+ }
1382
+ //#endregion
1383
+ //#region src/widgets/QRCodeField.tsx
1384
+ function Re({ value: e, onChange: t, field: n, readonly: r, ...a }) {
1385
+ let [o, s] = i.useState(!1), c = n || a.schema;
1386
+ return r ? /* @__PURE__ */ (0, A.jsxs)("div", {
1387
+ className: "flex items-center gap-3",
1388
+ children: [/* @__PURE__ */ (0, A.jsx)("span", {
1389
+ className: "text-sm flex-1 truncate",
1390
+ children: e || "-"
1391
+ }), e && /* @__PURE__ */ (0, A.jsxs)(h, {
1392
+ type: "button",
1393
+ variant: "outline",
1394
+ size: "sm",
1395
+ onClick: () => s(!o),
1396
+ children: [
1397
+ /* @__PURE__ */ (0, A.jsx)(fe, { className: "w-4 h-4 mr-2" }),
1398
+ o ? "Hide" : "Show",
1399
+ " QR"
1400
+ ]
1401
+ })]
1402
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
1403
+ className: "space-y-3",
1404
+ children: [
1405
+ /* @__PURE__ */ (0, A.jsxs)("div", {
1406
+ className: "flex items-center gap-2",
1407
+ children: [/* @__PURE__ */ (0, A.jsx)(_, {
1408
+ type: "text",
1409
+ value: e || "",
1410
+ onChange: (e) => t(e.target.value),
1411
+ placeholder: c?.placeholder || "Enter text for QR code",
1412
+ disabled: r || a.disabled,
1413
+ className: a.className
1414
+ }), e && /* @__PURE__ */ (0, A.jsxs)(A.Fragment, { children: [/* @__PURE__ */ (0, A.jsx)(h, {
1415
+ type: "button",
1416
+ variant: "outline",
1417
+ size: "sm",
1418
+ onClick: () => {
1419
+ e && navigator.clipboard.writeText(e);
1420
+ },
1421
+ children: /* @__PURE__ */ (0, A.jsx)(D, { className: "w-4 h-4" })
1422
+ }), /* @__PURE__ */ (0, A.jsx)(h, {
1423
+ type: "button",
1424
+ variant: "outline",
1425
+ size: "sm",
1426
+ onClick: () => s(!o),
1427
+ children: /* @__PURE__ */ (0, A.jsx)(fe, { className: "w-4 h-4" })
1428
+ })] })]
1429
+ }),
1430
+ o && e && /* @__PURE__ */ (0, A.jsx)("div", {
1431
+ className: "border rounded p-4 bg-white flex justify-center",
1432
+ children: /* @__PURE__ */ (0, A.jsx)("img", {
1433
+ src: ((e) => `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(e)}`)(e),
1434
+ alt: "QR Code",
1435
+ className: "w-48 h-48"
1436
+ })
1437
+ }),
1438
+ e && /* @__PURE__ */ (0, A.jsxs)("p", {
1439
+ className: "text-xs text-muted-foreground",
1440
+ children: [
1441
+ "QR code contains: ",
1442
+ e.length,
1443
+ " characters"
1444
+ ]
1445
+ })
1446
+ ]
1447
+ });
1448
+ }
1449
+ //#endregion
1450
+ //#region src/widgets/MasterDetailField.tsx
1451
+ function ze({ value: e, onChange: t, field: n, readonly: r, className: i, ...a }) {
1452
+ let o = e || [], s = n || a.schema, c = () => {
1453
+ let e = {
1454
+ id: `new-${Date.now()}`,
1455
+ label: "New Related Record"
1456
+ };
1457
+ t([...o, e]);
1458
+ }, l = (e) => {
1459
+ t(o.filter((t) => t.id !== e));
1460
+ }, u = (e) => {
1461
+ console.log("View detail:", e);
1462
+ };
1463
+ return r ? /* @__PURE__ */ (0, A.jsxs)("div", {
1464
+ className: T("space-y-2", i),
1465
+ children: [o.length === 0 ? /* @__PURE__ */ (0, A.jsx)("span", {
1466
+ className: "text-sm text-muted-foreground",
1467
+ children: "No related records"
1468
+ }) : o.map((e) => /* @__PURE__ */ (0, A.jsxs)("div", {
1469
+ className: "flex items-center justify-between p-2 border rounded hover:bg-muted/50",
1470
+ children: [/* @__PURE__ */ (0, A.jsx)("span", {
1471
+ className: "text-sm",
1472
+ children: e.label
1473
+ }), /* @__PURE__ */ (0, A.jsx)(h, {
1474
+ type: "button",
1475
+ variant: "ghost",
1476
+ size: "sm",
1477
+ onClick: () => u(e),
1478
+ children: /* @__PURE__ */ (0, A.jsx)(ie, { className: "w-4 h-4" })
1479
+ })]
1480
+ }, e.id)), /* @__PURE__ */ (0, A.jsxs)("p", {
1481
+ className: "text-xs text-muted-foreground",
1482
+ children: [
1483
+ o.length,
1484
+ " ",
1485
+ o.length === 1 ? "record" : "records"
1486
+ ]
1487
+ })]
1488
+ }) : /* @__PURE__ */ (0, A.jsxs)("div", {
1489
+ className: T("space-y-3", i),
1490
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", {
1491
+ className: "space-y-2",
1492
+ children: [o.map((e) => /* @__PURE__ */ (0, A.jsxs)("div", {
1493
+ className: "flex items-center justify-between gap-2 p-2 border rounded hover:bg-muted/50",
1494
+ children: [/* @__PURE__ */ (0, A.jsxs)("div", {
1495
+ className: "flex items-center gap-2 flex-1",
1496
+ children: [/* @__PURE__ */ (0, A.jsx)(m, {
1497
+ variant: "outline",
1498
+ children: e.id
1499
+ }), /* @__PURE__ */ (0, A.jsx)("span", {
1500
+ className: "text-sm flex-1",
1501
+ children: e.label
1502
+ })]
1503
+ }), /* @__PURE__ */ (0, A.jsxs)("div", {
1504
+ className: "flex items-center gap-1",
1505
+ children: [/* @__PURE__ */ (0, A.jsx)(h, {
1506
+ type: "button",
1507
+ variant: "ghost",
1508
+ size: "sm",
1509
+ onClick: () => u(e),
1510
+ children: /* @__PURE__ */ (0, A.jsx)(ie, { className: "w-4 h-4" })
1511
+ }), /* @__PURE__ */ (0, A.jsx)(h, {
1512
+ type: "button",
1513
+ variant: "ghost",
1514
+ size: "sm",
1515
+ onClick: () => l(e.id),
1516
+ disabled: a.disabled,
1517
+ children: /* @__PURE__ */ (0, A.jsx)(k, { className: "w-4 h-4" })
1518
+ })]
1519
+ })]
1520
+ }, e.id)), o.length === 0 && /* @__PURE__ */ (0, A.jsx)("div", {
1521
+ className: "text-sm text-muted-foreground text-center py-4 border border-dashed rounded bg-muted/20",
1522
+ children: "No related records"
1523
+ })]
1524
+ }), /* @__PURE__ */ (0, A.jsxs)(h, {
1525
+ type: "button",
1526
+ variant: "outline",
1527
+ className: "w-full",
1528
+ onClick: c,
1529
+ disabled: a.disabled,
1530
+ children: [
1531
+ /* @__PURE__ */ (0, A.jsx)(de, { className: "w-4 h-4 mr-2" }),
1532
+ "Add ",
1533
+ s?.label || "Record"
1534
+ ]
1535
+ })]
1536
+ });
1537
+ }
1538
+ //#endregion
1539
+ //#region src/index.tsx
1540
+ function H(e) {
1541
+ if (e == null || typeof e == "string" || typeof e == "number" || typeof e == "boolean") return e;
1542
+ if (e instanceof Date) return e.toISOString();
1543
+ if (Array.isArray(e)) return e.map((e) => {
1544
+ if (typeof e == "object" && e) {
1545
+ let t = e;
1546
+ return String(t.name || t.label || t.id || t._id || "[Object]");
1547
+ }
1548
+ return String(e);
1549
+ }).join(", ");
1550
+ if (typeof e == "object") {
1551
+ let t = e;
1552
+ return "$numberDecimal" in t ? Number(t.$numberDecimal) : "$oid" in t ? String(t.$oid) : "$date" in t ? String(t.$date) : String(t.name || t.label || t.id || t._id || "[Object]");
1553
+ }
1554
+ return String(e);
1555
+ }
1556
+ function Be(e, t = "USD") {
1557
+ try {
1558
+ return new Intl.NumberFormat("en-US", {
1559
+ style: "currency",
1560
+ currency: t
1561
+ }).format(e);
1562
+ } catch {
1563
+ return `${t} ${e.toFixed(2)}`;
1564
+ }
1565
+ }
1566
+ function Ve(e, t = "USD") {
1567
+ try {
1568
+ return new Intl.NumberFormat("en-US", {
1569
+ style: "currency",
1570
+ currency: t,
1571
+ notation: "compact",
1572
+ maximumFractionDigits: 1
1573
+ }).format(e).replace(/\.0(?=[KMBT])/, "");
1574
+ } catch {
1575
+ return `${t} ${e}`;
1576
+ }
1577
+ }
1578
+ function He(e, t = 0) {
1579
+ return `${(e > -1 && e < 1 ? e * 100 : e).toFixed(t)}%`;
1580
+ }
1581
+ function U(e) {
1582
+ return e.replace(/[_-]/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
1583
+ }
1584
+ function Ue(e) {
1585
+ if (!e) return "-";
1586
+ let t = typeof e == "string" ? new Date(e) : e;
1587
+ if (isNaN(t.getTime())) return "-";
1588
+ let n = /* @__PURE__ */ new Date(), r = new Date(n.getFullYear(), n.getMonth(), n.getDate()), i = new Date(t.getFullYear(), t.getMonth(), t.getDate()).getTime() - r.getTime(), a = Math.round(i / (1e3 * 60 * 60 * 24));
1589
+ if (a === 0) return "Today";
1590
+ if (a === 1) return "Tomorrow";
1591
+ if (a === -1) return "Yesterday";
1592
+ if (a < -1) {
1593
+ let e = Math.abs(a);
1594
+ return e <= 7 ? `Overdue ${e}d` : W(t);
1595
+ }
1596
+ return a > 1 && a <= 7 ? `In ${a} days` : W(t);
1597
+ }
1598
+ function W(e, t) {
1599
+ if (!e) return "-";
1600
+ let n = typeof e == "string" ? new Date(e) : e;
1601
+ return isNaN(n.getTime()) ? "-" : t === "short" ? `${n.toLocaleDateString("en-US", { month: "short" })} ${n.getDate()}, '${String(n.getFullYear()).slice(-2)}` : t === "relative" ? Ue(n) : n.toLocaleDateString(void 0, {
1602
+ year: "numeric",
1603
+ month: "short",
1604
+ day: "numeric"
1605
+ });
1606
+ }
1607
+ function We(e) {
1608
+ if (!e) return "-";
1609
+ let t = typeof e == "string" ? new Date(e) : e;
1610
+ return isNaN(t.getTime()) ? "-" : t.toLocaleDateString(void 0, {
1611
+ year: "numeric",
1612
+ month: "short",
1613
+ day: "numeric",
1614
+ hour: "2-digit",
1615
+ minute: "2-digit"
1616
+ });
1617
+ }
1618
+ function G({ value: e }) {
1619
+ let t = H(e);
1620
+ return /* @__PURE__ */ (0, A.jsx)("span", {
1621
+ className: "truncate",
1622
+ children: t != null && t !== "" ? String(t) : "-"
1623
+ });
1624
+ }
1625
+ function Ge({ value: e, field: t }) {
1626
+ if (e == null) return /* @__PURE__ */ (0, A.jsx)("span", {
1627
+ className: "text-muted-foreground",
1628
+ children: "-"
1629
+ });
1630
+ let n = H(e), r = t.precision ?? 0, i = Number(n);
1631
+ return /* @__PURE__ */ (0, A.jsx)("span", {
1632
+ className: "tabular-nums",
1633
+ children: isNaN(i) ? String(n) : new Intl.NumberFormat("en-US", {
1634
+ minimumFractionDigits: r,
1635
+ maximumFractionDigits: r
1636
+ }).format(i)
1637
+ });
1638
+ }
1639
+ function Ke({ value: e, field: t }) {
1640
+ if (e == null) return /* @__PURE__ */ (0, A.jsx)("span", {
1641
+ className: "text-muted-foreground",
1642
+ children: "-"
1643
+ });
1644
+ let n = H(e), r = t.currency || "USD", i = Number(n);
1645
+ return /* @__PURE__ */ (0, A.jsx)("span", {
1646
+ className: "tabular-nums font-medium whitespace-nowrap",
1647
+ children: isNaN(i) ? String(n) : Be(i, r)
1648
+ });
1649
+ }
1650
+ var qe = /progress|completion/;
1651
+ function Je({ value: e, field: t }) {
1652
+ if (e == null) return /* @__PURE__ */ (0, A.jsx)("span", {
1653
+ className: "text-muted-foreground",
1654
+ children: "-"
1655
+ });
1656
+ let n = H(e), r = t.precision ?? 0, i = Number(n);
1657
+ if (isNaN(i)) return /* @__PURE__ */ (0, A.jsx)("span", {
1658
+ className: "tabular-nums whitespace-nowrap",
1659
+ children: String(n)
1660
+ });
1661
+ let a = qe.test(t?.name?.toLowerCase() || ""), o = a ? i : i > -1 && i < 1 ? i * 100 : i, s = a ? `${i.toFixed(r)}%` : He(i, r), c = Math.max(0, Math.min(100, o));
1662
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
1663
+ className: "flex items-center gap-2",
1664
+ children: [/* @__PURE__ */ (0, A.jsx)("div", {
1665
+ className: "h-1.5 w-16 rounded-full bg-muted overflow-hidden flex-shrink-0",
1666
+ role: "progressbar",
1667
+ "aria-valuenow": c,
1668
+ "aria-valuemin": 0,
1669
+ "aria-valuemax": 100,
1670
+ children: /* @__PURE__ */ (0, A.jsx)("div", {
1671
+ className: "h-full rounded-full bg-primary transition-all",
1672
+ style: { width: `${c}%` }
1673
+ })
1674
+ }), /* @__PURE__ */ (0, A.jsx)("span", {
1675
+ className: "tabular-nums whitespace-nowrap",
1676
+ children: s
1677
+ })]
1678
+ });
1679
+ }
1680
+ var Ye = new Set([
1681
+ "active",
1682
+ "is_active",
1683
+ "enabled",
1684
+ "is_enabled",
1685
+ "verified",
1686
+ "is_verified"
2068
1687
  ]);
2069
- function Er({ value: e, field: r }) {
2070
- if (e == null)
2071
- return /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground/50 text-xs italic flex items-center justify-center", children: "—" });
2072
- const n = r?.name?.toLowerCase() || "";
2073
- return n === "completed" || n === "is_completed" || n === "done" || n === "is_done" ? /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center", children: e ? /* @__PURE__ */ t.jsx("div", { className: "size-5 rounded-full bg-green-500 flex items-center justify-center", role: "img", "aria-label": "Completed", "data-testid": "completion-indicator", children: /* @__PURE__ */ t.jsx(he, { className: "size-3 text-white" }) }) : /* @__PURE__ */ t.jsx("div", { className: "size-5 rounded-full border-2 border-muted-foreground/30", role: "img", "aria-label": "Not completed", "data-testid": "completion-indicator" }) }) : zr.has(n) && !e ? /* @__PURE__ */ t.jsxs(M, { variant: "destructive", className: "text-xs", "data-testid": "boolean-warning-badge", children: [
2074
- r?.label || ue(n),
2075
- " — Off"
2076
- ] }) : /* @__PURE__ */ t.jsx("div", { className: "flex items-center justify-center", children: /* @__PURE__ */ t.jsx(Ee, { checked: !!e, disabled: !0, className: "pointer-events-none" }) });
2077
- }
2078
- function Dr({ value: e, field: r }) {
2079
- if (!e) return /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: "-" });
2080
- const a = r.format || "relative", s = me(e, a), i = typeof e == "string" ? new Date(e) : e, l = i instanceof Date && !isNaN(i.getTime()), o = /* @__PURE__ */ new Date();
2081
- o.setHours(0, 0, 0, 0);
2082
- const c = l && i < o, m = l ? i.toISOString() : String(e);
2083
- return /* @__PURE__ */ t.jsx(
2084
- "span",
2085
- {
2086
- className: `tabular-nums${c ? " text-red-600" : ""}`,
2087
- title: m,
2088
- children: s
2089
- }
2090
- );
2091
- }
2092
- function Mr({ value: e }) {
2093
- if (!e) return /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: "-" });
2094
- const r = typeof e == "string" ? new Date(e) : e;
2095
- if (isNaN(r.getTime())) return /* @__PURE__ */ t.jsx("span", { className: "text-muted-foreground", children: "-" });
2096
- const n = r.toLocaleDateString(void 0, {
2097
- month: "numeric",
2098
- day: "numeric",
2099
- year: "numeric"
2100
- }), a = r.toLocaleTimeString(void 0, {
2101
- hour: "numeric",
2102
- minute: "2-digit",
2103
- hour12: !0
2104
- }).toLowerCase();
2105
- return /* @__PURE__ */ t.jsxs("span", { className: "tabular-nums text-sm whitespace-nowrap", children: [
2106
- /* @__PURE__ */ t.jsx("span", { children: n }),
2107
- /* @__PURE__ */ t.jsx("span", { className: "ml-2 text-muted-foreground", children: a })
2108
- ] });
2109
- }
2110
- const Lr = {
2111
- // Priority values
2112
- critical: "red",
2113
- urgent: "red",
2114
- high: "orange",
2115
- medium: "yellow",
2116
- normal: "blue",
2117
- low: "gray",
2118
- none: "gray",
2119
- // Status values
2120
- paid: "green",
2121
- completed: "green",
2122
- done: "green",
2123
- active: "green",
2124
- approved: "green",
2125
- resolved: "green",
2126
- pending: "yellow",
2127
- waiting: "yellow",
2128
- on_hold: "yellow",
2129
- shipped: "blue",
2130
- in_progress: "blue",
2131
- open: "blue",
2132
- processing: "blue",
2133
- draft: "gray",
2134
- new: "gray",
2135
- inactive: "gray",
2136
- closed: "gray",
2137
- cancelled: "red",
2138
- canceled: "red",
2139
- rejected: "red",
2140
- failed: "red",
2141
- overdue: "red",
2142
- delivered: "purple",
2143
- archived: "indigo"
2144
- }, Ir = {
2145
- gray: "bg-gray-100 text-gray-800 border-gray-300",
2146
- red: "bg-red-100 text-red-800 border-red-300",
2147
- orange: "bg-orange-100 text-orange-800 border-orange-300",
2148
- yellow: "bg-yellow-100 text-yellow-800 border-yellow-300",
2149
- green: "bg-green-100 text-green-800 border-green-300",
2150
- blue: "bg-blue-100 text-blue-800 border-blue-300",
2151
- indigo: "bg-indigo-100 text-indigo-800 border-indigo-300",
2152
- purple: "bg-purple-100 text-purple-800 border-purple-300",
2153
- pink: "bg-pink-100 text-pink-800 border-pink-300"
1688
+ function Xe({ value: e, field: t }) {
1689
+ if (e == null) return /* @__PURE__ */ (0, A.jsx)("span", {
1690
+ className: "text-muted-foreground/50 text-xs italic flex items-center justify-center",
1691
+ children: "—"
1692
+ });
1693
+ let n = t?.name?.toLowerCase() || "";
1694
+ return n === "completed" || n === "is_completed" || n === "done" || n === "is_done" ? /* @__PURE__ */ (0, A.jsx)("div", {
1695
+ className: "flex items-center justify-center",
1696
+ children: e ? /* @__PURE__ */ (0, A.jsx)("div", {
1697
+ className: "size-5 rounded-full bg-green-500 flex items-center justify-center",
1698
+ role: "img",
1699
+ "aria-label": "Completed",
1700
+ "data-testid": "completion-indicator",
1701
+ children: /* @__PURE__ */ (0, A.jsx)(E, { className: "size-3 text-white" })
1702
+ }) : /* @__PURE__ */ (0, A.jsx)("div", {
1703
+ className: "size-5 rounded-full border-2 border-muted-foreground/30",
1704
+ role: "img",
1705
+ "aria-label": "Not completed",
1706
+ "data-testid": "completion-indicator"
1707
+ })
1708
+ }) : Ye.has(n) && !e ? /* @__PURE__ */ (0, A.jsxs)(m, {
1709
+ variant: "destructive",
1710
+ className: "text-xs",
1711
+ "data-testid": "boolean-warning-badge",
1712
+ children: [t?.label || U(n), " — Off"]
1713
+ }) : /* @__PURE__ */ (0, A.jsx)("div", {
1714
+ className: "flex items-center justify-center",
1715
+ children: /* @__PURE__ */ (0, A.jsx)(g, {
1716
+ checked: !!e,
1717
+ disabled: !0,
1718
+ className: "pointer-events-none"
1719
+ })
1720
+ });
1721
+ }
1722
+ function Ze({ value: e, field: t }) {
1723
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", {
1724
+ className: "text-muted-foreground",
1725
+ children: "-"
1726
+ });
1727
+ let n = H(e), r = W(n, t.format || "relative"), i = typeof n == "string" ? new Date(n) : n, a = i instanceof Date && !isNaN(i.getTime()), o = /* @__PURE__ */ new Date();
1728
+ o.setHours(0, 0, 0, 0);
1729
+ let s = a && i < o, c = a ? i.toISOString() : String(n);
1730
+ return /* @__PURE__ */ (0, A.jsx)("span", {
1731
+ className: `tabular-nums${s ? " text-red-600" : ""}`,
1732
+ title: c,
1733
+ children: r
1734
+ });
1735
+ }
1736
+ function Qe({ value: e }) {
1737
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", {
1738
+ className: "text-muted-foreground",
1739
+ children: "-"
1740
+ });
1741
+ let t = H(e), n = typeof t == "string" ? new Date(t) : t;
1742
+ if (!(n instanceof Date) || isNaN(n.getTime())) return /* @__PURE__ */ (0, A.jsx)("span", {
1743
+ className: "text-muted-foreground",
1744
+ children: "-"
1745
+ });
1746
+ let r = n.toLocaleDateString(void 0, {
1747
+ month: "numeric",
1748
+ day: "numeric",
1749
+ year: "numeric"
1750
+ }), i = n.toLocaleTimeString(void 0, {
1751
+ hour: "numeric",
1752
+ minute: "2-digit",
1753
+ hour12: !0
1754
+ }).toLowerCase();
1755
+ return /* @__PURE__ */ (0, A.jsxs)("span", {
1756
+ className: "tabular-nums text-sm whitespace-nowrap",
1757
+ children: [/* @__PURE__ */ (0, A.jsx)("span", { children: r }), /* @__PURE__ */ (0, A.jsx)("span", {
1758
+ className: "ml-2 text-muted-foreground",
1759
+ children: i
1760
+ })]
1761
+ });
1762
+ }
1763
+ var $e = {
1764
+ critical: "red",
1765
+ urgent: "red",
1766
+ high: "orange",
1767
+ medium: "yellow",
1768
+ normal: "blue",
1769
+ low: "gray",
1770
+ none: "gray",
1771
+ paid: "green",
1772
+ completed: "green",
1773
+ done: "green",
1774
+ active: "green",
1775
+ approved: "green",
1776
+ resolved: "green",
1777
+ pending: "yellow",
1778
+ waiting: "yellow",
1779
+ on_hold: "yellow",
1780
+ shipped: "blue",
1781
+ in_progress: "blue",
1782
+ open: "blue",
1783
+ processing: "blue",
1784
+ draft: "gray",
1785
+ new: "gray",
1786
+ inactive: "gray",
1787
+ closed: "gray",
1788
+ cancelled: "red",
1789
+ canceled: "red",
1790
+ rejected: "red",
1791
+ failed: "red",
1792
+ overdue: "red",
1793
+ delivered: "purple",
1794
+ archived: "indigo"
1795
+ }, et = {
1796
+ gray: "bg-gray-100 text-gray-800 border-gray-300",
1797
+ red: "bg-red-100 text-red-800 border-red-300",
1798
+ orange: "bg-orange-100 text-orange-800 border-orange-300",
1799
+ yellow: "bg-yellow-100 text-yellow-800 border-yellow-300",
1800
+ green: "bg-green-100 text-green-800 border-green-300",
1801
+ blue: "bg-blue-100 text-blue-800 border-blue-300",
1802
+ indigo: "bg-indigo-100 text-indigo-800 border-indigo-300",
1803
+ purple: "bg-purple-100 text-purple-800 border-purple-300",
1804
+ pink: "bg-pink-100 text-pink-800 border-pink-300"
2154
1805
  };
2155
- function ke(e, r) {
2156
- const n = e || (r ? Lr[String(r).toLowerCase().replace(/[\s-]/g, "_")] : void 0);
2157
- return Ir[n || ""] || "bg-muted text-muted-foreground border-border";
2158
- }
2159
- function se({ value: e, field: r }) {
2160
- const a = r.options || [];
2161
- if (!e) return /* @__PURE__ */ t.jsx("span", { children: "-" });
2162
- if (Array.isArray(e))
2163
- return /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-1", children: e.map((o, c) => {
2164
- const m = a.find((u) => u.value === o), p = m?.label || ue(String(o)), f = ke(m?.color, o);
2165
- return /* @__PURE__ */ t.jsx(
2166
- M,
2167
- {
2168
- variant: "outline",
2169
- className: f,
2170
- children: p
2171
- },
2172
- c
2173
- );
2174
- }) });
2175
- const s = a.find((o) => o.value === e), i = s?.label || ue(String(e)), l = ke(s?.color, e);
2176
- return /* @__PURE__ */ t.jsx(
2177
- M,
2178
- {
2179
- variant: "outline",
2180
- className: l,
2181
- children: i
2182
- }
2183
- );
2184
- }
2185
- function Ur({ value: e }) {
2186
- if (!e) return /* @__PURE__ */ t.jsx("span", { children: "-" });
2187
- const [r, n] = k.useState(!1), a = (s) => {
2188
- s.stopPropagation(), s.preventDefault(), navigator.clipboard.writeText(String(e)).then(() => {
2189
- n(!0), setTimeout(() => n(!1), 2e3);
2190
- }).catch(() => {
2191
- });
2192
- };
2193
- return /* @__PURE__ */ t.jsxs("span", { className: "inline-flex items-center gap-1 group/email", children: [
2194
- /* @__PURE__ */ t.jsx(
2195
- P,
2196
- {
2197
- variant: "link",
2198
- className: "p-0 h-auto font-normal text-blue-600 hover:text-blue-800",
2199
- asChild: !0,
2200
- children: /* @__PURE__ */ t.jsx(
2201
- "a",
2202
- {
2203
- href: `mailto:${e}`,
2204
- onClick: (s) => s.stopPropagation(),
2205
- children: e
2206
- }
2207
- )
2208
- }
2209
- ),
2210
- /* @__PURE__ */ t.jsx(
2211
- "button",
2212
- {
2213
- type: "button",
2214
- className: "opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",
2215
- onClick: a,
2216
- "aria-label": "Copy email",
2217
- children: r ? /* @__PURE__ */ t.jsx(he, { className: "h-3 w-3 text-green-600" }) : /* @__PURE__ */ t.jsx(pe, { className: "h-3 w-3 text-muted-foreground" })
2218
- }
2219
- )
2220
- ] });
2221
- }
2222
- function Vr({ value: e }) {
2223
- return e ? /* @__PURE__ */ t.jsx(
2224
- P,
2225
- {
2226
- variant: "link",
2227
- className: "p-0 h-auto font-normal text-blue-600 hover:text-blue-800",
2228
- asChild: !0,
2229
- children: /* @__PURE__ */ t.jsx(
2230
- "a",
2231
- {
2232
- href: e,
2233
- target: "_blank",
2234
- rel: "noopener noreferrer",
2235
- onClick: (r) => r.stopPropagation(),
2236
- children: e
2237
- }
2238
- )
2239
- }
2240
- ) : /* @__PURE__ */ t.jsx("span", { children: "-" });
2241
- }
2242
- function Br({ value: e }) {
2243
- if (!e) return /* @__PURE__ */ t.jsx("span", { children: "-" });
2244
- const [r, n] = k.useState(!1), a = (s) => {
2245
- s.stopPropagation(), s.preventDefault(), navigator.clipboard.writeText(String(e)).then(() => {
2246
- n(!0), setTimeout(() => n(!1), 2e3);
2247
- }).catch(() => {
2248
- });
2249
- };
2250
- return /* @__PURE__ */ t.jsxs("span", { className: "inline-flex items-center gap-1 group/phone", children: [
2251
- /* @__PURE__ */ t.jsxs(
2252
- "a",
2253
- {
2254
- href: `tel:${e}`,
2255
- className: "inline-flex items-center gap-1 text-blue-600 hover:text-blue-800",
2256
- onClick: (s) => s.stopPropagation(),
2257
- children: [
2258
- /* @__PURE__ */ t.jsx(Bt, { className: "h-3 w-3" }),
2259
- e
2260
- ]
2261
- }
2262
- ),
2263
- /* @__PURE__ */ t.jsx(
2264
- "button",
2265
- {
2266
- type: "button",
2267
- className: "opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",
2268
- onClick: a,
2269
- "aria-label": "Copy phone number",
2270
- children: r ? /* @__PURE__ */ t.jsx(he, { className: "h-3 w-3 text-green-600" }) : /* @__PURE__ */ t.jsx(pe, { className: "h-3 w-3 text-muted-foreground" })
2271
- }
2272
- )
2273
- ] });
2274
- }
2275
- function Yr({ value: e, field: r }) {
2276
- if (!e) return /* @__PURE__ */ t.jsx("span", { children: "-" });
2277
- if (r.multiple, Array.isArray(e)) {
2278
- const s = e.length;
2279
- return /* @__PURE__ */ t.jsxs("span", { className: "text-sm text-gray-600", children: [
2280
- s,
2281
- " ",
2282
- s === 1 ? "file" : "files"
2283
- ] });
2284
- }
2285
- const a = e.name || e.original_name || "File";
2286
- return /* @__PURE__ */ t.jsx("span", { className: "text-sm truncate", children: a });
2287
- }
2288
- function qr({ value: e }) {
2289
- return e ? Array.isArray(e) ? /* @__PURE__ */ t.jsxs("div", { className: "flex -space-x-2", children: [
2290
- e.slice(0, 3).map((r, n) => /* @__PURE__ */ t.jsx(
2291
- "img",
2292
- {
2293
- src: r.url || "",
2294
- alt: r.name || `Image ${n + 1}`,
2295
- className: "size-8 rounded-md border-2 border-white object-cover"
2296
- },
2297
- n
2298
- )),
2299
- e.length > 3 && /* @__PURE__ */ t.jsxs("div", { className: "size-8 rounded-md border-2 border-white bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-600", children: [
2300
- "+",
2301
- e.length - 3
2302
- ] })
2303
- ] }) : /* @__PURE__ */ t.jsx(
2304
- "img",
2305
- {
2306
- src: e.url || "",
2307
- alt: e.name || "Image",
2308
- className: "size-10 rounded-md object-cover"
2309
- }
2310
- ) : /* @__PURE__ */ t.jsx("span", { children: "-" });
2311
- }
2312
- function ne({ value: e, field: r }) {
2313
- if (e == null || e === "") return /* @__PURE__ */ t.jsx("span", { children: "-" });
2314
- const n = r.options || [], a = (s) => {
2315
- if (n.length > 0) {
2316
- const i = n.find((l) => String(l.value) === String(s));
2317
- if (i) return i.label;
2318
- }
2319
- return String(s);
2320
- };
2321
- if (Array.isArray(e))
2322
- return /* @__PURE__ */ t.jsx("div", { className: "flex flex-wrap gap-1", children: e.map((s, i) => {
2323
- let l;
2324
- return s != null && typeof s == "object" ? l = s.name || s.label || s._id || String(s) : l = a(s), /* @__PURE__ */ t.jsx(
2325
- "span",
2326
- {
2327
- className: "inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800",
2328
- children: l
2329
- },
2330
- i
2331
- );
2332
- }) });
2333
- if (typeof e == "object" && e !== null) {
2334
- const s = e.name || e.label || e._id || "[Object]";
2335
- return /* @__PURE__ */ t.jsx("span", { className: "truncate", children: s });
2336
- }
2337
- return /* @__PURE__ */ t.jsx("span", { className: "truncate", children: a(e) });
2338
- }
2339
- function Ae({ value: e }) {
2340
- return /* @__PURE__ */ t.jsx("span", { className: "text-gray-700 font-mono text-sm", children: e != null ? String(e) : "-" });
2341
- }
2342
- function ae({ value: e }) {
2343
- if (!e) return /* @__PURE__ */ t.jsx("span", { children: "-" });
2344
- if (typeof e != "object")
2345
- return /* @__PURE__ */ t.jsx("span", { className: "truncate", children: String(e) });
2346
- if (Array.isArray(e))
2347
- return /* @__PURE__ */ t.jsxs("div", { className: "flex -space-x-2", children: [
2348
- e.slice(0, 3).map((a, s) => {
2349
- if (typeof a != "object" || a === null)
2350
- return /* @__PURE__ */ t.jsx("span", { className: "truncate text-sm", children: String(a) }, s);
2351
- const i = a.name || a.username || "User", l = i.split(" ").map((o) => o[0]).join("").toUpperCase().slice(0, 2);
2352
- return /* @__PURE__ */ t.jsx(
2353
- L,
2354
- {
2355
- className: "size-8 border-2 border-white",
2356
- title: i,
2357
- children: /* @__PURE__ */ t.jsx(I, { className: "bg-blue-500 text-white text-xs", children: l })
2358
- },
2359
- s
2360
- );
2361
- }),
2362
- e.length > 3 && /* @__PURE__ */ t.jsx(L, { className: "size-8 border-2 border-white", children: /* @__PURE__ */ t.jsxs(I, { className: "bg-gray-200 text-gray-600 text-xs", children: [
2363
- "+",
2364
- e.length - 3
2365
- ] }) })
2366
- ] });
2367
- const r = e.name || e.username || "User", n = r.split(" ").map((a) => a[0]).join("").toUpperCase().slice(0, 2);
2368
- return /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
2369
- /* @__PURE__ */ t.jsx(L, { className: "size-8", children: /* @__PURE__ */ t.jsx(I, { className: "bg-blue-500 text-white text-xs", children: n }) }),
2370
- /* @__PURE__ */ t.jsx("span", { className: "truncate", children: r })
2371
- ] });
2372
- }
2373
- const fe = /* @__PURE__ */ new Map();
2374
- function G(e, r) {
2375
- fe.set(e, r);
2376
- }
2377
- function es(e) {
2378
- return fe.has(e) ? fe.get(e) : {
2379
- text: D,
2380
- textarea: D,
2381
- markdown: D,
2382
- html: D,
2383
- number: Rr,
2384
- currency: kr,
2385
- percent: $r,
2386
- boolean: Er,
2387
- date: Dr,
2388
- datetime: Mr,
2389
- time: D,
2390
- select: se,
2391
- status: se,
2392
- lookup: ne,
2393
- master_detail: ne,
2394
- email: Ur,
2395
- url: Vr,
2396
- phone: Br,
2397
- file: Yr,
2398
- image: qr,
2399
- formula: Ae,
2400
- summary: Ae,
2401
- auto_number: D,
2402
- user: ae,
2403
- owner: ae,
2404
- password: () => /* @__PURE__ */ t.jsx("span", { children: "••••••" }),
2405
- location: D,
2406
- // Default fallback
2407
- object: () => /* @__PURE__ */ t.jsx("span", { className: "text-gray-500 italic", children: "[Object]" }),
2408
- vector: () => /* @__PURE__ */ t.jsx("span", { className: "text-gray-500 italic", children: "[Vector]" }),
2409
- grid: () => /* @__PURE__ */ t.jsx("span", { className: "text-gray-500 italic", children: "[Grid]" })
2410
- }[e] || D;
2411
- }
2412
- G("lookup", ne);
2413
- G("master_detail", ne);
2414
- G("select", se);
2415
- G("status", se);
2416
- G("user", ae);
2417
- G("owner", ae);
2418
- function ts(e) {
2419
- return {
2420
- // Text-based fields
2421
- text: "field:text",
2422
- textarea: "field:textarea",
2423
- markdown: "field:markdown",
2424
- // Markdown editor (fallback to textarea)
2425
- html: "field:html",
2426
- // Rich text editor (fallback to textarea)
2427
- // Numeric fields
2428
- number: "field:number",
2429
- currency: "field:currency",
2430
- percent: "field:percent",
2431
- // Date/Time fields
2432
- date: "field:date",
2433
- datetime: "field:datetime",
2434
- time: "field:time",
2435
- // Boolean
2436
- boolean: "field:boolean",
2437
- // Selection fields
2438
- select: "field:select",
2439
- lookup: "field:lookup",
2440
- master_detail: "field:master_detail",
2441
- // Contact fields
2442
- email: "field:email",
2443
- phone: "field:phone",
2444
- url: "field:url",
2445
- // File fields
2446
- file: "field:file",
2447
- image: "field:image",
2448
- // Special fields
2449
- password: "field:password",
2450
- location: "field:location",
2451
- // Location/map field (fallback to input)
2452
- // Auto-generated/computed fields (typically read-only)
2453
- formula: "field:formula",
2454
- summary: "field:summary",
2455
- auto_number: "field:auto_number"
2456
- }[e] || "field:text";
2457
- }
2458
- function rs(e) {
2459
- if (e < 0 || !Number.isFinite(e) || e === 0)
2460
- return "0 B";
2461
- const r = ["B", "KB", "MB", "GB", "TB"];
2462
- let n = e, a = 0;
2463
- for (; n >= 1024 && a < r.length - 1; )
2464
- n /= 1024, a++;
2465
- return `${n.toFixed(a > 0 ? 1 : 0)} ${r[a]}`;
2466
- }
2467
- function ss(e) {
2468
- const r = {};
2469
- return e.required && (r.required = typeof e.required_message == "string" ? e.required_message : `${e.label || e.name} is required`), e.min_length && (r.minLength = {
2470
- value: e.min_length,
2471
- message: e.min_length_message || `Minimum length is ${e.min_length} characters`
2472
- }), e.max_length && (r.maxLength = {
2473
- value: e.max_length,
2474
- message: e.max_length_message || `Maximum length is ${e.max_length} characters`
2475
- }), e.min !== void 0 && (r.min = {
2476
- value: e.min,
2477
- message: e.min_message || `Minimum value is ${e.min}`
2478
- }), e.max !== void 0 && (r.max = {
2479
- value: e.max,
2480
- message: e.max_message || `Maximum value is ${e.max}`
2481
- }), e.pattern && (r.pattern = {
2482
- value: typeof e.pattern == "string" ? new RegExp(e.pattern) : e.pattern,
2483
- message: e.pattern_message || "Invalid format"
2484
- }), e.type === "email" && (r.pattern = {
2485
- value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
2486
- message: "Please enter a valid email address"
2487
- }), e.type === "url" && (r.pattern = {
2488
- value: /^https?:\/\/.+/,
2489
- message: "Please enter a valid URL"
2490
- }), e.validate && (r.validate = e.validate), Object.keys(r).length > 0 ? r : void 0;
2491
- }
2492
- function $e(e, r) {
2493
- if (!e) return !0;
2494
- if (e.field && e.value !== void 0) {
2495
- const n = r[e.field];
2496
- if (e.operator === "=" || e.operator === "==")
2497
- return n === e.value;
2498
- if (e.operator === "!=")
2499
- return n !== e.value;
2500
- if (e.operator === ">")
2501
- return n > e.value;
2502
- if (e.operator === ">=")
2503
- return n >= e.value;
2504
- if (e.operator === "<")
2505
- return n < e.value;
2506
- if (e.operator === "<=")
2507
- return n <= e.value;
2508
- if (e.operator === "in")
2509
- return Array.isArray(e.value) && e.value.includes(n);
2510
- }
2511
- return e.and && Array.isArray(e.and) ? e.and.every((n) => $e(n, r)) : e.or && Array.isArray(e.or) ? e.or.some((n) => $e(n, r)) : !0;
2512
- }
2513
- function y(e) {
2514
- const r = ({ schema: n, className: a, value: s, ...i }) => {
2515
- const [l, o] = k.useState(s ?? n?.value ?? ""), c = {
2516
- name: n?.name || "field",
2517
- label: n?.label,
2518
- type: n?.type,
2519
- placeholder: n?.placeholder,
2520
- required: n?.required,
2521
- readonly: n?.readonly || n?.readOnly,
2522
- help: n?.help,
2523
- description: n?.description,
2524
- defaultValue: n?.defaultValue || n?.value,
2525
- ...n
2526
- }, m = k.useCallback((f) => {
2527
- o(f), i.onChange && i.onChange(f);
2528
- }, [i]), p = n?.readonly || n?.readOnly || !1;
2529
- return /* @__PURE__ */ t.jsxs(
2530
- "div",
2531
- {
2532
- className: "grid w-full items-center gap-1.5",
2533
- "data-obj-id": n?.id,
2534
- "data-obj-type": n?.type,
2535
- children: [
2536
- n?.label && /* @__PURE__ */ t.jsx("label", { htmlFor: n.id, className: n.required ? "after:content-['*'] after:ml-0.5 after:text-red-500" : "", children: n.label }),
2537
- /* @__PURE__ */ t.jsx(
2538
- e,
2539
- {
2540
- value: l,
2541
- onChange: m,
2542
- field: c,
2543
- readonly: p,
2544
- className: a
2545
- }
2546
- ),
2547
- n?.description && /* @__PURE__ */ t.jsx("p", { className: "text-sm text-gray-500", children: n.description })
2548
- ]
2549
- }
2550
- );
2551
- };
2552
- return r.displayName = `FieldRenderer(${e.displayName || e.name || "Component"})`, r;
2553
- }
2554
- const jt = {
2555
- // Basic fields
2556
- text: () => Promise.resolve().then(() => Wt).then((e) => ({ default: e.TextField })),
2557
- textarea: () => Promise.resolve().then(() => sr).then((e) => ({ default: e.TextAreaField })),
2558
- number: () => Promise.resolve().then(() => Gt).then((e) => ({ default: e.NumberField })),
2559
- boolean: () => Promise.resolve().then(() => Qt).then((e) => ({ default: e.BooleanField })),
2560
- select: () => Promise.resolve().then(() => Ht).then((e) => ({ default: e.SelectField })),
2561
- date: () => Promise.resolve().then(() => Xt).then((e) => ({ default: e.DateField })),
2562
- datetime: () => Promise.resolve().then(() => ar).then((e) => ({ default: e.DateTimeField })),
2563
- time: () => Promise.resolve().then(() => lr).then((e) => ({ default: e.TimeField })),
2564
- // Contact fields
2565
- email: () => Promise.resolve().then(() => Zt).then((e) => ({ default: e.EmailField })),
2566
- phone: () => Promise.resolve().then(() => Kt).then((e) => ({ default: e.PhoneField })),
2567
- url: () => Promise.resolve().then(() => er).then((e) => ({ default: e.UrlField })),
2568
- // Specialized fields
2569
- currency: () => Promise.resolve().then(() => rr).then((e) => ({ default: e.CurrencyField })),
2570
- percent: () => Promise.resolve().then(() => ir).then((e) => ({ default: e.PercentField })),
2571
- password: () => Promise.resolve().then(() => or).then((e) => ({ default: e.PasswordField })),
2572
- markdown: () => Promise.resolve().then(() => Oe).then((e) => ({ default: e.RichTextField })),
2573
- html: () => Promise.resolve().then(() => Oe).then((e) => ({ default: e.RichTextField })),
2574
- lookup: () => Promise.resolve().then(() => nr).then((e) => ({ default: e.LookupField })),
2575
- master_detail: () => Promise.resolve().then(() => Cr).then((e) => ({ default: e.MasterDetailField })),
2576
- // File fields
2577
- file: () => Promise.resolve().then(() => cr).then((e) => ({ default: e.FileField })),
2578
- image: () => Promise.resolve().then(() => dr).then((e) => ({ default: e.ImageField })),
2579
- // Location field
2580
- location: () => Promise.resolve().then(() => ur).then((e) => ({ default: e.LocationField })),
2581
- // Computed/Read-only fields
2582
- formula: () => Promise.resolve().then(() => mr).then((e) => ({ default: e.FormulaField })),
2583
- summary: () => Promise.resolve().then(() => fr).then((e) => ({ default: e.SummaryField })),
2584
- auto_number: () => Promise.resolve().then(() => xr).then((e) => ({ default: e.AutoNumberField })),
2585
- // User fields
2586
- user: () => Promise.resolve().then(() => Re).then((e) => ({ default: e.UserField })),
2587
- owner: () => Promise.resolve().then(() => Re).then((e) => ({ default: e.UserField })),
2588
- // Complex data types
2589
- object: () => Promise.resolve().then(() => pr).then((e) => ({ default: e.ObjectField })),
2590
- vector: () => Promise.resolve().then(() => hr).then((e) => ({ default: e.VectorField })),
2591
- grid: () => Promise.resolve().then(() => gr).then((e) => ({ default: e.GridField })),
2592
- // Additional field types from @objectstack/spec
2593
- color: () => Promise.resolve().then(() => br).then((e) => ({ default: e.ColorField })),
2594
- slider: () => Promise.resolve().then(() => jr).then((e) => ({ default: e.SliderField })),
2595
- rating: () => Promise.resolve().then(() => yr).then((e) => ({ default: e.RatingField })),
2596
- code: () => Promise.resolve().then(() => Nr).then((e) => ({ default: e.CodeField })),
2597
- avatar: () => Promise.resolve().then(() => vr).then((e) => ({ default: e.AvatarField })),
2598
- address: () => Promise.resolve().then(() => _r).then((e) => ({ default: e.AddressField })),
2599
- geolocation: () => Promise.resolve().then(() => wr).then((e) => ({ default: e.GeolocationField })),
2600
- signature: () => Promise.resolve().then(() => Fr).then((e) => ({ default: e.SignatureField })),
2601
- qrcode: () => Promise.resolve().then(() => Sr).then((e) => ({ default: e.QRCodeField }))
2602
- };
2603
- function Jr(e) {
2604
- const r = jt[e];
2605
- if (!r) {
2606
- console.warn(`Unknown field type: ${e}`);
2607
- return;
2608
- }
2609
- const n = k.lazy(r);
2610
- g.register(e, n, { namespace: "field" });
2611
- }
2612
- function Wr() {
2613
- Object.keys(jt).forEach((e) => {
2614
- Jr(e);
2615
- });
2616
- }
2617
- function ns() {
2618
- g.register("text", y(Le), { namespace: "field" }), g.register("textarea", y(Ge), { namespace: "field" }), g.register("number", y(Ie), { namespace: "field" }), g.register("boolean", y(Ue), { namespace: "field" }), g.register("select", y(Ve), { namespace: "field" }), g.register("date", y(Be), { namespace: "field" }), g.register("datetime", y(He), { namespace: "field" }), g.register("time", y(Xe), { namespace: "field" }), g.register("email", y(Ye), { namespace: "field" }), g.register("phone", y(qe), { namespace: "field" }), g.register("url", y(Je), { namespace: "field" }), g.register("currency", y(We), { namespace: "field" }), g.register("percent", y(Ze), { namespace: "field" }), g.register("password", y(Ke), { namespace: "field" }), g.register("markdown", y(ce), { namespace: "field" }), g.register("html", y(ce), { namespace: "field" }), g.register("lookup", y(Qe), { namespace: "field" }), g.register("master_detail", y(bt), { namespace: "field" }), g.register("file", y(et), { namespace: "field" }), g.register("image", y(tt), { namespace: "field" }), g.register("location", y(rt), { namespace: "field" }), g.register("formula", y(st), { namespace: "field" }), g.register("summary", y(nt), { namespace: "field" }), g.register("auto_number", y(at), { namespace: "field" }), g.register("user", y(de), { namespace: "field" }), g.register("owner", y(de), { namespace: "field" }), g.register("object", y(lt), { namespace: "field" }), g.register("vector", y(it), { namespace: "field" }), g.register("grid", y(ot), { namespace: "field" }), g.register("color", y(ct), { namespace: "field" }), g.register("slider", y(dt), { namespace: "field" }), g.register("rating", y(ut), { namespace: "field" }), g.register("code", y(mt), { namespace: "field" }), g.register("avatar", y(ft), { namespace: "field" }), g.register("address", y(xt), { namespace: "field" }), g.register("geolocation", y(pt), { namespace: "field" }), g.register("signature", y(ht), { namespace: "field" }), g.register("qrcode", y(gt), { namespace: "field" });
2619
- }
2620
- Wr();
2621
- export {
2622
- xt as AddressField,
2623
- at as AutoNumberField,
2624
- ft as AvatarField,
2625
- Er as BooleanCellRenderer,
2626
- Ue as BooleanField,
2627
- mt as CodeField,
2628
- ct as ColorField,
2629
- kr as CurrencyCellRenderer,
2630
- We as CurrencyField,
2631
- Dr as DateCellRenderer,
2632
- Be as DateField,
2633
- Mr as DateTimeCellRenderer,
2634
- He as DateTimeField,
2635
- Ur as EmailCellRenderer,
2636
- Ye as EmailField,
2637
- Yr as FileCellRenderer,
2638
- et as FileField,
2639
- Ae as FormulaCellRenderer,
2640
- st as FormulaField,
2641
- pt as GeolocationField,
2642
- ot as GridField,
2643
- qr as ImageCellRenderer,
2644
- tt as ImageField,
2645
- rt as LocationField,
2646
- ne as LookupCellRenderer,
2647
- Qe as LookupField,
2648
- bt as MasterDetailField,
2649
- Rr as NumberCellRenderer,
2650
- Ie as NumberField,
2651
- lt as ObjectField,
2652
- Ke as PasswordField,
2653
- $r as PercentCellRenderer,
2654
- Ze as PercentField,
2655
- Br as PhoneCellRenderer,
2656
- qe as PhoneField,
2657
- gt as QRCodeField,
2658
- ut as RatingField,
2659
- ce as RichTextField,
2660
- se as SelectCellRenderer,
2661
- Ve as SelectField,
2662
- ht as SignatureField,
2663
- dt as SliderField,
2664
- nt as SummaryField,
2665
- Ge as TextAreaField,
2666
- D as TextCellRenderer,
2667
- Le as TextField,
2668
- Xe as TimeField,
2669
- Vr as UrlCellRenderer,
2670
- Je as UrlField,
2671
- ae as UserCellRenderer,
2672
- de as UserField,
2673
- it as VectorField,
2674
- ss as buildValidationRules,
2675
- $e as evaluateCondition,
2676
- Zr as formatCompactCurrency,
2677
- Pr as formatCurrency,
2678
- me as formatDate,
2679
- Kr as formatDateTime,
2680
- rs as formatFileSize,
2681
- Tr as formatPercent,
2682
- Or as formatRelativeDate,
2683
- es as getCellRenderer,
2684
- ue as humanizeLabel,
2685
- ts as mapFieldTypeToFormType,
2686
- Wr as registerAllFields,
2687
- Jr as registerField,
2688
- G as registerFieldRenderer,
2689
- ns as registerFields
1806
+ function tt(e, t) {
1807
+ return et[e || (t ? $e[String(t).toLowerCase().replace(/[\s-]/g, "_")] : void 0) || ""] || "bg-muted text-muted-foreground border-border";
1808
+ }
1809
+ function K({ value: e, field: t }) {
1810
+ let n = t.options || [];
1811
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1812
+ if (Array.isArray(e)) return /* @__PURE__ */ (0, A.jsx)("div", {
1813
+ className: "flex flex-wrap gap-1",
1814
+ children: e.map((e, t) => {
1815
+ let r = n.find((t) => t.value === e), i = r?.label || U(String(e));
1816
+ return /* @__PURE__ */ (0, A.jsx)(m, {
1817
+ variant: "outline",
1818
+ className: tt(r?.color, e),
1819
+ children: i
1820
+ }, t);
1821
+ })
1822
+ });
1823
+ let r = n.find((t) => t.value === e), i = r?.label || U(String(e));
1824
+ return /* @__PURE__ */ (0, A.jsx)(m, {
1825
+ variant: "outline",
1826
+ className: tt(r?.color, e),
1827
+ children: i
1828
+ });
1829
+ }
1830
+ function nt({ value: e }) {
1831
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1832
+ let t = String(H(e) ?? ""), [n, r] = i.useState(!1);
1833
+ return /* @__PURE__ */ (0, A.jsxs)("span", {
1834
+ className: "inline-flex items-center gap-1 group/email",
1835
+ children: [/* @__PURE__ */ (0, A.jsx)(h, {
1836
+ variant: "link",
1837
+ className: "p-0 h-auto font-normal text-blue-600 hover:text-blue-800",
1838
+ asChild: !0,
1839
+ children: /* @__PURE__ */ (0, A.jsx)("a", {
1840
+ href: `mailto:${t}`,
1841
+ onClick: (e) => e.stopPropagation(),
1842
+ children: t
1843
+ })
1844
+ }), /* @__PURE__ */ (0, A.jsx)("button", {
1845
+ type: "button",
1846
+ className: "opacity-0 group-hover/email:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",
1847
+ onClick: (e) => {
1848
+ e.stopPropagation(), e.preventDefault(), navigator.clipboard.writeText(t).then(() => {
1849
+ r(!0), setTimeout(() => r(!1), 2e3);
1850
+ }).catch(() => {});
1851
+ },
1852
+ "aria-label": "Copy email",
1853
+ children: n ? /* @__PURE__ */ (0, A.jsx)(E, { className: "h-3 w-3 text-green-600" }) : /* @__PURE__ */ (0, A.jsx)(D, { className: "h-3 w-3 text-muted-foreground" })
1854
+ })]
1855
+ });
1856
+ }
1857
+ function rt({ value: e }) {
1858
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1859
+ let t = String(H(e) ?? "");
1860
+ return /* @__PURE__ */ (0, A.jsx)(h, {
1861
+ variant: "link",
1862
+ className: "p-0 h-auto font-normal text-blue-600 hover:text-blue-800",
1863
+ asChild: !0,
1864
+ children: /* @__PURE__ */ (0, A.jsx)("a", {
1865
+ href: t,
1866
+ target: "_blank",
1867
+ rel: "noopener noreferrer",
1868
+ onClick: (e) => e.stopPropagation(),
1869
+ children: t
1870
+ })
1871
+ });
1872
+ }
1873
+ function it({ value: e }) {
1874
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1875
+ let t = String(H(e) ?? ""), [n, r] = i.useState(!1);
1876
+ return /* @__PURE__ */ (0, A.jsxs)("span", {
1877
+ className: "inline-flex items-center gap-1 group/phone",
1878
+ children: [/* @__PURE__ */ (0, A.jsxs)("a", {
1879
+ href: `tel:${t}`,
1880
+ className: "inline-flex items-center gap-1 text-blue-600 hover:text-blue-800",
1881
+ onClick: (e) => e.stopPropagation(),
1882
+ children: [/* @__PURE__ */ (0, A.jsx)(ue, { className: "h-3 w-3" }), t]
1883
+ }), /* @__PURE__ */ (0, A.jsx)("button", {
1884
+ type: "button",
1885
+ className: "opacity-0 group-hover/phone:opacity-100 transition-opacity p-0.5 rounded hover:bg-muted",
1886
+ onClick: (e) => {
1887
+ e.stopPropagation(), e.preventDefault(), navigator.clipboard.writeText(t).then(() => {
1888
+ r(!0), setTimeout(() => r(!1), 2e3);
1889
+ }).catch(() => {});
1890
+ },
1891
+ "aria-label": "Copy phone number",
1892
+ children: n ? /* @__PURE__ */ (0, A.jsx)(E, { className: "h-3 w-3 text-green-600" }) : /* @__PURE__ */ (0, A.jsx)(D, { className: "h-3 w-3 text-muted-foreground" })
1893
+ })]
1894
+ });
1895
+ }
1896
+ function at({ value: e, field: t }) {
1897
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1898
+ if (t.multiple, Array.isArray(e)) {
1899
+ let t = e.length;
1900
+ return /* @__PURE__ */ (0, A.jsxs)("span", {
1901
+ className: "text-sm text-gray-600",
1902
+ children: [
1903
+ t,
1904
+ " ",
1905
+ t === 1 ? "file" : "files"
1906
+ ]
1907
+ });
1908
+ }
1909
+ return /* @__PURE__ */ (0, A.jsx)("span", {
1910
+ className: "text-sm truncate",
1911
+ children: e.name || e.original_name || "File"
1912
+ });
1913
+ }
1914
+ function ot({ value: e }) {
1915
+ return e ? Array.isArray(e) ? /* @__PURE__ */ (0, A.jsxs)("div", {
1916
+ className: "flex -space-x-2",
1917
+ children: [e.slice(0, 3).map((e, t) => /* @__PURE__ */ (0, A.jsx)("img", {
1918
+ src: e.url || "",
1919
+ alt: e.name || `Image ${t + 1}`,
1920
+ className: "size-8 rounded-md border-2 border-white object-cover"
1921
+ }, t)), e.length > 3 && /* @__PURE__ */ (0, A.jsxs)("div", {
1922
+ className: "size-8 rounded-md border-2 border-white bg-gray-100 flex items-center justify-center text-xs font-medium text-gray-600",
1923
+ children: ["+", e.length - 3]
1924
+ })]
1925
+ }) : /* @__PURE__ */ (0, A.jsx)("img", {
1926
+ src: e.url || "",
1927
+ alt: e.name || "Image",
1928
+ className: "size-10 rounded-md object-cover"
1929
+ }) : /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1930
+ }
1931
+ function q({ value: e, field: t }) {
1932
+ if (e == null || e === "") return /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1933
+ let n = t.options || [], r = (e) => {
1934
+ if (n.length > 0) {
1935
+ let t = n.find((t) => String(t.value) === String(e));
1936
+ if (t) return t.label;
1937
+ }
1938
+ return String(e);
1939
+ };
1940
+ return Array.isArray(e) ? /* @__PURE__ */ (0, A.jsx)("div", {
1941
+ className: "flex flex-wrap gap-1",
1942
+ children: e.map((e, t) => {
1943
+ let n;
1944
+ return n = typeof e == "object" && e ? e.name || e.label || e.id || e._id || String(e) : r(e), /* @__PURE__ */ (0, A.jsx)("span", {
1945
+ className: "inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800",
1946
+ children: n
1947
+ }, t);
1948
+ })
1949
+ }) : typeof e == "object" && e ? /* @__PURE__ */ (0, A.jsx)("span", {
1950
+ className: "truncate",
1951
+ children: e.name || e.label || e.id || e._id || "[Object]"
1952
+ }) : /* @__PURE__ */ (0, A.jsx)("span", {
1953
+ className: "truncate",
1954
+ children: r(e)
1955
+ });
1956
+ }
1957
+ function J({ value: e }) {
1958
+ let t = H(e);
1959
+ return /* @__PURE__ */ (0, A.jsx)("span", {
1960
+ className: "text-gray-700 font-mono text-sm",
1961
+ children: t == null ? "-" : String(t)
1962
+ });
1963
+ }
1964
+ function Y({ value: e }) {
1965
+ if (!e) return /* @__PURE__ */ (0, A.jsx)("span", { children: "-" });
1966
+ if (typeof e != "object") return /* @__PURE__ */ (0, A.jsx)("span", {
1967
+ className: "truncate",
1968
+ children: String(e)
1969
+ });
1970
+ if (Array.isArray(e)) return /* @__PURE__ */ (0, A.jsxs)("div", {
1971
+ className: "flex -space-x-2",
1972
+ children: [e.slice(0, 3).map((e, t) => {
1973
+ if (typeof e != "object" || !e) return /* @__PURE__ */ (0, A.jsx)("span", {
1974
+ className: "truncate text-sm",
1975
+ children: String(e)
1976
+ }, t);
1977
+ let n = e.name || e.username || "User";
1978
+ return /* @__PURE__ */ (0, A.jsx)(d, {
1979
+ className: "size-8 border-2 border-white",
1980
+ title: n,
1981
+ children: /* @__PURE__ */ (0, A.jsx)(f, {
1982
+ className: "bg-blue-500 text-white text-xs",
1983
+ children: n.split(" ").map((e) => e[0]).join("").toUpperCase().slice(0, 2)
1984
+ })
1985
+ }, t);
1986
+ }), e.length > 3 && /* @__PURE__ */ (0, A.jsx)(d, {
1987
+ className: "size-8 border-2 border-white",
1988
+ children: /* @__PURE__ */ (0, A.jsxs)(f, {
1989
+ className: "bg-gray-200 text-gray-600 text-xs",
1990
+ children: ["+", e.length - 3]
1991
+ })
1992
+ })]
1993
+ });
1994
+ let t = e.name || e.username || "User";
1995
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
1996
+ className: "flex items-center gap-2",
1997
+ children: [/* @__PURE__ */ (0, A.jsx)(d, {
1998
+ className: "size-8",
1999
+ children: /* @__PURE__ */ (0, A.jsx)(f, {
2000
+ className: "bg-blue-500 text-white text-xs",
2001
+ children: t.split(" ").map((e) => e[0]).join("").toUpperCase().slice(0, 2)
2002
+ })
2003
+ }), /* @__PURE__ */ (0, A.jsx)("span", {
2004
+ className: "truncate",
2005
+ children: t
2006
+ })]
2007
+ });
2008
+ }
2009
+ var X = /* @__PURE__ */ new Map();
2010
+ function Z(e, t) {
2011
+ X.set(e, t);
2012
+ }
2013
+ function st(e) {
2014
+ return X.has(e) ? X.get(e) : {
2015
+ text: G,
2016
+ textarea: G,
2017
+ markdown: G,
2018
+ html: G,
2019
+ number: Ge,
2020
+ currency: Ke,
2021
+ percent: Je,
2022
+ boolean: Xe,
2023
+ date: Ze,
2024
+ datetime: Qe,
2025
+ time: G,
2026
+ select: K,
2027
+ status: K,
2028
+ lookup: q,
2029
+ master_detail: q,
2030
+ email: nt,
2031
+ url: rt,
2032
+ phone: it,
2033
+ file: at,
2034
+ image: ot,
2035
+ formula: J,
2036
+ summary: J,
2037
+ auto_number: G,
2038
+ user: Y,
2039
+ owner: Y,
2040
+ password: () => /* @__PURE__ */ (0, A.jsx)("span", { children: "••••••" }),
2041
+ location: G,
2042
+ object: () => /* @__PURE__ */ (0, A.jsx)("span", {
2043
+ className: "text-gray-500 italic",
2044
+ children: "[Object]"
2045
+ }),
2046
+ vector: () => /* @__PURE__ */ (0, A.jsx)("span", {
2047
+ className: "text-gray-500 italic",
2048
+ children: "[Vector]"
2049
+ }),
2050
+ grid: () => /* @__PURE__ */ (0, A.jsx)("span", {
2051
+ className: "text-gray-500 italic",
2052
+ children: "[Grid]"
2053
+ })
2054
+ }[e] || G;
2055
+ }
2056
+ Z("lookup", q), Z("master_detail", q), Z("select", K), Z("status", K), Z("user", Y), Z("owner", Y), n(st);
2057
+ function ct(e) {
2058
+ return {
2059
+ text: "field:text",
2060
+ textarea: "field:textarea",
2061
+ markdown: "field:markdown",
2062
+ html: "field:html",
2063
+ number: "field:number",
2064
+ currency: "field:currency",
2065
+ percent: "field:percent",
2066
+ date: "field:date",
2067
+ datetime: "field:datetime",
2068
+ time: "field:time",
2069
+ boolean: "field:boolean",
2070
+ select: "field:select",
2071
+ lookup: "field:lookup",
2072
+ master_detail: "field:master_detail",
2073
+ email: "field:email",
2074
+ phone: "field:phone",
2075
+ url: "field:url",
2076
+ file: "field:file",
2077
+ image: "field:image",
2078
+ password: "field:password",
2079
+ location: "field:location",
2080
+ formula: "field:formula",
2081
+ summary: "field:summary",
2082
+ auto_number: "field:auto_number"
2083
+ }[e] || "field:text";
2084
+ }
2085
+ function lt(e) {
2086
+ if (e < 0 || !Number.isFinite(e) || e === 0) return "0 B";
2087
+ let t = [
2088
+ "B",
2089
+ "KB",
2090
+ "MB",
2091
+ "GB",
2092
+ "TB"
2093
+ ], n = e, r = 0;
2094
+ for (; n >= 1024 && r < t.length - 1;) n /= 1024, r++;
2095
+ return `${n.toFixed(r > 0 ? 1 : 0)} ${t[r]}`;
2096
+ }
2097
+ function ut(e) {
2098
+ let t = {};
2099
+ return e.required && (t.required = typeof e.required_message == "string" ? e.required_message : `${e.label || e.name} is required`), e.min_length && (t.minLength = {
2100
+ value: e.min_length,
2101
+ message: e.min_length_message || `Minimum length is ${e.min_length} characters`
2102
+ }), e.max_length && (t.maxLength = {
2103
+ value: e.max_length,
2104
+ message: e.max_length_message || `Maximum length is ${e.max_length} characters`
2105
+ }), e.min !== void 0 && (t.min = {
2106
+ value: e.min,
2107
+ message: e.min_message || `Minimum value is ${e.min}`
2108
+ }), e.max !== void 0 && (t.max = {
2109
+ value: e.max,
2110
+ message: e.max_message || `Maximum value is ${e.max}`
2111
+ }), e.pattern && (t.pattern = {
2112
+ value: typeof e.pattern == "string" ? new RegExp(e.pattern) : e.pattern,
2113
+ message: e.pattern_message || "Invalid format"
2114
+ }), e.type === "email" && (t.pattern = {
2115
+ value: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
2116
+ message: "Please enter a valid email address"
2117
+ }), e.type === "url" && (t.pattern = {
2118
+ value: /^https?:\/\/.+/,
2119
+ message: "Please enter a valid URL"
2120
+ }), e.validate && (t.validate = e.validate), Object.keys(t).length > 0 ? t : void 0;
2121
+ }
2122
+ function Q(e, t) {
2123
+ if (!e) return !0;
2124
+ if (e.field && e.value !== void 0) {
2125
+ let n = t[e.field];
2126
+ if (e.operator === "=" || e.operator === "==") return n === e.value;
2127
+ if (e.operator === "!=") return n !== e.value;
2128
+ if (e.operator === ">") return n > e.value;
2129
+ if (e.operator === ">=") return n >= e.value;
2130
+ if (e.operator === "<") return n < e.value;
2131
+ if (e.operator === "<=") return n <= e.value;
2132
+ if (e.operator === "in") return Array.isArray(e.value) && e.value.includes(n);
2133
+ }
2134
+ return e.and && Array.isArray(e.and) ? e.and.every((e) => Q(e, t)) : e.or && Array.isArray(e.or) ? e.or.some((e) => Q(e, t)) : !0;
2135
+ }
2136
+ function $(e) {
2137
+ let t = ({ schema: t, className: n, value: r, ...a }) => {
2138
+ let [o, s] = i.useState(r ?? t?.value ?? ""), c = {
2139
+ name: t?.name || "field",
2140
+ label: t?.label,
2141
+ type: t?.type,
2142
+ placeholder: t?.placeholder,
2143
+ required: t?.required,
2144
+ readonly: t?.readonly || t?.readOnly,
2145
+ help: t?.help,
2146
+ description: t?.description,
2147
+ defaultValue: t?.defaultValue || t?.value,
2148
+ ...t
2149
+ }, l = i.useCallback((e) => {
2150
+ s(e), a.onChange && a.onChange(e);
2151
+ }, [a]), u = t?.readonly || t?.readOnly || !1;
2152
+ return /* @__PURE__ */ (0, A.jsxs)("div", {
2153
+ className: "grid w-full items-center gap-1.5",
2154
+ "data-obj-id": t?.id,
2155
+ "data-obj-type": t?.type,
2156
+ children: [
2157
+ t?.label && /* @__PURE__ */ (0, A.jsx)("label", {
2158
+ htmlFor: t.id,
2159
+ className: t.required ? "after:content-['*'] after:ml-0.5 after:text-red-500" : "",
2160
+ children: t.label
2161
+ }),
2162
+ /* @__PURE__ */ (0, A.jsx)(e, {
2163
+ value: o,
2164
+ onChange: l,
2165
+ field: c,
2166
+ readonly: u,
2167
+ className: n
2168
+ }),
2169
+ t?.description && /* @__PURE__ */ (0, A.jsx)("p", {
2170
+ className: "text-sm text-gray-500",
2171
+ children: t.description
2172
+ })
2173
+ ]
2174
+ });
2175
+ };
2176
+ return t.displayName = `FieldRenderer(${e.displayName || e.name || "Component"})`, t;
2177
+ }
2178
+ var dt = {
2179
+ text: () => import("./TextField-CkEDGbkQ.js").then((e) => ({ default: e.TextField })),
2180
+ textarea: () => import("./TextAreaField--ut87UiB.js").then((e) => ({ default: e.TextAreaField })),
2181
+ number: () => import("./NumberField-DCHTzmDG.js").then((e) => ({ default: e.NumberField })),
2182
+ boolean: () => import("./BooleanField-Bs0urhsx.js").then((e) => ({ default: e.BooleanField })),
2183
+ select: () => import("./SelectField-DMy5IxRc.js").then((e) => ({ default: e.SelectField })),
2184
+ date: () => import("./DateField-DjGiK6BH.js").then((e) => ({ default: e.DateField })),
2185
+ datetime: () => import("./DateTimeField-DBh-dYdR.js").then((e) => ({ default: e.DateTimeField })),
2186
+ time: () => import("./TimeField-DA_S6lQV.js").then((e) => ({ default: e.TimeField })),
2187
+ email: () => import("./EmailField-Cp6yJlpH.js").then((e) => ({ default: e.EmailField })),
2188
+ phone: () => import("./PhoneField-CkrCFmcO.js").then((e) => ({ default: e.PhoneField })),
2189
+ url: () => import("./UrlField-DCnXHR1A.js").then((e) => ({ default: e.UrlField })),
2190
+ currency: () => import("./CurrencyField-D4VwXI9k.js").then((e) => ({ default: e.CurrencyField })),
2191
+ percent: () => import("./PercentField-B2t2knlc.js").then((e) => ({ default: e.PercentField })),
2192
+ password: () => import("./PasswordField-BZ_OeQyw.js").then((e) => ({ default: e.PasswordField })),
2193
+ markdown: () => import("./RichTextField-b-8QbNCJ.js").then((e) => ({ default: e.RichTextField })),
2194
+ html: () => import("./RichTextField-b-8QbNCJ.js").then((e) => ({ default: e.RichTextField })),
2195
+ lookup: () => import("./LookupField-BX4sK8NG.js").then((e) => e.n).then((e) => ({ default: e.LookupField })),
2196
+ master_detail: () => import("./MasterDetailField-BXncIT1s.js").then((e) => ({ default: e.MasterDetailField })),
2197
+ file: () => import("./FileField-DUgt6ai3.js").then((e) => ({ default: e.FileField })),
2198
+ image: () => import("./ImageField-rc1Nzcvb.js").then((e) => ({ default: e.ImageField })),
2199
+ location: () => import("./LocationField-QZPPYo0J.js").then((e) => ({ default: e.LocationField })),
2200
+ formula: () => import("./FormulaField-BLV1KgkQ.js").then((e) => ({ default: e.FormulaField })),
2201
+ summary: () => import("./SummaryField-DVSVfKmY.js").then((e) => ({ default: e.SummaryField })),
2202
+ auto_number: () => import("./AutoNumberField-DXIYJfiB.js").then((e) => ({ default: e.AutoNumberField })),
2203
+ user: () => import("./UserField-V0GmvyGV.js").then((e) => ({ default: e.UserField })),
2204
+ owner: () => import("./UserField-V0GmvyGV.js").then((e) => ({ default: e.UserField })),
2205
+ object: () => import("./ObjectField-BEUHpn_X.js").then((e) => ({ default: e.ObjectField })),
2206
+ vector: () => import("./VectorField-CVi5yrrc.js").then((e) => ({ default: e.VectorField })),
2207
+ grid: () => import("./GridField-O3Jd1NuJ.js").then((e) => ({ default: e.GridField })),
2208
+ color: () => import("./ColorField-Bar6bOJw.js").then((e) => ({ default: e.ColorField })),
2209
+ slider: () => import("./SliderField-B7WvKFv7.js").then((e) => ({ default: e.SliderField })),
2210
+ rating: () => import("./RatingField-DecDJkou.js").then((e) => ({ default: e.RatingField })),
2211
+ code: () => import("./CodeField-tRACqngO.js").then((e) => ({ default: e.CodeField })),
2212
+ avatar: () => import("./AvatarField-BHpex3Wa.js").then((e) => ({ default: e.AvatarField })),
2213
+ address: () => import("./AddressField-B6fPb2Fs.js").then((e) => ({ default: e.AddressField })),
2214
+ geolocation: () => import("./GeolocationField-BbIRH51u.js").then((e) => ({ default: e.GeolocationField })),
2215
+ signature: () => import("./SignatureField-BvTPE7Dn.js").then((e) => ({ default: e.SignatureField })),
2216
+ qrcode: () => import("./QRCodeField-CQoGow8y.js").then((e) => ({ default: e.QRCodeField }))
2690
2217
  };
2218
+ function ft(e) {
2219
+ let t = dt[e];
2220
+ if (!t) {
2221
+ console.warn(`Unknown field type: ${e}`);
2222
+ return;
2223
+ }
2224
+ let n = i.lazy(t);
2225
+ u.register(e, n, { namespace: "field" });
2226
+ }
2227
+ function pt() {
2228
+ Object.keys(dt).forEach((e) => {
2229
+ ft(e);
2230
+ });
2231
+ }
2232
+ function mt() {
2233
+ u.register("text", $(j), { namespace: "field" }), u.register("textarea", $(ge), { namespace: "field" }), u.register("number", $(M), { namespace: "field" }), u.register("boolean", $(N), { namespace: "field" }), u.register("select", $(P), { namespace: "field" }), u.register("date", $(F), { namespace: "field" }), u.register("datetime", $(_e), { namespace: "field" }), u.register("time", $(ve), { namespace: "field" }), u.register("email", $(I), { namespace: "field" }), u.register("phone", $(L), { namespace: "field" }), u.register("url", $(R), { namespace: "field" }), u.register("currency", $(z), { namespace: "field" }), u.register("percent", $(ye), { namespace: "field" }), u.register("password", $(be), { namespace: "field" }), u.register("markdown", $(B), { namespace: "field" }), u.register("html", $(B), { namespace: "field" }), u.register("lookup", $(r), { namespace: "field" }), u.register("master_detail", $(ze), { namespace: "field" }), u.register("file", $(xe), { namespace: "field" }), u.register("image", $(Se), { namespace: "field" }), u.register("location", $(Ce), { namespace: "field" }), u.register("formula", $(we), { namespace: "field" }), u.register("summary", $(Te), { namespace: "field" }), u.register("auto_number", $(Ee), { namespace: "field" }), u.register("user", $(V), { namespace: "field" }), u.register("owner", $(V), { namespace: "field" }), u.register("object", $(De), { namespace: "field" }), u.register("vector", $(Oe), { namespace: "field" }), u.register("grid", $(ke), { namespace: "field" }), u.register("color", $(Ae), { namespace: "field" }), u.register("slider", $(je), { namespace: "field" }), u.register("rating", $(Me), { namespace: "field" }), u.register("code", $(Ne), { namespace: "field" }), u.register("avatar", $(Pe), { namespace: "field" }), u.register("address", $(Fe), { namespace: "field" }), u.register("geolocation", $(Ie), { namespace: "field" }), u.register("signature", $(Le), { namespace: "field" }), u.register("qrcode", $(Re), { namespace: "field" });
2234
+ }
2235
+ pt();
2236
+ //#endregion
2237
+ export { Fe as AddressField, Ee as AutoNumberField, Pe as AvatarField, Xe as BooleanCellRenderer, N as BooleanField, Ne as CodeField, Ae as ColorField, Ke as CurrencyCellRenderer, z as CurrencyField, Ze as DateCellRenderer, F as DateField, Qe as DateTimeCellRenderer, _e as DateTimeField, nt as EmailCellRenderer, I as EmailField, at as FileCellRenderer, xe as FileField, J as FormulaCellRenderer, we as FormulaField, Ie as GeolocationField, ke as GridField, ot as ImageCellRenderer, Se as ImageField, Ce as LocationField, q as LookupCellRenderer, r as LookupField, ze as MasterDetailField, Ge as NumberCellRenderer, M as NumberField, De as ObjectField, be as PasswordField, Je as PercentCellRenderer, ye as PercentField, it as PhoneCellRenderer, L as PhoneField, Re as QRCodeField, Me as RatingField, t as RecordPickerDialog, B as RichTextField, K as SelectCellRenderer, P as SelectField, Le as SignatureField, je as SliderField, Te as SummaryField, ge as TextAreaField, G as TextCellRenderer, j as TextField, ve as TimeField, rt as UrlCellRenderer, R as UrlField, Y as UserCellRenderer, V as UserField, Oe as VectorField, ut as buildValidationRules, H as coerceToSafeValue, Q as evaluateCondition, Ve as formatCompactCurrency, Be as formatCurrency, W as formatDate, We as formatDateTime, lt as formatFileSize, He as formatPercent, Ue as formatRelativeDate, st as getCellRenderer, U as humanizeLabel, ct as mapFieldTypeToFormType, pt as registerAllFields, ft as registerField, Z as registerFieldRenderer, mt as registerFields };