@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.
- package/.turbo/turbo-build.log +99 -0
- package/CHANGELOG.md +16 -0
- package/OBJECT_AGGRID_CN.md +483 -0
- package/QUICKSTART.md +186 -0
- package/README.md +221 -1
- package/dist/AddressField-Bntpynvd.js +95 -0
- package/dist/AgGridImpl-3Mmf2qrR.js +229 -0
- package/dist/AutoNumberField-C1kBJaxh.js +8 -0
- package/dist/FileField-BDwbJvor.js +101 -0
- package/dist/FormulaField-BXNiyGoh.js +9 -0
- package/dist/GeolocationField-Df3yYcM9.js +141 -0
- package/dist/GridField-CcjQp4WM.js +29 -0
- package/dist/LocationField-BIfN5QIq.js +33 -0
- package/dist/MasterDetailField-CAEmxbIT.js +117 -0
- package/dist/ObjectAgGridImpl-EjifM4aY.js +28727 -0
- package/dist/ObjectField-BpkQpIF-.js +51 -0
- package/dist/QRCodeField-VCBewTDG.js +96 -0
- package/dist/RichTextField-CyQwSi2C.js +37 -0
- package/dist/SignatureField-Cr4tsEbj.js +96 -0
- package/dist/SummaryField-CnEJ_GZI.js +9 -0
- package/dist/UserField-DJjaVyrV.js +49 -0
- package/dist/VectorField-cPYmcKnV.js +25 -0
- package/dist/{index-B6NPAFZx.js → index-B87wd1E0.js} +301 -143
- package/dist/index.css +1 -1
- package/dist/index.js +4 -3
- package/dist/index.umd.cjs +225 -2
- package/dist/src/AgGridImpl.d.ts +5 -2
- package/dist/src/ObjectAgGridImpl.d.ts +6 -0
- package/dist/src/VirtualScrolling.d.ts +72 -0
- package/dist/src/field-renderers.d.ts +67 -0
- package/dist/src/index.d.ts +47 -2
- package/dist/src/object-aggrid.types.d.ts +74 -0
- package/dist/src/types.d.ts +48 -1
- package/package.json +11 -9
- package/src/AgGridImpl.tsx +100 -11
- package/src/ObjectAgGridImpl.tsx +501 -0
- package/src/VirtualScrolling.ts +74 -0
- package/src/field-renderers.test.tsx +383 -0
- package/src/field-renderers.tsx +224 -0
- package/src/index.test.ts +1 -1
- package/src/index.tsx +211 -2
- package/src/object-aggrid.test.ts +99 -0
- package/src/object-aggrid.types.ts +123 -0
- package/src/types.ts +57 -1
- package/vite.config.ts +13 -0
- package/dist/AgGridImpl-DKkq6v1B.js +0 -171
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
import { j as f } from "./index-B87wd1E0.js";
|
|
2
|
+
import { useRef as Z, useMemo as C, useCallback as d } from "react";
|
|
3
|
+
import { AgGridReact as _ } from "ag-grid-react";
|
|
4
|
+
function G({
|
|
5
|
+
rowData: i = [],
|
|
6
|
+
columnDefs: v = [],
|
|
7
|
+
gridOptions: c = {},
|
|
8
|
+
pagination: A = !1,
|
|
9
|
+
paginationPageSize: y = 10,
|
|
10
|
+
domLayout: R = "normal",
|
|
11
|
+
animateRows: N = !0,
|
|
12
|
+
rowSelection: E,
|
|
13
|
+
theme: O = "quartz",
|
|
14
|
+
height: h = 500,
|
|
15
|
+
className: Q = "",
|
|
16
|
+
editable: g = !1,
|
|
17
|
+
editType: F,
|
|
18
|
+
singleClickEdit: V = !1,
|
|
19
|
+
stopEditingWhenCellsLoseFocus: j = !0,
|
|
20
|
+
exportConfig: l,
|
|
21
|
+
statusBar: x,
|
|
22
|
+
callbacks: n,
|
|
23
|
+
columnConfig: o,
|
|
24
|
+
enableRangeSelection: z = !1,
|
|
25
|
+
enableCharts: H = !1,
|
|
26
|
+
contextMenu: u,
|
|
27
|
+
treeData: p,
|
|
28
|
+
rowGrouping: r,
|
|
29
|
+
excelExport: m
|
|
30
|
+
}) {
|
|
31
|
+
const t = Z(null), b = C(() => {
|
|
32
|
+
if (!x?.enabled) return;
|
|
33
|
+
const e = x.aggregations || ["count", "sum", "avg"], s = [];
|
|
34
|
+
return e.includes("count") && s.push({ statusPanel: "agAggregationComponent", statusPanelParams: { aggFuncs: ["count"] } }), e.includes("sum") && s.push({ statusPanel: "agAggregationComponent", statusPanelParams: { aggFuncs: ["sum"] } }), e.includes("avg") && s.push({ statusPanel: "agAggregationComponent", statusPanelParams: { aggFuncs: ["avg"] } }), e.includes("min") && s.push({ statusPanel: "agAggregationComponent", statusPanelParams: { aggFuncs: ["min"] } }), e.includes("max") && s.push({ statusPanel: "agAggregationComponent", statusPanelParams: { aggFuncs: ["max"] } }), s;
|
|
35
|
+
}, [x]), S = d(() => {
|
|
36
|
+
if (!t.current?.api) return;
|
|
37
|
+
const e = {
|
|
38
|
+
fileName: l?.fileName || "export.csv",
|
|
39
|
+
skipColumnHeaders: l?.skipColumnHeaders || !1,
|
|
40
|
+
allColumns: l?.allColumns || !1,
|
|
41
|
+
onlySelected: l?.onlySelected || !1
|
|
42
|
+
};
|
|
43
|
+
if (t.current.api.exportDataAsCsv(e), n?.onExport) {
|
|
44
|
+
const s = l?.onlySelected ? t.current.api.getSelectedRows() : i;
|
|
45
|
+
n.onExport(s || [], "csv");
|
|
46
|
+
}
|
|
47
|
+
}, [l, n, i]), P = d(() => {
|
|
48
|
+
if (!t.current?.api) return;
|
|
49
|
+
const e = m?.fileName || l?.fileName || "export.csv", s = m?.includeHeaders !== !1, K = {
|
|
50
|
+
fileName: e,
|
|
51
|
+
skipColumnHeaders: !s,
|
|
52
|
+
allColumns: !0,
|
|
53
|
+
onlySelected: m?.onlySelected || !1
|
|
54
|
+
};
|
|
55
|
+
if (t.current.api.exportDataAsCsv(K), n?.onExport) {
|
|
56
|
+
const a = m?.onlySelected ? t.current.api.getSelectedRows() : i;
|
|
57
|
+
n.onExport(a || [], "excel");
|
|
58
|
+
}
|
|
59
|
+
}, [m, l, n, i]), I = d((e) => {
|
|
60
|
+
if (!u?.enabled) return [];
|
|
61
|
+
const s = [];
|
|
62
|
+
return (u.items || ["copy", "copyWithHeaders", "separator", "export"]).forEach((a) => {
|
|
63
|
+
a === "export" ? s.push({
|
|
64
|
+
name: "Export CSV",
|
|
65
|
+
icon: "<span>📥</span>",
|
|
66
|
+
action: () => S()
|
|
67
|
+
}) : a === "export-excel" ? s.push({
|
|
68
|
+
name: "Export Excel (CSV)",
|
|
69
|
+
icon: "<span>📊</span>",
|
|
70
|
+
action: () => P()
|
|
71
|
+
}) : a === "autoSizeAll" ? s.push({
|
|
72
|
+
name: "Auto-size All Columns",
|
|
73
|
+
action: () => {
|
|
74
|
+
t.current?.api && t.current.api.autoSizeAllColumns();
|
|
75
|
+
}
|
|
76
|
+
}) : a === "resetColumns" ? s.push({
|
|
77
|
+
name: "Reset Columns",
|
|
78
|
+
action: () => {
|
|
79
|
+
t.current?.api && t.current.api.resetColumnState();
|
|
80
|
+
}
|
|
81
|
+
}) : s.push(a);
|
|
82
|
+
}), u.customItems && (s.length > 0 && s.push("separator"), u.customItems.forEach((a) => {
|
|
83
|
+
s.push({
|
|
84
|
+
name: a.name,
|
|
85
|
+
disabled: a.disabled,
|
|
86
|
+
action: () => {
|
|
87
|
+
n?.onContextMenuAction && n.onContextMenuAction(a.action, e.node?.data);
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
})), s;
|
|
91
|
+
}, [u, S, P, n]), B = d((e) => {
|
|
92
|
+
n?.onCellClicked?.(e);
|
|
93
|
+
}, [n]), W = d((e) => {
|
|
94
|
+
n?.onRowClicked?.(e);
|
|
95
|
+
}, [n]), $ = d((e) => {
|
|
96
|
+
n?.onSelectionChanged?.(e);
|
|
97
|
+
}, [n]), q = d((e) => {
|
|
98
|
+
n?.onCellValueChanged?.(e);
|
|
99
|
+
}, [n]), J = d((e) => {
|
|
100
|
+
t.current = e;
|
|
101
|
+
}, []), T = C(() => v ? v.map((e) => {
|
|
102
|
+
const s = { ...e };
|
|
103
|
+
return g && e.editable !== !1 && (s.editable = !0), o && (o.resizable !== void 0 && e.resizable === void 0 && (s.resizable = o.resizable), o.sortable !== void 0 && e.sortable === void 0 && (s.sortable = o.sortable), o.filterable !== void 0 && e.filter === void 0 && (s.filter = o.filterable)), r?.enabled && r.groupByFields?.includes(e.field || "") && (s.rowGroup = !0, s.hide = !0), r?.aggregations && e.field && r.aggregations[e.field] && (s.aggFunc = r.aggregations[e.field]), s;
|
|
104
|
+
}) : [], [v, g, o, r]), U = C(() => ({
|
|
105
|
+
...c,
|
|
106
|
+
pagination: A,
|
|
107
|
+
paginationPageSize: y,
|
|
108
|
+
domLayout: R,
|
|
109
|
+
animateRows: N,
|
|
110
|
+
rowSelection: E,
|
|
111
|
+
editType: F,
|
|
112
|
+
singleClickEdit: V,
|
|
113
|
+
stopEditingWhenCellsLoseFocus: j,
|
|
114
|
+
statusBar: b ? { statusPanels: b } : void 0,
|
|
115
|
+
enableRangeSelection: z,
|
|
116
|
+
enableCharts: H,
|
|
117
|
+
getContextMenuItems: u?.enabled ? I : void 0,
|
|
118
|
+
// Tree data support
|
|
119
|
+
...p?.enabled ? {
|
|
120
|
+
treeData: !0,
|
|
121
|
+
getDataPath: p.pathField ? (e) => e[p.pathField] : void 0,
|
|
122
|
+
autoGroupColumnDef: {
|
|
123
|
+
headerName: "Hierarchy",
|
|
124
|
+
minWidth: 250,
|
|
125
|
+
cellRendererParams: {
|
|
126
|
+
suppressCount: !1
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
groupDefaultExpanded: p.expandAll ? -1 : p.expandDepth ?? 0
|
|
130
|
+
} : {},
|
|
131
|
+
// Row grouping
|
|
132
|
+
...r?.enabled ? {
|
|
133
|
+
groupDefaultExpanded: r.groupByFields?.length ? 1 : 0,
|
|
134
|
+
autoGroupColumnDef: {
|
|
135
|
+
minWidth: 200,
|
|
136
|
+
cellRendererParams: {
|
|
137
|
+
suppressCount: !r.showRowCount
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
} : {},
|
|
141
|
+
// Default options for better UX
|
|
142
|
+
suppressCellFocus: !g,
|
|
143
|
+
enableCellTextSelection: !0,
|
|
144
|
+
ensureDomOrder: !0,
|
|
145
|
+
// Virtual scrolling optimizations for large datasets
|
|
146
|
+
rowBuffer: c.rowBuffer ?? 10,
|
|
147
|
+
debounceVerticalScrollbar: c.debounceVerticalScrollbar ?? i.length > 1e3,
|
|
148
|
+
// Event handlers
|
|
149
|
+
onCellClicked: B,
|
|
150
|
+
onRowClicked: W,
|
|
151
|
+
onSelectionChanged: $,
|
|
152
|
+
onCellValueChanged: q,
|
|
153
|
+
onGridReady: J
|
|
154
|
+
}), [
|
|
155
|
+
c,
|
|
156
|
+
A,
|
|
157
|
+
y,
|
|
158
|
+
R,
|
|
159
|
+
N,
|
|
160
|
+
E,
|
|
161
|
+
F,
|
|
162
|
+
V,
|
|
163
|
+
j,
|
|
164
|
+
b,
|
|
165
|
+
z,
|
|
166
|
+
H,
|
|
167
|
+
u,
|
|
168
|
+
I,
|
|
169
|
+
p,
|
|
170
|
+
r,
|
|
171
|
+
g,
|
|
172
|
+
i.length,
|
|
173
|
+
B,
|
|
174
|
+
W,
|
|
175
|
+
$,
|
|
176
|
+
q,
|
|
177
|
+
J
|
|
178
|
+
]), X = C(() => ({
|
|
179
|
+
height: typeof h == "number" ? `${h}px` : h,
|
|
180
|
+
width: "100%"
|
|
181
|
+
}), [h]), Y = [
|
|
182
|
+
`ag-theme-${O}`,
|
|
183
|
+
"rounded-xl",
|
|
184
|
+
"border",
|
|
185
|
+
"border-border",
|
|
186
|
+
"overflow-hidden",
|
|
187
|
+
"shadow-lg",
|
|
188
|
+
Q
|
|
189
|
+
].filter(Boolean).join(" ");
|
|
190
|
+
return /* @__PURE__ */ f.jsxs("div", { className: "ag-grid-container", children: [
|
|
191
|
+
(l?.enabled || m?.enabled) && /* @__PURE__ */ f.jsxs("div", { className: "mb-2 flex gap-2", children: [
|
|
192
|
+
l?.enabled && /* @__PURE__ */ f.jsx(
|
|
193
|
+
"button",
|
|
194
|
+
{
|
|
195
|
+
onClick: S,
|
|
196
|
+
className: "px-3 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors",
|
|
197
|
+
children: "Export CSV"
|
|
198
|
+
}
|
|
199
|
+
),
|
|
200
|
+
m?.enabled && /* @__PURE__ */ f.jsx(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
onClick: P,
|
|
204
|
+
className: "px-3 py-1.5 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-md transition-colors",
|
|
205
|
+
children: "Export Excel (CSV)"
|
|
206
|
+
}
|
|
207
|
+
)
|
|
208
|
+
] }),
|
|
209
|
+
/* @__PURE__ */ f.jsx(
|
|
210
|
+
"div",
|
|
211
|
+
{
|
|
212
|
+
className: Y,
|
|
213
|
+
style: X,
|
|
214
|
+
children: /* @__PURE__ */ f.jsx(
|
|
215
|
+
_,
|
|
216
|
+
{
|
|
217
|
+
ref: t,
|
|
218
|
+
rowData: i,
|
|
219
|
+
columnDefs: T,
|
|
220
|
+
gridOptions: U
|
|
221
|
+
}
|
|
222
|
+
)
|
|
223
|
+
}
|
|
224
|
+
)
|
|
225
|
+
] });
|
|
226
|
+
}
|
|
227
|
+
export {
|
|
228
|
+
G as default
|
|
229
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { j as n } from "./index-B87wd1E0.js";
|
|
2
|
+
function a({ value: t, field: o, ...s }) {
|
|
3
|
+
const e = t != null ? String(t) : "-";
|
|
4
|
+
return /* @__PURE__ */ n.jsx("span", { className: `text-sm font-mono text-gray-700 ${s.className || ""}`, children: e });
|
|
5
|
+
}
|
|
6
|
+
export {
|
|
7
|
+
a as AutoNumberField
|
|
8
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { j as e } from "./index-B87wd1E0.js";
|
|
2
|
+
import { useRef as y } from "react";
|
|
3
|
+
import { Button as p } from "@object-ui/components";
|
|
4
|
+
import { c as N, X as g, U as F } from "./ObjectAgGridImpl-EjifM4aY.js";
|
|
5
|
+
const z = [
|
|
6
|
+
[
|
|
7
|
+
"path",
|
|
8
|
+
{
|
|
9
|
+
d: "M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",
|
|
10
|
+
key: "1oefj6"
|
|
11
|
+
}
|
|
12
|
+
],
|
|
13
|
+
["path", { d: "M14 2v5a1 1 0 0 0 1 1h5", key: "wfsgrz" }]
|
|
14
|
+
], b = N("file", z);
|
|
15
|
+
function R({ value: t, onChange: r, field: x, readonly: h, ...o }) {
|
|
16
|
+
const d = y(null), c = x || o.schema, m = c?.multiple || !1, f = c?.accept ? c.accept.join(",") : void 0;
|
|
17
|
+
if (h) {
|
|
18
|
+
if (!t) return /* @__PURE__ */ e.jsx("span", { className: "text-sm", children: "-" });
|
|
19
|
+
const a = Array.isArray(t) ? t : [t];
|
|
20
|
+
return /* @__PURE__ */ e.jsx("div", { className: "flex flex-wrap gap-2", children: a.map((s, l) => /* @__PURE__ */ e.jsx("span", { className: "text-sm truncate max-w-xs", children: s.name || s.original_name || "File" }, l)) });
|
|
21
|
+
}
|
|
22
|
+
const n = t ? Array.isArray(t) ? t : [t] : [], j = (a) => {
|
|
23
|
+
const s = Array.from(a.target.files || []);
|
|
24
|
+
if (s.length === 0) return;
|
|
25
|
+
const l = s.map((i) => ({
|
|
26
|
+
name: i.name,
|
|
27
|
+
original_name: i.name,
|
|
28
|
+
size: i.size,
|
|
29
|
+
mime_type: i.type,
|
|
30
|
+
// In a real implementation, this would upload the file and return a URL
|
|
31
|
+
url: URL.createObjectURL(i)
|
|
32
|
+
}));
|
|
33
|
+
r(m ? [...n, ...l] : l[0]);
|
|
34
|
+
}, u = (a) => {
|
|
35
|
+
if (m) {
|
|
36
|
+
const s = n.filter((l, i) => i !== a);
|
|
37
|
+
r(s.length > 0 ? s : null);
|
|
38
|
+
} else
|
|
39
|
+
r(null);
|
|
40
|
+
};
|
|
41
|
+
return /* @__PURE__ */ e.jsxs("div", { className: o.className, children: [
|
|
42
|
+
/* @__PURE__ */ e.jsx(
|
|
43
|
+
"input",
|
|
44
|
+
{
|
|
45
|
+
ref: d,
|
|
46
|
+
type: "file",
|
|
47
|
+
multiple: m,
|
|
48
|
+
accept: f,
|
|
49
|
+
onChange: j,
|
|
50
|
+
className: "hidden"
|
|
51
|
+
}
|
|
52
|
+
),
|
|
53
|
+
/* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
|
|
54
|
+
n.length > 0 && /* @__PURE__ */ e.jsx("div", { className: "space-y-1", children: n.map((a, s) => /* @__PURE__ */ e.jsxs(
|
|
55
|
+
"div",
|
|
56
|
+
{
|
|
57
|
+
className: "flex items-center justify-between gap-2 p-2 bg-gray-50 rounded-md border border-gray-200",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 flex-1 min-w-0", children: [
|
|
60
|
+
/* @__PURE__ */ e.jsx(b, { className: "size-4 text-gray-500 flex-shrink-0" }),
|
|
61
|
+
/* @__PURE__ */ e.jsx("span", { className: "text-sm truncate", children: a.name || a.original_name || "File" }),
|
|
62
|
+
a.size && /* @__PURE__ */ e.jsxs("span", { className: "text-xs text-gray-500", children: [
|
|
63
|
+
"(",
|
|
64
|
+
(a.size / 1024).toFixed(1),
|
|
65
|
+
" KB)"
|
|
66
|
+
] })
|
|
67
|
+
] }),
|
|
68
|
+
/* @__PURE__ */ e.jsx(
|
|
69
|
+
p,
|
|
70
|
+
{
|
|
71
|
+
type: "button",
|
|
72
|
+
variant: "ghost",
|
|
73
|
+
size: "sm",
|
|
74
|
+
onClick: () => u(s),
|
|
75
|
+
className: "h-6 w-6 p-0",
|
|
76
|
+
children: /* @__PURE__ */ e.jsx(g, { className: "size-3" })
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
]
|
|
80
|
+
},
|
|
81
|
+
s
|
|
82
|
+
)) }),
|
|
83
|
+
/* @__PURE__ */ e.jsxs(
|
|
84
|
+
p,
|
|
85
|
+
{
|
|
86
|
+
type: "button",
|
|
87
|
+
variant: "outline",
|
|
88
|
+
onClick: () => d.current?.click(),
|
|
89
|
+
className: "w-full",
|
|
90
|
+
children: [
|
|
91
|
+
/* @__PURE__ */ e.jsx(F, { className: "size-4 mr-2" }),
|
|
92
|
+
n.length > 0 ? "Add More Files" : "Upload File"
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
)
|
|
96
|
+
] })
|
|
97
|
+
] });
|
|
98
|
+
}
|
|
99
|
+
export {
|
|
100
|
+
R as FileField
|
|
101
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { j as s } from "./index-B87wd1E0.js";
|
|
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__ */ s.jsx("span", { className: `text-sm font-mono text-gray-700 ${r.className || ""}`, children: t });
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
m as FormulaField
|
|
9
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { j as t } from "./index-B87wd1E0.js";
|
|
2
|
+
import f from "react";
|
|
3
|
+
import { Button as n, Label as m, Input as x } from "@object-ui/components";
|
|
4
|
+
import { c as h } from "./ObjectAgGridImpl-EjifM4aY.js";
|
|
5
|
+
const b = [
|
|
6
|
+
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
7
|
+
["line", { x1: "22", x2: "18", y1: "12", y2: "12", key: "l9bcsi" }],
|
|
8
|
+
["line", { x1: "6", x2: "2", y1: "12", y2: "12", key: "13hhkx" }],
|
|
9
|
+
["line", { x1: "12", x2: "12", y1: "6", y2: "2", key: "10w3f3" }],
|
|
10
|
+
["line", { x1: "12", x2: "12", y1: "22", y2: "18", key: "15g9kq" }]
|
|
11
|
+
], N = h("crosshair", b);
|
|
12
|
+
const v = [
|
|
13
|
+
[
|
|
14
|
+
"path",
|
|
15
|
+
{
|
|
16
|
+
d: "M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",
|
|
17
|
+
key: "1r0f0z"
|
|
18
|
+
}
|
|
19
|
+
],
|
|
20
|
+
["circle", { cx: "12", cy: "10", r: "3", key: "ilqhr7" }]
|
|
21
|
+
], g = h("map-pin", v);
|
|
22
|
+
function _({ value: p, onChange: c, field: k, readonly: a, ...s }) {
|
|
23
|
+
const [l, o] = f.useState(!1), i = p || {}, r = (e, u) => {
|
|
24
|
+
c({
|
|
25
|
+
...i,
|
|
26
|
+
[e]: u ? Number(u) : void 0
|
|
27
|
+
});
|
|
28
|
+
}, y = () => {
|
|
29
|
+
if (!navigator.geolocation) {
|
|
30
|
+
console.error("Geolocation is not supported by this browser");
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
o(!0), navigator.geolocation.getCurrentPosition(
|
|
34
|
+
(e) => {
|
|
35
|
+
c({
|
|
36
|
+
latitude: e.coords.latitude,
|
|
37
|
+
longitude: e.coords.longitude,
|
|
38
|
+
accuracy: e.coords.accuracy
|
|
39
|
+
}), o(!1);
|
|
40
|
+
},
|
|
41
|
+
(e) => {
|
|
42
|
+
console.error("Error getting location:", e.message), o(!1);
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
enableHighAccuracy: !0,
|
|
46
|
+
timeout: 5e3,
|
|
47
|
+
maximumAge: 0
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}, j = (e) => !e.latitude || !e.longitude ? "-" : `${e.latitude.toFixed(6)}, ${e.longitude.toFixed(6)}`, d = () => {
|
|
51
|
+
if (!i.latitude || !i.longitude) return;
|
|
52
|
+
const e = `https://www.google.com/maps?q=${i.latitude},${i.longitude}`;
|
|
53
|
+
window.open(e, "_blank");
|
|
54
|
+
};
|
|
55
|
+
return a ? /* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
56
|
+
/* @__PURE__ */ t.jsx(g, { className: "w-4 h-4 text-muted-foreground" }),
|
|
57
|
+
/* @__PURE__ */ t.jsx("span", { className: "text-sm", children: j(i) }),
|
|
58
|
+
i.latitude && i.longitude && /* @__PURE__ */ t.jsx(
|
|
59
|
+
n,
|
|
60
|
+
{
|
|
61
|
+
type: "button",
|
|
62
|
+
variant: "link",
|
|
63
|
+
size: "sm",
|
|
64
|
+
onClick: d,
|
|
65
|
+
className: "p-0 h-auto",
|
|
66
|
+
children: "View on map"
|
|
67
|
+
}
|
|
68
|
+
)
|
|
69
|
+
] }) : /* @__PURE__ */ t.jsxs("div", { className: "space-y-3", children: [
|
|
70
|
+
/* @__PURE__ */ t.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
71
|
+
/* @__PURE__ */ t.jsxs(
|
|
72
|
+
n,
|
|
73
|
+
{
|
|
74
|
+
type: "button",
|
|
75
|
+
variant: "outline",
|
|
76
|
+
size: "sm",
|
|
77
|
+
onClick: y,
|
|
78
|
+
disabled: a || l,
|
|
79
|
+
children: [
|
|
80
|
+
/* @__PURE__ */ t.jsx(N, { className: "w-4 h-4 mr-2" }),
|
|
81
|
+
l ? "Getting location..." : "Use Current Location"
|
|
82
|
+
]
|
|
83
|
+
}
|
|
84
|
+
),
|
|
85
|
+
i.latitude && i.longitude && /* @__PURE__ */ t.jsxs(
|
|
86
|
+
n,
|
|
87
|
+
{
|
|
88
|
+
type: "button",
|
|
89
|
+
variant: "link",
|
|
90
|
+
size: "sm",
|
|
91
|
+
onClick: d,
|
|
92
|
+
children: [
|
|
93
|
+
/* @__PURE__ */ t.jsx(g, { className: "w-4 h-4 mr-2" }),
|
|
94
|
+
"View on map"
|
|
95
|
+
]
|
|
96
|
+
}
|
|
97
|
+
)
|
|
98
|
+
] }),
|
|
99
|
+
/* @__PURE__ */ t.jsxs("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
100
|
+
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
101
|
+
/* @__PURE__ */ t.jsx(m, { htmlFor: "latitude", className: "text-xs", children: "Latitude" }),
|
|
102
|
+
/* @__PURE__ */ t.jsx(
|
|
103
|
+
x,
|
|
104
|
+
{
|
|
105
|
+
id: "latitude",
|
|
106
|
+
type: "number",
|
|
107
|
+
value: i.latitude ?? "",
|
|
108
|
+
onChange: (e) => r("latitude", e.target.value),
|
|
109
|
+
placeholder: "37.7749",
|
|
110
|
+
disabled: a || s.disabled,
|
|
111
|
+
step: "any",
|
|
112
|
+
className: s.className
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
] }),
|
|
116
|
+
/* @__PURE__ */ t.jsxs("div", { children: [
|
|
117
|
+
/* @__PURE__ */ t.jsx(m, { htmlFor: "longitude", className: "text-xs", children: "Longitude" }),
|
|
118
|
+
/* @__PURE__ */ t.jsx(
|
|
119
|
+
x,
|
|
120
|
+
{
|
|
121
|
+
id: "longitude",
|
|
122
|
+
type: "number",
|
|
123
|
+
value: i.longitude ?? "",
|
|
124
|
+
onChange: (e) => r("longitude", e.target.value),
|
|
125
|
+
placeholder: "-122.4194",
|
|
126
|
+
disabled: a || s.disabled,
|
|
127
|
+
step: "any"
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
] })
|
|
131
|
+
] }),
|
|
132
|
+
i.accuracy && /* @__PURE__ */ t.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
133
|
+
"Accuracy: ±",
|
|
134
|
+
i.accuracy.toFixed(0),
|
|
135
|
+
"m"
|
|
136
|
+
] })
|
|
137
|
+
] });
|
|
138
|
+
}
|
|
139
|
+
export {
|
|
140
|
+
_ as GeolocationField
|
|
141
|
+
};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { j as e } from "./index-B87wd1E0.js";
|
|
2
|
+
import { cn as l } from "@object-ui/components";
|
|
3
|
+
function g({ value: r, field: n, readonly: m, ...a }) {
|
|
4
|
+
const d = (n || a.schema)?.columns || [];
|
|
5
|
+
return !r || !Array.isArray(r) ? /* @__PURE__ */ e.jsx("span", { className: "text-sm text-gray-500", children: "-" }) : m ? /* @__PURE__ */ e.jsx("div", { className: l("text-sm", a.className), children: /* @__PURE__ */ e.jsxs("span", { className: "text-gray-700", children: [
|
|
6
|
+
r.length,
|
|
7
|
+
" rows"
|
|
8
|
+
] }) }) : /* @__PURE__ */ e.jsxs("div", { className: l("border border-gray-200 rounded-md overflow-hidden", a.className), children: [
|
|
9
|
+
/* @__PURE__ */ e.jsx("div", { className: "overflow-auto max-h-60", children: /* @__PURE__ */ e.jsxs("table", { className: "w-full text-sm", children: [
|
|
10
|
+
/* @__PURE__ */ e.jsx("thead", { className: "bg-gray-50 border-b border-gray-200", children: /* @__PURE__ */ e.jsx("tr", { children: d.map((s, t) => /* @__PURE__ */ e.jsx(
|
|
11
|
+
"th",
|
|
12
|
+
{
|
|
13
|
+
className: "px-3 py-2 text-left text-xs font-medium text-gray-700",
|
|
14
|
+
children: s.label || s.name
|
|
15
|
+
},
|
|
16
|
+
t
|
|
17
|
+
)) }) }),
|
|
18
|
+
/* @__PURE__ */ e.jsx("tbody", { className: "divide-y divide-gray-200", children: r.slice(0, 5).map((s, t) => /* @__PURE__ */ e.jsx("tr", { className: "hover:bg-gray-50", children: d.map((i, c) => /* @__PURE__ */ e.jsx("td", { className: "px-3 py-2 text-gray-900", children: s[i.name] != null ? String(s[i.name]) : "-" }, c)) }, t)) })
|
|
19
|
+
] }) }),
|
|
20
|
+
r.length > 5 && /* @__PURE__ */ e.jsxs("div", { className: "bg-gray-50 px-3 py-2 text-xs text-gray-500 border-t border-gray-200", children: [
|
|
21
|
+
"Showing 5 of ",
|
|
22
|
+
r.length,
|
|
23
|
+
" rows"
|
|
24
|
+
] })
|
|
25
|
+
] });
|
|
26
|
+
}
|
|
27
|
+
export {
|
|
28
|
+
g as GridField
|
|
29
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { j as r } from "./index-B87wd1E0.js";
|
|
2
|
+
import { Input as f } from "@object-ui/components";
|
|
3
|
+
function x({ value: t, onChange: l, field: d, readonly: i, ...a }) {
|
|
4
|
+
const m = d || a.schema, n = t && typeof t == "object" ? `${t.latitude || 0}, ${t.longitude || 0}` : "";
|
|
5
|
+
if (i)
|
|
6
|
+
return /* @__PURE__ */ r.jsx("span", { className: "text-sm", children: n || "-" });
|
|
7
|
+
const u = (p) => {
|
|
8
|
+
const o = p.target.value;
|
|
9
|
+
if (!o.trim()) {
|
|
10
|
+
l(null);
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const s = o.split(",").map((e) => e.trim());
|
|
14
|
+
if (s.length === 2) {
|
|
15
|
+
const e = parseFloat(s[0]), c = parseFloat(s[1]);
|
|
16
|
+
!isNaN(e) && !isNaN(c) && l({ latitude: e, longitude: c });
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
return /* @__PURE__ */ r.jsx(
|
|
20
|
+
f,
|
|
21
|
+
{
|
|
22
|
+
type: "text",
|
|
23
|
+
value: n,
|
|
24
|
+
onChange: u,
|
|
25
|
+
placeholder: m?.placeholder || "latitude, longitude",
|
|
26
|
+
disabled: i || a.disabled,
|
|
27
|
+
className: a.className
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
x as LocationField
|
|
33
|
+
};
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { j as e } from "./index-B87wd1E0.js";
|
|
2
|
+
import { Button as a, cn as c, Badge as N } from "@object-ui/components";
|
|
3
|
+
import { c as o, X as f } from "./ObjectAgGridImpl-EjifM4aY.js";
|
|
4
|
+
const g = [
|
|
5
|
+
["path", { d: "M15 3h6v6", key: "1q9fwt" }],
|
|
6
|
+
["path", { d: "M10 14 21 3", key: "gplh6r" }],
|
|
7
|
+
["path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6", key: "a6xqqp" }]
|
|
8
|
+
], i = o("external-link", g);
|
|
9
|
+
const v = [
|
|
10
|
+
["path", { d: "M5 12h14", key: "1ays0h" }],
|
|
11
|
+
["path", { d: "M12 5v14", key: "s699le" }]
|
|
12
|
+
], y = o("plus", v);
|
|
13
|
+
function R({
|
|
14
|
+
value: h,
|
|
15
|
+
onChange: l,
|
|
16
|
+
field: x,
|
|
17
|
+
readonly: m,
|
|
18
|
+
className: n,
|
|
19
|
+
...d
|
|
20
|
+
}) {
|
|
21
|
+
const t = h || [], u = x || d.schema, p = () => {
|
|
22
|
+
const s = {
|
|
23
|
+
id: `new-${Date.now()}`,
|
|
24
|
+
label: "New Related Record"
|
|
25
|
+
};
|
|
26
|
+
l([...t, s]);
|
|
27
|
+
}, j = (s) => {
|
|
28
|
+
l(t.filter((b) => b.id !== s));
|
|
29
|
+
}, r = (s) => {
|
|
30
|
+
console.log("View detail:", s);
|
|
31
|
+
};
|
|
32
|
+
return m ? /* @__PURE__ */ e.jsxs("div", { className: c("space-y-2", n), children: [
|
|
33
|
+
t.length === 0 ? /* @__PURE__ */ e.jsx("span", { className: "text-sm text-muted-foreground", children: "No related records" }) : t.map((s) => /* @__PURE__ */ e.jsxs(
|
|
34
|
+
"div",
|
|
35
|
+
{
|
|
36
|
+
className: "flex items-center justify-between p-2 border rounded hover:bg-muted/50",
|
|
37
|
+
children: [
|
|
38
|
+
/* @__PURE__ */ e.jsx("span", { className: "text-sm", children: s.label }),
|
|
39
|
+
/* @__PURE__ */ e.jsx(
|
|
40
|
+
a,
|
|
41
|
+
{
|
|
42
|
+
type: "button",
|
|
43
|
+
variant: "ghost",
|
|
44
|
+
size: "sm",
|
|
45
|
+
onClick: () => r(s),
|
|
46
|
+
children: /* @__PURE__ */ e.jsx(i, { className: "w-4 h-4" })
|
|
47
|
+
}
|
|
48
|
+
)
|
|
49
|
+
]
|
|
50
|
+
},
|
|
51
|
+
s.id
|
|
52
|
+
)),
|
|
53
|
+
/* @__PURE__ */ e.jsxs("p", { className: "text-xs text-muted-foreground", children: [
|
|
54
|
+
t.length,
|
|
55
|
+
" ",
|
|
56
|
+
t.length === 1 ? "record" : "records"
|
|
57
|
+
] })
|
|
58
|
+
] }) : /* @__PURE__ */ e.jsxs("div", { className: c("space-y-3", n), children: [
|
|
59
|
+
/* @__PURE__ */ e.jsxs("div", { className: "space-y-2", children: [
|
|
60
|
+
t.map((s) => /* @__PURE__ */ e.jsxs(
|
|
61
|
+
"div",
|
|
62
|
+
{
|
|
63
|
+
className: "flex items-center justify-between gap-2 p-2 border rounded hover:bg-muted/50",
|
|
64
|
+
children: [
|
|
65
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-2 flex-1", children: [
|
|
66
|
+
/* @__PURE__ */ e.jsx(N, { variant: "outline", children: s.id }),
|
|
67
|
+
/* @__PURE__ */ e.jsx("span", { className: "text-sm flex-1", children: s.label })
|
|
68
|
+
] }),
|
|
69
|
+
/* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-1", children: [
|
|
70
|
+
/* @__PURE__ */ e.jsx(
|
|
71
|
+
a,
|
|
72
|
+
{
|
|
73
|
+
type: "button",
|
|
74
|
+
variant: "ghost",
|
|
75
|
+
size: "sm",
|
|
76
|
+
onClick: () => r(s),
|
|
77
|
+
children: /* @__PURE__ */ e.jsx(i, { className: "w-4 h-4" })
|
|
78
|
+
}
|
|
79
|
+
),
|
|
80
|
+
/* @__PURE__ */ e.jsx(
|
|
81
|
+
a,
|
|
82
|
+
{
|
|
83
|
+
type: "button",
|
|
84
|
+
variant: "ghost",
|
|
85
|
+
size: "sm",
|
|
86
|
+
onClick: () => j(s.id),
|
|
87
|
+
disabled: d.disabled,
|
|
88
|
+
children: /* @__PURE__ */ e.jsx(f, { className: "w-4 h-4" })
|
|
89
|
+
}
|
|
90
|
+
)
|
|
91
|
+
] })
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
s.id
|
|
95
|
+
)),
|
|
96
|
+
t.length === 0 && /* @__PURE__ */ e.jsx("div", { className: "text-sm text-muted-foreground text-center py-4 border border-dashed rounded bg-muted/20", children: "No related records" })
|
|
97
|
+
] }),
|
|
98
|
+
/* @__PURE__ */ e.jsxs(
|
|
99
|
+
a,
|
|
100
|
+
{
|
|
101
|
+
type: "button",
|
|
102
|
+
variant: "outline",
|
|
103
|
+
className: "w-full",
|
|
104
|
+
onClick: p,
|
|
105
|
+
disabled: d.disabled,
|
|
106
|
+
children: [
|
|
107
|
+
/* @__PURE__ */ e.jsx(y, { className: "w-4 h-4 mr-2" }),
|
|
108
|
+
"Add ",
|
|
109
|
+
u?.label || "Record"
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
)
|
|
113
|
+
] });
|
|
114
|
+
}
|
|
115
|
+
export {
|
|
116
|
+
R as MasterDetailField
|
|
117
|
+
};
|