@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,25 +1,44 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { fn } from 'storybook/test';
|
|
2
|
+
import { useState, type KeyboardEvent, type MouseEvent } from 'react';
|
|
3
|
+
import { expect, fn, waitFor } from 'storybook/test';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
import { IconButton } from '@swisper.ai/ui';
|
|
5
|
+
import { AddIcon, EnterIcon, MicIcon, StopIcon } from '@swisper.ai/icons';
|
|
6
|
+
import { IconButton, Typography } from '@swisper.ai/ui';
|
|
7
7
|
|
|
8
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
9
|
+
import { ChatContainer, ChatContainerPrompt } from '../chat-container';
|
|
10
|
+
import {
|
|
11
|
+
ChatMessageAttachmentCard,
|
|
12
|
+
ChatMessageAttachmentCardActions,
|
|
13
|
+
ChatMessageAttachmentCardContent,
|
|
14
|
+
ChatMessageAttachmentCardIcon,
|
|
15
|
+
ChatMessageAttachmentCardTitle,
|
|
16
|
+
} from '../chat-message-attachment-card';
|
|
17
|
+
|
|
18
|
+
import { ATTACHED_FILES, LONG_PROMPT } from './__stories__/fixtures';
|
|
8
19
|
import {
|
|
9
20
|
ChatPromptBox,
|
|
10
21
|
ChatPromptBoxActionsLeft,
|
|
11
22
|
ChatPromptBoxActionsRight,
|
|
12
23
|
ChatPromptBoxContent,
|
|
13
24
|
ChatPromptBoxInput,
|
|
25
|
+
ChatPromptBoxToolbar,
|
|
14
26
|
} from './chat-prompt-box';
|
|
15
27
|
|
|
16
28
|
const meta: Meta<typeof ChatPromptBox> = {
|
|
17
|
-
title: '
|
|
29
|
+
title: 'Chat/ChatPromptBox',
|
|
18
30
|
component: ChatPromptBox,
|
|
31
|
+
subcomponents: {
|
|
32
|
+
ChatPromptBoxToolbar,
|
|
33
|
+
ChatPromptBoxContent,
|
|
34
|
+
ChatPromptBoxInput,
|
|
35
|
+
ChatPromptBoxActionsLeft,
|
|
36
|
+
ChatPromptBoxActionsRight,
|
|
37
|
+
},
|
|
19
38
|
tags: ['autodocs'],
|
|
20
39
|
decorators: [
|
|
21
40
|
(Story) => (
|
|
22
|
-
<div className="max-w-
|
|
41
|
+
<div className="max-w-chat-area">
|
|
23
42
|
<Story />
|
|
24
43
|
</div>
|
|
25
44
|
),
|
|
@@ -34,11 +53,16 @@ const meta: Meta<typeof ChatPromptBox> = {
|
|
|
34
53
|
children: {
|
|
35
54
|
control: false,
|
|
36
55
|
description:
|
|
37
|
-
'A `ChatPromptBoxContent` holding the `ChatPromptBoxInput` and the `ChatPromptBoxActionsLeft` / `ChatPromptBoxActionsRight` buttons.',
|
|
56
|
+
'A `ChatPromptBoxContent` holding the `ChatPromptBoxInput` and the `ChatPromptBoxActionsLeft` / `ChatPromptBoxActionsRight` buttons, with an optional `ChatPromptBoxToolbar` above it.',
|
|
38
57
|
},
|
|
39
58
|
className: {
|
|
40
59
|
control: 'text',
|
|
41
|
-
description: 'Extra classes merged onto the root.',
|
|
60
|
+
description: 'Extra classes merged onto the root, the 1px border ring around the box.',
|
|
61
|
+
},
|
|
62
|
+
innerClassName: {
|
|
63
|
+
control: 'text',
|
|
64
|
+
description:
|
|
65
|
+
'Extra classes merged onto the surface inside the border, which carries the background and padding.',
|
|
42
66
|
},
|
|
43
67
|
onMouseDown: {
|
|
44
68
|
description:
|
|
@@ -53,20 +77,14 @@ const meta: Meta<typeof ChatPromptBox> = {
|
|
|
53
77
|
export default meta;
|
|
54
78
|
type Story = StoryObj<typeof ChatPromptBox>;
|
|
55
79
|
|
|
80
|
+
/** The composer of a chat page: a question-style placeholder and one primary send action at the end. */
|
|
56
81
|
export const Default: Story = {
|
|
57
|
-
render: () => (
|
|
58
|
-
<ChatPromptBox>
|
|
82
|
+
render: (args) => (
|
|
83
|
+
<ChatPromptBox {...args}>
|
|
59
84
|
<ChatPromptBoxContent>
|
|
60
|
-
<ChatPromptBoxInput
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
if (event.key === 'Enter' && !event.shiftKey) {
|
|
64
|
-
alert('Enter pressed');
|
|
65
|
-
}
|
|
66
|
-
}}
|
|
67
|
-
/>
|
|
68
|
-
<ChatPromptBoxActionsRight>
|
|
69
|
-
<IconButton size="md" variant="primary" color="primary" aria-label="Send message">
|
|
85
|
+
<ChatPromptBoxInput placeholder="How can I help?" />
|
|
86
|
+
<ChatPromptBoxActionsRight aria-label="Message actions">
|
|
87
|
+
<IconButton size="md" variant="primary" aria-label="Send message">
|
|
70
88
|
<EnterIcon />
|
|
71
89
|
</IconButton>
|
|
72
90
|
</ChatPromptBoxActionsRight>
|
|
@@ -75,39 +93,136 @@ export const Default: Story = {
|
|
|
75
93
|
),
|
|
76
94
|
};
|
|
77
95
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
interface ChatComposerProps {
|
|
97
|
+
placeholder: string;
|
|
98
|
+
initialMessage?: string;
|
|
99
|
+
autoFocus?: boolean;
|
|
100
|
+
isDisabled?: boolean;
|
|
101
|
+
isStreaming?: boolean;
|
|
102
|
+
onSend: (message: string) => void;
|
|
103
|
+
onStop: () => void;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function ChatComposer({
|
|
107
|
+
placeholder,
|
|
108
|
+
initialMessage = '',
|
|
109
|
+
autoFocus = true,
|
|
110
|
+
isDisabled = false,
|
|
111
|
+
isStreaming = false,
|
|
112
|
+
onSend,
|
|
113
|
+
onStop,
|
|
114
|
+
}: ChatComposerProps) {
|
|
115
|
+
const [message, setMessage] = useState(initialMessage);
|
|
116
|
+
const canSend = !isDisabled && message.trim().length > 0;
|
|
117
|
+
|
|
118
|
+
const send = () => {
|
|
119
|
+
if (!canSend) {
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
onSend(message.trim());
|
|
124
|
+
setMessage('');
|
|
125
|
+
};
|
|
83
126
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
127
|
+
// Enter sends, Shift+Enter keeps the editor's new line.
|
|
128
|
+
const handleKeyDown = (event: KeyboardEvent<HTMLDivElement>) => {
|
|
129
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
130
|
+
event.preventDefault();
|
|
131
|
+
send();
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<ChatPromptBox>
|
|
137
|
+
<ChatPromptBoxContent>
|
|
138
|
+
<ChatPromptBoxInput
|
|
139
|
+
value={message}
|
|
140
|
+
placeholder={placeholder}
|
|
141
|
+
autoFocus={autoFocus}
|
|
142
|
+
isDisabled={isDisabled}
|
|
143
|
+
onChange={setMessage}
|
|
144
|
+
onKeyDown={handleKeyDown}
|
|
145
|
+
/>
|
|
146
|
+
<ChatPromptBoxActionsRight aria-label="Message actions">
|
|
147
|
+
{isStreaming ? (
|
|
148
|
+
<IconButton size="md" variant="prominent" aria-label="Stop message" onClick={onStop}>
|
|
149
|
+
<StopIcon />
|
|
150
|
+
</IconButton>
|
|
151
|
+
) : (
|
|
152
|
+
<IconButton
|
|
153
|
+
size="md"
|
|
154
|
+
variant="primary"
|
|
155
|
+
aria-label="Send message"
|
|
156
|
+
isDisabled={!canSend}
|
|
157
|
+
onClick={send}
|
|
158
|
+
>
|
|
90
159
|
<EnterIcon />
|
|
91
160
|
</IconButton>
|
|
92
|
-
|
|
93
|
-
</
|
|
94
|
-
</
|
|
95
|
-
|
|
161
|
+
)}
|
|
162
|
+
</ChatPromptBoxActionsRight>
|
|
163
|
+
</ChatPromptBoxContent>
|
|
164
|
+
</ChatPromptBox>
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
type ComposerStory = StoryObj<typeof ChatComposer>;
|
|
169
|
+
|
|
170
|
+
// The composer owns its `ChatPromptBox`, so the root's own controls do nothing in its stories.
|
|
171
|
+
const composerParameters: ComposerStory['parameters'] = {
|
|
172
|
+
controls: {
|
|
173
|
+
exclude: ['initialConfig', 'children', 'className', 'innerClassName', 'onMouseDown'],
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
const composerArgTypes: ComposerStory['argTypes'] = {
|
|
178
|
+
placeholder: { control: 'text', description: '`placeholder` of `ChatPromptBoxInput`.' },
|
|
179
|
+
initialMessage: {
|
|
180
|
+
control: 'text',
|
|
181
|
+
description: 'Markdown the input starts with. The composer then owns the value.',
|
|
182
|
+
},
|
|
183
|
+
autoFocus: { control: 'boolean', description: '`autoFocus` of `ChatPromptBoxInput`.' },
|
|
184
|
+
isDisabled: {
|
|
185
|
+
control: 'boolean',
|
|
186
|
+
description: '`isDisabled` of `ChatPromptBoxInput`; also disables send.',
|
|
187
|
+
},
|
|
188
|
+
isStreaming: {
|
|
189
|
+
control: 'boolean',
|
|
190
|
+
description: 'A reply is being written: the send action becomes Stop.',
|
|
191
|
+
},
|
|
192
|
+
onSend: { description: 'Called with the trimmed message on Enter or a click on send.' },
|
|
193
|
+
onStop: { description: 'Called when Stop is clicked while a reply is streaming.' },
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
/** A message long enough to wrap: the box expands and moves send under the text, so the text keeps the full width. */
|
|
197
|
+
export const Multiline: ComposerStory = {
|
|
198
|
+
args: {
|
|
199
|
+
placeholder: 'How can I help?',
|
|
200
|
+
initialMessage: LONG_PROMPT,
|
|
201
|
+
autoFocus: false,
|
|
202
|
+
onSend: fn(),
|
|
203
|
+
onStop: fn(),
|
|
96
204
|
},
|
|
205
|
+
argTypes: composerArgTypes,
|
|
206
|
+
parameters: composerParameters,
|
|
207
|
+
render: (args) => <ChatComposer {...args} />,
|
|
97
208
|
};
|
|
98
209
|
|
|
210
|
+
/** Secondary tools before the text and send alone at the end, written in the order they are shown so Tab follows it. */
|
|
99
211
|
export const WithLeftActions: Story = {
|
|
100
|
-
render: () => (
|
|
101
|
-
<ChatPromptBox>
|
|
212
|
+
render: (args) => (
|
|
213
|
+
<ChatPromptBox {...args}>
|
|
102
214
|
<ChatPromptBoxContent>
|
|
103
|
-
<
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
<AttachmentsIcon />
|
|
215
|
+
<ChatPromptBoxActionsLeft aria-label="Attachments">
|
|
216
|
+
<IconButton size="md" variant="tertiary" aria-label="Upload file">
|
|
217
|
+
<AddIcon />
|
|
107
218
|
</IconButton>
|
|
108
219
|
</ChatPromptBoxActionsLeft>
|
|
109
|
-
<
|
|
110
|
-
|
|
220
|
+
<ChatPromptBoxInput placeholder="How can I help?" autoFocus={false} />
|
|
221
|
+
<ChatPromptBoxActionsRight aria-label="Message actions">
|
|
222
|
+
<IconButton size="md" variant="tertiary" aria-label="Dictate">
|
|
223
|
+
<MicIcon />
|
|
224
|
+
</IconButton>
|
|
225
|
+
<IconButton size="md" variant="primary" aria-label="Send message">
|
|
111
226
|
<EnterIcon />
|
|
112
227
|
</IconButton>
|
|
113
228
|
</ChatPromptBoxActionsRight>
|
|
@@ -115,3 +230,380 @@ export const WithLeftActions: Story = {
|
|
|
115
230
|
</ChatPromptBox>
|
|
116
231
|
),
|
|
117
232
|
};
|
|
233
|
+
|
|
234
|
+
/** A working composer: Enter or the send button sends the message and empties the box, and send stays disabled while there is nothing to send. */
|
|
235
|
+
export const SendMessage: ComposerStory = {
|
|
236
|
+
args: {
|
|
237
|
+
placeholder: 'How can I help?',
|
|
238
|
+
autoFocus: false,
|
|
239
|
+
onSend: fn(),
|
|
240
|
+
onStop: fn(),
|
|
241
|
+
},
|
|
242
|
+
argTypes: composerArgTypes,
|
|
243
|
+
parameters: composerParameters,
|
|
244
|
+
render: (args) => <ChatComposer {...args} />,
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
/** While a reply is streaming, the send action is replaced by Stop. */
|
|
248
|
+
export const Streaming: ComposerStory = {
|
|
249
|
+
...SendMessage,
|
|
250
|
+
args: { ...SendMessage.args, isStreaming: true },
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
/** A composer that takes no input, e.g. once the usage limit for the period is reached. */
|
|
254
|
+
export const Disabled: ComposerStory = {
|
|
255
|
+
...SendMessage,
|
|
256
|
+
args: { ...SendMessage.args, isDisabled: true },
|
|
257
|
+
};
|
|
258
|
+
|
|
259
|
+
/** Types a message, adds a line with Shift+Enter and sends it with Enter, which empties the box. */
|
|
260
|
+
export const SendMessageWithEnter: ComposerStory = {
|
|
261
|
+
...SendMessage,
|
|
262
|
+
tags: ['e2e', '!autodocs'],
|
|
263
|
+
args: { ...SendMessage.args, onSend: fn(), onStop: fn() },
|
|
264
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
265
|
+
const textbox = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
266
|
+
const send = canvas.getByRole('button', { name: 'Send message' });
|
|
267
|
+
|
|
268
|
+
await step('Send is disabled while the box is empty', async () => {
|
|
269
|
+
await expect(send).toBeDisabled();
|
|
270
|
+
});
|
|
271
|
+
|
|
272
|
+
await step('Typing enables send', async () => {
|
|
273
|
+
await userEvent.click(textbox);
|
|
274
|
+
await userEvent.keyboard('Move my 3pm to Friday');
|
|
275
|
+
await waitFor(() => expect(send).toBeEnabled());
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
await step('Shift+Enter does not send', async () => {
|
|
279
|
+
await userEvent.keyboard('{Shift>}{Enter}{/Shift}');
|
|
280
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
await step('Enter sends the message and empties the box', async () => {
|
|
284
|
+
await userEvent.keyboard('{Enter}');
|
|
285
|
+
await expect(args.onSend).toHaveBeenCalledTimes(1);
|
|
286
|
+
await expect(args.onSend).toHaveBeenCalledWith('Move my 3pm to Friday');
|
|
287
|
+
await waitFor(() => expect(textbox).toHaveTextContent(''));
|
|
288
|
+
await expect(send).toBeDisabled();
|
|
289
|
+
});
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
/** A wrapped message puts send under the text; sending it empties the box and brings send back beside the text. */
|
|
294
|
+
export const MultilineExpandsAndResets: ComposerStory = {
|
|
295
|
+
...Multiline,
|
|
296
|
+
tags: ['e2e', '!autodocs'],
|
|
297
|
+
args: { ...Multiline.args, onSend: fn(), onStop: fn() },
|
|
298
|
+
play: async ({ args, canvas, canvasElement, userEvent, step }) => {
|
|
299
|
+
const textbox = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
300
|
+
const send = canvas.getByRole('button', { name: 'Send message' });
|
|
301
|
+
// The root has no role to query by; `data-compact` on it is the documented state.
|
|
302
|
+
const box = canvasElement.querySelector('[data-slot="chat-prompt-box"]');
|
|
303
|
+
|
|
304
|
+
await step('Expands when the text wraps', async () => {
|
|
305
|
+
await waitFor(() => expect(box).toHaveAttribute('data-compact', 'false'));
|
|
306
|
+
await expect(send.getBoundingClientRect().top).toBeGreaterThanOrEqual(
|
|
307
|
+
textbox.getBoundingClientRect().bottom,
|
|
308
|
+
);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
await step('Returns to one row once the message is sent', async () => {
|
|
312
|
+
await userEvent.click(send);
|
|
313
|
+
await expect(args.onSend).toHaveBeenCalledWith(LONG_PROMPT);
|
|
314
|
+
await waitFor(() => expect(box).toHaveAttribute('data-compact', 'true'));
|
|
315
|
+
await waitFor(() =>
|
|
316
|
+
expect(send.getBoundingClientRect().top).toBeLessThan(
|
|
317
|
+
textbox.getBoundingClientRect().bottom,
|
|
318
|
+
),
|
|
319
|
+
);
|
|
320
|
+
});
|
|
321
|
+
},
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
/** Pressing a button in the box leaves focus on the button; pressing anywhere else in the box focuses the input. */
|
|
325
|
+
export const WithLeftActionsClickToFocus: Story = {
|
|
326
|
+
...WithLeftActions,
|
|
327
|
+
tags: ['e2e', '!autodocs'],
|
|
328
|
+
args: { onMouseDown: fn() },
|
|
329
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
330
|
+
const textbox = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
331
|
+
const upload = canvas.getByRole('button', { name: 'Upload file' });
|
|
332
|
+
|
|
333
|
+
await step('A button keeps the focus it was given', async () => {
|
|
334
|
+
await expect(textbox).not.toHaveFocus();
|
|
335
|
+
await userEvent.click(upload);
|
|
336
|
+
await expect(upload).toHaveFocus();
|
|
337
|
+
await expect(args.onMouseDown).toHaveBeenCalledTimes(1);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
await step('The space around the buttons focuses the input', async () => {
|
|
341
|
+
await userEvent.click(canvas.getByRole('group', { name: 'Message actions' }));
|
|
342
|
+
await waitFor(() => expect(textbox).toHaveFocus());
|
|
343
|
+
await expect(args.onMouseDown).toHaveBeenCalledTimes(2);
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
/** A disabled composer cannot be edited and has nothing to send. */
|
|
349
|
+
export const DisabledBlocksInput: ComposerStory = {
|
|
350
|
+
...Disabled,
|
|
351
|
+
tags: ['e2e', '!autodocs'],
|
|
352
|
+
args: { ...Disabled.args, onSend: fn(), onStop: fn() },
|
|
353
|
+
play: async ({ args, canvas, userEvent }) => {
|
|
354
|
+
const textbox = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
355
|
+
|
|
356
|
+
await waitFor(() => expect(textbox).toHaveAttribute('contenteditable', 'false'));
|
|
357
|
+
await expect(canvas.getByRole('button', { name: 'Send message' })).toBeDisabled();
|
|
358
|
+
|
|
359
|
+
await userEvent.click(textbox);
|
|
360
|
+
await userEvent.keyboard('Hello{Enter}');
|
|
361
|
+
await expect(textbox).toHaveTextContent('');
|
|
362
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
363
|
+
},
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/** A click on Stop while a reply is streaming calls `onStop` and sends nothing. */
|
|
367
|
+
export const StreamingStop: ComposerStory = {
|
|
368
|
+
...Streaming,
|
|
369
|
+
tags: ['e2e', '!autodocs'],
|
|
370
|
+
args: { ...Streaming.args, onSend: fn(), onStop: fn() },
|
|
371
|
+
play: async ({ args, canvas, userEvent }) => {
|
|
372
|
+
await expect(canvas.queryByRole('button', { name: 'Send message' })).toBeNull();
|
|
373
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Stop message' }));
|
|
374
|
+
await expect(args.onStop).toHaveBeenCalledTimes(1);
|
|
375
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
376
|
+
},
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
/** The prompt box in each place it goes: the prompt slot of a chat container, a canvas footer and the footer of a chat page. */
|
|
380
|
+
export const Examples: Story = {
|
|
381
|
+
parameters: { controls: { disable: true } },
|
|
382
|
+
render: () => (
|
|
383
|
+
<div className="flex flex-col gap-24">
|
|
384
|
+
<ParentBlock parent="web-chat-ui/ChatContainerPrompt">
|
|
385
|
+
<div className="h-60 rounded-sm border border-component-divider">
|
|
386
|
+
<ChatContainer aria-label="Chat">
|
|
387
|
+
<div className="min-h-0 flex-1 overflow-y-auto p-16">
|
|
388
|
+
<Typography variant="body-medium" className="text-text-secondary">
|
|
389
|
+
Your 3pm with the facilities team is now on Friday at 10:00. Everyone has been
|
|
390
|
+
notified.
|
|
391
|
+
</Typography>
|
|
392
|
+
</div>
|
|
393
|
+
<ChatContainerPrompt className="p-16 pt-0">
|
|
394
|
+
<ChatPromptBox>
|
|
395
|
+
<ChatPromptBoxContent>
|
|
396
|
+
<ChatPromptBoxInput placeholder="How can I help?" autoFocus={false} />
|
|
397
|
+
<ChatPromptBoxActionsRight aria-label="Message actions">
|
|
398
|
+
<IconButton size="md" variant="primary" aria-label="Send message">
|
|
399
|
+
<EnterIcon />
|
|
400
|
+
</IconButton>
|
|
401
|
+
</ChatPromptBoxActionsRight>
|
|
402
|
+
</ChatPromptBoxContent>
|
|
403
|
+
</ChatPromptBox>
|
|
404
|
+
</ChatContainerPrompt>
|
|
405
|
+
</ChatContainer>
|
|
406
|
+
</div>
|
|
407
|
+
</ParentBlock>
|
|
408
|
+
|
|
409
|
+
<ParentBlock parent="web-chat-ui/CanvasShellFooter">
|
|
410
|
+
<footer
|
|
411
|
+
aria-label="Canvas footer"
|
|
412
|
+
className="flex flex-col items-stretch rounded-sm border border-component-divider p-16"
|
|
413
|
+
>
|
|
414
|
+
<ChatPromptBox>
|
|
415
|
+
<ChatPromptBoxContent>
|
|
416
|
+
<ChatPromptBoxInput placeholder="Ask about this page…" autoFocus={false} />
|
|
417
|
+
<ChatPromptBoxActionsRight aria-label="Message actions">
|
|
418
|
+
<IconButton size="md" variant="primary" aria-label="Send message">
|
|
419
|
+
<EnterIcon />
|
|
420
|
+
</IconButton>
|
|
421
|
+
</ChatPromptBoxActionsRight>
|
|
422
|
+
</ChatPromptBoxContent>
|
|
423
|
+
</ChatPromptBox>
|
|
424
|
+
</footer>
|
|
425
|
+
</ParentBlock>
|
|
426
|
+
|
|
427
|
+
<ParentBlock parent="chat page footer">
|
|
428
|
+
<section
|
|
429
|
+
aria-label="Chat page"
|
|
430
|
+
className="flex h-60 flex-col rounded-sm border border-component-divider"
|
|
431
|
+
>
|
|
432
|
+
<div className="min-h-0 flex-1 overflow-y-auto p-16">
|
|
433
|
+
<Typography variant="body-medium" className="text-text-secondary">
|
|
434
|
+
I can change how this agent answers, which tools it uses and who it hands over to.
|
|
435
|
+
</Typography>
|
|
436
|
+
</div>
|
|
437
|
+
<footer className="shrink-0 border-t border-component-divider p-16">
|
|
438
|
+
<ChatPromptBox>
|
|
439
|
+
<ChatPromptBoxContent>
|
|
440
|
+
<ChatPromptBoxInput
|
|
441
|
+
placeholder="Ask about or change this agent…"
|
|
442
|
+
autoFocus={false}
|
|
443
|
+
/>
|
|
444
|
+
<ChatPromptBoxActionsRight aria-label="Message actions">
|
|
445
|
+
<IconButton size="md" variant="primary" aria-label="Send message">
|
|
446
|
+
<EnterIcon />
|
|
447
|
+
</IconButton>
|
|
448
|
+
</ChatPromptBoxActionsRight>
|
|
449
|
+
</ChatPromptBoxContent>
|
|
450
|
+
</ChatPromptBox>
|
|
451
|
+
</footer>
|
|
452
|
+
</section>
|
|
453
|
+
</ParentBlock>
|
|
454
|
+
</div>
|
|
455
|
+
),
|
|
456
|
+
};
|
|
457
|
+
|
|
458
|
+
interface ChatPromptBoxPlaygroundProps {
|
|
459
|
+
className?: string;
|
|
460
|
+
innerClassName?: string;
|
|
461
|
+
textareaClassName?: string;
|
|
462
|
+
placeholder: string;
|
|
463
|
+
autoFocus: boolean;
|
|
464
|
+
isDisabled: boolean;
|
|
465
|
+
isReadOnly: boolean;
|
|
466
|
+
hasToolbar: boolean;
|
|
467
|
+
hasActionsLeft: boolean;
|
|
468
|
+
hasActionsRight: boolean;
|
|
469
|
+
onChange: (value: string) => void;
|
|
470
|
+
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
471
|
+
onMouseDown: (event: MouseEvent<HTMLDivElement>) => void;
|
|
472
|
+
onRemoveFile: (id: string) => void;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function ChatPromptBoxPlayground({
|
|
476
|
+
className,
|
|
477
|
+
innerClassName,
|
|
478
|
+
textareaClassName,
|
|
479
|
+
placeholder,
|
|
480
|
+
autoFocus,
|
|
481
|
+
isDisabled,
|
|
482
|
+
isReadOnly,
|
|
483
|
+
hasToolbar,
|
|
484
|
+
hasActionsLeft,
|
|
485
|
+
hasActionsRight,
|
|
486
|
+
onChange,
|
|
487
|
+
onKeyDown,
|
|
488
|
+
onMouseDown,
|
|
489
|
+
onRemoveFile,
|
|
490
|
+
}: ChatPromptBoxPlaygroundProps) {
|
|
491
|
+
return (
|
|
492
|
+
<ChatPromptBox className={className} innerClassName={innerClassName} onMouseDown={onMouseDown}>
|
|
493
|
+
{hasToolbar && (
|
|
494
|
+
<ChatPromptBoxToolbar aria-label="Attached files" className="flex gap-4 px-8 pt-8">
|
|
495
|
+
{ATTACHED_FILES.map((file) => (
|
|
496
|
+
<ChatMessageAttachmentCard key={file.id} className="min-w-0 max-w-60">
|
|
497
|
+
<ChatMessageAttachmentCardIcon icon={file.icon} />
|
|
498
|
+
<ChatMessageAttachmentCardContent>
|
|
499
|
+
<ChatMessageAttachmentCardTitle>{file.name}</ChatMessageAttachmentCardTitle>
|
|
500
|
+
</ChatMessageAttachmentCardContent>
|
|
501
|
+
<ChatMessageAttachmentCardActions onDelete={() => onRemoveFile(file.id)} />
|
|
502
|
+
</ChatMessageAttachmentCard>
|
|
503
|
+
))}
|
|
504
|
+
</ChatPromptBoxToolbar>
|
|
505
|
+
)}
|
|
506
|
+
<ChatPromptBoxContent>
|
|
507
|
+
{hasActionsLeft && (
|
|
508
|
+
<ChatPromptBoxActionsLeft aria-label="Attachments">
|
|
509
|
+
<IconButton
|
|
510
|
+
size="md"
|
|
511
|
+
variant="tertiary"
|
|
512
|
+
aria-label="Upload file"
|
|
513
|
+
isDisabled={isDisabled}
|
|
514
|
+
>
|
|
515
|
+
<AddIcon />
|
|
516
|
+
</IconButton>
|
|
517
|
+
</ChatPromptBoxActionsLeft>
|
|
518
|
+
)}
|
|
519
|
+
<ChatPromptBoxInput
|
|
520
|
+
textareaClassName={textareaClassName}
|
|
521
|
+
placeholder={placeholder}
|
|
522
|
+
autoFocus={autoFocus}
|
|
523
|
+
isDisabled={isDisabled}
|
|
524
|
+
isReadOnly={isReadOnly}
|
|
525
|
+
onChange={onChange}
|
|
526
|
+
onKeyDown={onKeyDown}
|
|
527
|
+
/>
|
|
528
|
+
{hasActionsRight && (
|
|
529
|
+
<ChatPromptBoxActionsRight aria-label="Message actions">
|
|
530
|
+
<IconButton size="md" variant="tertiary" aria-label="Dictate" isDisabled={isDisabled}>
|
|
531
|
+
<MicIcon />
|
|
532
|
+
</IconButton>
|
|
533
|
+
<IconButton
|
|
534
|
+
size="md"
|
|
535
|
+
variant="primary"
|
|
536
|
+
aria-label="Send message"
|
|
537
|
+
isDisabled={isDisabled}
|
|
538
|
+
>
|
|
539
|
+
<EnterIcon />
|
|
540
|
+
</IconButton>
|
|
541
|
+
</ChatPromptBoxActionsRight>
|
|
542
|
+
)}
|
|
543
|
+
</ChatPromptBoxContent>
|
|
544
|
+
</ChatPromptBox>
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/** Every part of the prompt box at once, toolbar included, with each part and prop on the Controls panel. */
|
|
549
|
+
export const Playground: StoryObj<typeof ChatPromptBoxPlayground> = {
|
|
550
|
+
tags: ['!autodocs'],
|
|
551
|
+
// The root's `initialConfig` and `children` are not args of the wrapper.
|
|
552
|
+
parameters: { controls: { exclude: ['initialConfig', 'children'] } },
|
|
553
|
+
args: {
|
|
554
|
+
className: '',
|
|
555
|
+
innerClassName: '',
|
|
556
|
+
textareaClassName: '',
|
|
557
|
+
placeholder: 'How can I help?',
|
|
558
|
+
autoFocus: true,
|
|
559
|
+
isDisabled: false,
|
|
560
|
+
isReadOnly: false,
|
|
561
|
+
hasToolbar: true,
|
|
562
|
+
hasActionsLeft: true,
|
|
563
|
+
hasActionsRight: true,
|
|
564
|
+
onChange: fn(),
|
|
565
|
+
onKeyDown: fn(),
|
|
566
|
+
onMouseDown: fn(),
|
|
567
|
+
onRemoveFile: fn(),
|
|
568
|
+
},
|
|
569
|
+
argTypes: {
|
|
570
|
+
textareaClassName: {
|
|
571
|
+
control: 'text',
|
|
572
|
+
description:
|
|
573
|
+
'`textareaClassName` of `ChatPromptBoxInput`: classes on the editable element, e.g. `max-h-40!` to let it grow further before it scrolls.',
|
|
574
|
+
},
|
|
575
|
+
placeholder: { control: 'text', description: '`placeholder` of `ChatPromptBoxInput`.' },
|
|
576
|
+
autoFocus: {
|
|
577
|
+
control: 'boolean',
|
|
578
|
+
description: '`autoFocus` of `ChatPromptBoxInput`: focuses the input on mount.',
|
|
579
|
+
},
|
|
580
|
+
isDisabled: {
|
|
581
|
+
control: 'boolean',
|
|
582
|
+
description: '`isDisabled` of `ChatPromptBoxInput`; the story disables the actions with it.',
|
|
583
|
+
},
|
|
584
|
+
isReadOnly: {
|
|
585
|
+
control: 'boolean',
|
|
586
|
+
description: '`isReadOnly` of `ChatPromptBoxInput`: the text can be selected, not edited.',
|
|
587
|
+
},
|
|
588
|
+
hasToolbar: {
|
|
589
|
+
control: 'boolean',
|
|
590
|
+
description: 'Renders `ChatPromptBoxToolbar` with the attached files.',
|
|
591
|
+
},
|
|
592
|
+
hasActionsLeft: {
|
|
593
|
+
control: 'boolean',
|
|
594
|
+
description: 'Renders `ChatPromptBoxActionsLeft` with the upload action.',
|
|
595
|
+
},
|
|
596
|
+
hasActionsRight: {
|
|
597
|
+
control: 'boolean',
|
|
598
|
+
description: 'Renders `ChatPromptBoxActionsRight` with dictate and send.',
|
|
599
|
+
},
|
|
600
|
+
onChange: {
|
|
601
|
+
description: '`onChange` of `ChatPromptBoxInput`: called with the text as Markdown.',
|
|
602
|
+
},
|
|
603
|
+
onKeyDown: {
|
|
604
|
+
description: '`onKeyDown` of `ChatPromptBoxInput`: where a consumer sends on Enter.',
|
|
605
|
+
},
|
|
606
|
+
onRemoveFile: { description: 'Called with the file id when its remove button is clicked.' },
|
|
607
|
+
},
|
|
608
|
+
render: (args) => <ChatPromptBoxPlayground {...args} />,
|
|
609
|
+
};
|