@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.
Files changed (78) hide show
  1. package/WebMcpProvider.js +1 -1
  2. package/WebMcpProvider.mjs +84 -80
  3. package/adapters/button.d.ts +1 -1
  4. package/adapters/button.js +1 -1
  5. package/adapters/button.mjs +12 -17
  6. package/adapters/{dashboard.d.ts → checkbox.d.ts} +5 -6
  7. package/adapters/checkbox.js +8 -0
  8. package/adapters/checkbox.mjs +60 -0
  9. package/adapters/dropdowntree.js +1 -1
  10. package/adapters/dropdowntree.mjs +78 -51
  11. package/adapters/editor.d.ts +0 -1
  12. package/adapters/editor.js +1 -1
  13. package/adapters/editor.mjs +38 -46
  14. package/adapters/form.d.ts +1 -0
  15. package/adapters/form.js +3 -3
  16. package/adapters/form.mjs +75 -49
  17. package/adapters/gantt.d.ts +2 -0
  18. package/adapters/gantt.js +1 -1
  19. package/adapters/gantt.mjs +188 -140
  20. package/adapters/grid.d.ts +0 -1
  21. package/adapters/grid.js +1 -1
  22. package/adapters/grid.mjs +52 -60
  23. package/adapters/multicolumncombobox.d.ts +20 -0
  24. package/adapters/multicolumncombobox.js +8 -0
  25. package/adapters/multicolumncombobox.mjs +75 -0
  26. package/adapters/multiselect.d.ts +2 -0
  27. package/adapters/multiselect.js +1 -1
  28. package/adapters/multiselect.mjs +46 -30
  29. package/adapters/notification.js +1 -1
  30. package/adapters/notification.mjs +14 -14
  31. package/adapters/pivotgrid.js +1 -1
  32. package/adapters/pivotgrid.mjs +39 -47
  33. package/adapters/scheduler.js +1 -1
  34. package/adapters/scheduler.mjs +137 -92
  35. package/adapters/spreadsheet.js +1 -1
  36. package/adapters/spreadsheet.mjs +3 -3
  37. package/adapters/switch.js +1 -1
  38. package/adapters/switch.mjs +29 -19
  39. package/adapters/treeview.js +2 -2
  40. package/adapters/treeview.mjs +79 -113
  41. package/adapters/window.d.ts +0 -2
  42. package/adapters/window.js +1 -1
  43. package/adapters/window.mjs +29 -63
  44. package/commands/form.d.ts +4 -1
  45. package/commands/form.js +1 -1
  46. package/commands/form.mjs +11 -7
  47. package/commands/gantt.js +1 -1
  48. package/commands/gantt.mjs +14 -10
  49. package/commands/grid.d.ts +0 -4
  50. package/commands/grid.js +1 -1
  51. package/commands/grid.mjs +18 -24
  52. package/commands/index.d.ts +0 -1
  53. package/commands/pivotgrid.d.ts +0 -4
  54. package/commands/pivotgrid.js +1 -1
  55. package/commands/pivotgrid.mjs +6 -12
  56. package/commands/scheduler.d.ts +10 -0
  57. package/commands/scheduler.js +1 -1
  58. package/commands/scheduler.mjs +16 -4
  59. package/commands/window.d.ts +0 -8
  60. package/commands/window.js +1 -1
  61. package/commands/window.mjs +8 -18
  62. package/dist/cdn/js/kendo-react-webmcp.js +1 -1
  63. package/index.d.mts +2 -1
  64. package/index.d.ts +2 -1
  65. package/index.js +1 -1
  66. package/index.mjs +248 -249
  67. package/package.json +3 -3
  68. package/schemas/gantt.d.ts +4 -0
  69. package/schemas/gantt.js +1 -1
  70. package/schemas/gantt.mjs +93 -8
  71. package/schemas/scheduler.d.ts +2 -0
  72. package/schemas/scheduler.js +1 -1
  73. package/schemas/scheduler.mjs +21 -5
  74. package/adapters/dashboard.js +0 -8
  75. package/adapters/dashboard.mjs +0 -41
  76. package/commands/dashboard.d.ts +0 -19
  77. package/commands/dashboard.js +0 -8
  78. package/commands/dashboard.mjs +0 -21
