@progress/kendo-react-conversational-ui
Version:
React Chat component allows the user to participate in chat sessions with users or chat bots. KendoReact Conversational UI components
57 lines (56 loc) • 1.85 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 n from "react";
import { Keys as d, classNames as x } from "@progress/kendo-react-common";
import b from "./Action.mjs";
const A = (m) => {
var f;
const { group: s, onActionExecute: p, selected: c, onRequestSelection: u } = m, [e, a] = n.useState(null);
n.useEffect(() => {
!c && e !== null ? a(null) : c && e === null && a(0);
}, [c, e]);
const r = n.useCallback(() => s.actions ? s.actions.length - 1 : -1, [s.actions]), i = n.useCallback(
(t, o = 0) => {
let l = null;
return t ? e === null ? l = o : e < r() && (l = e + 1) : e === null ? l = 0 : e > 0 && (l = e - 1), l !== null && a(l), l;
},
[e, r]
), C = n.useCallback(() => {
u(s.selectionIndex);
}, [u, s.selectionIndex]), g = n.useCallback(
(t) => {
let o = null;
const l = d.left, I = d.right;
t.keyCode === l ? o = i(!1) : t.keyCode === I && (o = i(!0)), o !== null && (t.preventDefault(), t.stopPropagation());
},
[i]
), k = n.useCallback(() => x("k-suggestion-group"), []);
return /* @__PURE__ */ n.createElement(
"div",
{
className: k(),
onClick: C,
onKeyDown: g,
role: "toolbar",
tabIndex: 0,
"aria-label": "Action group"
},
(f = s.actions) == null ? void 0 : f.map((t, o) => /* @__PURE__ */ n.createElement(
b,
{
item: t,
onActionExecute: p,
selected: o === e,
key: t.value
}
))
);
};
export {
A as default
};