UNPKG

@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

43 lines (42 loc) 1.93 kB
/** * @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 i from "react"; import { Keys as l } from "@progress/kendo-react-common"; class a extends i.Component { constructor() { super(...arguments), this.state = { selectedItemIndex: null }, this.onRequestContainerSelection = () => this.props.onRequestSelection(this.props.group.selectionIndex), this.onKeyDown = (t) => { let e = null, n, s; this.isKeyboardNavigationLeftRight ? (n = l.left, s = l.right) : (n = l.up, s = l.down), t.keyCode === n ? e = this.navigate(!1) : t.keyCode === s && (e = this.navigate(!0)), e !== null && (t.preventDefault(), t.stopPropagation()); }; } static getDerivedStateFromProps(t, e) { return !t.selected && e.selectedItemIndex !== null ? { selectedItemIndex: null } : t.selected && e.selectedItemIndex === null ? { selectedItemIndex: 0 } : null; } navigate(t, e = 0) { let n = null; const s = this.state.selectedItemIndex; return t ? s === null ? n = e : s < this.getLastSelectionIndex() && (n = s + 1) : s === null ? n = 0 : s > 0 && (n = s - 1), n !== null && this.setState({ selectedItemIndex: n }), n; } get isKeyboardNavigationLeftRight() { return !0; } getLastSelectionIndex() { let t = -1; if (this.props.group.type === "action-group") { const e = this.props.group; t = e.actions ? e.actions.length - 1 : -1; } else if (this.props.group.type === "attachment-group") { const e = this.props.group; t = e.attachments ? e.attachments.length - 1 : -1; } return t; } } export { a as SelectableItemsContainer };