@object-ui/plugin-aggrid 0.4.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/.turbo/turbo-build.log +99 -0
  2. package/CHANGELOG.md +16 -0
  3. package/OBJECT_AGGRID_CN.md +483 -0
  4. package/QUICKSTART.md +186 -0
  5. package/README.md +221 -1
  6. package/dist/AddressField-Bntpynvd.js +95 -0
  7. package/dist/AgGridImpl-3Mmf2qrR.js +229 -0
  8. package/dist/AutoNumberField-C1kBJaxh.js +8 -0
  9. package/dist/FileField-BDwbJvor.js +101 -0
  10. package/dist/FormulaField-BXNiyGoh.js +9 -0
  11. package/dist/GeolocationField-Df3yYcM9.js +141 -0
  12. package/dist/GridField-CcjQp4WM.js +29 -0
  13. package/dist/LocationField-BIfN5QIq.js +33 -0
  14. package/dist/MasterDetailField-CAEmxbIT.js +117 -0
  15. package/dist/ObjectAgGridImpl-EjifM4aY.js +28727 -0
  16. package/dist/ObjectField-BpkQpIF-.js +51 -0
  17. package/dist/QRCodeField-VCBewTDG.js +96 -0
  18. package/dist/RichTextField-CyQwSi2C.js +37 -0
  19. package/dist/SignatureField-Cr4tsEbj.js +96 -0
  20. package/dist/SummaryField-CnEJ_GZI.js +9 -0
  21. package/dist/UserField-DJjaVyrV.js +49 -0
  22. package/dist/VectorField-cPYmcKnV.js +25 -0
  23. package/dist/{index-B6NPAFZx.js → index-B87wd1E0.js} +301 -143
  24. package/dist/index.css +1 -1
  25. package/dist/index.js +4 -3
  26. package/dist/index.umd.cjs +225 -2
  27. package/dist/src/AgGridImpl.d.ts +5 -2
  28. package/dist/src/ObjectAgGridImpl.d.ts +6 -0
  29. package/dist/src/VirtualScrolling.d.ts +72 -0
  30. package/dist/src/field-renderers.d.ts +67 -0
  31. package/dist/src/index.d.ts +47 -2
  32. package/dist/src/object-aggrid.types.d.ts +74 -0
  33. package/dist/src/types.d.ts +48 -1
  34. package/package.json +11 -9
  35. package/src/AgGridImpl.tsx +100 -11
  36. package/src/ObjectAgGridImpl.tsx +501 -0
  37. package/src/VirtualScrolling.ts +74 -0
  38. package/src/field-renderers.test.tsx +383 -0
  39. package/src/field-renderers.tsx +224 -0
  40. package/src/index.test.ts +1 -1
  41. package/src/index.tsx +211 -2
  42. package/src/object-aggrid.test.ts +99 -0
  43. package/src/object-aggrid.types.ts +123 -0
  44. package/src/types.ts +57 -1
  45. package/vite.config.ts +13 -0
  46. package/dist/AgGridImpl-DKkq6v1B.js +0 -171
