@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,70 +1,36 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import {
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { expect, fn, waitFor } from 'storybook/test';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
+
import { Button, Typography } from '@swisper.ai/ui';
|
|
5
6
|
|
|
6
|
-
import {
|
|
7
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
8
|
+
import {
|
|
9
|
+
ChatCard,
|
|
10
|
+
ChatCardBody,
|
|
11
|
+
ChatCardContent,
|
|
12
|
+
ChatCardHeader,
|
|
13
|
+
ChatCardHeaderContent,
|
|
14
|
+
ChatCardTitle,
|
|
15
|
+
} from '../chat-card';
|
|
16
|
+
import { ChatCardContainer, type ChatCardContainerVariant } from '../chat-card-container';
|
|
17
|
+
import { ChatInput, ChatInputTextarea } from '../chat-input';
|
|
7
18
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* inherit, so this shows exactly what a real descendant resolves them to.
|
|
19
|
-
*
|
|
20
|
-
* Polls on rAF rather than subscribing: there is no change event for a custom
|
|
21
|
-
* property, and this only exists to make the contract visible in Storybook.
|
|
22
|
-
*/
|
|
23
|
-
function VariableReadout() {
|
|
24
|
-
const ref = useRef<HTMLDListElement>(null);
|
|
25
|
-
const [values, setValues] = useState<Record<string, string>>({});
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
let frame = requestAnimationFrame(function read() {
|
|
29
|
-
const element = ref.current;
|
|
30
|
-
|
|
31
|
-
if (element) {
|
|
32
|
-
const styles = getComputedStyle(element);
|
|
33
|
-
const next: Record<string, string> = {};
|
|
34
|
-
|
|
35
|
-
for (const name of PUBLISHED_VARIABLES) {
|
|
36
|
-
next[name] = styles.getPropertyValue(name).trim() || '—';
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
setValues((current) =>
|
|
40
|
-
PUBLISHED_VARIABLES.every((name) => current[name] === next[name]) ? current : next,
|
|
41
|
-
);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
frame = requestAnimationFrame(read);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
return () => cancelAnimationFrame(frame);
|
|
48
|
-
}, []);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<dl
|
|
52
|
-
ref={ref}
|
|
53
|
-
className="m-message grid grid-cols-[auto_1fr] gap-x-16 gap-y-1 font-mono text-[12px]"
|
|
54
|
-
>
|
|
55
|
-
{PUBLISHED_VARIABLES.map((name) => (
|
|
56
|
-
<div key={name} className="contents">
|
|
57
|
-
<dt className="text-text-secondary">{name}</dt>
|
|
58
|
-
<dd className="m-0">{values[name] ?? '—'}</dd>
|
|
59
|
-
</div>
|
|
60
|
-
))}
|
|
61
|
-
</dl>
|
|
62
|
-
);
|
|
63
|
-
}
|
|
19
|
+
import { ChatComposer } from './__stories__/chat-composer';
|
|
20
|
+
import { INBOX_EMAILS } from './__stories__/fixtures';
|
|
21
|
+
import { resolveLength } from './__stories__/measure';
|
|
22
|
+
import { VariableReadout } from './__stories__/variable-readout';
|
|
23
|
+
import {
|
|
24
|
+
ChatContainer,
|
|
25
|
+
ChatContainerPrompt,
|
|
26
|
+
ChatContainerWelcome,
|
|
27
|
+
type ChatContainerProps,
|
|
28
|
+
} from './chat-container';
|
|
64
29
|
|
|
65
30
|
const meta: Meta<typeof ChatContainer> = {
|
|
66
|
-
title: '
|
|
31
|
+
title: 'Chat/ChatContainer',
|
|
67
32
|
component: ChatContainer,
|
|
33
|
+
subcomponents: { ChatContainerWelcome, ChatContainerPrompt },
|
|
68
34
|
tags: ['autodocs'],
|
|
69
35
|
parameters: { layout: 'padded' },
|
|
70
36
|
argTypes: {
|
|
@@ -103,77 +69,543 @@ const meta: Meta<typeof ChatContainer> = {
|
|
|
103
69
|
export default meta;
|
|
104
70
|
type Story = StoryObj<typeof ChatContainer>;
|
|
105
71
|
|
|
72
|
+
// The reading column: message text reads the width the container publishes, like the cards do.
|
|
73
|
+
const readingColumnClassName =
|
|
74
|
+
'mx-auto flex w-full max-w-(--message-list-content-width) flex-col gap-16 px-8';
|
|
75
|
+
|
|
76
|
+
const questionClassName = 'max-w-4/5 self-end rounded-sm bg-paper-elevation-1 px-12 py-8';
|
|
77
|
+
|
|
78
|
+
// The composer sits in the reading column too, so it lines up with the messages above it.
|
|
79
|
+
const promptClassName = 'mx-auto w-full max-w-(--message-list-content-width) px-8 pb-16';
|
|
80
|
+
|
|
106
81
|
/**
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
82
|
+
* A chat window with its message list, a result card and the composer. Drag the dashed
|
|
83
|
+
* wrapper's right edge: `--chat-window-width` tracks the measured box, and
|
|
84
|
+
* `--message-list-content-width` stops at 736px in a wide window and follows a narrow one.
|
|
110
85
|
*/
|
|
111
86
|
export const Default: Story = {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
87
|
+
args: { className: 'h-105', 'aria-label': 'Chat' },
|
|
88
|
+
render: (args) => (
|
|
89
|
+
<div className="w-225 max-w-full min-w-80 resize-x overflow-auto border border-dashed border-component-divider">
|
|
90
|
+
<ChatContainer {...args}>
|
|
115
91
|
<VariableReadout />
|
|
116
92
|
|
|
117
|
-
<div
|
|
118
|
-
<
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
</
|
|
93
|
+
<div role="log" aria-label="Messages" className="min-h-0 flex-1 overflow-y-auto py-16">
|
|
94
|
+
<div className={readingColumnClassName}>
|
|
95
|
+
<Typography className={questionClassName}>
|
|
96
|
+
When is the office move, and what do I need to do before it?
|
|
97
|
+
</Typography>
|
|
98
|
+
<Typography className="text-text-secondary">
|
|
99
|
+
The move is on Friday 16 October. Pack your desk by Thursday afternoon; the movers
|
|
100
|
+
arrive at 08:00.
|
|
101
|
+
</Typography>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<ChatCardContainer variant="fixed" className="mt-16">
|
|
105
|
+
<ChatCard fullWidth>
|
|
106
|
+
<ChatCardHeader>
|
|
107
|
+
<ChatCardHeaderContent>
|
|
108
|
+
<ChatCardTitle>Reminder</ChatCardTitle>
|
|
109
|
+
</ChatCardHeaderContent>
|
|
110
|
+
</ChatCardHeader>
|
|
111
|
+
<ChatCardBody>
|
|
112
|
+
<ChatCardContent>Pack up my desk · Thursday 15 October, 15:00</ChatCardContent>
|
|
113
|
+
</ChatCardBody>
|
|
114
|
+
</ChatCard>
|
|
122
115
|
</ChatCardContainer>
|
|
123
116
|
</div>
|
|
117
|
+
|
|
118
|
+
<ChatContainerPrompt className={promptClassName}>
|
|
119
|
+
<ChatComposer />
|
|
120
|
+
</ChatContainerPrompt>
|
|
124
121
|
</ChatContainer>
|
|
125
122
|
</div>
|
|
126
123
|
),
|
|
127
124
|
};
|
|
128
125
|
|
|
129
|
-
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
*
|
|
133
|
-
* Drag the textarea taller and watch `--type-window-height` follow. Toggle the welcome
|
|
134
|
-
* box off and `--welcome-screen-box-height` returns to `unset` rather than leaving a
|
|
135
|
-
* stale height behind for the message list to reserve space for.
|
|
136
|
-
*/
|
|
137
|
-
export const MeasuredSlots: Story = {
|
|
138
|
-
render: function MeasuredSlotsStory() {
|
|
139
|
-
const [hasWelcome, setHasWelcome] = useState(true);
|
|
126
|
+
/** Sets the dashed wrapper to a width the viewport can't cap, so the test runs the same at any size. */
|
|
127
|
+
function resizeChatWindow(region: HTMLElement, width: number) {
|
|
128
|
+
const wrapper = region.parentElement;
|
|
140
129
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
if (wrapper) {
|
|
131
|
+
wrapper.style.maxWidth = 'none';
|
|
132
|
+
wrapper.style.width = `${width}px`;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
145
135
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
136
|
+
/** The window variables follow the measured box, and the reading column is clamped to the window. */
|
|
137
|
+
export const DefaultTracksWindow: Story = {
|
|
138
|
+
...Default,
|
|
139
|
+
tags: ['e2e', '!autodocs'],
|
|
140
|
+
play: async ({ canvas, step }) => {
|
|
141
|
+
const region = canvas.getByRole('region', { name: 'Chat' });
|
|
142
|
+
const chatArea = resolveLength(region, 'var(--spacing-chat-area)');
|
|
143
|
+
|
|
144
|
+
await step('Carries its slot name', async () => {
|
|
145
|
+
await expect(region).toHaveAttribute('data-slot', 'chat-container');
|
|
146
|
+
});
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
await step('A wide window publishes its size and stops the column at the token', async () => {
|
|
149
|
+
resizeChatWindow(region, 900);
|
|
150
|
+
await waitFor(() =>
|
|
151
|
+
expect(region.style.getPropertyValue('--chat-window-width')).toBe(
|
|
152
|
+
`${region.offsetWidth}px`,
|
|
153
|
+
),
|
|
154
|
+
);
|
|
155
|
+
await expect(region.offsetWidth).toBeGreaterThan(chatArea);
|
|
156
|
+
await expect(region.style.getPropertyValue('--chat-window-height')).toBe(
|
|
157
|
+
`${region.offsetHeight}px`,
|
|
158
|
+
);
|
|
159
|
+
await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(chatArea);
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
await step('A window narrower than the column pulls the column in with it', async () => {
|
|
163
|
+
resizeChatWindow(region, 400);
|
|
164
|
+
await waitFor(() =>
|
|
165
|
+
expect(region.style.getPropertyValue('--chat-window-width')).toBe(
|
|
166
|
+
`${region.offsetWidth}px`,
|
|
167
|
+
),
|
|
168
|
+
);
|
|
169
|
+
await expect(region.offsetWidth).toBeLessThan(chatArea);
|
|
170
|
+
await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(
|
|
171
|
+
region.offsetWidth,
|
|
172
|
+
);
|
|
173
|
+
});
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/** `contentWidth` sets the reading column, and the window width still caps it. */
|
|
178
|
+
export const DefaultContentWidth: Story = {
|
|
179
|
+
...Default,
|
|
180
|
+
tags: ['e2e', '!autodocs'],
|
|
181
|
+
args: { ...Default.args, contentWidth: '30rem' },
|
|
182
|
+
play: async ({ canvas, step }) => {
|
|
183
|
+
const region = canvas.getByRole('region', { name: 'Chat' });
|
|
184
|
+
const contentWidth = resolveLength(region, '30rem');
|
|
185
|
+
|
|
186
|
+
// `resolveLength` adds a probe to the DOM, which would re-trigger `waitFor`; wait on the
|
|
187
|
+
// published width first, then resolve the column once.
|
|
188
|
+
await step('A wide window gives the column its own width', async () => {
|
|
189
|
+
resizeChatWindow(region, 900);
|
|
190
|
+
await waitFor(() =>
|
|
191
|
+
expect(region.style.getPropertyValue('--chat-window-width')).toBe(
|
|
192
|
+
`${region.offsetWidth}px`,
|
|
193
|
+
),
|
|
194
|
+
);
|
|
195
|
+
await expect(region.offsetWidth).toBeGreaterThan(contentWidth);
|
|
196
|
+
await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(contentWidth);
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
await step('A narrower window caps it', async () => {
|
|
200
|
+
resizeChatWindow(region, 400);
|
|
201
|
+
await waitFor(() =>
|
|
202
|
+
expect(region.style.getPropertyValue('--chat-window-width')).toBe(
|
|
203
|
+
`${region.offsetWidth}px`,
|
|
204
|
+
),
|
|
205
|
+
);
|
|
206
|
+
await expect(region.offsetWidth).toBeLessThan(contentWidth);
|
|
207
|
+
await expect(resolveLength(region, 'var(--message-list-content-width)')).toBe(
|
|
208
|
+
region.offsetWidth,
|
|
209
|
+
);
|
|
210
|
+
});
|
|
211
|
+
},
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
interface NewChatProps {
|
|
215
|
+
greeting: string;
|
|
216
|
+
onSend: (message: string) => void;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function NewChat({ greeting, onSend }: NewChatProps) {
|
|
220
|
+
const [questions, setQuestions] = useState<string[]>([]);
|
|
221
|
+
// The welcome box only exists on an empty chat: the first message unmounts it.
|
|
222
|
+
const isEmpty = questions.length === 0;
|
|
223
|
+
|
|
224
|
+
const handleSend = (message: string) => {
|
|
225
|
+
setQuestions((current) => [...current, message]);
|
|
226
|
+
onSend(message);
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
return (
|
|
230
|
+
<div className="flex w-225 max-w-full flex-col gap-8">
|
|
231
|
+
<Button
|
|
232
|
+
variant="tertiary"
|
|
233
|
+
size="sm"
|
|
234
|
+
className="self-start"
|
|
235
|
+
isDisabled={isEmpty}
|
|
236
|
+
onClick={() => setQuestions([])}
|
|
237
|
+
>
|
|
238
|
+
New chat
|
|
239
|
+
</Button>
|
|
240
|
+
|
|
241
|
+
<div className="border border-dashed border-component-divider">
|
|
242
|
+
<ChatContainer aria-label="Chat" className="h-130">
|
|
243
|
+
<VariableReadout />
|
|
244
|
+
|
|
245
|
+
{isEmpty ? (
|
|
246
|
+
<ChatContainerWelcome className="px-message py-16">
|
|
247
|
+
<Typography variant="title-small" className="text-text-secondary">
|
|
248
|
+
{greeting}
|
|
249
|
+
</Typography>
|
|
157
250
|
</ChatContainerWelcome>
|
|
158
251
|
) : null}
|
|
159
252
|
|
|
160
|
-
{/*
|
|
253
|
+
{/* A sibling of the composer, sized from the height the prompt slot publishes. */}
|
|
161
254
|
<div
|
|
162
|
-
|
|
163
|
-
|
|
255
|
+
role="log"
|
|
256
|
+
aria-label="Messages"
|
|
257
|
+
className="min-h-0 flex-1 overflow-y-auto pt-16 pb-(--type-window-height)"
|
|
164
258
|
>
|
|
165
|
-
|
|
259
|
+
<div className={readingColumnClassName}>
|
|
260
|
+
{questions.map((question, index) => (
|
|
261
|
+
// Messages are only ever appended, so the position keeps the key stable.
|
|
262
|
+
<Typography key={`${index}-${question}`} className={questionClassName}>
|
|
263
|
+
{question}
|
|
264
|
+
</Typography>
|
|
265
|
+
))}
|
|
266
|
+
</div>
|
|
166
267
|
</div>
|
|
167
268
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
defaultValue="Drag my bottom edge to grow the composer."
|
|
172
|
-
rows={2}
|
|
173
|
-
/>
|
|
269
|
+
{/* Floats over the list, so the list has to reserve its height. */}
|
|
270
|
+
<ChatContainerPrompt className={`absolute inset-x-0 bottom-0 ${promptClassName}`}>
|
|
271
|
+
<ChatComposer onSend={handleSend} />
|
|
174
272
|
</ChatContainerPrompt>
|
|
175
273
|
</ChatContainer>
|
|
176
274
|
</div>
|
|
275
|
+
</div>
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
type NewChatStory = StoryObj<typeof NewChat>;
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The slot round-trip on a new chat: the welcome box and the composer measure themselves and
|
|
283
|
+
* their heights land on the container, where the message list reads them. Type a few lines and
|
|
284
|
+
* `--type-window-height` follows the composer; send the message and the welcome box unmounts,
|
|
285
|
+
* returning `--welcome-screen-box-height` to `unset`.
|
|
286
|
+
*/
|
|
287
|
+
export const MeasuredSlots: NewChatStory = {
|
|
288
|
+
args: {
|
|
289
|
+
greeting: 'Good morning, Mara. What should we get done today?',
|
|
290
|
+
onSend: fn(),
|
|
291
|
+
},
|
|
292
|
+
argTypes: {
|
|
293
|
+
greeting: { control: 'text', description: 'Text of the box in `ChatContainerWelcome`.' },
|
|
294
|
+
onSend: { description: 'Called with each message the composer sends.' },
|
|
295
|
+
},
|
|
296
|
+
parameters: { controls: { include: ['greeting', 'onSend'] } },
|
|
297
|
+
render: (args) => <NewChat {...args} />,
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
/** Grows the composer and sends the first message, checking both slot heights on the container. */
|
|
301
|
+
export const MeasuredSlotsRoundTrip: NewChatStory = {
|
|
302
|
+
...MeasuredSlots,
|
|
303
|
+
tags: ['e2e', '!autodocs'],
|
|
304
|
+
args: { ...MeasuredSlots.args, onSend: fn() },
|
|
305
|
+
play: async ({ args, canvas, canvasElement, userEvent, step }) => {
|
|
306
|
+
const region = canvas.getByRole('region', { name: 'Chat' });
|
|
307
|
+
const textbox = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
308
|
+
// The slots are layout wrappers with no role to query by; `data-slot` is their documented name.
|
|
309
|
+
const prompt = canvasElement.querySelector<HTMLElement>('[data-slot="chat-container-prompt"]');
|
|
310
|
+
const promptHeight = () => `${prompt?.offsetHeight ?? 0}px`;
|
|
311
|
+
const slotVariable = (name: string) => region.style.getPropertyValue(name);
|
|
312
|
+
|
|
313
|
+
await step('Both slots report their height to the container', async () => {
|
|
314
|
+
const welcome = canvasElement.querySelector<HTMLElement>(
|
|
315
|
+
'[data-slot="chat-container-welcome"]',
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
await expect(prompt).toBeInTheDocument();
|
|
319
|
+
await expect(welcome).toBeInTheDocument();
|
|
320
|
+
await waitFor(() => expect(slotVariable('--type-window-height')).toBe(promptHeight()));
|
|
321
|
+
await expect(slotVariable('--welcome-screen-box-height')).toBe(
|
|
322
|
+
`${welcome?.offsetHeight ?? 0}px`,
|
|
323
|
+
);
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
const oneLineHeight = prompt?.offsetHeight ?? 0;
|
|
327
|
+
|
|
328
|
+
await step('The composer height follows the text', async () => {
|
|
329
|
+
await userEvent.click(textbox);
|
|
330
|
+
await userEvent.keyboard('Move my 3pm to Friday');
|
|
331
|
+
await userEvent.keyboard('{Shift>}{Enter}{/Shift}and tell the facilities team');
|
|
332
|
+
await userEvent.keyboard('{Shift>}{Enter}{/Shift}before the movers arrive');
|
|
333
|
+
await waitFor(() => expect(prompt?.offsetHeight).toBeGreaterThan(oneLineHeight));
|
|
334
|
+
await waitFor(() => expect(slotVariable('--type-window-height')).toBe(promptHeight()));
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
await step('The message list reserves the composer height', async () => {
|
|
338
|
+
const list = canvas.getByRole('log', { name: 'Messages' });
|
|
339
|
+
|
|
340
|
+
await waitFor(() => expect(getComputedStyle(list).paddingBottom).toBe(promptHeight()));
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
await step(
|
|
344
|
+
'Sending the first message unmounts the welcome box and clears its height',
|
|
345
|
+
async () => {
|
|
346
|
+
await userEvent.keyboard('{Enter}');
|
|
347
|
+
await expect(args.onSend).toHaveBeenCalledTimes(1);
|
|
348
|
+
await waitFor(() =>
|
|
349
|
+
expect(canvasElement.querySelector('[data-slot="chat-container-welcome"]')).toBeNull(),
|
|
350
|
+
);
|
|
351
|
+
await waitFor(() => expect(slotVariable('--welcome-screen-box-height')).toBe('unset'));
|
|
352
|
+
await waitFor(() => expect(prompt?.offsetHeight).toBe(oneLineHeight));
|
|
353
|
+
await waitFor(() => expect(slotVariable('--type-window-height')).toBe(promptHeight()));
|
|
354
|
+
},
|
|
177
355
|
);
|
|
356
|
+
|
|
357
|
+
await step('A new chat mounts the welcome box and its height again', async () => {
|
|
358
|
+
await userEvent.click(canvas.getByRole('button', { name: 'New chat' }));
|
|
359
|
+
await expect(canvas.getByText(args.greeting)).toBeVisible();
|
|
360
|
+
await waitFor(() => expect(slotVariable('--welcome-screen-box-height')).toMatch(/^\d+px$/));
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
};
|
|
364
|
+
|
|
365
|
+
/** The container in each place it goes: a chat page, the chat side of a split pane and a full-screen chat. */
|
|
366
|
+
export const Examples: Story = {
|
|
367
|
+
parameters: { controls: { disable: true } },
|
|
368
|
+
render: () => (
|
|
369
|
+
<div className="flex flex-col gap-24">
|
|
370
|
+
<ParentBlock parent="chat page">
|
|
371
|
+
<div
|
|
372
|
+
role="group"
|
|
373
|
+
aria-label="Chat page"
|
|
374
|
+
className="flex h-80 flex-col rounded-sm border border-component-divider"
|
|
375
|
+
>
|
|
376
|
+
<header className="shrink-0 border-b border-component-divider px-16 py-8">
|
|
377
|
+
<Typography variant="body-small-high" fontWeight="medium">
|
|
378
|
+
Office move
|
|
379
|
+
</Typography>
|
|
380
|
+
</header>
|
|
381
|
+
<div className="min-h-0 flex-1">
|
|
382
|
+
<ChatContainer aria-label="Office move chat">
|
|
383
|
+
<div
|
|
384
|
+
role="log"
|
|
385
|
+
aria-label="Office move messages"
|
|
386
|
+
className="min-h-0 flex-1 overflow-y-auto py-16"
|
|
387
|
+
>
|
|
388
|
+
<div className={readingColumnClassName}>
|
|
389
|
+
<Typography className={questionClassName}>Move my 3pm to Friday</Typography>
|
|
390
|
+
<Typography className="text-text-secondary">
|
|
391
|
+
Your 3pm with the facilities team is now on Friday at 10:00. Everyone has been
|
|
392
|
+
notified.
|
|
393
|
+
</Typography>
|
|
394
|
+
</div>
|
|
395
|
+
</div>
|
|
396
|
+
<ChatContainerPrompt className={promptClassName}>
|
|
397
|
+
<ChatComposer />
|
|
398
|
+
</ChatContainerPrompt>
|
|
399
|
+
</ChatContainer>
|
|
400
|
+
</div>
|
|
401
|
+
</div>
|
|
402
|
+
</ParentBlock>
|
|
403
|
+
|
|
404
|
+
<ParentBlock parent="split pane">
|
|
405
|
+
<div
|
|
406
|
+
role="group"
|
|
407
|
+
aria-label="Productivity dashboard"
|
|
408
|
+
className="flex h-80 gap-16 rounded-sm border border-component-divider p-16"
|
|
409
|
+
>
|
|
410
|
+
<aside
|
|
411
|
+
aria-label="Inbox"
|
|
412
|
+
className="flex w-60 shrink-0 flex-col gap-8 rounded-sm border border-component-divider p-12"
|
|
413
|
+
>
|
|
414
|
+
<Typography
|
|
415
|
+
variant="body-small-high"
|
|
416
|
+
fontWeight="semibold"
|
|
417
|
+
className="text-text-secondary"
|
|
418
|
+
>
|
|
419
|
+
Productivity dashboard
|
|
420
|
+
</Typography>
|
|
421
|
+
<ul className="flex flex-col gap-8">
|
|
422
|
+
{INBOX_EMAILS.map((email) => (
|
|
423
|
+
<li key={email.id} className="flex min-w-0 flex-col">
|
|
424
|
+
<span className="flex items-baseline justify-between gap-8">
|
|
425
|
+
<Typography variant="caption-md" className="truncate">
|
|
426
|
+
{email.sender}
|
|
427
|
+
</Typography>
|
|
428
|
+
<Typography variant="caption-md" className="shrink-0 text-text-tertiary">
|
|
429
|
+
{email.receivedAt}
|
|
430
|
+
</Typography>
|
|
431
|
+
</span>
|
|
432
|
+
<Typography variant="caption-md" className="truncate text-text-secondary">
|
|
433
|
+
{email.subject}
|
|
434
|
+
</Typography>
|
|
435
|
+
</li>
|
|
436
|
+
))}
|
|
437
|
+
</ul>
|
|
438
|
+
</aside>
|
|
439
|
+
|
|
440
|
+
{/* The pane is narrower than the reading column, so the column follows the pane. */}
|
|
441
|
+
<div className="min-w-0 flex-1 overflow-hidden">
|
|
442
|
+
<ChatContainer aria-label="Chat about the selected email">
|
|
443
|
+
<div
|
|
444
|
+
role="log"
|
|
445
|
+
aria-label="Email chat messages"
|
|
446
|
+
className="min-h-0 flex-1 overflow-y-auto pb-16"
|
|
447
|
+
>
|
|
448
|
+
<div className={readingColumnClassName}>
|
|
449
|
+
<Typography className="text-text-secondary">
|
|
450
|
+
The facilities team confirms the office move for Friday 16 October and asks you
|
|
451
|
+
to pack your desk by Thursday afternoon.
|
|
452
|
+
</Typography>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
455
|
+
<ChatContainerPrompt className={promptClassName}>
|
|
456
|
+
<ChatComposer placeholder="Reply or ask about this email" />
|
|
457
|
+
</ChatContainerPrompt>
|
|
458
|
+
</ChatContainer>
|
|
459
|
+
</div>
|
|
460
|
+
</div>
|
|
461
|
+
</ParentBlock>
|
|
462
|
+
|
|
463
|
+
<ParentBlock parent="full-screen chat">
|
|
464
|
+
<div className="h-80 rounded-sm border border-component-divider">
|
|
465
|
+
{/* With asChild the page's own landmark is the container, so nothing wraps the chat. */}
|
|
466
|
+
<ChatContainer asChild>
|
|
467
|
+
<main aria-label="New chat">
|
|
468
|
+
<ChatContainerWelcome className="flex flex-1 items-center justify-center px-message">
|
|
469
|
+
<Typography variant="title-small" className="text-text-secondary">
|
|
470
|
+
Good morning, Mara. What should we get done today?
|
|
471
|
+
</Typography>
|
|
472
|
+
</ChatContainerWelcome>
|
|
473
|
+
<ChatContainerPrompt className={promptClassName}>
|
|
474
|
+
<ChatComposer />
|
|
475
|
+
</ChatContainerPrompt>
|
|
476
|
+
</main>
|
|
477
|
+
</ChatContainer>
|
|
478
|
+
</div>
|
|
479
|
+
</ParentBlock>
|
|
480
|
+
</div>
|
|
481
|
+
),
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
// ChatInput ships unstyled; this is the bordered field a consumer makes of it.
|
|
485
|
+
const chatInputClassName =
|
|
486
|
+
'max-h-30 min-h-40 w-full overflow-y-auto rounded-md border border-form-fields-border bg-paper-elevation-1 px-12 py-6 data-[focused=true]:border-primary-main';
|
|
487
|
+
|
|
488
|
+
interface ChatContainerPlaygroundProps extends Omit<ChatContainerProps, 'children'> {
|
|
489
|
+
hasWelcome: boolean;
|
|
490
|
+
greeting: string;
|
|
491
|
+
hasCard: boolean;
|
|
492
|
+
variant: ChatCardContainerVariant;
|
|
493
|
+
hasPrompt: boolean;
|
|
494
|
+
composer: 'ChatPromptBox' | 'ChatInput';
|
|
495
|
+
onSend: (message: string) => void;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function ChatContainerPlayground({
|
|
499
|
+
asChild,
|
|
500
|
+
hasWelcome,
|
|
501
|
+
greeting,
|
|
502
|
+
hasCard,
|
|
503
|
+
variant,
|
|
504
|
+
hasPrompt,
|
|
505
|
+
composer,
|
|
506
|
+
onSend,
|
|
507
|
+
...rest
|
|
508
|
+
}: ChatContainerPlaygroundProps) {
|
|
509
|
+
const content = (
|
|
510
|
+
<>
|
|
511
|
+
<VariableReadout />
|
|
512
|
+
|
|
513
|
+
{hasWelcome && (
|
|
514
|
+
<ChatContainerWelcome className="px-message pb-16">
|
|
515
|
+
<Typography variant="title-small" className="text-text-secondary">
|
|
516
|
+
{greeting}
|
|
517
|
+
</Typography>
|
|
518
|
+
</ChatContainerWelcome>
|
|
519
|
+
)}
|
|
520
|
+
|
|
521
|
+
<div role="log" aria-label="Messages" className="min-h-0 flex-1 overflow-y-auto pb-16">
|
|
522
|
+
<div className={readingColumnClassName}>
|
|
523
|
+
<Typography className={questionClassName}>
|
|
524
|
+
When is the office move, and what do I need to do before it?
|
|
525
|
+
</Typography>
|
|
526
|
+
<Typography className="text-text-secondary">
|
|
527
|
+
The move is on Friday 16 October. Pack your desk by Thursday afternoon; the movers
|
|
528
|
+
arrive at 08:00.
|
|
529
|
+
</Typography>
|
|
530
|
+
</div>
|
|
531
|
+
|
|
532
|
+
{hasCard && (
|
|
533
|
+
<ChatCardContainer variant={variant} className="mt-16">
|
|
534
|
+
<ChatCard fullWidth>
|
|
535
|
+
<ChatCardHeader>
|
|
536
|
+
<ChatCardHeaderContent>
|
|
537
|
+
<ChatCardTitle>Reminder</ChatCardTitle>
|
|
538
|
+
</ChatCardHeaderContent>
|
|
539
|
+
</ChatCardHeader>
|
|
540
|
+
<ChatCardBody>
|
|
541
|
+
<ChatCardContent>Pack up my desk · Thursday 15 October, 15:00</ChatCardContent>
|
|
542
|
+
</ChatCardBody>
|
|
543
|
+
</ChatCard>
|
|
544
|
+
</ChatCardContainer>
|
|
545
|
+
)}
|
|
546
|
+
</div>
|
|
547
|
+
|
|
548
|
+
{hasPrompt && (
|
|
549
|
+
<ChatContainerPrompt className={promptClassName}>
|
|
550
|
+
{composer === 'ChatPromptBox' ? (
|
|
551
|
+
<ChatComposer onSend={onSend} />
|
|
552
|
+
) : (
|
|
553
|
+
<ChatInput className={chatInputClassName}>
|
|
554
|
+
<ChatInputTextarea autoFocus={false} placeholder="How can I help?" />
|
|
555
|
+
</ChatInput>
|
|
556
|
+
)}
|
|
557
|
+
</ChatContainerPrompt>
|
|
558
|
+
)}
|
|
559
|
+
</>
|
|
560
|
+
);
|
|
561
|
+
|
|
562
|
+
return (
|
|
563
|
+
<div className="w-225 max-w-full min-w-80 resize-x overflow-auto border border-dashed border-component-divider">
|
|
564
|
+
<ChatContainer asChild={asChild} {...rest}>
|
|
565
|
+
{asChild ? <main>{content}</main> : content}
|
|
566
|
+
</ChatContainer>
|
|
567
|
+
</div>
|
|
568
|
+
);
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
/** Every slot and child at once in a resizable window, with each prop and part on the Controls panel. */
|
|
572
|
+
export const Playground: StoryObj<typeof ChatContainerPlayground> = {
|
|
573
|
+
tags: ['!autodocs'],
|
|
574
|
+
args: {
|
|
575
|
+
contentWidth: 'var(--spacing-chat-area)',
|
|
576
|
+
className: 'h-140',
|
|
577
|
+
asChild: false,
|
|
578
|
+
hasWelcome: true,
|
|
579
|
+
greeting: 'Good morning, Mara. What should we get done today?',
|
|
580
|
+
hasCard: true,
|
|
581
|
+
variant: 'fixed',
|
|
582
|
+
hasPrompt: true,
|
|
583
|
+
composer: 'ChatPromptBox',
|
|
584
|
+
onSend: fn(),
|
|
585
|
+
},
|
|
586
|
+
argTypes: {
|
|
587
|
+
asChild: {
|
|
588
|
+
control: 'boolean',
|
|
589
|
+
description: 'Renders a `<main>` as the container root instead of the `<section>`.',
|
|
590
|
+
},
|
|
591
|
+
hasWelcome: { control: 'boolean', description: 'Renders `ChatContainerWelcome`.' },
|
|
592
|
+
greeting: { control: 'text', description: 'Text of the box in `ChatContainerWelcome`.' },
|
|
593
|
+
hasCard: {
|
|
594
|
+
control: 'boolean',
|
|
595
|
+
description: 'Renders a card in a `ChatCardContainer` in the message list.',
|
|
596
|
+
},
|
|
597
|
+
variant: {
|
|
598
|
+
control: 'radio',
|
|
599
|
+
options: ['fixed', 'fluid', 'full'],
|
|
600
|
+
description: '`variant` of `ChatCardContainer`: how the card sizes against the window.',
|
|
601
|
+
},
|
|
602
|
+
hasPrompt: { control: 'boolean', description: 'Renders `ChatContainerPrompt`.' },
|
|
603
|
+
composer: {
|
|
604
|
+
control: 'radio',
|
|
605
|
+
options: ['ChatPromptBox', 'ChatInput'],
|
|
606
|
+
description: 'What `ChatContainerPrompt` holds: the styled prompt box or the bare input.',
|
|
607
|
+
},
|
|
608
|
+
onSend: { description: 'Called with each message the prompt box sends.' },
|
|
178
609
|
},
|
|
610
|
+
render: (args) => <ChatContainerPlayground {...args} />,
|
|
179
611
|
};
|