@object-ui/plugin-detail 3.1.3 → 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 (79) hide show
  1. package/.turbo/turbo-build.log +53 -49
  2. package/CHANGELOG.md +10 -0
  3. package/dist/AddressField-DBkEyMcG.js +93 -0
  4. package/dist/AutoNumberField-Baa191z-.js +14 -0
  5. package/dist/AvatarField-YGj51ozd.js +80 -0
  6. package/dist/BooleanField-CaA898Tk.js +40 -0
  7. package/dist/CodeField-BU51nl1L.js +22 -0
  8. package/dist/ColorField-Cnf6ZM7c.js +37 -0
  9. package/dist/CurrencyField-Wg-XOId2.js +51 -0
  10. package/dist/DateField-Cth1ky_m.js +21 -0
  11. package/dist/DateTimeField-B0m6FhHL.js +32 -0
  12. package/dist/EmailField-Do7qT_L_.js +28 -0
  13. package/dist/FileField-aRJAdbQb.js +151 -0
  14. package/dist/FormulaField-DTMkagFx.js +14 -0
  15. package/dist/GeolocationField-RqpHWTEv.js +113 -0
  16. package/dist/GridField-D4IH0cpo.js +51 -0
  17. package/dist/ImageField-BYCFajjr.js +75 -0
  18. package/dist/LocationField-Bi_ew9sd.js +35 -0
  19. package/dist/LookupField-BjwlDPtt.js +902 -0
  20. package/dist/MasterDetailField-I1A9oEGC.js +94 -0
  21. package/dist/NumberField-D_NucQlp.js +26 -0
  22. package/dist/ObjectField-CG-LaM65.js +52 -0
  23. package/dist/PasswordField-DBtluGJ1.js +35 -0
  24. package/dist/PercentField-B6sO_J3i.js +63 -0
  25. package/dist/PhoneField-CcQAWwR6.js +28 -0
  26. package/dist/QRCodeField-CEjWs-J5.js +72 -0
  27. package/dist/RatingField-B_Mnr63i.js +39 -0
  28. package/dist/RichTextField-qOEJl5Ai.js +32 -0
  29. package/dist/SelectField-C8hWu3gm.js +30 -0
  30. package/dist/SignatureField-CddhEK9u.js +92 -0
  31. package/dist/SliderField-Df5hMzNc.js +34 -0
  32. package/dist/SummaryField-DgiFm-Cr.js +19 -0
  33. package/dist/TextAreaField-DuriTqsD.js +36 -0
  34. package/dist/TextField-CGNSl7RU.js +29 -0
  35. package/dist/TimeField-YO58ctFg.js +21 -0
  36. package/dist/UrlField-1-BMM1jn.js +33 -0
  37. package/dist/UserField-B6GqxP_S.js +78 -0
  38. package/dist/VectorField-BkEjbSt0.js +36 -0
  39. package/dist/index.js +4092 -33
  40. package/dist/index.umd.cjs +85 -76
  41. package/dist/plugin-detail.css +3 -1
  42. package/dist/src-CXr1-vVl.js +77662 -0
  43. package/package.json +9 -9
  44. package/dist/AddressField-BtiTrEpf.js +0 -96
  45. package/dist/AutoNumberField-BxnFqllo.js +0 -8
  46. package/dist/AvatarField-CwlnWNSf.js +0 -82
  47. package/dist/BooleanField-DpMXU2ya.js +0 -37
  48. package/dist/CodeField-gwmcFihg.js +0 -21
  49. package/dist/ColorField-CWmF_zoW.js +0 -42
  50. package/dist/CurrencyField-BF3tYAgm.js +0 -43
  51. package/dist/DateField-a6Ka9ph2.js +0 -21
  52. package/dist/DateTimeField-C4wWOEiw.js +0 -28
  53. package/dist/EmailField-DJqiQ4sp.js +0 -31
  54. package/dist/FileField-ChjjCydz.js +0 -133
  55. package/dist/FormulaField-CJkkwIK8.js +0 -9
  56. package/dist/GeolocationField-BnkeUBek.js +0 -123
  57. package/dist/GridField-DoHqc2ON.js +0 -30
  58. package/dist/ImageField-Ld7SHA8N.js +0 -90
  59. package/dist/LocationField-Bgu-vMAE.js +0 -31
  60. package/dist/MasterDetailField-Bp5WBTzU.js +0 -108
  61. package/dist/NumberField-uBqVZ-gt.js +0 -26
  62. package/dist/ObjectField-BH1Md9gH.js +0 -48
  63. package/dist/PasswordField-D8GZjY7d.js +0 -38
  64. package/dist/PercentField-DyK8vg8M.js +0 -63
  65. package/dist/PhoneField-B3qJyLP0.js +0 -31
  66. package/dist/QRCodeField-CGiRTCZq.js +0 -77
  67. package/dist/RatingField-CWVaJNyf.js +0 -47
  68. package/dist/RichTextField-CusveP9T.js +0 -38
  69. package/dist/SelectField-UdDfsEZo.js +0 -26
  70. package/dist/SignatureField-DFvPKbuI.js +0 -85
  71. package/dist/SliderField-C-HvGV9e.js +0 -30
  72. package/dist/SummaryField-ugYPYxjP.js +0 -9
  73. package/dist/TextAreaField-C5KygUT3.js +0 -39
  74. package/dist/TextField-oUjuqQ1x.js +0 -32
  75. package/dist/TimeField-SsQ6rfk5.js +0 -21
  76. package/dist/UrlField-kd48Ip95.js +0 -33
  77. package/dist/UserField-BOjE_CAz.js +0 -49
  78. package/dist/VectorField-CKg9jdGa.js +0 -25
  79. package/dist/index-D2t9pLAg.js +0 -99948
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@object-ui/plugin-detail",
3
- "version": "3.1.3",
3
+ "version": "3.1.4",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "description": "DetailView plugin for Object UI - comprehensive detail page with sections, tabs, and related lists",
@@ -25,11 +25,11 @@
25
25
  },
