@progress/kendo-react-grid
Version:
React Data Grid (Table) provides 100+ ready-to-use data grid features. KendoReact Grid package
95 lines (94 loc) • 2.92 kB
JavaScript
/**
* @license
*-------------------------------------------------------------------------------------------
* Copyright © 2025 Progress Software Corporation. All rights reserved.
* Licensed under commercial license. See LICENSE.md in the package root for more information
*-------------------------------------------------------------------------------------------
*/
import * as e from "react";
import { promptViewDefaults as l, AIPrompt as D, outputViewDefaults as g, AIPromptView as S, AIPromptOutputView as q } from "@progress/kendo-react-conversational-ui";
import { Button as z } from "@progress/kendo-react-buttons";
import { TextArea as L } from "@progress/kendo-react-inputs";
import { tableWizardIcon as O } from "@progress/kendo-svg-icons";
import { toolbarAIApply as a, messages as d } from "../../messages/index.mjs";
import { useLocalization as B } from "@progress/kendo-react-intl";
const H = (s) => {
const { responseContent: o } = s, r = o.split(`
`);
return /* @__PURE__ */ e.createElement("div", { className: "k-card-body" }, r.map((n, i) => /* @__PURE__ */ e.createElement("div", { key: n.trim() + i, className: "k-card-text" }, n)));
}, F = (s) => {
const {
activeView: o,
onActiveViewChange: r,
toolbarItems: n,
outputs: i,
promptValue: f,
promptInput: w,
generateButton: A,
onCopy: y,
onOutputRating: C,
onPromptRequest: u,
suggestionsList: I,
outputCard: V,
promptPlaceHolder: h,
streaming: E,
loading: b,
onCancel: v,
onClose: p
} = s, m = B(), [x, c] = e.useState(l.name), P = (t, K) => {
t && (u && u(t), c(g.name));
}, k = (t) => {
r && r(t), c(t);
}, R = (t) => {
t.key === "Escape" && p && p();
};
return e.useEffect(() => {
const t = document.querySelector(".k-prompt-view .k-textarea textarea");
t && t.focus();
}, []), /* @__PURE__ */ e.createElement(
D,
{
style: { maxHeight: "100%" },
activeView: o != null ? o : x,
onActiveViewChange: k,
onPromptRequest: P,
toolbarItems: n || [l, g],
streaming: E,
loading: b,
suggestionsView: "modern",
onCancel: v,
onKeyDown: R
},
/* @__PURE__ */ e.createElement(
S,
{
promptSuggestions: I,
promptValue: f,
promptInput: w || /* @__PURE__ */ e.createElement(L, { placeholder: h, rows: 2 }),
generateButton: A || /* @__PURE__ */ e.createElement(
z,
{
svgIcon: O,
icon: "table-wizard",
type: "button",
title: m.toLanguageString(a, d[a])
},
m.toLanguageString(a, d[a])
)
}
),
/* @__PURE__ */ e.createElement(
q,
{
outputs: i,
showOutputRating: !0,
onCopy: y,
onOutputRating: C,
outputCard: V || { body: H }
}
)
);
};
export {
F as GridAIPrompt
};