@patternfly/chatbot 2.1.0-prerelease.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/@types/index.d.ts +9 -0
- package/dist/cjs/AttachMenu/AttachMenu.d.ts +29 -0
- package/dist/cjs/AttachMenu/AttachMenu.js +33 -0
- package/dist/cjs/AttachMenu/index.d.ts +2 -0
- package/dist/cjs/AttachMenu/index.js +23 -0
- package/dist/cjs/AttachmentEdit/AttachmentEdit.d.ts +22 -0
- package/dist/cjs/AttachmentEdit/AttachmentEdit.js +25 -0
- package/dist/cjs/AttachmentEdit/index.d.ts +2 -0
- package/dist/cjs/AttachmentEdit/index.js +23 -0
- package/dist/cjs/Chatbot/Chatbot.d.ts +23 -0
- package/dist/cjs/Chatbot/Chatbot.js +49 -0
- package/dist/cjs/Chatbot/index.d.ts +2 -0
- package/dist/cjs/Chatbot/index.js +23 -0
- package/dist/cjs/ChatbotAlert/ChatbotAlert.d.ts +8 -0
- package/dist/cjs/ChatbotAlert/ChatbotAlert.js +28 -0
- package/dist/cjs/ChatbotAlert/index.d.ts +2 -0
- package/dist/cjs/ChatbotAlert/index.js +23 -0
- package/dist/cjs/ChatbotContent/ChatbotContent.d.ts +9 -0
- package/dist/cjs/ChatbotContent/ChatbotContent.js +27 -0
- package/dist/cjs/ChatbotContent/index.d.ts +2 -0
- package/dist/cjs/ChatbotContent/index.js +23 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +14 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +22 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +52 -0
- package/dist/cjs/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +83 -0
- package/dist/cjs/ChatbotConversationHistoryNav/index.d.ts +3 -0
- package/dist/cjs/ChatbotConversationHistoryNav/index.js +24 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.d.ts +9 -0
- package/dist/cjs/ChatbotFooter/ChatbotFooter.js +35 -0
- package/dist/cjs/ChatbotFooter/ChatbotFootnote.d.ts +44 -0
- package/dist/cjs/ChatbotFooter/ChatbotFootnote.js +56 -0
- package/dist/cjs/ChatbotFooter/index.d.ts +3 -0
- package/dist/cjs/ChatbotFooter/index.js +24 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeader.d.ts +9 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeader.js +13 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.d.ts +9 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderActions.js +10 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.d.ts +9 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMain.js +10 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.d.ts +15 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderMenu.js +14 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.d.ts +14 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderOptionsDropdown.js +33 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.d.ts +18 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +33 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.d.ts +20 -0
- package/dist/cjs/ChatbotHeader/ChatbotHeaderTitle.js +33 -0
- package/dist/cjs/ChatbotHeader/index.d.ts +8 -0
- package/dist/cjs/ChatbotHeader/index.js +29 -0
- package/dist/cjs/ChatbotModal/ChatbotModal.d.ts +10 -0
- package/dist/cjs/ChatbotModal/ChatbotModal.js +34 -0
- package/dist/cjs/ChatbotModal/index.d.ts +2 -0
- package/dist/cjs/ChatbotModal/index.js +23 -0
- package/dist/cjs/ChatbotPopover/ChatbotPopover.d.ts +4 -0
- package/dist/cjs/ChatbotPopover/ChatbotPopover.js +29 -0
- package/dist/cjs/ChatbotPopover/index.d.ts +2 -0
- package/dist/cjs/ChatbotPopover/index.js +23 -0
- package/dist/cjs/ChatbotToggle/ChatbotToggle.d.ts +20 -0
- package/dist/cjs/ChatbotToggle/ChatbotToggle.js +35 -0
- package/dist/cjs/ChatbotToggle/index.d.ts +2 -0
- package/dist/cjs/ChatbotToggle/index.js +23 -0
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.d.ts +23 -0
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.js +40 -0
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +1 -0
- package/dist/cjs/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +49 -0
- package/dist/cjs/ChatbotWelcomePrompt/index.d.ts +2 -0
- package/dist/cjs/ChatbotWelcomePrompt/index.js +23 -0
- package/dist/cjs/CodeModal/CodeModal.d.ts +34 -0
- package/dist/cjs/CodeModal/CodeModal.js +105 -0
- package/dist/cjs/CodeModal/index.d.ts +2 -0
- package/dist/cjs/CodeModal/index.js +23 -0
- package/dist/cjs/FileDetails/FileDetails.d.ts +922 -0
- package/dist/cjs/FileDetails/FileDetails.js +954 -0
- package/dist/cjs/FileDetails/FileDetails.test.d.ts +1 -0
- package/dist/cjs/FileDetails/FileDetails.test.js +26 -0
- package/dist/cjs/FileDetails/index.d.ts +2 -0
- package/dist/cjs/FileDetails/index.js +23 -0
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.d.ts +21 -0
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.js +22 -0
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.d.ts +1 -0
- package/dist/cjs/FileDetailsLabel/FileDetailsLabel.test.js +61 -0
- package/dist/cjs/FileDetailsLabel/index.d.ts +2 -0
- package/dist/cjs/FileDetailsLabel/index.js +23 -0
- package/dist/cjs/FileDropZone/FileDropZone.d.ts +17 -0
- package/dist/cjs/FileDropZone/FileDropZone.js +28 -0
- package/dist/cjs/FileDropZone/FileDropZone.test.d.ts +1 -0
- package/dist/cjs/FileDropZone/FileDropZone.test.js +19 -0
- package/dist/cjs/FileDropZone/index.d.ts +2 -0
- package/dist/cjs/FileDropZone/index.js +23 -0
- package/dist/cjs/LoadingMessage/LoadingMessage.d.ts +6 -0
- package/dist/cjs/LoadingMessage/LoadingMessage.js +20 -0
- package/dist/cjs/LoadingMessage/LoadingMessage.test.d.ts +1 -0
- package/dist/cjs/LoadingMessage/LoadingMessage.test.js +20 -0
- package/dist/cjs/LoadingMessage/index.d.ts +2 -0
- package/dist/cjs/LoadingMessage/index.js +23 -0
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.d.ts +4 -0
- package/dist/cjs/Message/CodeBlockMessage/CodeBlockMessage.js +61 -0
- package/dist/cjs/Message/ListMessage/ListItemMessage.d.ts +4 -0
- package/dist/cjs/Message/ListMessage/ListItemMessage.js +12 -0
- package/dist/cjs/Message/ListMessage/OrderedListMessage.d.ts +4 -0
- package/dist/cjs/Message/ListMessage/OrderedListMessage.js +13 -0
- package/dist/cjs/Message/ListMessage/UnorderedListMessage.d.ts +4 -0
- package/dist/cjs/Message/ListMessage/UnorderedListMessage.js +13 -0
- package/dist/cjs/Message/Message.d.ts +65 -0
- package/dist/cjs/Message/Message.js +69 -0
- package/dist/cjs/Message/Message.test.d.ts +1 -0
- package/dist/cjs/Message/Message.test.js +239 -0
- package/dist/cjs/Message/MessageLoading.d.ts +5 -0
- package/dist/cjs/Message/MessageLoading.js +13 -0
- package/dist/cjs/Message/TextMessage/TextMessage.d.ts +4 -0
- package/dist/cjs/Message/TextMessage/TextMessage.js +27 -0
- package/dist/cjs/Message/index.d.ts +2 -0
- package/dist/cjs/Message/index.js +23 -0
- package/dist/cjs/MessageBar/AttachButton.d.ts +21 -0
- package/dist/cjs/MessageBar/AttachButton.js +38 -0
- package/dist/cjs/MessageBar/AttachButton.test.d.ts +1 -0
- package/dist/cjs/MessageBar/AttachButton.test.js +66 -0
- package/dist/cjs/MessageBar/MessageBar.d.ts +71 -0
- package/dist/cjs/MessageBar/MessageBar.js +112 -0
- package/dist/cjs/MessageBar/MessageBar.test.d.ts +1 -0
- package/dist/cjs/MessageBar/MessageBar.test.js +237 -0
- package/dist/cjs/MessageBar/MicrophoneButton.d.ts +21 -0
- package/dist/cjs/MessageBar/MicrophoneButton.js +74 -0
- package/dist/cjs/MessageBar/SendButton.d.ts +14 -0
- package/dist/cjs/MessageBar/SendButton.js +32 -0
- package/dist/cjs/MessageBar/SendButton.test.d.ts +1 -0
- package/dist/cjs/MessageBar/SendButton.test.js +54 -0
- package/dist/cjs/MessageBar/StopButton.d.ts +14 -0
- package/dist/cjs/MessageBar/StopButton.js +32 -0
- package/dist/cjs/MessageBar/StopButton.test.d.ts +1 -0
- package/dist/cjs/MessageBar/StopButton.test.js +54 -0
- package/dist/cjs/MessageBar/index.d.ts +5 -0
- package/dist/cjs/MessageBar/index.js +26 -0
- package/dist/cjs/MessageBox/JumpButton.d.ts +11 -0
- package/dist/cjs/MessageBox/JumpButton.js +17 -0
- package/dist/cjs/MessageBox/JumpButton.test.d.ts +1 -0
- package/dist/cjs/MessageBox/JumpButton.test.js +39 -0
- package/dist/cjs/MessageBox/MessageBox.d.ts +17 -0
- package/dist/cjs/MessageBox/MessageBox.js +74 -0
- package/dist/cjs/MessageBox/index.d.ts +3 -0
- package/dist/cjs/MessageBox/index.js +24 -0
- package/dist/cjs/PreviewAttachment/PreviewAttachment.d.ts +22 -0
- package/dist/cjs/PreviewAttachment/PreviewAttachment.js +25 -0
- package/dist/cjs/PreviewAttachment/index.d.ts +2 -0
- package/dist/cjs/PreviewAttachment/index.js +23 -0
- package/dist/cjs/ResponseActions/ResponseActionButton.d.ts +20 -0
- package/dist/cjs/ResponseActions/ResponseActionButton.js +12 -0
- package/dist/cjs/ResponseActions/ResponseActions.d.ts +30 -0
- package/dist/cjs/ResponseActions/ResponseActions.js +36 -0
- package/dist/cjs/ResponseActions/ResponseActions.test.d.ts +1 -0
- package/dist/cjs/ResponseActions/ResponseActions.test.js +67 -0
- package/dist/cjs/ResponseActions/index.d.ts +2 -0
- package/dist/cjs/ResponseActions/index.js +23 -0
- package/dist/cjs/SourceDetailsMenuItem/SourceDetailsMenuItem.d.ts +11 -0
- package/dist/cjs/SourceDetailsMenuItem/SourceDetailsMenuItem.js +31 -0
- package/dist/cjs/SourceDetailsMenuItem/index.d.ts +2 -0
- package/dist/cjs/SourceDetailsMenuItem/index.js +23 -0
- package/dist/cjs/SourcesCard/SourcesCard.d.ts +34 -0
- package/dist/cjs/SourcesCard/SourcesCard.js +68 -0
- package/dist/cjs/SourcesCard/SourcesCard.test.d.ts +1 -0
- package/dist/cjs/SourcesCard/SourcesCard.test.js +167 -0
- package/dist/cjs/SourcesCard/index.d.ts +2 -0
- package/dist/cjs/SourcesCard/index.js +23 -0
- package/dist/cjs/index.d.ts +48 -0
- package/dist/cjs/index.js +93 -0
- package/dist/css/main.css +1583 -0
- package/dist/css/main.css.map +1 -0
- package/dist/dynamic/AttachMenu/package.json +1 -0
- package/dist/dynamic/AttachmentEdit/package.json +1 -0
- package/dist/dynamic/Chatbot/package.json +1 -0
- package/dist/dynamic/ChatbotAlert/package.json +1 -0
- package/dist/dynamic/ChatbotContent/package.json +1 -0
- package/dist/dynamic/ChatbotConversationHistoryNav/package.json +1 -0
- package/dist/dynamic/ChatbotFooter/package.json +1 -0
- package/dist/dynamic/ChatbotHeader/package.json +1 -0
- package/dist/dynamic/ChatbotModal/package.json +1 -0
- package/dist/dynamic/ChatbotPopover/package.json +1 -0
- package/dist/dynamic/ChatbotToggle/package.json +1 -0
- package/dist/dynamic/ChatbotWelcomePrompt/package.json +1 -0
- package/dist/dynamic/CodeModal/package.json +1 -0
- package/dist/dynamic/FileDetails/package.json +1 -0
- package/dist/dynamic/FileDetailsLabel/package.json +1 -0
- package/dist/dynamic/FileDropZone/package.json +1 -0
- package/dist/dynamic/LoadingMessage/package.json +1 -0
- package/dist/dynamic/Message/package.json +1 -0
- package/dist/dynamic/MessageBar/package.json +1 -0
- package/dist/dynamic/MessageBox/package.json +1 -0
- package/dist/dynamic/PreviewAttachment/package.json +1 -0
- package/dist/dynamic/ResponseActions/package.json +1 -0
- package/dist/dynamic/SourceDetailsMenuItem/package.json +1 -0
- package/dist/dynamic/SourcesCard/package.json +1 -0
- package/dist/esm/AttachMenu/AttachMenu.d.ts +29 -0
- package/dist/esm/AttachMenu/AttachMenu.js +26 -0
- package/dist/esm/AttachMenu/index.d.ts +2 -0
- package/dist/esm/AttachMenu/index.js +2 -0
- package/dist/esm/AttachmentEdit/AttachmentEdit.d.ts +22 -0
- package/dist/esm/AttachmentEdit/AttachmentEdit.js +18 -0
- package/dist/esm/AttachmentEdit/index.d.ts +2 -0
- package/dist/esm/AttachmentEdit/index.js +2 -0
- package/dist/esm/Chatbot/Chatbot.d.ts +23 -0
- package/dist/esm/Chatbot/Chatbot.js +43 -0
- package/dist/esm/Chatbot/index.d.ts +2 -0
- package/dist/esm/Chatbot/index.js +2 -0
- package/dist/esm/ChatbotAlert/ChatbotAlert.d.ts +8 -0
- package/dist/esm/ChatbotAlert/ChatbotAlert.js +21 -0
- package/dist/esm/ChatbotAlert/index.d.ts +2 -0
- package/dist/esm/ChatbotAlert/index.js +2 -0
- package/dist/esm/ChatbotContent/ChatbotContent.d.ts +9 -0
- package/dist/esm/ChatbotContent/ChatbotContent.js +20 -0
- package/dist/esm/ChatbotContent/index.d.ts +2 -0
- package/dist/esm/ChatbotContent/index.js +2 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.d.ts +14 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.js +15 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.d.ts +52 -0
- package/dist/esm/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.js +76 -0
- package/dist/esm/ChatbotConversationHistoryNav/index.d.ts +3 -0
- package/dist/esm/ChatbotConversationHistoryNav/index.js +3 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.d.ts +9 -0
- package/dist/esm/ChatbotFooter/ChatbotFooter.js +28 -0
- package/dist/esm/ChatbotFooter/ChatbotFootnote.d.ts +44 -0
- package/dist/esm/ChatbotFooter/ChatbotFootnote.js +49 -0
- package/dist/esm/ChatbotFooter/index.d.ts +3 -0
- package/dist/esm/ChatbotFooter/index.js +3 -0
- package/dist/esm/ChatbotHeader/ChatbotHeader.d.ts +9 -0
- package/dist/esm/ChatbotHeader/ChatbotHeader.js +6 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.d.ts +9 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderActions.js +3 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.d.ts +9 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMain.js +3 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.d.ts +15 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderMenu.js +8 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.d.ts +14 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderOptionsDropdown.js +26 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.d.ts +18 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderSelectorDropdown.js +26 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.d.ts +20 -0
- package/dist/esm/ChatbotHeader/ChatbotHeaderTitle.js +26 -0
- package/dist/esm/ChatbotHeader/index.d.ts +8 -0
- package/dist/esm/ChatbotHeader/index.js +8 -0
- package/dist/esm/ChatbotModal/ChatbotModal.d.ts +10 -0
- package/dist/esm/ChatbotModal/ChatbotModal.js +27 -0
- package/dist/esm/ChatbotModal/index.d.ts +2 -0
- package/dist/esm/ChatbotModal/index.js +2 -0
- package/dist/esm/ChatbotPopover/ChatbotPopover.d.ts +4 -0
- package/dist/esm/ChatbotPopover/ChatbotPopover.js +22 -0
- package/dist/esm/ChatbotPopover/index.d.ts +2 -0
- package/dist/esm/ChatbotPopover/index.js +2 -0
- package/dist/esm/ChatbotToggle/ChatbotToggle.d.ts +20 -0
- package/dist/esm/ChatbotToggle/ChatbotToggle.js +30 -0
- package/dist/esm/ChatbotToggle/index.d.ts +2 -0
- package/dist/esm/ChatbotToggle/index.js +2 -0
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.d.ts +23 -0
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.js +33 -0
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.d.ts +1 -0
- package/dist/esm/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.js +44 -0
- package/dist/esm/ChatbotWelcomePrompt/index.d.ts +2 -0
- package/dist/esm/ChatbotWelcomePrompt/index.js +2 -0
- package/dist/esm/CodeModal/CodeModal.d.ts +34 -0
- package/dist/esm/CodeModal/CodeModal.js +75 -0
- package/dist/esm/CodeModal/index.d.ts +2 -0
- package/dist/esm/CodeModal/index.js +2 -0
- package/dist/esm/FileDetails/FileDetails.d.ts +922 -0
- package/dist/esm/FileDetails/FileDetails.js +947 -0
- package/dist/esm/FileDetails/FileDetails.test.d.ts +1 -0
- package/dist/esm/FileDetails/FileDetails.test.js +21 -0
- package/dist/esm/FileDetails/index.d.ts +2 -0
- package/dist/esm/FileDetails/index.js +2 -0
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.d.ts +21 -0
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.js +15 -0
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.d.ts +1 -0
- package/dist/esm/FileDetailsLabel/FileDetailsLabel.test.js +56 -0
- package/dist/esm/FileDetailsLabel/index.d.ts +2 -0
- package/dist/esm/FileDetailsLabel/index.js +2 -0
- package/dist/esm/FileDropZone/FileDropZone.d.ts +17 -0
- package/dist/esm/FileDropZone/FileDropZone.js +23 -0
- package/dist/esm/FileDropZone/FileDropZone.test.d.ts +1 -0
- package/dist/esm/FileDropZone/FileDropZone.test.js +14 -0
- package/dist/esm/FileDropZone/index.d.ts +2 -0
- package/dist/esm/FileDropZone/index.js +2 -0
- package/dist/esm/LoadingMessage/LoadingMessage.d.ts +6 -0
- package/dist/esm/LoadingMessage/LoadingMessage.js +13 -0
- package/dist/esm/LoadingMessage/LoadingMessage.test.d.ts +1 -0
- package/dist/esm/LoadingMessage/LoadingMessage.test.js +15 -0
- package/dist/esm/LoadingMessage/index.d.ts +2 -0
- package/dist/esm/LoadingMessage/index.js +2 -0
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.d.ts +4 -0
- package/dist/esm/Message/CodeBlockMessage/CodeBlockMessage.js +56 -0
- package/dist/esm/Message/ListMessage/ListItemMessage.d.ts +4 -0
- package/dist/esm/Message/ListMessage/ListItemMessage.js +7 -0
- package/dist/esm/Message/ListMessage/OrderedListMessage.d.ts +4 -0
- package/dist/esm/Message/ListMessage/OrderedListMessage.js +8 -0
- package/dist/esm/Message/ListMessage/UnorderedListMessage.d.ts +4 -0
- package/dist/esm/Message/ListMessage/UnorderedListMessage.js +8 -0
- package/dist/esm/Message/Message.d.ts +65 -0
- package/dist/esm/Message/Message.js +62 -0
- package/dist/esm/Message/Message.test.d.ts +1 -0
- package/dist/esm/Message/Message.test.js +234 -0
- package/dist/esm/Message/MessageLoading.d.ts +5 -0
- package/dist/esm/Message/MessageLoading.js +8 -0
- package/dist/esm/Message/TextMessage/TextMessage.d.ts +4 -0
- package/dist/esm/Message/TextMessage/TextMessage.js +22 -0
- package/dist/esm/Message/index.d.ts +2 -0
- package/dist/esm/Message/index.js +2 -0
- package/dist/esm/MessageBar/AttachButton.d.ts +21 -0
- package/dist/esm/MessageBar/AttachButton.js +32 -0
- package/dist/esm/MessageBar/AttachButton.test.d.ts +1 -0
- package/dist/esm/MessageBar/AttachButton.test.js +61 -0
- package/dist/esm/MessageBar/MessageBar.d.ts +71 -0
- package/dist/esm/MessageBar/MessageBar.js +105 -0
- package/dist/esm/MessageBar/MessageBar.test.d.ts +1 -0
- package/dist/esm/MessageBar/MessageBar.test.js +232 -0
- package/dist/esm/MessageBar/MicrophoneButton.d.ts +21 -0
- package/dist/esm/MessageBar/MicrophoneButton.js +67 -0
- package/dist/esm/MessageBar/SendButton.d.ts +14 -0
- package/dist/esm/MessageBar/SendButton.js +25 -0
- package/dist/esm/MessageBar/SendButton.test.d.ts +1 -0
- package/dist/esm/MessageBar/SendButton.test.js +49 -0
- package/dist/esm/MessageBar/StopButton.d.ts +14 -0
- package/dist/esm/MessageBar/StopButton.js +25 -0
- package/dist/esm/MessageBar/StopButton.test.d.ts +1 -0
- package/dist/esm/MessageBar/StopButton.test.js +49 -0
- package/dist/esm/MessageBar/index.d.ts +5 -0
- package/dist/esm/MessageBar/index.js +5 -0
- package/dist/esm/MessageBox/JumpButton.d.ts +11 -0
- package/dist/esm/MessageBox/JumpButton.js +12 -0
- package/dist/esm/MessageBox/JumpButton.test.d.ts +1 -0
- package/dist/esm/MessageBox/JumpButton.test.js +34 -0
- package/dist/esm/MessageBox/MessageBox.d.ts +17 -0
- package/dist/esm/MessageBox/MessageBox.js +68 -0
- package/dist/esm/MessageBox/index.d.ts +3 -0
- package/dist/esm/MessageBox/index.js +3 -0
- package/dist/esm/PreviewAttachment/PreviewAttachment.d.ts +22 -0
- package/dist/esm/PreviewAttachment/PreviewAttachment.js +18 -0
- package/dist/esm/PreviewAttachment/index.d.ts +2 -0
- package/dist/esm/PreviewAttachment/index.js +2 -0
- package/dist/esm/ResponseActions/ResponseActionButton.d.ts +20 -0
- package/dist/esm/ResponseActions/ResponseActionButton.js +5 -0
- package/dist/esm/ResponseActions/ResponseActions.d.ts +30 -0
- package/dist/esm/ResponseActions/ResponseActions.js +29 -0
- package/dist/esm/ResponseActions/ResponseActions.test.d.ts +1 -0
- package/dist/esm/ResponseActions/ResponseActions.test.js +62 -0
- package/dist/esm/ResponseActions/index.d.ts +2 -0
- package/dist/esm/ResponseActions/index.js +2 -0
- package/dist/esm/SourceDetailsMenuItem/SourceDetailsMenuItem.d.ts +11 -0
- package/dist/esm/SourceDetailsMenuItem/SourceDetailsMenuItem.js +24 -0
- package/dist/esm/SourceDetailsMenuItem/index.d.ts +2 -0
- package/dist/esm/SourceDetailsMenuItem/index.js +2 -0
- package/dist/esm/SourcesCard/SourcesCard.d.ts +34 -0
- package/dist/esm/SourcesCard/SourcesCard.js +63 -0
- package/dist/esm/SourcesCard/SourcesCard.test.d.ts +1 -0
- package/dist/esm/SourcesCard/SourcesCard.test.js +162 -0
- package/dist/esm/SourcesCard/index.d.ts +2 -0
- package/dist/esm/SourcesCard/index.js +2 -0
- package/dist/esm/index.d.ts +48 -0
- package/dist/esm/index.js +49 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/generate-fed-package-json.js +75 -0
- package/generate-index.js +42 -0
- package/package.json +79 -0
- package/patternfly-a11y.config.js +28 -0
- package/patternfly-docs/content/extensions/chatbot/about-chatbot.md +29 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachMenu.tsx +149 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentEdit.tsx +26 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/AttachmentError.tsx +13 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/BotMessage.tsx +87 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/FileDetails.tsx +4 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/FileDetailsLabel.tsx +54 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/FileDropZone.tsx +60 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithAttachment.tsx +75 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithCustomResponseActions.tsx +39 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithQuickResponses.tsx +44 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithResponseActions.tsx +25 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/MessageWithSources.tsx +118 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/Messages.md +171 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PaperclipIcon.svg +10 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/PreviewAttachment.tsx +25 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/UserMessage.tsx +37 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/patternfly_avatar.jpg +0 -0
- package/patternfly-docs/content/extensions/chatbot/examples/Messages/user_avatar.jpg +0 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotContainer.tsx +66 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotFooter.tsx +14 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotFootnote.tsx +26 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderBasic.tsx +189 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawer.tsx +93 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderDrawerWithActions.tsx +75 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotHeaderTitle.tsx +50 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotMessageBar.tsx +8 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotMessageBarAttach.tsx +148 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotMessageBarStop.tsx +10 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotModal.tsx +84 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotToggleBasic.tsx +13 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotWelcomeInteraction.tsx +144 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/ChatbotWelcomePrompt.tsx +38 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/CustomClosedIcon.tsx +89 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/PF-HorizontalLogo-Color.svg +29 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/PF-HorizontalLogo-Reverse.svg +28 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/PF-IconLogo-Color.svg +17 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/PF-IconLogo-Reverse.svg +16 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/SkipToContent.tsx +40 -0
- package/patternfly-docs/content/extensions/chatbot/examples/UI/UI.md +336 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/AttachmentDemos.md +99 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.md +105 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/Chatbot.tsx +473 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachment.tsx +278 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/ChatbotAttachmentMenu.tsx +268 -0
- package/patternfly-docs/content/extensions/chatbot/examples/demos/EmbeddedChatbot.tsx +437 -0
- package/patternfly-docs/pages/index.js +27 -0
- package/patternfly-docs/patternfly-docs.config.js +8 -0
- package/patternfly-docs/patternfly-docs.css.js +9 -0
- package/patternfly-docs/patternfly-docs.routes.js +12 -0
- package/patternfly-docs/patternfly-docs.source.js +24 -0
- package/release.config.js +18 -0
- package/src/AttachMenu/AttachMenu.scss +62 -0
- package/src/AttachMenu/AttachMenu.tsx +81 -0
- package/src/AttachMenu/index.ts +3 -0
- package/src/AttachmentEdit/AttachmentEdit.tsx +63 -0
- package/src/AttachmentEdit/index.ts +3 -0
- package/src/Chatbot/Chatbot.scss +89 -0
- package/src/Chatbot/Chatbot.tsx +81 -0
- package/src/Chatbot/index.ts +3 -0
- package/src/ChatbotAlert/ChatbotAlert.scss +5 -0
- package/src/ChatbotAlert/ChatbotAlert.tsx +32 -0
- package/src/ChatbotAlert/index.ts +3 -0
- package/src/ChatbotContent/ChatbotContent.scss +23 -0
- package/src/ChatbotContent/ChatbotContent.tsx +23 -0
- package/src/ChatbotContent/index.ts +3 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryDropdown.tsx +62 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.scss +166 -0
- package/src/ChatbotConversationHistoryNav/ChatbotConversationHistoryNav.tsx +217 -0
- package/src/ChatbotConversationHistoryNav/index.ts +4 -0
- package/src/ChatbotFooter/ChatbotFooter.scss +54 -0
- package/src/ChatbotFooter/ChatbotFooter.tsx +33 -0
- package/src/ChatbotFooter/ChatbotFootnote.scss +12 -0
- package/src/ChatbotFooter/ChatbotFootnote.tsx +135 -0
- package/src/ChatbotFooter/index.ts +4 -0
- package/src/ChatbotHeader/ChatbotHeader.scss +140 -0
- package/src/ChatbotHeader/ChatbotHeader.tsx +22 -0
- package/src/ChatbotHeader/ChatbotHeaderActions.tsx +15 -0
- package/src/ChatbotHeader/ChatbotHeaderMain.tsx +15 -0
- package/src/ChatbotHeader/ChatbotHeaderMenu.tsx +48 -0
- package/src/ChatbotHeader/ChatbotHeaderOptionsDropdown.tsx +73 -0
- package/src/ChatbotHeader/ChatbotHeaderSelectorDropdown.tsx +68 -0
- package/src/ChatbotHeader/ChatbotHeaderTitle.tsx +57 -0
- package/src/ChatbotHeader/index.ts +9 -0
- package/src/ChatbotModal/ChatbotModal.scss +93 -0
- package/src/ChatbotModal/ChatbotModal.tsx +43 -0
- package/src/ChatbotModal/index.ts +3 -0
- package/src/ChatbotPopover/ChatbotPopover.scss +27 -0
- package/src/ChatbotPopover/ChatbotPopover.tsx +15 -0
- package/src/ChatbotPopover/index.ts +3 -0
- package/src/ChatbotToggle/ChatbotToggle.scss +26 -0
- package/src/ChatbotToggle/ChatbotToggle.tsx +80 -0
- package/src/ChatbotToggle/index.ts +3 -0
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.scss +48 -0
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.test.tsx +64 -0
- package/src/ChatbotWelcomePrompt/ChatbotWelcomePrompt.tsx +66 -0
- package/src/ChatbotWelcomePrompt/__snapshots__/ChatbotWelcomePrompt.test.tsx.snap +29 -0
- package/src/ChatbotWelcomePrompt/index.ts +3 -0
- package/src/CodeModal/CodeModal.scss +76 -0
- package/src/CodeModal/CodeModal.tsx +153 -0
- package/src/CodeModal/index.ts +3 -0
- package/src/FileDetails/FileDetails.scss +25 -0
- package/src/FileDetails/FileDetails.test.tsx +23 -0
- package/src/FileDetails/FileDetails.tsx +990 -0
- package/src/FileDetails/__snapshots__/FileDetails.test.tsx.snap +74 -0
- package/src/FileDetails/index.ts +2 -0
- package/src/FileDetailsLabel/FileDetailsLabel.scss +66 -0
- package/src/FileDetailsLabel/FileDetailsLabel.test.tsx +48 -0
- package/src/FileDetailsLabel/FileDetailsLabel.tsx +66 -0
- package/src/FileDetailsLabel/__snapshots__/FileDetailsLabel.test.tsx.snap +90 -0
- package/src/FileDetailsLabel/index.ts +2 -0
- package/src/FileDropZone/FileDropZone.scss +36 -0
- package/src/FileDropZone/FileDropZone.test.tsx +15 -0
- package/src/FileDropZone/FileDropZone.tsx +56 -0
- package/src/FileDropZone/__snapshots__/FileDropZone.test.tsx.snap +18 -0
- package/src/FileDropZone/index.ts +3 -0
- package/src/LoadingMessage/LoadingMessage.test.tsx +16 -0
- package/src/LoadingMessage/LoadingMessage.tsx +27 -0
- package/src/LoadingMessage/__snapshots__/LoadingMessage.test.tsx.snap +52 -0
- package/src/LoadingMessage/index.ts +3 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.scss +82 -0
- package/src/Message/CodeBlockMessage/CodeBlockMessage.tsx +88 -0
- package/src/Message/ListMessage/ListItemMessage.tsx +11 -0
- package/src/Message/ListMessage/ListMessage.scss +25 -0
- package/src/Message/ListMessage/OrderedListMessage.tsx +17 -0
- package/src/Message/ListMessage/UnorderedListMessage.tsx +15 -0
- package/src/Message/Message.scss +118 -0
- package/src/Message/Message.test.tsx +281 -0
- package/src/Message/Message.tsx +181 -0
- package/src/Message/MessageLoading.scss +53 -0
- package/src/Message/MessageLoading.tsx +15 -0
- package/src/Message/TextMessage/TextMessage.scss +51 -0
- package/src/Message/TextMessage/TextMessage.tsx +17 -0
- package/src/Message/index.ts +3 -0
- package/src/MessageBar/AttachButton.scss +20 -0
- package/src/MessageBar/AttachButton.test.tsx +53 -0
- package/src/MessageBar/AttachButton.tsx +81 -0
- package/src/MessageBar/MessageBar.scss +77 -0
- package/src/MessageBar/MessageBar.test.tsx +318 -0
- package/src/MessageBar/MessageBar.tsx +252 -0
- package/src/MessageBar/MicrophoneButton.scss +48 -0
- package/src/MessageBar/MicrophoneButton.tsx +114 -0
- package/src/MessageBar/SendButton.scss +29 -0
- package/src/MessageBar/SendButton.test.tsx +43 -0
- package/src/MessageBar/SendButton.tsx +54 -0
- package/src/MessageBar/StopButton.scss +22 -0
- package/src/MessageBar/StopButton.test.tsx +42 -0
- package/src/MessageBar/StopButton.tsx +57 -0
- package/src/MessageBar/index.ts +6 -0
- package/src/MessageBox/JumpButton.scss +46 -0
- package/src/MessageBox/JumpButton.test.tsx +26 -0
- package/src/MessageBox/JumpButton.tsx +37 -0
- package/src/MessageBox/MessageBox.scss +36 -0
- package/src/MessageBox/MessageBox.tsx +114 -0
- package/src/MessageBox/index.ts +4 -0
- package/src/PreviewAttachment/PreviewAttachment.tsx +67 -0
- package/src/PreviewAttachment/index.ts +3 -0
- package/src/ResponseActions/ResponseActionButton.tsx +56 -0
- package/src/ResponseActions/ResponseActions.scss +26 -0
- package/src/ResponseActions/ResponseActions.test.tsx +59 -0
- package/src/ResponseActions/ResponseActions.tsx +115 -0
- package/src/ResponseActions/index.ts +3 -0
- package/src/SourceDetailsMenuItem/SourceDetailsMenuItem.scss +33 -0
- package/src/SourceDetailsMenuItem/SourceDetailsMenuItem.tsx +36 -0
- package/src/SourceDetailsMenuItem/index.ts +2 -0
- package/src/SourcesCard/SourcesCard.scss +74 -0
- package/src/SourcesCard/SourcesCard.test.tsx +238 -0
- package/src/SourcesCard/SourcesCard.tsx +159 -0
- package/src/SourcesCard/__snapshots__/SourcesCard.test.tsx.snap +34 -0
- package/src/SourcesCard/index.ts +3 -0
- package/src/index.ts +73 -0
- package/src/main.scss +89 -0
- package/tsconfig.cjs.json +8 -0
- package/tsconfig.json +73 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Chatbot Main - Messages
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import JumpButton from './JumpButton';
|
|
6
|
+
const MessageBoxBase = ({ announcement, ariaLabel = 'Scrollable message log', children, innerRef, className, position = 'top' }) => {
|
|
7
|
+
const [atTop, setAtTop] = React.useState(false);
|
|
8
|
+
const [atBottom, setAtBottom] = React.useState(true);
|
|
9
|
+
const [isOverflowing, setIsOverflowing] = React.useState(false);
|
|
10
|
+
const defaultRef = React.useRef(null);
|
|
11
|
+
let messageBoxRef;
|
|
12
|
+
if (innerRef) {
|
|
13
|
+
messageBoxRef = innerRef;
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
messageBoxRef = defaultRef;
|
|
17
|
+
}
|
|
18
|
+
// Configure handlers
|
|
19
|
+
const handleScroll = React.useCallback(() => {
|
|
20
|
+
const element = messageBoxRef.current;
|
|
21
|
+
if (element) {
|
|
22
|
+
const { scrollTop, scrollHeight, clientHeight } = element;
|
|
23
|
+
setAtTop(scrollTop === 0);
|
|
24
|
+
setAtBottom(Math.round(scrollTop) + Math.round(clientHeight) >= Math.round(scrollHeight) - 1); // rounding means it could be within a pixel of the bottom
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
27
|
+
const checkOverflow = React.useCallback(() => {
|
|
28
|
+
const element = messageBoxRef.current;
|
|
29
|
+
if (element) {
|
|
30
|
+
const { scrollHeight, clientHeight } = element;
|
|
31
|
+
setIsOverflowing(scrollHeight >= clientHeight);
|
|
32
|
+
}
|
|
33
|
+
}, []);
|
|
34
|
+
const scrollToTop = React.useCallback(() => {
|
|
35
|
+
const element = messageBoxRef.current;
|
|
36
|
+
if (element) {
|
|
37
|
+
element.scrollTo({ top: 0, behavior: 'smooth' });
|
|
38
|
+
}
|
|
39
|
+
}, []);
|
|
40
|
+
const scrollToBottom = React.useCallback(() => {
|
|
41
|
+
const element = messageBoxRef.current;
|
|
42
|
+
if (element) {
|
|
43
|
+
element.scrollTo({ top: element.scrollHeight, behavior: 'smooth' });
|
|
44
|
+
}
|
|
45
|
+
}, []);
|
|
46
|
+
// Detect scroll position
|
|
47
|
+
React.useEffect(() => {
|
|
48
|
+
const element = messageBoxRef.current;
|
|
49
|
+
if (element) {
|
|
50
|
+
// Listen for scroll events
|
|
51
|
+
element.addEventListener('scroll', handleScroll);
|
|
52
|
+
// Check initial position and overflow
|
|
53
|
+
handleScroll();
|
|
54
|
+
checkOverflow();
|
|
55
|
+
return () => {
|
|
56
|
+
element.removeEventListener('scroll', handleScroll);
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}, [checkOverflow, handleScroll]);
|
|
60
|
+
return (React.createElement(React.Fragment, null,
|
|
61
|
+
React.createElement(JumpButton, { position: "top", isHidden: isOverflowing && atTop, onClick: scrollToTop }),
|
|
62
|
+
React.createElement("div", { role: "region", tabIndex: 0, "aria-label": ariaLabel, className: `pf-chatbot__messagebox ${position === 'bottom' && 'pf-chatbot__messagebox--bottom'} ${className !== null && className !== void 0 ? className : ''}`, ref: innerRef !== null && innerRef !== void 0 ? innerRef : messageBoxRef },
|
|
63
|
+
children,
|
|
64
|
+
React.createElement("div", { className: "pf-chatbot__messagebox-announcement", "aria-live": "polite" }, announcement)),
|
|
65
|
+
React.createElement(JumpButton, { position: "bottom", isHidden: isOverflowing && atBottom, onClick: scrollToBottom })));
|
|
66
|
+
};
|
|
67
|
+
export const MessageBox = React.forwardRef((props, ref) => (React.createElement(MessageBoxBase, Object.assign({ innerRef: ref }, props))));
|
|
68
|
+
export default MessageBox;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChatbotDisplayMode } from '../Chatbot';
|
|
3
|
+
export interface PreviewAttachmentProps {
|
|
4
|
+
/** Text shown in code editor */
|
|
5
|
+
code: string;
|
|
6
|
+
/** Filename, including extension, of file shown in modal */
|
|
7
|
+
fileName: string;
|
|
8
|
+
/** Function called when edit button is clicked */
|
|
9
|
+
onEdit: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
10
|
+
/** Function called when dismiss button is clicked */
|
|
11
|
+
onDismiss?: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
12
|
+
/** Function called when modal is toggled */
|
|
13
|
+
handleModalToggle: (event: React.MouseEvent | MouseEvent | KeyboardEvent) => void;
|
|
14
|
+
/** Whether modal is open */
|
|
15
|
+
isModalOpen: boolean;
|
|
16
|
+
/** Title of modal */
|
|
17
|
+
title?: string;
|
|
18
|
+
/** Display mode for the Chatbot parent; this influences the styles applied */
|
|
19
|
+
displayMode?: ChatbotDisplayMode;
|
|
20
|
+
}
|
|
21
|
+
export declare const PreviewAttachment: React.FunctionComponent<PreviewAttachmentProps>;
|
|
22
|
+
export default PreviewAttachment;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// Preview Attachment - Chatbot Code Snippet Viewer
|
|
3
|
+
// ============================================================================
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import CodeModal from '../CodeModal';
|
|
6
|
+
import { ChatbotDisplayMode } from '../Chatbot';
|
|
7
|
+
export const PreviewAttachment = ({ fileName, code, handleModalToggle, isModalOpen, onDismiss = undefined, onEdit, title = 'Preview attachment', displayMode = ChatbotDisplayMode.default }) => {
|
|
8
|
+
const handleEdit = (_event) => {
|
|
9
|
+
handleModalToggle(_event);
|
|
10
|
+
onEdit(_event);
|
|
11
|
+
};
|
|
12
|
+
const handleDismiss = (_event) => {
|
|
13
|
+
handleModalToggle(_event);
|
|
14
|
+
onDismiss && onDismiss(_event);
|
|
15
|
+
};
|
|
16
|
+
return (React.createElement(CodeModal, { codeEditorControlClassName: "pf-chatbot__code-modal--controls", code: code, fileName: fileName, handleModalToggle: handleModalToggle, isCopyEnabled: true, isLineNumbersVisible: false, isModalOpen: isModalOpen, onPrimaryAction: handleEdit, onSecondaryAction: handleDismiss, primaryActionBtn: "Edit", secondaryActionBtn: "Dismiss", title: title, isReadOnly: true, displayMode: displayMode }));
|
|
17
|
+
};
|
|
18
|
+
export default PreviewAttachment;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TooltipProps } from '@patternfly/react-core';
|
|
3
|
+
export interface ResponseActionButtonProps {
|
|
4
|
+
/** Aria-label for the button. Defaults to the value of the tooltipContent if none provided */
|
|
5
|
+
ariaLabel?: string;
|
|
6
|
+
/** Icon for the button */
|
|
7
|
+
icon: React.ReactNode;
|
|
8
|
+
/** On-click handler for the button */
|
|
9
|
+
onClick?: ((event: MouseEvent | React.MouseEvent<Element, MouseEvent> | KeyboardEvent) => void) | undefined;
|
|
10
|
+
/** Class name for the button */
|
|
11
|
+
className?: string;
|
|
12
|
+
/** Props to control if the attach button should be disabled */
|
|
13
|
+
isDisabled?: boolean;
|
|
14
|
+
/** Content shown in the tooltip */
|
|
15
|
+
tooltipContent?: string;
|
|
16
|
+
/** Props to control the PF Tooltip component */
|
|
17
|
+
tooltipProps?: TooltipProps;
|
|
18
|
+
}
|
|
19
|
+
export declare const ResponseActionButton: React.FunctionComponent<ResponseActionButtonProps>;
|
|
20
|
+
export default ResponseActionButton;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Button, Icon, Tooltip } from '@patternfly/react-core';
|
|
3
|
+
export const ResponseActionButton = ({ ariaLabel, className, icon, isDisabled, onClick, tooltipContent, tooltipProps }) => (React.createElement(Tooltip, Object.assign({ id: `pf-chatbot__tooltip-response-action-${tooltipContent}`, content: tooltipContent, position: "bottom", entryDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.entryDelay) || 0, exitDelay: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.exitDelay) || 0, distance: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.distance) || 8, animationDuration: (tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.animationDuration) || 0 }, tooltipProps),
|
|
4
|
+
React.createElement(Button, { variant: "plain", className: `pf-chatbot__button--response-action ${className !== null && className !== void 0 ? className : ''}`, "aria-label": ariaLabel !== null && ariaLabel !== void 0 ? ariaLabel : tooltipContent, icon: React.createElement(Icon, { isInline: true, size: "lg" }, icon), isDisabled: isDisabled, onClick: onClick, size: "sm" })));
|
|
5
|
+
export default ResponseActionButton;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { TooltipProps } from '@patternfly/react-core';
|
|
3
|
+
export interface ActionProps {
|
|
4
|
+
/** Aria-label for the button */
|
|
5
|
+
ariaLabel?: string;
|
|
6
|
+
/** On-click handler for the button */
|
|
7
|
+
onClick?: ((event: MouseEvent | React.MouseEvent<Element, MouseEvent> | KeyboardEvent) => void) | undefined;
|
|
8
|
+
/** Class name for the button */
|
|
9
|
+
className?: string;
|
|
10
|
+
/** Props to control if the attach button should be disabled */
|
|
11
|
+
isDisabled?: boolean;
|
|
12
|
+
/** Content shown in the tooltip */
|
|
13
|
+
tooltipContent?: string;
|
|
14
|
+
/** Props to control the PF Tooltip component */
|
|
15
|
+
tooltipProps?: TooltipProps;
|
|
16
|
+
/** Icon for custom response action */
|
|
17
|
+
icon?: React.ReactNode;
|
|
18
|
+
}
|
|
19
|
+
export interface ResponseActionProps {
|
|
20
|
+
/** Props for message actions, such as feedback (positive or negative), copy button, share, and listen */
|
|
21
|
+
actions: Record<string, ActionProps | undefined> & {
|
|
22
|
+
positive?: ActionProps;
|
|
23
|
+
negative?: ActionProps;
|
|
24
|
+
copy?: ActionProps;
|
|
25
|
+
share?: ActionProps;
|
|
26
|
+
listen?: ActionProps;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
export declare const ResponseActions: React.FunctionComponent<ResponseActionProps>;
|
|
30
|
+
export default ResponseActions;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { ExternalLinkAltIcon, VolumeUpIcon, OutlinedThumbsUpIcon, OutlinedThumbsDownIcon, OutlinedCopyIcon } from '@patternfly/react-icons';
|
|
14
|
+
import ResponseActionButton from './ResponseActionButton';
|
|
15
|
+
export const ResponseActions = ({ actions }) => {
|
|
16
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
17
|
+
const { positive, negative, copy, share, listen } = actions, additionalActions = __rest(actions, ["positive", "negative", "copy", "share", "listen"]);
|
|
18
|
+
return (React.createElement("div", { className: "pf-chatbot__response-actions" },
|
|
19
|
+
positive && (React.createElement(ResponseActionButton, { ariaLabel: (_a = positive.ariaLabel) !== null && _a !== void 0 ? _a : 'Good response', onClick: positive.onClick, className: positive.className, isDisabled: positive.isDisabled, tooltipContent: (_b = positive.tooltipContent) !== null && _b !== void 0 ? _b : 'Good response', tooltipProps: positive.tooltipProps, icon: React.createElement(OutlinedThumbsUpIcon, null) })),
|
|
20
|
+
negative && (React.createElement(ResponseActionButton, { ariaLabel: (_c = negative.ariaLabel) !== null && _c !== void 0 ? _c : 'Bad response', onClick: negative.onClick, className: negative.className, isDisabled: negative.isDisabled, tooltipContent: (_d = negative.tooltipContent) !== null && _d !== void 0 ? _d : 'Bad response', tooltipProps: negative.tooltipProps, icon: React.createElement(OutlinedThumbsDownIcon, null) })),
|
|
21
|
+
copy && (React.createElement(ResponseActionButton, { ariaLabel: (_e = copy.ariaLabel) !== null && _e !== void 0 ? _e : 'Copy', onClick: copy.onClick, className: copy.className, isDisabled: copy.isDisabled, tooltipContent: (_f = copy.tooltipContent) !== null && _f !== void 0 ? _f : 'Copy', tooltipProps: copy.tooltipProps, icon: React.createElement(OutlinedCopyIcon, null) })),
|
|
22
|
+
share && (React.createElement(ResponseActionButton, { ariaLabel: (_g = share.ariaLabel) !== null && _g !== void 0 ? _g : 'Share', onClick: share.onClick, className: share.className, isDisabled: share.isDisabled, tooltipContent: (_h = share.tooltipContent) !== null && _h !== void 0 ? _h : 'Share', tooltipProps: share.tooltipProps, icon: React.createElement(ExternalLinkAltIcon, null) })),
|
|
23
|
+
listen && (React.createElement(ResponseActionButton, { ariaLabel: (_j = listen.ariaLabel) !== null && _j !== void 0 ? _j : 'Listen', onClick: listen.onClick, className: listen.className, isDisabled: listen.isDisabled, tooltipContent: (_k = listen.tooltipContent) !== null && _k !== void 0 ? _k : 'Listen', tooltipProps: listen.tooltipProps, icon: React.createElement(VolumeUpIcon, null) })),
|
|
24
|
+
Object.keys(additionalActions).map((action) => {
|
|
25
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
26
|
+
return (React.createElement(ResponseActionButton, { key: action, ariaLabel: (_a = additionalActions[action]) === null || _a === void 0 ? void 0 : _a.ariaLabel, onClick: (_b = additionalActions[action]) === null || _b === void 0 ? void 0 : _b.onClick, className: (_c = additionalActions[action]) === null || _c === void 0 ? void 0 : _c.className, isDisabled: (_d = additionalActions[action]) === null || _d === void 0 ? void 0 : _d.isDisabled, tooltipContent: (_e = additionalActions[action]) === null || _e === void 0 ? void 0 : _e.tooltipContent, tooltipProps: (_f = additionalActions[action]) === null || _f === void 0 ? void 0 : _f.tooltipProps, icon: (_g = additionalActions[action]) === null || _g === void 0 ? void 0 : _g.icon }));
|
|
27
|
+
})));
|
|
28
|
+
};
|
|
29
|
+
export default ResponseActions;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { render, screen } from '@testing-library/react';
|
|
12
|
+
import '@testing-library/jest-dom';
|
|
13
|
+
import ResponseActions from './ResponseActions';
|
|
14
|
+
import userEvent from '@testing-library/user-event';
|
|
15
|
+
const ALL_ACTIONS = [
|
|
16
|
+
{ type: 'positive', label: 'Good response' },
|
|
17
|
+
{ type: 'negative', label: 'Bad response' },
|
|
18
|
+
{ type: 'copy', label: 'Copy' },
|
|
19
|
+
{ type: 'share', label: 'Share' },
|
|
20
|
+
{ type: 'listen', label: 'Listen' }
|
|
21
|
+
];
|
|
22
|
+
describe('ResponseActions', () => {
|
|
23
|
+
it('should render buttons correctly', () => {
|
|
24
|
+
ALL_ACTIONS.forEach(({ type, label }) => {
|
|
25
|
+
render(React.createElement(ResponseActions, { actions: { [type]: { onClick: jest.fn() } } }));
|
|
26
|
+
expect(screen.getByRole('button', { name: label })).toBeTruthy();
|
|
27
|
+
});
|
|
28
|
+
});
|
|
29
|
+
it('should be able to call onClick correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
30
|
+
ALL_ACTIONS.forEach((_a) => __awaiter(void 0, [_a], void 0, function* ({ type, label }) {
|
|
31
|
+
const spy = jest.fn();
|
|
32
|
+
render(React.createElement(ResponseActions, { actions: { [type]: { onClick: spy } } }));
|
|
33
|
+
yield userEvent.click(screen.getByRole('button', { name: label }));
|
|
34
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
35
|
+
}));
|
|
36
|
+
}));
|
|
37
|
+
it('should be able to change aria labels', () => {
|
|
38
|
+
const actions = [
|
|
39
|
+
{ type: 'positive', ariaLabel: 'Thumbs up' },
|
|
40
|
+
{ type: 'negative', ariaLabel: 'Thumbs down' },
|
|
41
|
+
{ type: 'copy', ariaLabel: 'Copy the message' },
|
|
42
|
+
{ type: 'share', ariaLabel: 'Share it with friends' },
|
|
43
|
+
{ type: 'listen', ariaLabel: 'Listen up' }
|
|
44
|
+
];
|
|
45
|
+
actions.forEach(({ type, ariaLabel }) => {
|
|
46
|
+
render(React.createElement(ResponseActions, { actions: { [type]: { onClick: jest.fn(), ariaLabel } } }));
|
|
47
|
+
expect(screen.getByRole('button', { name: ariaLabel })).toBeTruthy();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
it('should be able to disable buttons', () => {
|
|
51
|
+
ALL_ACTIONS.forEach(({ type, label }) => {
|
|
52
|
+
render(React.createElement(ResponseActions, { actions: { [type]: { onClick: jest.fn(), isDisabled: true } } }));
|
|
53
|
+
expect(screen.getByRole('button', { name: label })).toBeDisabled();
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
it('should be able to add class to buttons', () => {
|
|
57
|
+
ALL_ACTIONS.forEach(({ type, label }) => {
|
|
58
|
+
render(React.createElement(ResponseActions, { actions: { [type]: { onClick: jest.fn(), className: 'test' } } }));
|
|
59
|
+
expect(screen.getByRole('button', { name: label })).toHaveClass('test');
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export interface SourceDetailsMenuItemProps extends React.HTMLProps<HTMLDivElement> {
|
|
3
|
+
/** Icon */
|
|
4
|
+
icon: React.ReactNode;
|
|
5
|
+
/** Name of source */
|
|
6
|
+
name: string;
|
|
7
|
+
/** Description of source */
|
|
8
|
+
type?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const SourceDetailsMenuItem: React.FunctionComponent<SourceDetailsMenuItemProps>;
|
|
11
|
+
export default SourceDetailsMenuItem;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { Icon, Flex, Stack, StackItem } from '@patternfly/react-core';
|
|
14
|
+
export const SourceDetailsMenuItem = (_a) => {
|
|
15
|
+
var { icon, name, type } = _a, props = __rest(_a, ["icon", "name", "type"]);
|
|
16
|
+
return (React.createElement(Flex, Object.assign({ className: "pf-chatbot__source-details", gap: { default: 'gapSm' } }, props),
|
|
17
|
+
React.createElement(Flex, { justifyContent: { default: 'justifyContentCenter' }, alignItems: { default: 'alignItemsCenter' }, alignSelf: { default: 'alignSelfCenter' } },
|
|
18
|
+
React.createElement(Icon, { className: "pf-chatbot__source-details-icon" }, icon)),
|
|
19
|
+
React.createElement(Stack, { className: "pf-chatbot__source-details-text" },
|
|
20
|
+
React.createElement(StackItem, null,
|
|
21
|
+
React.createElement("span", { className: "pf-chatbot__source-details-heading" }, name)),
|
|
22
|
+
type && React.createElement(StackItem, { className: "pf-chatbot__source-details-subhead" }, type))));
|
|
23
|
+
};
|
|
24
|
+
export default SourceDetailsMenuItem;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { CardProps } from '@patternfly/react-core';
|
|
3
|
+
export interface SourcesCardProps extends CardProps {
|
|
4
|
+
/** Additional classes for the pagination navigation container. */
|
|
5
|
+
className?: string;
|
|
6
|
+
/** Flag indicating if the pagination is disabled. */
|
|
7
|
+
isDisabled?: boolean;
|
|
8
|
+
/** Label for the English word "of". */
|
|
9
|
+
ofWord?: string;
|
|
10
|
+
/** Accessible label for the pagination component. */
|
|
11
|
+
paginationAriaLabel?: string;
|
|
12
|
+
/** Content rendered inside the paginated card */
|
|
13
|
+
sources: {
|
|
14
|
+
title?: string;
|
|
15
|
+
link: string;
|
|
16
|
+
body?: React.ReactNode | string;
|
|
17
|
+
}[];
|
|
18
|
+
/** Label for the English word "source" */
|
|
19
|
+
sourceWord?: string;
|
|
20
|
+
/** Plural for sourceWord */
|
|
21
|
+
sourceWordPlural?: string;
|
|
22
|
+
/** Accessible label for the button which moves to the next page. */
|
|
23
|
+
toNextPageAriaLabel?: string;
|
|
24
|
+
/** Accessible label for the button which moves to the previous page. */
|
|
25
|
+
toPreviousPageAriaLabel?: string;
|
|
26
|
+
/** Function called when user clicks to navigate to next page. */
|
|
27
|
+
onNextClick?: (event: React.SyntheticEvent<HTMLButtonElement>, page: number) => void;
|
|
28
|
+
/** Function called when user clicks to navigate to previous page. */
|
|
29
|
+
onPreviousClick?: (event: React.SyntheticEvent<HTMLButtonElement>, page: number) => void;
|
|
30
|
+
/** Function called when page is changed. */
|
|
31
|
+
onSetPage?: (event: React.MouseEvent | React.KeyboardEvent | MouseEvent, newPage: number) => void;
|
|
32
|
+
}
|
|
33
|
+
declare const SourcesCard: React.FunctionComponent<SourcesCardProps>;
|
|
34
|
+
export default SourcesCard;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
+
var t = {};
|
|
3
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
+
t[p] = s[p];
|
|
5
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
+
t[p[i]] = s[p[i]];
|
|
9
|
+
}
|
|
10
|
+
return t;
|
|
11
|
+
};
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Chatbot Main - Messages - Sources Card
|
|
14
|
+
// ============================================================================
|
|
15
|
+
import React from 'react';
|
|
16
|
+
// Import PatternFly components
|
|
17
|
+
import { Button, ButtonVariant, Card, CardBody, CardFooter, CardTitle, Icon, pluralize, Truncate } from '@patternfly/react-core';
|
|
18
|
+
const SourcesCard = (_a) => {
|
|
19
|
+
var { className, isDisabled, ofWord = 'of', paginationAriaLabel = 'Pagination', sources, sourceWord = 'source', sourceWordPlural = 'sources', toNextPageAriaLabel = 'Go to next page', toPreviousPageAriaLabel = 'Go to previous page', onNextClick, onPreviousClick, onSetPage } = _a, props = __rest(_a, ["className", "isDisabled", "ofWord", "paginationAriaLabel", "sources", "sourceWord", "sourceWordPlural", "toNextPageAriaLabel", "toPreviousPageAriaLabel", "onNextClick", "onPreviousClick", "onSetPage"]);
|
|
20
|
+
const [page, setPage] = React.useState(1);
|
|
21
|
+
const handleNewPage = (_evt, newPage) => {
|
|
22
|
+
setPage(newPage);
|
|
23
|
+
onSetPage && onSetPage(_evt, newPage);
|
|
24
|
+
};
|
|
25
|
+
const renderTitle = (title) => {
|
|
26
|
+
if (title) {
|
|
27
|
+
return React.createElement(Truncate, { content: title });
|
|
28
|
+
}
|
|
29
|
+
return `Source ${page}`;
|
|
30
|
+
};
|
|
31
|
+
return (React.createElement("div", { className: "pf-chatbot__source" },
|
|
32
|
+
React.createElement("span", null, pluralize(sources.length, sourceWord, sourceWordPlural)),
|
|
33
|
+
React.createElement(Card, Object.assign({ className: "pf-chatbot__sources-card" }, props),
|
|
34
|
+
React.createElement(CardTitle, { className: "pf-chatbot__sources-card-title" },
|
|
35
|
+
React.createElement("a", { href: sources[page - 1].link }, renderTitle(sources[page - 1].title))),
|
|
36
|
+
sources[page - 1].body && (React.createElement(CardBody, { className: `pf-chatbot__sources-card-body ${sources.length === 1 && 'pf-chatbot__sources-card-no-footer'}` }, sources[page - 1].body)),
|
|
37
|
+
sources.length > 1 && (React.createElement(CardFooter, { className: "pf-chatbot__sources-card-footer-container" },
|
|
38
|
+
React.createElement("div", { className: "pf-chatbot__sources-card-footer" },
|
|
39
|
+
React.createElement("nav", { className: `pf-chatbot__sources-card-footer-buttons ${className}`, "aria-label": paginationAriaLabel },
|
|
40
|
+
React.createElement(Button, { variant: ButtonVariant.plain, isDisabled: isDisabled || page === 1, "data-action": "previous", onClick: (event) => {
|
|
41
|
+
const newPage = page >= 1 ? page - 1 : 1;
|
|
42
|
+
onPreviousClick && onPreviousClick(event, newPage);
|
|
43
|
+
handleNewPage(event, newPage);
|
|
44
|
+
}, "aria-label": toPreviousPageAriaLabel },
|
|
45
|
+
React.createElement(Icon, { iconSize: "lg" },
|
|
46
|
+
React.createElement("svg", { className: "pf-v6-svg", viewBox: "0 0 280 500", fill: "currentColor", "aria-hidden": "true", role: "img", width: "1em", height: "1em" },
|
|
47
|
+
React.createElement("path", { d: "M31.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L127.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L201.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34z" })))),
|
|
48
|
+
React.createElement(Button, { variant: ButtonVariant.plain, isDisabled: isDisabled || page === sources.length, "aria-label": toNextPageAriaLabel, "data-action": "next", onClick: (event) => {
|
|
49
|
+
const newPage = page + 1 <= sources.length ? page + 1 : sources.length;
|
|
50
|
+
onNextClick && onNextClick(event, newPage);
|
|
51
|
+
handleNewPage(event, newPage);
|
|
52
|
+
} },
|
|
53
|
+
React.createElement(Icon, { isInline: true, iconSize: "lg" },
|
|
54
|
+
React.createElement("svg", { className: "pf-v6-svg", viewBox: "0 0 180 500", fill: "currentColor", "aria-hidden": "true", role: "img", width: "1em", height: "1em" },
|
|
55
|
+
React.createElement("path", { d: "M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34z" }))))),
|
|
56
|
+
React.createElement("span", { "aria-hidden": "true" },
|
|
57
|
+
page,
|
|
58
|
+
" ",
|
|
59
|
+
ofWord,
|
|
60
|
+
" ",
|
|
61
|
+
sources.length)))))));
|
|
62
|
+
};
|
|
63
|
+
export default SourcesCard;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom';
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import React from 'react';
|
|
11
|
+
import { render, screen } from '@testing-library/react';
|
|
12
|
+
import userEvent from '@testing-library/user-event';
|
|
13
|
+
import '@testing-library/jest-dom';
|
|
14
|
+
import SourcesCard from './SourcesCard';
|
|
15
|
+
describe('SourcesCard', () => {
|
|
16
|
+
it('should render card', () => {
|
|
17
|
+
const { container } = render(React.createElement(SourcesCard, { sources: [{ link: '' }] }));
|
|
18
|
+
expect(container).toMatchSnapshot();
|
|
19
|
+
});
|
|
20
|
+
it('should render card correctly if one source with only a link is passed in', () => {
|
|
21
|
+
render(React.createElement(SourcesCard, { sources: [{ link: '' }] }));
|
|
22
|
+
expect(screen.getByText('1 source')).toBeTruthy();
|
|
23
|
+
expect(screen.getByText('Source 1')).toBeTruthy();
|
|
24
|
+
// no buttons or navigation when there is only 1 source
|
|
25
|
+
expect(screen.queryByRole('button')).toBeFalsy();
|
|
26
|
+
expect(screen.queryByText('1 of 1')).toBeFalsy();
|
|
27
|
+
});
|
|
28
|
+
it('should render card correctly if one source with a title is passed in', () => {
|
|
29
|
+
render(React.createElement(SourcesCard, { sources: [{ title: 'How to make an apple pie', link: '' }] }));
|
|
30
|
+
expect(screen.getByText('1 source')).toBeTruthy();
|
|
31
|
+
expect(screen.getByText('How to make an apple pie')).toBeTruthy();
|
|
32
|
+
});
|
|
33
|
+
it('should render card correctly if one source with a body is passed in', () => {
|
|
34
|
+
render(React.createElement(SourcesCard, { sources: [{ link: '', body: 'To make an apple pie, you must first...' }] }));
|
|
35
|
+
expect(screen.getByText('1 source')).toBeTruthy();
|
|
36
|
+
expect(screen.getByText('To make an apple pie, you must first...')).toBeTruthy();
|
|
37
|
+
});
|
|
38
|
+
it('should render card correctly if one source with a title and body is passed in', () => {
|
|
39
|
+
render(React.createElement(SourcesCard, { sources: [{ title: 'How to make an apple pie', link: '', body: 'To make an apple pie, you must first...' }] }));
|
|
40
|
+
expect(screen.getByText('1 source')).toBeTruthy();
|
|
41
|
+
expect(screen.getByText('How to make an apple pie')).toBeTruthy();
|
|
42
|
+
expect(screen.getByText('To make an apple pie, you must first...')).toBeTruthy();
|
|
43
|
+
});
|
|
44
|
+
it('should render multiple cards correctly', () => {
|
|
45
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
46
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
47
|
+
{ title: 'How to make cookies', link: '' }
|
|
48
|
+
] }));
|
|
49
|
+
expect(screen.getByText('2 sources')).toBeTruthy();
|
|
50
|
+
expect(screen.getByText('How to make an apple pie')).toBeTruthy();
|
|
51
|
+
expect(screen.getByText('1 of 2')).toBeTruthy();
|
|
52
|
+
screen.getByRole('button', { name: /Go to previous page/i });
|
|
53
|
+
screen.getByRole('button', { name: /Go to next page/i });
|
|
54
|
+
});
|
|
55
|
+
it('should navigate between cards correctly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
57
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
58
|
+
{ title: 'How to make cookies', link: '' }
|
|
59
|
+
] }));
|
|
60
|
+
expect(screen.getByText('How to make an apple pie')).toBeTruthy();
|
|
61
|
+
expect(screen.getByText('1 of 2')).toBeTruthy();
|
|
62
|
+
expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
|
|
63
|
+
yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
|
|
64
|
+
expect(screen.queryByText('How to make an apple pie')).toBeFalsy();
|
|
65
|
+
expect(screen.getByText('How to make cookies')).toBeTruthy();
|
|
66
|
+
expect(screen.getByText('2 of 2')).toBeTruthy();
|
|
67
|
+
expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeEnabled();
|
|
68
|
+
expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
|
|
69
|
+
}));
|
|
70
|
+
it('should apply className appropriately', () => {
|
|
71
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
72
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
73
|
+
{ title: 'How to make cookies', link: '' }
|
|
74
|
+
], className: "test" }));
|
|
75
|
+
const element = screen.getByRole('navigation');
|
|
76
|
+
expect(element).toHaveClass('test');
|
|
77
|
+
});
|
|
78
|
+
it('should disable pagination appropriately', () => {
|
|
79
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
80
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
81
|
+
{ title: 'How to make cookies', link: '' }
|
|
82
|
+
], isDisabled: true }));
|
|
83
|
+
expect(screen.getByRole('button', { name: /Go to previous page/i })).toBeDisabled();
|
|
84
|
+
expect(screen.getByRole('button', { name: /Go to next page/i })).toBeDisabled();
|
|
85
|
+
});
|
|
86
|
+
it('should change ofWord appropriately', () => {
|
|
87
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
88
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
89
|
+
{ title: 'How to make cookies', link: '' }
|
|
90
|
+
], ofWord: 'de' }));
|
|
91
|
+
expect(screen.getByText('1 de 2')).toBeTruthy();
|
|
92
|
+
});
|
|
93
|
+
it('should render navigation aria label appropriately', () => {
|
|
94
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
95
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
96
|
+
{ title: 'How to make cookies', link: '' }
|
|
97
|
+
] }));
|
|
98
|
+
expect(screen.getByRole('navigation', { name: /Pagination/i })).toBeTruthy();
|
|
99
|
+
});
|
|
100
|
+
it('should change paginationAriaLabel appropriately', () => {
|
|
101
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
102
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
103
|
+
{ title: 'How to make cookies', link: '' }
|
|
104
|
+
], paginationAriaLabel: "Navegaci\u00F3n" }));
|
|
105
|
+
expect(screen.getByRole('navigation', { name: /Navegación/i })).toBeTruthy();
|
|
106
|
+
});
|
|
107
|
+
it('should change sourceWord appropriately', () => {
|
|
108
|
+
render(React.createElement(SourcesCard, { sources: [{ title: 'How to make an apple pie', link: '' }], sourceWord: 'fuente' }));
|
|
109
|
+
expect(screen.getByText('1 fuente')).toBeTruthy();
|
|
110
|
+
});
|
|
111
|
+
it('should sourceWordPlural appropriately', () => {
|
|
112
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
113
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
114
|
+
{ title: 'How to make cookies', link: '' }
|
|
115
|
+
], sourceWordPlural: 'fuentes' }));
|
|
116
|
+
expect(screen.getByText('2 fuentes')).toBeTruthy();
|
|
117
|
+
});
|
|
118
|
+
it('should change toNextPageAriaLabel appropriately', () => {
|
|
119
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
120
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
121
|
+
{ title: 'How to make cookies', link: '' }
|
|
122
|
+
], toNextPageAriaLabel: "Pase a la siguiente p\u00E1gina" }));
|
|
123
|
+
expect(screen.getByRole('button', { name: /Pase a la siguiente página/i })).toBeTruthy();
|
|
124
|
+
});
|
|
125
|
+
it('should change toPreviousPageAriaLabel appropriately', () => {
|
|
126
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
127
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
128
|
+
{ title: 'How to make cookies', link: '' }
|
|
129
|
+
], toPreviousPageAriaLabel: "Presione para regresar a la p\u00E1gina anterior" }));
|
|
130
|
+
expect(screen.getByRole('button', { name: /Presione para regresar a la página anterior/i })).toBeTruthy();
|
|
131
|
+
});
|
|
132
|
+
it('should call onNextClick appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
133
|
+
const spy = jest.fn();
|
|
134
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
135
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
136
|
+
{ title: 'How to make cookies', link: '' }
|
|
137
|
+
], onNextClick: spy }));
|
|
138
|
+
yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
|
|
139
|
+
expect(spy).toHaveBeenCalled();
|
|
140
|
+
}));
|
|
141
|
+
it('should call onPreviousClick appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
142
|
+
const spy = jest.fn();
|
|
143
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
144
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
145
|
+
{ title: 'How to make cookies', link: '' }
|
|
146
|
+
], onPreviousClick: spy }));
|
|
147
|
+
yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
|
|
148
|
+
yield userEvent.click(screen.getByRole('button', { name: /Go to previous page/i }));
|
|
149
|
+
expect(spy).toHaveBeenCalled();
|
|
150
|
+
}));
|
|
151
|
+
it('should call onSetPage appropriately', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
|
+
const spy = jest.fn();
|
|
153
|
+
render(React.createElement(SourcesCard, { sources: [
|
|
154
|
+
{ title: 'How to make an apple pie', link: '' },
|
|
155
|
+
{ title: 'How to make cookies', link: '' }
|
|
156
|
+
], onSetPage: spy }));
|
|
157
|
+
yield userEvent.click(screen.getByRole('button', { name: /Go to next page/i }));
|
|
158
|
+
expect(spy).toHaveBeenCalledTimes(1);
|
|
159
|
+
yield userEvent.click(screen.getByRole('button', { name: /Go to previous page/i }));
|
|
160
|
+
expect(spy).toHaveBeenCalledTimes(2);
|
|
161
|
+
}));
|
|
162
|
+
});
|