@swisper.ai/web-chat-ui 0.0.2 → 0.0.4
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 +27 -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-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/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 +1227 -1260
- 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 +15 -9
- 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/chat-input.json +10 -2
- package/src/components/chat-input/chat-input.stories.tsx +660 -197
- package/src/components/chat-input/chat-input.tsx +32 -2
- 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/rich-text-area.json +6 -4
- package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
- package/src/components/rich-text-area/rich-text-area.tsx +22 -1
- 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
|
@@ -14,9 +14,14 @@ import { cn } from '@swisper.ai/web-core';
|
|
|
14
14
|
export interface ChatThinkingProcessProps extends Omit<CollapsibleProps, 'isDisabled'> {
|
|
15
15
|
children: ReactNode;
|
|
16
16
|
className?: string;
|
|
17
|
+
/** The model is still thinking: the label shimmers and, while collapsed, the last step is previewed. */
|
|
17
18
|
isStreaming?: boolean;
|
|
18
19
|
}
|
|
19
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Collapsible disclosure of the assistant's reasoning or tool steps. Collapsed by default; exposes
|
|
23
|
+
* `data-state` (`open` / `closed`) and `data-streaming` for its parts to style from.
|
|
24
|
+
*/
|
|
20
25
|
export const ChatThinkingProcess = forwardRef<HTMLDivElement, ChatThinkingProcessProps>(
|
|
21
26
|
function ChatThinkingProcess(
|
|
22
27
|
{ children, className, defaultOpen = false, isStreaming = false, ...rest },
|
|
@@ -26,6 +31,7 @@ export const ChatThinkingProcess = forwardRef<HTMLDivElement, ChatThinkingProces
|
|
|
26
31
|
<Collapsible defaultOpen={defaultOpen} asChild {...rest}>
|
|
27
32
|
<div
|
|
28
33
|
ref={ref}
|
|
34
|
+
data-slot="chat-thinking-process"
|
|
29
35
|
data-testid="chat-thinking-process"
|
|
30
36
|
data-streaming={isStreaming}
|
|
31
37
|
className={cn('group/thinking-process', 'flex flex-col', className)}
|
|
@@ -45,6 +51,7 @@ export interface ChatThinkingProcessTriggerProps extends ComponentProps<'button'
|
|
|
45
51
|
isLoading?: boolean;
|
|
46
52
|
}
|
|
47
53
|
|
|
54
|
+
/** The button that expands and collapses the steps; holds the icon, the label and the arrow. */
|
|
48
55
|
export function ChatThinkingProcessTrigger({
|
|
49
56
|
children,
|
|
50
57
|
className,
|
|
@@ -52,6 +59,7 @@ export function ChatThinkingProcessTrigger({
|
|
|
52
59
|
}: ChatThinkingProcessTriggerProps) {
|
|
53
60
|
return (
|
|
54
61
|
<CollapsibleTrigger
|
|
62
|
+
data-slot="chat-thinking-process-trigger"
|
|
55
63
|
data-testid="chat-thinking-process-trigger"
|
|
56
64
|
className={cn('flex w-full items-center gap-4', 'cursor-pointer text-left', className)}
|
|
57
65
|
{...rest}
|
|
@@ -76,6 +84,7 @@ export interface ChatThinkingProcessTriggerIconProps extends ComponentProps<'spa
|
|
|
76
84
|
className?: string;
|
|
77
85
|
}
|
|
78
86
|
|
|
87
|
+
/** The icon before the label: what kind of work the process is. */
|
|
79
88
|
export function ChatThinkingProcessTriggerIcon({
|
|
80
89
|
children,
|
|
81
90
|
className,
|
|
@@ -83,6 +92,7 @@ export function ChatThinkingProcessTriggerIcon({
|
|
|
83
92
|
}: ChatThinkingProcessTriggerIconProps) {
|
|
84
93
|
return (
|
|
85
94
|
<span
|
|
95
|
+
data-slot="chat-thinking-process-trigger-icon"
|
|
86
96
|
data-testid="chat-thinking-process-trigger-icon"
|
|
87
97
|
className={cn('inline-flex shrink-0 items-center justify-center', className)}
|
|
88
98
|
{...rest}
|
|
@@ -97,6 +107,7 @@ export interface ChatThinkingProcessTriggerLabelProps extends ComponentProps<'sp
|
|
|
97
107
|
className?: string;
|
|
98
108
|
}
|
|
99
109
|
|
|
110
|
+
/** The trigger's text and accessible name; shimmers while the root is streaming. */
|
|
100
111
|
export function ChatThinkingProcessTriggerLabel({
|
|
101
112
|
children,
|
|
102
113
|
className,
|
|
@@ -106,6 +117,7 @@ export function ChatThinkingProcessTriggerLabel({
|
|
|
106
117
|
<Typography
|
|
107
118
|
asChild
|
|
108
119
|
variant="body-sm"
|
|
120
|
+
data-slot="chat-thinking-process-trigger-label"
|
|
109
121
|
data-testid="chat-thinking-process-trigger-label"
|
|
110
122
|
className={cn(
|
|
111
123
|
'text-text-secondary',
|
|
@@ -126,12 +138,14 @@ export interface ChatThinkingProcessTriggerArrowProps extends ComponentProps<'sp
|
|
|
126
138
|
className?: string;
|
|
127
139
|
}
|
|
128
140
|
|
|
141
|
+
/** The chevron after the label; points up while the steps are expanded. Hidden from assistive tech. */
|
|
129
142
|
export function ChatThinkingProcessTriggerArrow({
|
|
130
143
|
className,
|
|
131
144
|
...rest
|
|
132
145
|
}: ChatThinkingProcessTriggerArrowProps) {
|
|
133
146
|
return (
|
|
134
147
|
<span
|
|
148
|
+
data-slot="chat-thinking-process-trigger-arrow"
|
|
135
149
|
data-testid="chat-thinking-process-trigger-arrow"
|
|
136
150
|
aria-hidden
|
|
137
151
|
className={cn(
|
|
@@ -149,15 +163,34 @@ export function ChatThinkingProcessTriggerArrow({
|
|
|
149
163
|
|
|
150
164
|
export interface ChatThinkingProcessContentProps extends ComponentProps<'div'> {
|
|
151
165
|
children: ReactNode;
|
|
166
|
+
/** Classes for the outer wrapper, which holds the preview and the list of steps. */
|
|
152
167
|
className?: string;
|
|
168
|
+
/** Classes for the expanded list of steps. */
|
|
153
169
|
itemsClassName?: string;
|
|
170
|
+
/** Classes for each timeline row: the marker column and the step beside it. */
|
|
171
|
+
rowClassName?: string;
|
|
172
|
+
/** Classes for the dot that marks each step. */
|
|
173
|
+
markerClassName?: string;
|
|
174
|
+
/** Classes for the line that joins a step's dot to the next one. */
|
|
175
|
+
connectorClassName?: string;
|
|
176
|
+
/** Classes for the faded preview of the last step. */
|
|
177
|
+
previewClassName?: string;
|
|
178
|
+
/** Previews the last step while the root is streaming and collapsed. */
|
|
154
179
|
hasLastMessagePreview?: boolean;
|
|
155
180
|
}
|
|
156
181
|
|
|
182
|
+
/**
|
|
183
|
+
* The steps. Each child becomes a timeline row in the expanded list, and the last child is
|
|
184
|
+
* previewed while the root is streaming and collapsed.
|
|
185
|
+
*/
|
|
157
186
|
export function ChatThinkingProcessContent({
|
|
158
187
|
children,
|
|
159
188
|
className,
|
|
160
189
|
itemsClassName,
|
|
190
|
+
rowClassName,
|
|
191
|
+
markerClassName,
|
|
192
|
+
connectorClassName,
|
|
193
|
+
previewClassName,
|
|
161
194
|
hasLastMessagePreview = true,
|
|
162
195
|
...rest
|
|
163
196
|
}: ChatThinkingProcessContentProps) {
|
|
@@ -171,19 +204,21 @@ export function ChatThinkingProcessContent({
|
|
|
171
204
|
|
|
172
205
|
return (
|
|
173
206
|
<div
|
|
207
|
+
data-slot="chat-thinking-process-content"
|
|
174
208
|
data-testid="chat-thinking-process-content"
|
|
175
209
|
data-preview={hasLastMessagePreview}
|
|
176
210
|
className={cn('pt-8', className)}
|
|
177
211
|
>
|
|
178
212
|
{hasLastMessagePreview && lastItemContent && (
|
|
179
213
|
<AnimatePresence mode="wait">
|
|
180
|
-
<ChatThinkingProcessContentPreview contentId={lastItemIndex}>
|
|
214
|
+
<ChatThinkingProcessContentPreview contentId={lastItemIndex} className={previewClassName}>
|
|
181
215
|
{lastItemContent}
|
|
182
216
|
</ChatThinkingProcessContentPreview>
|
|
183
217
|
</AnimatePresence>
|
|
184
218
|
)}
|
|
185
219
|
|
|
186
220
|
<CollapsibleContent
|
|
221
|
+
data-slot="chat-thinking-process-content-items"
|
|
187
222
|
data-testid="chat-thinking-process-content-items"
|
|
188
223
|
className={cn('flex flex-col', itemsClassName)}
|
|
189
224
|
{...rest}
|
|
@@ -191,19 +226,32 @@ export function ChatThinkingProcessContent({
|
|
|
191
226
|
{React.Children.map(children, (child) => {
|
|
192
227
|
return (
|
|
193
228
|
<div
|
|
229
|
+
data-slot="chat-thinking-process-content-row"
|
|
194
230
|
className={cn(
|
|
195
231
|
'relative flex gap-8 text-text-secondary text-sm last:pb-0',
|
|
196
232
|
'pl-8',
|
|
197
233
|
'last:[&>div:first-child>span:last-child]:hidden',
|
|
234
|
+
rowClassName,
|
|
198
235
|
)}
|
|
199
|
-
{...rest}
|
|
200
236
|
>
|
|
201
237
|
<div
|
|
202
238
|
className="relative flex w-8 shrink-0 flex-col items-center self-stretch"
|
|
203
239
|
aria-hidden
|
|
204
240
|
>
|
|
205
|
-
<span
|
|
206
|
-
|
|
241
|
+
<span
|
|
242
|
+
data-slot="chat-thinking-process-content-marker"
|
|
243
|
+
className={cn(
|
|
244
|
+
'mt-[7px] size-[6px] shrink-0 rounded-full bg-text-secondary',
|
|
245
|
+
markerClassName,
|
|
246
|
+
)}
|
|
247
|
+
/>
|
|
248
|
+
<span
|
|
249
|
+
data-slot="chat-thinking-process-content-connector"
|
|
250
|
+
className={cn(
|
|
251
|
+
'absolute top-[16px] bottom-[-4px] left-1/2 w-px -translate-x-1/2 bg-component-divider',
|
|
252
|
+
connectorClassName,
|
|
253
|
+
)}
|
|
254
|
+
/>
|
|
207
255
|
</div>
|
|
208
256
|
|
|
209
257
|
<div className="min-w-0 flex-1 pb-8">{child}</div>
|
|
@@ -229,6 +277,7 @@ export function ChatThinkingProcessContentPreview({
|
|
|
229
277
|
return (
|
|
230
278
|
<motion.div
|
|
231
279
|
key={contentId}
|
|
280
|
+
data-slot="chat-thinking-process-content-preview"
|
|
232
281
|
data-testid="chat-thinking-process-content-preview"
|
|
233
282
|
initial={{ opacity: 0 }}
|
|
234
283
|
animate={{ opacity: 0.7 }}
|
|
@@ -251,6 +300,7 @@ export interface ChatThinkingProcessContentItemProps extends ComponentProps<'div
|
|
|
251
300
|
className?: string;
|
|
252
301
|
}
|
|
253
302
|
|
|
303
|
+
/** One step of the process: text, or any node such as streamed Markdown. */
|
|
254
304
|
export function ChatThinkingProcessContentItem({
|
|
255
305
|
children,
|
|
256
306
|
className,
|
|
@@ -258,6 +308,7 @@ export function ChatThinkingProcessContentItem({
|
|
|
258
308
|
}: ChatThinkingProcessContentItemProps) {
|
|
259
309
|
return (
|
|
260
310
|
<div
|
|
311
|
+
data-slot="chat-thinking-process-content-item"
|
|
261
312
|
data-testid="chat-thinking-process-content-item"
|
|
262
313
|
className={cn('text-text-secondary text-sm', className)}
|
|
263
314
|
{...rest}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import type { Conversation, Turn } from './types';
|
|
2
|
+
|
|
3
|
+
/** A question-and-answer conversation with the assistant; the last question is long enough to wrap. */
|
|
4
|
+
export const WEEK_AHEAD: Conversation = {
|
|
5
|
+
id: 'week-ahead',
|
|
6
|
+
title: 'Week ahead',
|
|
7
|
+
turns: [
|
|
8
|
+
{
|
|
9
|
+
id: 'calendar-tomorrow',
|
|
10
|
+
question: 'What’s on my calendar tomorrow?',
|
|
11
|
+
answer: [
|
|
12
|
+
'You have three meetings tomorrow, all before 15:00.',
|
|
13
|
+
'The weekly team sync is at 9:30 and runs for half an hour. At 11:00 you meet Anna for your 1:1, and at 14:00 there is the board preparation with Marc, booked for an hour in room Säntis.',
|
|
14
|
+
'The rest of the afternoon is free.',
|
|
15
|
+
],
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
id: 'move-board-preparation',
|
|
19
|
+
question: 'Can I move the board preparation to Thursday?',
|
|
20
|
+
answer: [
|
|
21
|
+
'Thursday works for both of you. Marc is free from 13:00 to 16:00, and your only meeting that afternoon ends at 13:30.',
|
|
22
|
+
'I can propose Thursday at 14:00 in the same room. Marc gets an updated invitation and the Wednesday slot is released.',
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
id: 'propose-thursday',
|
|
27
|
+
question: 'Yes, propose Thursday at 14:00.',
|
|
28
|
+
answer: [
|
|
29
|
+
'Done. I sent Marc the new time for the board preparation: Thursday, 14:00 to 15:00, room Säntis.',
|
|
30
|
+
'Your Wednesday afternoon is now free from 13:00.',
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
id: 'draft-reply',
|
|
35
|
+
question:
|
|
36
|
+
'Draft a reply to Marc saying I moved the board preparation to Thursday afternoon, and ask him to bring the latest numbers for the third quarter',
|
|
37
|
+
answer: [
|
|
38
|
+
'Here is a draft you can send as it is or edit first.',
|
|
39
|
+
'Hi Marc, I moved our board preparation to Thursday at 14:00, same room. Could you bring the latest numbers for the third quarter? I would like to go through revenue and costs before we finalise the slides.',
|
|
40
|
+
'Thanks, and see you Thursday.',
|
|
41
|
+
'Tell me if it should be shorter or more formal, or say “send it” and I will send it to Marc now.',
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
],
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/** A second conversation to switch to. */
|
|
48
|
+
export const LISBON_TRIP: Conversation = {
|
|
49
|
+
id: 'lisbon-trip',
|
|
50
|
+
title: 'Trip to Lisbon',
|
|
51
|
+
turns: [
|
|
52
|
+
{
|
|
53
|
+
id: 'flights',
|
|
54
|
+
question: 'Which flights get me to Lisbon before noon on Friday?',
|
|
55
|
+
answer: [
|
|
56
|
+
'Two direct flights from Zurich arrive before noon on Friday.',
|
|
57
|
+
'The first leaves at 7:05 and lands at 9:00. The second leaves at 9:40 and lands at 11:35, which leaves little room if it is delayed.',
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
id: 'hotel',
|
|
62
|
+
question: 'Is the hotel from last time available?',
|
|
63
|
+
answer: [
|
|
64
|
+
'Yes. The hotel you stayed at in March has rooms from Friday to Monday.',
|
|
65
|
+
'A room facing the courtyard is available for all three nights, and breakfast is included.',
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'calendar-block',
|
|
70
|
+
question: 'Block Friday to Monday in my calendar.',
|
|
71
|
+
answer: [
|
|
72
|
+
'Done. Friday to Monday is marked as out of office, and I declined the two meetings that fell on Friday afternoon with a note that you are travelling.',
|
|
73
|
+
'Both organisers got a suggestion to move their meeting to Tuesday, when you are back and free all morning.',
|
|
74
|
+
'Your flight and the hotel are not booked yet. Tell me which flight you prefer and I will prepare both bookings for you to confirm.',
|
|
75
|
+
],
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
/** Questions sent one after another by the interactive stories; the answers are long enough to watch them stream. */
|
|
81
|
+
export const NEXT_QUESTIONS: readonly Turn[] = [
|
|
82
|
+
{
|
|
83
|
+
id: 'unread-emails',
|
|
84
|
+
question: 'Summarise my unread emails',
|
|
85
|
+
answer: [
|
|
86
|
+
'You have seven unread emails. Three of them need your attention today.',
|
|
87
|
+
'Anna sent the agenda for your 1:1 and asks whether you want to add the hiring plan. Marc confirmed Thursday at 14:00 and attached a first version of the third-quarter numbers. The landlord wrote about the heating inspection and proposes Tuesday or Wednesday morning next week.',
|
|
88
|
+
'The other four are newsletters and a delivery notice for a parcel that arrives tomorrow.',
|
|
89
|
+
'I can draft replies to Anna and the landlord if you tell me what to answer.',
|
|
90
|
+
],
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
id: 'heating-inspection',
|
|
94
|
+
question: 'Tell the landlord Wednesday morning works',
|
|
95
|
+
answer: [
|
|
96
|
+
'I replied to the landlord that Wednesday morning works for the heating inspection and asked for a time window.',
|
|
97
|
+
'Wednesday from 8:00 to 10:00 is now held in your calendar as tentative. I will update it when the landlord confirms the exact time.',
|
|
98
|
+
'Your first meeting that day is at 10:30, so there is half an hour of room if the inspection runs late.',
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
id: 'hiring-plan',
|
|
103
|
+
question: 'Add the hiring plan to the agenda with Anna',
|
|
104
|
+
answer: [
|
|
105
|
+
'I added the hiring plan as the third item on the agenda and let Anna know.',
|
|
106
|
+
'The agenda now reads: project status, feedback on the workshop, hiring plan, and open questions. With four items the half hour is tight, so I suggested to Anna that you extend the meeting to 45 minutes.',
|
|
107
|
+
'Both of you are free until 12:00, so the longer slot fits without moving anything else.',
|
|
108
|
+
],
|
|
109
|
+
},
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
/** An agent run: each instruction is followed by the lines the agent reported while it worked. */
|
|
113
|
+
export const REPORT_RUN: Conversation = {
|
|
114
|
+
id: 'report-run',
|
|
115
|
+
title: 'Quarterly report',
|
|
116
|
+
turns: [
|
|
117
|
+
{
|
|
118
|
+
id: 'update-report',
|
|
119
|
+
question: 'Update the quarterly report with the September numbers',
|
|
120
|
+
answer: [
|
|
121
|
+
'Opening “Q3 report.xlsx” from your documents',
|
|
122
|
+
'Found three sheets: Revenue, Costs and Summary',
|
|
123
|
+
'Reading the September figures from the finance export',
|
|
124
|
+
'Updated 42 cells on Revenue',
|
|
125
|
+
'Updated 31 cells on Costs',
|
|
126
|
+
'Recalculated the Summary sheet',
|
|
127
|
+
'Saved as “Q3 report (September).xlsx”',
|
|
128
|
+
],
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: 'export-summary',
|
|
132
|
+
question: 'Export the summary as a PDF',
|
|
133
|
+
answer: [
|
|
134
|
+
'Opening the Summary sheet',
|
|
135
|
+
'Set the print area to the summary table and both charts',
|
|
136
|
+
'Exported one page',
|
|
137
|
+
'Saved as “Q3 summary.pdf” next to the report',
|
|
138
|
+
],
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** Instructions sent one after another in follow mode; the output arrives line by line. */
|
|
144
|
+
export const NEXT_INSTRUCTIONS: readonly Turn[] = [
|
|
145
|
+
{
|
|
146
|
+
id: 'compare-quarters',
|
|
147
|
+
question: 'Compare the totals with the second quarter',
|
|
148
|
+
answer: [
|
|
149
|
+
'Opening “Q2 report.xlsx” from your documents',
|
|
150
|
+
'Reading the totals from both Summary sheets',
|
|
151
|
+
'Revenue is up 6% on the second quarter',
|
|
152
|
+
'Costs are up 2%, mostly from the new office lease',
|
|
153
|
+
'The margin improved by 1.4 percentage points',
|
|
154
|
+
'Added a “Compared with Q2” table to the Summary sheet',
|
|
155
|
+
'Recalculated both charts',
|
|
156
|
+
'Saved “Q3 report (September).xlsx”',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
id: 'send-summary',
|
|
161
|
+
question: 'Send the PDF to Anna and Marc',
|
|
162
|
+
answer: [
|
|
163
|
+
'Exporting the Summary sheet again with the comparison table',
|
|
164
|
+
'Saved as “Q3 summary.pdf”, replacing the earlier export',
|
|
165
|
+
'Looking up Anna and Marc in your contacts',
|
|
166
|
+
'Drafted an email with the subject “Third-quarter summary”',
|
|
167
|
+
'Attached “Q3 summary.pdf”',
|
|
168
|
+
'Sent to Anna and Marc',
|
|
169
|
+
],
|
|
170
|
+
},
|
|
171
|
+
];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** Pixels between the bottom of the viewport and the end of its content: 0 when scrolled to the end. */
|
|
2
|
+
export function distanceFromEnd(viewport: HTMLElement): number {
|
|
3
|
+
return viewport.scrollHeight - viewport.scrollTop - viewport.clientHeight;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/** Pixels from the top edge of the viewport down to the top edge of an element inside it. */
|
|
7
|
+
export function offsetFromTop(element: HTMLElement, viewport: HTMLElement): number {
|
|
8
|
+
return element.getBoundingClientRect().top - viewport.getBoundingClientRect().top;
|
|
9
|
+
}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/** Source shown on the docs page, where the story's own code would only show a story component. */
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_SOURCE = `
|
|
4
|
+
import {
|
|
5
|
+
ChatMessage,
|
|
6
|
+
ChatMessageContent,
|
|
7
|
+
ChatThread,
|
|
8
|
+
ChatThreadAnswer,
|
|
9
|
+
ChatThreadGroup,
|
|
10
|
+
ChatThreadProvider,
|
|
11
|
+
ChatThreadQuestion,
|
|
12
|
+
} from '@swisper.ai/web-chat-ui';
|
|
13
|
+
|
|
14
|
+
// The parent needs a height of its own (here from the page layout):
|
|
15
|
+
// ChatThread fills it and is the only scroller.
|
|
16
|
+
<div className="flex h-full flex-col">
|
|
17
|
+
<ChatThreadProvider conversationId={conversation.id} groupIds={turns.map((turn) => turn.id)}>
|
|
18
|
+
<ChatThread contentClassName="p-12" scrollButtonTooltip="Scroll to the latest">
|
|
19
|
+
{turns.map((turn) => (
|
|
20
|
+
<ChatThreadGroup key={turn.id} groupId={turn.id}>
|
|
21
|
+
<ChatThreadQuestion messageId={turn.questionId}>
|
|
22
|
+
<ChatMessage isQuestion>
|
|
23
|
+
<ChatMessageContent>{turn.question}</ChatMessageContent>
|
|
24
|
+
</ChatMessage>
|
|
25
|
+
</ChatThreadQuestion>
|
|
26
|
+
<ChatThreadAnswer messageId={turn.answerId}>
|
|
27
|
+
<ChatMessage>
|
|
28
|
+
<ChatMessageContent>{turn.answer}</ChatMessageContent>
|
|
29
|
+
</ChatMessage>
|
|
30
|
+
</ChatThreadAnswer>
|
|
31
|
+
</ChatThreadGroup>
|
|
32
|
+
))}
|
|
33
|
+
</ChatThread>
|
|
34
|
+
</ChatThreadProvider>
|
|
35
|
+
</div>
|
|
36
|
+
`.trim();
|
|
37
|
+
|
|
38
|
+
export const STREAMING_SOURCE = `
|
|
39
|
+
// Add the new group to groupIds as soon as the question is sent, and keep
|
|
40
|
+
// isStreaming true until the last chunk of the answer has arrived.
|
|
41
|
+
<ChatThreadProvider
|
|
42
|
+
conversationId={conversation.id}
|
|
43
|
+
groupIds={turns.map((turn) => turn.id)}
|
|
44
|
+
isStreaming={isStreaming}
|
|
45
|
+
>
|
|
46
|
+
<ChatThread contentClassName="p-12" scrollButtonTooltip="Scroll to the latest">
|
|
47
|
+
{turns.map((turn) => (
|
|
48
|
+
<ChatThreadGroup key={turn.id} groupId={turn.id}>
|
|
49
|
+
{/* ChatThreadQuestion and ChatThreadAnswer, as in Default */}
|
|
50
|
+
</ChatThreadGroup>
|
|
51
|
+
))}
|
|
52
|
+
</ChatThread>
|
|
53
|
+
</ChatThreadProvider>
|
|
54
|
+
`.trim();
|
|
55
|
+
|
|
56
|
+
export const FOLLOW_MODE_SOURCE = `
|
|
57
|
+
<ChatThreadProvider
|
|
58
|
+
conversationId={run.id}
|
|
59
|
+
groupIds={steps.map((step) => step.id)}
|
|
60
|
+
isStreaming={isRunning}
|
|
61
|
+
scrollMode="follow"
|
|
62
|
+
>
|
|
63
|
+
<ChatThread contentClassName="p-12" scrollButtonTooltip="Jump to latest">
|
|
64
|
+
{steps.map((step) => (
|
|
65
|
+
<ChatThreadGroup key={step.id} groupId={step.id}>
|
|
66
|
+
{/* ChatThreadQuestion and ChatThreadAnswer, as in Default */}
|
|
67
|
+
</ChatThreadGroup>
|
|
68
|
+
))}
|
|
69
|
+
</ChatThread>
|
|
70
|
+
</ChatThreadProvider>
|
|
71
|
+
`.trim();
|
|
72
|
+
|
|
73
|
+
export const SCROLL_COMMANDS_SOURCE = `
|
|
74
|
+
import { Button } from '@swisper.ai/ui';
|
|
75
|
+
import { useChatThread } from '@swisper.ai/web-chat-ui';
|
|
76
|
+
|
|
77
|
+
// Anywhere inside ChatThreadProvider, also outside ChatThread itself.
|
|
78
|
+
function JumpToQuestion({ groupId }: { groupId: string }) {
|
|
79
|
+
const { scrollToMessage } = useChatThread();
|
|
80
|
+
|
|
81
|
+
return (
|
|
82
|
+
<Button
|
|
83
|
+
size="sm"
|
|
84
|
+
onClick={() =>
|
|
85
|
+
// A group is registered as "chat-thread-group-<groupId>".
|
|
86
|
+
scrollToMessage(\`chat-thread-group-\${groupId}\`, { align: 'start', behavior: 'smooth' })
|
|
87
|
+
}
|
|
88
|
+
>
|
|
89
|
+
Go to the question
|
|
90
|
+
</Button>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
`.trim();
|
|
94
|
+
|
|
95
|
+
export const EXAMPLES_SOURCE = `
|
|
96
|
+
import {
|
|
97
|
+
CanvasShell,
|
|
98
|
+
CanvasShellCloseTrigger,
|
|
99
|
+
CanvasShellContent,
|
|
100
|
+
CanvasShellFooter,
|
|
101
|
+
CanvasShellHeader,
|
|
102
|
+
CanvasShellTitle,
|
|
103
|
+
canvasShellContentPadding,
|
|
104
|
+
ChatThread,
|
|
105
|
+
ChatThreadProvider,
|
|
106
|
+
} from '@swisper.ai/web-chat-ui';
|
|
107
|
+
|
|
108
|
+
<CanvasShell aria-label={conversation.title}>
|
|
109
|
+
<CanvasShellHeader>
|
|
110
|
+
<CanvasShellTitle>{conversation.title}</CanvasShellTitle>
|
|
111
|
+
<CanvasShellCloseTrigger onClick={onClose} />
|
|
112
|
+
</CanvasShellHeader>
|
|
113
|
+
|
|
114
|
+
{/* The thread scrolls and pads itself, so the shell does neither. */}
|
|
115
|
+
<CanvasShellContent hasPadding={false} hasScroll={false}>
|
|
116
|
+
<ChatThreadProvider conversationId={conversation.id} groupIds={turns.map((turn) => turn.id)}>
|
|
117
|
+
<ChatThread
|
|
118
|
+
className="h-full"
|
|
119
|
+
contentClassName={canvasShellContentPadding}
|
|
120
|
+
scrollButtonTooltip="Scroll to the latest"
|
|
121
|
+
>
|
|
122
|
+
{/* One ChatThreadGroup per turn, as in Default */}
|
|
123
|
+
</ChatThread>
|
|
124
|
+
</ChatThreadProvider>
|
|
125
|
+
</CanvasShellContent>
|
|
126
|
+
|
|
127
|
+
<CanvasShellFooter className="flex-col items-stretch">{/* The composer */}</CanvasShellFooter>
|
|
128
|
+
</CanvasShell>
|
|
129
|
+
`.trim();
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@swisper.ai/web-core';
|
|
4
|
+
|
|
5
|
+
export interface ThreadFrameProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** A panel with a fixed height: `ChatThread` fills its parent, so the parent has to be sized. */
|
|
11
|
+
export function ThreadFrame({ children, className }: ThreadFrameProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
className={cn(
|
|
15
|
+
'mx-auto flex h-120 w-full max-w-105 flex-col rounded-10 border border-divider-border-base',
|
|
16
|
+
className,
|
|
17
|
+
)}
|
|
18
|
+
>
|
|
19
|
+
{children}
|
|
20
|
+
</div>
|
|
21
|
+
);
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ChatMessage, ChatMessageContent } from '../../chat-message';
|
|
2
|
+
import { ChatThreadAnswer, ChatThreadGroup, ChatThreadQuestion } from '../chat-thread';
|
|
3
|
+
|
|
4
|
+
import type { Turn } from './types';
|
|
5
|
+
|
|
6
|
+
export interface ThreadTurnsProps {
|
|
7
|
+
turns: readonly Turn[];
|
|
8
|
+
groupClassName?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** The children of a `ChatThread`: one `ChatThreadGroup` per turn, holding its question and its answer. */
|
|
12
|
+
export function ThreadTurns({ turns, groupClassName }: ThreadTurnsProps) {
|
|
13
|
+
return (
|
|
14
|
+
<>
|
|
15
|
+
{turns.map((turn) => (
|
|
16
|
+
<ChatThreadGroup key={turn.id} groupId={turn.id} className={groupClassName}>
|
|
17
|
+
<ChatThreadQuestion messageId={`${turn.id}-question`}>
|
|
18
|
+
<ChatMessage isQuestion>
|
|
19
|
+
<ChatMessageContent>{turn.question}</ChatMessageContent>
|
|
20
|
+
</ChatMessage>
|
|
21
|
+
</ChatThreadQuestion>
|
|
22
|
+
<ChatThreadAnswer messageId={`${turn.id}-answer`}>
|
|
23
|
+
{turn.answer.length > 0 && (
|
|
24
|
+
<ChatMessage>
|
|
25
|
+
{turn.answer.map((block, index) => (
|
|
26
|
+
<ChatMessageContent key={index}>{block}</ChatMessageContent>
|
|
27
|
+
))}
|
|
28
|
+
</ChatMessage>
|
|
29
|
+
)}
|
|
30
|
+
</ChatThreadAnswer>
|
|
31
|
+
</ChatThreadGroup>
|
|
32
|
+
))}
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** One question with its answer; each answer entry renders as its own `ChatMessageContent` block. */
|
|
2
|
+
export interface Turn {
|
|
3
|
+
id: string;
|
|
4
|
+
question: string;
|
|
5
|
+
answer: readonly string[];
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface Conversation {
|
|
9
|
+
id: string;
|
|
10
|
+
title: string;
|
|
11
|
+
turns: readonly Turn[];
|
|
12
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import type { Turn } from './types';
|
|
4
|
+
|
|
5
|
+
export interface UseTurnStreamOptions {
|
|
6
|
+
/** Turns sent one after another by `sendNext`, starting over when they run out */
|
|
7
|
+
nextTurns: readonly Turn[];
|
|
8
|
+
/** `word` reveals an answer word by word; `line` adds one answer block per tick */
|
|
9
|
+
chunk?: 'word' | 'line';
|
|
10
|
+
intervalMs?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Every intermediate state of an answer, in the order a stream would produce them. */
|
|
14
|
+
function answerSnapshots(answer: readonly string[], chunk: 'word' | 'line'): string[][] {
|
|
15
|
+
if (chunk === 'line') {
|
|
16
|
+
return answer.map((_, index) => answer.slice(0, index + 1));
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return answer.flatMap((paragraph, paragraphIndex) => {
|
|
20
|
+
const words = paragraph.match(/\S+\s*/g) ?? [];
|
|
21
|
+
|
|
22
|
+
return words.map((_, wordIndex) => [
|
|
23
|
+
...answer.slice(0, paragraphIndex),
|
|
24
|
+
words.slice(0, wordIndex + 1).join(''),
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Stands in for a chat backend: `sendNext` appends the next question and streams its answer on a timer,
|
|
31
|
+
* with `isStreaming` true from the question until the last chunk.
|
|
32
|
+
*/
|
|
33
|
+
export function useTurnStream(
|
|
34
|
+
initialTurns: readonly Turn[],
|
|
35
|
+
{ nextTurns, chunk = 'word', intervalMs = 45 }: UseTurnStreamOptions,
|
|
36
|
+
) {
|
|
37
|
+
const [turns, setTurns] = useState(initialTurns);
|
|
38
|
+
const [isStreaming, setIsStreaming] = useState(false);
|
|
39
|
+
const sentCountRef = useRef(0);
|
|
40
|
+
const timerRef = useRef<number | undefined>(undefined);
|
|
41
|
+
|
|
42
|
+
const stop = useCallback(() => {
|
|
43
|
+
window.clearInterval(timerRef.current);
|
|
44
|
+
timerRef.current = undefined;
|
|
45
|
+
setIsStreaming(false);
|
|
46
|
+
}, []);
|
|
47
|
+
|
|
48
|
+
useEffect(() => () => window.clearInterval(timerRef.current), []);
|
|
49
|
+
|
|
50
|
+
const sendNext = useCallback(() => {
|
|
51
|
+
const source = nextTurns[sentCountRef.current % nextTurns.length];
|
|
52
|
+
|
|
53
|
+
if (!source) return;
|
|
54
|
+
|
|
55
|
+
const id = `${source.id}-${sentCountRef.current}`;
|
|
56
|
+
const snapshots = answerSnapshots(source.answer, chunk);
|
|
57
|
+
let step = 0;
|
|
58
|
+
|
|
59
|
+
sentCountRef.current += 1;
|
|
60
|
+
window.clearInterval(timerRef.current);
|
|
61
|
+
setTurns((current) => [...current, { id, question: source.question, answer: [] }]);
|
|
62
|
+
setIsStreaming(true);
|
|
63
|
+
|
|
64
|
+
timerRef.current = window.setInterval(() => {
|
|
65
|
+
const answer = snapshots[step];
|
|
66
|
+
|
|
67
|
+
step += 1;
|
|
68
|
+
|
|
69
|
+
if (answer) {
|
|
70
|
+
setTurns((current) => current.map((turn) => (turn.id === id ? { ...turn, answer } : turn)));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (step >= snapshots.length) stop();
|
|
74
|
+
}, intervalMs);
|
|
75
|
+
}, [nextTurns, chunk, intervalMs, stop]);
|
|
76
|
+
|
|
77
|
+
return { turns, isStreaming, sendNext };
|
|
78
|
+
}
|