@object-ui/plugin-aggrid 4.0.4 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +33 -0
- package/dist/index.js +704 -17
- package/package.json +7 -7
- package/dist/AgGridImpl-CAfXf2vU.js +0 -225
- package/dist/ObjectAgGridImpl-C-HQaIhp.js +0 -460
package/dist/index.js
CHANGED
|
@@ -1,16 +1,703 @@
|
|
|
1
|
-
import e, { Suspense as t } from "react";
|
|
2
|
-
import { ComponentRegistry as
|
|
3
|
-
import { Skeleton as
|
|
1
|
+
import e, { Suspense as t, useCallback as n, useEffect as r, useMemo as i, useRef as ee, useState as a } from "react";
|
|
2
|
+
import { ComponentRegistry as o, buildExpandFields as s } from "@object-ui/core";
|
|
3
|
+
import { Skeleton as c } from "@object-ui/components";
|
|
4
4
|
import "ag-grid-community/styles/ag-grid.css";
|
|
5
5
|
import "ag-grid-community/styles/ag-theme-quartz.css";
|
|
6
6
|
import "ag-grid-community/styles/ag-theme-alpine.css";
|
|
7
7
|
import "ag-grid-community/styles/ag-theme-balham.css";
|
|
8
8
|
import "ag-grid-community/styles/ag-theme-material.css";
|
|
9
|
-
import { jsx as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
9
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
10
|
+
import { AgGridReact as d } from "ag-grid-react";
|
|
11
|
+
import { createRoot as f } from "react-dom/client";
|
|
12
|
+
import { AvatarField as p, BooleanField as m, CodeField as h, ColorField as g, CurrencyField as _, DateField as v, DateTimeField as y, EmailField as b, ImageField as x, LookupField as S, NumberField as C, PasswordField as w, PercentField as T, PhoneField as E, RatingField as D, SelectField as O, SliderField as k, TextAreaField as A, TextField as j, TimeField as M, UrlField as N } from "@object-ui/fields";
|
|
13
|
+
//#region \0rolldown/runtime.js
|
|
14
|
+
var P = Object.defineProperty, F = (e, t) => () => (e && (t = e(e = 0)), t), I = (e, t) => {
|
|
15
|
+
let n = {};
|
|
16
|
+
for (var r in e) P(n, r, {
|
|
17
|
+
get: e[r],
|
|
18
|
+
enumerable: !0
|
|
19
|
+
});
|
|
20
|
+
return t || P(n, Symbol.toStringTag, { value: "Module" }), n;
|
|
21
|
+
}, L = /* @__PURE__ */ I({ default: () => R });
|
|
22
|
+
function R({ rowData: e = [], columnDefs: t = [], gridOptions: r = {}, pagination: a = !1, paginationPageSize: o = 10, domLayout: s = "normal", animateRows: c = !0, rowSelection: f, theme: p = "quartz", height: m = 500, className: h = "", editable: g = !1, editType: _, singleClickEdit: v = !1, stopEditingWhenCellsLoseFocus: y = !0, exportConfig: b, statusBar: x, callbacks: S, columnConfig: C, enableRangeSelection: w = !1, enableCharts: T = !1, contextMenu: E, treeData: D, rowGrouping: O, excelExport: k }) {
|
|
23
|
+
let A = ee(null), j = i(() => {
|
|
24
|
+
if (!x?.enabled) return;
|
|
25
|
+
let e = x.aggregations || [
|
|
26
|
+
"count",
|
|
27
|
+
"sum",
|
|
28
|
+
"avg"
|
|
29
|
+
], t = [];
|
|
30
|
+
return e.includes("count") && t.push({
|
|
31
|
+
statusPanel: "agAggregationComponent",
|
|
32
|
+
statusPanelParams: { aggFuncs: ["count"] }
|
|
33
|
+
}), e.includes("sum") && t.push({
|
|
34
|
+
statusPanel: "agAggregationComponent",
|
|
35
|
+
statusPanelParams: { aggFuncs: ["sum"] }
|
|
36
|
+
}), e.includes("avg") && t.push({
|
|
37
|
+
statusPanel: "agAggregationComponent",
|
|
38
|
+
statusPanelParams: { aggFuncs: ["avg"] }
|
|
39
|
+
}), e.includes("min") && t.push({
|
|
40
|
+
statusPanel: "agAggregationComponent",
|
|
41
|
+
statusPanelParams: { aggFuncs: ["min"] }
|
|
42
|
+
}), e.includes("max") && t.push({
|
|
43
|
+
statusPanel: "agAggregationComponent",
|
|
44
|
+
statusPanelParams: { aggFuncs: ["max"] }
|
|
45
|
+
}), t;
|
|
46
|
+
}, [x]), M = n(() => {
|
|
47
|
+
if (!A.current?.api) return;
|
|
48
|
+
let t = {
|
|
49
|
+
fileName: b?.fileName || "export.csv",
|
|
50
|
+
skipColumnHeaders: b?.skipColumnHeaders || !1,
|
|
51
|
+
allColumns: b?.allColumns || !1,
|
|
52
|
+
onlySelected: b?.onlySelected || !1
|
|
53
|
+
};
|
|
54
|
+
if (A.current.api.exportDataAsCsv(t), S?.onExport) {
|
|
55
|
+
let t = b?.onlySelected ? A.current.api.getSelectedRows() : e;
|
|
56
|
+
S.onExport(t || [], "csv");
|
|
57
|
+
}
|
|
58
|
+
}, [
|
|
59
|
+
b,
|
|
60
|
+
S,
|
|
61
|
+
e
|
|
62
|
+
]), N = n(() => {
|
|
63
|
+
if (!A.current?.api) return;
|
|
64
|
+
let t = {
|
|
65
|
+
fileName: k?.fileName || b?.fileName || "export.csv",
|
|
66
|
+
skipColumnHeaders: k?.includeHeaders === !1,
|
|
67
|
+
allColumns: !0,
|
|
68
|
+
onlySelected: k?.onlySelected || !1
|
|
69
|
+
};
|
|
70
|
+
if (A.current.api.exportDataAsCsv(t), S?.onExport) {
|
|
71
|
+
let t = k?.onlySelected ? A.current.api.getSelectedRows() : e;
|
|
72
|
+
S.onExport(t || [], "excel");
|
|
73
|
+
}
|
|
74
|
+
}, [
|
|
75
|
+
k,
|
|
76
|
+
b,
|
|
77
|
+
S,
|
|
78
|
+
e
|
|
79
|
+
]), P = n((e) => {
|
|
80
|
+
if (!E?.enabled) return [];
|
|
81
|
+
let t = [];
|
|
82
|
+
return (E.items || [
|
|
83
|
+
"copy",
|
|
84
|
+
"copyWithHeaders",
|
|
85
|
+
"separator",
|
|
86
|
+
"export"
|
|
87
|
+
]).forEach((e) => {
|
|
88
|
+
e === "export" ? t.push({
|
|
89
|
+
name: "Export CSV",
|
|
90
|
+
icon: "<span>📥</span>",
|
|
91
|
+
action: () => M()
|
|
92
|
+
}) : e === "export-excel" ? t.push({
|
|
93
|
+
name: "Export Excel (CSV)",
|
|
94
|
+
icon: "<span>📊</span>",
|
|
95
|
+
action: () => N()
|
|
96
|
+
}) : e === "autoSizeAll" ? t.push({
|
|
97
|
+
name: "Auto-size All Columns",
|
|
98
|
+
action: () => {
|
|
99
|
+
A.current?.api && A.current.api.autoSizeAllColumns();
|
|
100
|
+
}
|
|
101
|
+
}) : e === "resetColumns" ? t.push({
|
|
102
|
+
name: "Reset Columns",
|
|
103
|
+
action: () => {
|
|
104
|
+
A.current?.api && A.current.api.resetColumnState();
|
|
105
|
+
}
|
|
106
|
+
}) : t.push(e);
|
|
107
|
+
}), E.customItems && (t.length > 0 && t.push("separator"), E.customItems.forEach((n) => {
|
|
108
|
+
t.push({
|
|
109
|
+
name: n.name,
|
|
110
|
+
disabled: n.disabled,
|
|
111
|
+
action: () => {
|
|
112
|
+
S?.onContextMenuAction && S.onContextMenuAction(n.action, e.node?.data);
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
})), t;
|
|
116
|
+
}, [
|
|
117
|
+
E,
|
|
118
|
+
M,
|
|
119
|
+
N,
|
|
120
|
+
S
|
|
121
|
+
]), F = n((e) => {
|
|
122
|
+
S?.onCellClicked?.(e);
|
|
123
|
+
}, [S]), I = n((e) => {
|
|
124
|
+
S?.onRowClicked?.(e);
|
|
125
|
+
}, [S]), L = n((e) => {
|
|
126
|
+
S?.onSelectionChanged?.(e);
|
|
127
|
+
}, [S]), R = n((e) => {
|
|
128
|
+
S?.onCellValueChanged?.(e);
|
|
129
|
+
}, [S]), z = n((e) => {
|
|
130
|
+
A.current = e;
|
|
131
|
+
}, []), B = i(() => t ? t.map((e) => {
|
|
132
|
+
let t = { ...e };
|
|
133
|
+
return g && e.editable !== !1 && (t.editable = !0), C && (C.resizable !== void 0 && e.resizable === void 0 && (t.resizable = C.resizable), C.sortable !== void 0 && e.sortable === void 0 && (t.sortable = C.sortable), C.filterable !== void 0 && e.filter === void 0 && (t.filter = C.filterable)), O?.enabled && O.groupByFields?.includes(e.field || "") && (t.rowGroup = !0, t.hide = !0), O?.aggregations && e.field && O.aggregations[e.field] && (t.aggFunc = O.aggregations[e.field]), t;
|
|
134
|
+
}) : [], [
|
|
135
|
+
t,
|
|
136
|
+
g,
|
|
137
|
+
C,
|
|
138
|
+
O
|
|
139
|
+
]), V = i(() => ({
|
|
140
|
+
...r,
|
|
141
|
+
pagination: a,
|
|
142
|
+
paginationPageSize: o,
|
|
143
|
+
domLayout: s,
|
|
144
|
+
animateRows: c,
|
|
145
|
+
rowSelection: f,
|
|
146
|
+
editType: _,
|
|
147
|
+
singleClickEdit: v,
|
|
148
|
+
stopEditingWhenCellsLoseFocus: y,
|
|
149
|
+
statusBar: j ? { statusPanels: j } : void 0,
|
|
150
|
+
enableRangeSelection: w,
|
|
151
|
+
enableCharts: T,
|
|
152
|
+
getContextMenuItems: E?.enabled ? P : void 0,
|
|
153
|
+
...D?.enabled ? {
|
|
154
|
+
treeData: !0,
|
|
155
|
+
getDataPath: D.pathField ? (e) => e[D.pathField] : void 0,
|
|
156
|
+
autoGroupColumnDef: {
|
|
157
|
+
headerName: "Hierarchy",
|
|
158
|
+
minWidth: 250,
|
|
159
|
+
cellRendererParams: { suppressCount: !1 }
|
|
160
|
+
},
|
|
161
|
+
groupDefaultExpanded: D.expandAll ? -1 : D.expandDepth ?? 0
|
|
162
|
+
} : {},
|
|
163
|
+
...O?.enabled ? {
|
|
164
|
+
groupDefaultExpanded: +!!O.groupByFields?.length,
|
|
165
|
+
autoGroupColumnDef: {
|
|
166
|
+
minWidth: 200,
|
|
167
|
+
cellRendererParams: { suppressCount: !O.showRowCount }
|
|
168
|
+
}
|
|
169
|
+
} : {},
|
|
170
|
+
suppressCellFocus: !g,
|
|
171
|
+
enableCellTextSelection: !0,
|
|
172
|
+
ensureDomOrder: !0,
|
|
173
|
+
rowBuffer: r.rowBuffer ?? 10,
|
|
174
|
+
debounceVerticalScrollbar: r.debounceVerticalScrollbar ?? e.length > 1e3,
|
|
175
|
+
onCellClicked: F,
|
|
176
|
+
onRowClicked: I,
|
|
177
|
+
onSelectionChanged: L,
|
|
178
|
+
onCellValueChanged: R,
|
|
179
|
+
onGridReady: z
|
|
180
|
+
}), [
|
|
181
|
+
r,
|
|
182
|
+
a,
|
|
183
|
+
o,
|
|
184
|
+
s,
|
|
185
|
+
c,
|
|
186
|
+
f,
|
|
187
|
+
_,
|
|
188
|
+
v,
|
|
189
|
+
y,
|
|
190
|
+
j,
|
|
191
|
+
w,
|
|
192
|
+
T,
|
|
193
|
+
E,
|
|
194
|
+
P,
|
|
195
|
+
D,
|
|
196
|
+
O,
|
|
197
|
+
g,
|
|
198
|
+
e.length,
|
|
199
|
+
F,
|
|
200
|
+
I,
|
|
201
|
+
L,
|
|
202
|
+
R,
|
|
203
|
+
z
|
|
204
|
+
]), H = i(() => ({
|
|
205
|
+
height: typeof m == "number" ? `${m}px` : m,
|
|
206
|
+
width: "100%"
|
|
207
|
+
}), [m]), U = [
|
|
208
|
+
`ag-theme-${p}`,
|
|
209
|
+
"rounded-xl",
|
|
210
|
+
"border",
|
|
211
|
+
"border-border",
|
|
212
|
+
"overflow-hidden",
|
|
213
|
+
"shadow-lg",
|
|
214
|
+
h
|
|
215
|
+
].filter(Boolean).join(" ");
|
|
216
|
+
return /* @__PURE__ */ u("div", {
|
|
217
|
+
className: "ag-grid-container",
|
|
218
|
+
children: [(b?.enabled || k?.enabled) && /* @__PURE__ */ u("div", {
|
|
219
|
+
className: "mb-2 flex gap-2",
|
|
220
|
+
children: [b?.enabled && /* @__PURE__ */ l("button", {
|
|
221
|
+
onClick: M,
|
|
222
|
+
className: "px-3 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors",
|
|
223
|
+
children: "Export CSV"
|
|
224
|
+
}), k?.enabled && /* @__PURE__ */ l("button", {
|
|
225
|
+
onClick: N,
|
|
226
|
+
className: "px-3 py-1.5 text-sm font-medium text-white bg-green-600 hover:bg-green-700 rounded-md transition-colors",
|
|
227
|
+
children: "Export Excel (CSV)"
|
|
228
|
+
})]
|
|
229
|
+
}), /* @__PURE__ */ l("div", {
|
|
230
|
+
className: U,
|
|
231
|
+
style: H,
|
|
232
|
+
children: /* @__PURE__ */ l(d, {
|
|
233
|
+
ref: A,
|
|
234
|
+
rowData: e,
|
|
235
|
+
columnDefs: B,
|
|
236
|
+
gridOptions: V
|
|
237
|
+
})
|
|
238
|
+
})]
|
|
239
|
+
});
|
|
240
|
+
}
|
|
241
|
+
var z = F((() => {})), B, V = F((() => {
|
|
242
|
+
B = {
|
|
243
|
+
text: "agTextColumnFilter",
|
|
244
|
+
textarea: "agTextColumnFilter",
|
|
245
|
+
number: "agNumberColumnFilter",
|
|
246
|
+
currency: "agNumberColumnFilter",
|
|
247
|
+
percent: "agNumberColumnFilter",
|
|
248
|
+
boolean: "agSetColumnFilter",
|
|
249
|
+
date: "agDateColumnFilter",
|
|
250
|
+
datetime: "agDateColumnFilter",
|
|
251
|
+
time: "agTextColumnFilter",
|
|
252
|
+
email: "agTextColumnFilter",
|
|
253
|
+
phone: "agTextColumnFilter",
|
|
254
|
+
url: "agTextColumnFilter",
|
|
255
|
+
select: "agSetColumnFilter"
|
|
256
|
+
};
|
|
257
|
+
}));
|
|
258
|
+
//#endregion
|
|
259
|
+
//#region src/field-renderers.tsx
|
|
260
|
+
function H(e) {
|
|
261
|
+
return G[e] || null;
|
|
262
|
+
}
|
|
263
|
+
function U(e) {
|
|
264
|
+
return class extends K {
|
|
265
|
+
init(t) {
|
|
266
|
+
super.init({
|
|
267
|
+
...t,
|
|
268
|
+
field: e
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
refresh(t) {
|
|
272
|
+
return super.refresh({
|
|
273
|
+
...t,
|
|
274
|
+
field: e
|
|
275
|
+
});
|
|
276
|
+
}
|
|
277
|
+
};
|
|
278
|
+
}
|
|
279
|
+
function W(e) {
|
|
280
|
+
return class extends q {
|
|
281
|
+
init(t) {
|
|
282
|
+
super.init({
|
|
283
|
+
...t,
|
|
284
|
+
field: e
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
var G, K, q, J = F((() => {
|
|
290
|
+
G = {
|
|
291
|
+
text: j,
|
|
292
|
+
textarea: A,
|
|
293
|
+
number: C,
|
|
294
|
+
currency: _,
|
|
295
|
+
percent: T,
|
|
296
|
+
boolean: m,
|
|
297
|
+
select: O,
|
|
298
|
+
date: v,
|
|
299
|
+
datetime: y,
|
|
300
|
+
time: M,
|
|
301
|
+
email: b,
|
|
302
|
+
phone: E,
|
|
303
|
+
url: N,
|
|
304
|
+
password: w,
|
|
305
|
+
color: g,
|
|
306
|
+
rating: D,
|
|
307
|
+
image: x,
|
|
308
|
+
avatar: p,
|
|
309
|
+
lookup: S,
|
|
310
|
+
slider: k,
|
|
311
|
+
code: h
|
|
312
|
+
}, K = class {
|
|
313
|
+
eGui;
|
|
314
|
+
root = null;
|
|
315
|
+
init(e) {
|
|
316
|
+
let { value: t, field: n } = e, r = H(n.type);
|
|
317
|
+
this.eGui = document.createElement("div"), this.eGui.className = "field-widget-cell", r ? (this.root = f(this.eGui), this.root.render(/* @__PURE__ */ l(r, {
|
|
318
|
+
value: t,
|
|
319
|
+
onChange: () => {},
|
|
320
|
+
field: n,
|
|
321
|
+
readonly: !0
|
|
322
|
+
}))) : this.eGui.textContent = t == null ? "" : String(t);
|
|
323
|
+
}
|
|
324
|
+
getGui() {
|
|
325
|
+
return this.eGui;
|
|
326
|
+
}
|
|
327
|
+
refresh(e) {
|
|
328
|
+
let { value: t, field: n } = e, r = H(n.type);
|
|
329
|
+
return r && this.root ? (this.root.render(/* @__PURE__ */ l(r, {
|
|
330
|
+
value: t,
|
|
331
|
+
onChange: () => {},
|
|
332
|
+
field: n,
|
|
333
|
+
readonly: !0
|
|
334
|
+
})), !0) : this.eGui ? (this.eGui.textContent = t == null ? "" : String(t), !0) : !1;
|
|
335
|
+
}
|
|
336
|
+
destroy() {
|
|
337
|
+
this.root && this.root.unmount();
|
|
338
|
+
}
|
|
339
|
+
}, q = class {
|
|
340
|
+
eGui;
|
|
341
|
+
root = null;
|
|
342
|
+
currentValue;
|
|
343
|
+
params;
|
|
344
|
+
init(e) {
|
|
345
|
+
this.params = e, this.currentValue = e.value;
|
|
346
|
+
let { field: t } = e, n = H(t.type);
|
|
347
|
+
if (this.eGui = document.createElement("div"), this.eGui.className = "field-widget-editor", n) this.root = f(this.eGui), this.root.render(/* @__PURE__ */ l(n, {
|
|
348
|
+
value: this.currentValue,
|
|
349
|
+
onChange: (e) => {
|
|
350
|
+
this.currentValue = e;
|
|
351
|
+
},
|
|
352
|
+
field: t,
|
|
353
|
+
readonly: !1
|
|
354
|
+
}));
|
|
355
|
+
else {
|
|
356
|
+
let e = document.createElement("input");
|
|
357
|
+
e.value = this.currentValue == null ? "" : String(this.currentValue), e.className = "ag-input-field-input ag-text-field-input", e.addEventListener("input", (e) => {
|
|
358
|
+
this.currentValue = e.target.value;
|
|
359
|
+
}), this.eGui.appendChild(e), setTimeout(() => e.focus(), 0);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
getGui() {
|
|
363
|
+
return this.eGui;
|
|
364
|
+
}
|
|
365
|
+
getValue() {
|
|
366
|
+
return this.currentValue;
|
|
367
|
+
}
|
|
368
|
+
destroy() {
|
|
369
|
+
this.root && this.root.unmount();
|
|
370
|
+
}
|
|
371
|
+
isPopup() {
|
|
372
|
+
return [
|
|
373
|
+
"date",
|
|
374
|
+
"datetime",
|
|
375
|
+
"select",
|
|
376
|
+
"lookup",
|
|
377
|
+
"color"
|
|
378
|
+
].includes(this.params.field.type);
|
|
379
|
+
}
|
|
380
|
+
};
|
|
381
|
+
})), Y = /* @__PURE__ */ I({ default: () => X });
|
|
382
|
+
function X({ objectName: e, dataSource: t, fields: o, fieldNames: c, filters: f, sort: p, pageSize: m = 10, pagination: h = !0, domLayout: g = "normal", animateRows: _ = !0, rowSelection: v, theme: y = "quartz", height: b = 500, className: x = "", editable: S = !1, editType: C, singleClickEdit: w = !1, stopEditingWhenCellsLoseFocus: T = !0, exportConfig: E, statusBar: D, callbacks: O, columnConfig: k, enableRangeSelection: A = !1, enableCharts: j = !1, contextMenu: M }) {
|
|
383
|
+
let N = ee(null), [P, F] = a(!0), [I, L] = a(null), [R, z] = a(null), [B, V] = a([]);
|
|
384
|
+
r(() => {
|
|
385
|
+
if (!t) {
|
|
386
|
+
L(/* @__PURE__ */ Error("DataSource is required")), F(!1);
|
|
387
|
+
return;
|
|
388
|
+
}
|
|
389
|
+
(async () => {
|
|
390
|
+
try {
|
|
391
|
+
F(!0), L(null), z(await t.getObjectSchema(e));
|
|
392
|
+
} catch (e) {
|
|
393
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
394
|
+
L(t), O?.onDataError?.(t);
|
|
395
|
+
} finally {
|
|
396
|
+
F(!1);
|
|
397
|
+
}
|
|
398
|
+
})();
|
|
399
|
+
}, [
|
|
400
|
+
e,
|
|
401
|
+
t,
|
|
402
|
+
O
|
|
403
|
+
]), r(() => {
|
|
404
|
+
!t || !R || (async () => {
|
|
405
|
+
try {
|
|
406
|
+
F(!0), L(null);
|
|
407
|
+
let n = {
|
|
408
|
+
$top: m,
|
|
409
|
+
$skip: 0
|
|
410
|
+
};
|
|
411
|
+
f && (n.$filter = f), p && (n.$orderby = p);
|
|
412
|
+
let r = s(R?.fields);
|
|
413
|
+
r.length > 0 && (n.$expand = r);
|
|
414
|
+
let i = await t.find(e, n);
|
|
415
|
+
V(i.data || []), O?.onDataLoaded?.(i.data || []);
|
|
416
|
+
} catch (e) {
|
|
417
|
+
let t = e instanceof Error ? e : Error(String(e));
|
|
418
|
+
L(t), O?.onDataError?.(t);
|
|
419
|
+
} finally {
|
|
420
|
+
F(!1);
|
|
421
|
+
}
|
|
422
|
+
})();
|
|
423
|
+
}, [
|
|
424
|
+
e,
|
|
425
|
+
t,
|
|
426
|
+
R,
|
|
427
|
+
f,
|
|
428
|
+
p,
|
|
429
|
+
m,
|
|
430
|
+
O
|
|
431
|
+
]);
|
|
432
|
+
let H = i(() => {
|
|
433
|
+
if (!R?.fields) return [];
|
|
434
|
+
let e = o || Object.values(R.fields);
|
|
435
|
+
return (c ? e.filter((e) => c.includes(e.name)) : e).map((e) => {
|
|
436
|
+
let t = {
|
|
437
|
+
field: e.name,
|
|
438
|
+
headerName: e.label || e.name,
|
|
439
|
+
sortable: e.sortable !== !1,
|
|
440
|
+
filter: te(e),
|
|
441
|
+
editable: S && !e.readonly
|
|
442
|
+
};
|
|
443
|
+
return k && (k.resizable !== void 0 && (t.resizable = k.resizable), k.sortable !== void 0 && t.sortable === void 0 && (t.sortable = k.sortable)), ne(t, e), t;
|
|
444
|
+
});
|
|
445
|
+
}, [
|
|
446
|
+
R,
|
|
447
|
+
o,
|
|
448
|
+
c,
|
|
449
|
+
S,
|
|
450
|
+
k
|
|
451
|
+
]), U = i(() => {
|
|
452
|
+
if (!D?.enabled) return;
|
|
453
|
+
let e = D.aggregations || [
|
|
454
|
+
"count",
|
|
455
|
+
"sum",
|
|
456
|
+
"avg"
|
|
457
|
+
], t = [];
|
|
458
|
+
return e.includes("count") && t.push({
|
|
459
|
+
statusPanel: "agAggregationComponent",
|
|
460
|
+
statusPanelParams: { aggFuncs: ["count"] }
|
|
461
|
+
}), e.includes("sum") && t.push({
|
|
462
|
+
statusPanel: "agAggregationComponent",
|
|
463
|
+
statusPanelParams: { aggFuncs: ["sum"] }
|
|
464
|
+
}), e.includes("avg") && t.push({
|
|
465
|
+
statusPanel: "agAggregationComponent",
|
|
466
|
+
statusPanelParams: { aggFuncs: ["avg"] }
|
|
467
|
+
}), e.includes("min") && t.push({
|
|
468
|
+
statusPanel: "agAggregationComponent",
|
|
469
|
+
statusPanelParams: { aggFuncs: ["min"] }
|
|
470
|
+
}), e.includes("max") && t.push({
|
|
471
|
+
statusPanel: "agAggregationComponent",
|
|
472
|
+
statusPanelParams: { aggFuncs: ["max"] }
|
|
473
|
+
}), t;
|
|
474
|
+
}, [D]), W = n(() => {
|
|
475
|
+
if (!N.current?.api) return;
|
|
476
|
+
let t = {
|
|
477
|
+
fileName: E?.fileName || `${e}-export.csv`,
|
|
478
|
+
skipColumnHeaders: E?.skipColumnHeaders || !1,
|
|
479
|
+
allColumns: E?.allColumns || !1,
|
|
480
|
+
onlySelected: E?.onlySelected || !1
|
|
481
|
+
};
|
|
482
|
+
if (N.current.api.exportDataAsCsv(t), O?.onExport) {
|
|
483
|
+
let e = E?.onlySelected ? N.current.api.getSelectedRows() : B;
|
|
484
|
+
O.onExport(e || [], "csv");
|
|
485
|
+
}
|
|
486
|
+
}, [
|
|
487
|
+
E,
|
|
488
|
+
O,
|
|
489
|
+
B,
|
|
490
|
+
e
|
|
491
|
+
]), G = n((e) => {
|
|
492
|
+
if (!M?.enabled) return [];
|
|
493
|
+
let t = [];
|
|
494
|
+
return (M.items || [
|
|
495
|
+
"copy",
|
|
496
|
+
"copyWithHeaders",
|
|
497
|
+
"separator",
|
|
498
|
+
"export"
|
|
499
|
+
]).forEach((e) => {
|
|
500
|
+
e === "export" ? t.push({
|
|
501
|
+
name: "Export CSV",
|
|
502
|
+
icon: "<span>📥</span>",
|
|
503
|
+
action: () => W()
|
|
504
|
+
}) : e === "autoSizeAll" ? t.push({
|
|
505
|
+
name: "Auto-size All Columns",
|
|
506
|
+
action: () => {
|
|
507
|
+
N.current?.api && N.current.api.autoSizeAllColumns();
|
|
508
|
+
}
|
|
509
|
+
}) : e === "resetColumns" ? t.push({
|
|
510
|
+
name: "Reset Columns",
|
|
511
|
+
action: () => {
|
|
512
|
+
N.current?.api && N.current.api.resetColumnState();
|
|
513
|
+
}
|
|
514
|
+
}) : t.push(e);
|
|
515
|
+
}), M.customItems && (t.length > 0 && t.push("separator"), M.customItems.forEach((n) => {
|
|
516
|
+
t.push({
|
|
517
|
+
name: n.name,
|
|
518
|
+
disabled: n.disabled,
|
|
519
|
+
action: () => {
|
|
520
|
+
O?.onContextMenuAction && O.onContextMenuAction(n.action, e.node?.data);
|
|
521
|
+
}
|
|
522
|
+
});
|
|
523
|
+
})), t;
|
|
524
|
+
}, [
|
|
525
|
+
M,
|
|
526
|
+
W,
|
|
527
|
+
O
|
|
528
|
+
]), K = n((e) => {
|
|
529
|
+
O?.onCellClicked?.(e);
|
|
530
|
+
}, [O]), q = n((e) => {
|
|
531
|
+
O?.onRowClicked?.(e);
|
|
532
|
+
}, [O]), J = n((e) => {
|
|
533
|
+
O?.onSelectionChanged?.(e);
|
|
534
|
+
}, [O]), Y = n(async (n) => {
|
|
535
|
+
if (O?.onCellValueChanged?.(n), t && n.data && n.data.id) try {
|
|
536
|
+
await t.update(e, n.data.id, { [n.colDef.field]: n.newValue });
|
|
537
|
+
} catch (e) {
|
|
538
|
+
console.error("Failed to update record:", e), n.node.setDataValue(n.colDef.field, n.oldValue);
|
|
539
|
+
}
|
|
540
|
+
}, [
|
|
541
|
+
O,
|
|
542
|
+
t,
|
|
543
|
+
e
|
|
544
|
+
]), X = n((e) => {
|
|
545
|
+
N.current = e;
|
|
546
|
+
}, []), re = i(() => ({
|
|
547
|
+
pagination: h,
|
|
548
|
+
paginationPageSize: m,
|
|
549
|
+
domLayout: g,
|
|
550
|
+
animateRows: _,
|
|
551
|
+
rowSelection: v,
|
|
552
|
+
editType: C,
|
|
553
|
+
singleClickEdit: w,
|
|
554
|
+
stopEditingWhenCellsLoseFocus: T,
|
|
555
|
+
statusBar: U ? { statusPanels: U } : void 0,
|
|
556
|
+
enableRangeSelection: A,
|
|
557
|
+
enableCharts: j,
|
|
558
|
+
getContextMenuItems: M?.enabled ? G : void 0,
|
|
559
|
+
suppressCellFocus: !S,
|
|
560
|
+
enableCellTextSelection: !0,
|
|
561
|
+
ensureDomOrder: !0,
|
|
562
|
+
onCellClicked: K,
|
|
563
|
+
onRowClicked: q,
|
|
564
|
+
onSelectionChanged: J,
|
|
565
|
+
onCellValueChanged: Y,
|
|
566
|
+
onGridReady: X
|
|
567
|
+
}), [
|
|
568
|
+
h,
|
|
569
|
+
m,
|
|
570
|
+
g,
|
|
571
|
+
_,
|
|
572
|
+
v,
|
|
573
|
+
C,
|
|
574
|
+
w,
|
|
575
|
+
T,
|
|
576
|
+
U,
|
|
577
|
+
A,
|
|
578
|
+
j,
|
|
579
|
+
M,
|
|
580
|
+
G,
|
|
581
|
+
S,
|
|
582
|
+
K,
|
|
583
|
+
q,
|
|
584
|
+
J,
|
|
585
|
+
Y,
|
|
586
|
+
X
|
|
587
|
+
]), Z = i(() => ({
|
|
588
|
+
height: typeof b == "number" ? `${b}px` : b,
|
|
589
|
+
width: "100%"
|
|
590
|
+
}), [b]), ie = [
|
|
591
|
+
`ag-theme-${y}`,
|
|
592
|
+
"rounded-xl",
|
|
593
|
+
"border",
|
|
594
|
+
"border-border",
|
|
595
|
+
"overflow-hidden",
|
|
596
|
+
"shadow-lg",
|
|
597
|
+
x
|
|
598
|
+
].filter(Boolean).join(" ");
|
|
599
|
+
return P ? /* @__PURE__ */ l("div", {
|
|
600
|
+
className: "flex items-center justify-center",
|
|
601
|
+
style: Z,
|
|
602
|
+
children: /* @__PURE__ */ u("div", {
|
|
603
|
+
className: "text-muted-foreground",
|
|
604
|
+
children: [
|
|
605
|
+
"Loading ",
|
|
606
|
+
e,
|
|
607
|
+
"..."
|
|
608
|
+
]
|
|
609
|
+
})
|
|
610
|
+
}) : I ? /* @__PURE__ */ l("div", {
|
|
611
|
+
className: "flex items-center justify-center",
|
|
612
|
+
style: Z,
|
|
613
|
+
children: /* @__PURE__ */ u("div", {
|
|
614
|
+
className: "text-destructive",
|
|
615
|
+
children: ["Error loading data: ", I.message]
|
|
616
|
+
})
|
|
617
|
+
}) : /* @__PURE__ */ u("div", {
|
|
618
|
+
className: "object-aggrid-container",
|
|
619
|
+
children: [E?.enabled && /* @__PURE__ */ l("div", {
|
|
620
|
+
className: "mb-2 flex gap-2",
|
|
621
|
+
children: /* @__PURE__ */ l("button", {
|
|
622
|
+
onClick: W,
|
|
623
|
+
className: "px-3 py-1.5 text-sm font-medium text-white bg-blue-600 hover:bg-blue-700 rounded-md transition-colors",
|
|
624
|
+
children: "Export CSV"
|
|
625
|
+
})
|
|
626
|
+
}), /* @__PURE__ */ l("div", {
|
|
627
|
+
className: ie,
|
|
628
|
+
style: Z,
|
|
629
|
+
children: /* @__PURE__ */ l(d, {
|
|
630
|
+
ref: N,
|
|
631
|
+
rowData: B,
|
|
632
|
+
columnDefs: H,
|
|
633
|
+
gridOptions: re
|
|
634
|
+
})
|
|
635
|
+
})]
|
|
636
|
+
});
|
|
637
|
+
}
|
|
638
|
+
function te(e) {
|
|
639
|
+
return e.filterable === !1 ? !1 : B[e.type] || "agTextColumnFilter";
|
|
640
|
+
}
|
|
641
|
+
function ne(e, t) {
|
|
642
|
+
if ([
|
|
643
|
+
"text",
|
|
644
|
+
"textarea",
|
|
645
|
+
"number",
|
|
646
|
+
"currency",
|
|
647
|
+
"percent",
|
|
648
|
+
"boolean",
|
|
649
|
+
"select",
|
|
650
|
+
"date",
|
|
651
|
+
"datetime",
|
|
652
|
+
"time",
|
|
653
|
+
"email",
|
|
654
|
+
"phone",
|
|
655
|
+
"url",
|
|
656
|
+
"password",
|
|
657
|
+
"color",
|
|
658
|
+
"rating",
|
|
659
|
+
"image",
|
|
660
|
+
"avatar",
|
|
661
|
+
"lookup",
|
|
662
|
+
"slider",
|
|
663
|
+
"code"
|
|
664
|
+
].includes(t.type)) e.cellRenderer = U(t), e.editable && (e.cellEditor = W(t), [
|
|
665
|
+
"date",
|
|
666
|
+
"datetime",
|
|
667
|
+
"select",
|
|
668
|
+
"lookup",
|
|
669
|
+
"color"
|
|
670
|
+
].includes(t.type) && (e.cellEditorPopup = !0));
|
|
671
|
+
else switch (t.type) {
|
|
672
|
+
case "master_detail":
|
|
673
|
+
e.valueFormatter = (e) => e.value ? typeof e.value == "object" ? e.value.name || e.value.label || e.value.id || "" : String(e.value) : "";
|
|
674
|
+
break;
|
|
675
|
+
case "object":
|
|
676
|
+
e.cellRenderer = () => {
|
|
677
|
+
let e = document.createElement("span");
|
|
678
|
+
return e.className = "text-gray-500 italic", e.textContent = "[Object]", e;
|
|
679
|
+
};
|
|
680
|
+
break;
|
|
681
|
+
case "vector":
|
|
682
|
+
e.cellRenderer = () => {
|
|
683
|
+
let e = document.createElement("span");
|
|
684
|
+
return e.className = "text-gray-500 italic", e.textContent = "[Vector]", e;
|
|
685
|
+
};
|
|
686
|
+
break;
|
|
687
|
+
case "grid":
|
|
688
|
+
e.cellRenderer = () => {
|
|
689
|
+
let e = document.createElement("span");
|
|
690
|
+
return e.className = "text-gray-500 italic", e.textContent = "[Grid]", e;
|
|
691
|
+
};
|
|
692
|
+
break;
|
|
693
|
+
default: e.valueFormatter = (e) => e.value == null ? "" : String(e.value);
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
var re = F((() => {
|
|
697
|
+
V(), J();
|
|
698
|
+
})), Z = e.lazy(() => Promise.resolve().then(() => (z(), L))), ie = e.lazy(() => Promise.resolve().then(() => (re(), Y))), Q = ({ schema: e }) => /* @__PURE__ */ l(t, {
|
|
699
|
+
fallback: /* @__PURE__ */ l(c, { className: "w-full h-[500px]" }),
|
|
700
|
+
children: /* @__PURE__ */ l(Z, {
|
|
14
701
|
rowData: e.rowData,
|
|
15
702
|
columnDefs: e.columnDefs,
|
|
16
703
|
gridOptions: e.gridOptions,
|
|
@@ -38,7 +725,7 @@ var a = e.lazy(() => import("./AgGridImpl-CAfXf2vU.js")), o = e.lazy(() => impor
|
|
|
38
725
|
excelExport: e.excelExport
|
|
39
726
|
})
|
|
40
727
|
});
|
|
41
|
-
|
|
728
|
+
o.register("aggrid", Q, {
|
|
42
729
|
namespace: "plugin-aggrid",
|
|
43
730
|
label: "AG Grid",
|
|
44
731
|
icon: "Table",
|
|
@@ -362,9 +1049,9 @@ n.register("aggrid", s, {
|
|
|
362
1049
|
domLayout: "normal"
|
|
363
1050
|
}
|
|
364
1051
|
});
|
|
365
|
-
var
|
|
366
|
-
fallback: /* @__PURE__ */
|
|
367
|
-
children: /* @__PURE__ */
|
|
1052
|
+
var $ = ({ schema: e }) => /* @__PURE__ */ l(t, {
|
|
1053
|
+
fallback: /* @__PURE__ */ l(c, { className: "w-full h-[500px]" }),
|
|
1054
|
+
children: /* @__PURE__ */ l(ie, {
|
|
368
1055
|
objectName: e.objectName,
|
|
369
1056
|
dataSource: e.dataSource,
|
|
370
1057
|
fields: e.fields,
|
|
@@ -391,11 +1078,11 @@ var c = ({ schema: e }) => /* @__PURE__ */ i(t, {
|
|
|
391
1078
|
enableCharts: e.enableCharts,
|
|
392
1079
|
contextMenu: e.contextMenu
|
|
393
1080
|
})
|
|
394
|
-
}),
|
|
395
|
-
aggrid:
|
|
396
|
-
"object-aggrid":
|
|
1081
|
+
}), ae = {
|
|
1082
|
+
aggrid: Q,
|
|
1083
|
+
"object-aggrid": $
|
|
397
1084
|
};
|
|
398
|
-
|
|
1085
|
+
o.register("object-aggrid", $, {
|
|
399
1086
|
namespace: "plugin-aggrid",
|
|
400
1087
|
label: "Object AG Grid",
|
|
401
1088
|
icon: "Table",
|
|
@@ -506,4 +1193,4 @@ n.register("object-aggrid", c, {
|
|
|
506
1193
|
]
|
|
507
1194
|
});
|
|
508
1195
|
//#endregion
|
|
509
|
-
export {
|
|
1196
|
+
export { Q as AgGridRenderer, $ as ObjectAgGridRenderer, ae as aggridComponents };
|