@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,6 +1,29 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { expect, fn, within } from 'storybook/test';
|
|
2
3
|
|
|
3
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
BookmarkIcon,
|
|
6
|
+
CopyIcon,
|
|
7
|
+
DocIcon,
|
|
8
|
+
DownloadIcon,
|
|
9
|
+
EditIcon,
|
|
10
|
+
PdfIcon,
|
|
11
|
+
ThumbsDownIcon,
|
|
12
|
+
ThumbsUpIcon,
|
|
13
|
+
} from '@swisper.ai/icons';
|
|
14
|
+
import {
|
|
15
|
+
DropdownMenuList,
|
|
16
|
+
DropdownMenuListItem,
|
|
17
|
+
Menu,
|
|
18
|
+
MenuItemIcon,
|
|
19
|
+
MenuItemLabel,
|
|
20
|
+
MenuProvider,
|
|
21
|
+
MenuTrigger,
|
|
22
|
+
withTooltip,
|
|
23
|
+
} from '@swisper.ai/ui';
|
|
24
|
+
|
|
25
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
26
|
+
import { ChatMessage, ChatMessageActions, ChatMessageContent } from '../chat-message';
|
|
4
27
|
|
|
5
28
|
import {
|
|
6
29
|
ChatMessageToolbar,
|
|
@@ -10,12 +33,19 @@ import {
|
|
|
10
33
|
} from './chat-message-toolbar';
|
|
11
34
|
|
|
12
35
|
const meta: Meta<typeof ChatMessageToolbar> = {
|
|
13
|
-
title: '
|
|
36
|
+
title: 'Chat/ChatMessageToolbar',
|
|
14
37
|
component: ChatMessageToolbar,
|
|
38
|
+
subcomponents: {
|
|
39
|
+
ChatMessageToolbarTimestamp,
|
|
40
|
+
ChatMessageToolbarActions,
|
|
41
|
+
ChatMessageToolbarActionButton,
|
|
42
|
+
},
|
|
15
43
|
tags: ['autodocs'],
|
|
16
44
|
decorators: [
|
|
45
|
+
// An action button with a `tooltip` needs a TooltipProvider above it
|
|
46
|
+
withTooltip,
|
|
17
47
|
(Story) => (
|
|
18
|
-
<div className="max-w-
|
|
48
|
+
<div className="max-w-105 mx-auto">
|
|
19
49
|
<Story />
|
|
20
50
|
</div>
|
|
21
51
|
),
|
|
@@ -23,12 +53,12 @@ const meta: Meta<typeof ChatMessageToolbar> = {
|
|
|
23
53
|
args: {
|
|
24
54
|
children: (
|
|
25
55
|
<>
|
|
26
|
-
<ChatMessageToolbarTimestamp>
|
|
56
|
+
<ChatMessageToolbarTimestamp>14:32</ChatMessageToolbarTimestamp>
|
|
27
57
|
<ChatMessageToolbarActions>
|
|
28
|
-
<ChatMessageToolbarActionButton>
|
|
58
|
+
<ChatMessageToolbarActionButton tooltip="Edit" aria-label="Edit">
|
|
29
59
|
<EditIcon />
|
|
30
60
|
</ChatMessageToolbarActionButton>
|
|
31
|
-
<ChatMessageToolbarActionButton>
|
|
61
|
+
<ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy">
|
|
32
62
|
<CopyIcon />
|
|
33
63
|
</ChatMessageToolbarActionButton>
|
|
34
64
|
</ChatMessageToolbarActions>
|
|
@@ -59,4 +89,345 @@ const meta: Meta<typeof ChatMessageToolbar> = {
|
|
|
59
89
|
export default meta;
|
|
60
90
|
type Story = StoryObj<typeof ChatMessageToolbar>;
|
|
61
91
|
|
|
92
|
+
/** The row under a message: when it was sent on one side, its edit and copy actions on the other. */
|
|
62
93
|
export const Default: Story = {};
|
|
94
|
+
|
|
95
|
+
/** `reverse` under the user's own question: the actions move to the left, the time to the right. */
|
|
96
|
+
export const Reversed: Story = {
|
|
97
|
+
args: { reverse: true },
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** A disabled action stays in the row but takes no click and leaves the tab order. */
|
|
101
|
+
export const Disabled: Story = {
|
|
102
|
+
parameters: { controls: { disable: true } },
|
|
103
|
+
render: () => (
|
|
104
|
+
<ChatMessageToolbar>
|
|
105
|
+
<ChatMessageToolbarTimestamp>14:32</ChatMessageToolbarTimestamp>
|
|
106
|
+
<ChatMessageToolbarActions>
|
|
107
|
+
<ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy">
|
|
108
|
+
<CopyIcon />
|
|
109
|
+
</ChatMessageToolbarActionButton>
|
|
110
|
+
<ChatMessageToolbarActionButton tooltip="Bookmark" aria-label="Bookmark" isDisabled>
|
|
111
|
+
<BookmarkIcon />
|
|
112
|
+
</ChatMessageToolbarActionButton>
|
|
113
|
+
</ChatMessageToolbarActions>
|
|
114
|
+
</ChatMessageToolbar>
|
|
115
|
+
),
|
|
116
|
+
};
|
|
117
|
+
|
|
118
|
+
type DownloadFormat = 'markdown' | 'pdf';
|
|
119
|
+
|
|
120
|
+
interface MessageActionsToolbarProps {
|
|
121
|
+
/** When the message was sent, already formatted */
|
|
122
|
+
time: string;
|
|
123
|
+
onCopy: () => void;
|
|
124
|
+
onDownload: (format: DownloadFormat) => void;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function MessageActionsToolbar({ time, onCopy, onDownload }: MessageActionsToolbarProps) {
|
|
128
|
+
return (
|
|
129
|
+
<ChatMessageToolbar>
|
|
130
|
+
<ChatMessageToolbarTimestamp>{time}</ChatMessageToolbarTimestamp>
|
|
131
|
+
<ChatMessageToolbarActions>
|
|
132
|
+
<ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy" onClick={onCopy}>
|
|
133
|
+
<CopyIcon />
|
|
134
|
+
</ChatMessageToolbarActionButton>
|
|
135
|
+
|
|
136
|
+
<MenuProvider>
|
|
137
|
+
<MenuTrigger asChild>
|
|
138
|
+
<ChatMessageToolbarActionButton tooltip="Download" aria-label="Download">
|
|
139
|
+
<DownloadIcon />
|
|
140
|
+
</ChatMessageToolbarActionButton>
|
|
141
|
+
</MenuTrigger>
|
|
142
|
+
<Menu className="min-w-55" side="bottom" align="start">
|
|
143
|
+
<DropdownMenuList>
|
|
144
|
+
<DropdownMenuListItem onClick={() => onDownload('markdown')}>
|
|
145
|
+
<MenuItemIcon>
|
|
146
|
+
<DocIcon />
|
|
147
|
+
</MenuItemIcon>
|
|
148
|
+
<MenuItemLabel>Download as Markdown</MenuItemLabel>
|
|
149
|
+
</DropdownMenuListItem>
|
|
150
|
+
<DropdownMenuListItem onClick={() => onDownload('pdf')}>
|
|
151
|
+
<MenuItemIcon>
|
|
152
|
+
<PdfIcon />
|
|
153
|
+
</MenuItemIcon>
|
|
154
|
+
<MenuItemLabel>Download as PDF</MenuItemLabel>
|
|
155
|
+
</DropdownMenuListItem>
|
|
156
|
+
</DropdownMenuList>
|
|
157
|
+
</Menu>
|
|
158
|
+
</MenuProvider>
|
|
159
|
+
</ChatMessageToolbarActions>
|
|
160
|
+
</ChatMessageToolbar>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
type MessageActionsStory = StoryObj<typeof MessageActionsToolbar>;
|
|
165
|
+
|
|
166
|
+
/** An action that opens a menu: the button is the menu's `asChild` trigger and keeps its tooltip. */
|
|
167
|
+
export const WithMenuAction: MessageActionsStory = {
|
|
168
|
+
args: { time: '14:32', onCopy: fn(), onDownload: fn() },
|
|
169
|
+
argTypes: {
|
|
170
|
+
time: { control: 'text', description: 'Text of `ChatMessageToolbarTimestamp`.' },
|
|
171
|
+
onCopy: { control: false, description: 'Called when Copy is activated.' },
|
|
172
|
+
onDownload: { control: false, description: 'Called with the format picked in the menu.' },
|
|
173
|
+
},
|
|
174
|
+
render: (args) => <MessageActionsToolbar {...args} />,
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** A click calls the action's handler, and the menu action opens its menu and reports the pick. */
|
|
178
|
+
export const WithMenuActionSelect: MessageActionsStory = {
|
|
179
|
+
...WithMenuAction,
|
|
180
|
+
tags: ['e2e', '!autodocs'],
|
|
181
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
182
|
+
// The menu portals into document.body, outside the canvas.
|
|
183
|
+
const page = within(document.body);
|
|
184
|
+
|
|
185
|
+
await step('A click on an action calls its handler', async () => {
|
|
186
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Copy' }));
|
|
187
|
+
await expect(args.onCopy).toHaveBeenCalledTimes(1);
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
await step('The action button opens the menu it triggers', async () => {
|
|
191
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Download' }));
|
|
192
|
+
const menu = within(await page.findByRole('menu'));
|
|
193
|
+
await userEvent.click(menu.getByRole('menuitem', { name: 'Download as PDF' }));
|
|
194
|
+
await expect(args.onDownload).toHaveBeenCalledWith('pdf');
|
|
195
|
+
});
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
|
|
199
|
+
/** Tab reaches each action and opens its tooltip; Enter and Space activate it, ArrowDown opens a menu. */
|
|
200
|
+
export const WithMenuActionKeyboard: MessageActionsStory = {
|
|
201
|
+
...WithMenuAction,
|
|
202
|
+
tags: ['e2e', '!autodocs'],
|
|
203
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
204
|
+
const page = within(document.body);
|
|
205
|
+
const copy = canvas.getByRole('button', { name: 'Copy' });
|
|
206
|
+
|
|
207
|
+
await step('Tab reaches the first action and opens its tooltip', async () => {
|
|
208
|
+
await userEvent.tab();
|
|
209
|
+
await expect(copy).toHaveFocus();
|
|
210
|
+
await expect(await page.findByRole('tooltip', { name: 'Copy' })).toBeInTheDocument();
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
await step('Enter and Space activate it', async () => {
|
|
214
|
+
await userEvent.keyboard('{Enter}');
|
|
215
|
+
await userEvent.keyboard(' ');
|
|
216
|
+
await expect(args.onCopy).toHaveBeenCalledTimes(2);
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
await step('ArrowDown on the menu action opens the menu', async () => {
|
|
220
|
+
await userEvent.tab();
|
|
221
|
+
await expect(canvas.getByRole('button', { name: 'Download' })).toHaveFocus();
|
|
222
|
+
await userEvent.keyboard('{ArrowDown}');
|
|
223
|
+
await expect(
|
|
224
|
+
await page.findByRole('menuitem', { name: 'Download as Markdown' }),
|
|
225
|
+
).toBeVisible();
|
|
226
|
+
});
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/** A disabled action ignores clicks and is skipped by Tab. */
|
|
231
|
+
export const DisabledAction: StoryObj<{ onBookmark: () => void }> = {
|
|
232
|
+
tags: ['e2e', '!autodocs'],
|
|
233
|
+
args: { onBookmark: fn() },
|
|
234
|
+
parameters: { controls: { disable: true } },
|
|
235
|
+
render: ({ onBookmark }) => (
|
|
236
|
+
<ChatMessageToolbar>
|
|
237
|
+
<ChatMessageToolbarTimestamp>14:32</ChatMessageToolbarTimestamp>
|
|
238
|
+
<ChatMessageToolbarActions>
|
|
239
|
+
<ChatMessageToolbarActionButton aria-label="Bookmark" isDisabled onClick={onBookmark}>
|
|
240
|
+
<BookmarkIcon />
|
|
241
|
+
</ChatMessageToolbarActionButton>
|
|
242
|
+
</ChatMessageToolbarActions>
|
|
243
|
+
</ChatMessageToolbar>
|
|
244
|
+
),
|
|
245
|
+
play: async ({ args, canvas, userEvent }) => {
|
|
246
|
+
const bookmark = canvas.getByRole('button', { name: 'Bookmark' });
|
|
247
|
+
|
|
248
|
+
await expect(bookmark).toHaveAttribute('aria-disabled', 'true');
|
|
249
|
+
await userEvent.click(bookmark);
|
|
250
|
+
await userEvent.tab();
|
|
251
|
+
await expect(bookmark).not.toHaveFocus();
|
|
252
|
+
await expect(args.onBookmark).not.toHaveBeenCalled();
|
|
253
|
+
},
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* The toolbar in each place it's allowed: inside `ChatMessageActions`, under an answer, under a
|
|
258
|
+
* question and on an agent transcript turn. `ChatMessageActions` hides the row until its message is
|
|
259
|
+
* hovered from `md` up; these blocks keep it visible.
|
|
260
|
+
*/
|
|
261
|
+
export const Examples: Story = {
|
|
262
|
+
parameters: { controls: { disable: true } },
|
|
263
|
+
render: () => (
|
|
264
|
+
<div className="flex flex-col gap-24">
|
|
265
|
+
<ParentBlock parent="web-chat-ui/ChatMessageActions">
|
|
266
|
+
<ChatMessage>
|
|
267
|
+
<ChatMessageContent>
|
|
268
|
+
The quarterly report is ready. Revenue is up 8% on the previous quarter.
|
|
269
|
+
</ChatMessageContent>
|
|
270
|
+
<ChatMessageActions className="md:opacity-100">
|
|
271
|
+
<ChatMessageToolbar>
|
|
272
|
+
<ChatMessageToolbarTimestamp>14:32</ChatMessageToolbarTimestamp>
|
|
273
|
+
<ChatMessageToolbarActions>
|
|
274
|
+
<ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy">
|
|
275
|
+
<CopyIcon />
|
|
276
|
+
</ChatMessageToolbarActionButton>
|
|
277
|
+
</ChatMessageToolbarActions>
|
|
278
|
+
</ChatMessageToolbar>
|
|
279
|
+
</ChatMessageActions>
|
|
280
|
+
</ChatMessage>
|
|
281
|
+
</ParentBlock>
|
|
282
|
+
|
|
283
|
+
<ParentBlock parent="under an assistant answer">
|
|
284
|
+
<ChatMessage>
|
|
285
|
+
<ChatMessageContent>
|
|
286
|
+
You have three meetings tomorrow. The first is the design review at 09:30.
|
|
287
|
+
</ChatMessageContent>
|
|
288
|
+
<ChatMessageActions className="md:opacity-100">
|
|
289
|
+
<ChatMessageToolbar>
|
|
290
|
+
<ChatMessageToolbarTimestamp>09:14</ChatMessageToolbarTimestamp>
|
|
291
|
+
<ChatMessageToolbarActions>
|
|
292
|
+
<ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy">
|
|
293
|
+
<CopyIcon />
|
|
294
|
+
</ChatMessageToolbarActionButton>
|
|
295
|
+
<ChatMessageToolbarActionButton tooltip="Good response" aria-label="Good response">
|
|
296
|
+
<ThumbsUpIcon />
|
|
297
|
+
</ChatMessageToolbarActionButton>
|
|
298
|
+
<ChatMessageToolbarActionButton tooltip="Bad response" aria-label="Bad response">
|
|
299
|
+
<ThumbsDownIcon />
|
|
300
|
+
</ChatMessageToolbarActionButton>
|
|
301
|
+
</ChatMessageToolbarActions>
|
|
302
|
+
</ChatMessageToolbar>
|
|
303
|
+
</ChatMessageActions>
|
|
304
|
+
</ChatMessage>
|
|
305
|
+
</ParentBlock>
|
|
306
|
+
|
|
307
|
+
<ParentBlock parent="under a user question">
|
|
308
|
+
<ChatMessage isQuestion>
|
|
309
|
+
<ChatMessageContent>What do I have on tomorrow?</ChatMessageContent>
|
|
310
|
+
<ChatMessageActions className="w-full md:opacity-100">
|
|
311
|
+
<ChatMessageToolbar reverse>
|
|
312
|
+
<ChatMessageToolbarTimestamp>09:13</ChatMessageToolbarTimestamp>
|
|
313
|
+
<ChatMessageToolbarActions>
|
|
314
|
+
<ChatMessageToolbarActionButton tooltip="Edit" aria-label="Edit">
|
|
315
|
+
<EditIcon />
|
|
316
|
+
</ChatMessageToolbarActionButton>
|
|
317
|
+
<ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy">
|
|
318
|
+
<CopyIcon />
|
|
319
|
+
</ChatMessageToolbarActionButton>
|
|
320
|
+
</ChatMessageToolbarActions>
|
|
321
|
+
</ChatMessageToolbar>
|
|
322
|
+
</ChatMessageActions>
|
|
323
|
+
</ChatMessage>
|
|
324
|
+
</ParentBlock>
|
|
325
|
+
|
|
326
|
+
<ParentBlock parent="agent transcript turn">
|
|
327
|
+
<section aria-label="Agent transcript">
|
|
328
|
+
<ChatMessage>
|
|
329
|
+
<ChatMessageContent>
|
|
330
|
+
Searched the shared drive and found two contracts that expire this month.
|
|
331
|
+
</ChatMessageContent>
|
|
332
|
+
<ChatMessageContent>
|
|
333
|
+
I drafted a renewal reminder for each owner. Nothing has been sent yet.
|
|
334
|
+
</ChatMessageContent>
|
|
335
|
+
<ChatMessageActions className="md:opacity-100">
|
|
336
|
+
<ChatMessageToolbar>
|
|
337
|
+
<ChatMessageToolbarTimestamp>16:05</ChatMessageToolbarTimestamp>
|
|
338
|
+
<ChatMessageToolbarActions>
|
|
339
|
+
<ChatMessageToolbarActionButton tooltip="Copy" aria-label="Copy">
|
|
340
|
+
<CopyIcon />
|
|
341
|
+
</ChatMessageToolbarActionButton>
|
|
342
|
+
<ChatMessageToolbarActionButton tooltip="Bookmark" aria-label="Bookmark">
|
|
343
|
+
<BookmarkIcon />
|
|
344
|
+
</ChatMessageToolbarActionButton>
|
|
345
|
+
</ChatMessageToolbarActions>
|
|
346
|
+
</ChatMessageToolbar>
|
|
347
|
+
</ChatMessageActions>
|
|
348
|
+
</ChatMessage>
|
|
349
|
+
</section>
|
|
350
|
+
</ParentBlock>
|
|
351
|
+
</div>
|
|
352
|
+
),
|
|
353
|
+
};
|
|
354
|
+
|
|
355
|
+
const PLAYGROUND_ACTIONS = [
|
|
356
|
+
{ label: 'Edit', icon: <EditIcon /> },
|
|
357
|
+
{ label: 'Copy', icon: <CopyIcon /> },
|
|
358
|
+
{ label: 'Bookmark', icon: <BookmarkIcon /> },
|
|
359
|
+
{ label: 'Good response', icon: <ThumbsUpIcon /> },
|
|
360
|
+
{ label: 'Bad response', icon: <ThumbsDownIcon /> },
|
|
361
|
+
];
|
|
362
|
+
|
|
363
|
+
interface ChatMessageToolbarPlaygroundProps {
|
|
364
|
+
reverse: boolean;
|
|
365
|
+
timestamp: string;
|
|
366
|
+
hasTimestamp: boolean;
|
|
367
|
+
hasTooltips: boolean;
|
|
368
|
+
actionCount: number;
|
|
369
|
+
isDisabled: boolean;
|
|
370
|
+
onAction: (label: string) => void;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
function ChatMessageToolbarPlayground({
|
|
374
|
+
reverse,
|
|
375
|
+
timestamp,
|
|
376
|
+
hasTimestamp,
|
|
377
|
+
hasTooltips,
|
|
378
|
+
actionCount,
|
|
379
|
+
isDisabled,
|
|
380
|
+
onAction,
|
|
381
|
+
}: ChatMessageToolbarPlaygroundProps) {
|
|
382
|
+
return (
|
|
383
|
+
<ChatMessageToolbar reverse={reverse}>
|
|
384
|
+
{hasTimestamp && <ChatMessageToolbarTimestamp>{timestamp}</ChatMessageToolbarTimestamp>}
|
|
385
|
+
<ChatMessageToolbarActions>
|
|
386
|
+
{PLAYGROUND_ACTIONS.slice(0, actionCount).map((action) => (
|
|
387
|
+
<ChatMessageToolbarActionButton
|
|
388
|
+
key={action.label}
|
|
389
|
+
aria-label={action.label}
|
|
390
|
+
tooltip={hasTooltips ? action.label : undefined}
|
|
391
|
+
isDisabled={isDisabled}
|
|
392
|
+
onClick={() => onAction(action.label)}
|
|
393
|
+
>
|
|
394
|
+
{action.icon}
|
|
395
|
+
</ChatMessageToolbarActionButton>
|
|
396
|
+
))}
|
|
397
|
+
</ChatMessageToolbarActions>
|
|
398
|
+
</ChatMessageToolbar>
|
|
399
|
+
);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/** Every part of the toolbar at once, with each part and prop on the Controls panel. */
|
|
403
|
+
export const Playground: StoryObj<typeof ChatMessageToolbarPlayground> = {
|
|
404
|
+
tags: ['!autodocs'],
|
|
405
|
+
args: {
|
|
406
|
+
reverse: false,
|
|
407
|
+
timestamp: '14:32',
|
|
408
|
+
hasTimestamp: true,
|
|
409
|
+
hasTooltips: true,
|
|
410
|
+
actionCount: PLAYGROUND_ACTIONS.length,
|
|
411
|
+
isDisabled: false,
|
|
412
|
+
onAction: fn(),
|
|
413
|
+
},
|
|
414
|
+
argTypes: {
|
|
415
|
+
reverse: { control: 'boolean', description: '`reverse` on the root.' },
|
|
416
|
+
timestamp: { control: 'text', description: 'Text of `ChatMessageToolbarTimestamp`.' },
|
|
417
|
+
hasTimestamp: { control: 'boolean', description: 'Renders `ChatMessageToolbarTimestamp`.' },
|
|
418
|
+
hasTooltips: {
|
|
419
|
+
control: 'boolean',
|
|
420
|
+
description: 'Sets `tooltip` on every `ChatMessageToolbarActionButton`.',
|
|
421
|
+
},
|
|
422
|
+
actionCount: {
|
|
423
|
+
control: { type: 'number', min: 0, max: PLAYGROUND_ACTIONS.length },
|
|
424
|
+
description: 'Number of buttons in `ChatMessageToolbarActions`.',
|
|
425
|
+
},
|
|
426
|
+
isDisabled: {
|
|
427
|
+
control: 'boolean',
|
|
428
|
+
description: '`isDisabled` on every `ChatMessageToolbarActionButton`.',
|
|
429
|
+
},
|
|
430
|
+
onAction: { control: false, description: 'Called with the label of the activated action.' },
|
|
431
|
+
},
|
|
432
|
+
render: (args) => <ChatMessageToolbarPlayground {...args} />,
|
|
433
|
+
};
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { forwardRef, type ComponentProps, type ReactNode } from 'react';
|
|
2
2
|
|
|
3
3
|
import { IconButton, Tooltip, type IconButtonProps } from '@swisper.ai/ui';
|
|
4
4
|
import { cn } from '@swisper.ai/web-core';
|
|
5
5
|
|
|
6
6
|
export interface ChatMessageToolbarProps extends ComponentProps<'div'> {
|
|
7
|
+
/** The toolbar parts: a `ChatMessageToolbarTimestamp` and a `ChatMessageToolbarActions`. */
|
|
7
8
|
children: ReactNode;
|
|
9
|
+
/** Classes merged last onto the row. */
|
|
8
10
|
className?: string;
|
|
11
|
+
/** Flips the row, so the first part sits at the end. Set it under an end-aligned question. */
|
|
9
12
|
reverse?: boolean;
|
|
10
13
|
}
|
|
11
14
|
|
|
15
|
+
/** The row under a chat message: its timestamp at one end, its icon actions at the other. */
|
|
12
16
|
export function ChatMessageToolbar({
|
|
13
17
|
children,
|
|
14
18
|
className,
|
|
@@ -17,6 +21,7 @@ export function ChatMessageToolbar({
|
|
|
17
21
|
}: ChatMessageToolbarProps) {
|
|
18
22
|
return (
|
|
19
23
|
<div
|
|
24
|
+
data-slot="chat-message-toolbar"
|
|
20
25
|
data-testid="chat-message-toolbar"
|
|
21
26
|
data-reverse={reverse}
|
|
22
27
|
className={cn(
|
|
@@ -33,17 +38,26 @@ export function ChatMessageToolbar({
|
|
|
33
38
|
);
|
|
34
39
|
}
|
|
35
40
|
|
|
36
|
-
export interface ChatMessageToolbarActionsProps {
|
|
41
|
+
export interface ChatMessageToolbarActionsProps extends ComponentProps<'div'> {
|
|
42
|
+
/** The actions, each a `ChatMessageToolbarActionButton`. */
|
|
37
43
|
children: ReactNode;
|
|
44
|
+
/** Classes merged last onto the group. */
|
|
38
45
|
className?: string;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
|
|
48
|
+
/** Groups the toolbar's action buttons in a `role="group"` row. */
|
|
49
|
+
export function ChatMessageToolbarActions({
|
|
50
|
+
children,
|
|
51
|
+
className,
|
|
52
|
+
...rest
|
|
53
|
+
}: ChatMessageToolbarActionsProps) {
|
|
42
54
|
return (
|
|
43
55
|
<div
|
|
56
|
+
data-slot="chat-message-toolbar-actions"
|
|
44
57
|
data-testid="chat-message-toolbar-actions"
|
|
45
58
|
role="group"
|
|
46
59
|
className={cn('flex items-center gap-8', className)}
|
|
60
|
+
{...rest}
|
|
47
61
|
>
|
|
48
62
|
{children}
|
|
49
63
|
</div>
|
|
@@ -54,22 +68,29 @@ export interface ChatMessageToolbarActionButtonProps extends Omit<
|
|
|
54
68
|
IconButtonProps,
|
|
55
69
|
'variant' | 'size'
|
|
56
70
|
> {
|
|
71
|
+
/** The action's icon. */
|
|
57
72
|
children: ReactNode;
|
|
73
|
+
/** Classes merged last onto the button. */
|
|
58
74
|
className?: string;
|
|
75
|
+
/** Text of the hover tooltip. It is not the accessible name: pass `aria-label` as well. */
|
|
59
76
|
tooltip?: string;
|
|
60
77
|
}
|
|
61
78
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
/**
|
|
80
|
+
* One icon action in the toolbar: an extra-small tertiary `IconButton`, in a `Tooltip` when
|
|
81
|
+
* `tooltip` is set. The ref reaches the button, so it can be an `asChild` menu or popover trigger.
|
|
82
|
+
*/
|
|
83
|
+
export const ChatMessageToolbarActionButton = forwardRef<
|
|
84
|
+
HTMLButtonElement | HTMLSpanElement,
|
|
85
|
+
ChatMessageToolbarActionButtonProps
|
|
86
|
+
>(function ChatMessageToolbarActionButton({ children, className, tooltip, ...rest }, ref) {
|
|
68
87
|
const content = (
|
|
69
88
|
<IconButton
|
|
89
|
+
ref={ref}
|
|
70
90
|
variant="tertiary"
|
|
71
91
|
isSemantic={false}
|
|
72
92
|
size="xs"
|
|
93
|
+
data-slot="chat-message-toolbar-action-button"
|
|
73
94
|
className={cn('text-action-active', className)}
|
|
74
95
|
{...rest}
|
|
75
96
|
>
|
|
@@ -82,16 +103,30 @@ export function ChatMessageToolbarActionButton({
|
|
|
82
103
|
}
|
|
83
104
|
|
|
84
105
|
return <Tooltip tooltip={tooltip}>{content}</Tooltip>;
|
|
85
|
-
}
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
ChatMessageToolbarActionButton.displayName = 'ChatMessageToolbarActionButton';
|
|
86
109
|
|
|
87
|
-
export interface ChatMessageToolbarTimestampProps {
|
|
110
|
+
export interface ChatMessageToolbarTimestampProps extends ComponentProps<'div'> {
|
|
111
|
+
/** The time, already formatted. */
|
|
88
112
|
children: ReactNode;
|
|
113
|
+
/** Classes merged last onto the timestamp. */
|
|
89
114
|
className?: string;
|
|
90
115
|
}
|
|
91
116
|
|
|
117
|
+
/** When the message was sent. Renders its children as given. */
|
|
92
118
|
export function ChatMessageToolbarTimestamp({
|
|
93
119
|
className,
|
|
94
120
|
children,
|
|
121
|
+
...rest
|
|
95
122
|
}: ChatMessageToolbarTimestampProps) {
|
|
96
|
-
return
|
|
123
|
+
return (
|
|
124
|
+
<div
|
|
125
|
+
data-slot="chat-message-toolbar-timestamp"
|
|
126
|
+
className={cn('text-action-active', className)}
|
|
127
|
+
{...rest}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</div>
|
|
131
|
+
);
|
|
97
132
|
}
|
|
@@ -3,4 +3,8 @@ export {
|
|
|
3
3
|
ChatMessageToolbarActions,
|
|
4
4
|
ChatMessageToolbarActionButton,
|
|
5
5
|
ChatMessageToolbarTimestamp,
|
|
6
|
+
type ChatMessageToolbarProps,
|
|
7
|
+
type ChatMessageToolbarActionsProps,
|
|
8
|
+
type ChatMessageToolbarActionButtonProps,
|
|
9
|
+
type ChatMessageToolbarTimestampProps,
|
|
6
10
|
} from './chat-message-toolbar';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@swisper.ai/web-core';
|
|
4
|
+
|
|
5
|
+
export interface ConversationFrameProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A flex column with a fixed height: `ChatMessages` is `flex-1`, so it only scrolls inside a
|
|
12
|
+
* parent whose height is bounded.
|
|
13
|
+
*/
|
|
14
|
+
export function ConversationFrame({ children, className }: ConversationFrameProps) {
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
className={cn(
|
|
18
|
+
'flex h-120 w-full max-w-120 flex-col rounded-10 border border-divider-border-base',
|
|
19
|
+
className,
|
|
20
|
+
)}
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</div>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ChatMessage, ChatMessageContent } from '../../chat-message';
|
|
2
|
+
import { ChatMessageListGroup } from '../chat-messages';
|
|
3
|
+
|
|
4
|
+
import type { ConversationTurn } from './types';
|
|
5
|
+
|
|
6
|
+
export interface ConversationGroupProps {
|
|
7
|
+
turn: ConversationTurn;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** One row of a `ChatMessagesList`: the question bubble with its answer below it. */
|
|
11
|
+
export function ConversationGroup({ turn }: ConversationGroupProps) {
|
|
12
|
+
return (
|
|
13
|
+
<ChatMessageListGroup>
|
|
14
|
+
<ChatMessage isQuestion>
|
|
15
|
+
<ChatMessageContent>{turn.question}</ChatMessageContent>
|
|
16
|
+
</ChatMessage>
|
|
17
|
+
<ChatMessage>
|
|
18
|
+
<ChatMessageContent className="whitespace-pre-line">{turn.answer}</ChatMessageContent>
|
|
19
|
+
</ChatMessage>
|
|
20
|
+
</ChatMessageListGroup>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { ConversationTurn } from './types';
|
|
2
|
+
|
|
3
|
+
/** A finished conversation about one month's spending; the third question is the long kind. */
|
|
4
|
+
export const CONVERSATION: ConversationTurn[] = [
|
|
5
|
+
{
|
|
6
|
+
question: 'What were my biggest expenses this month?',
|
|
7
|
+
answer:
|
|
8
|
+
'Your three biggest expenses in May were rent at CHF 2,150.00, groceries at CHF 412.30 across nine purchases, and the annual liability insurance premium of CHF 340.00.',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
question: 'Can you show the largest card payment?',
|
|
12
|
+
answer:
|
|
13
|
+
'The largest card payment was CHF 96.40 at the supermarket on 24 May. The next one down was CHF 84.50 at a restaurant on 17 May.',
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
question:
|
|
17
|
+
"I'm trying to work out why May cost so much more than April. Can you leave out rent and the travelcard, because those are the same every month, and tell me which categories went up by more than CHF 50?",
|
|
18
|
+
answer:
|
|
19
|
+
'Two categories went up by more than CHF 50. Dining rose from CHF 148.90 to CHF 286.15, and groceries from CHF 338.20 to CHF 412.30. Everything else moved by less than CHF 20.',
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
question: 'Which subscriptions am I paying for?',
|
|
23
|
+
answer:
|
|
24
|
+
'You have four active subscriptions, CHF 89.90 a month in total: a streaming service, cloud storage, a fitness app and a digital newspaper.',
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
question: 'Can I set a budget alert for dining?',
|
|
28
|
+
answer: 'Yes. What monthly limit would you like?',
|
|
29
|
+
},
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/** Follow-up questions whose answers are longer than the viewport, so they stream past its end. */
|
|
33
|
+
export const FOLLOW_UP_TURNS: ConversationTurn[] = [
|
|
34
|
+
{
|
|
35
|
+
question: 'Why was May so much more expensive than April?',
|
|
36
|
+
answer: [
|
|
37
|
+
'May came to CHF 4,218.40, which is CHF 612.75 more than April. Rent and your travelcard are the same in both months, so the difference comes from three categories.',
|
|
38
|
+
'Dining went up the most: CHF 286.15 against CHF 148.90 in April. You had eleven restaurant visits instead of six, and two of them were above CHF 60. The most expensive was CHF 84.50 on 17 May.',
|
|
39
|
+
'Groceries rose from CHF 338.20 to CHF 412.30. You made nine purchases in both months, so the baskets were bigger rather than more frequent. The purchase on 24 May alone was CHF 96.40.',
|
|
40
|
+
'The third is a one-off: the annual liability insurance premium of CHF 340.00 was debited on 3 May. It will not come back until next year, so June should land closer to April without any change on your side.',
|
|
41
|
+
'Everything else moved by less than CHF 20. Transport, subscriptions and pharmacy are all within their three-month average.',
|
|
42
|
+
].join('\n\n'),
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
question: 'Which subscriptions could I cancel?',
|
|
46
|
+
answer: [
|
|
47
|
+
'You pay for four subscriptions, CHF 89.90 a month in total. Two of them look unused.',
|
|
48
|
+
'The digital newspaper costs CHF 29.00 a month and you have not opened it in 60 days. It can be cancelled at the end of any month, so cancelling before 30 June stops the July charge.',
|
|
49
|
+
'The fitness app costs CHF 19.90 a month. The last session it recorded was on 2 March. It renews yearly on 14 September, and the provider asks for one month of notice, so the deadline is 14 August.',
|
|
50
|
+
'The streaming service at CHF 22.00 and the cloud storage at CHF 19.00 are both in regular use: you streamed on 23 days in May, and the storage is 71% full.',
|
|
51
|
+
'Cancelling the two unused ones saves CHF 48.90 a month, or CHF 586.80 a year. I can draft both cancellation letters for you to review before anything is sent.',
|
|
52
|
+
].join('\n\n'),
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
question: 'How much could I put aside each month?',
|
|
56
|
+
answer: [
|
|
57
|
+
'Over the last three months your income averaged CHF 6,480.00 and your spending CHF 3,790.20, which leaves CHF 2,689.80 a month before savings.',
|
|
58
|
+
'Fixed costs take CHF 2,829.90 of that spending: rent, health insurance, the travelcard and your subscriptions. They do not change from month to month, so the room to move is in the remaining CHF 960.30.',
|
|
59
|
+
'If you keep dining at the April level and cancel the two unused subscriptions, spending drops by about CHF 186.00 a month. That would leave roughly CHF 2,875.00.',
|
|
60
|
+
'A standing order of CHF 2,300.00 on the 26th, the day after your salary arrives, still leaves a buffer of more than CHF 500.00 for months like May, when a yearly premium falls due.',
|
|
61
|
+
'I can set up the standing order as a draft. You confirm it in your banking app before it becomes active.',
|
|
62
|
+
].join('\n\n'),
|
|
63
|
+
},
|
|
64
|
+
];
|
|
65
|
+
|
|
66
|
+
/** Every turn, for the playground's row count. */
|
|
67
|
+
export const ALL_TURNS: ConversationTurn[] = [...CONVERSATION, ...FOLLOW_UP_TURNS];
|
|
68
|
+
|
|
69
|
+
/** The scroll button's tooltip and accessible name. */
|
|
70
|
+
export const SCROLL_TOOLTIP = 'Scroll to latest message';
|