@@ -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 N from "react";
9
- import { GanttCommands as i, getGanttToolSchema as H } from "../commands/gantt.mjs";
10
- import { toText as S } from "./utils.mjs";
11
- function E(t) {
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: (t == null ? void 0 : t.id) || "id",
14
- title: (t == null ? void 0 : t.title) || "title",
15
- start: (t == null ? void 0 : t.start) || "start",
16
- end: (t == null ? void 0 : t.end) || "end",
17
- percentComplete: (t == null ? void 0 : t.percentComplete) || "percentComplete",
18
- isExpanded: (t == null ? void 0 : t.isExpanded) || "isExpanded",
19
- children: (t == null ? void 0 : t.children) || "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 b(t, e) {
23
- const n = [], r = (o) => {
24
- for (const c of o) {
23
+ function w(e, t) {
24
+ const n = [], r = (a) => {
25
+ for (const c of a) {
25
26
  n.push(c);
26
- const a = c[e.children];
27
- Array.isArray(a) && a.length > 0 && r(a);
27
+ const o = c[t.children];
28
+ Array.isArray(o) && o.length > 0 && r(o);
28
29
  }
29
30
  };
30
- return r(t), n;
31
+ return r(e), n;
31
32
  }
32
- function V(t) {
33
- const e = [];
34
- if (Array.isArray(t.columns))
35
- for (const n of t.columns)
36
- n.field && e.push({ field: n.field, id: n.id || n.field });
37
- return e.length === 0 && t.children && N.Children.forEach(t.children, (n) => {
38
- if (N.isValidElement(n) && n.props.field) {
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
- e.push({ field: r.field, id: r.id || r.field });
41
+ t.push({ field: r.field, id: r.id || r.field });
41
42
  }
42
- }), e;
43
+ }), t;
43
44
  }
44
- function W(t, e, n) {
45
- if (!t.field)
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 = t.field, o = t.dir || "asc", c = [{ field: r, dir: o }];
48
- return e.current.onSortChange && e.current.onSortChange({ sort: c, field: r, target: n }), { content: [{ type: "text", text: `Sorted by ${r} ${o}.` }] };
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 U(t, e, n) {
51
- if (!t.field || !t.operator)
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 = t.field, o = t.operator, c = t.value;
54
- return e.current.onFilterChange && e.current.onFilterChange({
55
- filter: { logic: "and", filters: [{ field: r, operator: o, value: c }] },
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} ${o} "${S(c)}".` }] };
58
+ }), { content: [{ type: "text", text: `Filter applied: ${r} ${a} "${g(c)}".` }] };
58
59
  }
59
- function I(t, e, n) {
60
- const r = typeof t == "string" ? t.toLowerCase() : t, o = typeof n == "string" ? n.toLowerCase() : n;
61
- switch (e) {
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 === o;
64
+ return r === a;
64
65
  case "neq":
65
- return r !== o;
66
+ return r !== a;
66
67
  case "contains":
67
- return typeof r == "string" && typeof o == "string" && r.includes(o);
68
+ return typeof r == "string" && typeof a == "string" && r.includes(a);
68
69
  case "startswith":
69
- return typeof r == "string" && typeof o == "string" && r.startsWith(o);
70
+ return typeof r == "string" && typeof a == "string" && r.startsWith(a);
70
71
  case "endswith":
71
- return typeof r == "string" && typeof o == "string" && r.endsWith(o);
72
+ return typeof r == "string" && typeof a == "string" && r.endsWith(a);
72
73
  default:
73
- return r === o;
74
+ return r === a;
74
75
  }
75
76
  }
76
- function A(t, e, n, r) {
77
- const o = n.current, c = E(o.taskModelFields), a = b(o.taskData || [], c);
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 e.field && e.operator ? s = a.find((l) => {
80
- const d = l[e.field];
81
- return I(d, e.operator, e.value);
82
- }) : e.id !== void 0 && (s = a.find((l) => String(l[c.id]) === String(e.id))), s ? (o.onExpandChange && o.onExpandChange({ dataItem: s, value: t, level: [], target: r }), { content: [{ type: "text", text: `${t ? "Expanded" : "Collapsed"} task "${S(s[c.title])}".` }] }) : { content: [{ type: "text", text: "No matching task found." }], isError: !0 };
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 z(t, e, n) {
85
- const r = e.current, o = E(r.taskModelFields), a = b(r.taskData || [], o).filter((u) => {
86
- const l = u[o.children];
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 a)
91
- r.onExpandChange({ dataItem: u, value: t, level: [], target: n });
92
- return { content: [{ type: "text", text: `${t ? "Expanded" : "Collapsed"} ${a.length} parent task(s).` }] };
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 L(t, e, n, r) {
95
- switch (t) {
95
+ function J(e, t, n, r) {
96
+ switch (e) {
96
97
  case i.Expand:
97
- return A(!0, e, n, r);
98
+ return q(!0, t, n, r);
98
99
  case i.Collapse:
99
- return A(!1, e, n, r);
100
+ return q(!1, t, n, r);
100
101
  case i.ExpandAll:
101
- return z(!0, n, r);
102
+ return R(!0, n, r);
102
103
  case i.CollapseAll:
103
- return z(!1, n, r);
104
+ return R(!1, n, r);
104
105
  default:
105
106
  return {
106
- content: [{ type: "text", text: `Unknown expand/collapse command: ${t}` }],
107
+ content: [{ type: "text", text: `Unknown expand/collapse command: ${e}` }],
107
108
  isError: !0
108
109
  };
109
110
  }
110
111
  }
111
- function g(t, e) {
112
- return t.id === e || t.field === e;
112
+ function $(e, t) {
113
+ return e.id === t || e.field === t;
113
114
  }
114
- function _(t, e, n) {
115
- return t.map(
116
- (r) => g(r, e) ? n(r) : r
115
+ function H(e, t, n) {
116
+ return e.map(
117
+ (r) => $(r, t) ? n(r) : r
117
118
  );
118
119
  }
119
- function j(t, e, n, r, o, c, a) {
120
+ function Q(e, t, n, r, a, c, o) {
120
121
  var u;
121
- const s = Number(e.position);
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 (a) {
125
- const l = o.findIndex((p) => g(p, t)), d = c[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, w) => ({ ...C, orderIndex: w })),
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 = o.findIndex((d) => g(d, t));
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 ${t} moved to position ${s}.` }] };
139
+ return { content: [{ type: "text", text: `Column ${e} moved to position ${s}.` }] };
139
140
  }
