@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,10 +1,20 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import {
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import { expect, fn, waitFor } from 'storybook/test';
|
|
3
4
|
|
|
4
|
-
import { BrainIcon } from '@swisper.ai/icons';
|
|
5
|
+
import { BrainIcon, SearchIcon, ToolIcon } from '@swisper.ai/icons';
|
|
5
6
|
|
|
7
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
6
8
|
import { useStreamingMarkdown } from '../../utils/use-streaming-markdown';
|
|
9
|
+
import { ChatMessage, ChatMessageContent } from '../chat-message';
|
|
7
10
|
|
|
11
|
+
import {
|
|
12
|
+
AGENT_ANSWER,
|
|
13
|
+
AGENT_REASONING,
|
|
14
|
+
AGENT_REQUEST,
|
|
15
|
+
EXPENSE_STEPS,
|
|
16
|
+
MAILBOX_LOOKUP_LOG,
|
|
17
|
+
} from './__stories__/fixtures';
|
|
8
18
|
import {
|
|
9
19
|
ChatThinkingProcess,
|
|
10
20
|
ChatThinkingProcessContent,
|
|
@@ -13,16 +23,26 @@ import {
|
|
|
13
23
|
ChatThinkingProcessTriggerArrow,
|
|
14
24
|
ChatThinkingProcessTriggerIcon,
|
|
15
25
|
ChatThinkingProcessTriggerLabel,
|
|
26
|
+
type ChatThinkingProcessContentProps,
|
|
27
|
+
type ChatThinkingProcessProps,
|
|
16
28
|
} from './chat-thinking-process';
|
|
17
29
|
|
|
18
30
|
const meta: Meta<typeof ChatThinkingProcess> = {
|
|
19
|
-
title: '
|
|
31
|
+
title: 'Chat/ChatThinkingProcess',
|
|
20
32
|
component: ChatThinkingProcess,
|
|
33
|
+
subcomponents: {
|
|
34
|
+
ChatThinkingProcessTrigger,
|
|
35
|
+
ChatThinkingProcessTriggerIcon,
|
|
36
|
+
ChatThinkingProcessTriggerLabel,
|
|
37
|
+
ChatThinkingProcessTriggerArrow,
|
|
38
|
+
ChatThinkingProcessContent,
|
|
39
|
+
ChatThinkingProcessContentItem,
|
|
40
|
+
},
|
|
21
41
|
parameters: { layout: 'padded' },
|
|
22
42
|
tags: ['autodocs'],
|
|
23
43
|
decorators: [
|
|
24
44
|
(Story) => (
|
|
25
|
-
<div className="w-
|
|
45
|
+
<div className="w-full max-w-175">
|
|
26
46
|
<Story />
|
|
27
47
|
</div>
|
|
28
48
|
),
|
|
@@ -61,127 +81,84 @@ const meta: Meta<typeof ChatThinkingProcess> = {
|
|
|
61
81
|
isStreaming: false,
|
|
62
82
|
defaultOpen: false,
|
|
63
83
|
onOpenChange: fn(),
|
|
64
|
-
children: (
|
|
65
|
-
<>
|
|
66
|
-
<ChatThinkingProcessTrigger>
|
|
67
|
-
<ChatThinkingProcessTriggerIcon>
|
|
68
|
-
<BrainIcon />
|
|
69
|
-
</ChatThinkingProcessTriggerIcon>
|
|
70
|
-
<ChatThinkingProcessTriggerLabel>Thinking...</ChatThinkingProcessTriggerLabel>
|
|
71
|
-
<ChatThinkingProcessTriggerArrow />
|
|
72
|
-
</ChatThinkingProcessTrigger>
|
|
73
|
-
<ChatThinkingProcessContent>
|
|
74
|
-
<ChatThinkingProcessContentItem>
|
|
75
|
-
Searching knowledge base...
|
|
76
|
-
</ChatThinkingProcessContentItem>
|
|
77
|
-
<ChatThinkingProcessContentItem>Analyzing context...</ChatThinkingProcessContentItem>
|
|
78
|
-
</ChatThinkingProcessContent>
|
|
79
|
-
</>
|
|
80
|
-
),
|
|
81
84
|
},
|
|
82
85
|
};
|
|
83
86
|
|
|
84
87
|
export default meta;
|
|
85
88
|
type Story = StoryObj<typeof ChatThinkingProcess>;
|
|
86
89
|
|
|
90
|
+
/** A finished process above an answer: collapsed, with a label that sums up what was done. */
|
|
87
91
|
export const Default: Story = {
|
|
88
|
-
render: () => (
|
|
89
|
-
<ChatThinkingProcess>
|
|
92
|
+
render: (args) => (
|
|
93
|
+
<ChatThinkingProcess {...args}>
|
|
90
94
|
<ChatThinkingProcessTrigger>
|
|
91
95
|
<ChatThinkingProcessTriggerIcon>
|
|
92
96
|
<BrainIcon />
|
|
93
97
|
</ChatThinkingProcessTriggerIcon>
|
|
94
|
-
<ChatThinkingProcessTriggerLabel>
|
|
98
|
+
<ChatThinkingProcessTriggerLabel>
|
|
99
|
+
Used {EXPENSE_STEPS.length} tools
|
|
100
|
+
</ChatThinkingProcessTriggerLabel>
|
|
95
101
|
<ChatThinkingProcessTriggerArrow />
|
|
96
102
|
</ChatThinkingProcessTrigger>
|
|
97
103
|
|
|
98
104
|
<ChatThinkingProcessContent>
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
{EXPENSE_STEPS.map((step) => (
|
|
106
|
+
<ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
|
|
107
|
+
))}
|
|
101
108
|
</ChatThinkingProcessContent>
|
|
102
109
|
</ChatThinkingProcess>
|
|
103
110
|
),
|
|
104
111
|
};
|
|
105
112
|
|
|
113
|
+
/** Still thinking with the preview switched off: the label shimmers, and the steps show only once expanded. */
|
|
106
114
|
export const WithoutPreview: Story = {
|
|
107
|
-
|
|
108
|
-
|
|
115
|
+
args: { isStreaming: true },
|
|
116
|
+
render: (args) => (
|
|
117
|
+
<ChatThinkingProcess {...args}>
|
|
109
118
|
<ChatThinkingProcessTrigger>
|
|
110
119
|
<ChatThinkingProcessTriggerIcon>
|
|
111
120
|
<BrainIcon />
|
|
112
121
|
</ChatThinkingProcessTriggerIcon>
|
|
113
|
-
<ChatThinkingProcessTriggerLabel>Thinking
|
|
122
|
+
<ChatThinkingProcessTriggerLabel>Thinking…</ChatThinkingProcessTriggerLabel>
|
|
114
123
|
<ChatThinkingProcessTriggerArrow />
|
|
115
124
|
</ChatThinkingProcessTrigger>
|
|
116
125
|
|
|
117
126
|
<ChatThinkingProcessContent hasLastMessagePreview={false}>
|
|
118
|
-
|
|
119
|
-
|
|
127
|
+
{EXPENSE_STEPS.slice(0, 2).map((step) => (
|
|
128
|
+
<ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
|
|
129
|
+
))}
|
|
120
130
|
</ChatThinkingProcessContent>
|
|
121
131
|
</ChatThinkingProcess>
|
|
122
132
|
),
|
|
123
133
|
};
|
|
124
134
|
|
|
135
|
+
/** Still thinking: the label shimmers and the latest step is previewed under the collapsed trigger. */
|
|
125
136
|
export const Streaming: Story = {
|
|
126
|
-
|
|
127
|
-
|
|
137
|
+
args: { isStreaming: true },
|
|
138
|
+
render: (args) => (
|
|
139
|
+
<ChatThinkingProcess {...args}>
|
|
128
140
|
<ChatThinkingProcessTrigger>
|
|
129
141
|
<ChatThinkingProcessTriggerIcon>
|
|
130
142
|
<BrainIcon />
|
|
131
143
|
</ChatThinkingProcessTriggerIcon>
|
|
132
|
-
<ChatThinkingProcessTriggerLabel>Thinking
|
|
144
|
+
<ChatThinkingProcessTriggerLabel>Thinking…</ChatThinkingProcessTriggerLabel>
|
|
133
145
|
<ChatThinkingProcessTriggerArrow />
|
|
134
146
|
</ChatThinkingProcessTrigger>
|
|
135
147
|
|
|
136
148
|
<ChatThinkingProcessContent>
|
|
137
|
-
|
|
138
|
-
|
|
149
|
+
{EXPENSE_STEPS.slice(0, 2).map((step) => (
|
|
150
|
+
<ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
|
|
151
|
+
))}
|
|
139
152
|
</ChatThinkingProcessContent>
|
|
140
153
|
</ChatThinkingProcess>
|
|
141
154
|
),
|
|
142
155
|
};
|
|
143
156
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
Understanding intent
|
|
147
|
-
- Parsed: "show me my emails" → list inbox messages for the connected account
|
|
148
|
-
- Scope: Inbox only (excluding Sent, Drafts, Junk unless user asks otherwise)
|
|
149
|
-
- Time window: last 7 days, newest first
|
|
150
|
-
|
|
151
|
-
Checking access
|
|
152
|
-
- Account: alex.morgan@acme.com (Microsoft 365)
|
|
153
|
-
- OAuth token present and not expired
|
|
154
|
-
- Required scope Mail.Read confirmed
|
|
155
|
-
|
|
156
|
-
Connecting to mailbox
|
|
157
|
-
- Endpoint: https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messages
|
|
158
|
-
- Building OData query:
|
|
159
|
-
- $filter: receivedDateTime ge 2026-05-21T00:00:00Z
|
|
160
|
-
- $orderby: receivedDateTime desc
|
|
161
|
-
- $top: 50
|
|
162
|
-
- $select: id,subject,from,receivedDateTime,isRead,hasAttachments,bodyPreview
|
|
163
|
-
|
|
164
|
-
Fetching messages (page 1 of 1)
|
|
165
|
-
- Request sent… waiting for response
|
|
166
|
-
- HTTP 200 — 47 messages returned in 312ms
|
|
167
|
-
|
|
168
|
-
Normalizing results
|
|
169
|
-
- Mapping sender display names and email addresses
|
|
170
|
-
- Trimming body previews to 120 characters
|
|
171
|
-
- Flagging 12 unread, 8 with attachments
|
|
172
|
-
|
|
173
|
-
Ranking for display
|
|
174
|
-
- Prioritizing unread and messages from known contacts
|
|
175
|
-
- Deprioritizing newsletters and automated notifications (noreply@, no-reply@)
|
|
176
|
-
|
|
177
|
-
Preparing summary
|
|
178
|
-
- Grouping: 12 unread · 35 read · 8 with attachments
|
|
179
|
-
- Top threads: "Q2 budget review", "Design sign-off", "Invoice #4821"
|
|
180
|
-
- Ready to present the email list to the user`;
|
|
181
|
-
|
|
157
|
+
/** A step whose text grows as it streams in; the label changes to a summary once the stream ends. */
|
|
182
158
|
export const StreamingWithContent: Story = {
|
|
159
|
+
parameters: { controls: { disable: true } },
|
|
183
160
|
render: () => {
|
|
184
|
-
const { markdown, isStreaming } = useStreamingMarkdown(
|
|
161
|
+
const { markdown, isStreaming } = useStreamingMarkdown(MAILBOX_LOOKUP_LOG, 30);
|
|
185
162
|
|
|
186
163
|
return (
|
|
187
164
|
<ChatThinkingProcess isStreaming={isStreaming}>
|
|
@@ -189,14 +166,313 @@ export const StreamingWithContent: Story = {
|
|
|
189
166
|
<ChatThinkingProcessTriggerIcon>
|
|
190
167
|
<BrainIcon />
|
|
191
168
|
</ChatThinkingProcessTriggerIcon>
|
|
192
|
-
<ChatThinkingProcessTriggerLabel>
|
|
169
|
+
<ChatThinkingProcessTriggerLabel>
|
|
170
|
+
{isStreaming ? 'Thinking…' : 'Used 2 tools'}
|
|
171
|
+
</ChatThinkingProcessTriggerLabel>
|
|
193
172
|
<ChatThinkingProcessTriggerArrow />
|
|
194
173
|
</ChatThinkingProcessTrigger>
|
|
195
174
|
<ChatThinkingProcessContent>
|
|
196
|
-
<ChatThinkingProcessContentItem>Connecting to mailbox
|
|
197
|
-
<ChatThinkingProcessContentItem>
|
|
175
|
+
<ChatThinkingProcessContentItem>Connecting to mailbox…</ChatThinkingProcessContentItem>
|
|
176
|
+
<ChatThinkingProcessContentItem className="whitespace-pre-wrap">
|
|
177
|
+
{markdown}
|
|
178
|
+
</ChatThinkingProcessContentItem>
|
|
198
179
|
</ChatThinkingProcessContent>
|
|
199
180
|
</ChatThinkingProcess>
|
|
200
181
|
);
|
|
201
182
|
},
|
|
202
183
|
};
|
|
184
|
+
|
|
185
|
+
/** Expands and collapses the finished process with the mouse, checking the trigger's expanded state. */
|
|
186
|
+
export const DefaultOpenAndClose: Story = {
|
|
187
|
+
...Default,
|
|
188
|
+
tags: ['e2e', '!autodocs'],
|
|
189
|
+
args: { onOpenChange: fn() },
|
|
190
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
191
|
+
const trigger = canvas.getByRole('button', { name: 'Used 4 tools' });
|
|
192
|
+
|
|
193
|
+
await step('Starts collapsed with no step and no preview', async () => {
|
|
194
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
195
|
+
await expect(canvas.queryByText(EXPENSE_STEPS[0])).toBeNull();
|
|
196
|
+
// The last step stays mounted for the preview, which only shows while streaming.
|
|
197
|
+
await expect(canvas.getByText(EXPENSE_STEPS[3])).not.toBeVisible();
|
|
198
|
+
});
|
|
199
|
+
|
|
200
|
+
await step('Expands to every step', async () => {
|
|
201
|
+
await userEvent.click(trigger);
|
|
202
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
203
|
+
for (const text of EXPENSE_STEPS.slice(0, 3)) {
|
|
204
|
+
await expect(canvas.getByText(text)).toBeVisible();
|
|
205
|
+
}
|
|
206
|
+
await expect(
|
|
207
|
+
canvas.getAllByText(EXPENSE_STEPS[3]).filter((copy) => copy.checkVisibility()),
|
|
208
|
+
).toHaveLength(1);
|
|
209
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(true);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
await step('Collapses again', async () => {
|
|
213
|
+
await userEvent.click(trigger);
|
|
214
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
215
|
+
await expect(canvas.queryByText(EXPENSE_STEPS[0])).toBeNull();
|
|
216
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(false);
|
|
217
|
+
});
|
|
218
|
+
},
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/** Focuses the trigger with Tab, expands the steps with Enter and collapses them with Space. */
|
|
222
|
+
export const DefaultKeyboard: Story = {
|
|
223
|
+
...Default,
|
|
224
|
+
tags: ['e2e', '!autodocs'],
|
|
225
|
+
args: { onOpenChange: fn() },
|
|
226
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
227
|
+
const trigger = canvas.getByRole('button', { name: 'Used 4 tools' });
|
|
228
|
+
|
|
229
|
+
await step('Tab reaches the trigger, the only tab stop', async () => {
|
|
230
|
+
await userEvent.tab();
|
|
231
|
+
await expect(trigger).toHaveFocus();
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
await step('Enter expands and focus stays on the trigger', async () => {
|
|
235
|
+
await userEvent.keyboard('{Enter}');
|
|
236
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
237
|
+
await expect(canvas.getByText(EXPENSE_STEPS[0])).toBeVisible();
|
|
238
|
+
await expect(trigger).toHaveFocus();
|
|
239
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(true);
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
await step('Space collapses', async () => {
|
|
243
|
+
await userEvent.keyboard(' ');
|
|
244
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
245
|
+
await expect(canvas.queryByText(EXPENSE_STEPS[0])).toBeNull();
|
|
246
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(false);
|
|
247
|
+
});
|
|
248
|
+
},
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
/** While streaming, the collapsed process previews its last step and drops the preview once expanded. */
|
|
252
|
+
export const StreamingPreview: Story = {
|
|
253
|
+
...Streaming,
|
|
254
|
+
tags: ['e2e', '!autodocs'],
|
|
255
|
+
args: { isStreaming: true, onOpenChange: fn() },
|
|
256
|
+
play: async ({ canvas, userEvent, step }) => {
|
|
257
|
+
const trigger = canvas.getByRole('button', { name: 'Thinking…' });
|
|
258
|
+
const [firstStep, lastStep] = EXPENSE_STEPS;
|
|
259
|
+
|
|
260
|
+
await step('Collapsed: only the last step shows, as the preview', async () => {
|
|
261
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
262
|
+
// The preview fades in.
|
|
263
|
+
await waitFor(() => expect(canvas.getByText(lastStep)).toBeVisible());
|
|
264
|
+
await expect(canvas.queryByText(firstStep)).toBeNull();
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
await step('Expanded: the full list replaces the preview', async () => {
|
|
268
|
+
await userEvent.click(trigger);
|
|
269
|
+
await expect(canvas.getByText(firstStep)).toBeVisible();
|
|
270
|
+
const lastStepCopies = canvas.getAllByText(lastStep);
|
|
271
|
+
await expect(lastStepCopies).toHaveLength(2);
|
|
272
|
+
await expect(
|
|
273
|
+
lastStepCopies.filter((copy) => copy.checkVisibility({ opacityProperty: true })),
|
|
274
|
+
).toHaveLength(1);
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
await step('Collapsed again: the preview is back', async () => {
|
|
278
|
+
await userEvent.click(trigger);
|
|
279
|
+
await expect(canvas.queryByText(firstStep)).toBeNull();
|
|
280
|
+
await expect(canvas.getByText(lastStep)).toBeVisible();
|
|
281
|
+
});
|
|
282
|
+
},
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/** With the preview off, a streaming process shows no step until it is expanded. */
|
|
286
|
+
export const WithoutPreviewHidesSteps: Story = {
|
|
287
|
+
...WithoutPreview,
|
|
288
|
+
tags: ['e2e', '!autodocs'],
|
|
289
|
+
args: { isStreaming: true, onOpenChange: fn() },
|
|
290
|
+
play: async ({ canvas, userEvent, step }) => {
|
|
291
|
+
const trigger = canvas.getByRole('button', { name: 'Thinking…' });
|
|
292
|
+
const [firstStep, lastStep] = EXPENSE_STEPS;
|
|
293
|
+
|
|
294
|
+
await step('Collapsed: no step is rendered', async () => {
|
|
295
|
+
await expect(canvas.queryByText(firstStep)).toBeNull();
|
|
296
|
+
await expect(canvas.queryByText(lastStep)).toBeNull();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
await step('Expanded: each step shows once', async () => {
|
|
300
|
+
await userEvent.click(trigger);
|
|
301
|
+
await expect(canvas.getByText(firstStep)).toBeVisible();
|
|
302
|
+
await expect(canvas.getByText(lastStep)).toBeVisible();
|
|
303
|
+
});
|
|
304
|
+
},
|
|
305
|
+
};
|
|
306
|
+
|
|
307
|
+
/** The process in each place it's allowed: in a chat message while thinking, and above the answer in a thread. */
|
|
308
|
+
export const Examples: Story = {
|
|
309
|
+
parameters: { controls: { disable: true } },
|
|
310
|
+
render: () => (
|
|
311
|
+
<div className="flex flex-col gap-24">
|
|
312
|
+
<ParentBlock parent="web-chat-ui/ChatMessage">
|
|
313
|
+
<ChatMessage>
|
|
314
|
+
<ChatThinkingProcess isStreaming>
|
|
315
|
+
<ChatThinkingProcessTrigger>
|
|
316
|
+
<ChatThinkingProcessTriggerIcon>
|
|
317
|
+
<BrainIcon />
|
|
318
|
+
</ChatThinkingProcessTriggerIcon>
|
|
319
|
+
<ChatThinkingProcessTriggerLabel>Thinking…</ChatThinkingProcessTriggerLabel>
|
|
320
|
+
<ChatThinkingProcessTriggerArrow />
|
|
321
|
+
</ChatThinkingProcessTrigger>
|
|
322
|
+
<ChatThinkingProcessContent>
|
|
323
|
+
{EXPENSE_STEPS.slice(0, 2).map((step) => (
|
|
324
|
+
<ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
|
|
325
|
+
))}
|
|
326
|
+
</ChatThinkingProcessContent>
|
|
327
|
+
</ChatThinkingProcess>
|
|
328
|
+
</ChatMessage>
|
|
329
|
+
</ParentBlock>
|
|
330
|
+
|
|
331
|
+
<ParentBlock parent="assistant message in a chat thread">
|
|
332
|
+
<section aria-label="Chat thread" className="flex flex-col gap-16">
|
|
333
|
+
<ChatMessage isQuestion>
|
|
334
|
+
<ChatMessageContent>{AGENT_REQUEST}</ChatMessageContent>
|
|
335
|
+
</ChatMessage>
|
|
336
|
+
<ChatMessage>
|
|
337
|
+
<ChatThinkingProcess>
|
|
338
|
+
<ChatThinkingProcessTrigger>
|
|
339
|
+
<ChatThinkingProcessTriggerIcon>
|
|
340
|
+
<BrainIcon />
|
|
341
|
+
</ChatThinkingProcessTriggerIcon>
|
|
342
|
+
<ChatThinkingProcessTriggerLabel>Reasoned for 12s</ChatThinkingProcessTriggerLabel>
|
|
343
|
+
<ChatThinkingProcessTriggerArrow />
|
|
344
|
+
</ChatThinkingProcessTrigger>
|
|
345
|
+
<ChatThinkingProcessContent>
|
|
346
|
+
<ChatThinkingProcessContentItem>{AGENT_REASONING}</ChatThinkingProcessContentItem>
|
|
347
|
+
</ChatThinkingProcessContent>
|
|
348
|
+
</ChatThinkingProcess>
|
|
349
|
+
<ChatMessageContent>{AGENT_ANSWER}</ChatMessageContent>
|
|
350
|
+
</ChatMessage>
|
|
351
|
+
</section>
|
|
352
|
+
</ParentBlock>
|
|
353
|
+
</div>
|
|
354
|
+
),
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
interface ChatThinkingProcessPlaygroundProps
|
|
358
|
+
extends
|
|
359
|
+
Omit<ChatThinkingProcessProps, 'children'>,
|
|
360
|
+
Pick<
|
|
361
|
+
ChatThinkingProcessContentProps,
|
|
362
|
+
| 'itemsClassName'
|
|
363
|
+
| 'rowClassName'
|
|
364
|
+
| 'markerClassName'
|
|
365
|
+
| 'connectorClassName'
|
|
366
|
+
| 'previewClassName'
|
|
367
|
+
| 'hasLastMessagePreview'
|
|
368
|
+
> {
|
|
369
|
+
label: string;
|
|
370
|
+
icon: ReactNode;
|
|
371
|
+
stepCount: number;
|
|
372
|
+
hasArrow: boolean;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
function ChatThinkingProcessPlayground({
|
|
376
|
+
label,
|
|
377
|
+
icon,
|
|
378
|
+
stepCount,
|
|
379
|
+
itemsClassName,
|
|
380
|
+
rowClassName,
|
|
381
|
+
markerClassName,
|
|
382
|
+
connectorClassName,
|
|
383
|
+
previewClassName,
|
|
384
|
+
defaultOpen,
|
|
385
|
+
hasArrow,
|
|
386
|
+
hasLastMessagePreview,
|
|
387
|
+
...rest
|
|
388
|
+
}: ChatThinkingProcessPlaygroundProps) {
|
|
389
|
+
return (
|
|
390
|
+
// `defaultOpen` is only read on mount, so the key lets its control take effect.
|
|
391
|
+
<ChatThinkingProcess key={String(defaultOpen)} defaultOpen={defaultOpen} {...rest}>
|
|
392
|
+
<ChatThinkingProcessTrigger>
|
|
393
|
+
{icon && <ChatThinkingProcessTriggerIcon>{icon}</ChatThinkingProcessTriggerIcon>}
|
|
394
|
+
<ChatThinkingProcessTriggerLabel>{label}</ChatThinkingProcessTriggerLabel>
|
|
395
|
+
{hasArrow && <ChatThinkingProcessTriggerArrow />}
|
|
396
|
+
</ChatThinkingProcessTrigger>
|
|
397
|
+
|
|
398
|
+
<ChatThinkingProcessContent
|
|
399
|
+
itemsClassName={itemsClassName}
|
|
400
|
+
rowClassName={rowClassName}
|
|
401
|
+
markerClassName={markerClassName}
|
|
402
|
+
connectorClassName={connectorClassName}
|
|
403
|
+
previewClassName={previewClassName}
|
|
404
|
+
hasLastMessagePreview={hasLastMessagePreview}
|
|
405
|
+
>
|
|
406
|
+
{EXPENSE_STEPS.slice(0, stepCount).map((step) => (
|
|
407
|
+
<ChatThinkingProcessContentItem key={step}>{step}</ChatThinkingProcessContentItem>
|
|
408
|
+
))}
|
|
409
|
+
</ChatThinkingProcessContent>
|
|
410
|
+
</ChatThinkingProcess>
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
/** Every part at once, with each part and prop of the root and the content on the Controls panel. */
|
|
415
|
+
export const Playground: StoryObj<typeof ChatThinkingProcessPlayground> = {
|
|
416
|
+
tags: ['!autodocs'],
|
|
417
|
+
args: {
|
|
418
|
+
label: 'Thinking…',
|
|
419
|
+
icon: 'Brain',
|
|
420
|
+
stepCount: EXPENSE_STEPS.length,
|
|
421
|
+
isStreaming: true,
|
|
422
|
+
defaultOpen: false,
|
|
423
|
+
hasArrow: true,
|
|
424
|
+
hasLastMessagePreview: true,
|
|
425
|
+
onOpenChange: fn(),
|
|
426
|
+
},
|
|
427
|
+
argTypes: {
|
|
428
|
+
label: {
|
|
429
|
+
control: 'text',
|
|
430
|
+
description:
|
|
431
|
+
'Text of `ChatThinkingProcessTriggerLabel`. Change it to a summary such as "Used 4 tools" when `isStreaming` goes off.',
|
|
432
|
+
},
|
|
433
|
+
icon: {
|
|
434
|
+
control: 'select',
|
|
435
|
+
options: ['None', 'Brain', 'Search', 'Tool'],
|
|
436
|
+
mapping: {
|
|
437
|
+
None: undefined,
|
|
438
|
+
Brain: <BrainIcon />,
|
|
439
|
+
Search: <SearchIcon />,
|
|
440
|
+
Tool: <ToolIcon />,
|
|
441
|
+
},
|
|
442
|
+
description: 'Icon in `ChatThinkingProcessTriggerIcon`; `None` leaves the part out.',
|
|
443
|
+
},
|
|
444
|
+
stepCount: {
|
|
445
|
+
control: { type: 'number', min: 0, max: EXPENSE_STEPS.length },
|
|
446
|
+
description: 'Number of `ChatThinkingProcessContentItem` steps.',
|
|
447
|
+
},
|
|
448
|
+
hasArrow: { control: 'boolean', description: 'Renders `ChatThinkingProcessTriggerArrow`.' },
|
|
449
|
+
hasLastMessagePreview: {
|
|
450
|
+
control: 'boolean',
|
|
451
|
+
description:
|
|
452
|
+
'`hasLastMessagePreview` on `ChatThinkingProcessContent`: previews the last step while streaming and collapsed.',
|
|
453
|
+
},
|
|
454
|
+
itemsClassName: {
|
|
455
|
+
control: 'text',
|
|
456
|
+
description: '`itemsClassName` on `ChatThinkingProcessContent`: the expanded list of steps.',
|
|
457
|
+
},
|
|
458
|
+
rowClassName: {
|
|
459
|
+
control: 'text',
|
|
460
|
+
description: '`rowClassName` on `ChatThinkingProcessContent`: each timeline row.',
|
|
461
|
+
},
|
|
462
|
+
markerClassName: {
|
|
463
|
+
control: 'text',
|
|
464
|
+
description: '`markerClassName` on `ChatThinkingProcessContent`: the dot of each step.',
|
|
465
|
+
},
|
|
466
|
+
connectorClassName: {
|
|
467
|
+
control: 'text',
|
|
468
|
+
description:
|
|
469
|
+
'`connectorClassName` on `ChatThinkingProcessContent`: the line between two dots.',
|
|
470
|
+
},
|
|
471
|
+
previewClassName: {
|
|
472
|
+
control: 'text',
|
|
473
|
+
description:
|
|
474
|
+
'`previewClassName` on `ChatThinkingProcessContent`: the preview of the last step.',
|
|
475
|
+
},
|
|
476
|
+
},
|
|
477
|
+
render: (args) => <ChatThinkingProcessPlayground {...args} />,
|
|
478
|
+
};
|