@progress/kendo-react-grid 13.2.0-develop.7 → 13.2.0-develop.8

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.
@@ -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 u=require("../utils/index.js"),m=1,w=20;class W{constructor(a){this.columns=[],this.columnsState=[],this.resizable=!1,this.isRtl=!1,this.setIsRtl=n=>{this.isRtl=n},this.initWidths=()=>{var c;const n=((c=this.colGroupMain)==null?void 0:c.children)||[],l=u.getFlatColumnsState(this.columnsState),r=this.columns.filter(e=>{var s;return!((s=e.children)!=null&&s.length)});for(let e=0;e<n.length;e++){const s=n[e],t=r[e];let i="";const h=l.find(o=>o.id===r[e].id);h&&(i=this.applyWidthConstraints(h,t)),s.width=i,this.colGroupHeader&&(this.colGroupHeader.children[e].width=i),this.colGroupFooter&&(this.colGroupFooter.children[e].width=i)}},this.dragHandler=(n,l,r,c)=>{const e=n.originalEvent;c||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation());const s=r.closest("th");if(!s||!s)return;const t=s.clientWidth;let i=t;if(this.isRtl?i+=r.getBoundingClientRect().right-r.offsetWidth/2-n.clientX:i+=n.clientX-r.getBoundingClientRect().left-r.offsetWidth/2,!c&&Math.abs(i-t)<1)return;this.fixateInitialWidths(s.parentElement.clientWidth),this.setWidths(l,Math.floor(i)/t);const h=this.columns.filter(o=>!o.children.length).findIndex(o=>o.id===l.id);this.onResize(h,t,i,e,c,this.columnsState,l.id)},this.dblClickHandler=(n,l)=>{const r=this.columns.filter(d=>l.indexOf(d.id)>-1),c=u.getFlatColumnsState(this.columnsState);if(!this.colGroupMain||!r.length)return;const e={},s=r;for(;s.length>0;){const d=s.pop();if(!d)break;d.children.length?s.push(...d.children):e[d.id]=d}const t=this.columns.filter(d=>!d.children.length),i=[];t.forEach((d,p)=>{e[d.id]&&i.push(p)});const h=[this.colGroupMain.parentElement],o=[this.colGroupMain];this.colGroupHeader&&(h.push(this.colGroupHeader.parentElement),o.push(this.colGroupHeader)),this.colGroupFooter&&(h.push(this.colGroupFooter.parentElement),o.push(this.colGroupFooter)),h.forEach(d=>d.classList.add("k-autofitting"));const f=[];o.forEach(d=>{i.forEach(p=>{d.children[p]&&(d.children[p].width="",f[p]=Math.max(f[p]||0,d.children[p].offsetWidth+m))})}),o.forEach(d=>{i.forEach(p=>{if(d.children[p]){d.children[p].width=f[p]+"px";const g=c.find(G=>G.id===t[p].id);g&&(g.width=f[p])}})}),h.forEach(d=>d.classList.remove("k-autofitting")),this.onResize(i[0],0,0,n,!0,this.columnsState,l[0])},this.updateColElements=n=>{const l=this.columns.filter(c=>!c.hidden&&!c.children.length);let r=1e-10;for(let c=0;c<n.length;c++){const e=n[c],s=l.findIndex(f=>f.id===e.id),t=parseFloat((e.width||0).toString()),i=Math.floor(t);r+=t-i;const h=i+Math.floor(r);r-=Math.floor(r);const o=l.find(f=>f.id===e.id);if(!o)return;if(this.colGroupMain&&this.colGroupMain.children[s]){const f=parseInt(this.colGroupMain.children[s].width,10);this.colGroupMain.children[s].width=h+"px",this.updateNextLockedCol(this.colGroupMain.parentElement,o,f-h)}if(this.colGroupHeader&&this.colGroupHeader.children[s]){const f=parseInt(this.colGroupHeader.children[s].width,10);this.colGroupHeader.children[s].width=h+"px",this.updateNextLockedCol(this.colGroupHeader.parentElement,o,f-h)}if(this.colGroupFooter&&this.colGroupFooter.children[s]){const f=parseInt(this.colGroupFooter.children[s].width,10);this.colGroupFooter.children[s].width=h+"px",this.updateNextLockedCol(this.colGroupFooter.parentElement,o,f-h)}}},this.onResize=a}applyWidthConstraints(a,n,l=1){if(!a.width)return a.width||"";const r=a.width.toString();if(r.includes("%")){const s=parseFloat(r)*l,t=Math.max(0,Math.min(100,s));return a.width=t+"%",a.width}else{let e=parseFloat(r)*l;const s=n.minResizableWidth===void 0?10:n.minResizableWidth,t=n==null?void 0:n.minWidth,i=t!==void 0?Math.max(s,t):s,h=n==null?void 0:n.maxWidth;return e<i&&(e=i),h!==void 0&&e>h&&(e=h),a.width=e,e}}fixateInitialWidths(a){var s;let n=0;const l=((s=this.colGroupMain)==null?void 0:s.children)||[];for(let t=0;t<l.length;t++)l[t].width?a-=l[t].clientWidth:n++;if(n===0)return;const r=Math.floor(a/n),c=u.getFlatColumnsState(this.columnsState),e=this.columns.filter(t=>!t.children.length);for(let t=0;t<l.length;t++){const i=l[t],h=i.width?i.clientWidth:r;i.width=h;const o=c.find(f=>f.id===e[t].id);o&&(o.width=h.toString()),this.colGroupHeader&&(this.colGroupHeader.children[t].width=h),this.colGroupFooter&&(this.colGroupFooter.children[t].width=h)}}setWidths(a,n){const l=u.getFlatColumnsState(this.columnsState),r=this.columns.findIndex(t=>t.id===a.id),c=[];let e=a.children.filter(t=>!t.hidden).length;for(let t=r+1;t<this.columns.length&&!(e<=0);t++){const i=this.columns[t];i.children.length?e+=i.children.filter(h=>!h.hidden).length:c.push(i),e--}c.length===0&&c.push(a);const s=[];c.forEach(t=>{const i=l.find(h=>h.id===t.id);i&&(this.applyWidthConstraints(i,t,n),s.push(i))}),this.updateColElements(s)}updateNextLockedCol(a,n,l){const r=n.index,c=this.colGroupMain.parentElement.closest(".k-grid"),e=c==null?void 0:c.clientWidth,s=this.columns.filter(t=>t.locked).map(t=>parseInt(t.width+"",10)).reduce((t,i)=>t+i,0);!n.locked||e<=s+w||this.columns.forEach(t=>{if(t!=null&&t.locked&&l){const i=a==null?void 0:a.querySelectorAll('[aria-colindex="'+t.ariaColumnIndex+'"]');i==null||i.forEach(h=>{const o=h.style;this.isRtl?(t.index>r&&o&&o.right&&(o.right=parseInt(o.right,10)-l+"px"),t.index<r&&o&&o.left&&(o.left=parseInt(o.left,10)-l+"px")):(t.index>r&&o&&o.left&&(o.left=parseInt(o.left,10)-l+"px"),t.index<r&&o&&o.right&&(o.right=parseInt(o.right,10)-l+"px"))})}})}}exports.ColumnResize=W;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("../utils/index.js"),m=1,w=20;class W{constructor(a){this.columns=[],this.columnsState=[],this.resizable=!1,this.isRtl=!1,this.setIsRtl=n=>{this.isRtl=n},this.initWidths=()=>{var c;const n=((c=this.colGroupMain)==null?void 0:c.children)||[],l=u.getFlatColumnsState(this.columnsState),r=this.columns.filter(e=>{var o;return!((o=e.children)!=null&&o.length)});for(let e=0;e<n.length;e++){const o=n[e],t=r[e];let i="";const h=l.find(s=>s.id===r[e].id);h&&(i=this.applyWidthConstraints(h,t)),o.width=i,this.colGroupHeader&&(this.colGroupHeader.children[e].width=i),this.colGroupFooter&&(this.colGroupFooter.children[e].width=i)}},this.dragHandler=(n,l,r,c)=>{const e=n.originalEvent;c||(e.preventDefault(),e.stopPropagation(),e.stopImmediatePropagation());const o=r.closest("th");if(!o||!o)return;const t=o.clientWidth;let i=t;if(this.isRtl?i+=r.getBoundingClientRect().right-r.offsetWidth/2-n.clientX:i+=n.clientX-r.getBoundingClientRect().left-r.offsetWidth/2,!c&&Math.abs(i-t)<1)return;this.fixateInitialWidths(o.parentElement.clientWidth),this.setWidths(l,Math.floor(i)/t);const h=this.columns.filter(s=>!s.children.length).findIndex(s=>s.id===l.id);this.onResize(h,t,i,e,c,this.columnsState,l.id)},this.dblClickHandler=(n,l)=>{const r=this.columns.filter(d=>l.indexOf(d.id)>-1),c=u.getFlatColumnsState(this.columnsState);if(!this.colGroupMain||!r.length)return;const e={},o=r;for(;o.length>0;){const d=o.pop();if(!d)break;d.children.length?o.push(...d.children):e[d.id]=d}const t=this.columns.filter(d=>!d.children.length),i=[];t.forEach((d,p)=>{e[d.id]&&i.push(p)});const h=[this.colGroupMain.parentElement],s=[this.colGroupMain];this.colGroupHeader&&(h.push(this.colGroupHeader.parentElement),s.push(this.colGroupHeader)),this.colGroupFooter&&(h.push(this.colGroupFooter.parentElement),s.push(this.colGroupFooter)),h.forEach(d=>d.classList.add("k-autofitting"));const f=[];s.forEach(d=>{i.forEach(p=>{d.children[p]&&(d.children[p].width="",f[p]=Math.max(f[p]||0,d.children[p].offsetWidth+m))})}),s.forEach(d=>{i.forEach(p=>{if(d.children[p]){d.children[p].width=f[p]+"px";const g=c.find(G=>G.id===t[p].id);g&&(g.width=f[p])}})}),h.forEach(d=>d.classList.remove("k-autofitting")),this.onResize(i[0],0,0,n,!0,this.columnsState,l[0])},this.updateColElements=n=>{const l=this.columns.filter(c=>!c.hidden&&!c.children.length);let r=1e-10;for(let c=0;c<n.length;c++){const e=n[c],o=l.findIndex(f=>f.id===e.id),t=parseFloat((e.width||0).toString()),i=Math.floor(t);r+=t-i;const h=i+Math.floor(r);r-=Math.floor(r);const s=l.find(f=>f.id===e.id);if(!s)return;if(this.colGroupMain&&this.colGroupMain.children[o]){const f=parseInt(this.colGroupMain.children[o].width,10);this.colGroupMain.children[o].width=h+"px",this.updateNextLockedCol(this.colGroupMain.parentElement,s,f-h)}if(this.colGroupHeader&&this.colGroupHeader.children[o]){const f=parseInt(this.colGroupHeader.children[o].width,10);this.colGroupHeader.children[o].width=h+"px",this.updateNextLockedCol(this.colGroupHeader.parentElement,s,f-h)}if(this.colGroupFooter&&this.colGroupFooter.children[o]){const f=parseInt(this.colGroupFooter.children[o].width,10);this.colGroupFooter.children[o].width=h+"px",this.updateNextLockedCol(this.colGroupFooter.parentElement,s,f-h)}}},this.onResize=a}applyWidthConstraints(a,n,l=1){if(!a.width)return a.width||"";const r=a.width.toString();if(r.includes("%")){const f=parseFloat(r)*l,d=Math.max(0,Math.min(100,f));return a.width=d+"%",a.width}let e=parseFloat(r)*l;const o=n.minResizableWidth===void 0?10:n.minResizableWidth,t=n==null?void 0:n.minWidth,i=t!==void 0?Math.max(o,t):o,h=n==null?void 0:n.maxWidth;return e<i&&(e=i),h!==void 0&&e>h&&(e=h),a.width=e,e}fixateInitialWidths(a){var o;let n=0;const l=((o=this.colGroupMain)==null?void 0:o.children)||[];for(let t=0;t<l.length;t++)l[t].width?a-=l[t].clientWidth:n++;if(n===0)return;const r=Math.floor(a/n),c=u.getFlatColumnsState(this.columnsState),e=this.columns.filter(t=>!t.children.length);for(let t=0;t<l.length;t++){const i=l[t],h=i.width?i.clientWidth:r;i.width=h;const s=c.find(f=>f.id===e[t].id);s&&(s.width=h.toString()),this.colGroupHeader&&(this.colGroupHeader.children[t].width=h),this.colGroupFooter&&(this.colGroupFooter.children[t].width=h)}}setWidths(a,n){const l=u.getFlatColumnsState(this.columnsState),r=this.columns.findIndex(t=>t.id===a.id),c=[];let e=a.children.filter(t=>!t.hidden).length;for(let t=r+1;t<this.columns.length&&!(e<=0);t++){const i=this.columns[t];i.children.length?e+=i.children.filter(h=>!h.hidden).length:c.push(i),e--}c.length===0&&c.push(a);const o=[];c.forEach(t=>{const i=l.find(h=>h.id===t.id);i&&(this.applyWidthConstraints(i,t,n),o.push(i))}),this.updateColElements(o)}updateNextLockedCol(a,n,l){const r=n.index,c=this.colGroupMain.parentElement.closest(".k-grid"),e=c==null?void 0:c.clientWidth,o=this.columns.filter(t=>t.locked).map(t=>parseInt(t.width+"",10)).reduce((t,i)=>t+i,0);!n.locked||e<=o+w||this.columns.forEach(t=>{if(t!=null&&t.locked&&l){const i=a==null?void 0:a.querySelectorAll('[aria-colindex="'+t.ariaColumnIndex+'"]');i==null||i.forEach(h=>{const s=h.style;this.isRtl?(t.index>r&&s&&s.right&&(s.right=parseInt(s.right,10)-l+"px"),t.index<r&&s&&s.left&&(s.left=parseInt(s.left,10)-l+"px")):(t.index>r&&s&&s.left&&(s.left=parseInt(s.left,10)-l+"px"),t.index<r&&s&&s.right&&(s.right=parseInt(s.right,10)-l+"px"))})}})}}exports.ColumnResize=W;
@@ -14,54 +14,54 @@ class F {
14
14
  }, this.initWidths = () => {
15
15
  var c;
16
16
  const h = ((c = this.colGroupMain) == null ? void 0 : c.children) || [], l = u(this.columnsState), r = this.columns.filter((e) => {
17
- var s;
18
- return !((s = e.children) != null && s.length);
17
+ var o;
18
+ return !((o = e.children) != null && o.length);
19
19
  });
20
20
  for (let e = 0; e < h.length; e++) {
21
- const s = h[e], t = r[e];
21
+ const o = h[e], t = r[e];
22
22
  let i = "";
23
- const n = l.find((o) => o.id === r[e].id);
24
- n && (i = this.applyWidthConstraints(n, t)), s.width = i, this.colGroupHeader && (this.colGroupHeader.children[e].width = i), this.colGroupFooter && (this.colGroupFooter.children[e].width = i);
23
+ const n = l.find((s) => s.id === r[e].id);
24
+ n && (i = this.applyWidthConstraints(n, t)), o.width = i, this.colGroupHeader && (this.colGroupHeader.children[e].width = i), this.colGroupFooter && (this.colGroupFooter.children[e].width = i);
25
25
  }
26
26
  }, this.dragHandler = (h, l, r, c) => {
27
27
  const e = h.originalEvent;
28
28
  c || (e.preventDefault(), e.stopPropagation(), e.stopImmediatePropagation());
29
- const s = r.closest("th");
30
- if (!s || !s)
29
+ const o = r.closest("th");
30
+ if (!o || !o)
31
31
  return;
32
- const t = s.clientWidth;
32
+ const t = o.clientWidth;
33
33
  let i = t;
34
34
  if (this.isRtl ? i += r.getBoundingClientRect().right - r.offsetWidth / 2 - h.clientX : i += h.clientX - r.getBoundingClientRect().left - r.offsetWidth / 2, !c && Math.abs(i - t) < 1)
35
35
  return;
36
- this.fixateInitialWidths(s.parentElement.clientWidth), this.setWidths(l, Math.floor(i) / t);
37
- const n = this.columns.filter((o) => !o.children.length).findIndex((o) => o.id === l.id);
36
+ this.fixateInitialWidths(o.parentElement.clientWidth), this.setWidths(l, Math.floor(i) / t);
37
+ const n = this.columns.filter((s) => !s.children.length).findIndex((s) => s.id === l.id);
38
38
  this.onResize(n, t, i, e, c, this.columnsState, l.id);
39
39
  }, this.dblClickHandler = (h, l) => {
40
40
  const r = this.columns.filter((d) => l.indexOf(d.id) > -1), c = u(this.columnsState);
41
41
  if (!this.colGroupMain || !r.length)
42
42
  return;
43
- const e = {}, s = r;
44
- for (; s.length > 0; ) {
45
- const d = s.pop();
43
+ const e = {}, o = r;
44
+ for (; o.length > 0; ) {
45
+ const d = o.pop();
46
46
  if (!d)
47
47
  break;
48
- d.children.length ? s.push(...d.children) : e[d.id] = d;
48
+ d.children.length ? o.push(...d.children) : e[d.id] = d;
49
49
  }
50
50
  const t = this.columns.filter((d) => !d.children.length), i = [];
51
51
  t.forEach((d, p) => {
52
52
  e[d.id] && i.push(p);
53
53
  });
54
- const n = [this.colGroupMain.parentElement], o = [this.colGroupMain];
55
- this.colGroupHeader && (n.push(this.colGroupHeader.parentElement), o.push(this.colGroupHeader)), this.colGroupFooter && (n.push(this.colGroupFooter.parentElement), o.push(this.colGroupFooter)), n.forEach((d) => d.classList.add("k-autofitting"));
54
+ const n = [this.colGroupMain.parentElement], s = [this.colGroupMain];
55
+ this.colGroupHeader && (n.push(this.colGroupHeader.parentElement), s.push(this.colGroupHeader)), this.colGroupFooter && (n.push(this.colGroupFooter.parentElement), s.push(this.colGroupFooter)), n.forEach((d) => d.classList.add("k-autofitting"));
56
56
  const f = [];
57
- o.forEach((d) => {
57
+ s.forEach((d) => {
58
58
  i.forEach((p) => {
59
59
  d.children[p] && (d.children[p].width = "", f[p] = Math.max(
60
60
  f[p] || 0,
61
61
  d.children[p].offsetWidth + w
62
62
  ));
63
63
  });
64
- }), o.forEach((d) => {
64
+ }), s.forEach((d) => {
65
65
  i.forEach((p) => {
66
66
  if (d.children[p]) {
67
67
  d.children[p].width = f[p] + "px";
@@ -74,24 +74,24 @@ class F {
74
74
  const l = this.columns.filter((c) => !c.hidden && !c.children.length);
75
75
  let r = 1e-10;
76
76
  for (let c = 0; c < h.length; c++) {
77
- const e = h[c], s = l.findIndex((f) => f.id === e.id), t = parseFloat((e.width || 0).toString()), i = Math.floor(t);
77
+ const e = h[c], o = l.findIndex((f) => f.id === e.id), t = parseFloat((e.width || 0).toString()), i = Math.floor(t);
78
78
  r += t - i;
79
79
  const n = i + Math.floor(r);
80
80
  r -= Math.floor(r);
81
- const o = l.find((f) => f.id === e.id);
82
- if (!o)
81
+ const s = l.find((f) => f.id === e.id);
82
+ if (!s)
83
83
  return;
84
- if (this.colGroupMain && this.colGroupMain.children[s]) {
85
- const f = parseInt(this.colGroupMain.children[s].width, 10);
86
- this.colGroupMain.children[s].width = n + "px", this.updateNextLockedCol(this.colGroupMain.parentElement, o, f - n);
84
+ if (this.colGroupMain && this.colGroupMain.children[o]) {
85
+ const f = parseInt(this.colGroupMain.children[o].width, 10);
86
+ this.colGroupMain.children[o].width = n + "px", this.updateNextLockedCol(this.colGroupMain.parentElement, s, f - n);
87
87
  }
88
- if (this.colGroupHeader && this.colGroupHeader.children[s]) {
89
- const f = parseInt(this.colGroupHeader.children[s].width, 10);
90
- this.colGroupHeader.children[s].width = n + "px", this.updateNextLockedCol(this.colGroupHeader.parentElement, o, f - n);
88
+ if (this.colGroupHeader && this.colGroupHeader.children[o]) {
89
+ const f = parseInt(this.colGroupHeader.children[o].width, 10);
90
+ this.colGroupHeader.children[o].width = n + "px", this.updateNextLockedCol(this.colGroupHeader.parentElement, s, f - n);
91
91
  }
92
- if (this.colGroupFooter && this.colGroupFooter.children[s]) {
93
- const f = parseInt(this.colGroupFooter.children[s].width, 10);
94
- this.colGroupFooter.children[s].width = n + "px", this.updateNextLockedCol(this.colGroupFooter.parentElement, o, f - n);
92
+ if (this.colGroupFooter && this.colGroupFooter.children[o]) {
93
+ const f = parseInt(this.colGroupFooter.children[o].width, 10);
94
+ this.colGroupFooter.children[o].width = n + "px", this.updateNextLockedCol(this.colGroupFooter.parentElement, s, f - n);
95
95
  }
96
96
  }
97
97
  }, this.onResize = a;
@@ -101,18 +101,17 @@ class F {
101
101
  return a.width || "";
102
102
  const r = a.width.toString();
103
103
  if (r.includes("%")) {
104
- const s = parseFloat(r) * l, t = Math.max(0, Math.min(100, s));
105
- return a.width = t + "%", a.width;
106
- } else {
107
- let e = parseFloat(r) * l;
108
- const s = h.minResizableWidth === void 0 ? 10 : h.minResizableWidth, t = h == null ? void 0 : h.minWidth, i = t !== void 0 ? Math.max(s, t) : s, n = h == null ? void 0 : h.maxWidth;
109
- return e < i && (e = i), n !== void 0 && e > n && (e = n), a.width = e, e;
104
+ const f = parseFloat(r) * l, d = Math.max(0, Math.min(100, f));
105
+ return a.width = d + "%", a.width;
110
106
  }
107
+ let e = parseFloat(r) * l;
108
+ const o = h.minResizableWidth === void 0 ? 10 : h.minResizableWidth, t = h == null ? void 0 : h.minWidth, i = t !== void 0 ? Math.max(o, t) : o, n = h == null ? void 0 : h.maxWidth;
109
+ return e < i && (e = i), n !== void 0 && e > n && (e = n), a.width = e, e;
111
110
  }
112
111
  fixateInitialWidths(a) {
113
- var s;
112
+ var o;
114
113
  let h = 0;
115
- const l = ((s = this.colGroupMain) == null ? void 0 : s.children) || [];
114
+ const l = ((o = this.colGroupMain) == null ? void 0 : o.children) || [];
116
115
  for (let t = 0; t < l.length; t++)
117
116
  l[t].width ? a -= l[t].clientWidth : h++;
118
117
  if (h === 0)
@@ -121,8 +120,8 @@ class F {
121
120
  for (let t = 0; t < l.length; t++) {
122
121
  const i = l[t], n = i.width ? i.clientWidth : r;
123
122
  i.width = n;
124
- const o = c.find((f) => f.id === e[t].id);
125
- o && (o.width = n.toString()), this.colGroupHeader && (this.colGroupHeader.children[t].width = n), this.colGroupFooter && (this.colGroupFooter.children[t].width = n);
123
+ const s = c.find((f) => f.id === e[t].id);
124
+ s && (s.width = n.toString()), this.colGroupHeader && (this.colGroupHeader.children[t].width = n), this.colGroupFooter && (this.colGroupFooter.children[t].width = n);
126
125
  }
127
126
  }
128
127
  setWidths(a, h) {
@@ -133,20 +132,20 @@ class F {
133
132
  i.children.length ? e += i.children.filter((n) => !n.hidden).length : c.push(i), e--;
134
133
  }
135
134
  c.length === 0 && c.push(a);
136
- const s = [];
135
+ const o = [];
137
136
  c.forEach((t) => {
138
137
  const i = l.find((n) => n.id === t.id);
139
- i && (this.applyWidthConstraints(i, t, h), s.push(i));
140
- }), this.updateColElements(s);
138
+ i && (this.applyWidthConstraints(i, t, h), o.push(i));
139
+ }), this.updateColElements(o);
141
140
  }
142
141
  updateNextLockedCol(a, h, l) {
143
- const r = h.index, c = this.colGroupMain.parentElement.closest(".k-grid"), e = c == null ? void 0 : c.clientWidth, s = this.columns.filter((t) => t.locked).map((t) => parseInt(t.width + "", 10)).reduce((t, i) => t + i, 0);
144
- !h.locked || e <= s + W || this.columns.forEach((t) => {
142
+ const r = h.index, c = this.colGroupMain.parentElement.closest(".k-grid"), e = c == null ? void 0 : c.clientWidth, o = this.columns.filter((t) => t.locked).map((t) => parseInt(t.width + "", 10)).reduce((t, i) => t + i, 0);
143
+ !h.locked || e <= o + W || this.columns.forEach((t) => {
145
144
  if (t != null && t.locked && l) {
146
145
  const i = a == null ? void 0 : a.querySelectorAll('[aria-colindex="' + t.ariaColumnIndex + '"]');
147
146
  i == null || i.forEach((n) => {
148
- const o = n.style;
149
- this.isRtl ? (t.index > r && o && o.right && (o.right = parseInt(o.right, 10) - l + "px"), t.index < r && o && o.left && (o.left = parseInt(o.left, 10) - l + "px")) : (t.index > r && o && o.left && (o.left = parseInt(o.left, 10) - l + "px"), t.index < r && o && o.right && (o.right = parseInt(o.right, 10) - l + "px"));
147
+ const s = n.style;
148
+ this.isRtl ? (t.index > r && s && s.right && (s.right = parseInt(s.right, 10) - l + "px"), t.index < r && s && s.left && (s.left = parseInt(s.left, 10) - l + "px")) : (t.index > r && s && s.left && (s.left = parseInt(s.left, 10) - l + "px"), t.index < r && s && s.right && (s.right = parseInt(s.right, 10) - l + "px"));
150
149
  });
151
150
  }
152
151
  });
@@ -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 V=require("react"),_=require("./GridHeaderCell.js"),c=require("@progress/kendo-react-common"),$=require("@progress/kendo-react-data-tools"),S=require("../messages/index.js"),N=require("@progress/kendo-svg-icons"),d=require("../utils/index.js"),v=require("./client/GridHeaderCellContainer.js"),B=require("./client/HeaderRowDraggable.js"),F=require("./client/GridHeaderRowContainer.js"),J=require("./client/GridHeaderCellElementContainer.js"),K=require("./client/HeaderCellResizer.js");function Q(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(i,a,o.get?o:{enumerable:!0,get:()=>e[a]})}}return i.default=e,Object.freeze(i)}const t=Q(V),U={none:"none",asc:"ascending",desc:"descending"},X=e=>{let i=e.columnsState||[];const a=e.unstyled,o=a&&a.uGrid?a.uGrid:c.uGrid;let w=0,P=-1;const O=r=>{if(!e.sort)return null;const n=c.classNames(o.sortIcon({}));return r>=0&&[t.createElement("span",{key:1,className:n},t.createElement(c.IconWrap,{name:"sort-"+e.sort[r].dir+"-small",icon:e.sort[r].dir==="asc"?N.sortAscSmallIcon:N.sortDescSmallIcon})),e.sort.length>1&&t.createElement("span",{key:2,className:n},t.createElement("span",{className:c.classNames(o.sortOrder({}))},r+1))]},D=r=>r.map(n=>{var M,q,G;const l=e.columns[n],u=i[n],m=(q=(M=l.locked)!=null?M:u==null?void 0:u.locked)!=null?q:!1,h=e.sortable&&l.sortable,C=e.sort?e.sort.findIndex(s=>s.field===l.field):-1,T=C>=0&&e.sort[C].dir||"none",k=l.columnMenu===null?null:l.columnMenu||e.columnMenu,j=l.menuIcon||e.columnMenuIcon,A=c.classNames(c.classNames(o.headerTh({first:l.kFirst,filterable:!!k,locked:m,sorted:e.sort&&e.sort.some(s=>s.field===l.field)})),l.headerClassName);m===!1&&(l.left=0);const L=e.localization.toLanguageString(S.sortAriaLabel,S.messages[S.sortAriaLabel]),z=l.isAccessible?{ariaSort:U[T],role:"columnheader",ariaColumnIndex:l.ariaColumnIndex,ariaSelected:!1,ariaDescription:h?L:""}:{role:"presentation"},E=l.declarationIndex>=0?++P:--w,f={field:l.field,title:l.title,selectionValue:(G=l.headerSelectionValue)!=null?G:e.headerSelectionValue,children:O(C),selectionChange:null,columnMenuWrapperProps:{column:{field:l.field,title:l.title,locked:m,filter:l.filter,id:l.id},sortable:h&&e.sortable,sort:e.sort,filter:e.filter,filterable:e.filterable&&l.filterable,filterOperators:e.filterOperators,navigatable:e.navigatable,group:e.group,groupable:e.groupable,columnMenu:k,columnMenuIcon:j}},b={...z,colSpan:l.headerColSpan,rowSpan:l.rowSpan,className:A,columnId:l.id,navigatable:l.navigatable,role:"columnheader"},g=d.clientColumn(l),R={column:g,sortable:e.sortable,sort:e.sort,columnMenuWrapperProps:f.columnMenuWrapperProps},y=l.defaultHeaderCell?l.defaultHeaderCell:_.GridHeaderCell,I=[t.createElement(v.GridHeaderCellContainer,{key:1,...R,isClient:d.isClientReference(y)},t.createElement(y,{...f})),t.createElement(K.HeaderCellResizer,{key:2,column:g})],H=d.resolveCells(e.cells,l.cells);if(H&&H.headerCell){const s=H.headerCell,W=d.isClientReference(s);return t.createElement(v.GridHeaderCellContainer,{key:E,...R,thProps:b,isCustom:!0,isClient:W},t.createElement(s,{...f,thProps:b,index:n},I))}return t.createElement(J.GridHeaderCellElementContainer,{key:E,column:g},t.createElement($.HeaderThElement,{...b},I))}),x=e.columns.map(d.clientColumn);return t.createElement(F.GridHeaderRowContainer,{sortable:e.sortable,sort:e.sort,navigatable:e.navigatable,groupable:e.groupable,columns:x},e.columnsMap.map((r,n)=>t.createElement(B.HeaderRowDraggable,{key:n,className:c.classNames(o.simpleTr({})),ariaRowIndex:n+1},D(r))))};exports.HeaderRow=X;
8
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=require("react"),_=require("./GridHeaderCell.js"),c=require("@progress/kendo-react-common"),$=require("@progress/kendo-react-data-tools"),S=require("../messages/index.js"),N=require("@progress/kendo-svg-icons"),d=require("../utils/index.js"),v=require("./client/GridHeaderCellContainer.js"),B=require("./client/HeaderRowDraggable.js"),F=require("./client/GridHeaderRowContainer.js"),J=require("./client/GridHeaderCellElementContainer.js"),K=require("./client/HeaderCellResizer.js");function Q(e){const i=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const a in e)if(a!=="default"){const o=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(i,a,o.get?o:{enumerable:!0,get:()=>e[a]})}}return i.default=e,Object.freeze(i)}const l=Q(V),U={none:"none",asc:"ascending",desc:"descending"},X=e=>{const i=e.columnsState||[],a=e.unstyled,o=a&&a.uGrid?a.uGrid:c.uGrid;let w=0,P=-1;const O=r=>{if(!e.sort)return null;const n=c.classNames(o.sortIcon({}));return r>=0&&[l.createElement("span",{key:1,className:n},l.createElement(c.IconWrap,{name:"sort-"+e.sort[r].dir+"-small",icon:e.sort[r].dir==="asc"?N.sortAscSmallIcon:N.sortDescSmallIcon})),e.sort.length>1&&l.createElement("span",{key:2,className:n},l.createElement("span",{className:c.classNames(o.sortOrder({}))},r+1))]},D=r=>r.map(n=>{var M,q,G;const t=e.columns[n],u=i[n],m=(q=(M=t.locked)!=null?M:u==null?void 0:u.locked)!=null?q:!1,h=e.sortable&&t.sortable,C=e.sort?e.sort.findIndex(s=>s.field===t.field):-1,T=C>=0&&e.sort[C].dir||"none",k=t.columnMenu===null?null:t.columnMenu||e.columnMenu,j=t.menuIcon||e.columnMenuIcon,A=c.classNames(c.classNames(o.headerTh({first:t.kFirst,filterable:!!k,locked:m,sorted:e.sort&&e.sort.some(s=>s.field===t.field)})),t.headerClassName);m===!1&&(t.left=0);const L=e.localization.toLanguageString(S.sortAriaLabel,S.messages[S.sortAriaLabel]),z=t.isAccessible?{ariaSort:U[T],role:"columnheader",ariaColumnIndex:t.ariaColumnIndex,ariaSelected:!1,ariaDescription:h?L:""}:{role:"presentation"},E=t.declarationIndex>=0?++P:--w,f={field:t.field,title:t.title,selectionValue:(G=t.headerSelectionValue)!=null?G:e.headerSelectionValue,children:O(C),selectionChange:null,columnMenuWrapperProps:{column:{field:t.field,title:t.title,locked:m,filter:t.filter,id:t.id},sortable:h&&e.sortable,sort:e.sort,filter:e.filter,filterable:e.filterable&&t.filterable,filterOperators:e.filterOperators,navigatable:e.navigatable,group:e.group,groupable:e.groupable,columnMenu:k,columnMenuIcon:j}},b={...z,colSpan:t.headerColSpan,rowSpan:t.rowSpan,className:A,columnId:t.id,navigatable:t.navigatable,role:"columnheader"},g=d.clientColumn(t),R={column:g,sortable:e.sortable,sort:e.sort,columnMenuWrapperProps:f.columnMenuWrapperProps},y=t.defaultHeaderCell?t.defaultHeaderCell:_.GridHeaderCell,I=[l.createElement(v.GridHeaderCellContainer,{key:1,...R,isClient:d.isClientReference(y)},l.createElement(y,{...f})),l.createElement(K.HeaderCellResizer,{key:2,column:g})],H=d.resolveCells(e.cells,t.cells);if(H&&H.headerCell){const s=H.headerCell,W=d.isClientReference(s);return l.createElement(v.GridHeaderCellContainer,{key:E,...R,thProps:b,isCustom:!0,isClient:W},l.createElement(s,{...f,thProps:b,index:n},I))}return l.createElement(J.GridHeaderCellElementContainer,{key:E,column:g},l.createElement($.HeaderThElement,{...b},I))}),x=e.columns.map(d.clientColumn);return l.createElement(F.GridHeaderRowContainer,{sortable:e.sortable,sort:e.sort,navigatable:e.navigatable,groupable:e.groupable,columns:x},e.columnsMap.map((r,n)=>l.createElement(B.HeaderRowDraggable,{key:n,className:c.classNames(o.simpleTr({})),ariaRowIndex:n+1},D(r))))};exports.HeaderRow=X;
@@ -22,8 +22,7 @@ const p = {
22
22
  asc: "ascending",
23
23
  desc: "descending"
24
24
  }, de = (e) => {
25
- let R = e.columnsState || [];
26
- const s = e.unstyled, c = s && s.uGrid ? s.uGrid : j;
25
+ const R = e.columnsState || [], s = e.unstyled, c = s && s.uGrid ? s.uGrid : j;
27
26
  let w = 0, x = -1;
28
27
  const A = (a) => {
29
28
  if (!e.sort)
package/index.d.mts CHANGED
@@ -401,7 +401,7 @@ export declare interface GridAIAssistantCommand {
401
401
  /**
402
402
  * The highlight descriptor for highlight operations.
403
403
  */
404
- highlight?: any;
404
+ highlight?: CompositeHighlightDescriptor;
405
405
  /**
406
406
  * The select descriptor for selection operations.
407
407
  * Used when type is 'GridSelect' to define cell or row selection criteria.
@@ -654,6 +654,103 @@ export declare interface GridAIPromptProps {
654
654
  onClose?: () => void;
655
655
  }
656
656
 
657
+ /**
658
+ * Represents the result of processing an AI response.
659
+ * Contains the updated grid state and any messages to display.
660
+ */
661
+ export declare interface GridAIResponseResult {
662
+ /**
663
+ * The updated grid state after processing AI commands.
664
+ * Spread this into your Grid component props.
665
+ */
666
+ state: GridAIState;
667
+ /**
668
+ * Array of user-friendly messages describing what changes were made.
669
+ * Can be displayed to users as feedback.
670
+ */
671
+ messages: string[];
672
+ /**
673
+ * Indicates whether the AI triggered a PDF export.
674
+ * Handle this separately as it's an action, not state.
675
+ */
676
+ shouldExportPdf: boolean;
677
+ }
678
+
679
+ /**
680
+ * Represents the grid state that can be controlled externally.
681
+ * This interface contains all the stateful properties that can be modified through AI commands.
682
+ *
683
+ * @example
684
+ * ```tsx
685
+ * const [gridState, setGridState] = useState<GridAIState>({
686
+ * sort: [],
687
+ * filter: undefined,
688
+ * group: [],
689
+ * columnsState: initialColumns,
690
+ * skip: 0,
691
+ * take: 20
692
+ * });
693
+ * ```
694
+ */
695
+ export declare interface GridAIState {
696
+ /**
697
+ * The current sort descriptors applied to the grid.
698
+ * Array of sort objects defining field and direction.
699
+ */
700
+ sort?: SortDescriptor[];
701
+ /**
702
+ * The current filter descriptor applied to the grid.
703
+ * Composite filter defining logic and filter array.
704
+ */
705
+ filter?: CompositeFilterDescriptor;
706
+ /**
707
+ * The current group descriptors applied to the grid.
708
+ * Array of group objects defining field and aggregates.
709
+ */
710
+ group?: GroupDescriptor[];
711
+ /**
712
+ * The current column state including visibility, width, order, and lock status.
713
+ * Array of column state objects.
714
+ */
715
+ columnsState?: GridColumnState[];
716
+ /**
717
+ * The number of items to skip for pagination.
718
+ * Zero-based index for the first item to display.
719
+ */
720
+ skip?: number;
721
+ /**
722
+ * The number of items to take (page size) for pagination.
723
+ * Number of items to display per page.
724
+ */
725
+ take?: number;
726
+ /**
727
+ * The highlight descriptor for highlighting cells/rows in the grid.
728
+ * Object with dataItemKey as keys, values can be boolean (whole row) or number array (specific cells).
729
+ *
730
+ * @example
731
+ * ```tsx
732
+ * highlight: {
733
+ * '1': true, // Highlight entire row with dataItemKey = 1
734
+ * '2': [0, 1, 2] // Highlight cells at column indices 0, 1, 2 in row with dataItemKey = 2
735
+ * }
736
+ * ```
737
+ */
738
+ highlight?: any;
739
+ /**
740
+ * The select descriptor for selecting cells/rows in the grid.
741
+ * Object with dataItemKey as keys, values can be boolean (whole row) or number array (specific cells).
742
+ *
743
+ * @example
744
+ * ```tsx
745
+ * select: {
746
+ * '1': true, // Select entire row with dataItemKey = 1
747
+ * '2': [0, 1] // Select cells at column indices 0 and 1 in row with dataItemKey = 2
748
+ * }
749
+ * ```
750
+ */
751
+ select?: any;
752
+ }
753
+
657
754
  /**
658
755
  * @hidden
659
756
  */
@@ -2595,6 +2692,35 @@ export declare interface GridHandle {
2595
2692
  * The 'pdf' prop of the Grid should be set to true or object of setting that will be applied the exported Grid.
2596
2693
  */
2597
2694
  exportAsPdf: () => void;
2695
+ /**
2696
+ * Gets the total number of items in the grid data source.
2697
+ * Used for pagination calculations and AI operations.
2698
+ *
2699
+ * @returns The total count of data items
2700
+ *
2701
+ * @example
2702
+ * ```jsx
2703
+ * const grid = useRef<GridHandle>(null);
2704
+ * const total = grid.current?.getTotal();
2705
+ * console.log(`Total items: ${total}`);
2706
+ * ```
2707
+ */
2708
+ getTotal: () => number;
2709
+ /**
2710
+ * Gets all leaf-level data items in the grid.
2711
+ * Returns actual data rows excluding group headers/footers.
2712
+ * Useful for AI operations and data processing.
2713
+ *
2714
+ * @returns Array of data items
2715
+ *
2716
+ * @example
2717
+ * ```jsx
2718
+ * const grid = useRef<GridHandle>(null);
2719
+ * const dataItems = grid.current?.getLeafDataItems();
2720
+ * console.log(`Leaf items: ${dataItems.length}`);
2721
+ * ```
2722
+ */
2723
+ getLeafDataItems: () => any[];
2598
2724
  }
2599
2725
 
2600
2726
  /**
@@ -4833,6 +4959,62 @@ export declare const GridToolbarSpacer: {
4833
4959
  export declare interface GridToolbarSpacerProps extends ToolbarSpacerProps {
4834
4960
  }
4835
4961
 
4962
+ /**
4963
+ * Processes an AI response and returns the updated grid state.
4964
+ * This is a pure function that takes the current state and AI response,
4965
+ * and returns a new state object with all the changes applied.
4966
+ *
4967
+ * @param response - The axios response from the AI service containing commands
4968
+ * @param currentState - The current grid state
4969
+ * @param gridRef - Reference to grid methods (getTotal, getLeafDataItems, exportAsPdf)
4970
+ * @returns Object containing the new state, messages, and export flag
4971
+ *
4972
+ * @example
4973
+ * ```tsx
4974
+ * const App = () => {
4975
+ * const [gridState, setGridState] = useState<GridAIState>({
4976
+ * sort: [],
4977
+ * filter: undefined,
4978
+ * group: [],
4979
+ * columnsState: initialColumns,
4980
+ * skip: 0,
4981
+ * take: 20
4982
+ * });
4983
+ * const gridRef = useRef<GridHandle>(null);
4984
+ *
4985
+ * const handleAIRequest = async (prompt: string) => {
4986
+ * const response = await axios.post('/api/ai/grid', { prompt, columns: gridState.columnsState });
4987
+ * const result = handleAIResponse(response, gridState, gridRef.current);
4988
+ *
4989
+ * // Update state with AI changes
4990
+ * setGridState(result.state);
4991
+ *
4992
+ * // Handle PDF export if requested
4993
+ * if (result.shouldExportPdf && gridRef.current) {
4994
+ * gridRef.current.exportAsPdf();
4995
+ * }
4996
+ *
4997
+ * // Show messages to user
4998
+ * console.log(result.messages);
4999
+ * };
5000
+ *
5001
+ * return (
5002
+ * <Grid
5003
+ * ref={gridRef}
5004
+ * data={data}
5005
+ * {...gridState}
5006
+ * onSortChange={(e) => setGridState(prev => ({ ...prev, sort: e.sort }))}
5007
+ * onFilterChange={(e) => setGridState(prev => ({ ...prev, filter: e.filter }))}
5008
+ * onGroupChange={(e) => setGridState(prev => ({ ...prev, group: e.group }))}
5009
+ * onColumnsStateChange={(e) => setGridState(prev => ({ ...prev, columnsState: e.columnsState }))}
5010
+ * onPageChange={(e) => setGridState(prev => ({ ...prev, skip: e.page.skip, take: e.page.take }))}
5011
+ * />
5012
+ * );
5013
+ * };
5014
+ * ```
5015
+ */
5016
+ export declare function handleAIResponse(response: AxiosResponse<any>, currentState: GridAIState, gridRef: Pick<GridHandle, 'getLeafDataItems' | 'getTotal' | 'exportAsPdf' | 'props'> | null): GridAIResponseResult;
5017
+
4836
5018
  /**
4837
5019
  * @hidden
4838
5020
  */
package/index.d.ts CHANGED
@@ -401,7 +401,7 @@ export declare interface GridAIAssistantCommand {
401
401
  /**
402
402
  * The highlight descriptor for highlight operations.
403
403
  */
404
- highlight?: any;
404
+ highlight?: CompositeHighlightDescriptor;
405
405
  /**
406
406
  * The select descriptor for selection operations.
407
407
  * Used when type is 'GridSelect' to define cell or row selection criteria.
@@ -654,6 +654,103 @@ export declare interface GridAIPromptProps {
654
654
  onClose?: () => void;
655
655
  }
656
656
 
657
+ /**
658
+ * Represents the result of processing an AI response.
659
+ * Contains the updated grid state and any messages to display.
660
+ */
661
+ export declare interface GridAIResponseResult {
662
+ /**
663
+ * The updated grid state after processing AI commands.
664
+ * Spread this into your Grid component props.
665
+ */
666
+ state: GridAIState;
667
+ /**
668
+ * Array of user-friendly messages describing what changes were made.
669
+ * Can be displayed to users as feedback.
670
+ */
671
+ messages: string[];
672
+ /**
673
+ * Indicates whether the AI triggered a PDF export.
674
+ * Handle this separately as it's an action, not state.
675
+ */
676
+ shouldExportPdf: boolean;
677
+ }
678
+
679
+ /**
680
+ * Represents the grid state that can be controlled externally.
681
+ * This interface contains all the stateful properties that can be modified through AI commands.
682
+ *
683
+ * @example
684
+ * ```tsx
685
+ * const [gridState, setGridState] = useState<GridAIState>({
686
+ * sort: [],
687
+ * filter: undefined,
688
+ * group: [],
689
+ * columnsState: initialColumns,
690
+ * skip: 0,
691
+ * take: 20
692
+ * });
693
+ * ```
694
+ */
695
+ export declare interface GridAIState {
696
+ /**
697
+ * The current sort descriptors applied to the grid.
698
+ * Array of sort objects defining field and direction.
699
+ */
700
+ sort?: SortDescriptor[];
701
+ /**
702
+ * The current filter descriptor applied to the grid.
703
+ * Composite filter defining logic and filter array.
704
+ */
705
+ filter?: CompositeFilterDescriptor;
706
+ /**
707
+ * The current group descriptors applied to the grid.
708
+ * Array of group objects defining field and aggregates.
709
+ */
710
+ group?: GroupDescriptor[];
711
+ /**
712
+ * The current column state including visibility, width, order, and lock status.
713
+ * Array of column state objects.
714
+ */
715
+ columnsState?: GridColumnState[];
716
+ /**
717
+ * The number of items to skip for pagination.
718
+ * Zero-based index for the first item to display.
719
+ */
720
+ skip?: number;
721
+ /**
722
+ * The number of items to take (page size) for pagination.
723
+ * Number of items to display per page.
724
+ */
725
+ take?: number;
726
+ /**
727
+ * The highlight descriptor for highlighting cells/rows in the grid.
728
+ * Object with dataItemKey as keys, values can be boolean (whole row) or number array (specific cells).
729
+ *
730
+ * @example
731
+ * ```tsx
732
+ * highlight: {
733
+ * '1': true, // Highlight entire row with dataItemKey = 1
734
+ * '2': [0, 1, 2] // Highlight cells at column indices 0, 1, 2 in row with dataItemKey = 2
735
+ * }
736
+ * ```
737
+ */
738
+ highlight?: any;
739
+ /**
740
+ * The select descriptor for selecting cells/rows in the grid.
741
+ * Object with dataItemKey as keys, values can be boolean (whole row) or number array (specific cells).
742
+ *
743
+ * @example
744
+ * ```tsx
745
+ * select: {
746
+ * '1': true, // Select entire row with dataItemKey = 1
747
+ * '2': [0, 1] // Select cells at column indices 0 and 1 in row with dataItemKey = 2
748
+ * }
749
+ * ```
750
+ */
751
+ select?: any;
752
+ }
753
+
657
754
  /**
658
755
  * @hidden
659
756
  */
@@ -2595,6 +2692,35 @@ export declare interface GridHandle {
2595
2692
  * The 'pdf' prop of the Grid should be set to true or object of setting that will be applied the exported Grid.
2596
2693
  */
2597
2694
  exportAsPdf: () => void;
2695
+ /**
2696
+ * Gets the total number of items in the grid data source.
2697
+ * Used for pagination calculations and AI operations.
2698
+ *
2699
+ * @returns The total count of data items
2700
+ *
2701
+ * @example
2702
+ * ```jsx
2703
+ * const grid = useRef<GridHandle>(null);
2704
+ * const total = grid.current?.getTotal();
2705
+ * console.log(`Total items: ${total}`);
2706
+ * ```
2707
+ */
2708
+ getTotal: () => number;
2709
+ /**
2710
+ * Gets all leaf-level data items in the grid.
2711
+ * Returns actual data rows excluding group headers/footers.
2712
+ * Useful for AI operations and data processing.
2713
+ *
2714
+ * @returns Array of data items
2715
+ *
2716
+ * @example
2717
+ * ```jsx
2718
+ * const grid = useRef<GridHandle>(null);
2719
+ * const dataItems = grid.current?.getLeafDataItems();
2720
+ * console.log(`Leaf items: ${dataItems.length}`);
2721
+ * ```
2722
+ */
2723
+ getLeafDataItems: () => any[];
2598
2724
  }
2599
2725
 
2600
2726
  /**
@@ -4833,6 +4959,62 @@ export declare const GridToolbarSpacer: {
4833
4959
  export declare interface GridToolbarSpacerProps extends ToolbarSpacerProps {
4834
4960
  }
4835
4961
 
4962
+ /**
4963
+ * Processes an AI response and returns the updated grid state.
4964
+ * This is a pure function that takes the current state and AI response,
4965
+ * and returns a new state object with all the changes applied.
4966
+ *
4967
+ * @param response - The axios response from the AI service containing commands
4968
+ * @param currentState - The current grid state
4969
+ * @param gridRef - Reference to grid methods (getTotal, getLeafDataItems, exportAsPdf)
4970
+ * @returns Object containing the new state, messages, and export flag
4971
+ *
4972
+ * @example
4973
+ * ```tsx
4974
+ * const App = () => {
4975
+ * const [gridState, setGridState] = useState<GridAIState>({
4976
+ * sort: [],
4977
+ * filter: undefined,
4978
+ * group: [],
4979
+ * columnsState: initialColumns,
4980
+ * skip: 0,
4981
+ * take: 20
4982
+ * });
4983
+ * const gridRef = useRef<GridHandle>(null);
4984
+ *
4985
+ * const handleAIRequest = async (prompt: string) => {
4986
+ * const response = await axios.post('/api/ai/grid', { prompt, columns: gridState.columnsState });
4987
+ * const result = handleAIResponse(response, gridState, gridRef.current);
4988
+ *
4989
+ * // Update state with AI changes
4990
+ * setGridState(result.state);
4991
+ *
4992
+ * // Handle PDF export if requested
4993
+ * if (result.shouldExportPdf && gridRef.current) {
4994
+ * gridRef.current.exportAsPdf();
4995
+ * }
4996
+ *
4997
+ * // Show messages to user
4998
+ * console.log(result.messages);
4999
+ * };
5000
+ *
5001
+ * return (
5002
+ * <Grid
5003
+ * ref={gridRef}
5004
+ * data={data}
5005
+ * {...gridState}
5006
+ * onSortChange={(e) => setGridState(prev => ({ ...prev, sort: e.sort }))}
5007
+ * onFilterChange={(e) => setGridState(prev => ({ ...prev, filter: e.filter }))}
5008
+ * onGroupChange={(e) => setGridState(prev => ({ ...prev, group: e.group }))}
5009
+ * onColumnsStateChange={(e) => setGridState(prev => ({ ...prev, columnsState: e.columnsState }))}
5010
+ * onPageChange={(e) => setGridState(prev => ({ ...prev, skip: e.page.skip, take: e.page.take }))}
5011
+ * />
5012
+ * );
5013
+ * };
5014
+ * ```
5015
+ */
5016
+ export declare function handleAIResponse(response: AxiosResponse<any>, currentState: GridAIState, gridRef: Pick<GridHandle, 'getLeafDataItems' | 'getTotal' | 'exportAsPdf' | 'props'> | null): GridAIResponseResult;
5017
+
4836
5018
  /**
4837
5019
  * @hidden
4838
5020
  */