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

9 lines (8 loc) 1.97 kB
/** * @license *------------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the package root for more information *------------------------------------------------------------------------------------------- */ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react"),o=require("@progress/kendo-react-common");function i(l){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(l){for(const e in l)if(e!=="default"){const n=Object.getOwnPropertyDescriptor(l,e);Object.defineProperty(t,e,n.get?n:{enumerable:!0,get:()=>l[e]})}}return t.default=l,Object.freeze(t)}const a=i(r);class c extends a.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=o.Keys.left,s=o.Keys.right):(n=o.Keys.up,s=o.Keys.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}}exports.SelectableItemsContainer=c;