@progress/kendo-react-grid 14.5.0-develop.4 → 14.5.0-develop.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/js/kendo-react-grid.js +1 -1
- package/hooks/useGridAIRequest.d.ts +76 -10
- package/hooks/useGridAIRequest.js +1 -1
- package/hooks/useGridAIRequest.mjs +126 -62
- package/index.d.mts +2 -2
- package/index.d.ts +2 -2
- package/index.js +1 -1
- package/index.mjs +45 -44
- package/package-metadata.js +1 -1
- package/package-metadata.mjs +2 -2
- package/package.json +18 -19
- package/toolbar-tools/GridToolbarAIAssistant.d.ts +27 -5
- package/toolbar-tools/GridToolbarAIAssistant.js +2 -2
- package/toolbar-tools/GridToolbarAIAssistant.mjs +11 -10
- package/toolbar-tools/smartbox/SmartBox.js +1 -1
- package/toolbar-tools/smartbox/SmartBox.mjs +91 -90
- package/toolbar-tools/smartbox/interfaces/SmartBoxTypes.d.ts +12 -4
- package/utils/handleAIResponse.d.ts +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@progress/kendo-react-grid",
|
|
3
|
-
"version": "14.5.0-develop.
|
|
3
|
+
"version": "14.5.0-develop.5",
|
|
4
4
|
"description": "React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package",
|
|
5
5
|
"author": "Progress",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
@@ -30,25 +30,24 @@
|
|
|
30
30
|
"@progress/kendo-drawing": "^1.21.2",
|
|
31
31
|
"@progress/kendo-file-saver": "^1.1.1",
|
|
32
32
|
"@progress/kendo-licensing": "^1.7.2",
|
|
33
|
-
"@progress/kendo-react-animation": "14.5.0-develop.
|
|
34
|
-
"@progress/kendo-react-buttons": "14.5.0-develop.
|
|
35
|
-
"@progress/kendo-react-common": "14.5.0-develop.
|
|
36
|
-
"@progress/kendo-react-data-tools": "14.5.0-develop.
|
|
37
|
-
"@progress/kendo-react-dateinputs": "14.5.0-develop.
|
|
38
|
-
"@progress/kendo-react-indicators": "14.5.0-develop.
|
|
39
|
-
"@progress/kendo-react-form": "14.5.0-develop.
|
|
40
|
-
"@progress/kendo-react-labels": "14.5.0-develop.
|
|
41
|
-
"@progress/kendo-react-dialogs": "14.5.0-develop.
|
|
42
|
-
"@progress/kendo-react-dropdowns": "14.5.0-develop.
|
|
43
|
-
"@progress/kendo-react-inputs": "14.5.0-develop.
|
|
44
|
-
"@progress/kendo-react-intl": "14.5.0-develop.
|
|
45
|
-
"@progress/kendo-react-popup": "14.5.0-develop.
|
|
46
|
-
"@progress/kendo-react-layout": "14.5.0-develop.
|
|
47
|
-
"@progress/kendo-react-conversational-ui": "14.5.0-develop.
|
|
33
|
+
"@progress/kendo-react-animation": "14.5.0-develop.5",
|
|
34
|
+
"@progress/kendo-react-buttons": "14.5.0-develop.5",
|
|
35
|
+
"@progress/kendo-react-common": "14.5.0-develop.5",
|
|
36
|
+
"@progress/kendo-react-data-tools": "14.5.0-develop.5",
|
|
37
|
+
"@progress/kendo-react-dateinputs": "14.5.0-develop.5",
|
|
38
|
+
"@progress/kendo-react-indicators": "14.5.0-develop.5",
|
|
39
|
+
"@progress/kendo-react-form": "14.5.0-develop.5",
|
|
40
|
+
"@progress/kendo-react-labels": "14.5.0-develop.5",
|
|
41
|
+
"@progress/kendo-react-dialogs": "14.5.0-develop.5",
|
|
42
|
+
"@progress/kendo-react-dropdowns": "14.5.0-develop.5",
|
|
43
|
+
"@progress/kendo-react-inputs": "14.5.0-develop.5",
|
|
44
|
+
"@progress/kendo-react-intl": "14.5.0-develop.5",
|
|
45
|
+
"@progress/kendo-react-popup": "14.5.0-develop.5",
|
|
46
|
+
"@progress/kendo-react-layout": "14.5.0-develop.5",
|
|
47
|
+
"@progress/kendo-react-conversational-ui": "14.5.0-develop.5",
|
|
48
48
|
"@progress/kendo-svg-icons": "^4.0.0",
|
|
49
49
|
"react": "^18.0.0 || ^19.0.0",
|
|
50
|
-
"react-dom": "^18.0.0 || ^19.0.0"
|
|
51
|
-
"axios": "^1.15.0"
|
|
50
|
+
"react-dom": "^18.0.0 || ^19.0.0"
|
|
52
51
|
},
|
|
53
52
|
"dependencies": {
|
|
54
53
|
"prop-types": "^15.6.0"
|
|
@@ -149,7 +148,7 @@
|
|
|
149
148
|
"package": {
|
|
150
149
|
"productName": "KendoReact",
|
|
151
150
|
"productCode": "KENDOUIREACT",
|
|
152
|
-
"publishDate":
|
|
151
|
+
"publishDate": 1777988950,
|
|
153
152
|
"licensingDocsUrl": "https://www.telerik.com/kendo-react-ui/components/my-license/"
|
|
154
153
|
}
|
|
155
154
|
},
|
|
@@ -7,11 +7,10 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { SpeechToTextButtonProps } from '@progress/kendo-react-buttons';
|
|
9
9
|
import { SVGIcon } from '@progress/kendo-svg-icons';
|
|
10
|
-
import {
|
|
10
|
+
import { GridAIRequestConfig, GridAIResponse, GridAIHttpClient, GridAIRequestData } from '../hooks/useGridAIRequest.js';
|
|
11
11
|
import { CustomComponent } from '@progress/kendo-react-common';
|
|
12
12
|
import { AIPromptOutputInterface } from '@progress/kendo-react-conversational-ui';
|
|
13
13
|
import { GridAIPromptProps } from './ai-tool/GridAIPrompt.js';
|
|
14
|
-
import { GridAIRequestData } from '../hooks/useGridAIRequest.js';
|
|
15
14
|
import * as React from 'react';
|
|
16
15
|
/**
|
|
17
16
|
* Represents the handle interface for the GridToolbarAIAssistant component.
|
|
@@ -118,14 +117,19 @@ export interface GridToolbarAIAssistantProps {
|
|
|
118
117
|
*/
|
|
119
118
|
outputs?: AIPromptOutputInterface[];
|
|
120
119
|
/**
|
|
121
|
-
* Defines the options for the
|
|
120
|
+
* Defines the options for the HTTP request.
|
|
121
|
+
* Accepts both the new `GridAIRequestConfig` and the legacy `AxiosRequestConfig`.
|
|
122
|
+
*
|
|
123
|
+
* @remarks
|
|
124
|
+
* `GridAIRequestConfig` is the recommended type — it has no external dependency.
|
|
125
|
+
* `AxiosRequestConfig` continues to work for backward compatibility.
|
|
122
126
|
*
|
|
123
127
|
* @example
|
|
124
128
|
* ```jsx
|
|
125
129
|
* <GridToolbarAIAssistant requestOptions={{ timeout: 5000 }} />
|
|
126
130
|
* ```
|
|
127
131
|
*/
|
|
128
|
-
requestOptions?:
|
|
132
|
+
requestOptions?: GridAIRequestConfig;
|
|
129
133
|
/**
|
|
130
134
|
* Called before the request is sent.
|
|
131
135
|
*
|
|
@@ -138,12 +142,17 @@ export interface GridToolbarAIAssistantProps {
|
|
|
138
142
|
/**
|
|
139
143
|
* Called when the response is received.
|
|
140
144
|
*
|
|
145
|
+
* @remarks
|
|
146
|
+
* The response object provides `data`, `status`, and `statusText` —
|
|
147
|
+
* the same properties available on both `GridAIResponse` and `AxiosResponse`.
|
|
148
|
+
* Use `GridAIResponse` as the recommended type annotation.
|
|
149
|
+
*
|
|
141
150
|
* @example
|
|
142
151
|
* ```jsx
|
|
143
152
|
* <GridToolbarAIAssistant onResponseSuccess={(response) => console.log(response)} />
|
|
144
153
|
* ```
|
|
145
154
|
*/
|
|
146
|
-
onResponseSuccess?: (response:
|
|
155
|
+
onResponseSuccess?: (response: GridAIResponse<any>, promptMessage?: string, isRetry?: boolean) => void;
|
|
147
156
|
/**
|
|
148
157
|
* Called when the response returns an error.
|
|
149
158
|
*
|
|
@@ -212,6 +221,19 @@ export interface GridToolbarAIAssistantProps {
|
|
|
212
221
|
* ```
|
|
213
222
|
*/
|
|
214
223
|
onCloseWindow?: () => void;
|
|
224
|
+
/**
|
|
225
|
+
* Optional custom HTTP client for the AI assistant.
|
|
226
|
+
* When not provided, the component uses the built-in fetch-based transport.
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* ```tsx
|
|
230
|
+
* import axios from 'axios';
|
|
231
|
+
* import { createAxiosAIClient } from '@progress/kendo-react-grid';
|
|
232
|
+
*
|
|
233
|
+
* <GridToolbarAIAssistant httpClient={createAxiosAIClient(axios)} />
|
|
234
|
+
* ```
|
|
235
|
+
*/
|
|
236
|
+
httpClient?: GridAIHttpClient;
|
|
215
237
|
}
|
|
216
238
|
declare const GridToolbarAIAssistant: React.ForwardRefExoticComponent<GridToolbarAIAssistantProps & React.RefAttributes<GridToolbarAIAssistantHandle>>;
|
|
217
239
|
export { GridToolbarAIAssistant };
|
|
@@ -5,5 +5,5 @@
|
|
|
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 ae=require("react"),le=require("../utils/GridContext.js"),ue=require("@progress/kendo-react-buttons"),ce=require("@progress/kendo-svg-icons"),de=require("@progress/kendo-react-intl"),
|
|
9
|
-
`);I(A=>[{id:A.length+1,title:i.toLanguageString(
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const ae=require("react"),le=require("../utils/GridContext.js"),ue=require("@progress/kendo-react-buttons"),ce=require("@progress/kendo-svg-icons"),de=require("@progress/kendo-react-intl"),r=require("../messages/index.js"),y=require("@progress/kendo-react-common"),ge=require("@progress/kendo-react-dialogs"),pe=require("./ai-tool/GridAIPrompt.js"),me=require("../hooks/useGridAIRequest.js");function fe(n){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const i=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(a,e,i.get?i:{enumerable:!0,get:()=>n[e]})}}return a.default=n,Object.freeze(a)}const o=fe(ae),P=768,he=(n,a)=>n.map(i=>{let c=i;return a.forEach(l=>{l.field&&c.includes(l.field)&&(c=c.replace(new RegExp(l.field,"g"),l.title||l.field))}),c}),Ce=()=>null,q=o.forwardRef((n,a)=>{const e=o.useContext(le.GridContext),i=de.useLocalization(),{requestUrl:c,requestOptions:l,onPromptRequest:v,onResponseSuccess:x,onResponseError:T,role:E="user",gridAIPrompt:W=pe.GridAIPrompt,icon:k,svgIcon:O,onCloseWindow:m,promptPlaceHolder:L,suggestionsList:M,streaming:B,loading:D,outputs:G,enableSpeechToText:S}=n,[j,I]=o.useState([]),z=o.useMemo(()=>e&&Array.isArray(e.columnsRef)&&Array.isArray(e.hiddenColumnsRef)?[...e.columnsRef,...e.hiddenColumnsRef].map(t=>{var s;return{id:t.id,field:t.field,values:(s=t.values)!=null?s:[]}}):[],[e]),N=o.useMemo(()=>({sort:e.sort,filter:e.filter,group:e.group,highlight:e.highlight,select:e.select,columnsState:e.columnsState,skip:e.skip,take:e.take}),[e]),H=o.useMemo(()=>({getTotal:()=>e.getTotal(),getLeafDataItems:()=>e.getLeafDataItems(),exportAsPdf:()=>e.exportAsPdf(),props:{dataItemKey:e.dataItemKey}}),[e]),[f,h]=o.useState(!1),[K,_]=o.useState(),[F,w]=o.useState(),[b,U]=o.useState(()=>{const t=window.innerWidth;return t<P?t*.8:560}),d=o.useRef(null),X=o.useCallback(t=>{var s,u;t.sort!==void 0&&t.sort!==e.sort&&e.sortChange(t.sort,{}),t.filter!==e.filter&&e.filterChange(t.filter,{}),t.group!==void 0&&t.group!==e.group&&e.groupChange(t.group,{}),t.highlight!==void 0&&t.highlight!==e.highlight&&e.applyHighlightDescriptor(t.highlight),t.select!==void 0&&t.select!==e.select&&e.applySelectionDescriptor(t.select),t.columnsState!==void 0&&t.columnsState!==e.columnsState&&e.onColumnsStateChange(t.columnsState),(t.skip!==void 0&&t.skip!==e.skip||t.take!==void 0&&t.take!==e.take)&&e.pagerPageChange({skip:(s=t.skip)!=null?s:0,take:(u=t.take)!=null?u:0,syntheticEvent:{}})},[e]),Y=o.useCallback((t,s,u)=>{const C=[i.toLanguageString(r.aIResponseData,r.messages[r.aIResponseData])];t.forEach(re=>{const ie=he([re],e.columnsRef).join(`
|
|
9
|
+
`);I(A=>[{id:A.length+1,title:i.toLanguageString(r.generatedWithAI,r.messages[r.generatedWithAI]),subTitle:s,prompt:s,responseContent:C.concat(ie).join(""),isRetry:u},...A])})},[i,e.columnsRef]),$=o.useCallback(()=>{e.exportAsPdf()},[e]),{loading:J,streaming:Q,sendRequest:V,cancelRequest:Z}=me.useGridAIRequest({requestUrl:c,requestOptions:l,httpClient:n.httpClient,role:E,columns:z,gridState:N,gridRef:H,onPromptRequest:v,onResponseSuccess:x,onResponseError:T,onStateChange:X,onMessages:Y,onExportPdf:$}),ee=t=>{t.preventDefault(),h(!f)},g=o.useMemo(()=>{var t;return(t=n.show)!=null?t:f},[n.show,f]),p=o.useCallback(()=>{var t;m&&m(),I([]),h(!1),d.current&&((t=d.current.element)==null||t.focus())},[m]),[te,R]=y.useCustomComponent(W),oe=Object.keys(R).length>0?R:{},se=o.createElement(te,{onPromptRequest:V,onCancel:Z,onClose:p,streaming:B||Q,loading:D||J,outputs:G||j,promptPlaceHolder:L,suggestionsList:M,enableSpeechToText:S,...oe}),ne=o.createElement(ue.Button,{ref:d,togglable:!0,themeColor:"primary",rounded:"full",selected:g,svgIcon:O||(k?void 0:ce.sparklesIcon),icon:k,size:e.mobileMode?"large":"medium",className:y.classNames("k-toolbar-button",{"k-icon-button":e.mobileMode}),title:i.toLanguageString(r.toolbarAI,r.messages[r.toolbarAI]),onClick:ee});return o.useEffect(()=>{var t;if(d.current&&g){const s=(t=d.current.element)==null?void 0:t.getBoundingClientRect();if(s){_(s.top+window.scrollY+s.height),w(s.left+window.scrollX+s.width);const u=window.innerWidth,C=u<P?u*.75:560;U(C)}}},[g]),o.useImperativeHandle(a,()=>({show:()=>h(!0),hide:()=>p()}),[p]),o.createElement(o.Fragment,null,ne,g&&o.createElement(ge.Window,{key:b,autoFocus:!1,title:i.toLanguageString(r.toolbarAI,r.messages[r.toolbarAI]),initialTop:K,initialLeft:F,initialWidth:b,style:{height:"auto",minWidth:"90px",minHeight:"50px"},onClose:p,resizable:!0,draggable:!0,className:"k-grid-assistant-window",maximizeButton:Ce},se))});q.displayName="KendoReactGridToolbarAIAssistant";exports.GridToolbarAIAssistant=q;
|
|
@@ -15,15 +15,15 @@ import { useCustomComponent as mt, classNames as gt } from "@progress/kendo-reac
|
|
|
15
15
|
import { Window as pt } from "@progress/kendo-react-dialogs";
|
|
16
16
|
import { GridAIPrompt as ft } from "./ai-tool/GridAIPrompt.mjs";
|
|
17
17
|
import { useGridAIRequest as ht } from "../hooks/useGridAIRequest.mjs";
|
|
18
|
-
const E = 768, Ct = (
|
|
19
|
-
let
|
|
18
|
+
const E = 768, Ct = (l, p) => l.map((i) => {
|
|
19
|
+
let a = i;
|
|
20
20
|
return p.forEach((n) => {
|
|
21
|
-
n.field &&
|
|
22
|
-
}),
|
|
21
|
+
n.field && a.includes(n.field) && (a = a.replace(new RegExp(n.field, "g"), n.title || n.field));
|
|
22
|
+
}), a;
|
|
23
23
|
}), kt = () => null, It = o.forwardRef(
|
|
24
|
-
(
|
|
24
|
+
(l, p) => {
|
|
25
25
|
const t = o.useContext(at), i = dt(), {
|
|
26
|
-
requestUrl:
|
|
26
|
+
requestUrl: a,
|
|
27
27
|
requestOptions: n,
|
|
28
28
|
onPromptRequest: v,
|
|
29
29
|
onResponseSuccess: T,
|
|
@@ -39,7 +39,7 @@ const E = 768, Ct = (a, p) => a.map((i) => {
|
|
|
39
39
|
loading: D,
|
|
40
40
|
outputs: G,
|
|
41
41
|
enableSpeechToText: N
|
|
42
|
-
} =
|
|
42
|
+
} = l, [S, R] = o.useState([]), H = o.useMemo(() => t && Array.isArray(t.columnsRef) && Array.isArray(t.hiddenColumnsRef) ? [...t.columnsRef, ...t.hiddenColumnsRef].map((e) => {
|
|
43
43
|
var s;
|
|
44
44
|
return {
|
|
45
45
|
id: e.id,
|
|
@@ -109,8 +109,9 @@ const E = 768, Ct = (a, p) => a.map((i) => {
|
|
|
109
109
|
sendRequest: Z,
|
|
110
110
|
cancelRequest: tt
|
|
111
111
|
} = ht({
|
|
112
|
-
requestUrl:
|
|
112
|
+
requestUrl: a,
|
|
113
113
|
requestOptions: n,
|
|
114
|
+
httpClient: l.httpClient,
|
|
114
115
|
role: L,
|
|
115
116
|
columns: H,
|
|
116
117
|
gridState: K,
|
|
@@ -125,8 +126,8 @@ const E = 768, Ct = (a, p) => a.map((i) => {
|
|
|
125
126
|
e.preventDefault(), C(!h);
|
|
126
127
|
}, c = o.useMemo(() => {
|
|
127
128
|
var e;
|
|
128
|
-
return (e =
|
|
129
|
-
}, [
|
|
129
|
+
return (e = l.show) != null ? e : h;
|
|
130
|
+
}, [l.show, h]), d = o.useCallback(() => {
|
|
130
131
|
var e;
|
|
131
132
|
f && f(), R([]), C(!1), u.current && ((e = u.current.element) == null || e.focus());
|
|
132
133
|
}, [f]), [ot, b] = mt(
|
|
@@ -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
|
|
8
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ae=require("react"),_=require("@progress/kendo-react-buttons"),M=require("@progress/kendo-svg-icons"),d=require("@progress/kendo-react-common"),et=require("@progress/kendo-react-intl"),J=require("@progress/kendo-react-dropdowns"),tt=require("@progress/kendo-react-popup"),R=require("./listItemRenders.js"),o=require("../../messages/index.js"),nt=require("../../hooks/useGridAIRequest.js"),st=require("../../utils/GridContext.js"),rt=require("./hooks/useSmartBoxModes.js"),at=require("./hooks/useSmartBoxHistory.js"),ot=require("./hooks/useSmartBoxPopup.js"),ct=require("./hooks/useSmartBoxGridState.js"),it=require("./hooks/useSmartBoxLabels.js"),lt=require("./hooks/useSmartBoxListData.js"),ut=require("./hooks/useSmartBoxSegmentedControl.js"),pt=require("./hooks/useSmartBoxSearch.js"),dt=require("./hooks/useDebounce.js");function mt(m){const x=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(m){for(const f in m)if(f!=="default"){const I=Object.getOwnPropertyDescriptor(m,f);Object.defineProperty(x,f,I.get?I:{enumerable:!0,get:()=>m[f]})}}return x.default=m,Object.freeze(x)}const e=mt(Ae),ge=e.forwardRef((m,x)=>{var de;const{searchConfig:f,semanticSearchConfig:I,aiAssistantConfig:he,activeMode:fe,dir:Se="ltr",size:Q="medium",placeholder:ke,history:xe,loading:Ce=!1,promptSuggestionRender:X,historyItemRender:Y,onOpen:be,onClose:Be,onFocus:v,onBlur:q,onSearch:Re,onSemanticSearch:Ie,onAIPromptRequest:N,onAIResponseSuccess:F,onAIResponseError:O,onAICancelRequest:w}=m,C=et.useLocalization(),b=e.useContext(st.GridContext),ve=e.useRef(`k-${d.guid()}`),S=e.useRef(null),B=e.useRef(null),Z=e.useRef(null),[c,g]=e.useState(""),[qe,D]=e.useState(!1),[we,A]=e.useState(void 0),[De,ee]=e.useState(null),{searchMode:i,semanticSearchMode:u,aiAssistantMode:r,selectedView:n,setSelectedViewState:z,lastSearchMode:Pe,searchHistorySettings:te,semanticSearchHistorySettings:ne,aiAssistantHistorySettings:G,speechToTextButtonSettings:se,currentSearchDelay:ye}=rt.useSmartBoxModes({searchConfigProp:f,semanticSearchConfigProp:I,aiAssistantConfigProp:he,activeModeProp:fe,sharedHistory:xe}),{currentHistory:P,currentHistorySettings:Ee,addToHistory:V}=at.useSmartBoxHistory({selectedView:n,searchHistorySettings:te,semanticSearchHistorySettings:ne,aiAssistantHistorySettings:G}),{isOpen:W,togglePopup:a}=ot.useSmartBoxPopup({onOpen:be,onClose:Be}),{columns:re,gridState:Le,gridRef:Te,handleStateChange:He}=ct.useSmartBoxGridState(b),j=e.useMemo(()=>(r==null?void 0:r.promptSuggestions)||[],[r==null?void 0:r.promptSuggestions]),{inputPlaceholder:Ne,prefixIcon:Fe}=it.useSmartBoxLabels({selectedView:n,searchMode:i,semanticSearchMode:u,aiAssistantMode:r,sharedPlaceholder:ke}),{searchListData:k,aiAssistantListData:y,searchHistoryListData:E}=lt.useSmartBoxListData({selectedView:n,searchModeEnabled:i==null?void 0:i.enabled,semanticSearchModeEnabled:u==null?void 0:u.enabled,promptSuggestions:j,currentHistory:P,currentHistorySettings:Ee}),L=ut.useSmartBoxSegmentedControl({searchMode:i,semanticSearchMode:u,aiAssistantMode:r,selectedView:n,lastSearchMode:Pe,setSelectedViewState:z,setInputValue:g});e.useEffect(()=>{const t=S.current;if(!t)return;A(t.offsetWidth);const s=new ResizeObserver(()=>{t&&A(t.offsetWidth)});return s.observe(t),()=>{s.disconnect()}},[]);const h=Ce||qe,U=!n,Oe=!(i!=null&&i.enabled)&&!(u!=null&&u.enabled)&&!(r!=null&&r.enabled),ze=d.kendoThemeMaps.sizeMap[Q]||"md",{emitSearchEvent:p}=pt.useSmartBoxSearch({selectedView:n,searchMode:i,columns:re,gridContext:b,searchHistorySettings:te,semanticSearchHistorySettings:ne,addToHistory:V,onSearch:Re,onSemanticSearch:Ie}),{sendRequest:ae,cancelRequest:oe}=nt.useGridAIRequest({requestUrl:r==null?void 0:r.requestUrl,requestOptions:r==null?void 0:r.requestOptions,httpClient:r==null?void 0:r.httpClient,columns:re,gridState:Le,gridRef:Te,onPromptRequest:t=>{N==null||N({requestData:t})},onResponseSuccess:t=>{D(!1),F==null||F({response:t})},onResponseError:t=>{D(!1),O==null||O({error:t})},onStateChange:He,onExportPdf:()=>b==null?void 0:b.exportAsPdf()});e.useImperativeHandle(x,()=>({show:()=>a(!0),hide:()=>a(!1)}),[a]);const $=dt.useDebounce(De,ye),ce=e.useRef(p);ce.current=p,e.useEffect(()=>{$!==null&&ce.current($)},[$]);const Ge=e.useCallback(t=>{const s=t.target.value;g(s),a(!s),(n==="search"||n==="semanticSearch")&&ee(s)},[a,n]),Ve=e.useCallback(()=>{v==null||v(),c||a(!0)},[v,a,c]),We=e.useCallback(t=>{var me;const s=S.current,l=(me=Z.current)==null?void 0:me.element,H=t.relatedTarget,Ye=H&&(s==null?void 0:s.contains(H)),Ze=H&&(l==null?void 0:l.contains(H));!Ye&&!Ze&&(q==null||q(),a(!1))},[q,a]),je=e.useCallback(()=>{c||a(!0)},[a,c]),ie=!!((de=r==null?void 0:r.requestOptions)!=null&&de.url||r!=null&&r.requestUrl),K=e.useCallback(()=>{if(h){w==null||w(),oe(),D(!1);return}c.trim()&&(ie&&D(!0),V("aiAssistant",c,G),a(!1),ae(c.trim()),g(""))},[h,c,G,a,V,ae,oe,ie,w]),Ue=e.useCallback(t=>{t.key==="Enter"&&(n==="aiAssistant"?K():n==="semanticSearch"&&p(c))},[n,c,p,K]),$e=e.useCallback(()=>{var t;a(!W),(t=B.current)==null||t.focus()},[W,a]),Ke=e.useCallback(t=>{var s;t.stopPropagation(),t.preventDefault(),g(""),(s=B.current)==null||s.focus(),a(!0),p("")},[a,p]),le=e.useCallback(t=>{var s;z(t),g(""),ee(null),(s=B.current)==null||s.focus()},[z]),T=e.useCallback(t=>{var s;g(t),a(!1),(s=B.current)==null||s.focus(),n!=="aiAssistant"&&p(t)},[n,a,p]),_e=e.useCallback(t=>{if(t.isFinal&&t.alternatives.length>0){const s=t.alternatives[0].transcript;g(l=>l?`${l} ${s}`:s)}},[]),Me=e.useMemo(()=>n==="aiAssistant"?P.length===0&&j.length===0:n==="search"||n==="semanticSearch"?P.length===0&&k.length===0:!1,[n,P.length,j.length,k.length]),ue=e.useCallback(t=>{const l=(n==="aiAssistant"?y:E)[t];l&&T(l.text)},[n,y,E,T]),Je=e.useCallback(t=>{const s=k[t];s&&le(s.mode)},[k,le]),pe=e.useMemo(()=>R.createListItemRender({historyItemRender:Y,promptSuggestionRender:X,handleListItemClick:T}),[Y,X,T]),Qe=W&&!Oe,Xe=()=>e.createElement(e.Fragment,null,L.items.length>0&&e.createElement(_.SegmentedControl,{items:L.items,value:L.value,onChange:L.onChange,size:Q,layoutMode:"stretch"}),(n==="search"||n==="semanticSearch")&&k.length>0&&e.createElement(J.List,{data:k,textField:"text",descriptionField:"description",onClick:Je,itemRender:R.searchModeItemRender,show:!0,wrapperCssClass:"k-list k-list-md"}),n==="aiAssistant"&&y.length>0&&e.createElement(J.List,{data:y,textField:"text",groupField:"group",svgIconField:"groupSvgIcon",descriptionField:"description",onClick:ue,itemRender:pe,groupHeaderItemRender:R.listGroupHeaderRender,showFirstGroupHeader:!0,show:!0,wrapperCssClass:"k-list k-list-md"}),(n==="search"||n==="semanticSearch")&&E.length>0&&e.createElement(J.List,{data:E,textField:"text",groupField:"group",svgIconField:"groupSvgIcon",descriptionField:"description",onClick:ue,itemRender:pe,groupHeaderItemRender:R.listGroupHeaderRender,showFirstGroupHeader:!0,show:!0,wrapperCssClass:"k-list k-list-md"}),Me&&e.createElement(R.NoDataRender,{selectedView:n}));return e.createElement("div",{ref:S,className:"k-smart-box-wrapper",dir:Se,onBlur:We},e.createElement("span",{className:d.classNames("k-smart-box","k-input",`k-input-${ze}`,{"k-loading":h})},!U&&e.createElement("span",{className:"k-input-prefix k-input-prefix-horizontal"},e.createElement(d.IconWrap,{className:d.classNames("k-icon",{"k-accent-icon":n==="aiAssistant"||n==="semanticSearch"}),icon:Fe.svgIcon,onClick:$e,onMouseDown:t=>{"preventDefault"in t&&t.preventDefault()}})),e.createElement("input",{ref:B,type:"text",className:d.classNames("k-input-inner",{"k-disabled":U}),id:ve.current,placeholder:Ne,value:c,disabled:U,onChange:Ge,onFocus:Ve,onClick:je,onKeyDown:Ue}),c.length>0&&(n==="search"||n==="semanticSearch")&&e.createElement("span",{className:"k-clear-value",title:C.toLanguageString(o.smartBoxClearTitle,o.messages[o.smartBoxClearTitle]),role:"button",tabIndex:-1,onClick:Ke,onMouseDown:t=>t.preventDefault()},e.createElement(d.IconWrap,{className:"k-icon",icon:M.xIcon})),n==="aiAssistant"&&e.createElement("span",{className:"k-input-suffix k-input-suffix-horizontal"},se&&e.createElement(_.SpeechToTextButton,{...se,"aria-label":C.toLanguageString(o.smartBoxSpeechToTextButton,o.messages[o.smartBoxSpeechToTextButton]),title:C.toLanguageString(o.smartBoxSpeechToTextButton,o.messages[o.smartBoxSpeechToTextButton]),onResult:_e}),e.createElement(_.Button,{className:d.classNames("k-smart-box-send",{"k-processing":h,"k-active":h}),type:"button",rounded:"full",size:"small",title:C.toLanguageString(o.smartBoxSubmitPromptButton,o.messages[o.smartBoxSubmitPromptButton]),"aria-label":C.toLanguageString(o.smartBoxSubmitPromptButton,o.messages[o.smartBoxSubmitPromptButton]),"aria-disabled":c.length===0,svgIcon:h?M.stopSmIcon:M.arrowUpOutlineIcon,disabled:c.length===0&&!h,onClick:K}))),e.createElement(tt.Popup,{ref:Z,anchor:S.current,show:Qe,popupClass:"k-smart-box-popup",style:{width:we},anchorAlign:{horizontal:"left",vertical:"bottom"},popupAlign:{horizontal:"left",vertical:"top"},margin:{horizontal:0,vertical:2},onMouseDownOutside:t=>{const s=t.event.target;S.current&&!S.current.contains(s)&&a(!1)}},Xe()))});ge.displayName="KendoReactSmartBox";exports.SmartBox=ge;
|