26
26
  "dependencies": {
27
27
  "lucide-react": "^0.577.0",
28
- "@object-ui/components": "3.1.3",
29
- "@object-ui/core": "3.1.3",
30
- "@object-ui/fields": "3.1.3",
31
- "@object-ui/react": "3.1.3",
32
- "@object-ui/types": "3.1.3"
28
+ "@object-ui/components": "3.1.4",
29
+ "@object-ui/fields": "3.1.4",
30
+ "@object-ui/core": "3.1.4",
31
+ "@object-ui/react": "3.1.4",
32
+ "@object-ui/types": "3.1.4"
33
33
  },
34
34
  "peerDependencies": {
35
35
  "react": "^18.0.0 || ^19.0.0",
@@ -38,11 +38,11 @@
38
38
  "devDependencies": {
39
39
  "@types/react": "19.2.14",
40
40
  "@types/react-dom": "19.2.3",
41
- "@vitejs/plugin-react": "^5.1.4",
41
+ "@vitejs/plugin-react": "^6.0.1",
42
42
  "typescript": "^5.9.3",
43
- "vite": "^7.3.1",
43
+ "vite": "^8.0.1",
44
44
  "vite-plugin-dts": "^4.5.4",
45
- "vitest": "^4.0.18"
45
+ "vitest": "^4.1.0"
46
46
  },
47
47
  "scripts": {
48
48
  "build": "vite build",
@@ -1,96 +0,0 @@
1
- import { jsx as t, jsxs as a } from "react/jsx-runtime";
2
- import { L as r, I as c } from "./index-D2t9pLAg.js";
3
- import "react";
4
- function p({ value: o, onChange: h, field: u, readonly: i, ...l }) {
5
- const s = o || {}, d = (e, n) => {
6
- h({
7
- ...s,
8
- [e]: n
9
- });
10
- }, m = (e) => [
11
- e.street,
12
- e.city,
13
- [e.state, e.zipCode].filter(Boolean).join(" "),
14
- e.country
15
- ].filter(Boolean).join(", ") || "-";
16
- return i ? /* @__PURE__ */ t("span", { className: "text-sm", children: m(s) }) : /* @__PURE__ */ a("div", { className: "space-y-3", children: [
17
- /* @__PURE__ */ a("div", { children: [
18
- /* @__PURE__ */ t(r, { htmlFor: "street", className: "text-xs", children: "Street Address" }),
19
- /* @__PURE__ */ t(
20
- c,
21
- {
22
- id: "street",
23
- type: "text",
24
- value: s.street || "",
25
- onChange: (e) => d("street", e.target.value),
26
- placeholder: "123 Main St",
27
- disabled: i || l.disabled,
28
- className: l.className
29
- }
30
- )
31
- ] }),
32
- /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-3", children: [
33
- /* @__PURE__ */ a("div", { children: [
34
- /* @__PURE__ */ t(r, { htmlFor: "city", className: "text-xs", children: "City" }),
35
- /* @__PURE__ */ t(
36
- c,
37
- {
38
- id: "city",
39
- type: "text",
40
- value: s.city || "",
41
- onChange: (e) => d("city", e.target.value),
42
- placeholder: "San Francisco",
43
- disabled: i || l.disabled
44
- }
45
- )
46
- ] }),
47
- /* @__PURE__ */ a("div", { children: [
48
- /* @__PURE__ */ t(r, { htmlFor: "state", className: "text-xs", children: "State / Province" }),
49
- /* @__PURE__ */ t(
50
- c,
51
- {
52
- id: "state",
53
- type: "text",
54
- value: s.state || "",
55
- onChange: (e) => d("state", e.target.value),
56
- placeholder: "CA",
57
- disabled: i || l.disabled
58
- }
59
- )
60
- ] })
61
- ] }),
62
- /* @__PURE__ */ a("div", { className: "grid grid-cols-2 gap-3", children: [
63
- /* @__PURE__ */ a("div", { children: [
64
- /* @__PURE__ */ t(r, { htmlFor: "zipCode", className: "text-xs", children: "ZIP / Postal Code" }),
65
- /* @__PURE__ */ t(
66
- c,
67
- {
68
- id: "zipCode",
69
- type: "text",
70
- value: s.zipCode || "",
71
- onChange: (e) => d("zipCode", e.target.value),
72
- placeholder: "94102",
73
- disabled: i || l.disabled
74
- }
75
- )
76
- ] }),
77
- /* @__PURE__ */ a("div", { children: [
78
- /* @__PURE__ */ t(r, { htmlFor: "country", className: "text-xs", children: "Country" }),
79
- /* @__PURE__ */ t(
80
- c,
81
- {
82
- id: "country",
83
- type: "text",
84
- value: s.country || "",
85
- onChange: (e) => d("country", e.target.value),
86
- placeholder: "United States",
87
- disabled: i || l.disabled
88
- }
89
- )
90
- ] })
91
- ] })
92
- ] });
93
- }
94
- export {
95
- p as AddressField
96
- };
@@ -1,8 +0,0 @@
1
- import { jsx as o } from "react/jsx-runtime";
2
- function l({ value: t, field: r, ...e }) {
3
- const n = t != null ? String(t) : "-";
4
- return /* @__PURE__ */ o("span", { className: `text-sm font-mono text-gray-700 ${e.className || ""}`, children: n });
5
- }
6
- export {
7
- l as AutoNumberField
8
- };
@@ -1,82 +0,0 @@
1
- import { jsxs as s, jsx as e } from "react/jsx-runtime";
2
- import f from "react";
3
- import { A as h, n as p, l as g, X as A, B as F, U as R } from "./index-D2t9pLAg.js";
4
- function B({ value: t, onChange: i, field: v, readonly: l, ...c }) {
5
- const [b, o] = f.useState(!1), d = f.useRef(null), r = v || c.schema, N = (u) => {
6
- const a = u.target.files?.[0];
7
- if (!a) return;
8
- if (!a.type.startsWith("image/")) {
9
- console.error("Please select an image file");
10
- return;
11
- }
12
- if (a.size > 5 * 1024 * 1024) {
13
- console.error("File size must be less than 5MB");
14
- return;
15
- }
16
- const n = new FileReader();
17
- n.onloadend = () => {
18
- i(n.result);
19
- }, n.readAsDataURL(a);
20
- }, x = () => {
21
- i("");
22
- }, m = () => (r?.defaultName || r?.label || "User").split(" ").map((a) => a[0]).join("").toUpperCase().slice(0, 2);
23
- return l ? /* @__PURE__ */ s(h, { className: "w-16 h-16", children: [
24
- t && /* @__PURE__ */ e(p, { src: t, alt: r?.label }),
25
- /* @__PURE__ */ e(g, { children: m() })
26
- ] }) : /* @__PURE__ */ s("div", { className: "flex items-center gap-4", children: [
27
- /* @__PURE__ */ s(
28
- "div",
29
- {
30
- className: "relative",
31
- onMouseEnter: () => o(!0),
32
- onMouseLeave: () => o(!1),
33
- children: [
34
- /* @__PURE__ */ s(h, { className: "w-16 h-16", children: [
35
- t && /* @__PURE__ */ e(p, { src: t, alt: r?.label }),
36
- /* @__PURE__ */ e(g, { children: m() })
37
- ] }),
38
- !l && b && t && /* @__PURE__ */ e(
39
- "button",
40
- {
41
- type: "button",
42
- onClick: x,
43
- className: "absolute -top-1 -right-1 bg-destructive text-destructive-foreground rounded-full p-1 hover:bg-destructive/90",
44
- children: /* @__PURE__ */ e(A, { className: "w-3 h-3" })
45
- }
46
- )
47
- ]
48
- }
49
- ),
50
- /* @__PURE__ */ s("div", { className: "flex flex-col gap-2", children: [
51
- /* @__PURE__ */ e(
52
- "input",
53
- {
54
- ref: d,
55
- type: "file",
56
- accept: "image/*",
57
- onChange: N,
58
- className: "hidden"
59
- }
60
- ),
61
- /* @__PURE__ */ s(
62
- F,
63
- {
64
- type: "button",
65
- variant: "outline",
66
- size: "sm",
67
- onClick: () => d.current?.click(),
68
- disabled: l || c.disabled,
69
- children: [
70
- /* @__PURE__ */ e(R, { className: "w-4 h-4 mr-2" }),
71
- t ? "Change" : "Upload",
72
- " Avatar"
73
- ]
74
- }
75
- ),
76
- /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: "PNG, JPG up to 5MB" })
77
- ] })
78
- ] });
79
- }
80
- export {
81
- B as AvatarField
82
- };
@@ -1,37 +0,0 @@
1
- import { jsx as e, jsxs as a } from "react/jsx-runtime";
2
- import { useId as f } from "react";
3
- import { C as p, L as l, S as k } from "./index-D2t9pLAg.js";
4
- function w({ value: t, onChange: n, field: h, readonly: i, ...o }) {
5
- const d = h || o.schema, m = d?.widget, x = f(), c = d?.name || x, r = d?.label || "Checkbox";
6
- if (i)
7
- return /* @__PURE__ */ e("span", { className: "text-sm", children: t ? "Yes" : "No" });
8
- const { inputType: C, ...s } = o;
9
- return m === "checkbox" ? /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
10
- /* @__PURE__ */ e(
11
- p,
12
- {
13
- ...s,
14
- id: c,
15
- checked: !!t,
16
- onCheckedChange: (b) => n(!!b),
17
- disabled: i || s.disabled
18
- }
19
- ),
20
- /* @__PURE__ */ e(l, { htmlFor: c, children: r })
21
- ] }) : /* @__PURE__ */ a("div", { className: "flex items-center space-x-2", children: [
22
- /* @__PURE__ */ e(
23
- k,
24
- {
25
- ...s,
26
- id: c,
27
- checked: !!t,
28
- onCheckedChange: n,
29
- disabled: i || s.disabled
30
- }
31
- ),
32
- /* @__PURE__ */ e(l, { htmlFor: c, children: r })
33
- ] });
34
- }
35
- export {
36
- w as BooleanField
37
- };
@@ -1,21 +0,0 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { i as l, T as i } from "./index-D2t9pLAg.js";
3
- import "react";
4
- function g({ value: o, onChange: s, field: c, readonly: r, ...e }) {
5
- const t = c || e.schema, n = t?.language ?? "javascript";
6
- return r ? /* @__PURE__ */ a("pre", { className: l("text-sm bg-muted p-2 rounded overflow-x-auto border", e.className), children: /* @__PURE__ */ a("code", { children: o || "-" }) }) : /* @__PURE__ */ a(
7
- i,
8
- {
9
- value: o || "",
10
- onChange: (d) => s(d.target.value),
11
- placeholder: t?.placeholder || `// Write ${n} code here...`,
12
- disabled: r || e.disabled,
13
- className: l("font-mono text-sm", e.className),
14
- rows: 12,
15
- spellCheck: !1
16
- }
17
- );
18
- }
19
- export {
20
- g as CodeField
21
- };
@@ -1,42 +0,0 @@
1
- import { jsxs as d, jsx as a } from "react/jsx-runtime";
2
- import { I as c } from "./index-D2t9pLAg.js";
3
- import "react";
4
- function p({ value: e, onChange: l, field: i, readonly: t, ...r }) {
5
- const o = i || r.schema;
6
- return t ? /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
7
- /* @__PURE__ */ a(
8
- "div",
9
- {
10
- className: "w-6 h-6 rounded border border-input",
11
- style: { backgroundColor: e || "#000000" }
12
- }
13
- ),
14
- /* @__PURE__ */ a("span", { className: "text-sm", children: e || "-" })
15
- ] }) : /* @__PURE__ */ d("div", { className: "flex items-center gap-2", children: [
16
- /* @__PURE__ */ a(
17
- "input",
18
- {
19
- type: "color",
20
- value: e || "#000000",
21
- onChange: (s) => l(s.target.value),
22
- disabled: t || r.disabled,
23
- className: "w-10 h-10 rounded border border-input cursor-pointer"
24
- }
25
- ),
26
- /* @__PURE__ */ a(
27
- c,
28
- {
29
- type: "text",
30
- value: e || "",
31
- onChange: (s) => l(s.target.value),
32
- placeholder: o?.placeholder || "#000000",
33
- disabled: t || r.disabled,
34
- className: r.className,
35
- pattern: "^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$"
36
- }
37
- )
38
- ] });
39
- }
40
- export {
41
- p as ColorField
42
- };
@@ -1,43 +0,0 @@
1
- import { jsx as n, jsxs as p } from "react/jsx-runtime";
2
- import { I as f } from "./index-D2t9pLAg.js";
3
- import "react";
4
- function h(e, t = "USD") {
5
- try {
6
- return new Intl.NumberFormat("en-US", {
7
- style: "currency",
8
- currency: t
9
- }).format(e);
10
- } catch {
11
- return `${t} ${e.toFixed(2)}`;
12
- }
13
- }
14
- function b({ value: e, onChange: t, field: u, readonly: o, errorMessage: m, className: d, ...l }) {
15
- const s = u || l.schema, c = s?.currency || "USD", i = s?.precision ?? 2;
16
- return o ? e == null ? /* @__PURE__ */ n("span", { className: "text-sm", children: "-" }) : /* @__PURE__ */ n("span", { className: "text-sm font-medium tabular-nums", children: h(Number(e), c) }) : /* @__PURE__ */ p("div", { className: "relative", children: [
17
- /* @__PURE__ */ n("span", { className: "absolute left-3 top-1/2 -translate-y-1/2 text-sm text-gray-500", children: c === "USD" ? "$" : c }),
18
- /* @__PURE__ */ n(
19
- f,
20
- {
21
- ...l,
22
- type: "number",
23
- value: e ?? "",
24
- onChange: (r) => {
25
- const a = r.target.value === "" ? null : parseFloat(r.target.value);
26
- t(a);
27
- },
28
- onBlur: (r) => {
29
- const a = parseFloat(r.target.value);
30
- isNaN(a) || t(parseFloat(a.toFixed(i)));
31
- },
32
- placeholder: s?.placeholder || "0.00",
33
- disabled: o || l.disabled,
34
- className: `pl-8 ${d || ""}`,
35
- step: Math.pow(10, -i).toFixed(i),
36
- "aria-invalid": !!m
37
- }
38
- )
39
- ] });
40
- }
41
- export {
42
- b as CurrencyField
43
- };
@@ -1,21 +0,0 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { I as p } from "./index-D2t9pLAg.js";
3
- import "react";
4
- function f({ value: t, onChange: i, field: s, readonly: e, ...n }) {
5
- if (e)
6
- return /* @__PURE__ */ a("span", { className: "text-sm", children: t ? new Date(t).toLocaleDateString() : "-" });
7
- const { inputType: d, ...r } = n;
8
- return /* @__PURE__ */ a(
9
- p,
10
- {
11
- ...r,
12
- type: "date",
13
- value: t || "",
14
- onChange: (o) => i(o.target.value),
15
- disabled: e || r.disabled
16
- }
17
- );
18
- }
19
- export {
20
- f as DateField
21
- };
@@ -1,28 +0,0 @@
1
- import { jsx as n, jsxs as o } from "react/jsx-runtime";
2
- import { I as m } from "./index-D2t9pLAg.js";
3
- import "react";
4
- function u({ value: e, onChange: r, field: l, readonly: a, ...s }) {
5
- if (a) {
6
- if (!e) return /* @__PURE__ */ n("span", { className: "text-sm", children: "-" });
7
- const t = new Date(e);
8
- return /* @__PURE__ */ o("span", { className: "text-sm", children: [
9
- t.toLocaleDateString(),
10
- " ",
11
- t.toLocaleTimeString()
12
- ] });
13
- }
14
- const { inputType: p, ...i } = s;
15
- return /* @__PURE__ */ n(
16
- m,
17
- {
18
- ...i,
19
- type: "datetime-local",
20
- value: e || "",
21
- onChange: (t) => r(t.target.value),
22
- disabled: a || i.disabled
23
- }
24
- );
25
- }
26
- export {
27
- u as DateTimeField
28
- };
@@ -1,31 +0,0 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { I as c } from "./index-D2t9pLAg.js";
3
- import "react";
4
- function f({ value: e, onChange: l, field: m, readonly: i, errorMessage: n, ...r }) {
5
- const o = m || r.schema;
6
- if (i)
7
- return e ? /* @__PURE__ */ t(
8
- "a",
9
- {
10
- href: `mailto:${e}`,
11
- className: "text-sm text-blue-600 hover:text-blue-800 hover:underline",
12
- children: e
13
- }
14
- ) : /* @__PURE__ */ t("span", { className: "text-sm", children: "-" });
15
- const { inputType: d, ...a } = r;
16
- return /* @__PURE__ */ t(
17
- c,
18
- {
19
- ...a,
20
- type: "email",
21
- value: e || "",
22
- onChange: (s) => l(s.target.value),
23
- placeholder: o?.placeholder || "email@example.com",
24
- disabled: i || a.disabled,
25
- "aria-invalid": !!n
26
- }
27
- );
28
- }
29
- export {
30
- f as EmailField
31
- };
@@ -1,133 +0,0 @@
1
- import { jsx as t, jsxs as o } from "react/jsx-runtime";
2
- import { useRef as I, useState as k, useCallback as g } from "react";
3
- import { U as P, k as U, F as $, B as C, X as E } from "./index-D2t9pLAg.js";
4
- function M({ value: n, onChange: c, field: w, readonly: j, ...b }) {
5
- const y = I(null), m = w || b.schema, d = m?.multiple || !1, p = m?.accept ? m.accept.join(",") : void 0, u = m?.maxSize, [N, v] = k(!1), [D, A] = k([]), l = n ? Array.isArray(n) ? n : [n] : [], f = g((e) => {
6
- if (e.length === 0) return;
7
- const r = [], a = e.filter((s) => {
8
- if (u && s.size > u) {
9
- const x = (u / 1048576).toFixed(1);
10
- return r.push(`"${s.name}" exceeds max size (${x} MB)`), !1;
11
- }
12
- return !0;
13
- });
14
- if (A(r), a.length === 0) return;
15
- const i = a.map((s) => ({
16
- name: s.name,
17
- original_name: s.name,
18
- size: s.size,
19
- mime_type: s.type,
20
- // In a real implementation, this would upload the file and return a URL
21
- url: URL.createObjectURL(s)
22
- }));
23
- c(d ? [...l, ...i] : i[0]);
24
- }, [l, d, c, u]), L = g((e) => {
25
- e.preventDefault(), e.stopPropagation(), v(!0);
26
- }, []), O = g((e) => {
27
- e.preventDefault(), e.stopPropagation(), v(!1);
28
- }, []), _ = g((e) => {
29
- e.preventDefault(), e.stopPropagation(), v(!1);
30
- const r = Array.from(e.dataTransfer.files);
31
- if (p) {
32
- const a = p.split(",").map((s) => s.trim().toLowerCase()), i = r.filter((s) => {
33
- const x = s.name.split("."), F = x.length > 1 ? "." + x.pop()?.toLowerCase() : "";
34
- return a.some(
35
- (h) => h === s.type || F && h === F || h.endsWith("/*") && s.type.startsWith(h.replace("/*", "/"))
36
- );
37
- });
38
- f(i);
39
- } else
40
- f(r);
41
- }, [p, f]);
42
- if (j) {
43
- if (!n) return /* @__PURE__ */ t("span", { className: "text-sm", children: "-" });
44
- const e = Array.isArray(n) ? n : [n];
45
- return /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-2", children: e.map((r, a) => /* @__PURE__ */ t("span", { className: "text-sm truncate max-w-xs", children: r.name || r.original_name || "File" }, a)) });
46
- }
47
- const B = (e) => {
48
- f(Array.from(e.target.files || []));
49
- }, R = (e) => {
50
- if (d) {
51
- const r = l.filter((a, i) => i !== e);
52
- c(r.length > 0 ? r : null);
53
- } else
54
- c(null);
55
- }, z = (e) => (e.mime_type || "").startsWith("image/");
56
- return /* @__PURE__ */ o("div", { className: b.className, children: [
57
- /* @__PURE__ */ t(
58
- "input",
59
- {
60
- ref: y,
61
- type: "file",
62
- multiple: d,
63
- accept: p,
64
- onChange: B,
65
- className: "hidden"
66
- }
67
- ),
68
- /* @__PURE__ */ o("div", { className: "space-y-2", children: [
69
- /* @__PURE__ */ o(
70
- "div",
71
- {
72
- onDragOver: L,
73
- onDragLeave: O,
74
- onDrop: _,
75
- onClick: () => y.current?.click(),
76
- className: `
77
- flex flex-col items-center justify-center gap-2 p-6
78
- border-2 border-dashed rounded-lg cursor-pointer
79
- transition-colors duration-200
80
- ${N ? "border-primary bg-primary/5 text-primary" : "border-muted-foreground/25 hover:border-primary/50 text-muted-foreground hover:text-foreground"}
81
- `,
82
- role: "button",
83
- tabIndex: 0,
84
- onKeyDown: (e) => {
85
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), y.current?.click());
86
- },
87
- children: [
88
- /* @__PURE__ */ t(P, { className: `size-8 ${N ? "text-primary" : "text-muted-foreground"}` }),
89
- /* @__PURE__ */ o("div", { className: "text-center", children: [
90
- /* @__PURE__ */ t("p", { className: "text-sm font-medium", children: N ? "Drop files here" : "Drag & drop files here" }),
91
- /* @__PURE__ */ t("p", { className: "text-xs text-muted-foreground mt-1", children: "or click to browse" })
92
- ] })
93
- ]
94
- }
95
- ),
96
- D.length > 0 && /* @__PURE__ */ t("div", { className: "space-y-0.5", children: D.map((e, r) => /* @__PURE__ */ t("p", { className: "text-xs text-destructive", children: e }, r)) }),
97
- l.length > 0 && /* @__PURE__ */ t("div", { className: "space-y-1", children: l.map((e, r) => /* @__PURE__ */ o(
98
- "div",
99
- {
100
- className: "flex items-center justify-between gap-2 p-2 bg-muted/50 rounded-md border",
101
- children: [
102
- /* @__PURE__ */ o("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
103
- z(e) && e.url ? /* @__PURE__ */ t("img", { src: e.url, alt: e.name, className: "size-8 object-cover rounded flex-shrink-0" }) : z(e) ? /* @__PURE__ */ t(U, { className: "size-4 text-muted-foreground flex-shrink-0" }) : /* @__PURE__ */ t($, { className: "size-4 text-muted-foreground flex-shrink-0" }),
104
- /* @__PURE__ */ t("span", { className: "text-sm truncate", children: e.name || e.original_name || "File" }),
105
- e.size && /* @__PURE__ */ o("span", { className: "text-xs text-muted-foreground", children: [
106
- "(",
107
- (e.size / 1024).toFixed(1),
108
- " KB)"
109
- ] })
110
- ] }),
111
- /* @__PURE__ */ t(
112
- C,
113
- {
114
- type: "button",
115
- variant: "ghost",
116
- size: "sm",
117
- onClick: (a) => {
118
- a.stopPropagation(), R(r);
119
- },
120
- className: "h-6 w-6 p-0",
121
- children: /* @__PURE__ */ t(E, { className: "size-3" })
122
- }
123
- )
124
- ]
125
- },
126
- r
127
- )) })
128
- ] })
129
- ] });
130
- }
131
- export {
132
- M as FileField
133
- };
@@ -1,9 +0,0 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- function m({ value: e, field: o, ...r }) {
3
- const n = (o || r.schema)?.return_type || "text";
4
- let t = "-";
5
- return e != null && (n === "number" || n === "currency" ? t = typeof e == "number" ? e.toFixed(2) : String(e) : n === "boolean" ? t = e ? "Yes" : "No" : n === "date" ? t = new Date(e).toLocaleDateString() : t = String(e)), /* @__PURE__ */ i("span", { className: `text-sm font-mono text-gray-700 ${r.className || ""}`, children: t });
6
- }
7
- export {
8
- m as FormulaField
9
- };