@swisper.ai/web-chat-ui 0.0.2 → 0.0.5
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/README.md +9 -12
- package/dist/components/canvas-shell/canvas-shell.d.ts +32 -10
- package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -1
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts +49 -17
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.d.ts +1 -0
- package/dist/components/chat-card/chat-card.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.stories.d.ts +47 -1
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-body.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-footer.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-form.d.ts +15 -2
- package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-header.d.ts +23 -2
- package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -1
- package/dist/components/chat-card/contexts.d.ts +2 -0
- package/dist/components/chat-card/contexts.d.ts.map +1 -1
- package/dist/components/chat-card/hooks.d.ts +1 -0
- package/dist/components/chat-card/hooks.d.ts.map +1 -1
- package/dist/components/chat-card/types.d.ts +3 -0
- package/dist/components/chat-card/types.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.d.ts +4 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts +12 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.stories.d.ts +36 -11
- package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.d.ts +30 -2
- package/dist/components/chat-input/chat-input.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.stories.d.ts +63 -3
- package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -1
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +4 -1
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -1
- package/dist/components/chat-input/plugins/value-plugin.d.ts +4 -1
- package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-item.d.ts +6 -0
- package/dist/components/chat-list/chat-list-item.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-items.d.ts +12 -1
- package/dist/components/chat-list/chat-list-items.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.d.ts +36 -2
- package/dist/components/chat-list/chat-list.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.stories.d.ts +67 -9
- package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.d.ts +12 -1
- package/dist/components/chat-message/chat-message.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.stories.d.ts +31 -0
- package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -1
- package/dist/components/chat-message/index.d.ts +1 -1
- package/dist/components/chat-message/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +3 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +25 -5
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +32 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/index.d.ts +2 -2
- package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/utils.d.ts +1 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -1
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts +13 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +22 -5
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +42 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.d.ts +34 -2
- package/dist/components/chat-messages/chat-messages.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.stories.d.ts +33 -2
- package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.d.ts +56 -4
- package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +50 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +6 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +43 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +37 -17
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +53 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.d.ts +11 -0
- package/dist/components/chat-reply/chat-reply.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.stories.d.ts +23 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/index.d.ts +1 -1
- package/dist/components/chat-reply/index.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.d.ts +36 -10
- package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +66 -2
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -1
- package/dist/components/chat-suggestion/index.d.ts +2 -1
- package/dist/components/chat-suggestion/index.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +26 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +25 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.d.ts +17 -2
- package/dist/components/chat-thread/chat-thread.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.stories.d.ts +75 -10
- package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts +8 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +18 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +4 -1
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts +4 -1
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.d.ts +17 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts +52 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/styled.d.ts +6 -2
- package/dist/components/rich-text-area/styled.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +9 -2
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/index.d.ts +5 -5
- package/dist/components/rich-text-field/components/index.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts +12 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.d.ts +22 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts +28 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
- package/dist/components/topmenu/index.d.ts +2 -0
- package/dist/components/topmenu/index.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.d.ts +22 -0
- package/dist/components/topmenu/topmenu.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.stories.d.ts +31 -0
- package/dist/components/topmenu/topmenu.stories.d.ts.map +1 -0
- package/dist/docs/agent.stories.d.ts.map +1 -1
- package/dist/docs/chat-panel.d.ts +7 -5
- package/dist/docs/chat-panel.d.ts.map +1 -1
- package/dist/docs/chatbot-panel.d.ts.map +1 -1
- package/dist/docs/chatbot.stories.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +1801 -1806
- package/dist/index.es.js.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +9 -7
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +37 -9
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +41 -16
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +6 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +22 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -1
- package/package.json +16 -10
- package/src/__storybook__/parent-block.tsx +21 -0
- package/src/components/canvas-shell/__stories__/canvas-panel.tsx +25 -0
- package/src/components/canvas-shell/__stories__/document-list.tsx +29 -0
- package/src/components/canvas-shell/__stories__/fixtures.ts +222 -0
- package/src/components/canvas-shell/__stories__/holdings-table.tsx +56 -0
- package/src/components/canvas-shell/__stories__/types.ts +47 -0
- package/src/components/canvas-shell/{canvas-shell.test.tsx → __tests__/canvas-shell.spec.tsx} +1 -1
- package/src/components/canvas-shell/canvas-shell.json +24 -0
- package/src/components/canvas-shell/canvas-shell.stories.tsx +581 -122
- package/src/components/canvas-shell/canvas-shell.tsx +44 -17
- package/src/components/chat-card/__stories__/fixtures.ts +119 -0
- package/src/components/chat-card/__stories__/types.ts +44 -0
- package/src/components/chat-card/chat-card.json +67 -3
- package/src/components/chat-card/chat-card.stories.tsx +872 -148
- package/src/components/chat-card/chat-card.tsx +2 -0
- package/src/components/chat-card/components/chat-card-body.tsx +12 -0
- package/src/components/chat-card/components/chat-card-footer.tsx +11 -0
- package/src/components/chat-card/components/chat-card-form.tsx +21 -2
- package/src/components/chat-card/components/chat-card-header.tsx +39 -2
- package/src/components/chat-card/contexts.tsx +2 -0
- package/src/components/chat-card/hooks.ts +1 -0
- package/src/components/chat-card/types.ts +3 -0
- package/src/components/chat-card-container/__stories__/fixtures.ts +54 -0
- package/src/components/chat-card-container/__stories__/resizable-chat-window.tsx +19 -0
- package/src/components/chat-card-container/__stories__/result-card.tsx +31 -0
- package/src/components/chat-card-container/__stories__/types.ts +16 -0
- package/src/components/chat-card-container/chat-card-container.json +7 -0
- package/src/components/chat-card-container/chat-card-container.stories.tsx +209 -56
- package/src/components/chat-card-container/chat-card-container.tsx +5 -0
- package/src/components/chat-container/__stories__/chat-composer.tsx +67 -0
- package/src/components/chat-container/__stories__/fixtures.ts +27 -0
- package/src/components/chat-container/__stories__/measure.ts +22 -0
- package/src/components/chat-container/__stories__/types.ts +7 -0
- package/src/components/chat-container/__stories__/variable-readout.tsx +64 -0
- package/src/components/chat-container/chat-container.json +9 -1
- package/src/components/chat-container/chat-container.stories.tsx +538 -106
- package/src/components/chat-container/chat-container.tsx +3 -0
- package/src/components/chat-input/__stories__/fixtures.ts +31 -0
- package/src/components/chat-input/__tests__/chat-input.spec.tsx +100 -0
- package/src/components/chat-input/chat-input.json +11 -2
- package/src/components/chat-input/chat-input.stories.tsx +660 -197
- package/src/components/chat-input/chat-input.tsx +39 -5
- package/src/components/chat-input/plugins/controlled-value-plugin.tsx +16 -3
- package/src/components/chat-input/plugins/value-plugin.tsx +19 -4
- package/src/components/chat-list/__stories__/chat-row.tsx +41 -0
- package/src/components/chat-list/__stories__/fixtures.ts +94 -0
- package/src/components/chat-list/__stories__/types.ts +13 -0
- package/src/components/chat-list/chat-list-item.tsx +6 -0
- package/src/components/chat-list/chat-list-items.tsx +16 -0
- package/src/components/chat-list/chat-list.json +24 -2
- package/src/components/chat-list/chat-list.stories.tsx +631 -215
- package/src/components/chat-list/chat-list.tsx +51 -4
- package/src/components/chat-message/__stories__/fixtures.ts +53 -0
- package/src/components/chat-message/__stories__/sent-attachment.tsx +22 -0
- package/src/components/chat-message/__stories__/tool-steps.tsx +37 -0
- package/src/components/chat-message/chat-message.json +10 -1
- package/src/components/chat-message/chat-message.stories.tsx +282 -20
- package/src/components/chat-message/chat-message.tsx +16 -1
- package/src/components/chat-message/index.ts +8 -1
- package/src/components/chat-message-attachment-card/__stories__/fixtures.ts +30 -0
- package/src/components/chat-message-attachment-card/__stories__/types.ts +14 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +4 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +20 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +266 -51
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +37 -4
- package/src/components/chat-message-attachment-card/index.ts +6 -0
- package/src/components/chat-message-attachment-card/utils.ts +1 -0
- package/src/components/chat-message-response/__stories__/fixtures.ts +50 -0
- package/src/components/chat-message-response/chat-message-response.json +5 -0
- package/src/components/chat-message-response/chat-message-response.stories.tsx +135 -26
- package/src/components/chat-message-toolbar/chat-message-toolbar.json +21 -3
- package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +377 -6
- package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +47 -12
- package/src/components/chat-message-toolbar/index.ts +4 -0
- package/src/components/chat-messages/__stories__/conversation-frame.tsx +25 -0
- package/src/components/chat-messages/__stories__/conversation-group.tsx +22 -0
- package/src/components/chat-messages/__stories__/fixtures.ts +70 -0
- package/src/components/chat-messages/__stories__/types.ts +5 -0
- package/src/components/chat-messages/chat-messages.json +30 -12
- package/src/components/chat-messages/chat-messages.stories.tsx +439 -212
- package/src/components/chat-messages/chat-messages.tsx +46 -3
- package/src/components/chat-notification-card/__stories__/fixtures.ts +38 -0
- package/src/components/chat-notification-card/__stories__/types.ts +13 -0
- package/src/components/chat-notification-card/chat-notification-card.json +52 -2
- package/src/components/chat-notification-card/chat-notification-card.stories.tsx +542 -62
- package/src/components/chat-notification-card/chat-notification-card.tsx +97 -6
- package/src/components/chat-notification-popup/__stories__/fixtures.ts +36 -0
- package/src/components/chat-notification-popup/__stories__/notification-item.tsx +93 -0
- package/src/components/chat-notification-popup/__stories__/types.ts +14 -0
- package/src/components/chat-notification-popup/chat-notification-popup.json +14 -1
- package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +467 -17
- package/src/components/chat-notification-popup/chat-notification-popup.tsx +18 -3
- package/src/components/chat-prompt-box/__stories__/fixtures.ts +16 -0
- package/src/components/chat-prompt-box/__stories__/types.ts +8 -0
- package/src/components/chat-prompt-box/chat-prompt-box.json +25 -2
- package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +535 -43
- package/src/components/chat-prompt-box/chat-prompt-box.tsx +73 -19
- package/src/components/chat-reply/chat-reply.json +10 -0
- package/src/components/chat-reply/chat-reply.stories.tsx +264 -21
- package/src/components/chat-reply/chat-reply.tsx +15 -0
- package/src/components/chat-reply/index.ts +10 -1
- package/src/components/chat-suggestion/__stories__/fixtures.ts +16 -0
- package/src/components/chat-suggestion/__tests__/chat-suggestion.spec.tsx +185 -0
- package/src/components/chat-suggestion/chat-suggestion.json +62 -20
- package/src/components/chat-suggestion/chat-suggestion.stories.tsx +542 -58
- package/src/components/chat-suggestion/chat-suggestion.tsx +154 -65
- package/src/components/chat-suggestion/index.ts +9 -0
- package/src/components/chat-thinking-process/__stories__/fixtures.ts +56 -0
- package/src/components/chat-thinking-process/chat-thinking-process.json +28 -3
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +354 -78
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -4
- package/src/components/chat-thread/__stories__/fixtures.ts +171 -0
- package/src/components/chat-thread/__stories__/scroll-position.ts +9 -0
- package/src/components/chat-thread/__stories__/snippets.ts +129 -0
- package/src/components/chat-thread/__stories__/thread-frame.tsx +22 -0
- package/src/components/chat-thread/__stories__/thread-turns.tsx +35 -0
- package/src/components/chat-thread/__stories__/types.ts +12 -0
- package/src/components/chat-thread/__stories__/use-turn-stream.ts +78 -0
- package/src/components/chat-thread/chat-thread.json +23 -3
- package/src/components/chat-thread/chat-thread.stories.tsx +804 -142
- package/src/components/chat-thread/chat-thread.tsx +64 -16
- package/src/components/index.ts +1 -3
- package/src/components/markdown-viewer/__stories__/fixtures.ts +67 -0
- package/src/components/markdown-viewer/markdown-viewer.json +7 -1
- package/src/components/markdown-viewer/markdown-viewer.stories.tsx +219 -50
- package/src/components/markdown-viewer/markdown-viewer.tsx +9 -0
- package/src/components/rich-text-area/__stories__/fixtures.ts +30 -0
- package/src/components/rich-text-area/__tests__/rich-text-area.spec.tsx +114 -0
- package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +20 -3
- package/src/components/rich-text-area/plugins/value-plugin.tsx +16 -3
- package/src/components/rich-text-area/rich-text-area.json +7 -4
- package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
- package/src/components/rich-text-area/rich-text-area.tsx +27 -4
- package/src/components/rich-text-area/styled.tsx +11 -5
- package/src/components/rich-text-field/__stories__/fixtures.ts +29 -0
- package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +10 -1
- package/src/components/rich-text-field/components/index.ts +8 -5
- package/src/components/rich-text-field/components/text-color-button.tsx +16 -2
- package/src/components/rich-text-field/rich-text-field.json +3 -1
- package/src/components/rich-text-field/rich-text-field.stories.tsx +452 -61
- package/src/components/rich-text-field/rich-text-field.tsx +23 -0
- package/src/components/topmenu/index.ts +1 -0
- package/src/components/topmenu/topmenu.json +107 -0
- package/src/components/topmenu/topmenu.stories.tsx +334 -0
- package/src/components/topmenu/topmenu.tsx +71 -0
- package/src/docs/agent.stories.tsx +16 -16
- package/src/docs/chat-panel.tsx +37 -32
- package/src/docs/chatbot-panel.tsx +11 -2
- package/src/docs/chatbot.mdx +17 -12
- package/src/docs/chatbot.stories.tsx +7 -8
- package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +112 -0
- package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +36 -0
- package/src/layouts/chat-card-list-layout/__stories__/types.ts +31 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +14 -1
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +316 -84
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +11 -7
- package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +117 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +18 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +85 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +50 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +44 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +61 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +35 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +16 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +603 -182
- package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +51 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +83 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +24 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +15 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +13 -1
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +368 -67
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +11 -2
- package/dist/components/card-item-picker/card-item-picker-context.d.ts +0 -21
- package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-list.d.ts +0 -24
- package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +0 -28
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row.d.ts +0 -12
- package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts +0 -19
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +0 -1
- package/dist/components/card-item-picker/index.d.ts +0 -9
- package/dist/components/card-item-picker/index.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.d.ts +0 -48
- package/dist/components/chat-message-history/chat-message-history.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts +0 -7
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +0 -1
- package/dist/components/chat-message-history/index.d.ts +0 -2
- package/dist/components/chat-message-history/index.d.ts.map +0 -1
- package/dist/components/spinner/index.d.ts +0 -2
- package/dist/components/spinner/index.d.ts.map +0 -1
- package/dist/components/spinner/spinner.d.ts +0 -9
- package/dist/components/spinner/spinner.d.ts.map +0 -1
- package/dist/components/spinner/spinner.stories.d.ts +0 -8
- package/dist/components/spinner/spinner.stories.d.ts.map +0 -1
- package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +0 -279
- package/src/components/card-item-picker/card-item-picker-context.tsx +0 -44
- package/src/components/card-item-picker/card-item-picker-list.tsx +0 -95
- package/src/components/card-item-picker/card-item-picker-row-parts.tsx +0 -96
- package/src/components/card-item-picker/card-item-picker-row.tsx +0 -109
- package/src/components/card-item-picker/card-item-picker.json +0 -147
- package/src/components/card-item-picker/card-item-picker.stories.tsx +0 -158
- package/src/components/card-item-picker/index.ts +0 -24
- package/src/components/chat-message-history/chat-message-history.json +0 -99
- package/src/components/chat-message-history/chat-message-history.stories.tsx +0 -136
- package/src/components/chat-message-history/chat-message-history.tsx +0 -277
- package/src/components/chat-message-history/index.ts +0 -13
- package/src/components/spinner/index.ts +0 -1
- package/src/components/spinner/spinner.json +0 -73
- package/src/components/spinner/spinner.stories.tsx +0 -41
- package/src/components/spinner/spinner.tsx +0 -32
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import {
|
|
2
|
+
import { useState, type ReactNode } from 'react';
|
|
3
|
+
import { expect, fn, within } from 'storybook/test';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
5
|
+
import {
|
|
6
|
+
CalendarIcon,
|
|
7
|
+
CloseIcon,
|
|
8
|
+
EnterIcon,
|
|
9
|
+
MailIcon,
|
|
10
|
+
NewChatIcon,
|
|
11
|
+
SearchIcon,
|
|
12
|
+
} from '@swisper.ai/icons';
|
|
13
|
+
import {
|
|
14
|
+
EmptyState,
|
|
15
|
+
EmptyStateDescription,
|
|
16
|
+
EmptyStateIcon,
|
|
17
|
+
EmptyStateTitle,
|
|
18
|
+
IconButton,
|
|
19
|
+
Typography,
|
|
20
|
+
} from '@swisper.ai/ui';
|
|
6
21
|
|
|
22
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
23
|
+
import { CanvasShellFooter } from '../canvas-shell';
|
|
24
|
+
import { ChatInput, ChatInputTextarea } from '../chat-input';
|
|
25
|
+
|
|
26
|
+
import { CONVERSATION_STARTERS, FOLLOW_UPS, QUICK_REPLIES } from './__stories__/fixtures';
|
|
7
27
|
import {
|
|
8
28
|
ChatSuggestion,
|
|
29
|
+
ChatSuggestionAction,
|
|
9
30
|
ChatSuggestionActions,
|
|
10
31
|
ChatSuggestionLabel,
|
|
11
32
|
ChatSuggestionLabelIcon,
|
|
@@ -13,12 +34,12 @@ import {
|
|
|
13
34
|
} from './chat-suggestion';
|
|
14
35
|
|
|
15
36
|
const meta: Meta<typeof ChatSuggestion> = {
|
|
16
|
-
title: '
|
|
37
|
+
title: 'Chat/ChatSuggestion',
|
|
17
38
|
component: ChatSuggestion,
|
|
18
39
|
tags: ['autodocs'],
|
|
19
40
|
decorators: [
|
|
20
41
|
(Story) => (
|
|
21
|
-
<div className="max-w-
|
|
42
|
+
<div className="max-w-105">
|
|
22
43
|
<Story />
|
|
23
44
|
</div>
|
|
24
45
|
),
|
|
@@ -33,19 +54,27 @@ const meta: Meta<typeof ChatSuggestion> = {
|
|
|
33
54
|
children: {
|
|
34
55
|
control: false,
|
|
35
56
|
description:
|
|
36
|
-
'A `ChatSuggestionLabelIcon`, a `ChatSuggestionLabel` and optional `ChatSuggestionActions` shown
|
|
57
|
+
'A `ChatSuggestionLabelIcon`, a `ChatSuggestionLabel` and optional `ChatSuggestionActions` shown while the suggestion is highlighted.',
|
|
37
58
|
},
|
|
38
59
|
className: {
|
|
39
60
|
control: 'text',
|
|
40
61
|
description: 'Extra classes merged onto the root.',
|
|
41
62
|
},
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
description: '
|
|
63
|
+
triggerClassName: {
|
|
64
|
+
control: 'text',
|
|
65
|
+
description: 'Classes for the overlay `role="button"` that covers the suggestion.',
|
|
66
|
+
},
|
|
67
|
+
onSelect: {
|
|
68
|
+
description:
|
|
69
|
+
'Called when the suggestion is clicked or activated with Enter or Space, usually to send it as the next message.',
|
|
45
70
|
},
|
|
46
71
|
onHover: {
|
|
47
72
|
description:
|
|
48
|
-
'Called when the pointer enters the suggestion, e.g. to preview
|
|
73
|
+
'Called when the pointer enters the suggestion, e.g. to preview it. Keyboard highlight does not call it.',
|
|
74
|
+
},
|
|
75
|
+
isDisabled: {
|
|
76
|
+
control: 'boolean',
|
|
77
|
+
description: 'The suggestion can’t be focused, highlighted or selected.',
|
|
49
78
|
},
|
|
50
79
|
},
|
|
51
80
|
args: {
|
|
@@ -53,95 +82,550 @@ const meta: Meta<typeof ChatSuggestion> = {
|
|
|
53
82
|
children: (
|
|
54
83
|
<>
|
|
55
84
|
<ChatSuggestionLabelIcon />
|
|
56
|
-
<ChatSuggestionLabel>
|
|
85
|
+
<ChatSuggestionLabel>Check my calendar for next week</ChatSuggestionLabel>
|
|
57
86
|
<ChatSuggestionActions>
|
|
58
87
|
<EnterIcon />
|
|
59
88
|
</ChatSuggestionActions>
|
|
60
89
|
</>
|
|
61
90
|
),
|
|
62
|
-
|
|
91
|
+
onSelect: fn(),
|
|
63
92
|
onHover: fn(),
|
|
64
93
|
},
|
|
65
94
|
};
|
|
66
95
|
|
|
67
96
|
export default meta;
|
|
68
97
|
type Story = StoryObj<typeof ChatSuggestion>;
|
|
98
|
+
type ListStory = StoryObj<typeof ChatSuggestions>;
|
|
69
99
|
|
|
100
|
+
/** One follow-up question under a finished answer; selecting it sends it as the next message. */
|
|
70
101
|
export const Default: Story = {
|
|
102
|
+
render: (args) => (
|
|
103
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
104
|
+
<ChatSuggestion {...args} />
|
|
105
|
+
</ChatSuggestions>
|
|
106
|
+
),
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
interface ListArgs {
|
|
110
|
+
onSend: (text: string) => void;
|
|
111
|
+
onMouseLeave: () => void;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Follow-up questions after an answer, numbered by the list; the longest wraps to a second line.
|
|
116
|
+
* Selecting one calls `onSelect`, logged in the Actions panel as `onSend` with its text.
|
|
117
|
+
*/
|
|
118
|
+
export const List: StoryObj<ListArgs> = {
|
|
119
|
+
args: { onSend: fn(), onMouseLeave: fn() },
|
|
120
|
+
render: ({ onSend, onMouseLeave }) => (
|
|
121
|
+
<ChatSuggestions aria-label="Suggested questions" onMouseLeave={onMouseLeave}>
|
|
122
|
+
{FOLLOW_UPS.map((text) => (
|
|
123
|
+
<ChatSuggestion key={text} onSelect={() => onSend(text)}>
|
|
124
|
+
<ChatSuggestionLabelIcon />
|
|
125
|
+
<ChatSuggestionLabel>{text}</ChatSuggestionLabel>
|
|
126
|
+
<ChatSuggestionActions>
|
|
127
|
+
<EnterIcon />
|
|
128
|
+
</ChatSuggestionActions>
|
|
129
|
+
</ChatSuggestion>
|
|
130
|
+
))}
|
|
131
|
+
</ChatSuggestions>
|
|
132
|
+
),
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
/** Clicking a follow-up sends its text once. */
|
|
136
|
+
export const ListSelect: StoryObj<ListArgs> = {
|
|
137
|
+
...List,
|
|
138
|
+
tags: ['e2e', '!autodocs'],
|
|
139
|
+
play: async ({ args, canvas, userEvent }) => {
|
|
140
|
+
await userEvent.click(canvas.getByRole('button', { name: FOLLOW_UPS[1] }));
|
|
141
|
+
|
|
142
|
+
await expect(args.onSend).toHaveBeenCalledTimes(1);
|
|
143
|
+
await expect(args.onSend).toHaveBeenCalledWith(FOLLOW_UPS[1]);
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
/** A disabled suggestion ignores clicks and the arrow keys skip it. */
|
|
148
|
+
export const DisabledSuggestion: StoryObj<ListArgs> = {
|
|
149
|
+
tags: ['e2e', '!autodocs'],
|
|
150
|
+
args: { onSend: fn(), onMouseLeave: fn() },
|
|
151
|
+
render: ({ onSend }) => (
|
|
152
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
153
|
+
{FOLLOW_UPS.map((text, position) => (
|
|
154
|
+
<ChatSuggestion key={text} isDisabled={position === 1} onSelect={() => onSend(text)}>
|
|
155
|
+
<ChatSuggestionLabelIcon />
|
|
156
|
+
<ChatSuggestionLabel>{text}</ChatSuggestionLabel>
|
|
157
|
+
<ChatSuggestionActions>
|
|
158
|
+
<EnterIcon />
|
|
159
|
+
</ChatSuggestionActions>
|
|
160
|
+
</ChatSuggestion>
|
|
161
|
+
))}
|
|
162
|
+
</ChatSuggestions>
|
|
163
|
+
),
|
|
164
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
165
|
+
const [first, second, third] = canvas.getAllByRole('button');
|
|
166
|
+
|
|
167
|
+
await step('The disabled suggestion says so and does not send', async () => {
|
|
168
|
+
await expect(second).toHaveAttribute('aria-disabled', 'true');
|
|
169
|
+
await userEvent.click(second);
|
|
170
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
await step('ArrowDown goes from the first suggestion to the third', async () => {
|
|
174
|
+
await userEvent.tab();
|
|
175
|
+
await expect(first).toHaveFocus();
|
|
176
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
177
|
+
await expect(third).toHaveFocus();
|
|
178
|
+
});
|
|
179
|
+
},
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
/** Quick replies to a question the assistant asked: confirming the address before an email is sent. */
|
|
183
|
+
export const QuickReplies: ListStory = {
|
|
184
|
+
parameters: { controls: { disable: true } },
|
|
185
|
+
render: () => (
|
|
186
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
187
|
+
{QUICK_REPLIES.map((text) => (
|
|
188
|
+
<ChatSuggestion key={text}>
|
|
189
|
+
<ChatSuggestionLabelIcon />
|
|
190
|
+
<ChatSuggestionLabel>{text}</ChatSuggestionLabel>
|
|
191
|
+
<ChatSuggestionActions>
|
|
192
|
+
<EnterIcon />
|
|
193
|
+
</ChatSuggestionActions>
|
|
194
|
+
</ChatSuggestion>
|
|
195
|
+
))}
|
|
196
|
+
</ChatSuggestions>
|
|
197
|
+
),
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/** In a narrow panel, `isMultiline={false}` keeps each suggestion to one truncated line. */
|
|
201
|
+
export const Truncated: ListStory = {
|
|
202
|
+
parameters: { controls: { disable: true } },
|
|
71
203
|
render: () => (
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
204
|
+
<div className="max-w-80">
|
|
205
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
206
|
+
{FOLLOW_UPS.map((text) => (
|
|
207
|
+
<ChatSuggestion key={text}>
|
|
208
|
+
<ChatSuggestionLabelIcon />
|
|
209
|
+
<ChatSuggestionLabel isMultiline={false}>{text}</ChatSuggestionLabel>
|
|
210
|
+
<ChatSuggestionActions>
|
|
211
|
+
<EnterIcon />
|
|
212
|
+
</ChatSuggestionActions>
|
|
213
|
+
</ChatSuggestion>
|
|
214
|
+
))}
|
|
215
|
+
</ChatSuggestions>
|
|
216
|
+
</div>
|
|
79
217
|
),
|
|
80
218
|
};
|
|
81
219
|
|
|
82
|
-
|
|
220
|
+
/** Conversation starters with an icon in place of the number, one per kind of task. */
|
|
221
|
+
export const WithIcons: ListStory = {
|
|
222
|
+
parameters: { controls: { disable: true } },
|
|
83
223
|
render: () => (
|
|
84
|
-
<ChatSuggestions>
|
|
224
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
85
225
|
<ChatSuggestion>
|
|
86
|
-
<ChatSuggestionLabelIcon
|
|
87
|
-
|
|
226
|
+
<ChatSuggestionLabelIcon>
|
|
227
|
+
<CalendarIcon />
|
|
228
|
+
</ChatSuggestionLabelIcon>
|
|
229
|
+
<ChatSuggestionLabel>Check my calendar for today</ChatSuggestionLabel>
|
|
88
230
|
<ChatSuggestionActions>
|
|
89
231
|
<EnterIcon />
|
|
90
232
|
</ChatSuggestionActions>
|
|
91
233
|
</ChatSuggestion>
|
|
92
234
|
<ChatSuggestion>
|
|
93
|
-
<ChatSuggestionLabelIcon
|
|
94
|
-
|
|
235
|
+
<ChatSuggestionLabelIcon>
|
|
236
|
+
<MailIcon />
|
|
237
|
+
</ChatSuggestionLabelIcon>
|
|
238
|
+
<ChatSuggestionLabel>Summarise my unread emails</ChatSuggestionLabel>
|
|
95
239
|
<ChatSuggestionActions>
|
|
96
240
|
<EnterIcon />
|
|
97
241
|
</ChatSuggestionActions>
|
|
98
242
|
</ChatSuggestion>
|
|
99
243
|
<ChatSuggestion>
|
|
100
|
-
<ChatSuggestionLabelIcon
|
|
101
|
-
|
|
244
|
+
<ChatSuggestionLabelIcon>
|
|
245
|
+
<SearchIcon />
|
|
246
|
+
</ChatSuggestionLabelIcon>
|
|
247
|
+
<ChatSuggestionLabel>Find the slides Marc sent last week</ChatSuggestionLabel>
|
|
102
248
|
<ChatSuggestionActions>
|
|
103
249
|
<EnterIcon />
|
|
104
250
|
</ChatSuggestionActions>
|
|
105
251
|
</ChatSuggestion>
|
|
106
|
-
|
|
252
|
+
</ChatSuggestions>
|
|
253
|
+
),
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
interface WithActionsArgs {
|
|
257
|
+
onSend: () => void;
|
|
258
|
+
onDismiss: () => void;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/** A dismiss button in the actions, wrapped in `ChatSuggestionAction` so dismissing doesn't also send the suggestion. */
|
|
262
|
+
export const WithActions: StoryObj<WithActionsArgs> = {
|
|
263
|
+
args: { onSend: fn(), onDismiss: fn() },
|
|
264
|
+
render: ({ onSend, onDismiss }) => (
|
|
265
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
266
|
+
<ChatSuggestion onSelect={onSend}>
|
|
107
267
|
<ChatSuggestionLabelIcon />
|
|
108
|
-
<ChatSuggestionLabel
|
|
109
|
-
Inline. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor
|
|
110
|
-
incididunt ut labore et dolore magna aliqua.
|
|
111
|
-
</ChatSuggestionLabel>
|
|
112
|
-
<ChatSuggestionActions>
|
|
113
|
-
<EnterIcon />
|
|
114
|
-
</ChatSuggestionActions>
|
|
115
|
-
</ChatSuggestion>
|
|
116
|
-
<ChatSuggestion>
|
|
117
|
-
<ChatSuggestionLabelIcon>
|
|
118
|
-
<PersonIcon />
|
|
119
|
-
</ChatSuggestionLabelIcon>
|
|
120
|
-
<ChatSuggestionLabel isMultiline>
|
|
121
|
-
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt
|
|
122
|
-
ut labore et dolore magna aliqua.Lorem ipsum dolor sit amet, consectetur adipiscing elit.
|
|
123
|
-
Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
124
|
-
</ChatSuggestionLabel>
|
|
268
|
+
<ChatSuggestionLabel>Prep talking points for my 1:1 with Anna</ChatSuggestionLabel>
|
|
125
269
|
<ChatSuggestionActions>
|
|
126
|
-
<
|
|
270
|
+
<ChatSuggestionAction>
|
|
271
|
+
<IconButton
|
|
272
|
+
size="xs"
|
|
273
|
+
variant="tertiary"
|
|
274
|
+
aria-label="Dismiss suggestion"
|
|
275
|
+
onClick={onDismiss}
|
|
276
|
+
>
|
|
277
|
+
<CloseIcon />
|
|
278
|
+
</IconButton>
|
|
279
|
+
</ChatSuggestionAction>
|
|
127
280
|
</ChatSuggestionActions>
|
|
128
281
|
</ChatSuggestion>
|
|
129
282
|
</ChatSuggestions>
|
|
130
283
|
),
|
|
131
284
|
};
|
|
132
285
|
|
|
133
|
-
|
|
286
|
+
/** Dismissing a suggestion does not send it; clicking the rest of the row does. */
|
|
287
|
+
export const WithActionsDismiss: StoryObj<WithActionsArgs> = {
|
|
288
|
+
...WithActions,
|
|
289
|
+
tags: ['e2e', '!autodocs'],
|
|
290
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
291
|
+
await step('The dismiss button only dismisses', async () => {
|
|
292
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Dismiss suggestion' }));
|
|
293
|
+
|
|
294
|
+
await expect(args.onDismiss).toHaveBeenCalledTimes(1);
|
|
295
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
await step('The suggestion itself still sends', async () => {
|
|
299
|
+
await userEvent.click(
|
|
300
|
+
canvas.getByRole('button', { name: 'Prep talking points for my 1:1 with Anna' }),
|
|
301
|
+
);
|
|
302
|
+
|
|
303
|
+
await expect(args.onSend).toHaveBeenCalledTimes(1);
|
|
304
|
+
await expect(args.onDismiss).toHaveBeenCalledTimes(1);
|
|
305
|
+
});
|
|
306
|
+
},
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
interface KeyboardArgs {
|
|
310
|
+
onSend: (text: string) => void;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Tab reaches the list once, the arrow keys move between suggestions and wrap, Enter sends. */
|
|
314
|
+
export const Keyboard: StoryObj<KeyboardArgs> = {
|
|
315
|
+
args: { onSend: fn() },
|
|
316
|
+
render: ({ onSend }) => (
|
|
317
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
318
|
+
{FOLLOW_UPS.map((text) => (
|
|
319
|
+
<ChatSuggestion key={text} onSelect={() => onSend(text)}>
|
|
320
|
+
<ChatSuggestionLabelIcon />
|
|
321
|
+
<ChatSuggestionLabel>{text}</ChatSuggestionLabel>
|
|
322
|
+
<ChatSuggestionActions>
|
|
323
|
+
<EnterIcon />
|
|
324
|
+
</ChatSuggestionActions>
|
|
325
|
+
</ChatSuggestion>
|
|
326
|
+
))}
|
|
327
|
+
</ChatSuggestions>
|
|
328
|
+
),
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/** Tab lands on the first suggestion, the arrows move and wrap, Enter sends the focused one. */
|
|
332
|
+
export const KeyboardNavigation: StoryObj<KeyboardArgs> = {
|
|
333
|
+
...Keyboard,
|
|
334
|
+
tags: ['e2e', '!autodocs'],
|
|
335
|
+
play: async ({ args, canvas, userEvent }) => {
|
|
336
|
+
const list = canvas.getByRole('list', { name: 'Suggested questions' });
|
|
337
|
+
const [first, second, third] = within(list).getAllByRole('button');
|
|
338
|
+
|
|
339
|
+
await userEvent.tab();
|
|
340
|
+
await expect(first).toHaveFocus();
|
|
341
|
+
|
|
342
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
343
|
+
await expect(second).toHaveFocus();
|
|
344
|
+
|
|
345
|
+
// The list loops: ArrowUp from the first suggestion lands on the last.
|
|
346
|
+
await userEvent.keyboard('{ArrowUp}{ArrowUp}');
|
|
347
|
+
await expect(third).toHaveFocus();
|
|
348
|
+
|
|
349
|
+
await userEvent.keyboard('{Enter}');
|
|
350
|
+
await expect(args.onSend).toHaveBeenCalledWith(FOLLOW_UPS[2]);
|
|
351
|
+
},
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
interface PointerPreviewArgs {
|
|
355
|
+
onHover: (text: string) => void;
|
|
356
|
+
onMouseLeave: () => void;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** Follow-ups with a line underneath that repeats the text of the one under the pointer. */
|
|
360
|
+
function PointerPreviewSuggestions({ onHover, onMouseLeave }: PointerPreviewArgs) {
|
|
361
|
+
const [preview, setPreview] = useState<string | null>(null);
|
|
362
|
+
|
|
363
|
+
return (
|
|
364
|
+
<div className="flex flex-col gap-8">
|
|
365
|
+
<ChatSuggestions
|
|
366
|
+
aria-label="Suggested questions"
|
|
367
|
+
onMouseLeave={() => {
|
|
368
|
+
setPreview(null);
|
|
369
|
+
onMouseLeave();
|
|
370
|
+
}}
|
|
371
|
+
>
|
|
372
|
+
{FOLLOW_UPS.map((text) => (
|
|
373
|
+
<ChatSuggestion
|
|
374
|
+
key={text}
|
|
375
|
+
onHover={() => {
|
|
376
|
+
setPreview(text);
|
|
377
|
+
onHover(text);
|
|
378
|
+
}}
|
|
379
|
+
>
|
|
380
|
+
<ChatSuggestionLabelIcon />
|
|
381
|
+
<ChatSuggestionLabel isMultiline={false}>{text}</ChatSuggestionLabel>
|
|
382
|
+
<ChatSuggestionActions>
|
|
383
|
+
<EnterIcon />
|
|
384
|
+
</ChatSuggestionActions>
|
|
385
|
+
</ChatSuggestion>
|
|
386
|
+
))}
|
|
387
|
+
</ChatSuggestions>
|
|
388
|
+
<Typography
|
|
389
|
+
role="status"
|
|
390
|
+
variant="caption-md"
|
|
391
|
+
className="min-h-16 px-8 text-typography-text-secondary"
|
|
392
|
+
>
|
|
393
|
+
{preview}
|
|
394
|
+
</Typography>
|
|
395
|
+
</div>
|
|
396
|
+
);
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* The pointer callbacks driving a preview that repeats the hovered suggestion's text: `onHover` on
|
|
401
|
+
* a suggestion fires when the pointer enters it, `onMouseLeave` on the list when it leaves the
|
|
402
|
+
* list. Keyboard highlight calls neither.
|
|
403
|
+
*/
|
|
404
|
+
export const PointerPreview: StoryObj<PointerPreviewArgs> = {
|
|
405
|
+
args: { onHover: fn(), onMouseLeave: fn() },
|
|
406
|
+
render: (args) => <PointerPreviewSuggestions {...args} />,
|
|
407
|
+
};
|
|
408
|
+
|
|
409
|
+
/** Hovering a suggestion shows its text in the preview; leaving the list clears it. */
|
|
410
|
+
export const PointerPreviewHover: StoryObj<PointerPreviewArgs> = {
|
|
411
|
+
...PointerPreview,
|
|
412
|
+
tags: ['e2e', '!autodocs'],
|
|
413
|
+
play: async ({ args, canvas, userEvent }) => {
|
|
414
|
+
const list = canvas.getByRole('list', { name: 'Suggested questions' });
|
|
415
|
+
const status = canvas.getByRole('status');
|
|
416
|
+
|
|
417
|
+
await userEvent.hover(canvas.getByRole('button', { name: FOLLOW_UPS[1] }));
|
|
418
|
+
|
|
419
|
+
await expect(args.onHover).toHaveBeenCalledWith(FOLLOW_UPS[1]);
|
|
420
|
+
await expect(status).toHaveTextContent(FOLLOW_UPS[1]);
|
|
421
|
+
|
|
422
|
+
await userEvent.unhover(list);
|
|
423
|
+
|
|
424
|
+
await expect(args.onMouseLeave).toHaveBeenCalledTimes(1);
|
|
425
|
+
await expect(status).toBeEmptyDOMElement();
|
|
426
|
+
},
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
function FollowUpSuggestions() {
|
|
430
|
+
return (
|
|
431
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
432
|
+
{FOLLOW_UPS.map((text) => (
|
|
433
|
+
<ChatSuggestion key={text}>
|
|
434
|
+
<ChatSuggestionLabelIcon />
|
|
435
|
+
<ChatSuggestionLabel isMultiline={false}>{text}</ChatSuggestionLabel>
|
|
436
|
+
<ChatSuggestionActions>
|
|
437
|
+
<EnterIcon />
|
|
438
|
+
</ChatSuggestionActions>
|
|
439
|
+
</ChatSuggestion>
|
|
440
|
+
))}
|
|
441
|
+
</ChatSuggestions>
|
|
442
|
+
);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/** The suggestions in each place they're allowed: a canvas footer, a chat footer and an empty conversation. */
|
|
446
|
+
export const Examples: Story = {
|
|
447
|
+
parameters: { controls: { disable: true } },
|
|
134
448
|
render: () => (
|
|
135
|
-
<
|
|
136
|
-
<
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
449
|
+
<div className="flex flex-col gap-24">
|
|
450
|
+
<ParentBlock parent="web-chat-ui/CanvasShellFooter">
|
|
451
|
+
<CanvasShellFooter className="flex-col items-stretch rounded-10 border border-divider-border-base">
|
|
452
|
+
<FollowUpSuggestions />
|
|
453
|
+
<ChatInput>
|
|
454
|
+
<ChatInputTextarea placeholder="How can I help?" />
|
|
455
|
+
</ChatInput>
|
|
456
|
+
</CanvasShellFooter>
|
|
457
|
+
</ParentBlock>
|
|
458
|
+
|
|
459
|
+
<ParentBlock parent="chat footer, above ChatInput">
|
|
460
|
+
<div aria-label="Chat footer" className="flex flex-col gap-8">
|
|
461
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
462
|
+
{QUICK_REPLIES.map((text) => (
|
|
463
|
+
<ChatSuggestion key={text}>
|
|
464
|
+
<ChatSuggestionLabelIcon />
|
|
465
|
+
<ChatSuggestionLabel>{text}</ChatSuggestionLabel>
|
|
466
|
+
<ChatSuggestionActions>
|
|
467
|
+
<EnterIcon />
|
|
468
|
+
</ChatSuggestionActions>
|
|
469
|
+
</ChatSuggestion>
|
|
470
|
+
))}
|
|
471
|
+
</ChatSuggestions>
|
|
472
|
+
<ChatInput>
|
|
473
|
+
<ChatInputTextarea placeholder="How can I help?" />
|
|
474
|
+
</ChatInput>
|
|
475
|
+
</div>
|
|
476
|
+
</ParentBlock>
|
|
477
|
+
|
|
478
|
+
<ParentBlock parent="empty conversation">
|
|
479
|
+
<section aria-label="New conversation" className="flex flex-col gap-16">
|
|
480
|
+
<EmptyState>
|
|
481
|
+
<EmptyStateIcon>
|
|
482
|
+
<NewChatIcon />
|
|
483
|
+
</EmptyStateIcon>
|
|
484
|
+
<EmptyStateTitle>Good morning, Sarah</EmptyStateTitle>
|
|
485
|
+
<EmptyStateDescription>
|
|
486
|
+
Ask about your calendar, emails or files. Pick a question below or type your own.
|
|
487
|
+
</EmptyStateDescription>
|
|
488
|
+
</EmptyState>
|
|
489
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
490
|
+
{CONVERSATION_STARTERS.map((text) => (
|
|
491
|
+
<ChatSuggestion key={text}>
|
|
492
|
+
<ChatSuggestionLabelIcon />
|
|
493
|
+
<ChatSuggestionLabel>{text}</ChatSuggestionLabel>
|
|
494
|
+
<ChatSuggestionActions>
|
|
495
|
+
<EnterIcon />
|
|
496
|
+
</ChatSuggestionActions>
|
|
497
|
+
</ChatSuggestion>
|
|
498
|
+
))}
|
|
499
|
+
</ChatSuggestions>
|
|
500
|
+
</section>
|
|
501
|
+
</ParentBlock>
|
|
502
|
+
</div>
|
|
146
503
|
),
|
|
147
504
|
};
|
|
505
|
+
|
|
506
|
+
interface ChatSuggestionPlaygroundProps {
|
|
507
|
+
label: string;
|
|
508
|
+
isMultiline: boolean;
|
|
509
|
+
icon: ReactNode;
|
|
510
|
+
hasActions: boolean;
|
|
511
|
+
action: 'Enter hint' | 'Dismiss button';
|
|
512
|
+
isDisabled: boolean;
|
|
513
|
+
hasLoop: boolean;
|
|
514
|
+
onSelect: (text: string) => void;
|
|
515
|
+
onHover: () => void;
|
|
516
|
+
onDismiss: () => void;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
function ChatSuggestionPlayground({
|
|
520
|
+
label,
|
|
521
|
+
isMultiline,
|
|
522
|
+
icon,
|
|
523
|
+
hasActions,
|
|
524
|
+
action,
|
|
525
|
+
isDisabled,
|
|
526
|
+
hasLoop,
|
|
527
|
+
onSelect,
|
|
528
|
+
onHover,
|
|
529
|
+
onDismiss,
|
|
530
|
+
}: ChatSuggestionPlaygroundProps) {
|
|
531
|
+
return (
|
|
532
|
+
<ChatSuggestions aria-label="Suggested questions" hasLoop={hasLoop}>
|
|
533
|
+
<ChatSuggestion isDisabled={isDisabled} onSelect={() => onSelect(label)} onHover={onHover}>
|
|
534
|
+
<ChatSuggestionLabelIcon>{icon}</ChatSuggestionLabelIcon>
|
|
535
|
+
<ChatSuggestionLabel isMultiline={isMultiline}>{label}</ChatSuggestionLabel>
|
|
536
|
+
{hasActions && (
|
|
537
|
+
<ChatSuggestionActions>
|
|
538
|
+
{action === 'Enter hint' ? (
|
|
539
|
+
<EnterIcon />
|
|
540
|
+
) : (
|
|
541
|
+
<ChatSuggestionAction>
|
|
542
|
+
<IconButton
|
|
543
|
+
size="xs"
|
|
544
|
+
variant="tertiary"
|
|
545
|
+
aria-label="Dismiss suggestion"
|
|
546
|
+
onClick={onDismiss}
|
|
547
|
+
>
|
|
548
|
+
<CloseIcon />
|
|
549
|
+
</IconButton>
|
|
550
|
+
</ChatSuggestionAction>
|
|
551
|
+
)}
|
|
552
|
+
</ChatSuggestionActions>
|
|
553
|
+
)}
|
|
554
|
+
</ChatSuggestion>
|
|
555
|
+
{FOLLOW_UPS.slice(0, 2).map((text) => (
|
|
556
|
+
<ChatSuggestion key={text} onSelect={() => onSelect(text)}>
|
|
557
|
+
<ChatSuggestionLabelIcon />
|
|
558
|
+
<ChatSuggestionLabel isMultiline={isMultiline}>{text}</ChatSuggestionLabel>
|
|
559
|
+
<ChatSuggestionActions>
|
|
560
|
+
<EnterIcon />
|
|
561
|
+
</ChatSuggestionActions>
|
|
562
|
+
</ChatSuggestion>
|
|
563
|
+
))}
|
|
564
|
+
</ChatSuggestions>
|
|
565
|
+
);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
/** Every part of a suggestion at once; the controls drive the first one, the other two make the list navigable. */
|
|
569
|
+
export const Playground: StoryObj<typeof ChatSuggestionPlayground> = {
|
|
570
|
+
tags: ['!autodocs'],
|
|
571
|
+
// The meta's own controls drive `ChatSuggestion` directly; the wrapper replaces them here.
|
|
572
|
+
parameters: { controls: { exclude: ['index', 'className', 'triggerClassName', 'children'] } },
|
|
573
|
+
args: {
|
|
574
|
+
label: FOLLOW_UPS[2],
|
|
575
|
+
isMultiline: true,
|
|
576
|
+
icon: 'Number',
|
|
577
|
+
hasActions: true,
|
|
578
|
+
action: 'Dismiss button',
|
|
579
|
+
isDisabled: false,
|
|
580
|
+
hasLoop: true,
|
|
581
|
+
onSelect: fn(),
|
|
582
|
+
onHover: fn(),
|
|
583
|
+
onDismiss: fn(),
|
|
584
|
+
},
|
|
585
|
+
argTypes: {
|
|
586
|
+
label: {
|
|
587
|
+
control: 'text',
|
|
588
|
+
description: 'Text of the first suggestion’s `ChatSuggestionLabel`.',
|
|
589
|
+
},
|
|
590
|
+
isMultiline: {
|
|
591
|
+
control: 'boolean',
|
|
592
|
+
description:
|
|
593
|
+
'`isMultiline` on every `ChatSuggestionLabel`: up to three lines, or one truncated line.',
|
|
594
|
+
},
|
|
595
|
+
icon: {
|
|
596
|
+
control: 'select',
|
|
597
|
+
options: ['Number', 'Calendar', 'Mail', 'Search'],
|
|
598
|
+
mapping: {
|
|
599
|
+
Number: null,
|
|
600
|
+
Calendar: <CalendarIcon />,
|
|
601
|
+
Mail: <MailIcon />,
|
|
602
|
+
Search: <SearchIcon />,
|
|
603
|
+
},
|
|
604
|
+
description:
|
|
605
|
+
'Children of the first `ChatSuggestionLabelIcon`: none shows its number, an icon replaces it.',
|
|
606
|
+
},
|
|
607
|
+
hasActions: {
|
|
608
|
+
control: 'boolean',
|
|
609
|
+
description: 'Renders `ChatSuggestionActions` in the first suggestion.',
|
|
610
|
+
},
|
|
611
|
+
action: {
|
|
612
|
+
control: 'inline-radio',
|
|
613
|
+
options: ['Enter hint', 'Dismiss button'],
|
|
614
|
+
description:
|
|
615
|
+
'What the actions hold: a hint icon, or an `IconButton` wrapped in `ChatSuggestionAction`.',
|
|
616
|
+
if: { arg: 'hasActions' },
|
|
617
|
+
},
|
|
618
|
+
isDisabled: {
|
|
619
|
+
control: 'boolean',
|
|
620
|
+
description: '`isDisabled` on the first suggestion.',
|
|
621
|
+
},
|
|
622
|
+
hasLoop: {
|
|
623
|
+
control: 'boolean',
|
|
624
|
+
description: '`hasLoop` on `ChatSuggestions`: the arrow keys wrap at the ends of the list.',
|
|
625
|
+
},
|
|
626
|
+
onSelect: { description: 'Called with the text of the suggestion that was selected.' },
|
|
627
|
+
onHover: { description: 'Called when the pointer enters the first suggestion.' },
|
|
628
|
+
onDismiss: { description: 'Called when the dismiss button is pressed.' },
|
|
629
|
+
},
|
|
630
|
+
render: (args) => <ChatSuggestionPlayground {...args} />,
|
|
631
|
+
};
|