@@ -0,0 +1,51 @@
1
+ import { j as t } from "./index-B87wd1E0.js";
2
+ import { useState as m, useEffect as h } from "react";
3
+ import { cn as u, Textarea as y } from "@object-ui/components";
4
+ function p({ value: r, onChange: c, field: x, readonly: a, ...s }) {
5
+ const g = x || s.schema, N = () => r == null ? "" : JSON.stringify(r, null, 2), [e, n] = m(N), [i, d] = m(null);
6
+ if (h(() => {
7
+ try {
8
+ if (r == null) {
9
+ n("");
10
+ return;
11
+ }
12
+ const l = e ? JSON.parse(e) : null;
13
+ JSON.stringify(l) !== JSON.stringify(r) && n(JSON.stringify(r, null, 2));
14
+ } catch {
15
+ n(JSON.stringify(r, null, 2));
16
+ }
17
+ }, [r, e]), a)
18
+ return r ? /* @__PURE__ */ t.jsx("pre", { className: u("text-xs bg-gray-50 p-2 rounded border border-gray-200 overflow-auto max-h-40", s.className), children: JSON.stringify(r, null, 2) }) : /* @__PURE__ */ t.jsx("span", { className: "text-sm", children: "-" });
19
+ const S = (l) => {
20
+ const o = l.target.value;
21
+ if (n(o), d(null), !o.trim()) {
22
+ c(null);
23
+ return;
24
+ }
25
+ try {
26
+ const f = JSON.parse(o);
27
+ c(f);
28
+ } catch {
29
+ d("Invalid JSON");
30
+ }
31
+ };
32
+ return /* @__PURE__ */ t.jsxs("div", { className: "space-y-1", children: [
33
+ /* @__PURE__ */ t.jsx(
34
+ y,
35
+ {
36
+ value: e,
37
+ onChange: S,
38
+ placeholder: g?.placeholder || `{
39
+ "key": "value"
40
+ }`,
41
+ disabled: a || s.disabled,
42
+ className: u("font-mono text-xs", i ? "border-red-500 focus-visible:ring-red-500" : "", s.className),
43
+ rows: 6
44
+ }
45
+ ),
46
+ i && /* @__PURE__ */ t.jsx("p", { className: "text-xs text-red-500", children: i })
47
+ ] });
48
+ }
49
+ export {
50
+ p as ObjectField
51
+ };
@@ -0,0 +1,96 @@
1
+ import { j as e } from "./index-B87wd1E0.js";
2
+ import y from "react";
3
+ import { Button as a, Input as j } from "@object-ui/components";
4
+ import { c as d } from "./ObjectAgGridImpl-EjifM4aY.js";
5
+ const g = [
6
+ ["rect", { width: "14", height: "14", x: "8", y: "8", rx: "2", ry: "2", key: "17jyea" }],
7
+ ["path", { d: "M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2", key: "zix9uf" }]
8
+ ], k = d("copy", g);
9
+ const f = [
10
+ ["rect", { width: "5", height: "5", x: "3", y: "3", rx: "1", key: "1tu5fj" }],
11
+ ["rect", { width: "5", height: "5", x: "16", y: "3", rx: "1", key: "1v8r4q" }],
12
+ ["rect", { width: "5", height: "5", x: "3", y: "16", rx: "1", key: "1x03jg" }],
13
+ ["path", { d: "M21 16h-3a2 2 0 0 0-2 2v3", key: "177gqh" }],
14
+ ["path", { d: "M21 21v.01", key: "ents32" }],
15
+ ["path", { d: "M12 7v3a2 2 0 0 1-2 2H7", key: "8crl2c" }],
16
+ ["path", { d: "M3 12h.01", key: "nlz23k" }],
17
+ ["path", { d: "M12 3h.01", key: "n36tog" }],
18
+ ["path", { d: "M12 16v.01", key: "133mhm" }],
19
+ ["path", { d: "M16 12h1", key: "1slzba" }],
20
+ ["path", { d: "M21 12v.01", key: "1lwtk9" }],
21
+ ["path", { d: "M12 21v-1", key: "1880an" }]
22
+ ], n = d("qr-code", f);
23
+ function R({ value: t, onChange: h, field: l, readonly: o, ...c }) {
24
+ const [s, i] = y.useState(!1), x = l || c.schema, m = (r) => `https://api.qrserver.com/v1/create-qr-code/?size=200x200&data=${encodeURIComponent(r)}`, p = () => {
25
+ t && navigator.clipboard.writeText(t);
26
+ };
27
+ return o ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-3", children: [
28
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm flex-1 truncate", children: t || "-" }),
29
+ t && /* @__PURE__ */ e.jsxs(
30
+ a,
31
+ {
32
+ type: "button",
33
+ variant: "outline",
34
+ size: "sm",
35
+ onClick: () => i(!s),
36
+ children: [
37
+ /* @__PURE__ */ e.jsx(n, { className: "w-4 h-4 mr-2" }),
38
+ s ? "Hide" : "Show",
39
+ " QR"
40
+ ]
41
+ }
42
+ )
43
+ ] }) : /* @__PURE__ */ e.jsxs("div", { className: "space-y-3", children: [
44
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2", children: [
45
+ /* @__PURE__ */ e.jsx(
46
+ j,
47
+ {
48
+ type: "text",
49
+ value: t || "",
50
+ onChange: (r) => h(r.target.value),
51
+ placeholder: x?.placeholder || "Enter text for QR code",
52
+ disabled: o || c.disabled,
53
+ className: c.className
54
+ }
55
+ ),
56
+ t && /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
57
+ /* @__PURE__ */ e.jsx(
58
+ a,
59
+ {
60
+ type: "button",
61
+ variant: "outline",
62
+ size: "sm",
63
+ onClick: p,
64
+ children: /* @__PURE__ */ e.jsx(k, { className: "w-4 h-4" })
65
+ }
66
+ ),
67
+ /* @__PURE__ */ e.jsx(
68
+ a,
69
+ {
70
+ type: "button",
71
+ variant: "outline",
72
+ size: "sm",
73
+ onClick: () => i(!s),
74
+ children: /* @__PURE__ */ e.jsx(n, { className: "w-4 h-4" })
75
+ }
76
+ )
77
+ ] })
78
+ ] }),
79
+ s && t && /* @__PURE__ */ e.jsx("div", { className: "border rounded p-4 bg-white flex justify-center", children: /* @__PURE__ */ e.jsx(
80
+ "img",
81
+ {
82
+ src: m(t),
83
+ alt: "QR Code",
84
+ className: "w-48 h-48"
85
+ }
86
+ ) }),
87
+ t && /* @__PURE__ */ e.jsxs("p", { className: "text-xs text-muted-foreground", children: [
88
+ "QR code contains: ",
89
+ t.length,
90
+ " characters"
91
+ ] })
92
+ ] });
93
+ }
94
+ export {
95
+ R as QRCodeField
96
+ };
@@ -0,0 +1,37 @@
1
+ import { j as e } from "./index-B87wd1E0.js";
2
+ import { Textarea as x } from "@object-ui/components";
3
+ function f({ value: a, onChange: i, field: c, readonly: r, errorMessage: n, ...s }) {
4
+ if (r)
5
+ return /* @__PURE__ */ e.jsx(
6
+ "div",
7
+ {
8
+ className: "text-sm prose prose-sm max-w-none",
9
+ children: a || "-"
10
+ }
11
+ );
12
+ const t = c || s.schema, o = t?.rows || 8, l = t?.format || "markdown";
13
+ return /* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
14
+ /* @__PURE__ */ e.jsxs("div", { className: "flex items-center justify-between text-xs text-gray-500", children: [
15
+ /* @__PURE__ */ e.jsxs("span", { children: [
16
+ "Format: ",
17
+ l
18
+ ] }),
19
+ /* @__PURE__ */ e.jsx("span", { className: "italic", children: "Rich text editor (basic)" })
20
+ ] }),
21
+ /* @__PURE__ */ e.jsx(
22
+ x,
23
+ {
24
+ value: a || "",
25
+ onChange: (m) => i(m.target.value),
26
+ placeholder: t?.placeholder || "Enter text...",
27
+ disabled: r || s.disabled,
28
+ rows: o,
29
+ className: `font-mono text-sm ${s.className || ""}`,
30
+ "aria-invalid": !!n
31
+ }
32
+ )
33
+ ] });
34
+ }
35
+ export {
36
+ f as RichTextField
37
+ };
@@ -0,0 +1,96 @@
1
+ import { j as s } from "./index-B87wd1E0.js";
2
+ import w, { useRef as v, useEffect as N } from "react";
3
+ import { Button as b } from "@object-ui/components";
4
+ import { c as S } from "./ObjectAgGridImpl-EjifM4aY.js";
5
+ const C = [
6
+ [
7
+ "path",
8
+ {
9
+ d: "M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",
10
+ key: "g5wo59"
11
+ }
12
+ ],
13
+ ["path", { d: "m5.082 11.09 8.828 8.828", key: "1wx5vj" }]
14
+ ], R = S("eraser", C);
15
+ function k({ value: o, onChange: f, readonly: i }) {
16
+ const r = v(null), [m, h] = w.useState(!1), [g, a] = w.useState(!o);
17
+ N(() => {
18
+ if (o && r.current) {
19
+ const e = r.current.getContext("2d");
20
+ if (e) {
21
+ const n = new Image();
22
+ n.onload = () => {
23
+ e.drawImage(n, 0, 0), a(!1);
24
+ }, n.src = o;
25
+ }
26
+ }
27
+ }, [o]);
28
+ const x = (t) => {
29
+ if (i) return;
30
+ h(!0), a(!1);
31
+ const e = r.current;
32
+ if (!e) return;
33
+ const n = e.getContext("2d");
34
+ if (!n) return;
35
+ const c = e.getBoundingClientRect(), l = "touches" in t ? t.touches[0].clientX - c.left : t.clientX - c.left, d = "touches" in t ? t.touches[0].clientY - c.top : t.clientY - c.top;
36
+ n.beginPath(), n.moveTo(l, d);
37
+ }, p = (t) => {
38
+ if (!m || i) return;
39
+ const e = r.current;
40
+ if (!e) return;
41
+ const n = e.getContext("2d");
42
+ if (!n) return;
43
+ const c = e.getBoundingClientRect(), l = "touches" in t ? t.touches[0].clientX - c.left : t.clientX - c.left, d = "touches" in t ? t.touches[0].clientY - c.top : t.clientY - c.top;
44
+ n.lineTo(l, d), n.strokeStyle = "#000", n.lineWidth = 2, n.lineCap = "round", n.lineJoin = "round", n.stroke();
45
+ }, u = () => {
46
+ if (!m) return;
47
+ h(!1);
48
+ const t = r.current;
49
+ if (!t) return;
50
+ const e = t.toDataURL("image/png");
51
+ f(e);
52
+ }, j = () => {
53
+ const t = r.current;
54
+ if (!t) return;
55
+ const e = t.getContext("2d");
56
+ e && (e.clearRect(0, 0, t.width, t.height), a(!0), f(""));
57
+ };
58
+ return i && o ? /* @__PURE__ */ s.jsx("div", { className: "border rounded p-2 bg-white", children: /* @__PURE__ */ s.jsx("img", { src: o, alt: "Signature", className: "max-w-full h-auto" }) }) : i && !o ? /* @__PURE__ */ s.jsx("span", { className: "text-sm text-muted-foreground", children: "No signature" }) : /* @__PURE__ */ s.jsxs("div", { className: "space-y-2", children: [
59
+ /* @__PURE__ */ s.jsx("div", { className: "border rounded bg-white", children: /* @__PURE__ */ s.jsx(
60
+ "canvas",
61
+ {
62
+ ref: r,
63
+ width: 400,
64
+ height: 200,
65
+ className: "w-full touch-none cursor-crosshair",
66
+ onMouseDown: x,
67
+ onMouseMove: p,
68
+ onMouseUp: u,
69
+ onMouseLeave: u,
70
+ onTouchStart: x,
71
+ onTouchMove: p,
72
+ onTouchEnd: u
73
+ }
74
+ ) }),
75
+ /* @__PURE__ */ s.jsxs("div", { className: "flex justify-between items-center", children: [
76
+ /* @__PURE__ */ s.jsx("p", { className: "text-xs text-muted-foreground", children: g ? "Sign above" : "Signature captured" }),
77
+ /* @__PURE__ */ s.jsxs(
78
+ b,
79
+ {
80
+ type: "button",
81
+ variant: "outline",
82
+ size: "sm",
83
+ onClick: j,
84
+ disabled: i || g,
85
+ children: [
86
+ /* @__PURE__ */ s.jsx(R, { className: "w-4 h-4 mr-2" }),
87
+ "Clear"
88
+ ]
89
+ }
90
+ )
91
+ ] })
92
+ ] });
93
+ }
94
+ export {
95
+ k as SignatureField
96
+ };
@@ -0,0 +1,9 @@
1
+ import { j as i } from "./index-B87wd1E0.js";
2
+ function u({ value: m, field: n, ...s }) {
3
+ const e = (n || s.schema)?.summary_type || "count";
4
+ let t = "-";
5
+ return m != null && (e === "count" ? t = String(m) : ["sum", "avg", "min", "max"].includes(e) ? t = typeof m == "number" ? m.toFixed(2) : String(m) : t = String(m)), /* @__PURE__ */ i.jsx("span", { className: `text-sm font-medium tabular-nums text-gray-700 ${s.className || ""}`, children: t });
6
+ }
7
+ export {
8
+ u as SummaryField
9
+ };
@@ -0,0 +1,49 @@
1
+ import { j as e } from "./index-B87wd1E0.js";
2
+ import { Avatar as c, AvatarFallback as m, Badge as g } from "@object-ui/components";
3
+ import { X as N } from "./ObjectAgGridImpl-EjifM4aY.js";
4
+ function U({ value: s, onChange: o, field: d, readonly: h, ...x }) {
5
+ const p = (d || x.schema)?.multiple || !1;
6
+ if (h) {
7
+ if (!s) return /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "-" });
8
+ const t = Array.isArray(s) ? s : [s];
9
+ return /* @__PURE__ */ e.jsxs("div", { className: "flex -space-x-2", children: [
10
+ t.slice(0, 3).map((r, i) => {
11
+ const a = r.name || r.username || "User", n = a.split(" ").map((u) => u[0]).join("").toUpperCase().slice(0, 2);
12
+ return /* @__PURE__ */ e.jsx(c, { className: "size-8 border-2 border-white", title: a, children: /* @__PURE__ */ e.jsx(m, { className: "bg-blue-500 text-white text-xs", children: n }) }, i);
13
+ }),
14
+ t.length > 3 && /* @__PURE__ */ e.jsx(c, { className: "size-8 border-2 border-white", children: /* @__PURE__ */ e.jsxs(m, { className: "bg-gray-200 text-gray-600 text-xs", children: [
15
+ "+",
16
+ t.length - 3
17
+ ] }) })
18
+ ] });
19
+ }
20
+ const l = s ? Array.isArray(s) ? s : [s] : [], j = (t) => {
21
+ if (p) {
22
+ const r = l.filter((i, a) => a !== t);
23
+ o(r.length > 0 ? r : null);
24
+ } else
25
+ o(null);
26
+ };
27
+ return /* @__PURE__ */ e.jsxs("div", { className: x.className, children: [
28
+ l.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "flex flex-wrap gap-2 mb-2", children: l.map((t, r) => {
29
+ const i = t.name || t.username || "User", a = i.split(" ").map((n) => n[0]).join("").toUpperCase().slice(0, 2);
30
+ return /* @__PURE__ */ e.jsxs(g, { variant: "outline", className: "gap-2 pr-1", children: [
31
+ /* @__PURE__ */ e.jsx(c, { className: "size-5", children: /* @__PURE__ */ e.jsx(m, { className: "bg-blue-500 text-white text-xs", children: a }) }),
32
+ /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: i }),
33
+ /* @__PURE__ */ e.jsx(
34
+ "button",
35
+ {
36
+ type: "button",
37
+ onClick: () => j(r),
38
+ className: "ml-1 rounded-full hover:bg-gray-200 p-0.5",
39
+ children: /* @__PURE__ */ e.jsx(N, { className: "size-3" })
40
+ }
41
+ )
42
+ ] }, r);
43
+ }) }),
44
+ /* @__PURE__ */ e.jsx("div", { className: "text-sm text-gray-500 italic", children: "User selection component requires integration with user management system" })
45
+ ] });
46
+ }
47
+ export {
48
+ U as UserField
49
+ };
@@ -0,0 +1,25 @@
1
+ import { j as e } from "./index-B87wd1E0.js";
2
+ function x({ value: s, field: n, ...r }) {
3
+ const i = (n || r.schema)?.dimensions || (Array.isArray(s) ? s.length : 0);
4
+ if (!s || !Array.isArray(s))
5
+ return /* @__PURE__ */ e.jsx("span", { className: "text-sm text-gray-500", children: "-" });
6
+ const a = s.slice(0, 3).map((c) => {
7
+ const t = Number(c);
8
+ return isNaN(t) ? "0" : t.toFixed(4);
9
+ }).join(", ");
10
+ return /* @__PURE__ */ e.jsxs("div", { className: `text-sm ${r.className || ""}`, children: [
11
+ /* @__PURE__ */ e.jsxs("span", { className: "font-mono text-gray-700", children: [
12
+ "[",
13
+ a,
14
+ "...]"
15
+ ] }),
16
+ /* @__PURE__ */ e.jsxs("span", { className: "text-gray-500 ml-2", children: [
17
+ "(",
18
+ i,
19
+ "D)"
20
+ ] })
21
+ ] });
22
+ }
23
+ export {
24
+ x as VectorField
25
+ };