@progress/kendo-react-webmcp 15.0.1-develop.3 → 15.0.1-develop.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.
- package/WebMcpProvider.js +1 -1
- package/WebMcpProvider.mjs +84 -80
- package/adapters/button.d.ts +1 -1
- package/adapters/button.js +1 -1
- package/adapters/button.mjs +12 -17
- package/adapters/{dashboard.d.ts → checkbox.d.ts} +5 -6
- package/adapters/checkbox.js +8 -0
- package/adapters/checkbox.mjs +60 -0
- package/adapters/dropdowntree.js +1 -1
- package/adapters/dropdowntree.mjs +78 -51
- package/adapters/editor.d.ts +0 -1
- package/adapters/editor.js +1 -1
- package/adapters/editor.mjs +38 -46
- package/adapters/form.d.ts +1 -0
- package/adapters/form.js +3 -3
- package/adapters/form.mjs +75 -49
- package/adapters/gantt.d.ts +2 -0
- package/adapters/gantt.js +1 -1
- package/adapters/gantt.mjs +188 -140
- package/adapters/grid.d.ts +0 -1
- package/adapters/grid.js +1 -1
- package/adapters/grid.mjs +52 -60
- package/adapters/multicolumncombobox.d.ts +20 -0
- package/adapters/multicolumncombobox.js +8 -0
- package/adapters/multicolumncombobox.mjs +75 -0
- package/adapters/multiselect.d.ts +2 -0
- package/adapters/multiselect.js +1 -1
- package/adapters/multiselect.mjs +46 -30
- package/adapters/notification.js +1 -1
- package/adapters/notification.mjs +14 -14
- package/adapters/pivotgrid.js +1 -1
- package/adapters/pivotgrid.mjs +39 -47
- package/adapters/scheduler.js +1 -1
- package/adapters/scheduler.mjs +137 -92
- package/adapters/spreadsheet.js +1 -1
- package/adapters/spreadsheet.mjs +3 -3
- package/adapters/switch.js +1 -1
- package/adapters/switch.mjs +29 -19
- package/adapters/treeview.js +2 -2
- package/adapters/treeview.mjs +79 -113
- package/adapters/window.d.ts +0 -2
- package/adapters/window.js +1 -1
- package/adapters/window.mjs +29 -63
- package/commands/form.d.ts +4 -1
- package/commands/form.js +1 -1
- package/commands/form.mjs +11 -7
- package/commands/gantt.js +1 -1
- package/commands/gantt.mjs +14 -10
- package/commands/grid.d.ts +0 -4
- package/commands/grid.js +1 -1
- package/commands/grid.mjs +18 -24
- package/commands/index.d.ts +0 -1
- package/commands/pivotgrid.d.ts +0 -4
- package/commands/pivotgrid.js +1 -1
- package/commands/pivotgrid.mjs +6 -12
- package/commands/scheduler.d.ts +10 -0
- package/commands/scheduler.js +1 -1
- package/commands/scheduler.mjs +16 -4
- package/commands/window.d.ts +0 -8
- package/commands/window.js +1 -1
- package/commands/window.mjs +8 -18
- package/dist/cdn/js/kendo-react-webmcp.js +1 -1
- package/index.d.mts +2 -1
- package/index.d.ts +2 -1
- package/index.js +1 -1
- package/index.mjs +248 -249
- package/package.json +3 -3
- package/schemas/gantt.d.ts +4 -0
- package/schemas/gantt.js +1 -1
- package/schemas/gantt.mjs +93 -8
- package/schemas/scheduler.d.ts +2 -0
- package/schemas/scheduler.js +1 -1
- package/schemas/scheduler.mjs +21 -5
- package/adapters/dashboard.js +0 -8
- package/adapters/dashboard.mjs +0 -41
- package/commands/dashboard.d.ts +0 -19
- package/commands/dashboard.js +0 -8
- package/commands/dashboard.mjs +0 -21
package/adapters/gantt.mjs
CHANGED
|
@@ -5,220 +5,232 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
import * as
|
|
9
|
-
import { GanttCommands as i, getGanttToolSchema as
|
|
10
|
-
import { toText as
|
|
11
|
-
|
|
8
|
+
import * as I from "react";
|
|
9
|
+
import { GanttCommands as i, getGanttToolSchema as j } from "../commands/gantt.mjs";
|
|
10
|
+
import { toText as g } from "./utils.mjs";
|
|
11
|
+
const A = "GanttUpdateTask", G = "GanttSelect";
|
|
12
|
+
function T(e) {
|
|
12
13
|
return {
|
|
13
|
-
id: (
|
|
14
|
-
title: (
|
|
15
|
-
start: (
|
|
16
|
-
end: (
|
|
17
|
-
percentComplete: (
|
|
18
|
-
isExpanded: (
|
|
19
|
-
children: (
|
|
14
|
+
id: (e == null ? void 0 : e.id) || "id",
|
|
15
|
+
title: (e == null ? void 0 : e.title) || "title",
|
|
16
|
+
start: (e == null ? void 0 : e.start) || "start",
|
|
17
|
+
end: (e == null ? void 0 : e.end) || "end",
|
|
18
|
+
percentComplete: (e == null ? void 0 : e.percentComplete) || "percentComplete",
|
|
19
|
+
isExpanded: (e == null ? void 0 : e.isExpanded) || "isExpanded",
|
|
20
|
+
children: (e == null ? void 0 : e.children) || "children"
|
|
20
21
|
};
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
const n = [], r = (
|
|
24
|
-
for (const c of
|
|
23
|
+
function w(e, t) {
|
|
24
|
+
const n = [], r = (a) => {
|
|
25
|
+
for (const c of a) {
|
|
25
26
|
n.push(c);
|
|
26
|
-
const
|
|
27
|
-
Array.isArray(
|
|
27
|
+
const o = c[t.children];
|
|
28
|
+
Array.isArray(o) && o.length > 0 && r(o);
|
|
28
29
|
}
|
|
29
30
|
};
|
|
30
|
-
return r(
|
|
31
|
+
return r(e), n;
|
|
31
32
|
}
|
|
32
|
-
function
|
|
33
|
-
const
|
|
34
|
-
if (Array.isArray(
|
|
35
|
-
for (const n of
|
|
36
|
-
n.field &&
|
|
37
|
-
return
|
|
38
|
-
if (
|
|
33
|
+
function B(e) {
|
|
34
|
+
const t = [];
|
|
35
|
+
if (Array.isArray(e.columns))
|
|
36
|
+
for (const n of e.columns)
|
|
37
|
+
n.field && t.push({ field: n.field, id: n.id || n.field });
|
|
38
|
+
return t.length === 0 && e.children && I.Children.forEach(e.children, (n) => {
|
|
39
|
+
if (I.isValidElement(n) && n.props.field) {
|
|
39
40
|
const r = n.props;
|
|
40
|
-
|
|
41
|
+
t.push({ field: r.field, id: r.id || r.field });
|
|
41
42
|
}
|
|
42
|
-
}),
|
|
43
|
+
}), t;
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
if (!
|
|
45
|
+
function K(e, t, n) {
|
|
46
|
+
if (!e.field)
|
|
46
47
|
return { content: [{ type: "text", text: "Missing required argument: field" }], isError: !0 };
|
|
47
|
-
const r =
|
|
48
|
-
return
|
|
48
|
+
const r = e.field, a = e.dir || "asc", c = [{ field: r, dir: a }];
|
|
49
|
+
return t.current.onSortChange && t.current.onSortChange({ sort: c, field: r, target: n }), { content: [{ type: "text", text: `Sorted by ${r} ${a}.` }] };
|
|
49
50
|
}
|
|
50
|
-
function
|
|
51
|
-
if (!
|
|
51
|
+
function O(e, t, n) {
|
|
52
|
+
if (!e.field || !e.operator)
|
|
52
53
|
return { content: [{ type: "text", text: "Missing required arguments: field, operator" }], isError: !0 };
|
|
53
|
-
const r =
|
|
54
|
-
return
|
|
55
|
-
filter: { logic: "and", filters: [{ field: r, operator:
|
|
54
|
+
const r = e.field, a = e.operator, c = e.value;
|
|
55
|
+
return t.current.onFilterChange && t.current.onFilterChange({
|
|
56
|
+
filter: { logic: "and", filters: [{ field: r, operator: a, value: c }] },
|
|
56
57
|
target: n
|
|
57
|
-
}), { content: [{ type: "text", text: `Filter applied: ${r} ${
|
|
58
|
+
}), { content: [{ type: "text", text: `Filter applied: ${r} ${a} "${g(c)}".` }] };
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
-
const r = typeof
|
|
61
|
-
switch (
|
|
60
|
+
function b(e, t, n) {
|
|
61
|
+
const r = typeof e == "string" ? e.toLowerCase() : e, a = typeof n == "string" ? n.toLowerCase() : n;
|
|
62
|
+
switch (t) {
|
|
62
63
|
case "eq":
|
|
63
|
-
return r ===
|
|
64
|
+
return r === a;
|
|
64
65
|
case "neq":
|
|
65
|
-
return r !==
|
|
66
|
+
return r !== a;
|
|
66
67
|
case "contains":
|
|
67
|
-
return typeof r == "string" && typeof
|
|
68
|
+
return typeof r == "string" && typeof a == "string" && r.includes(a);
|
|
68
69
|
case "startswith":
|
|
69
|
-
return typeof r == "string" && typeof
|
|
70
|
+
return typeof r == "string" && typeof a == "string" && r.startsWith(a);
|
|
70
71
|
case "endswith":
|
|
71
|
-
return typeof r == "string" && typeof
|
|
72
|
+
return typeof r == "string" && typeof a == "string" && r.endsWith(a);
|
|
72
73
|
default:
|
|
73
|
-
return r ===
|
|
74
|
+
return r === a;
|
|
74
75
|
}
|
|
75
76
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
77
|
+
function q(e, t, n, r) {
|
|
78
|
+
const a = n.current, c = T(a.taskModelFields), o = w(a.taskData || [], c);
|
|
78
79
|
let s;
|
|
79
|
-
return
|
|
80
|
-
const d = l[
|
|
81
|
-
return
|
|
82
|
-
}) :
|
|
80
|
+
return t.field && t.operator ? s = o.find((l) => {
|
|
81
|
+
const d = l[t.field];
|
|
82
|
+
return b(d, t.operator, t.value);
|
|
83
|
+
}) : t.id !== void 0 && (s = o.find((l) => String(l[c.id]) === String(t.id))), s ? (a.onExpandChange && a.onExpandChange({ dataItem: s, value: e, level: [], target: r }), { content: [{ type: "text", text: `${e ? "Expanded" : "Collapsed"} task "${g(s[c.title])}".` }] }) : { content: [{ type: "text", text: "No matching task found." }], isError: !0 };
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
-
const r =
|
|
86
|
-
const l = u[
|
|
85
|
+
function R(e, t, n) {
|
|
86
|
+
const r = t.current, a = T(r.taskModelFields), o = w(r.taskData || [], a).filter((u) => {
|
|
87
|
+
const l = u[a.children];
|
|
87
88
|
return Array.isArray(l) && l.length > 0;
|
|
88
89
|
});
|
|
89
90
|
if (r.onExpandChange)
|
|
90
|
-
for (const u of
|
|
91
|
-
r.onExpandChange({ dataItem: u, value:
|
|
92
|
-
return { content: [{ type: "text", text: `${
|
|
91
|
+
for (const u of o)
|
|
92
|
+
r.onExpandChange({ dataItem: u, value: e, level: [], target: n });
|
|
93
|
+
return { content: [{ type: "text", text: `${e ? "Expanded" : "Collapsed"} ${o.length} parent task(s).` }] };
|
|
93
94
|
}
|
|
94
|
-
function
|
|
95
|
-
switch (
|
|
95
|
+
function J(e, t, n, r) {
|
|
96
|
+
switch (e) {
|
|
96
97
|
case i.Expand:
|
|
97
|
-
return
|
|
98
|
+
return q(!0, t, n, r);
|
|
98
99
|
case i.Collapse:
|
|
99
|
-
return
|
|
100
|
+
return q(!1, t, n, r);
|
|
100
101
|
case i.ExpandAll:
|
|
101
|
-
return
|
|
102
|
+
return R(!0, n, r);
|
|
102
103
|
case i.CollapseAll:
|
|
103
|
-
return
|
|
104
|
+
return R(!1, n, r);
|
|
104
105
|
default:
|
|
105
106
|
return {
|
|
106
|
-
content: [{ type: "text", text: `Unknown expand/collapse command: ${
|
|
107
|
+
content: [{ type: "text", text: `Unknown expand/collapse command: ${e}` }],
|
|
107
108
|
isError: !0
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
-
return
|
|
112
|
+
function $(e, t) {
|
|
113
|
+
return e.id === t || e.field === t;
|
|
113
114
|
}
|
|
114
|
-
function
|
|
115
|
-
return
|
|
116
|
-
(r) =>
|
|
115
|
+
function H(e, t, n) {
|
|
116
|
+
return e.map(
|
|
117
|
+
(r) => $(r, t) ? n(r) : r
|
|
117
118
|
);
|
|
118
119
|
}
|
|
119
|
-
function
|
|
120
|
+
function Q(e, t, n, r, a, c, o) {
|
|
120
121
|
var u;
|
|
121
|
-
const s = Number(
|
|
122
|
+
const s = Number(t.position);
|
|
122
123
|
if (Number.isNaN(s))
|
|
123
124
|
return { content: [{ type: "text", text: "Missing required argument: position" }], isError: !0 };
|
|
124
|
-
if (
|
|
125
|
-
const l =
|
|
125
|
+
if (o) {
|
|
126
|
+
const l = a.findIndex((p) => $(p, e)), d = c[l];
|
|
126
127
|
if (d) {
|
|
127
128
|
const p = [...c];
|
|
128
129
|
p.splice(l, 1), p.splice(s, 0, d), (u = n.onColumnsStateChange) == null || u.call(n, {
|
|
129
|
-
columnsState: p.map((C,
|
|
130
|
+
columnsState: p.map((C, v) => ({ ...C, orderIndex: v })),
|
|
130
131
|
target: r
|
|
131
132
|
});
|
|
132
133
|
}
|
|
133
134
|
} else if (n.onColumnReorder) {
|
|
134
|
-
const l =
|
|
135
|
+
const l = a.findIndex((d) => $(d, e));
|
|
135
136
|
n.onColumnReorder({ oldIndex: l, newIndex: s, target: r });
|
|
136
137
|
} else
|
|
137
138
|
return { content: [{ type: "text", text: "Column reorder not supported." }], isError: !0 };
|
|
138
|
-
return { content: [{ type: "text", text: `Column ${
|
|
139
|
+
return { content: [{ type: "text", text: `Column ${e} moved to position ${s}.` }] };
|
|
139
140
|
}
|
|
140
|
-
function
|
|
141
|
+
function X(e, t, n, r, a, c, o) {
|
|
141
142
|
var u;
|
|
142
|
-
const s = Number.parseInt(
|
|
143
|
+
const s = Number.parseInt(t.size, 10);
|
|
143
144
|
if (Number.isNaN(s))
|
|
144
145
|
return { content: [{ type: "text", text: "Missing required argument: size" }], isError: !0 };
|
|
145
|
-
if (
|
|
146
|
+
if (o)
|
|
146
147
|
(u = n.onColumnsStateChange) == null || u.call(n, {
|
|
147
|
-
columnsState:
|
|
148
|
+
columnsState: H(c, e, (l) => ({ ...l, width: s })),
|
|
148
149
|
target: r
|
|
149
150
|
});
|
|
150
151
|
else if (n.onColumnResize) {
|
|
151
|
-
const l =
|
|
152
|
+
const l = a.findIndex((C) => $(C, e)), d = (n.columns || [])[l], p = d && d.width || 0;
|
|
152
153
|
n.onColumnResize({ index: l, newWidth: s, oldWidth: p, end: !0, target: r });
|
|
153
154
|
} else
|
|
154
155
|
return { content: [{ type: "text", text: "Column resize not supported." }], isError: !0 };
|
|
155
|
-
return { content: [{ type: "text", text: `Column ${
|
|
156
|
+
return { content: [{ type: "text", text: `Column ${e} resized to ${s}px.` }] };
|
|
156
157
|
}
|
|
157
|
-
function
|
|
158
|
+
function U(e, t, n, r, a, c) {
|
|
158
159
|
var s;
|
|
159
160
|
return c ? ((s = n.onColumnsStateChange) == null || s.call(n, {
|
|
160
|
-
columnsState:
|
|
161
|
+
columnsState: H(a, e, (u) => ({ ...u, hidden: t })),
|
|
161
162
|
target: r
|
|
162
|
-
}), { content: [{ type: "text", text: `Column ${
|
|
163
|
+
}), { content: [{ type: "text", text: `Column ${e} is now ${t ? "hidden" : "visible"}.` }] }) : { content: [{ type: "text", text: "Column state changes not supported." }], isError: !0 };
|
|
163
164
|
}
|
|
164
|
-
function
|
|
165
|
-
const c =
|
|
165
|
+
function Y(e, t, n, r, a) {
|
|
166
|
+
const c = t.id;
|
|
166
167
|
if (!c)
|
|
167
168
|
return { content: [{ type: "text", text: "Missing required argument: id" }], isError: !0 };
|
|
168
|
-
const
|
|
169
|
-
switch (
|
|
169
|
+
const o = n.current, s = !!o.onColumnsStateChange && !!r, u = s ? o.columnsState || (r == null ? void 0 : r.columns) || [] : [];
|
|
170
|
+
switch (e) {
|
|
170
171
|
case i.ColumnReorder:
|
|
171
|
-
return
|
|
172
|
+
return Q(c, t, o, r, a, u, s);
|
|
172
173
|
case i.ColumnResize:
|
|
173
|
-
return
|
|
174
|
+
return X(c, t, o, r, a, u, s);
|
|
174
175
|
case i.ColumnShow:
|
|
175
|
-
return
|
|
176
|
+
return U(c, !1, o, r, u, s);
|
|
176
177
|
case i.ColumnHide:
|
|
177
|
-
return
|
|
178
|
+
return U(c, !0, o, r, u, s);
|
|
178
179
|
default:
|
|
179
180
|
return null;
|
|
180
181
|
}
|
|
181
182
|
}
|
|
182
|
-
function
|
|
183
|
-
const r =
|
|
184
|
-
return r ? (
|
|
183
|
+
function Z(e, t, n) {
|
|
184
|
+
const r = e.view;
|
|
185
|
+
return r ? (t.current.onViewChange && t.current.onViewChange({ value: r, target: n }), { content: [{ type: "text", text: `Switched to ${r} view.` }] }) : { content: [{ type: "text", text: "Missing required argument: view" }], isError: !0 };
|
|
185
186
|
}
|
|
186
|
-
function
|
|
187
|
+
function F(e, t, n, r) {
|
|
187
188
|
var s;
|
|
188
|
-
const
|
|
189
|
+
const a = n.current, c = a.onTaskChange || a.onDataStateChange;
|
|
189
190
|
if (!c)
|
|
190
191
|
return null;
|
|
191
|
-
const
|
|
192
|
-
switch (
|
|
192
|
+
const o = T(a.taskModelFields);
|
|
193
|
+
switch (e) {
|
|
193
194
|
case i.CreateTask: {
|
|
194
|
-
const u =
|
|
195
|
+
const u = t.title;
|
|
195
196
|
if (!u)
|
|
196
197
|
return { content: [{ type: "text", text: "Missing required argument: title" }], isError: !0 };
|
|
197
198
|
const l = {
|
|
198
|
-
[
|
|
199
|
-
[
|
|
200
|
-
[
|
|
201
|
-
[
|
|
202
|
-
[
|
|
199
|
+
[o.id]: Date.now(),
|
|
200
|
+
[o.title]: u,
|
|
201
|
+
[o.start]: t.start ? new Date(t.start) : void 0,
|
|
202
|
+
[o.end]: t.end ? new Date(t.end) : void 0,
|
|
203
|
+
[o.percentComplete]: (s = t.percentComplete) != null ? s : 0
|
|
203
204
|
};
|
|
204
205
|
return c({ created: [l], updated: [], deleted: [] }), { content: [{ type: "text", text: `Added task "${u}".` }] };
|
|
205
206
|
}
|
|
206
207
|
case i.DeleteTask: {
|
|
207
|
-
const u =
|
|
208
|
+
const u = w(a.taskData || [], o);
|
|
208
209
|
let l;
|
|
209
|
-
return
|
|
210
|
-
const p = d[
|
|
211
|
-
return
|
|
212
|
-
}) :
|
|
210
|
+
return t.field && t.operator ? l = u.find((d) => {
|
|
211
|
+
const p = d[t.field];
|
|
212
|
+
return b(p, t.operator, t.value);
|
|
213
|
+
}) : t.id !== void 0 && (l = u.find((d) => String(d[o.id]) === String(t.id))), l ? (c({ created: [], updated: [], deleted: [l] }), { content: [{ type: "text", text: `Deleted task "${g(l[o.title])}".` }] }) : { content: [{ type: "text", text: "No matching task found." }], isError: !0 };
|
|
214
|
+
}
|
|
215
|
+
case A: {
|
|
216
|
+
const u = w(a.taskData || [], o);
|
|
217
|
+
let l;
|
|
218
|
+
if (t.field && t.operator ? l = u.find((p) => {
|
|
219
|
+
const C = p[t.field];
|
|
220
|
+
return b(C, t.operator, t.value);
|
|
221
|
+
}) : t.id !== void 0 && (l = u.find((p) => String(p[o.id]) === String(t.id))), !l)
|
|
222
|
+
return { content: [{ type: "text", text: "No matching task found." }], isError: !0 };
|
|
223
|
+
const d = { ...l };
|
|
224
|
+
return t.title !== void 0 && (d[o.title] = t.title), t.start !== void 0 && (d[o.start] = new Date(t.start)), t.end !== void 0 && (d[o.end] = new Date(t.end)), t.percentComplete !== void 0 && (d[o.percentComplete] = t.percentComplete), c({ created: [], updated: [d], deleted: [] }), { content: [{ type: "text", text: `Updated task "${g(d[o.title])}".` }] };
|
|
213
225
|
}
|
|
214
226
|
default:
|
|
215
227
|
return null;
|
|
216
228
|
}
|
|
217
229
|
}
|
|
218
|
-
const
|
|
230
|
+
const et = {
|
|
219
231
|
componentSuffix: "gantt",
|
|
220
|
-
createTools(
|
|
221
|
-
const
|
|
232
|
+
createTools(e, t, n, r) {
|
|
233
|
+
const a = [], c = (m) => `${n.groupName}_${m}`, o = t.current, s = B(o), u = !!o.sortable, l = !!o.onFilterChange, d = !!o.onExpandChange, p = !!o.onViewChange, C = !!o.onTaskChange || !!o.onDataStateChange, v = !!o.reorderable || !!o.onColumnReorder, V = !!o.resizable || !!o.onColumnResize, D = !!o.onColumnsStateChange, z = [
|
|
222
234
|
{
|
|
223
235
|
name: "sort",
|
|
224
236
|
description: `Sort the ${n.dataName} gantt by a column`,
|
|
@@ -268,76 +280,112 @@ const X = {
|
|
|
268
280
|
enabled: d
|
|
269
281
|
},
|
|
270
282
|
{
|
|
271
|
-
name: "
|
|
283
|
+
name: "set_view",
|
|
272
284
|
description: `Switch the ${n.dataName} gantt chart view`,
|
|
273
285
|
commandType: i.ChangeView,
|
|
274
286
|
enabled: p
|
|
275
287
|
},
|
|
276
288
|
{
|
|
277
|
-
name: "
|
|
289
|
+
name: "add_task",
|
|
278
290
|
description: `Add a new task to the ${n.dataName} gantt`,
|
|
279
291
|
commandType: i.CreateTask,
|
|
280
292
|
enabled: C
|
|
281
293
|
},
|
|
294
|
+
{
|
|
295
|
+
name: "update_task",
|
|
296
|
+
description: `Update an existing task in the ${n.dataName} gantt`,
|
|
297
|
+
commandType: A,
|
|
298
|
+
enabled: C
|
|
299
|
+
},
|
|
282
300
|
{
|
|
283
301
|
name: "delete_task",
|
|
284
302
|
description: `Delete a task from the ${n.dataName} gantt`,
|
|
285
303
|
commandType: i.DeleteTask,
|
|
286
304
|
enabled: C
|
|
287
305
|
},
|
|
306
|
+
{
|
|
307
|
+
name: "select",
|
|
308
|
+
description: `Select a task in the ${n.dataName} gantt`,
|
|
309
|
+
commandType: G,
|
|
310
|
+
enabled: !!o.selectable || !!o.onSelectionChange || C
|
|
311
|
+
},
|
|
288
312
|
{
|
|
289
313
|
name: "reorder_column",
|
|
290
314
|
description: `Reorder a column in the ${n.dataName} gantt`,
|
|
291
315
|
commandType: i.ColumnReorder,
|
|
292
|
-
enabled:
|
|
316
|
+
enabled: v
|
|
293
317
|
},
|
|
294
318
|
{
|
|
295
319
|
name: "resize_column",
|
|
296
320
|
description: `Resize a column in the ${n.dataName} gantt`,
|
|
297
321
|
commandType: i.ColumnResize,
|
|
298
|
-
enabled:
|
|
322
|
+
enabled: V
|
|
299
323
|
},
|
|
300
324
|
{
|
|
301
325
|
name: "show_column",
|
|
302
326
|
description: `Show a hidden column in the ${n.dataName} gantt`,
|
|
303
327
|
commandType: i.ColumnShow,
|
|
304
|
-
enabled:
|
|
328
|
+
enabled: D
|
|
305
329
|
},
|
|
306
330
|
{
|
|
307
331
|
name: "hide_column",
|
|
308
332
|
description: `Hide a column in the ${n.dataName} gantt`,
|
|
309
333
|
commandType: i.ColumnHide,
|
|
310
|
-
enabled:
|
|
334
|
+
enabled: D
|
|
311
335
|
}
|
|
312
|
-
],
|
|
313
|
-
const
|
|
336
|
+
], E = t.current.webMcp, _ = typeof E == "object" && E !== null && typeof E.tools == "function" ? E.tools : void 0, W = { tname: c, columns: s, data: o.taskData }, L = _ ? _(z, W) : z, P = async (m, f) => {
|
|
337
|
+
const y = t.current;
|
|
314
338
|
switch (m) {
|
|
315
339
|
case i.Sort:
|
|
316
|
-
return
|
|
340
|
+
return K(f, t, e);
|
|
317
341
|
case i.ClearSort:
|
|
318
|
-
return
|
|
342
|
+
return y.onSortChange && y.onSortChange({ sort: [], field: "", target: e }), { content: [{ type: "text", text: "Sorting cleared." }] };
|
|
319
343
|
case i.Filter:
|
|
320
|
-
return
|
|
344
|
+
return O(f, t, e);
|
|
321
345
|
case i.ClearFilter:
|
|
322
|
-
return
|
|
346
|
+
return y.onFilterChange && y.onFilterChange({ filter: { logic: "and", filters: [] }, target: e }), { content: [{ type: "text", text: "All filters cleared." }] };
|
|
323
347
|
case i.Expand:
|
|
324
348
|
case i.Collapse:
|
|
325
349
|
case i.ExpandAll:
|
|
326
350
|
case i.CollapseAll:
|
|
327
|
-
return
|
|
351
|
+
return J(m, f, t, e);
|
|
328
352
|
case i.ChangeView:
|
|
329
|
-
return
|
|
353
|
+
return Z(f, t, e);
|
|
330
354
|
case i.CreateTask:
|
|
331
|
-
case i.DeleteTask:
|
|
332
|
-
|
|
333
|
-
|
|
355
|
+
case i.DeleteTask:
|
|
356
|
+
case A: {
|
|
357
|
+
const x = F(m, f, t);
|
|
358
|
+
return x || { content: [{ type: "text", text: "Task operations not supported." }], isError: !0 };
|
|
359
|
+
}
|
|
360
|
+
case G: {
|
|
361
|
+
const x = t.current, h = T(x.taskModelFields), N = w(x.taskData || [], h);
|
|
362
|
+
let S;
|
|
363
|
+
if (f.field && f.operator ? S = N.find(
|
|
364
|
+
(k) => b(k[f.field], f.operator, f.value)
|
|
365
|
+
) : f.id !== void 0 && (S = N.find((k) => String(k[h.id]) === String(f.id))), !S)
|
|
366
|
+
return { content: [{ type: "text", text: "No matching task found." }], isError: !0 };
|
|
367
|
+
if (x.onSelectionChange)
|
|
368
|
+
x.onSelectionChange({ dataItem: S, dataItems: N, target: e });
|
|
369
|
+
else if (x.onDataStateChange)
|
|
370
|
+
x.onDataStateChange({ selected: [S], target: e });
|
|
371
|
+
else
|
|
372
|
+
return {
|
|
373
|
+
content: [
|
|
374
|
+
{
|
|
375
|
+
type: "text",
|
|
376
|
+
text: "Selection not supported. Add onSelectionChange or selectable prop."
|
|
377
|
+
}
|
|
378
|
+
],
|
|
379
|
+
isError: !0
|
|
380
|
+
};
|
|
381
|
+
return { content: [{ type: "text", text: `Selected task "${g(S[h.title])}".` }] };
|
|
334
382
|
}
|
|
335
383
|
case i.ColumnReorder:
|
|
336
384
|
case i.ColumnResize:
|
|
337
385
|
case i.ColumnShow:
|
|
338
386
|
case i.ColumnHide: {
|
|
339
|
-
const
|
|
340
|
-
return
|
|
387
|
+
const x = Y(m, f, t, e, s);
|
|
388
|
+
return x || {
|
|
341
389
|
content: [{ type: "text", text: `Unknown column command: ${m}` }],
|
|
342
390
|
isError: !0
|
|
343
391
|
};
|
|
@@ -346,25 +394,25 @@ const X = {
|
|
|
346
394
|
return { content: [{ type: "text", text: `Unknown command: ${m}` }], isError: !0 };
|
|
347
395
|
}
|
|
348
396
|
};
|
|
349
|
-
for (const m of
|
|
397
|
+
for (const m of L) {
|
|
350
398
|
if (!m.enabled)
|
|
351
399
|
continue;
|
|
352
|
-
const
|
|
400
|
+
const f = m.inputSchema || j(m.commandType, s), y = m.commandType, x = m.execute;
|
|
353
401
|
try {
|
|
354
|
-
|
|
402
|
+
a.push(
|
|
355
403
|
r.registerTool({
|
|
356
404
|
name: c(m.name),
|
|
357
405
|
description: m.description,
|
|
358
|
-
inputSchema:
|
|
359
|
-
execute: async (
|
|
406
|
+
inputSchema: f,
|
|
407
|
+
execute: x ? async (h) => await x(h || {}) : async (h) => P(y, h || {})
|
|
360
408
|
})
|
|
361
409
|
);
|
|
362
410
|
} catch {
|
|
363
411
|
}
|
|
364
412
|
}
|
|
365
|
-
return
|
|
413
|
+
return a;
|
|
366
414
|
}
|
|
367
415
|
};
|
|
368
416
|
export {
|
|
369
|
-
|
|
417
|
+
et as ganttAdapter
|
|
370
418
|
};
|
package/adapters/grid.d.ts
CHANGED
package/adapters/grid.js
CHANGED
|
@@ -5,4 +5,4 @@
|
|
|
5
5
|
* Licensed under commercial license. See LICENSE.md in the package root for more information
|
|
6
6
|
*-------------------------------------------------------------------------------------------
|
|
7
7
|
*/
|
|
8
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Q=require("react"),Y=require("../commands/grid.js");function Z(r){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(n,e,t.get?t:{enumerable:!0,get:()=>r[e]})}}return n.default=r,Object.freeze(n)}const U=Z(Q);function C(r,n,e,t,a){const i=r.current;if(n)n({...e,target:a});else if(i.onDataStateChange){const o={filter:i.filter,sort:i.sort,skip:i.skip,take:i.take,group:i.group};i.onDataStateChange({dataState:{...o,...t},target:a})}}function V(r){const n=[];return U.Children.forEach(r,e=>{if(U.isValidElement(e)&&e.props.field){const t=e.props;n.push({field:t.field,id:t.id||t.field})}}),n}function R(r,n,e){if(!r.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const t=r.field,a=r.dir||"asc",i=[{field:t,dir:a}];return C(n,n.current.onSortChange,{sort:i},{sort:i},e),{content:[{type:"text",text:`Sorted by ${t} ${a}.`}]}}function ee(r,n,e,t){var l,s;if(!r.field||!r.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=r.field,i=r.operator,o=r.value,u=n.current,c={logic:"and",filters:[...(s=t!=null?t:(l=u.filter)==null?void 0:l.filters)!=null?s:[],{field:a,operator:i,value:o}]};return C(n,u.onFilterChange,{filter:c},{filter:c,skip:0},e),{content:[{type:"text",text:`Filter applied: ${a} ${i} "${o}".`}]}}function te(r,n,e){var u;if(!r.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const t=r.field,a=r.dir||"asc",i=n.current,o=[...(u=i.group)!=null?u:[],{field:t,dir:a}];return C(n,i.onGroupChange,{group:o},{group:o},e),{content:[{type:"text",text:`Grouped by ${t} ${a}.`}]}}function re(r,n,e){var o;const t=Number(r.page);if(!t||t<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const a=(o=n.current.take)!=null?o:10,i=(t-1)*a;return C(n,n.current.onPageChange,{page:{skip:i,take:a}},{skip:i,take:a},e),{content:[{type:"text",text:`Navigated to page ${t}.`}]}}function ne(r,n,e){const t=Number(r.pageSize);return!t||t<1?{content:[{type:"text",text:"Invalid page size."}],isError:!0}:(C(n,n.current.onPageChange,{page:{skip:0,take:t}},{skip:0,take:t},e),{content:[{type:"text",text:`Page size set to ${t}.`}]})}function oe(r,n,e,t,a){const i=e.current;switch(r){case"GridSort":return R(n,e,t);case"GridClearSort":return C(e,i.onSortChange,{sort:[]},{sort:[]},t),{content:[{type:"text",text:"Sorting cleared."}]};case"GridFilter":return ee(n,e,t,a);case"GridClearFilter":{const o={logic:"and",filters:[]};return C(e,i.onFilterChange,{filter:o},{filter:o,skip:0},t),{content:[{type:"text",text:"All filters cleared."}]}}case"GridGroup":return te(n,e,t);case"GridClearGroup":return C(e,i.onGroupChange,{group:[]},{group:[]},t),{content:[{type:"text",text:"Grouping cleared."}]};case"GridPage":return re(n,e,t);case"GridPageSize":return ne(n,e,t);default:return null}}function $(r){return Array.isArray(r)?r:r&&typeof r=="object"&&Array.isArray(r.data)?r.data:[]}function ae(r,n,e){var c,l;if(!r.field||!r.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const t=r.field,a=r.operator,i=r.value,o=n.current.dataItemKey;if(!o)return{content:[{type:"text",text:"dataItemKey prop is required for highlighting."}],isError:!0};const u=(l=(c=e==null?void 0:e.getLeafDataItems)==null?void 0:c.call(e))!=null?l:$(n.current.data),d={};for(const s of u){const p=s;if(_(p[t],a,i)){const g=N(p[o]);g!==null&&(d[g]=!0)}}return n.current.onHighlightChange&&n.current.onHighlightChange({highlight:d}),{content:[{type:"text",text:`Highlighted rows where ${t} ${a} "${JSON.stringify(i)}".`}]}}function ie(r,n,e){var c,l;if(!r.field||!r.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const t=r.field,a=r.operator,i=r.value,o=n.current.dataItemKey;if(!o)return{content:[{type:"text",text:"dataItemKey prop is required for selection."}],isError:!0};const u=(l=(c=e==null?void 0:e.getLeafDataItems)==null?void 0:c.call(e))!=null?l:$(n.current.data),d={};for(const s of u){const p=s;if(_(p[t],a,i)){const g=N(p[o]);g!==null&&(d[g]=!0)}}return n.current.onSelectionChange&&n.current.onSelectionChange({select:d,dataItem:null,dataItems:u,startDataItem:null,endDataItem:null,target:e}),{content:[{type:"text",text:`Selected rows where ${t} ${a} "${JSON.stringify(i)}".`}]}}function ce(r,n,e,t,a){const i=n.id;if(!i)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const o=e.current;if(!o.onColumnsStateChange||!t)return{content:[{type:"text",text:"Column state changes not supported."}],isError:!0};const u=o.columnsState||t.columns||[],d=c=>c.id===i||c.field===i;switch(r){case"GridColumnReorder":{const c=Number(n.position);if(Number.isNaN(c))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};const l=u.findIndex(d),s=u[l];if(s){const p=[...u];p.splice(l,1),p.splice(c,0,s),o.onColumnsStateChange({columnsState:p.map((g,G)=>({...g,orderIndex:G})),target:t})}return{content:[{type:"text",text:`Column ${i} moved to position ${c}.`}]}}case"GridColumnResize":{const c=Number.parseInt(n.size,10);if(Number.isNaN(c))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};const l=u.map(s=>d(s)?{...s,width:c}:s);return o.onColumnsStateChange({columnsState:l,target:t}),{content:[{type:"text",text:`Column ${i} resized to ${c}px.`}]}}case"GridColumnShow":{const c=u.map(l=>d(l)?{...l,hidden:!1}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} is now visible.`}]}}case"GridColumnHide":{const c=u.map(l=>d(l)?{...l,hidden:!0}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} is now hidden.`}]}}case"GridColumnLock":{const c=u.map(l=>d(l)?{...l,locked:!0}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} locked.`}]}}case"GridColumnUnlock":{const c=u.map(l=>d(l)?{...l,locked:!1}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} unlocked.`}]}}default:return null}}function de(r,n,e,t){const a=e.current;if(!a.onItemChange)return null;switch(r){case"GridAdd":return a.onItemChange({dataItem:n,dataIndex:-1,field:void 0,value:void 0,target:t}),{content:[{type:"text",text:"Record added."}]};case"GridUpdate":return a.onItemChange({dataItem:n,dataIndex:-1,field:void 0,value:void 0,target:t}),{content:[{type:"text",text:"Record updated."}]};case"GridDelete":return a.onItemChange({dataItem:n,dataIndex:-1,field:"_deleted",value:!0,target:t}),{content:[{type:"text",text:"Record deleted."}]};default:return null}}function ue(r,n,e,t,a){switch(r){case"GridHighlight":return ae(n,e,t);case"GridClearHighlight":return e.current.onHighlightChange&&e.current.onHighlightChange({highlight:{}}),{content:[{type:"text",text:"Highlights cleared."}]};case"GridSelect":return ie(n,e,t);case"GridClearSelect":return e.current.onSelectionChange&&e.current.onSelectionChange({select:{},target:t}),{content:[{type:"text",text:"Selection cleared."}]};case"GridSelectAll":return le(e,t);case"GridDetailExpand":case"GridDetailCollapse":case"GridDetailExpandAll":case"GridDetailCollapseAll":return se(r,n,e,t);case"GridGroupExpand":case"GridGroupCollapse":case"GridGroupExpandAll":case"GridGroupCollapseAll":return fe(r,n,e,t);case"GridSetAggregates":return me(n,e,t);case"GridExportPDF":return t!=null&&t.exportAsPdf&&t.exportAsPdf(),{content:[{type:"text",text:"PDF export triggered."}]};case"GridExportCSV":return t!=null&&t.saveAsCsv?t.saveAsCsv().then(()=>({content:[{type:"text",text:"CSV export triggered."}]})):{content:[{type:"text",text:"CSV export not available."}],isError:!0};case"GridExportExcel":return t!=null&&t.saveAsExcel&&t.saveAsExcel(),{content:[{type:"text",text:"Excel export triggered."}]};case"GridColumnReorder":case"GridColumnResize":case"GridColumnShow":case"GridColumnHide":case"GridColumnLock":case"GridColumnUnlock":return ce(r,n,e,t);case"GridAdd":case"GridUpdate":case"GridDelete":return de(r,n,e,t);default:return null}}function N(r){return r==null?null:typeof r=="string"||typeof r=="number"?String(r):null}function I(r,n){const e={};for(const t of r){const a=N(t[n]);a!==null&&(e[a]=!0)}return e}function le(r,n){var i,o;const e=r.current;if(!e.onHeaderSelectionChange&&!e.onSelectionChange)return{content:[{type:"text",text:"Selection not enabled."}],isError:!0};const t=(o=(i=n==null?void 0:n.getLeafDataItems)==null?void 0:i.call(n))!=null?o:[],a=e.dataItemKey;if(e.onHeaderSelectionChange){const u=a?I(t,a):{};e.onHeaderSelectionChange({select:u,field:void 0,dataItems:t,target:n})}else if(e.onSelectionChange){if(!a)return{content:[{type:"text",text:"dataItemKey prop is required for select all."}],isError:!0};e.onSelectionChange({select:I(t,a),dataItems:t,target:n})}return{content:[{type:"text",text:"All rows selected."}]}}function se(r,n,e,t){var u,d;const a=e.current;if(!a.onDetailExpandChange)return{content:[{type:"text",text:"onDetailExpandChange callback not provided."}],isError:!0};const i=a.dataItemKey;if(!i)return{content:[{type:"text",text:"dataItemKey prop is required for detail expand."}],isError:!0};const o=(d=(u=t==null?void 0:t.getLeafDataItems)==null?void 0:u.call(t))!=null?d:[];switch(r){case"GridDetailExpandAll":return a.onDetailExpandChange({detailExpand:I(o,i),target:t}),{content:[{type:"text",text:"All detail rows expanded."}]};case"GridDetailCollapseAll":return a.onDetailExpandChange({detailExpand:{},target:t}),{content:[{type:"text",text:"All detail rows collapsed."}]};case"GridDetailExpand":case"GridDetailCollapse":return pe(r,n,a,t,i,o);default:return{content:[{type:"text",text:`Unknown expand command: ${r}`}],isError:!0}}}function pe(r,n,e,t,a,i){var g;if(!n.field||!n.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const o=n.field,u=n.operator,d=n.value,c=r==="GridDetailExpand",s={...(g=e.detailExpand)!=null?g:{}};for(const G of i){const w=G[o];if(_(w,u,d)){const S=N(G[a]);S!==null&&(c?s[S]=!0:delete s[S])}}return e.onDetailExpandChange&&e.onDetailExpandChange({detailExpand:s,target:t}),{content:[{type:"text",text:`Detail rows ${c?"expanded":"collapsed"} where ${o} ${u} "${d}".`}]}}function _(r,n,e){switch(n){case"eq":return r===e||String(r)===String(e);case"neq":return r!==e&&String(r)!==String(e);case"contains":return typeof r=="string"&&typeof e=="string"&&r.toLowerCase().includes(e.toLowerCase());case"startswith":return typeof r=="string"&&typeof e=="string"&&r.toLowerCase().startsWith(e.toLowerCase());case"gt":return Number(r)>Number(e);case"gte":return Number(r)>=Number(e);case"lt":return Number(r)<Number(e);case"lte":return Number(r)<=Number(e);default:return!1}}function me(r,n,e){const t=n.current;if(!t.groupable)return{content:[{type:"text",text:"Grouping not enabled — aggregates require grouped data."}],isError:!0};if(!t.group||t.group.length===0)return{content:[{type:"text",text:"No active grouping — group the data first."}],isError:!0};if(!r.field||!r.aggregate)return{content:[{type:"text",text:"Missing required arguments: field, aggregate"}],isError:!0};const a=r.field,i=r.aggregate,o={field:a,aggregate:i},u=t.group.map(d=>{var s;const c=(s=d.aggregates)!=null?s:[];return c.some(p=>p.field===a&&p.aggregate===i)?d:{...d,aggregates:[...c,o]}});return C(n,t.onGroupChange,{group:u},{group:u},e),{content:[{type:"text",text:`Aggregate "${i}" added for column "${a}".`}]}}function ge(r,n){const e=[];for(const t of r){const a=new Set;for(const i of n){const o=i[t.field];a.has(o)||(a.add(o),e.push({field:t.field,value:o,expanded:!1}))}}return e}function xe(r,n,e){if(!r.field||r.value==null)return null;const t=r.field,a=r.value,i=typeof a=="string"||typeof a=="number"?String(a):JSON.stringify(a);return{updated:n.find(d=>d.field===t&&String(d.value)===i)?n.map(d=>d.field===t&&String(d.value)===i?{...d,expanded:e}:d):[...n,{field:t,value:a,expanded:e}],field:t,valueStr:i}}function fe(r,n,e,t){var i,o,u;const a=e.current;if(!a.groupable)return{content:[{type:"text",text:"Grouping not enabled."}],isError:!0};if(!a.onGroupExpandChange)return{content:[{type:"text",text:"onGroupExpandChange callback not provided."}],isError:!0};switch(r){case"GridGroupExpandAll":return a.onGroupExpandChange({groupExpand:[],target:t}),{content:[{type:"text",text:"All groups expanded."}]};case"GridGroupCollapseAll":{if(!a.group||a.group.length===0)return{content:[{type:"text",text:"No active grouping."}],isError:!0};const d=(o=(i=t==null?void 0:t.getLeafDataItems)==null?void 0:i.call(t))!=null?o:$(a.data),c=ge(a.group,d);return a.onGroupExpandChange({groupExpand:c,target:t}),{content:[{type:"text",text:"All groups collapsed."}]}}case"GridGroupExpand":case"GridGroupCollapse":{const d=r==="GridGroupExpand",c=xe(n,(u=a.groupExpand)!=null?u:[],d);if(!c)return{content:[{type:"text",text:"Missing required arguments: field, value"}],isError:!0};a.onGroupExpandChange({groupExpand:c.updated,target:t});const l=d?"expanded":"collapsed";return{content:[{type:"text",text:`Group "${c.field}=${c.valueStr}" ${l}.`}]}}default:return{content:[{type:"text",text:`Unknown group expand command: ${r}`}],isError:!0}}}const Ce={componentSuffix:"grid",createTools(r,n,e,t){const a=[],i=m=>`${e.groupName}_${m}`,o=n.current,u=V(o.children),d=!!o.onHighlightChange,c=!!o.selectable,l=c&&(!!o.onHeaderSelectionChange||!!o.dataItemKey),s=!!o.onDetailExpandChange,p=!!o.groupable&&!!o.onGroupExpandChange,g=!!o.pdf,G=!!o.excel,w=!!o.csv,S=!!o.reorderable,j=!!o.resizable,b=!!o.onColumnsStateChange,D=!!o.onItemChange||!!o.editable,k=[{name:"sort",description:`Sort the ${e.dataName} grid by a column`,commandType:"GridSort",enabled:!!(o.sortable||o.columnMenu)},{name:"clear_sort",description:`Remove all sorting from the ${e.dataName} grid`,commandType:"GridClearSort",enabled:!!(o.sortable||o.columnMenu)},{name:"filter",description:`Filter the ${e.dataName} grid on a column`,commandType:"GridFilter",enabled:!!(o.filterable||o.columnMenu)},{name:"clear_filters",description:`Remove all filters from the ${e.dataName} grid`,commandType:"GridClearFilter",enabled:!!(o.filterable||o.columnMenu)},{name:"group",description:`Group the ${e.dataName} grid rows by a column`,commandType:"GridGroup",enabled:!!(o.groupable||o.columnMenu)},{name:"clear_group",description:`Remove all grouping from the ${e.dataName} grid`,commandType:"GridClearGroup",enabled:!!(o.groupable||o.columnMenu)},{name:"page",description:`Navigate to a specific page in the ${e.dataName} grid`,commandType:"GridPage",enabled:!!o.pageable},{name:"set_page_size",description:`Change the number of items per page in the ${e.dataName} grid`,commandType:"GridPageSize",enabled:!!o.pageable},{name:"highlight",description:`Visually highlight rows in the ${e.dataName} grid`,commandType:"GridHighlight",enabled:d},{name:"clear_highlight",description:`Remove all row highlighting from the ${e.dataName} grid`,commandType:"GridClearHighlight",enabled:d},{name:"select",description:`Select rows in the ${e.dataName} grid`,commandType:"GridSelect",enabled:c},{name:"clear_select",description:`Clear all row selections in the ${e.dataName} grid`,commandType:"GridClearSelect",enabled:c},{name:"select_all",description:`Select all rows in the ${e.dataName} grid`,commandType:"GridSelectAll",enabled:l},{name:"detail_expand",description:`Expand detail rows matching a condition in the ${e.dataName} grid`,commandType:"GridDetailExpand",enabled:s},{name:"detail_collapse",description:`Collapse detail rows matching a condition in the ${e.dataName} grid`,commandType:"GridDetailCollapse",enabled:s},{name:"detail_expand_all",description:`Expand all detail rows in the ${e.dataName} grid`,commandType:"GridDetailExpandAll",enabled:s},{name:"detail_collapse_all",description:`Collapse all detail rows in the ${e.dataName} grid`,commandType:"GridDetailCollapseAll",enabled:s},{name:"group_expand",description:`Expand a specific group in the ${e.dataName} grid`,commandType:"GridGroupExpand",enabled:p},{name:"group_collapse",description:`Collapse a specific group in the ${e.dataName} grid`,commandType:"GridGroupCollapse",enabled:p},{name:"group_expand_all",description:`Expand all groups in the ${e.dataName} grid`,commandType:"GridGroupExpandAll",enabled:p},{name:"group_collapse_all",description:`Collapse all groups in the ${e.dataName} grid`,commandType:"GridGroupCollapseAll",enabled:p},{name:"set_aggregates",description:`Add an aggregate function (sum, average, count, min, max) to a column in the ${e.dataName} grid. Requires active grouping.`,commandType:"GridSetAggregates",enabled:!!o.groupable},{name:"export_pdf",description:`Export the ${e.dataName} grid to PDF`,commandType:"GridExportPDF",enabled:g},{name:"export_csv",description:`Export the ${e.dataName} grid to CSV`,commandType:"GridExportCSV",enabled:w},{name:"export_excel",description:`Export the ${e.dataName} grid to Excel`,commandType:"GridExportExcel",enabled:G},{name:"reorder_column",description:`Reorder a column in the ${e.dataName} grid`,commandType:"GridColumnReorder",enabled:S},{name:"resize_column",description:`Resize a column in the ${e.dataName} grid`,commandType:"GridColumnResize",enabled:j},{name:"show_column",description:`Show a hidden column in the ${e.dataName} grid`,commandType:"GridColumnShow",enabled:b},{name:"hide_column",description:`Hide a column in the ${e.dataName} grid`,commandType:"GridColumnHide",enabled:b},{name:"lock_column",description:`Lock a column in the ${e.dataName} grid`,commandType:"GridColumnLock",enabled:b},{name:"unlock_column",description:`Unlock a column in the ${e.dataName} grid`,commandType:"GridColumnUnlock",enabled:b},{name:"add",description:`Add a new record to the ${e.dataName} grid`,commandType:"GridAdd",enabled:D},{name:"update",description:`Update a record in the ${e.dataName} grid`,commandType:"GridUpdate",enabled:D},{name:"delete",description:`Delete a record from the ${e.dataName} grid`,commandType:"GridDelete",enabled:D},{name:"get_data",description:`Read the data currently visible in the ${e.dataName} grid as JSON`,commandType:"GridGetData",enabled:!0}],h=n.current.webMcp,T=typeof h=="object"&&h!==null&&typeof h.tools=="function"?h.tools:void 0,J={tname:i,columns:u,data:o.data},W=T?T(k,J):k;let x=null;const X=async(m,f)=>{var M,q,z,P,F,O,K;const v=(q=x==null?void 0:x.filters)!=null?q:(M=n.current.filter)==null?void 0:M.filters,E=oe(m,f,n,r,v);if(E)return m==="GridFilter"&&f.field&&f.operator?x={logic:"and",filters:[...(F=(P=x==null?void 0:x.filters)!=null?P:(z=n.current.filter)==null?void 0:z.filters)!=null?F:[],{field:f.field,operator:f.operator,value:f.value}]}:m==="GridClearFilter"&&(x={logic:"and",filters:[]}),E;const H=ue(m,f,n,r);if(H)return H;if(m==="GridGetData"){x&&await new Promise(B=>setTimeout(B,100));const A=1e3,y=(K=(O=r==null?void 0:r.getLeafDataItems)==null?void 0:O.call(r))!=null?K:$(n.current.data),L=Array.isArray(y)&&y.length>A?y.slice(0,A):y;return{content:[{type:"text",text:JSON.stringify(L!==y?{rows:L,truncated:!0,total:y.length}:y)}]}}return{content:[{type:"text",text:`Unknown command: ${m}`}],isError:!0}};for(const m of W){if(!m.enabled)continue;const f=Y.getGridToolSchema(m.commandType,u),v=m.commandType;try{a.push(t.registerTool({name:i(m.name),description:m.description,inputSchema:f,execute:async E=>X(v,E||{})}))}catch{}}return a}};exports.gridAdapter=Ce;
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=require("react"),Q=require("../commands/grid.js");function Y(r){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const e in r)if(e!=="default"){const t=Object.getOwnPropertyDescriptor(r,e);Object.defineProperty(n,e,t.get?t:{enumerable:!0,get:()=>r[e]})}}return n.default=r,Object.freeze(n)}const U=Y(B);function C(r,n,e,t,a){const i=r.current;if(n)n({...e,target:a});else if(i.onDataStateChange){const o={filter:i.filter,sort:i.sort,skip:i.skip,take:i.take,group:i.group};i.onDataStateChange({dataState:{...o,...t},target:a})}}function Z(r){const n=[];return U.Children.forEach(r,e=>{if(U.isValidElement(e)&&e.props.field){const t=e.props;n.push({field:t.field,id:t.id||t.field})}}),n}function V(r,n,e){if(!r.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const t=r.field,a=r.dir||"asc",i=[{field:t,dir:a}];return C(n,n.current.onSortChange,{sort:i},{sort:i},e),{content:[{type:"text",text:`Sorted by ${t} ${a}.`}]}}function R(r,n,e,t){var l,s;if(!r.field||!r.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const a=r.field,i=r.operator,o=r.value,u=n.current,c={logic:"and",filters:[...(s=t!=null?t:(l=u.filter)==null?void 0:l.filters)!=null?s:[],{field:a,operator:i,value:o}]};return C(n,u.onFilterChange,{filter:c},{filter:c,skip:0},e),{content:[{type:"text",text:`Filter applied: ${a} ${i} "${o}".`}]}}function ee(r,n,e){var u;if(!r.field)return{content:[{type:"text",text:"Missing required argument: field"}],isError:!0};const t=r.field,a=r.dir||"asc",i=n.current,o=[...(u=i.group)!=null?u:[],{field:t,dir:a}];return C(n,i.onGroupChange,{group:o},{group:o},e),{content:[{type:"text",text:`Grouped by ${t} ${a}.`}]}}function te(r,n,e){var o;const t=Number(r.page);if(!t||t<1)return{content:[{type:"text",text:"Invalid page number."}],isError:!0};const a=(o=n.current.take)!=null?o:10,i=(t-1)*a;return C(n,n.current.onPageChange,{page:{skip:i,take:a}},{skip:i,take:a},e),{content:[{type:"text",text:`Navigated to page ${t}.`}]}}function re(r,n,e){const t=Number(r.pageSize);return!t||t<1?{content:[{type:"text",text:"Invalid page size."}],isError:!0}:(C(n,n.current.onPageChange,{page:{skip:0,take:t}},{skip:0,take:t},e),{content:[{type:"text",text:`Page size set to ${t}.`}]})}function ne(r,n,e,t,a){const i=e.current;switch(r){case"GridSort":return V(n,e,t);case"GridClearSort":return C(e,i.onSortChange,{sort:[]},{sort:[]},t),{content:[{type:"text",text:"Sorting cleared."}]};case"GridFilter":return R(n,e,t,a);case"GridClearFilter":{const o={logic:"and",filters:[]};return C(e,i.onFilterChange,{filter:o},{filter:o,skip:0},t),{content:[{type:"text",text:"All filters cleared."}]}}case"GridGroup":return ee(n,e,t);case"GridClearGroup":return C(e,i.onGroupChange,{group:[]},{group:[]},t),{content:[{type:"text",text:"Grouping cleared."}]};case"GridPage":return te(n,e,t);case"GridPageSize":return re(n,e,t);default:return null}}function $(r){return Array.isArray(r)?r:r&&typeof r=="object"&&Array.isArray(r.data)?r.data:[]}function oe(r,n,e){var c,l;if(!r.field||!r.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const t=r.field,a=r.operator,i=r.value,o=n.current.dataItemKey;if(!o)return{content:[{type:"text",text:"dataItemKey prop is required for highlighting."}],isError:!0};const u=(l=(c=e==null?void 0:e.getLeafDataItems)==null?void 0:c.call(e))!=null?l:$(n.current.data),d={};for(const s of u){const p=s;if(_(p[t],a,i)){const g=N(p[o]);g!==null&&(d[g]=!0)}}return n.current.onHighlightChange&&n.current.onHighlightChange({highlight:d}),{content:[{type:"text",text:`Highlighted rows where ${t} ${a} "${JSON.stringify(i)}".`}]}}function ae(r,n,e){var c,l;if(!r.field||!r.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const t=r.field,a=r.operator,i=r.value,o=n.current.dataItemKey;if(!o)return{content:[{type:"text",text:"dataItemKey prop is required for selection."}],isError:!0};const u=(l=(c=e==null?void 0:e.getLeafDataItems)==null?void 0:c.call(e))!=null?l:$(n.current.data),d={};for(const s of u){const p=s;if(_(p[t],a,i)){const g=N(p[o]);g!==null&&(d[g]=!0)}}return n.current.onSelectionChange&&n.current.onSelectionChange({select:d,dataItem:null,dataItems:u,startDataItem:null,endDataItem:null,target:e}),{content:[{type:"text",text:`Selected rows where ${t} ${a} "${JSON.stringify(i)}".`}]}}function ie(r,n,e,t,a){const i=n.id;if(!i)return{content:[{type:"text",text:"Missing required argument: id"}],isError:!0};const o=e.current;if(!o.onColumnsStateChange||!t)return{content:[{type:"text",text:"Column state changes not supported."}],isError:!0};const u=o.columnsState||t.columns||[],d=c=>c.id===i||c.field===i;switch(r){case"GridColumnReorder":{const c=Number(n.position);if(Number.isNaN(c))return{content:[{type:"text",text:"Missing required argument: position"}],isError:!0};const l=u.findIndex(d),s=u[l];if(s){const p=[...u];p.splice(l,1),p.splice(c,0,s),o.onColumnsStateChange({columnsState:p.map((g,G)=>({...g,orderIndex:G})),target:t})}return{content:[{type:"text",text:`Column ${i} moved to position ${c}.`}]}}case"GridColumnResize":{const c=Number.parseInt(n.size,10);if(Number.isNaN(c))return{content:[{type:"text",text:"Missing required argument: size"}],isError:!0};const l=u.map(s=>d(s)?{...s,width:c}:s);return o.onColumnsStateChange({columnsState:l,target:t}),{content:[{type:"text",text:`Column ${i} resized to ${c}px.`}]}}case"GridColumnShow":{const c=u.map(l=>d(l)?{...l,hidden:!1}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} is now visible.`}]}}case"GridColumnHide":{const c=u.map(l=>d(l)?{...l,hidden:!0}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} is now hidden.`}]}}case"GridColumnLock":{const c=u.map(l=>d(l)?{...l,locked:!0}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} locked.`}]}}case"GridColumnUnlock":{const c=u.map(l=>d(l)?{...l,locked:!1}:l);return o.onColumnsStateChange({columnsState:c,target:t}),{content:[{type:"text",text:`Column ${i} unlocked.`}]}}default:return null}}function ce(r,n,e,t){const a=e.current;if(!a.onItemChange)return null;switch(r){case"GridAdd":return a.onItemChange({dataItem:n,dataIndex:-1,field:void 0,value:void 0,target:t}),{content:[{type:"text",text:"Record added."}]};case"GridUpdate":return a.onItemChange({dataItem:n,dataIndex:-1,field:void 0,value:void 0,target:t}),{content:[{type:"text",text:"Record updated."}]};case"GridDelete":return a.onItemChange({dataItem:n,dataIndex:-1,field:"_deleted",value:!0,target:t}),{content:[{type:"text",text:"Record deleted."}]};default:return null}}function de(r,n,e,t,a){switch(r){case"GridHighlight":return oe(n,e,t);case"GridClearHighlight":return e.current.onHighlightChange&&e.current.onHighlightChange({highlight:{}}),{content:[{type:"text",text:"Highlights cleared."}]};case"GridSelect":return ae(n,e,t);case"GridClearSelect":return e.current.onSelectionChange&&e.current.onSelectionChange({select:{},target:t}),{content:[{type:"text",text:"Selection cleared."}]};case"GridSelectAll":return ue(e,t);case"GridDetailExpand":case"GridDetailCollapse":case"GridDetailExpandAll":case"GridDetailCollapseAll":return le(r,n,e,t);case"GridGroupExpand":case"GridGroupCollapse":case"GridGroupExpandAll":case"GridGroupCollapseAll":return xe(r,n,e,t);case"GridSetAggregates":return pe(n,e,t);case"GridExportPDF":return t!=null&&t.exportAsPdf&&t.exportAsPdf(),{content:[{type:"text",text:"PDF export triggered."}]};case"GridExportCSV":return t!=null&&t.saveAsCsv?t.saveAsCsv().then(()=>({content:[{type:"text",text:"CSV export triggered."}]})):{content:[{type:"text",text:"CSV export not available."}],isError:!0};case"GridColumnReorder":case"GridColumnResize":case"GridColumnShow":case"GridColumnHide":case"GridColumnLock":case"GridColumnUnlock":return ie(r,n,e,t);case"GridAdd":case"GridUpdate":case"GridDelete":return ce(r,n,e,t);default:return null}}function N(r){return r==null?null:typeof r=="string"||typeof r=="number"?String(r):null}function I(r,n){const e={};for(const t of r){const a=N(t[n]);a!==null&&(e[a]=!0)}return e}function ue(r,n){var i,o;const e=r.current;if(!e.onHeaderSelectionChange&&!e.onSelectionChange)return{content:[{type:"text",text:"Selection not enabled."}],isError:!0};const t=(o=(i=n==null?void 0:n.getLeafDataItems)==null?void 0:i.call(n))!=null?o:[],a=e.dataItemKey;if(e.onHeaderSelectionChange){const u=a?I(t,a):{};e.onHeaderSelectionChange({select:u,field:void 0,dataItems:t,target:n})}else if(e.onSelectionChange){if(!a)return{content:[{type:"text",text:"dataItemKey prop is required for select all."}],isError:!0};e.onSelectionChange({select:I(t,a),dataItems:t,target:n})}return{content:[{type:"text",text:"All rows selected."}]}}function le(r,n,e,t){var u,d;const a=e.current;if(!a.onDetailExpandChange)return{content:[{type:"text",text:"onDetailExpandChange callback not provided."}],isError:!0};const i=a.dataItemKey;if(!i)return{content:[{type:"text",text:"dataItemKey prop is required for detail expand."}],isError:!0};const o=(d=(u=t==null?void 0:t.getLeafDataItems)==null?void 0:u.call(t))!=null?d:[];switch(r){case"GridDetailExpandAll":return a.onDetailExpandChange({detailExpand:I(o,i),target:t}),{content:[{type:"text",text:"All detail rows expanded."}]};case"GridDetailCollapseAll":return a.onDetailExpandChange({detailExpand:{},target:t}),{content:[{type:"text",text:"All detail rows collapsed."}]};case"GridDetailExpand":case"GridDetailCollapse":return se(r,n,a,t,i,o);default:return{content:[{type:"text",text:`Unknown expand command: ${r}`}],isError:!0}}}function se(r,n,e,t,a,i){var g;if(!n.field||!n.operator)return{content:[{type:"text",text:"Missing required arguments: field, operator"}],isError:!0};const o=n.field,u=n.operator,d=n.value,c=r==="GridDetailExpand",s={...(g=e.detailExpand)!=null?g:{}};for(const G of i){const w=G[o];if(_(w,u,d)){const S=N(G[a]);S!==null&&(c?s[S]=!0:delete s[S])}}return e.onDetailExpandChange&&e.onDetailExpandChange({detailExpand:s,target:t}),{content:[{type:"text",text:`Detail rows ${c?"expanded":"collapsed"} where ${o} ${u} "${d}".`}]}}function _(r,n,e){switch(n){case"eq":return r===e||String(r)===String(e);case"neq":return r!==e&&String(r)!==String(e);case"contains":return typeof r=="string"&&typeof e=="string"&&r.toLowerCase().includes(e.toLowerCase());case"startswith":return typeof r=="string"&&typeof e=="string"&&r.toLowerCase().startsWith(e.toLowerCase());case"gt":return Number(r)>Number(e);case"gte":return Number(r)>=Number(e);case"lt":return Number(r)<Number(e);case"lte":return Number(r)<=Number(e);default:return!1}}function pe(r,n,e){const t=n.current;if(!t.groupable)return{content:[{type:"text",text:"Grouping not enabled — aggregates require grouped data."}],isError:!0};if(!t.group||t.group.length===0)return{content:[{type:"text",text:"No active grouping — group the data first."}],isError:!0};if(!r.field||!r.aggregate)return{content:[{type:"text",text:"Missing required arguments: field, aggregate"}],isError:!0};const a=r.field,i=r.aggregate,o={field:a,aggregate:i},u=t.group.map(d=>{var s;const c=(s=d.aggregates)!=null?s:[];return c.some(p=>p.field===a&&p.aggregate===i)?d:{...d,aggregates:[...c,o]}});return C(n,t.onGroupChange,{group:u},{group:u},e),{content:[{type:"text",text:`Aggregate "${i}" added for column "${a}".`}]}}function me(r,n){const e=[];for(const t of r){const a=new Set;for(const i of n){const o=i[t.field];a.has(o)||(a.add(o),e.push({field:t.field,value:o,expanded:!1}))}}return e}function ge(r,n,e){if(!r.field||r.value==null)return null;const t=r.field,a=r.value,i=typeof a=="string"||typeof a=="number"?String(a):JSON.stringify(a);return{updated:n.find(d=>d.field===t&&String(d.value)===i)?n.map(d=>d.field===t&&String(d.value)===i?{...d,expanded:e}:d):[...n,{field:t,value:a,expanded:e}],field:t,valueStr:i}}function xe(r,n,e,t){var i,o,u;const a=e.current;if(!a.groupable)return{content:[{type:"text",text:"Grouping not enabled."}],isError:!0};if(!a.onGroupExpandChange)return{content:[{type:"text",text:"onGroupExpandChange callback not provided."}],isError:!0};switch(r){case"GridGroupExpandAll":return a.onGroupExpandChange({groupExpand:[],target:t}),{content:[{type:"text",text:"All groups expanded."}]};case"GridGroupCollapseAll":{if(!a.group||a.group.length===0)return{content:[{type:"text",text:"No active grouping."}],isError:!0};const d=(o=(i=t==null?void 0:t.getLeafDataItems)==null?void 0:i.call(t))!=null?o:$(a.data),c=me(a.group,d);return a.onGroupExpandChange({groupExpand:c,target:t}),{content:[{type:"text",text:"All groups collapsed."}]}}case"GridGroupExpand":case"GridGroupCollapse":{const d=r==="GridGroupExpand",c=ge(n,(u=a.groupExpand)!=null?u:[],d);if(!c)return{content:[{type:"text",text:"Missing required arguments: field, value"}],isError:!0};a.onGroupExpandChange({groupExpand:c.updated,target:t});const l=d?"expanded":"collapsed";return{content:[{type:"text",text:`Group "${c.field}=${c.valueStr}" ${l}.`}]}}default:return{content:[{type:"text",text:`Unknown group expand command: ${r}`}],isError:!0}}}const fe={componentSuffix:"grid",createTools(r,n,e,t){const a=[],i=m=>`${e.groupName}_${m}`,o=n.current,u=Z(o.children),d=!!o.onHighlightChange,c=!!o.selectable,l=c&&(!!o.onHeaderSelectionChange||!!o.dataItemKey),s=!!o.onDetailExpandChange,p=!!o.groupable&&!!o.onGroupExpandChange,g=!!o.pdf,G=!!o.csv,w=!!o.reorderable,S=!!o.resizable,h=!!o.onColumnsStateChange,D=!!o.onItemChange||!!o.editable,k=[{name:"sort",description:`Sort the ${e.dataName} grid by a column`,commandType:"GridSort",enabled:!!(o.sortable||o.columnMenu)},{name:"clear_sort",description:`Remove all sorting from the ${e.dataName} grid`,commandType:"GridClearSort",enabled:!!(o.sortable||o.columnMenu)},{name:"filter",description:`Filter the ${e.dataName} grid on a column`,commandType:"GridFilter",enabled:!!(o.filterable||o.columnMenu)},{name:"clear_filters",description:`Remove all filters from the ${e.dataName} grid`,commandType:"GridClearFilter",enabled:!!(o.filterable||o.columnMenu)},{name:"group",description:`Group the ${e.dataName} grid rows by a column`,commandType:"GridGroup",enabled:!!(o.groupable||o.columnMenu)},{name:"clear_group",description:`Remove all grouping from the ${e.dataName} grid`,commandType:"GridClearGroup",enabled:!!(o.groupable||o.columnMenu)},{name:"page",description:`Navigate to a specific page in the ${e.dataName} grid`,commandType:"GridPage",enabled:!!o.pageable},{name:"set_page_size",description:`Change the number of items per page in the ${e.dataName} grid`,commandType:"GridPageSize",enabled:!!o.pageable},{name:"highlight",description:`Visually highlight rows in the ${e.dataName} grid`,commandType:"GridHighlight",enabled:d},{name:"clear_highlight",description:`Remove all row highlighting from the ${e.dataName} grid`,commandType:"GridClearHighlight",enabled:d},{name:"select",description:`Select rows in the ${e.dataName} grid`,commandType:"GridSelect",enabled:c},{name:"clear_select",description:`Clear all row selections in the ${e.dataName} grid`,commandType:"GridClearSelect",enabled:c},{name:"select_all",description:`Select all rows in the ${e.dataName} grid`,commandType:"GridSelectAll",enabled:l},{name:"detail_expand",description:`Expand detail rows matching a condition in the ${e.dataName} grid`,commandType:"GridDetailExpand",enabled:s},{name:"detail_collapse",description:`Collapse detail rows matching a condition in the ${e.dataName} grid`,commandType:"GridDetailCollapse",enabled:s},{name:"detail_expand_all",description:`Expand all detail rows in the ${e.dataName} grid`,commandType:"GridDetailExpandAll",enabled:s},{name:"detail_collapse_all",description:`Collapse all detail rows in the ${e.dataName} grid`,commandType:"GridDetailCollapseAll",enabled:s},{name:"group_expand",description:`Expand a specific group in the ${e.dataName} grid`,commandType:"GridGroupExpand",enabled:p},{name:"group_collapse",description:`Collapse a specific group in the ${e.dataName} grid`,commandType:"GridGroupCollapse",enabled:p},{name:"group_expand_all",description:`Expand all groups in the ${e.dataName} grid`,commandType:"GridGroupExpandAll",enabled:p},{name:"group_collapse_all",description:`Collapse all groups in the ${e.dataName} grid`,commandType:"GridGroupCollapseAll",enabled:p},{name:"set_aggregates",description:`Add an aggregate function (sum, average, count, min, max) to a column in the ${e.dataName} grid. Requires active grouping.`,commandType:"GridSetAggregates",enabled:!!o.groupable},{name:"export_pdf",description:`Export the ${e.dataName} grid to PDF`,commandType:"GridExportPDF",enabled:g},{name:"export_csv",description:`Export the ${e.dataName} grid to CSV`,commandType:"GridExportCSV",enabled:G},{name:"reorder_column",description:`Reorder a column in the ${e.dataName} grid`,commandType:"GridColumnReorder",enabled:w},{name:"resize_column",description:`Resize a column in the ${e.dataName} grid`,commandType:"GridColumnResize",enabled:S},{name:"show_column",description:`Show a hidden column in the ${e.dataName} grid`,commandType:"GridColumnShow",enabled:h},{name:"hide_column",description:`Hide a column in the ${e.dataName} grid`,commandType:"GridColumnHide",enabled:h},{name:"lock_column",description:`Lock a column in the ${e.dataName} grid`,commandType:"GridColumnLock",enabled:h},{name:"unlock_column",description:`Unlock a column in the ${e.dataName} grid`,commandType:"GridColumnUnlock",enabled:h},{name:"add",description:`Add a new record to the ${e.dataName} grid`,commandType:"GridAdd",enabled:D},{name:"update",description:`Update a record in the ${e.dataName} grid`,commandType:"GridUpdate",enabled:D},{name:"delete",description:`Delete a record from the ${e.dataName} grid`,commandType:"GridDelete",enabled:D},{name:"get_data",description:`Read the data currently visible in the ${e.dataName} grid as JSON`,commandType:"GridGetData",enabled:!1}],b=n.current.webMcp,T=typeof b=="object"&&b!==null&&typeof b.tools=="function"?b.tools:void 0,j={tname:i,columns:u,data:o.data},J=T?T(k,j):k;let x=null;const W=async(m,f)=>{var M,q,z,P,F,O,K;const v=(q=x==null?void 0:x.filters)!=null?q:(M=n.current.filter)==null?void 0:M.filters,E=ne(m,f,n,r,v);if(E)return m==="GridFilter"&&f.field&&f.operator?x={logic:"and",filters:[...(F=(P=x==null?void 0:x.filters)!=null?P:(z=n.current.filter)==null?void 0:z.filters)!=null?F:[],{field:f.field,operator:f.operator,value:f.value}]}:m==="GridClearFilter"&&(x={logic:"and",filters:[]}),E;const H=de(m,f,n,r);if(H)return H;if(m==="GridGetData"){x&&await new Promise(X=>setTimeout(X,100));const A=1e3,y=(K=(O=r==null?void 0:r.getLeafDataItems)==null?void 0:O.call(r))!=null?K:$(n.current.data),L=Array.isArray(y)&&y.length>A?y.slice(0,A):y;return{content:[{type:"text",text:JSON.stringify(L!==y?{rows:L,truncated:!0,total:y.length}:y)}]}}return{content:[{type:"text",text:`Unknown command: ${m}`}],isError:!0}};for(const m of J){if(!m.enabled)continue;const f=Q.getGridToolSchema(m.commandType,u),v=m.commandType;try{a.push(t.registerTool({name:i(m.name),description:m.description,inputSchema:f,execute:async E=>W(v,E||{})}))}catch{}}return a}};exports.gridAdapter=fe;
|