@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,4 +1,4 @@
|
|
|
1
|
-
import type { MouseEvent, ReactNode } from 'react';
|
|
1
|
+
import type { ComponentPropsWithoutRef, MouseEvent, ReactNode } from 'react';
|
|
2
2
|
import { forwardRef, useCallback, useLayoutEffect, useState } from 'react';
|
|
3
3
|
|
|
4
4
|
import { cn, useElementMeasure } from '@swisper.ai/web-core';
|
|
@@ -9,7 +9,10 @@ import type { ChatInputProps, ChatInputTextareaProps } from '../chat-input';
|
|
|
9
9
|
import { ChatPromptBoxContextProvider, useChatPromptBoxContext } from './chat-prompt-box-context';
|
|
10
10
|
import { ChatPromptBoxFocusPlugin } from './chat-prompt-box-focus-plugin';
|
|
11
11
|
|
|
12
|
-
export
|
|
12
|
+
export interface ChatPromptBoxProps extends ChatInputProps {
|
|
13
|
+
/** Classes merged last onto the inner surface, the element that carries the box's background and padding. */
|
|
14
|
+
innerClassName?: string;
|
|
15
|
+
}
|
|
13
16
|
|
|
14
17
|
const COMPACT_INPUT_HEIGHT_THRESHOLD = 40;
|
|
15
18
|
|
|
@@ -23,6 +26,10 @@ function shouldSkipFocus(target: EventTarget | null): boolean {
|
|
|
23
26
|
return Boolean(target.closest(INTERACTIVE_SELECTOR));
|
|
24
27
|
}
|
|
25
28
|
|
|
29
|
+
/**
|
|
30
|
+
* The styled chat composer: a `ChatInput` with the box's border, background and focus glow. Sets
|
|
31
|
+
* `data-compact` on the root, which the parts read to move the actions under the text.
|
|
32
|
+
*/
|
|
26
33
|
export const ChatPromptBox = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
27
34
|
function ChatPromptBox(props, ref) {
|
|
28
35
|
const [isCompact, setIsCompact] = useState(true);
|
|
@@ -51,7 +58,10 @@ export const ChatPromptBox = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
|
51
58
|
ChatPromptBox.displayName = 'ChatPromptBox';
|
|
52
59
|
|
|
53
60
|
const ChatPromptBoxContainer = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
54
|
-
function ChatPromptBoxContainer(
|
|
61
|
+
function ChatPromptBoxContainer(
|
|
62
|
+
{ className, innerClassName, children, onMouseDown, ...rest },
|
|
63
|
+
ref,
|
|
64
|
+
) {
|
|
55
65
|
const { focusInput } = useChatPromptBoxContext();
|
|
56
66
|
|
|
57
67
|
const handleMouseDown = useCallback(
|
|
@@ -68,6 +78,7 @@ const ChatPromptBoxContainer = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
|
68
78
|
return (
|
|
69
79
|
<ChatInput
|
|
70
80
|
ref={ref}
|
|
81
|
+
data-slot="chat-prompt-box"
|
|
71
82
|
className={cn(
|
|
72
83
|
'group/chat-prompt-box',
|
|
73
84
|
'relative overflow-hidden',
|
|
@@ -84,6 +95,7 @@ const ChatPromptBoxContainer = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
|
84
95
|
{...rest}
|
|
85
96
|
>
|
|
86
97
|
<div
|
|
98
|
+
data-slot="chat-prompt-box-inner"
|
|
87
99
|
className={cn(
|
|
88
100
|
'rounded-[15px]',
|
|
89
101
|
'p-[4px]',
|
|
@@ -95,6 +107,7 @@ const ChatPromptBoxContainer = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
|
95
107
|
'group-data-[focused=true]/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]',
|
|
96
108
|
// focused & hover bg
|
|
97
109
|
'group-data-[focused=true]/chat-prompt-box:group-hover/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]',
|
|
110
|
+
innerClassName,
|
|
98
111
|
)}
|
|
99
112
|
>
|
|
100
113
|
{children}
|
|
@@ -106,10 +119,13 @@ const ChatPromptBoxContainer = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
|
106
119
|
},
|
|
107
120
|
);
|
|
108
121
|
|
|
122
|
+
ChatPromptBoxContainer.displayName = 'ChatPromptBoxContainer';
|
|
123
|
+
|
|
109
124
|
function ChatPromptBoxFocusRadials() {
|
|
110
125
|
return (
|
|
111
126
|
<>
|
|
112
127
|
<div
|
|
128
|
+
data-slot="chat-prompt-box-glow-top"
|
|
113
129
|
className={cn(
|
|
114
130
|
'absolute left-1/2 top-[-40px]',
|
|
115
131
|
'translate-x-[-50%]',
|
|
@@ -125,6 +141,7 @@ function ChatPromptBoxFocusRadials() {
|
|
|
125
141
|
/>
|
|
126
142
|
|
|
127
143
|
<div
|
|
144
|
+
data-slot="chat-prompt-box-glow-bottom"
|
|
128
145
|
className={cn(
|
|
129
146
|
'absolute left-1/2 -bottom-22',
|
|
130
147
|
'translate-x-[-50%]',
|
|
@@ -142,27 +159,33 @@ function ChatPromptBoxFocusRadials() {
|
|
|
142
159
|
);
|
|
143
160
|
}
|
|
144
161
|
|
|
145
|
-
export interface ChatPromptBoxToolbarProps {
|
|
162
|
+
export interface ChatPromptBoxToolbarProps extends ComponentPropsWithoutRef<'div'> {
|
|
146
163
|
children: ReactNode;
|
|
147
|
-
className?: string;
|
|
148
164
|
}
|
|
149
165
|
|
|
150
|
-
|
|
166
|
+
/** A row above the content for what the message carries, such as the attached files. */
|
|
167
|
+
export function ChatPromptBoxToolbar({ className, children, ...rest }: ChatPromptBoxToolbarProps) {
|
|
151
168
|
return (
|
|
152
|
-
<div
|
|
169
|
+
<div
|
|
170
|
+
data-slot="chat-prompt-box-toolbar"
|
|
171
|
+
data-testid="chat-prompt-box-toolbar"
|
|
172
|
+
className={cn(className)}
|
|
173
|
+
{...rest}
|
|
174
|
+
>
|
|
153
175
|
{children}
|
|
154
176
|
</div>
|
|
155
177
|
);
|
|
156
178
|
}
|
|
157
179
|
|
|
158
|
-
export interface ChatPromptBoxContentProps {
|
|
180
|
+
export interface ChatPromptBoxContentProps extends ComponentPropsWithoutRef<'div'> {
|
|
159
181
|
children: ReactNode;
|
|
160
|
-
className?: string;
|
|
161
182
|
}
|
|
162
183
|
|
|
163
|
-
|
|
184
|
+
/** The row holding the input and both action groups. Reserves room under the text once the box expands. */
|
|
185
|
+
export function ChatPromptBoxContent({ className, children, ...rest }: ChatPromptBoxContentProps) {
|
|
164
186
|
return (
|
|
165
187
|
<div
|
|
188
|
+
data-slot="chat-prompt-box-content"
|
|
166
189
|
data-testid="chat-prompt-box-content"
|
|
167
190
|
className={cn(
|
|
168
191
|
'relative',
|
|
@@ -171,16 +194,27 @@ export function ChatPromptBoxContent({ children, className }: ChatPromptBoxConte
|
|
|
171
194
|
'group-data-[compact=false]/chat-prompt-box:pb-[calc(8px+4px+40px)]',
|
|
172
195
|
className,
|
|
173
196
|
)}
|
|
197
|
+
{...rest}
|
|
174
198
|
>
|
|
175
199
|
{children}
|
|
176
200
|
</div>
|
|
177
201
|
);
|
|
178
202
|
}
|
|
179
203
|
|
|
180
|
-
export
|
|
204
|
+
export interface ChatPromptBoxInputProps extends ChatInputTextareaProps {
|
|
205
|
+
/** Classes merged last onto the editable element, after its 72px max height. `className` goes to the wrapper around it. */
|
|
206
|
+
textareaClassName?: string;
|
|
207
|
+
}
|
|
181
208
|
|
|
209
|
+
/**
|
|
210
|
+
* The box's text input: a `ChatInputTextarea` that reports its height to the box and registers
|
|
211
|
+
* click-to-focus. `children` are rendered inside the editor, for extra Lexical plugins.
|
|
212
|
+
*/
|
|
182
213
|
export const ChatPromptBoxInput = forwardRef<HTMLDivElement, ChatPromptBoxInputProps>(
|
|
183
|
-
function ChatPromptBoxInput(
|
|
214
|
+
function ChatPromptBoxInput(
|
|
215
|
+
{ className, textareaClassName, placeholderClassName, children, ...rest },
|
|
216
|
+
ref,
|
|
217
|
+
) {
|
|
184
218
|
const { reportInputHeight, resetCompact } = useChatPromptBoxContext();
|
|
185
219
|
const { hasValue } = useChatInputContext();
|
|
186
220
|
const { ref: measureRef, height } = useElementMeasure<HTMLDivElement>();
|
|
@@ -218,6 +252,7 @@ export const ChatPromptBoxInput = forwardRef<HTMLDivElement, ChatPromptBoxInputP
|
|
|
218
252
|
|
|
219
253
|
return (
|
|
220
254
|
<div
|
|
255
|
+
data-slot="chat-prompt-box-input"
|
|
221
256
|
data-testid="chat-prompt-box-input"
|
|
222
257
|
className={cn(
|
|
223
258
|
'min-h-[40px]',
|
|
@@ -231,11 +266,12 @@ export const ChatPromptBoxInput = forwardRef<HTMLDivElement, ChatPromptBoxInputP
|
|
|
231
266
|
>
|
|
232
267
|
<ChatInputTextarea
|
|
233
268
|
ref={setRef}
|
|
234
|
-
className=
|
|
269
|
+
className={cn('max-h-[72px]!', textareaClassName)}
|
|
235
270
|
placeholderClassName={cn('leading-[24px]!', placeholderClassName)}
|
|
236
271
|
{...rest}
|
|
237
272
|
>
|
|
238
273
|
<ChatPromptBoxFocusPlugin />
|
|
274
|
+
{children}
|
|
239
275
|
</ChatInputTextarea>
|
|
240
276
|
</div>
|
|
241
277
|
);
|
|
@@ -244,14 +280,22 @@ export const ChatPromptBoxInput = forwardRef<HTMLDivElement, ChatPromptBoxInputP
|
|
|
244
280
|
|
|
245
281
|
ChatPromptBoxInput.displayName = 'ChatPromptBoxInput';
|
|
246
282
|
|
|
247
|
-
export interface ChatPromptBoxActionsLeftProps {
|
|
283
|
+
export interface ChatPromptBoxActionsLeftProps extends ComponentPropsWithoutRef<'div'> {
|
|
248
284
|
children: ReactNode;
|
|
249
|
-
className?: string;
|
|
250
285
|
}
|
|
251
286
|
|
|
252
|
-
|
|
287
|
+
/**
|
|
288
|
+
* The `role="group"` of secondary actions before the text, e.g. attach. Moves to the bottom-left
|
|
289
|
+
* when the box expands. Name it with `aria-label`.
|
|
290
|
+
*/
|
|
291
|
+
export function ChatPromptBoxActionsLeft({
|
|
292
|
+
className,
|
|
293
|
+
children,
|
|
294
|
+
...rest
|
|
295
|
+
}: ChatPromptBoxActionsLeftProps) {
|
|
253
296
|
return (
|
|
254
297
|
<div
|
|
298
|
+
data-slot="chat-prompt-box-actions-left"
|
|
255
299
|
data-testid="chat-prompt-box-actions-left"
|
|
256
300
|
role="group"
|
|
257
301
|
className={cn(
|
|
@@ -263,20 +307,29 @@ export function ChatPromptBoxActionsLeft({ children, className }: ChatPromptBoxA
|
|
|
263
307
|
'[grid-area:left]',
|
|
264
308
|
className,
|
|
265
309
|
)}
|
|
310
|
+
{...rest}
|
|
266
311
|
>
|
|
267
312
|
{children}
|
|
268
313
|
</div>
|
|
269
314
|
);
|
|
270
315
|
}
|
|
271
316
|
|
|
272
|
-
export interface ChatPromptBoxActionsRightProps {
|
|
317
|
+
export interface ChatPromptBoxActionsRightProps extends ComponentPropsWithoutRef<'div'> {
|
|
273
318
|
children: ReactNode;
|
|
274
|
-
className?: string;
|
|
275
319
|
}
|
|
276
320
|
|
|
277
|
-
|
|
321
|
+
/**
|
|
322
|
+
* The `role="group"` of actions after the text, ending in send. Moves to the bottom-right when the
|
|
323
|
+
* box expands. Name it with `aria-label`.
|
|
324
|
+
*/
|
|
325
|
+
export function ChatPromptBoxActionsRight({
|
|
326
|
+
className,
|
|
327
|
+
children,
|
|
328
|
+
...rest
|
|
329
|
+
}: ChatPromptBoxActionsRightProps) {
|
|
278
330
|
return (
|
|
279
331
|
<div
|
|
332
|
+
data-slot="chat-prompt-box-actions-right"
|
|
280
333
|
data-testid="chat-prompt-box-actions-right"
|
|
281
334
|
role="group"
|
|
282
335
|
className={cn(
|
|
@@ -289,6 +342,7 @@ export function ChatPromptBoxActionsRight({ children, className }: ChatPromptBox
|
|
|
289
342
|
'[grid-area:right]',
|
|
290
343
|
className,
|
|
291
344
|
)}
|
|
345
|
+
{...rest}
|
|
292
346
|
>
|
|
293
347
|
{children}
|
|
294
348
|
</div>
|
|
@@ -2,6 +2,16 @@
|
|
|
2
2
|
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
3
|
"component": "chat-reply",
|
|
4
4
|
"purpose": "List of label/value rows that summarise the fields of a drafted reply or message, such as its subject and recipients, with a chip label per row.",
|
|
5
|
+
"anatomy": [
|
|
6
|
+
"import { ChatReplies, ChatReply, ChatReplyLabel, ChatReplyValue } from '@swisper.ai/web-chat-ui';",
|
|
7
|
+
"",
|
|
8
|
+
"<ChatReplies>",
|
|
9
|
+
" <ChatReply>",
|
|
10
|
+
" <ChatReplyLabel />",
|
|
11
|
+
" <ChatReplyValue />",
|
|
12
|
+
" </ChatReply>",
|
|
13
|
+
"</ChatReplies>"
|
|
14
|
+
],
|
|
5
15
|
"useWhen": [
|
|
6
16
|
"Showing the fields of something the assistant drafted for the user, like an e-mail's subject and recipients, before it is sent",
|
|
7
17
|
"A value is a set of chips (recipients) that should wrap onto several lines"
|
|
@@ -1,16 +1,19 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { expect, within } from 'storybook/test';
|
|
2
3
|
|
|
3
|
-
import { Chip } from '@swisper.ai/ui';
|
|
4
|
+
import { Chip, Typography } from '@swisper.ai/ui';
|
|
5
|
+
|
|
6
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
4
7
|
|
|
5
8
|
import { ChatReplies, ChatReply, ChatReplyLabel, ChatReplyValue } from './chat-reply';
|
|
6
9
|
|
|
7
10
|
const meta: Meta<typeof ChatReply> = {
|
|
8
|
-
title: '
|
|
11
|
+
title: 'Chat/ChatReply',
|
|
9
12
|
component: ChatReply,
|
|
10
13
|
tags: ['autodocs'],
|
|
11
14
|
decorators: [
|
|
12
15
|
(Story) => (
|
|
13
|
-
<div className="max-w-
|
|
16
|
+
<div className="max-w-105">
|
|
14
17
|
<Story />
|
|
15
18
|
</div>
|
|
16
19
|
),
|
|
@@ -31,21 +34,30 @@ const meta: Meta<typeof ChatReply> = {
|
|
|
31
34
|
description: 'Extra classes merged onto the `<li>` root.',
|
|
32
35
|
},
|
|
33
36
|
},
|
|
34
|
-
args: {
|
|
35
|
-
isMultiline: false,
|
|
36
|
-
children: (
|
|
37
|
-
<>
|
|
38
|
-
<ChatReplyLabel>Reply e-mail</ChatReplyLabel>
|
|
39
|
-
<ChatReplyValue>Job application</ChatReplyValue>
|
|
40
|
-
</>
|
|
41
|
-
),
|
|
42
|
-
},
|
|
43
37
|
};
|
|
44
38
|
|
|
45
39
|
export default meta;
|
|
46
40
|
type Story = StoryObj<typeof ChatReply>;
|
|
47
41
|
|
|
42
|
+
interface Recipient {
|
|
43
|
+
email: string;
|
|
44
|
+
isInvalid?: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// The recipients of a drafted reply: one long address, and one the mail server rejected.
|
|
48
|
+
const RECIPIENTS: Recipient[] = [
|
|
49
|
+
{ email: 'nora.keller@company.com' },
|
|
50
|
+
{ email: 'recruiting-team.zurich@company.com' },
|
|
51
|
+
{ email: 'j.meier@company', isInvalid: true },
|
|
52
|
+
{ email: 'luca.brunner@company.com' },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
const LONG_SUBJECT =
|
|
56
|
+
'Re: Your application for the Senior Product Designer role – next steps and available interview dates';
|
|
57
|
+
|
|
58
|
+
/** The summary of a drafted reply: what it answers on one line, and its recipients as wrapping chips with the invalid address in the error colour. */
|
|
48
59
|
export const Default: Story = {
|
|
60
|
+
parameters: { controls: { disable: true } },
|
|
49
61
|
render: () => (
|
|
50
62
|
<ChatReplies>
|
|
51
63
|
<ChatReply>
|
|
@@ -56,17 +68,248 @@ export const Default: Story = {
|
|
|
56
68
|
<ChatReply isMultiline>
|
|
57
69
|
<ChatReplyLabel>To</ChatReplyLabel>
|
|
58
70
|
<ChatReplyValue>
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
71
|
+
{RECIPIENTS.slice(0, 3).map((recipient) => (
|
|
72
|
+
<Chip
|
|
73
|
+
key={recipient.email}
|
|
74
|
+
variant="filled"
|
|
75
|
+
color={recipient.isInvalid ? 'error' : 'primary'}
|
|
76
|
+
size="md"
|
|
77
|
+
>
|
|
78
|
+
{recipient.email}
|
|
79
|
+
</Chip>
|
|
80
|
+
))}
|
|
68
81
|
</ChatReplyValue>
|
|
69
82
|
</ChatReply>
|
|
70
83
|
</ChatReplies>
|
|
71
84
|
),
|
|
72
85
|
};
|
|
86
|
+
|
|
87
|
+
/** A single-line row keeps a long subject on one line and cuts it at the edge, so the summary stays compact. */
|
|
88
|
+
export const LongValue: Story = {
|
|
89
|
+
parameters: { controls: { disable: true } },
|
|
90
|
+
render: () => (
|
|
91
|
+
<ChatReplies>
|
|
92
|
+
<ChatReply>
|
|
93
|
+
<ChatReplyLabel>From</ChatReplyLabel>
|
|
94
|
+
<ChatReplyValue>anna.vogel@company.com</ChatReplyValue>
|
|
95
|
+
</ChatReply>
|
|
96
|
+
<ChatReply>
|
|
97
|
+
<ChatReplyLabel>Subject</ChatReplyLabel>
|
|
98
|
+
<ChatReplyValue>{LONG_SUBJECT}</ChatReplyValue>
|
|
99
|
+
</ChatReply>
|
|
100
|
+
</ChatReplies>
|
|
101
|
+
),
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
/** Checks the rows are exposed as a padded list, and that the recipients wrap while the single-line row keeps its height. */
|
|
105
|
+
export const DefaultListAndWrapping: Story = {
|
|
106
|
+
...Default,
|
|
107
|
+
tags: ['e2e', '!autodocs'],
|
|
108
|
+
play: async ({ canvas, step }) => {
|
|
109
|
+
const list = canvas.getByRole('list');
|
|
110
|
+
const [replyRow, recipientsRow] = within(list).getAllByRole('listitem');
|
|
111
|
+
|
|
112
|
+
await step('Exposes one list item per row, each with its label and value', async () => {
|
|
113
|
+
await expect(within(list).getAllByRole('listitem')).toHaveLength(2);
|
|
114
|
+
await expect(within(replyRow).getByText('Reply e-mail')).toBeVisible();
|
|
115
|
+
await expect(within(replyRow).getByText('Job application')).toBeVisible();
|
|
116
|
+
await expect(within(recipientsRow).getByText('To')).toBeVisible();
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
await step('Pads the list by default', async () => {
|
|
120
|
+
await expect(getComputedStyle(list).paddingLeft).toBe('16px');
|
|
121
|
+
await expect(getComputedStyle(list).paddingTop).toBe('8px');
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
await step('Wraps the recipients inside the list instead of cutting them', async () => {
|
|
125
|
+
const listRight = list.getBoundingClientRect().right;
|
|
126
|
+
await expect(recipientsRow.getBoundingClientRect().height).toBeGreaterThan(
|
|
127
|
+
replyRow.getBoundingClientRect().height,
|
|
128
|
+
);
|
|
129
|
+
for (const recipient of RECIPIENTS.slice(0, 3)) {
|
|
130
|
+
const chip = within(recipientsRow).getByText(recipient.email);
|
|
131
|
+
await expect(chip).toBeVisible();
|
|
132
|
+
await expect(chip.getBoundingClientRect().right).toBeLessThanOrEqual(listRight);
|
|
133
|
+
}
|
|
134
|
+
});
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** Checks a long subject stays on one line and is cut at the row's edge. */
|
|
139
|
+
export const LongValueTruncates: Story = {
|
|
140
|
+
...LongValue,
|
|
141
|
+
tags: ['e2e', '!autodocs'],
|
|
142
|
+
play: async ({ canvas }) => {
|
|
143
|
+
const [fromRow, subjectRow] = canvas.getAllByRole('listitem');
|
|
144
|
+
const subject = canvas.getByText(LONG_SUBJECT);
|
|
145
|
+
|
|
146
|
+
await expect(subject.scrollWidth).toBeGreaterThan(subject.clientWidth);
|
|
147
|
+
await expect(subjectRow.getBoundingClientRect().height).toBe(
|
|
148
|
+
fromRow.getBoundingClientRect().height,
|
|
149
|
+
);
|
|
150
|
+
await expect(subjectRow.getBoundingClientRect().right).toBeLessThanOrEqual(
|
|
151
|
+
canvas.getByRole('list').getBoundingClientRect().right,
|
|
152
|
+
);
|
|
153
|
+
},
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/** The summary in each place it's allowed: its own list, the body of a chat card and the body of a chat message. */
|
|
157
|
+
export const Examples: Story = {
|
|
158
|
+
parameters: { controls: { disable: true } },
|
|
159
|
+
render: () => (
|
|
160
|
+
<div className="flex flex-col gap-24">
|
|
161
|
+
<ParentBlock parent="web-chat-ui/ChatReplies">
|
|
162
|
+
<ChatReplies>
|
|
163
|
+
<ChatReply>
|
|
164
|
+
<ChatReplyLabel>From</ChatReplyLabel>
|
|
165
|
+
<ChatReplyValue>anna.vogel@company.com</ChatReplyValue>
|
|
166
|
+
</ChatReply>
|
|
167
|
+
<ChatReply>
|
|
168
|
+
<ChatReplyLabel>Subject</ChatReplyLabel>
|
|
169
|
+
<ChatReplyValue>Quarterly reports</ChatReplyValue>
|
|
170
|
+
</ChatReply>
|
|
171
|
+
</ChatReplies>
|
|
172
|
+
</ParentBlock>
|
|
173
|
+
|
|
174
|
+
<ParentBlock parent="chat card body">
|
|
175
|
+
<section
|
|
176
|
+
aria-label="E-mail draft"
|
|
177
|
+
className="flex flex-col gap-12 rounded-sm border border-component-divider p-16"
|
|
178
|
+
>
|
|
179
|
+
<Typography variant="body-small-high" fontWeight="medium">
|
|
180
|
+
Quarterly reports
|
|
181
|
+
</Typography>
|
|
182
|
+
{/* The card body already insets its content, so the list drops its own padding. */}
|
|
183
|
+
<ChatReplies hasPadding={false}>
|
|
184
|
+
<ChatReply>
|
|
185
|
+
<ChatReplyLabel>From</ChatReplyLabel>
|
|
186
|
+
<ChatReplyValue>anna.vogel@company.com</ChatReplyValue>
|
|
187
|
+
</ChatReply>
|
|
188
|
+
<ChatReply isMultiline>
|
|
189
|
+
<ChatReplyLabel>To</ChatReplyLabel>
|
|
190
|
+
<ChatReplyValue>
|
|
191
|
+
{RECIPIENTS.slice(0, 2).map((recipient) => (
|
|
192
|
+
<Chip key={recipient.email} variant="filled" color="primary" size="md">
|
|
193
|
+
{recipient.email}
|
|
194
|
+
</Chip>
|
|
195
|
+
))}
|
|
196
|
+
</ChatReplyValue>
|
|
197
|
+
</ChatReply>
|
|
198
|
+
</ChatReplies>
|
|
199
|
+
<Typography variant="body-small-high" className="text-text-secondary">
|
|
200
|
+
Hello Nora, here are the reports for the third quarter. Best regards, Anna
|
|
201
|
+
</Typography>
|
|
202
|
+
</section>
|
|
203
|
+
</ParentBlock>
|
|
204
|
+
|
|
205
|
+
<ParentBlock parent="chat message body">
|
|
206
|
+
<div aria-label="Assistant message" role="group" className="flex flex-col gap-8">
|
|
207
|
+
<Typography variant="body-small-high">
|
|
208
|
+
I drafted a reply to the job application. Check the details before I send it.
|
|
209
|
+
</Typography>
|
|
210
|
+
<ChatReplies hasPadding={false}>
|
|
211
|
+
<ChatReply>
|
|
212
|
+
<ChatReplyLabel>Reply e-mail</ChatReplyLabel>
|
|
213
|
+
<ChatReplyValue>Job application</ChatReplyValue>
|
|
214
|
+
</ChatReply>
|
|
215
|
+
<ChatReply>
|
|
216
|
+
<ChatReplyLabel>Subject</ChatReplyLabel>
|
|
217
|
+
<ChatReplyValue>{LONG_SUBJECT}</ChatReplyValue>
|
|
218
|
+
</ChatReply>
|
|
219
|
+
</ChatReplies>
|
|
220
|
+
</div>
|
|
221
|
+
</ParentBlock>
|
|
222
|
+
</div>
|
|
223
|
+
),
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
/** Checks the list pads itself on its own and drops the padding with `hasPadding={false}` inside a card or message. */
|
|
227
|
+
export const ExamplesPadding: Story = {
|
|
228
|
+
...Examples,
|
|
229
|
+
tags: ['e2e', '!autodocs'],
|
|
230
|
+
play: async ({ canvas }) => {
|
|
231
|
+
const [standalone, inCard, inMessage] = canvas.getAllByRole('list');
|
|
232
|
+
|
|
233
|
+
await expect(getComputedStyle(standalone).paddingLeft).toBe('16px');
|
|
234
|
+
await expect(getComputedStyle(inCard).paddingLeft).toBe('0px');
|
|
235
|
+
await expect(getComputedStyle(inCard).paddingTop).toBe('0px');
|
|
236
|
+
await expect(getComputedStyle(inMessage).paddingLeft).toBe('0px');
|
|
237
|
+
},
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
interface ChatReplyPlaygroundProps {
|
|
241
|
+
hasPadding: boolean;
|
|
242
|
+
subject: string;
|
|
243
|
+
label: string;
|
|
244
|
+
recipientCount: number;
|
|
245
|
+
isMultiline: boolean;
|
|
246
|
+
className?: string;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function ChatReplyPlayground({
|
|
250
|
+
hasPadding,
|
|
251
|
+
subject,
|
|
252
|
+
label,
|
|
253
|
+
recipientCount,
|
|
254
|
+
isMultiline,
|
|
255
|
+
className,
|
|
256
|
+
}: ChatReplyPlaygroundProps) {
|
|
257
|
+
return (
|
|
258
|
+
<ChatReplies hasPadding={hasPadding}>
|
|
259
|
+
<ChatReply>
|
|
260
|
+
<ChatReplyLabel>Subject</ChatReplyLabel>
|
|
261
|
+
<ChatReplyValue>{subject}</ChatReplyValue>
|
|
262
|
+
</ChatReply>
|
|
263
|
+
|
|
264
|
+
<ChatReply isMultiline={isMultiline} className={className}>
|
|
265
|
+
<ChatReplyLabel>{label}</ChatReplyLabel>
|
|
266
|
+
<ChatReplyValue>
|
|
267
|
+
{RECIPIENTS.slice(0, recipientCount).map((recipient) => (
|
|
268
|
+
<Chip
|
|
269
|
+
key={recipient.email}
|
|
270
|
+
variant="filled"
|
|
271
|
+
color={recipient.isInvalid ? 'error' : 'primary'}
|
|
272
|
+
size="md"
|
|
273
|
+
>
|
|
274
|
+
{recipient.email}
|
|
275
|
+
</Chip>
|
|
276
|
+
))}
|
|
277
|
+
</ChatReplyValue>
|
|
278
|
+
</ChatReply>
|
|
279
|
+
</ChatReplies>
|
|
280
|
+
);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
type PlaygroundStory = StoryObj<typeof ChatReplyPlayground>;
|
|
284
|
+
|
|
285
|
+
/** A text row and a chip row at once, with every prop of the list and the row on the Controls panel. */
|
|
286
|
+
export const Playground: PlaygroundStory = {
|
|
287
|
+
tags: ['!autodocs'],
|
|
288
|
+
args: {
|
|
289
|
+
hasPadding: true,
|
|
290
|
+
subject: LONG_SUBJECT,
|
|
291
|
+
label: 'To',
|
|
292
|
+
recipientCount: RECIPIENTS.length,
|
|
293
|
+
isMultiline: true,
|
|
294
|
+
className: '',
|
|
295
|
+
},
|
|
296
|
+
argTypes: {
|
|
297
|
+
hasPadding: {
|
|
298
|
+
control: 'boolean',
|
|
299
|
+
description:
|
|
300
|
+
'`hasPadding` on `ChatReplies`. Set `false` when the parent already provides the padding.',
|
|
301
|
+
},
|
|
302
|
+
subject: { control: 'text', description: 'Text of `ChatReplyValue` in the single-line row.' },
|
|
303
|
+
label: { control: 'text', description: 'Text of `ChatReplyLabel` in the recipients row.' },
|
|
304
|
+
recipientCount: {
|
|
305
|
+
control: { type: 'number', min: 0, max: RECIPIENTS.length },
|
|
306
|
+
description: 'Number of chips in the `ChatReplyValue` of the recipients row.',
|
|
307
|
+
},
|
|
308
|
+
isMultiline: {
|
|
309
|
+
control: 'boolean',
|
|
310
|
+
description: '`isMultiline` on the recipients row. Off, its chips stay on one line and clip.',
|
|
311
|
+
},
|
|
312
|
+
className: { control: 'text', description: '`className` on the recipients row.' },
|
|
313
|
+
},
|
|
314
|
+
render: (args) => <ChatReplyPlayground {...args} />,
|
|
315
|
+
};
|
|
@@ -4,15 +4,20 @@ import { Chip, Typography, type TypographyProps } from '@swisper.ai/ui';
|
|
|
4
4
|
import { cn } from '@swisper.ai/web-core';
|
|
5
5
|
|
|
6
6
|
export interface ChatRepliesProps {
|
|
7
|
+
/** The `ChatReply` rows. */
|
|
7
8
|
children: ReactNode;
|
|
9
|
+
/** Classes for the list (`data-slot="chat-replies"`). */
|
|
8
10
|
className?: string;
|
|
11
|
+
/** Pads the list. Set `false` when the parent already provides the padding. */
|
|
9
12
|
hasPadding?: boolean;
|
|
10
13
|
}
|
|
11
14
|
|
|
15
|
+
/** The list of rows that summarises a drafted reply; a `ul` that stacks its `ChatReply` rows. */
|
|
12
16
|
export function ChatReplies({ className, children, hasPadding = true }: ChatRepliesProps) {
|
|
13
17
|
return (
|
|
14
18
|
<ul
|
|
15
19
|
data-testid="chat-replies"
|
|
20
|
+
data-slot="chat-replies"
|
|
16
21
|
data-padding={hasPadding}
|
|
17
22
|
className={cn(
|
|
18
23
|
'flex flex-col justify-start items-start gap-8',
|
|
@@ -26,14 +31,18 @@ export function ChatReplies({ className, children, hasPadding = true }: ChatRepl
|
|
|
26
31
|
}
|
|
27
32
|
|
|
28
33
|
export interface ChatReplyProps extends ComponentProps<'li'> {
|
|
34
|
+
/** A `ChatReplyLabel` followed by a `ChatReplyValue`. */
|
|
29
35
|
children: ReactNode;
|
|
36
|
+
/** Lets the row and its value wrap onto several lines, for a value that is a list of chips. */
|
|
30
37
|
isMultiline?: boolean;
|
|
31
38
|
}
|
|
32
39
|
|
|
40
|
+
/** One row of the summary: a label and its value. An `li`, so it goes inside `ChatReplies`. */
|
|
33
41
|
export function ChatReply({ className, children, isMultiline = false, ...rest }: ChatReplyProps) {
|
|
34
42
|
return (
|
|
35
43
|
<li
|
|
36
44
|
data-testid="chat-reply"
|
|
45
|
+
data-slot="chat-reply"
|
|
37
46
|
data-multiline={isMultiline}
|
|
38
47
|
className={cn(
|
|
39
48
|
'group/chat-reply',
|
|
@@ -50,9 +59,11 @@ export function ChatReply({ className, children, isMultiline = false, ...rest }:
|
|
|
50
59
|
}
|
|
51
60
|
|
|
52
61
|
export interface ChatReplyLabelProps extends ComponentProps<typeof Chip> {
|
|
62
|
+
/** The field's name, one or two words. */
|
|
53
63
|
children: ReactNode;
|
|
54
64
|
}
|
|
55
65
|
|
|
66
|
+
/** The name of the row's field, as an outlined chip that keeps its width. */
|
|
56
67
|
export function ChatReplyLabel({ className, children, ...rest }: ChatReplyLabelProps) {
|
|
57
68
|
return (
|
|
58
69
|
<Chip
|
|
@@ -62,6 +73,7 @@ export function ChatReplyLabel({ className, children, ...rest }: ChatReplyLabelP
|
|
|
62
73
|
// @ts-expect-error TODO(design): Chip has no `secondary` color any more; renders without color classes.
|
|
63
74
|
color="secondary"
|
|
64
75
|
data-testid="chat-reply-label"
|
|
76
|
+
data-slot="chat-reply-label"
|
|
65
77
|
className={cn('shrink-0', className)}
|
|
66
78
|
{...rest}
|
|
67
79
|
>
|
|
@@ -71,10 +83,12 @@ export function ChatReplyLabel({ className, children, ...rest }: ChatReplyLabelP
|
|
|
71
83
|
}
|
|
72
84
|
|
|
73
85
|
export interface ChatReplyValueProps extends Omit<TypographyProps, 'variant'> {
|
|
86
|
+
/** The field's content: text, or one chip per item in a multiline row. */
|
|
74
87
|
children: ReactNode;
|
|
75
88
|
asChild?: boolean;
|
|
76
89
|
}
|
|
77
90
|
|
|
91
|
+
/** The row's value: secondary text cut to one line, or wrapping items when the row is multiline. */
|
|
78
92
|
export function ChatReplyValue({
|
|
79
93
|
className,
|
|
80
94
|
children,
|
|
@@ -84,6 +98,7 @@ export function ChatReplyValue({
|
|
|
84
98
|
return (
|
|
85
99
|
<Typography
|
|
86
100
|
data-testid="chat-reply-value"
|
|
101
|
+
data-slot="chat-reply-value"
|
|
87
102
|
variant="body-sm"
|
|
88
103
|
className={cn(
|
|
89
104
|
'leading-[24px]',
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export {
|
|
2
|
+
ChatReplies,
|
|
3
|
+
ChatReply,
|
|
4
|
+
ChatReplyLabel,
|
|
5
|
+
ChatReplyValue,
|
|
6
|
+
type ChatRepliesProps,
|
|
7
|
+
type ChatReplyProps,
|
|
8
|
+
type ChatReplyLabelProps,
|
|
9
|
+
type ChatReplyValueProps,
|
|
10
|
+
} from './chat-reply';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Follow-ups offered after an answer about the week ahead: short, specific, in the user's words. */
|
|
2
|
+
export const FOLLOW_UPS = [
|
|
3
|
+
'Check my calendar for next week',
|
|
4
|
+
'Pull up last week’s standup notes',
|
|
5
|
+
'Draft a reply to Marc saying I can move the board meeting to Thursday afternoon',
|
|
6
|
+
];
|
|
7
|
+
|
|
8
|
+
/** Replies to a question the assistant asked: confirming the address before an email is sent. */
|
|
9
|
+
export const QUICK_REPLIES = ['Yes, that’s correct', 'Use a different address', 'Never mind'];
|
|
10
|
+
|
|
11
|
+
/** Starters for an empty conversation. */
|
|
12
|
+
export const CONVERSATION_STARTERS = [
|
|
13
|
+
'What can you help me with?',
|
|
14
|
+
'Check my calendar for today',
|
|
15
|
+
'Summarise my unread emails',
|
|
16
|
+
];
|