140
- function B(t, e, n, r, o, c, a) {
141
+ function X(e, t, n, r, a, c, o) {
141
142
  var u;
142
- const s = Number.parseInt(e.size, 10);
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 (a)
146
+ if (o)
146
147
  (u = n.onColumnsStateChange) == null || u.call(n, {
147
- columnsState: _(c, t, (l) => ({ ...l, width: s })),
148
+ columnsState: H(c, e, (l) => ({ ...l, width: s })),
148
149
  target: r
149
150
  });
150
151
  else if (n.onColumnResize) {
151
- const l = o.findIndex((C) => g(C, t)), d = (n.columns || [])[l], p = d && d.width || 0;
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 ${t} resized to ${s}px.` }] };
156
+ return { content: [{ type: "text", text: `Column ${e} resized to ${s}px.` }] };
156
157
  }
157
- function D(t, e, n, r, o, c) {
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: _(o, t, (u) => ({ ...u, hidden: e })),
161
+ columnsState: H(a, e, (u) => ({ ...u, hidden: t })),
161
162
  target: r
162
- }), { content: [{ type: "text", text: `Column ${t} is now ${e ? "hidden" : "visible"}.` }] }) : { content: [{ type: "text", text: "Column state changes not supported." }], isError: !0 };
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 O(t, e, n, r, o) {
165
- const c = e.id;
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 a = n.current, s = !!a.onColumnsStateChange && !!r, u = s ? a.columnsState || (r == null ? void 0 : r.columns) || [] : [];
169
- switch (t) {
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 j(c, e, a, r, o, u, s);
172
+ return Q(c, t, o, r, a, u, s);
172
173
  case i.ColumnResize:
173
- return B(c, e, a, r, o, u, s);
174
+ return X(c, t, o, r, a, u, s);
174
175
  case i.ColumnShow:
175
- return D(c, !1, a, r, u, s);
176
+ return U(c, !1, o, r, u, s);
176
177
  case i.ColumnHide:
177
- return D(c, !0, a, r, u, s);
178
+ return U(c, !0, o, r, u, s);
178
179
  default:
179
180
  return null;
180
181
  }
181
182
  }
182
- function J(t, e, n) {
183
- const r = t.view;
184
- return r ? (e.current.onViewChange && e.current.onViewChange({ value: r, target: n }), { content: [{ type: "text", text: `Switched to ${r} view.` }] }) : { content: [{ type: "text", text: "Missing required argument: view" }], isError: !0 };
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 K(t, e, n, r) {
187
+ function F(e, t, n, r) {
187
188
  var s;
188
- const o = n.current, c = o.onTaskChange || o.onDataStateChange;
189
+ const a = n.current, c = a.onTaskChange || a.onDataStateChange;
189
190
  if (!c)
190
191
  return null;
191
- const a = E(o.taskModelFields);
192
- switch (t) {
192
+ const o = T(a.taskModelFields);
193
+ switch (e) {
193
194
  case i.CreateTask: {
194
- const u = e.title;
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
- [a.id]: Date.now(),
199
- [a.title]: u,
200
- [a.start]: e.start ? new Date(e.start) : void 0,
201
- [a.end]: e.end ? new Date(e.end) : void 0,
202
- [a.percentComplete]: (s = e.percentComplete) != null ? s : 0
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 = b(o.taskData || [], a);
208
+ const u = w(a.taskData || [], o);
208
209
  let l;
209
- return e.field && e.operator ? l = u.find((d) => {
210
- const p = d[e.field];
211
- return I(p, e.operator, e.value);
212
- }) : e.id !== void 0 && (l = u.find((d) => String(d[a.id]) === String(e.id))), l ? (c({ created: [], updated: [], deleted: [l] }), { content: [{ type: "text", text: `Deleted task "${S(l[a.title])}".` }] }) : { content: [{ type: "text", text: "No matching task found." }], isError: !0 };
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 X = {
230
+ const et = {
219
231
  componentSuffix: "gantt",
220
- createTools(t, e, n, r) {
221
- const o = [], c = (m) => `${n.groupName}_${m}`, a = e.current, s = V(a), u = !!a.sortable, l = !!a.onFilterChange, d = !!a.onExpandChange, p = !!a.onViewChange, C = !!a.onTaskChange || !!a.onDataStateChange, w = !!a.reorderable, k = !!a.resizable, $ = !!a.onColumnsStateChange, v = [
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: "change_view",
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: "create_task",
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: w
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: k
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
- ], y = e.current.webMcp, T = typeof y == "object" && y !== null && typeof y.tools == "function" ? y.tools : void 0, q = { tname: c, columns: s, data: a.taskData }, R = T ? T(v, q) : v, G = async (m, x) => {
313
- const h = e.current;
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 W(x, e, t);
340
+ return K(f, t, e);
317
341
  case i.ClearSort:
318
- return h.onSortChange && h.onSortChange({ sort: [], field: "", target: t }), { content: [{ type: "text", text: "Sorting cleared." }] };
342
+ return y.onSortChange && y.onSortChange({ sort: [], field: "", target: e }), { content: [{ type: "text", text: "Sorting cleared." }] };
319
343
  case i.Filter:
320
- return U(x, e, t);
344
+ return O(f, t, e);
321
345
  case i.ClearFilter:
322
- return h.onFilterChange && h.onFilterChange({ filter: { logic: "and", filters: [] }, target: t }), { content: [{ type: "text", text: "All filters cleared." }] };
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 L(m, x, e, t);
351
+ return J(m, f, t, e);
328
352
  case i.ChangeView:
329
- return J(x, e, t);
353
+ return Z(f, t, e);
330
354
  case i.CreateTask:
331
- case i.DeleteTask: {
332
- const f = K(m, x, e);
333
- return f || { content: [{ type: "text", text: "Task operations not supported." }], isError: !0 };
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 f = O(m, x, e, t, s);
340
- return f || {
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 R) {
397
+ for (const m of L) {
350
398
  if (!m.enabled)
351
399
  continue;
352
- const x = H(m.commandType, s), h = m.commandType;
400
+ const f = m.inputSchema || j(m.commandType, s), y = m.commandType, x = m.execute;
353
401
  try {
354
- o.push(
402
+ a.push(
355
403
  r.registerTool({
356
404
  name: c(m.name),
357
405
  description: m.description,
358
- inputSchema: x,
359
- execute: async (f) => G(h, f || {})
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 o;
413
+ return a;
366
414
  }
367
415
  };
368
416
  export {
369
- X as ganttAdapter
417
+ et as ganttAdapter
370
418
  };
@@ -31,7 +31,6 @@ interface GridColumnState {
31
31
  interface GridAdapterHandle {
32
32
  exportAsPdf?: () => void;
33
33
  saveAsCsv?: () => Promise<void>;
34
- saveAsExcel?: () => void;
35
34
  getTotal?: () => number;
36
35
  getLeafDataItems?: () => unknown[];
37
36
  columns?: Array<{
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;