-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathStarterPromptsToolbar.tsx
More file actions
41 lines (34 loc) · 1.57 KB
/
StarterPromptsToolbar.tsx
File metadata and controls
41 lines (34 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import { hooks } from 'botframework-webchat';
import { type DirectLineCardAction } from 'botframework-webchat/internal';
import cx from 'classnames';
import React, { memo } from 'react';
import { useStyles } from '../../styles/index.js';
import StarterPromptsCardAction from './StarterPromptsCardAction.js';
import styles from './StarterPromptsToolbar.module.css';
const { useUIState } = hooks;
type Props = Readonly<{
cardActions: readonly DirectLineCardAction[];
className?: string | undefined;
}>;
const StarterPromptsToolbar = ({ cardActions, className }: Props) => {
const classNames = useStyles(styles);
const [uiState] = useUIState();
return (
// TODO: Accessibility-wise, this should be role="toolbar" with keyboard navigation.
<div className={cx(className, classNames['pre-chat-message-activity__card-action-toolbar'])}>
<div className={classNames['pre-chat-message-activity__card-action-toolbar-grid']}>
{uiState !== 'blueprint' &&
cardActions
.filter<DirectLineCardAction & { type: 'messageBack' }>(
(card: DirectLineCardAction): card is DirectLineCardAction & { type: 'messageBack' } =>
card.type === 'messageBack'
)
// There is no other usable keys in card actions.
// eslint-disable-next-line react/no-array-index-key
.map((cardAction, index) => <StarterPromptsCardAction key={index} messageBackAction={cardAction} />)}
</div>
</div>
);
};
StarterPromptsToolbar.displayName = 'StarterPromptsToolbar';
export default memo(StarterPromptsToolbar);