@progress/kendo-react-grid 13.1.1-develop.1 → 13.2.0-develop.1

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,70 +5,70 @@
5
5
  * Licensed under commercial license. See LICENSE.md in the package root for more information
6
6
  *-------------------------------------------------------------------------------------------
7
7
  */
8
- import * as a from "react";
9
- import { GridContext as Se } from "../utils/GridContext.mjs";
10
- import { Button as Ge } from "@progress/kendo-react-buttons";
11
- import { sparklesIcon as be } from "@progress/kendo-svg-icons";
8
+ import * as l from "react";
9
+ import { GridContext as be } from "../utils/GridContext.mjs";
10
+ import { Button as Pe } from "@progress/kendo-react-buttons";
11
+ import { sparklesIcon as Re } from "@progress/kendo-svg-icons";
12
12
  import W from "axios";
13
- import { useLocalization as ke } from "@progress/kendo-react-intl";
14
- import { toolbarAI as S, messages as G, aIResponseData as B, generatedWithAI as M } from "../messages/index.mjs";
15
- import { useCustomComponent as Re, classNames as we } from "@progress/kendo-react-common";
16
- import { Window as xe } from "@progress/kendo-react-dialogs";
17
- import { GridAIPrompt as ye } from "./ai-tool/GridAIPrompt.mjs";
18
- import { combineSmartFilters as Te } from "../filterCommon.mjs";
19
- const j = 768;
20
- var Pe = /* @__PURE__ */ ((i) => (i.GridClearFilter = "GridClearFilter", i.GridClearSort = "GridClearSort", i.GridClearGroup = "GridClearGroup", i.GridClearHighlight = "GridClearHighlight", i.GridClearSelect = "GridClearSelect", i.GridSort = "GridSort", i.GridFilter = "GridFilter", i.GridGroup = "GridGroup", i.GridHighlight = "GridHighlight", i.GridSelect = "GridSelect", i.GridExportPDF = "GridExportPDF", i.GridColumnResize = "GridColumnResize", i.GridColumnHide = "GridColumnHide", i.GridColumnShow = "GridColumnShow", i.GridColumnReorder = "GridColumnReorder", i.GridColumnLock = "GridColumnLock", i.GridColumnUnlock = "GridColumnUnlock", i))(Pe || {});
21
- const ve = (i, b) => i.map((d) => {
22
- let p = d;
23
- return b.forEach((c) => {
24
- c.field && p.includes(c.field) && (p = p.replace(new RegExp(c.field, "g"), c.title || c.field));
25
- }), p;
26
- }), Fe = () => null, Le = a.forwardRef(
27
- (i, b) => {
28
- const t = a.useContext(Se), d = ke(), {
29
- requestUrl: p,
30
- requestOptions: c,
13
+ import { useLocalization as we } from "@progress/kendo-react-intl";
14
+ import { toolbarAI as k, messages as m, aIResponseData as B, generatedWithAI as j } from "../messages/index.mjs";
15
+ import { useCustomComponent as xe, classNames as ye } from "@progress/kendo-react-common";
16
+ import { Window as Te } from "@progress/kendo-react-dialogs";
17
+ import { GridAIPrompt as ve } from "./ai-tool/GridAIPrompt.mjs";
18
+ import { combineSmartFilters as ze } from "../filterCommon.mjs";
19
+ const I = 768;
20
+ var Ee = /* @__PURE__ */ ((a) => (a.GridClearFilter = "GridClearFilter", a.GridClearSort = "GridClearSort", a.GridClearGroup = "GridClearGroup", a.GridClearHighlight = "GridClearHighlight", a.GridClearSelect = "GridClearSelect", a.GridSort = "GridSort", a.GridFilter = "GridFilter", a.GridGroup = "GridGroup", a.GridHighlight = "GridHighlight", a.GridSelect = "GridSelect", a.GridExportPDF = "GridExportPDF", a.GridColumnResize = "GridColumnResize", a.GridColumnHide = "GridColumnHide", a.GridColumnShow = "GridColumnShow", a.GridColumnReorder = "GridColumnReorder", a.GridColumnLock = "GridColumnLock", a.GridColumnUnlock = "GridColumnUnlock", a.GridPage = "GridPage", a.GridPageSize = "GridPageSize", a))(Ee || {});
21
+ const Le = (a, b) => a.map((p) => {
22
+ let g = p;
23
+ return b.forEach((d) => {
24
+ d.field && g.includes(d.field) && (g = g.replace(new RegExp(d.field, "g"), d.title || d.field));
25
+ }), g;
26
+ }), Fe = () => null, Me = l.forwardRef(
27
+ (a, b) => {
28
+ const t = l.useContext(be), p = we(), {
29
+ requestUrl: g,
30
+ requestOptions: d,
31
31
  onPromptRequest: v,
32
- onResponseSuccess: F,
33
- onResponseError: k,
34
- role: A = "user",
35
- gridAIPrompt: I = ye,
36
- icon: L,
37
- svgIcon: N,
32
+ onResponseSuccess: z,
33
+ onResponseError: P,
34
+ role: N = "user",
35
+ gridAIPrompt: A = ve,
36
+ icon: E,
37
+ svgIcon: U,
38
38
  onCloseWindow: R,
39
- promptPlaceHolder: U,
40
- suggestionsList: K,
41
- streaming: V,
42
- loading: X,
43
- outputs: Y,
44
- enableSpeechToText: _
45
- } = i, [w, E] = a.useState([]), $ = a.useMemo(() => t && Array.isArray(t.columnsRef) && Array.isArray(t.hiddenColumnsRef) ? [...t.columnsRef, ...t.hiddenColumnsRef].map((e) => {
39
+ promptPlaceHolder: K,
40
+ suggestionsList: V,
41
+ streaming: X,
42
+ loading: Y,
43
+ outputs: _,
44
+ enableSpeechToText: $
45
+ } = a, [w, L] = l.useState([]), J = l.useMemo(() => t && Array.isArray(t.columnsRef) && Array.isArray(t.hiddenColumnsRef) ? [...t.columnsRef, ...t.hiddenColumnsRef].map((e) => {
46
46
  var r;
47
47
  return {
48
48
  id: e.id,
49
49
  field: e.field,
50
50
  values: (r = e.values) != null ? r : []
51
51
  };
52
- }) : [], [t]), [J, g] = a.useState(!1), [Q, h] = a.useState(!1), [x, y] = a.useState(!1), [Z, q] = a.useState(), [ee, te] = a.useState(), [H, re] = a.useState(() => {
52
+ }) : [], [t]), [Q, h] = l.useState(!1), [Z, C] = l.useState(!1), [x, y] = l.useState(!1), [q, ee] = l.useState(), [te, re] = l.useState(), [F, oe] = l.useState(() => {
53
53
  const e = window.innerWidth;
54
- return e < j ? e * 0.8 : 560;
55
- }), f = a.useRef(null), T = a.useRef(null), oe = (e) => {
54
+ return e < I ? e * 0.8 : 560;
55
+ }), f = l.useRef(null), T = l.useRef(null), ne = (e) => {
56
56
  e.preventDefault(), y(!x);
57
- }, C = a.useMemo(() => {
57
+ }, S = l.useMemo(() => {
58
58
  var e;
59
- return (e = i.show) != null ? e : x;
60
- }, [i.show, x]), m = a.useCallback(() => {
59
+ return (e = a.show) != null ? e : x;
60
+ }, [a.show, x]), G = l.useCallback(() => {
61
61
  var e;
62
- R && R(), E([]), y(!1), f.current && ((e = f.current.element) == null || e.focus());
63
- }, [R]), ne = (e, r) => {
64
- var n;
62
+ R && R(), L([]), y(!1), f.current && ((e = f.current.element) == null || e.focus());
63
+ }, [R]), ie = (e, r) => {
64
+ var i;
65
65
  if (t.sortable && e) {
66
66
  const o = Array.isArray(e) ? e : [e];
67
67
  if (o.length === 0)
68
68
  t.sortChange([], r);
69
69
  else {
70
- const u = ((n = t.sort) != null ? n : []).filter(
71
- (s) => !o.some((P) => P.field === s.field)
70
+ const u = ((i = t.sort) != null ? i : []).filter(
71
+ (n) => !o.some((c) => c.field === n.field)
72
72
  );
73
73
  u.push(...o), t.sortChange(u, r);
74
74
  }
@@ -76,66 +76,66 @@ const ve = (i, b) => i.map((d) => {
76
76
  }, se = (e, r) => {
77
77
  if (!e)
78
78
  return;
79
- const n = Te(
79
+ const i = ze(
80
80
  {
81
81
  logic: e.logic ? e.logic : "and",
82
82
  filters: e.filters
83
83
  },
84
84
  t.filter
85
85
  );
86
- t.filterChange(n, r);
87
- }, ie = (e, r) => {
86
+ t.filterChange(i, r);
87
+ }, ae = (e, r) => {
88
88
  var o;
89
89
  if (!e)
90
90
  return;
91
- const n = Array.isArray(e) ? e : [e];
92
- if (n.length === 0)
91
+ const i = Array.isArray(e) ? e : [e];
92
+ if (i.length === 0)
93
93
  t.groupChange([], r);
94
94
  else {
95
95
  const u = ((o = t.group) != null ? o : []).filter(
96
- (s) => !n.some((P) => P.field === s.field)
96
+ (n) => !i.some((c) => c.field === n.field)
97
97
  );
98
- u.push(...n), t.groupChange(u, r);
98
+ u.push(...i), t.groupChange(u, r);
99
99
  }
100
- }, le = (e, r, n) => {
101
- const o = [d.toLanguageString(B, G[B])], l = ve([e], t.columnsRef).join(`
100
+ }, le = (e, r, i) => {
101
+ const o = [p.toLanguageString(B, m[B])], s = Le([e], t.columnsRef).join(`
102
102
  `);
103
- E([
103
+ L([
104
104
  {
105
105
  id: w.length + 1,
106
- title: d.toLanguageString(M, G[M]),
106
+ title: p.toLanguageString(j, m[j]),
107
107
  subTitle: r,
108
108
  prompt: r,
109
- responseContent: o.concat(l).join(""),
110
- isRetry: n
109
+ responseContent: o.concat(s).join(""),
110
+ isRetry: i
111
111
  },
112
112
  ...w
113
113
  ]);
114
- }, ae = (e, r, n) => {
115
- const o = t.columnsRef.findIndex((l) => l.id === e);
116
- t.reorderable && t.columnReorder(o, r, n);
117
- }, z = (e, r) => {
118
- const n = t.columnsState.findIndex((l) => l.id === e), o = t.columnsState.map(
119
- (l) => l.id === e ? { ...l, hidden: r } : l
114
+ }, ue = (e, r, i) => {
115
+ const o = t.columnsRef.findIndex((s) => s.id === e);
116
+ t.reorderable && t.columnReorder(o, r, i);
117
+ }, M = (e, r) => {
118
+ const i = t.columnsState.findIndex((s) => s.id === e), o = t.columnsState.map(
119
+ (s) => s.id === e ? { ...s, hidden: r } : s
120
120
  );
121
- n !== -1 && t.onColumnsStateChange(o);
122
- }, D = (e, r) => {
123
- const n = t.columnsRef.findIndex((l) => l.id === e), o = t.columnsState.map(
124
- (l) => l.id === e ? { ...l, locked: r } : l
121
+ i !== -1 && t.onColumnsStateChange(o);
122
+ }, H = (e, r) => {
123
+ const i = t.columnsRef.findIndex((s) => s.id === e), o = t.columnsState.map(
124
+ (s) => s.id === e ? { ...s, locked: r } : s
125
125
  );
126
- n !== -1 && t.onColumnsStateChange(o);
127
- }, ue = (e, r, n) => {
128
- const o = t.columnsRef.findIndex((s) => s.id === e), l = t.columnsState[o], u = t.columnsState.map(
129
- (s) => s.id === e ? { ...s, width: parseFloat(r) } : s
126
+ i !== -1 && t.onColumnsStateChange(o);
127
+ }, ce = (e, r, i) => {
128
+ const o = t.columnsRef.findIndex((n) => n.id === e), s = t.columnsState[o], u = t.columnsState.map(
129
+ (n) => n.id === e ? { ...n, width: parseFloat(r) } : n
130
130
  );
131
131
  o !== -1 && t.onResize(
132
132
  o,
133
133
  // index: number
134
134
  parseFloat(r),
135
135
  // newWidth: 200
136
- parseFloat(l.width) || 0,
136
+ parseFloat(s.width) || 0,
137
137
  // oldWidth: current width
138
- n,
138
+ i,
139
139
  // nativeEvent: mock event
140
140
  !0,
141
141
  // end: true (resize is complete)
@@ -144,21 +144,42 @@ const ve = (i, b) => i.map((d) => {
144
144
  e
145
145
  // targetId: column ID
146
146
  );
147
- }, ce = (e, r, n) => {
148
- var o, l, u;
149
- g(!1), h(!1), (o = e == null ? void 0 : e.data) == null || o.commands.forEach((s) => {
150
- switch (s.type) {
147
+ }, de = (e, r) => {
148
+ var c, O;
149
+ if (!t.pageable)
150
+ return;
151
+ const i = t.getLeafDataItems().length, o = Math.max(1, Math.floor(e)), s = t.getTotal(), u = Math.floor((O = (c = t.take) != null ? c : t.pageSize) != null ? O : i), n = Math.floor((o - 1) * u);
152
+ n < s && t.pagerPageChange({
153
+ skip: n,
154
+ take: u,
155
+ syntheticEvent: r
156
+ });
157
+ }, pe = (e, r) => {
158
+ var c;
159
+ if (!t.pageable)
160
+ return;
161
+ const i = Math.max(1, Math.floor(e)), o = t.skip || 0, s = (c = t.take) != null ? c : 0, u = Math.floor(o / s);
162
+ let n = 0;
163
+ s > 0 && (n = Math.max(0, u * i)), t.pagerPageChange({
164
+ skip: n,
165
+ take: i,
166
+ syntheticEvent: r
167
+ });
168
+ }, ge = (e, r, i) => {
169
+ var o, s, u;
170
+ h(!1), C(!1), (o = e == null ? void 0 : e.data) == null || o.commands.forEach((n) => {
171
+ switch (n.type) {
151
172
  case "GridSort":
152
- ne(s.sort, e);
173
+ ie(n.sort, e);
153
174
  break;
154
175
  case "GridFilter":
155
- se(s.filter, e);
176
+ se(n.filter, e);
156
177
  break;
157
178
  case "GridHighlight":
158
- t.applyHighlightDescriptor([s.highlight]);
179
+ t.applyHighlightDescriptor([n.highlight]);
159
180
  break;
160
181
  case "GridGroup":
161
- ie(s.group, e);
182
+ ae(n.group, e);
162
183
  break;
163
184
  case "GridClearFilter":
164
185
  t.filterChange(void 0);
@@ -173,7 +194,7 @@ const ve = (i, b) => i.map((d) => {
173
194
  t.sortChange(void 0);
174
195
  break;
175
196
  case "GridSelect":
176
- t.applySelectionDescriptor([s.select]);
197
+ t.applySelectionDescriptor([n.select]);
177
198
  break;
178
199
  case "GridClearSelect":
179
200
  t.applySelectionDescriptor([]);
@@ -182,49 +203,55 @@ const ve = (i, b) => i.map((d) => {
182
203
  t.exportAsPdf();
183
204
  break;
184
205
  case "GridColumnResize":
185
- ue(s.id, s.size, e);
206
+ ce(n.id, n.size, e);
186
207
  break;
187
208
  case "GridColumnHide":
188
- z(s.id, !0);
209
+ M(n.id, !0);
189
210
  break;
190
211
  case "GridColumnShow":
191
- z(s.id, !1);
212
+ M(n.id, !1);
192
213
  break;
193
214
  case "GridColumnReorder":
194
- ae(s.id, s.position, e);
215
+ ue(n.id, n.position, e);
195
216
  break;
196
217
  case "GridColumnLock":
197
- D(s.id, !0);
218
+ H(n.id, !0);
198
219
  break;
199
220
  case "GridColumnUnlock":
200
- D(s.id, !1);
221
+ H(n.id, !1);
222
+ break;
223
+ case "GridPage":
224
+ de(n.page, e);
225
+ break;
226
+ case "GridPageSize":
227
+ pe(n.pageSize, e);
201
228
  break;
202
229
  }
203
- }), (u = (l = e == null ? void 0 : e.data) == null ? void 0 : l.commands) != null && u.length || le(e.data.message, r, n), F && F(e, r, n);
204
- }, de = (e) => {
205
- k == null || k(e), g(!1), h(!1);
206
- }, pe = (e, r) => {
207
- const n = W.CancelToken.source(), o = {
208
- role: A || "user",
209
- columns: $ || [],
230
+ }), (u = (s = e == null ? void 0 : e.data) == null ? void 0 : s.commands) != null && u.length || le(e.data.message, r, i), z && z(e, r, i);
231
+ }, fe = (e) => {
232
+ P == null || P(e), h(!1), C(!1);
233
+ }, he = (e, r) => {
234
+ const i = W.CancelToken.source(), o = {
235
+ role: N || "user",
236
+ columns: J || [],
210
237
  headers: {
211
238
  Accept: "*/*",
212
239
  "Content-Type": "application/json"
213
240
  },
214
241
  promptMessage: e,
215
242
  requestOptions: {
216
- url: p,
243
+ url: g,
217
244
  method: "POST",
218
245
  withCredentials: !1,
219
246
  responseType: "json",
220
- cancelToken: n.token,
221
- ...c
247
+ cancelToken: i.token,
248
+ ...d
222
249
  }
223
250
  };
224
251
  if (v && v(o, r), o.requestOptions.url !== void 0) {
225
- g(!0), h(!0);
226
- const { url: l, ...u } = o.requestOptions;
227
- W(l, {
252
+ h(!0), C(!0);
253
+ const { url: s, ...u } = o.requestOptions;
254
+ W(s, {
228
255
  ...u,
229
256
  headers: o.headers,
230
257
  data: {
@@ -233,85 +260,85 @@ const ve = (i, b) => i.map((d) => {
233
260
  },
234
261
  responseType: "json"
235
262
  // Ensure correct type
236
- }).then((s) => ce(s, o.promptMessage, r)).catch(de), T.current = n;
263
+ }).then((n) => ge(n, o.promptMessage, r)).catch(fe), T.current = i;
237
264
  }
238
- }, fe = a.useCallback(() => {
239
- T.current && T.current.cancel("Request cancelled by user."), g(!1), h(!1);
240
- }, []), [ge, O] = Re(
241
- I
242
- ), he = Object.keys(O).length > 0 ? O : {}, Ce = /* @__PURE__ */ a.createElement(
243
- ge,
265
+ }, Ce = l.useCallback(() => {
266
+ T.current && T.current.cancel("Request cancelled by user."), h(!1), C(!1);
267
+ }, []), [Se, D] = xe(
268
+ A
269
+ ), Ge = Object.keys(D).length > 0 ? D : {}, ke = /* @__PURE__ */ l.createElement(
270
+ Se,
244
271
  {
245
- onPromptRequest: pe,
246
- onCancel: fe,
247
- onClose: m,
248
- streaming: V || J,
249
- loading: X || Q,
250
- outputs: Y || w,
251
- promptPlaceHolder: U,
252
- suggestionsList: K,
253
- enableSpeechToText: _,
254
- ...he
272
+ onPromptRequest: he,
273
+ onCancel: Ce,
274
+ onClose: G,
275
+ streaming: X || Q,
276
+ loading: Y || Z,
277
+ outputs: _ || w,
278
+ promptPlaceHolder: K,
279
+ suggestionsList: V,
280
+ enableSpeechToText: $,
281
+ ...Ge
255
282
  }
256
- ), me = /* @__PURE__ */ a.createElement(
257
- Ge,
283
+ ), me = /* @__PURE__ */ l.createElement(
284
+ Pe,
258
285
  {
259
286
  ref: f,
260
287
  togglable: !0,
261
288
  themeColor: "primary",
262
289
  rounded: "full",
263
- selected: C,
264
- svgIcon: N || (L ? void 0 : be),
265
- icon: L,
290
+ selected: S,
291
+ svgIcon: U || (E ? void 0 : Re),
292
+ icon: E,
266
293
  size: t.mobileMode ? "large" : "medium",
267
- className: we("k-toolbar-button", { "k-icon-button": t.mobileMode }),
268
- title: d.toLanguageString(S, G[S]),
269
- onClick: oe
294
+ className: ye("k-toolbar-button", { "k-icon-button": t.mobileMode }),
295
+ title: p.toLanguageString(k, m[k]),
296
+ onClick: ne
270
297
  }
271
298
  );
272
- return a.useEffect(() => {
299
+ return l.useEffect(() => {
273
300
  var e;
274
- if (f.current && C) {
301
+ if (f.current && S) {
275
302
  const r = (e = f.current.element) == null ? void 0 : e.getBoundingClientRect();
276
303
  if (r) {
277
- q(r.top + window.scrollY + r.height), te(r.left + window.scrollX + r.width);
278
- const n = window.innerWidth, o = n < j ? n * 0.75 : 560;
279
- re(o);
304
+ ee(r.top + window.scrollY + r.height), re(r.left + window.scrollX + r.width);
305
+ const i = window.innerWidth, o = i < I ? i * 0.75 : 560;
306
+ oe(o);
280
307
  }
281
308
  }
282
- }, [C]), a.useImperativeHandle(
309
+ }, [S]), l.useImperativeHandle(
283
310
  b,
284
311
  () => ({
285
312
  show: () => y(!0),
286
- hide: () => m()
313
+ hide: () => G()
287
314
  }),
288
- [m]
289
- ), /* @__PURE__ */ a.createElement(a.Fragment, null, me, C && /* @__PURE__ */ a.createElement(
290
- xe,
315
+ [G]
316
+ ), /* @__PURE__ */ l.createElement(l.Fragment, null, me, S && /* @__PURE__ */ l.createElement(
317
+ Te,
291
318
  {
292
- key: H,
319
+ key: F,
293
320
  autoFocus: !1,
294
- title: d.toLanguageString(S, G[S]),
295
- initialTop: Z,
296
- initialLeft: ee,
297
- initialWidth: H,
321
+ title: p.toLanguageString(k, m[k]),
322
+ initialTop: q,
323
+ initialLeft: te,
324
+ initialWidth: F,
298
325
  style: {
299
326
  height: "auto",
300
327
  minWidth: "90px",
301
328
  minHeight: "50px"
302
329
  },
303
- onClose: m,
330
+ onClose: G,
304
331
  resizable: !0,
305
332
  draggable: !0,
306
333
  className: "k-grid-assistant-window",
307
334
  maximizeButton: Fe
308
335
  },
309
- Ce
336
+ ke
310
337
  ));
311
338
  }
312
339
  );
313
- Le.displayName = "KendoReactGridToolbarAIAssistant";
340
+ Me.displayName = "KendoReactGridToolbarAIAssistant";
314
341
  export {
315
- Pe as GridAICommands,
316
- Le as GridToolbarAIAssistant
342
+ Ee as GridAICommands,
343
+ Me as GridToolbarAIAssistant
317
344
  };