@progress/kendo-react-grid 11.4.0-develop.2 → 11.4.0-develop.3

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.
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @license
3
+ *-------------------------------------------------------------------------------------------
4
+ * Copyright © 2025 Progress Software Corporation. All rights reserved.
5
+ * Licensed under commercial license. See LICENSE.md in the package root for more information
6
+ *-------------------------------------------------------------------------------------------
7
+ */
8
+ import * as s from "react";
9
+ import { GridContext as st } from "../utils/GridContext.mjs";
10
+ import { Button as nt } from "@progress/kendo-react-buttons";
11
+ import { sparklesIcon as rt } from "@progress/kendo-svg-icons";
12
+ import E from "axios";
13
+ import { useInternationalization as at, useLocalization as it } from "@progress/kendo-react-intl";
14
+ import { toolbarAI as m, messages as g, aIResponseData as L, generatedWithAI as j } from "../messages/index.mjs";
15
+ import { useCustomComponent as lt, classNames as ut } from "@progress/kendo-react-common";
16
+ import { Window as ct } from "@progress/kendo-react-dialogs";
17
+ import { GridAIPrompt as pt } from "./ai-tool/GridAIPrompt.mjs";
18
+ const ft = (l, n) => l.map((u) => {
19
+ let c = u;
20
+ return n.forEach((a) => {
21
+ a.field && c.includes(a.field) && (c = c.replace(new RegExp(a.field, "g"), a.title || a.field));
22
+ }), c;
23
+ }), dt = (l) => {
24
+ const n = s.useContext(st), R = at(), u = it(), {
25
+ requestUrl: c,
26
+ requestOptions: a,
27
+ onPromptRequest: w,
28
+ onResponseSuccess: y,
29
+ onResponseError: b,
30
+ role: v = "user",
31
+ gridAIPrompt: D = pt,
32
+ icon: W,
33
+ svgIcon: h,
34
+ onCloseWindow: T,
35
+ promptPlaceHolder: z,
36
+ suggestionsList: B,
37
+ streaming: F,
38
+ outputs: G
39
+ } = l, [C, k] = s.useState([]), M = s.useMemo(() => n && Array.isArray(n.columnsRef) ? n.columnsRef.map((t) => ({ field: t.field })) : [], [n]), [H, f] = s.useState(!1), [d, I] = s.useState(!1), [N, $] = s.useState(), [K, U] = s.useState(), p = s.useRef(null), A = s.useRef(null), V = (t) => {
40
+ t.preventDefault(), I(!d);
41
+ }, S = s.useMemo(() => {
42
+ var t;
43
+ return (t = l.show) != null ? t : d;
44
+ }, [l.show, d]), O = () => {
45
+ var t;
46
+ T && T(), k([]), I(!1), p.current && ((t = p.current.element) == null || t.focus());
47
+ }, P = (t) => {
48
+ t.filters = t.filters.map((o) => {
49
+ if (o.value) {
50
+ const i = R.parseDate(o.value);
51
+ i && (o.value = i);
52
+ }
53
+ return o;
54
+ });
55
+ }, X = (t, o, i) => {
56
+ if (f(!1), t != null && t.data) {
57
+ if (t.data.sort && n.sortChange(t.data.sort, t), t.data.filter) {
58
+ let e = t.data.filter;
59
+ if (e && Object.keys(e).length === 0 && (e = null), e != null && e.filters && Array.isArray(e.filters)) {
60
+ P(e);
61
+ const r = n.filter || { filters: [], logic: "or" }, et = e.filters.map((ot) => ({
62
+ logic: "and",
63
+ filters: [ot]
64
+ }));
65
+ e = {
66
+ ...r,
67
+ filters: [...r.filters, ...et]
68
+ };
69
+ }
70
+ n.filterChange(e, t);
71
+ }
72
+ if (t.data.highlight) {
73
+ let e = t.data.highlight;
74
+ Array.isArray(e) && (e = e.map((r) => (r != null && r.filters && Array.isArray(r.filters) && P(r), r))), n.applyHighlightDescriptor(e);
75
+ }
76
+ if (t.data.group && n.groupChange(t.data.group, t), t.data.messages) {
77
+ const e = [u.toLanguageString(L, g[L])], r = ft(t.data.messages, n.columnsRef).join(
78
+ `
79
+ `
80
+ );
81
+ k([
82
+ ...C,
83
+ {
84
+ id: C.length + 1,
85
+ title: u.toLanguageString(j, g[j]),
86
+ subTitle: o,
87
+ prompt: o,
88
+ responseContent: e.concat(r).join(""),
89
+ isRetry: i
90
+ }
91
+ ]);
92
+ }
93
+ }
94
+ y && y(t);
95
+ }, Y = (t) => {
96
+ b && b(t), f(!1);
97
+ }, J = (t, o) => {
98
+ const i = E.CancelToken.source(), e = {
99
+ role: "user",
100
+ columns: M || [],
101
+ headers: {
102
+ Accept: "*/*",
103
+ "Content-Type": "application/json"
104
+ },
105
+ promptMessage: t,
106
+ requestOptions: {
107
+ url: c,
108
+ method: "POST",
109
+ withCredentials: !1,
110
+ responseType: "json",
111
+ cancelToken: i.token,
112
+ ...a
113
+ }
114
+ };
115
+ w && w(e, o), e.requestOptions.url !== void 0 && (f(!0), E({
116
+ ...e.requestOptions,
117
+ headers: e.headers,
118
+ data: {
119
+ role: v || e.role,
120
+ contents: [
121
+ {
122
+ $type: "text",
123
+ text: e.promptMessage
124
+ }
125
+ ],
126
+ columns: e.columns || []
127
+ },
128
+ ...l.requestOptions
129
+ }).then((r) => X(r, e.promptMessage, o)).catch(Y), A.current = i);
130
+ }, Q = () => {
131
+ A.current && A.current.cancel("Request cancelled by user."), f(!1);
132
+ }, [Z, x] = lt(
133
+ D
134
+ ), _ = Object.keys(x).length > 0 ? x : {}, q = /* @__PURE__ */ s.createElement(
135
+ Z,
136
+ {
137
+ onPromptRequest: J,
138
+ onCancel: Q,
139
+ onClose: O,
140
+ streaming: F || H,
141
+ outputs: G || C,
142
+ promptPlaceHolder: z,
143
+ suggestionsList: B,
144
+ ..._
145
+ }
146
+ ), tt = /* @__PURE__ */ s.createElement(
147
+ nt,
148
+ {
149
+ ref: p,
150
+ togglable: !0,
151
+ themeColor: "primary",
152
+ rounded: "full",
153
+ selected: S,
154
+ svgIcon: h != null ? h : rt,
155
+ icon: W,
156
+ size: n.mobileMode ? "large" : "medium",
157
+ className: ut("k-toolbar-button", { "k-icon-button": n.mobileMode }),
158
+ title: u.toLanguageString(m, g[m]),
159
+ onClick: V
160
+ }
161
+ );
162
+ return s.useEffect(() => {
163
+ var t;
164
+ if (p.current && S) {
165
+ const o = (t = p.current.element) == null ? void 0 : t.getBoundingClientRect();
166
+ o && ($(o.top + window.scrollY + o.height), U(o.left + window.scrollX + o.width));
167
+ }
168
+ }, [S]), /* @__PURE__ */ s.createElement(s.Fragment, null, tt, d && /* @__PURE__ */ s.createElement(
169
+ ct,
170
+ {
171
+ autoFocus: !1,
172
+ title: u.toLanguageString(m, g[m]),
173
+ initialTop: N,
174
+ initialLeft: K,
175
+ onClose: O,
176
+ resizable: !0,
177
+ draggable: !0,
178
+ initialWidth: 437,
179
+ initialHeight: 460,
180
+ className: "k-grid-assistant-window"
181
+ },
182
+ q
183
+ ));
184
+ };
185
+ dt.displayName = "KendoReactGridToolbarAIAssistant";
186
+ export {
187
+ dt as GridToolbarAIAssistant
188
+ };
@@ -1,9 +0,0 @@
1
- /**
2
- * @license
3
- *-------------------------------------------------------------------------------------------
4
- * Copyright © 2025 Progress Software Corporation. All rights reserved.
5
- * Licensed under commercial license. See LICENSE.md in the package root for more information
6
- *-------------------------------------------------------------------------------------------
7
- */
8
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Z=require("react"),ee=require("../utils/GridContext.js"),te=require("@progress/kendo-react-buttons"),oe=require("@progress/kendo-svg-icons"),j=require("axios"),x=require("@progress/kendo-react-intl"),l=require("../messages/index.js"),v=require("@progress/kendo-react-common"),ne=require("@progress/kendo-react-dialogs"),se=require("./ai-tool/GridAIPrompt.js");function re(a){const o=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const c in a)if(c!=="default"){const i=Object.getOwnPropertyDescriptor(a,c);Object.defineProperty(o,c,i.get?i:{enumerable:!0,get:()=>a[c]})}}return o.default=a,Object.freeze(o)}const s=re(Z),ae=(a,o)=>a.map(i=>{let f=i;return o.forEach(u=>{u.field&&f.includes(u.field)&&(f=f.replace(new RegExp(u.field,"g"),u.title||u.field))}),f}),D=a=>{const o=s.useContext(ee.GridContext),c=x.useInternationalization(),i=x.useLocalization(),{requestUrl:f,requestOptions:u,onPromptRequest:A,onResponseSuccess:R,onResponseError:I,role:E="user",gridAIPrompt:G=se.GridAIPrompt,icon:W,svgIcon:h,onCloseWindow:y}=a,[b,k]=s.useState([]),z=s.useMemo(()=>o&&Array.isArray(o.columnsRef)?o.columnsRef.map(e=>({field:e.field})):[],[o]),[B,p]=s.useState(!1),[m,w]=s.useState(!1),[L,M]=s.useState(),[F,N]=s.useState(),g=s.useRef(null),C=s.useRef(null),q=e=>{e.preventDefault(),w(!m)},S=s.useMemo(()=>{var e;return(e=a.show)!=null?e:m},[a.show,m]),O=()=>{var e;y&&y(),k([]),w(!1),g.current&&((e=g.current.element)==null||e.focus())},T=e=>{e.filters=e.filters.map(n=>{if(n.value){const d=c.parseDate(n.value);d&&(n.value=d)}return n})},_=(e,n,d)=>{if(p(!1),e!=null&&e.data){if(e.data.sort&&o.sortChange(e.data.sort,e),e.data.filter){let t=e.data.filter;if(t&&Object.keys(t).length===0&&(t=null),t!=null&&t.filters&&Array.isArray(t.filters)){T(t);const r=o.filter||{filters:[],logic:"or"},J=t.filters.map(Q=>({logic:"and",filters:[Q]}));t={...r,filters:[...r.filters,...J]}}o.filterChange(t,e)}if(e.data.highlight){let t=e.data.highlight;Array.isArray(t)&&(t=t.map(r=>(r!=null&&r.filters&&Array.isArray(r.filters)&&T(r),r))),o.highlightChange(t)}if(e.data.group&&o.groupChange(e.data.group,e),e.data.messages){const t=[i.toLanguageString(l.aIResponseData,l.messages[l.aIResponseData])],r=ae(e.data.messages,o.columnsRef).join(`
9
- `);k([...b,{id:b.length+1,title:i.toLanguageString(l.generatedWithAI,l.messages[l.generatedWithAI]),subTitle:n,prompt:n,responseContent:t.concat(r).join(""),isRetry:d}])}}R&&R(e)},H=e=>{I&&I(e),p(!1)},$=(e,n)=>{const d=j.CancelToken.source();console.log("Prompt requested:",e,n);const t={role:"user",columns:z||[],headers:{Accept:"*/*","Content-Type":"application/json"},promptMessage:e,requestOptions:{url:f,method:"POST",withCredentials:!1,responseType:"json",cancelToken:d.token,...u}};A&&A(t,n),t.requestOptions.url!==void 0&&(p(!0),j({...t.requestOptions,headers:t.headers,data:{role:E||t.role,contents:[{$type:"text",text:t.promptMessage}],columns:t.columns||[]},...a.requestOptions}).then(r=>_(r,t.promptMessage,n)).catch(H),C.current=d)},K=()=>{C.current&&C.current.cancel("Request cancelled by user."),p(!1)},[U,P]=v.useCustomComponent(G),V=Object.keys(P).length>0?P:{},X=s.createElement(U,{onPromptRequest:$,onCancel:K,onClose:O,streaming:B,outputs:b,...V}),Y=s.createElement(te.Button,{ref:g,togglable:!0,themeColor:"primary",rounded:"full",selected:S,svgIcon:h!=null?h:oe.sparklesIcon,icon:W,size:o.mobileMode?"large":"medium",className:v.classNames("k-toolbar-button",{"k-icon-button":o.mobileMode}),title:i.toLanguageString(l.toolbarAI,l.messages[l.toolbarAI]),onClick:q});return s.useEffect(()=>{var e;if(g.current&&S){const n=(e=g.current.element)==null?void 0:e.getBoundingClientRect();n&&(M(n.top+window.scrollY+n.height),N(n.left+window.scrollX+n.width))}},[S]),s.createElement(s.Fragment,null,Y,m&&s.createElement(ne.Window,{autoFocus:!1,title:i.toLanguageString(l.toolbarAI,l.messages[l.toolbarAI]),top:L,left:F,onClose:O,resizable:!0,draggable:!0,initialWidth:437,initialHeight:460,className:"k-grid-assistant-window"},X))};D.displayName="KendoReactGridToolbarAI";exports.GridToolbarAI=D;
@@ -1,187 +0,0 @@
1
- /**
2
- * @license
3
- *-------------------------------------------------------------------------------------------
4
- * Copyright © 2025 Progress Software Corporation. All rights reserved.
5
- * Licensed under commercial license. See LICENSE.md in the package root for more information
6
- *-------------------------------------------------------------------------------------------
7
- */
8
- import * as n from "react";
9
- import { GridContext as q } from "../utils/GridContext.mjs";
10
- import { Button as ee } from "@progress/kendo-react-buttons";
11
- import { sparklesIcon as te } from "@progress/kendo-svg-icons";
12
- import E from "axios";
13
- import { useInternationalization as oe, useLocalization as ne } from "@progress/kendo-react-intl";
14
- import { toolbarAI as m, messages as g, aIResponseData as j, generatedWithAI as v } from "../messages/index.mjs";
15
- import { useCustomComponent as se, classNames as re } from "@progress/kendo-react-common";
16
- import { Window as ae } from "@progress/kendo-react-dialogs";
17
- import { GridAIPrompt as le } from "./ai-tool/GridAIPrompt.mjs";
18
- const ie = (i, s) => i.map((c) => {
19
- let u = c;
20
- return s.forEach((a) => {
21
- a.field && u.includes(a.field) && (u = u.replace(new RegExp(a.field, "g"), a.title || a.field));
22
- }), u;
23
- }), ce = (i) => {
24
- const s = n.useContext(q), w = oe(), c = ne(), {
25
- requestUrl: u,
26
- requestOptions: a,
27
- onPromptRequest: R,
28
- onResponseSuccess: b,
29
- onResponseError: y,
30
- role: L = "user",
31
- gridAIPrompt: W = le,
32
- icon: z,
33
- svgIcon: h,
34
- onCloseWindow: T
35
- } = i, [C, k] = n.useState([]), B = n.useMemo(() => s && Array.isArray(s.columnsRef) ? s.columnsRef.map((e) => ({ field: e.field })) : [], [s]), [D, d] = n.useState(!1), [p, I] = n.useState(!1), [F, G] = n.useState(), [M, N] = n.useState(), f = n.useRef(null), S = n.useRef(null), H = (e) => {
36
- e.preventDefault(), I(!p);
37
- }, A = n.useMemo(() => {
38
- var e;
39
- return (e = i.show) != null ? e : p;
40
- }, [i.show, p]), P = () => {
41
- var e;
42
- T && T(), k([]), I(!1), f.current && ((e = f.current.element) == null || e.focus());
43
- }, O = (e) => {
44
- e.filters = e.filters.map((o) => {
45
- if (o.value) {
46
- const l = w.parseDate(o.value);
47
- l && (o.value = l);
48
- }
49
- return o;
50
- });
51
- }, $ = (e, o, l) => {
52
- if (d(!1), e != null && e.data) {
53
- if (e.data.sort && s.sortChange(e.data.sort, e), e.data.filter) {
54
- let t = e.data.filter;
55
- if (t && Object.keys(t).length === 0 && (t = null), t != null && t.filters && Array.isArray(t.filters)) {
56
- O(t);
57
- const r = s.filter || { filters: [], logic: "or" }, Z = t.filters.map((_) => ({
58
- logic: "and",
59
- filters: [_]
60
- }));
61
- t = {
62
- ...r,
63
- filters: [
64
- ...r.filters,
65
- ...Z
66
- ]
67
- };
68
- }
69
- s.filterChange(t, e);
70
- }
71
- if (e.data.highlight) {
72
- let t = e.data.highlight;
73
- Array.isArray(t) && (t = t.map((r) => (r != null && r.filters && Array.isArray(r.filters) && O(r), r))), s.highlightChange(t);
74
- }
75
- if (e.data.group && s.groupChange(e.data.group, e), e.data.messages) {
76
- const t = [c.toLanguageString(j, g[j])], r = ie(e.data.messages, s.columnsRef).join(
77
- `
78
- `
79
- );
80
- k([
81
- ...C,
82
- {
83
- id: C.length + 1,
84
- title: c.toLanguageString(v, g[v]),
85
- subTitle: o,
86
- prompt: o,
87
- responseContent: t.concat(r).join(""),
88
- isRetry: l
89
- }
90
- ]);
91
- }
92
- }
93
- b && b(e);
94
- }, K = (e) => {
95
- y && y(e), d(!1);
96
- }, U = (e, o) => {
97
- const l = E.CancelToken.source();
98
- console.log("Prompt requested:", e, o);
99
- const t = {
100
- role: "user",
101
- columns: B || [],
102
- headers: {
103
- Accept: "*/*",
104
- "Content-Type": "application/json"
105
- },
106
- promptMessage: e,
107
- requestOptions: {
108
- url: u,
109
- method: "POST",
110
- withCredentials: !1,
111
- responseType: "json",
112
- cancelToken: l.token,
113
- ...a
114
- }
115
- };
116
- R && R(t, o), t.requestOptions.url !== void 0 && (d(!0), E({
117
- ...t.requestOptions,
118
- headers: t.headers,
119
- data: {
120
- role: L || t.role,
121
- contents: [
122
- {
123
- $type: "text",
124
- text: t.promptMessage
125
- }
126
- ],
127
- columns: t.columns || []
128
- },
129
- ...i.requestOptions
130
- }).then((r) => $(r, t.promptMessage, o)).catch(K), S.current = l);
131
- }, V = () => {
132
- S.current && S.current.cancel("Request cancelled by user."), d(!1);
133
- }, [X, x] = se(
134
- W
135
- ), Y = Object.keys(x).length > 0 ? x : {}, J = /* @__PURE__ */ n.createElement(
136
- X,
137
- {
138
- onPromptRequest: U,
139
- onCancel: V,
140
- onClose: P,
141
- streaming: D,
142
- outputs: C,
143
- ...Y
144
- }
145
- ), Q = /* @__PURE__ */ n.createElement(
146
- ee,
147
- {
148
- ref: f,
149
- togglable: !0,
150
- themeColor: "primary",
151
- rounded: "full",
152
- selected: A,
153
- svgIcon: h != null ? h : te,
154
- icon: z,
155
- size: s.mobileMode ? "large" : "medium",
156
- className: re("k-toolbar-button", { "k-icon-button": s.mobileMode }),
157
- title: c.toLanguageString(m, g[m]),
158
- onClick: H
159
- }
160
- );
161
- return n.useEffect(() => {
162
- var e;
163
- if (f.current && A) {
164
- const o = (e = f.current.element) == null ? void 0 : e.getBoundingClientRect();
165
- o && (G(o.top + window.scrollY + o.height), N(o.left + window.scrollX + o.width));
166
- }
167
- }, [A]), /* @__PURE__ */ n.createElement(n.Fragment, null, Q, p && /* @__PURE__ */ n.createElement(
168
- ae,
169
- {
170
- autoFocus: !1,
171
- title: c.toLanguageString(m, g[m]),
172
- top: F,
173
- left: M,
174
- onClose: P,
175
- resizable: !0,
176
- draggable: !0,
177
- initialWidth: 437,
178
- initialHeight: 460,
179
- className: "k-grid-assistant-window"
180
- },
181
- J
182
- ));
183
- };
184
- ce.displayName = "KendoReactGridToolbarAI";
185
- export {
186
- ce as GridToolbarAI
187
- };