@swisper.ai/web-chat-ui 0.0.2 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -12
- package/dist/components/canvas-shell/canvas-shell.d.ts +32 -10
- package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -1
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts +49 -17
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.d.ts +1 -0
- package/dist/components/chat-card/chat-card.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.stories.d.ts +47 -1
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-body.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-footer.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-form.d.ts +15 -2
- package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-header.d.ts +23 -2
- package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -1
- package/dist/components/chat-card/contexts.d.ts +2 -0
- package/dist/components/chat-card/contexts.d.ts.map +1 -1
- package/dist/components/chat-card/hooks.d.ts +1 -0
- package/dist/components/chat-card/hooks.d.ts.map +1 -1
- package/dist/components/chat-card/types.d.ts +3 -0
- package/dist/components/chat-card/types.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.d.ts +4 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts +12 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.stories.d.ts +36 -11
- package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.d.ts +27 -2
- package/dist/components/chat-input/chat-input.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.stories.d.ts +63 -3
- package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-item.d.ts +6 -0
- package/dist/components/chat-list/chat-list-item.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-items.d.ts +12 -1
- package/dist/components/chat-list/chat-list-items.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.d.ts +36 -2
- package/dist/components/chat-list/chat-list.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.stories.d.ts +67 -9
- package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.d.ts +12 -1
- package/dist/components/chat-message/chat-message.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.stories.d.ts +31 -0
- package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -1
- package/dist/components/chat-message/index.d.ts +1 -1
- package/dist/components/chat-message/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +3 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +25 -5
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +32 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/index.d.ts +2 -2
- package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/utils.d.ts +1 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -1
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts +13 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +22 -5
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +42 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.d.ts +34 -2
- package/dist/components/chat-messages/chat-messages.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.stories.d.ts +33 -2
- package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.d.ts +56 -4
- package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +50 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +6 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +43 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +37 -17
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +53 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.d.ts +11 -0
- package/dist/components/chat-reply/chat-reply.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.stories.d.ts +23 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/index.d.ts +1 -1
- package/dist/components/chat-reply/index.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.d.ts +36 -10
- package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +66 -2
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -1
- package/dist/components/chat-suggestion/index.d.ts +2 -1
- package/dist/components/chat-suggestion/index.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +26 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +25 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.d.ts +17 -2
- package/dist/components/chat-thread/chat-thread.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.stories.d.ts +75 -10
- package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts +8 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +18 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.d.ts +17 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts +52 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/styled.d.ts +6 -2
- package/dist/components/rich-text-area/styled.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +9 -2
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/index.d.ts +5 -5
- package/dist/components/rich-text-field/components/index.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts +12 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.d.ts +22 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts +28 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
- package/dist/components/topmenu/index.d.ts +2 -0
- package/dist/components/topmenu/index.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.d.ts +22 -0
- package/dist/components/topmenu/topmenu.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.stories.d.ts +31 -0
- package/dist/components/topmenu/topmenu.stories.d.ts.map +1 -0
- package/dist/docs/agent.stories.d.ts.map +1 -1
- package/dist/docs/chat-panel.d.ts +7 -5
- package/dist/docs/chat-panel.d.ts.map +1 -1
- package/dist/docs/chatbot-panel.d.ts.map +1 -1
- package/dist/docs/chatbot.stories.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +1227 -1260
- package/dist/index.es.js.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +9 -7
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +37 -9
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +41 -16
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +6 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +22 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -1
- package/package.json +15 -9
- package/src/__storybook__/parent-block.tsx +21 -0
- package/src/components/canvas-shell/__stories__/canvas-panel.tsx +25 -0
- package/src/components/canvas-shell/__stories__/document-list.tsx +29 -0
- package/src/components/canvas-shell/__stories__/fixtures.ts +222 -0
- package/src/components/canvas-shell/__stories__/holdings-table.tsx +56 -0
- package/src/components/canvas-shell/__stories__/types.ts +47 -0
- package/src/components/canvas-shell/{canvas-shell.test.tsx → __tests__/canvas-shell.spec.tsx} +1 -1
- package/src/components/canvas-shell/canvas-shell.json +24 -0
- package/src/components/canvas-shell/canvas-shell.stories.tsx +581 -122
- package/src/components/canvas-shell/canvas-shell.tsx +44 -17
- package/src/components/chat-card/__stories__/fixtures.ts +119 -0
- package/src/components/chat-card/__stories__/types.ts +44 -0
- package/src/components/chat-card/chat-card.json +67 -3
- package/src/components/chat-card/chat-card.stories.tsx +872 -148
- package/src/components/chat-card/chat-card.tsx +2 -0
- package/src/components/chat-card/components/chat-card-body.tsx +12 -0
- package/src/components/chat-card/components/chat-card-footer.tsx +11 -0
- package/src/components/chat-card/components/chat-card-form.tsx +21 -2
- package/src/components/chat-card/components/chat-card-header.tsx +39 -2
- package/src/components/chat-card/contexts.tsx +2 -0
- package/src/components/chat-card/hooks.ts +1 -0
- package/src/components/chat-card/types.ts +3 -0
- package/src/components/chat-card-container/__stories__/fixtures.ts +54 -0
- package/src/components/chat-card-container/__stories__/resizable-chat-window.tsx +19 -0
- package/src/components/chat-card-container/__stories__/result-card.tsx +31 -0
- package/src/components/chat-card-container/__stories__/types.ts +16 -0
- package/src/components/chat-card-container/chat-card-container.json +7 -0
- package/src/components/chat-card-container/chat-card-container.stories.tsx +209 -56
- package/src/components/chat-card-container/chat-card-container.tsx +5 -0
- package/src/components/chat-container/__stories__/chat-composer.tsx +67 -0
- package/src/components/chat-container/__stories__/fixtures.ts +27 -0
- package/src/components/chat-container/__stories__/measure.ts +22 -0
- package/src/components/chat-container/__stories__/types.ts +7 -0
- package/src/components/chat-container/__stories__/variable-readout.tsx +64 -0
- package/src/components/chat-container/chat-container.json +9 -1
- package/src/components/chat-container/chat-container.stories.tsx +538 -106
- package/src/components/chat-container/chat-container.tsx +3 -0
- package/src/components/chat-input/__stories__/fixtures.ts +31 -0
- package/src/components/chat-input/chat-input.json +10 -2
- package/src/components/chat-input/chat-input.stories.tsx +660 -197
- package/src/components/chat-input/chat-input.tsx +32 -2
- package/src/components/chat-list/__stories__/chat-row.tsx +41 -0
- package/src/components/chat-list/__stories__/fixtures.ts +94 -0
- package/src/components/chat-list/__stories__/types.ts +13 -0
- package/src/components/chat-list/chat-list-item.tsx +6 -0
- package/src/components/chat-list/chat-list-items.tsx +16 -0
- package/src/components/chat-list/chat-list.json +24 -2
- package/src/components/chat-list/chat-list.stories.tsx +631 -215
- package/src/components/chat-list/chat-list.tsx +51 -4
- package/src/components/chat-message/__stories__/fixtures.ts +53 -0
- package/src/components/chat-message/__stories__/sent-attachment.tsx +22 -0
- package/src/components/chat-message/__stories__/tool-steps.tsx +37 -0
- package/src/components/chat-message/chat-message.json +10 -1
- package/src/components/chat-message/chat-message.stories.tsx +282 -20
- package/src/components/chat-message/chat-message.tsx +16 -1
- package/src/components/chat-message/index.ts +8 -1
- package/src/components/chat-message-attachment-card/__stories__/fixtures.ts +30 -0
- package/src/components/chat-message-attachment-card/__stories__/types.ts +14 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +4 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +20 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +266 -51
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +37 -4
- package/src/components/chat-message-attachment-card/index.ts +6 -0
- package/src/components/chat-message-attachment-card/utils.ts +1 -0
- package/src/components/chat-message-response/__stories__/fixtures.ts +50 -0
- package/src/components/chat-message-response/chat-message-response.json +5 -0
- package/src/components/chat-message-response/chat-message-response.stories.tsx +135 -26
- package/src/components/chat-message-toolbar/chat-message-toolbar.json +21 -3
- package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +377 -6
- package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +47 -12
- package/src/components/chat-message-toolbar/index.ts +4 -0
- package/src/components/chat-messages/__stories__/conversation-frame.tsx +25 -0
- package/src/components/chat-messages/__stories__/conversation-group.tsx +22 -0
- package/src/components/chat-messages/__stories__/fixtures.ts +70 -0
- package/src/components/chat-messages/__stories__/types.ts +5 -0
- package/src/components/chat-messages/chat-messages.json +30 -12
- package/src/components/chat-messages/chat-messages.stories.tsx +439 -212
- package/src/components/chat-messages/chat-messages.tsx +46 -3
- package/src/components/chat-notification-card/__stories__/fixtures.ts +38 -0
- package/src/components/chat-notification-card/__stories__/types.ts +13 -0
- package/src/components/chat-notification-card/chat-notification-card.json +52 -2
- package/src/components/chat-notification-card/chat-notification-card.stories.tsx +542 -62
- package/src/components/chat-notification-card/chat-notification-card.tsx +97 -6
- package/src/components/chat-notification-popup/__stories__/fixtures.ts +36 -0
- package/src/components/chat-notification-popup/__stories__/notification-item.tsx +93 -0
- package/src/components/chat-notification-popup/__stories__/types.ts +14 -0
- package/src/components/chat-notification-popup/chat-notification-popup.json +14 -1
- package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +467 -17
- package/src/components/chat-notification-popup/chat-notification-popup.tsx +18 -3
- package/src/components/chat-prompt-box/__stories__/fixtures.ts +16 -0
- package/src/components/chat-prompt-box/__stories__/types.ts +8 -0
- package/src/components/chat-prompt-box/chat-prompt-box.json +25 -2
- package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +535 -43
- package/src/components/chat-prompt-box/chat-prompt-box.tsx +73 -19
- package/src/components/chat-reply/chat-reply.json +10 -0
- package/src/components/chat-reply/chat-reply.stories.tsx +264 -21
- package/src/components/chat-reply/chat-reply.tsx +15 -0
- package/src/components/chat-reply/index.ts +10 -1
- package/src/components/chat-suggestion/__stories__/fixtures.ts +16 -0
- package/src/components/chat-suggestion/__tests__/chat-suggestion.spec.tsx +185 -0
- package/src/components/chat-suggestion/chat-suggestion.json +62 -20
- package/src/components/chat-suggestion/chat-suggestion.stories.tsx +542 -58
- package/src/components/chat-suggestion/chat-suggestion.tsx +154 -65
- package/src/components/chat-suggestion/index.ts +9 -0
- package/src/components/chat-thinking-process/__stories__/fixtures.ts +56 -0
- package/src/components/chat-thinking-process/chat-thinking-process.json +28 -3
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +354 -78
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -4
- package/src/components/chat-thread/__stories__/fixtures.ts +171 -0
- package/src/components/chat-thread/__stories__/scroll-position.ts +9 -0
- package/src/components/chat-thread/__stories__/snippets.ts +129 -0
- package/src/components/chat-thread/__stories__/thread-frame.tsx +22 -0
- package/src/components/chat-thread/__stories__/thread-turns.tsx +35 -0
- package/src/components/chat-thread/__stories__/types.ts +12 -0
- package/src/components/chat-thread/__stories__/use-turn-stream.ts +78 -0
- package/src/components/chat-thread/chat-thread.json +23 -3
- package/src/components/chat-thread/chat-thread.stories.tsx +804 -142
- package/src/components/chat-thread/chat-thread.tsx +64 -16
- package/src/components/index.ts +1 -3
- package/src/components/markdown-viewer/__stories__/fixtures.ts +67 -0
- package/src/components/markdown-viewer/markdown-viewer.json +7 -1
- package/src/components/markdown-viewer/markdown-viewer.stories.tsx +219 -50
- package/src/components/markdown-viewer/markdown-viewer.tsx +9 -0
- package/src/components/rich-text-area/__stories__/fixtures.ts +30 -0
- package/src/components/rich-text-area/rich-text-area.json +6 -4
- package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
- package/src/components/rich-text-area/rich-text-area.tsx +22 -1
- package/src/components/rich-text-area/styled.tsx +11 -5
- package/src/components/rich-text-field/__stories__/fixtures.ts +29 -0
- package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +10 -1
- package/src/components/rich-text-field/components/index.ts +8 -5
- package/src/components/rich-text-field/components/text-color-button.tsx +16 -2
- package/src/components/rich-text-field/rich-text-field.json +3 -1
- package/src/components/rich-text-field/rich-text-field.stories.tsx +452 -61
- package/src/components/rich-text-field/rich-text-field.tsx +23 -0
- package/src/components/topmenu/index.ts +1 -0
- package/src/components/topmenu/topmenu.json +107 -0
- package/src/components/topmenu/topmenu.stories.tsx +334 -0
- package/src/components/topmenu/topmenu.tsx +71 -0
- package/src/docs/agent.stories.tsx +16 -16
- package/src/docs/chat-panel.tsx +37 -32
- package/src/docs/chatbot-panel.tsx +11 -2
- package/src/docs/chatbot.mdx +17 -12
- package/src/docs/chatbot.stories.tsx +7 -8
- package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +112 -0
- package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +36 -0
- package/src/layouts/chat-card-list-layout/__stories__/types.ts +31 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +14 -1
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +316 -84
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +11 -7
- package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +117 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +18 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +85 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +50 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +44 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +61 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +35 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +16 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +603 -182
- package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +51 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +83 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +24 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +15 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +13 -1
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +368 -67
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +11 -2
- package/dist/components/card-item-picker/card-item-picker-context.d.ts +0 -21
- package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-list.d.ts +0 -24
- package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +0 -28
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row.d.ts +0 -12
- package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts +0 -19
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +0 -1
- package/dist/components/card-item-picker/index.d.ts +0 -9
- package/dist/components/card-item-picker/index.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.d.ts +0 -48
- package/dist/components/chat-message-history/chat-message-history.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts +0 -7
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +0 -1
- package/dist/components/chat-message-history/index.d.ts +0 -2
- package/dist/components/chat-message-history/index.d.ts.map +0 -1
- package/dist/components/spinner/index.d.ts +0 -2
- package/dist/components/spinner/index.d.ts.map +0 -1
- package/dist/components/spinner/spinner.d.ts +0 -9
- package/dist/components/spinner/spinner.d.ts.map +0 -1
- package/dist/components/spinner/spinner.stories.d.ts +0 -8
- package/dist/components/spinner/spinner.stories.d.ts.map +0 -1
- package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +0 -279
- package/src/components/card-item-picker/card-item-picker-context.tsx +0 -44
- package/src/components/card-item-picker/card-item-picker-list.tsx +0 -95
- package/src/components/card-item-picker/card-item-picker-row-parts.tsx +0 -96
- package/src/components/card-item-picker/card-item-picker-row.tsx +0 -109
- package/src/components/card-item-picker/card-item-picker.json +0 -147
- package/src/components/card-item-picker/card-item-picker.stories.tsx +0 -158
- package/src/components/card-item-picker/index.ts +0 -24
- package/src/components/chat-message-history/chat-message-history.json +0 -99
- package/src/components/chat-message-history/chat-message-history.stories.tsx +0 -136
- package/src/components/chat-message-history/chat-message-history.tsx +0 -277
- package/src/components/chat-message-history/index.ts +0 -13
- package/src/components/spinner/index.ts +0 -1
- package/src/components/spinner/spinner.json +0 -73
- package/src/components/spinner/spinner.stories.tsx +0 -41
- package/src/components/spinner/spinner.tsx +0 -32
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
2
|
import { useState } from 'react';
|
|
3
|
-
import { fn } from 'storybook/test';
|
|
3
|
+
import { expect, fn, waitFor, within } from 'storybook/test';
|
|
4
4
|
|
|
5
|
-
import { DownloadIcon, EditIcon } from '@swisper.ai/icons';
|
|
5
|
+
import { DownloadIcon, EditIcon, EnterIcon } from '@swisper.ai/icons';
|
|
6
6
|
import {
|
|
7
7
|
Button,
|
|
8
8
|
DropdownMenuList,
|
|
@@ -10,185 +10,644 @@ import {
|
|
|
10
10
|
MenuItemIcon,
|
|
11
11
|
MenuItemLabel,
|
|
12
12
|
Typography,
|
|
13
|
-
|
|
13
|
+
withTooltip,
|
|
14
14
|
} from '@swisper.ai/ui';
|
|
15
15
|
|
|
16
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
17
|
+
import { ChatInput, ChatInputTextarea } from '../chat-input';
|
|
18
|
+
import { ChatMessage, ChatMessageContent } from '../chat-message';
|
|
19
|
+
import {
|
|
20
|
+
ChatSuggestion,
|
|
21
|
+
ChatSuggestionActions,
|
|
22
|
+
ChatSuggestionLabel,
|
|
23
|
+
ChatSuggestionLabelIcon,
|
|
24
|
+
ChatSuggestions,
|
|
25
|
+
} from '../chat-suggestion';
|
|
26
|
+
import {
|
|
27
|
+
ChatThread,
|
|
28
|
+
ChatThreadAnswer,
|
|
29
|
+
ChatThreadGroup,
|
|
30
|
+
ChatThreadProvider,
|
|
31
|
+
ChatThreadQuestion,
|
|
32
|
+
} from '../chat-thread';
|
|
33
|
+
|
|
34
|
+
import { CanvasPanel } from './__stories__/canvas-panel';
|
|
35
|
+
import { DocumentList } from './__stories__/document-list';
|
|
36
|
+
import {
|
|
37
|
+
HOLDING_COLUMNS,
|
|
38
|
+
HOLDINGS,
|
|
39
|
+
LIBRARY_DOCUMENTS,
|
|
40
|
+
LONG_PREVIEW_FILENAME,
|
|
41
|
+
PREVIEW_FILENAME,
|
|
42
|
+
PREVIEW_PARAGRAPHS,
|
|
43
|
+
TRIP_CHAT_FOLLOW_UPS,
|
|
44
|
+
TRIP_CHAT_TITLE,
|
|
45
|
+
TRIP_CHAT_TURNS,
|
|
46
|
+
WALLET_TICKET,
|
|
47
|
+
} from './__stories__/fixtures';
|
|
48
|
+
import { HoldingsTable } from './__stories__/holdings-table';
|
|
16
49
|
import {
|
|
17
50
|
CanvasShell,
|
|
18
51
|
CanvasShellCloseTrigger,
|
|
19
52
|
CanvasShellContent,
|
|
20
|
-
CanvasShellFullScreenTrigger,
|
|
21
53
|
CanvasShellFooter,
|
|
54
|
+
CanvasShellFullScreenTrigger,
|
|
22
55
|
CanvasShellHeader,
|
|
23
56
|
CanvasShellOptionsButton,
|
|
24
57
|
CanvasShellTitle,
|
|
58
|
+
canvasShellContentPadding,
|
|
25
59
|
} from './canvas-shell';
|
|
26
60
|
|
|
27
|
-
|
|
28
|
-
title:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
61
|
+
const meta: Meta<typeof CanvasShell> = {
|
|
62
|
+
title: 'Chat/CanvasShell',
|
|
63
|
+
component: CanvasShell,
|
|
64
|
+
parameters: {
|
|
65
|
+
layout: 'fullscreen',
|
|
66
|
+
},
|
|
67
|
+
tags: ['autodocs'],
|
|
68
|
+
argTypes: {
|
|
69
|
+
children: {
|
|
70
|
+
control: false,
|
|
71
|
+
description:
|
|
72
|
+
'A `CanvasShellHeader`, a `CanvasShellContent` and, when the canvas has actions, a `CanvasShellFooter`.',
|
|
73
|
+
},
|
|
74
|
+
className: {
|
|
75
|
+
control: 'text',
|
|
76
|
+
description:
|
|
77
|
+
'Extra classes merged onto the `<section>`. The shell is `h-full`: give its parent a height.',
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default meta;
|
|
83
|
+
type Story = StoryObj<typeof CanvasShell>;
|
|
84
|
+
|
|
85
|
+
/** A booked train ticket in the side panel: its name and a close button on top, the details in the scrolling region, the download action in the footer. */
|
|
86
|
+
export const Default: Story = {
|
|
87
|
+
render: (args) => (
|
|
88
|
+
<CanvasPanel label={WALLET_TICKET.title}>
|
|
89
|
+
<CanvasShell {...args}>
|
|
90
|
+
<CanvasShellHeader>
|
|
91
|
+
<CanvasShellTitle>{WALLET_TICKET.title}</CanvasShellTitle>
|
|
92
|
+
<CanvasShellCloseTrigger onClick={fn()} />
|
|
93
|
+
</CanvasShellHeader>
|
|
94
|
+
|
|
95
|
+
<CanvasShellContent>
|
|
96
|
+
<div className="flex flex-col gap-24">
|
|
97
|
+
<dl className="grid grid-cols-2 gap-16">
|
|
98
|
+
{WALLET_TICKET.fields.map((field) => (
|
|
99
|
+
<div key={field.label} className={field.isWide ? 'col-span-2' : undefined}>
|
|
100
|
+
<Typography variant="caption-md" className="text-text-secondary" asChild>
|
|
101
|
+
<dt>{field.label}</dt>
|
|
102
|
+
</Typography>
|
|
103
|
+
<Typography variant="body-small-high" fontWeight="semibold" asChild>
|
|
104
|
+
<dd>{field.value}</dd>
|
|
105
|
+
</Typography>
|
|
106
|
+
</div>
|
|
107
|
+
))}
|
|
108
|
+
</dl>
|
|
109
|
+
|
|
110
|
+
<section aria-label="Changes" className="flex flex-col gap-8">
|
|
111
|
+
<Typography variant="body-small-high" fontWeight="bold">
|
|
112
|
+
Changes
|
|
113
|
+
</Typography>
|
|
114
|
+
{WALLET_TICKET.changes.map((change) => (
|
|
115
|
+
<Typography
|
|
116
|
+
key={change.station}
|
|
117
|
+
variant="caption-md"
|
|
118
|
+
className="text-text-secondary"
|
|
119
|
+
asChild
|
|
120
|
+
>
|
|
121
|
+
<p>
|
|
122
|
+
<span className="font-semibold text-text-primary">{change.station}</span>
|
|
123
|
+
{' · '}
|
|
124
|
+
{change.arrival} ➔ {change.departure}
|
|
125
|
+
</p>
|
|
126
|
+
</Typography>
|
|
127
|
+
))}
|
|
128
|
+
</section>
|
|
129
|
+
</div>
|
|
130
|
+
</CanvasShellContent>
|
|
131
|
+
|
|
132
|
+
<CanvasShellFooter>
|
|
133
|
+
<Button onClick={fn()}>Download PDF</Button>
|
|
134
|
+
</CanvasShellFooter>
|
|
135
|
+
</CanvasShell>
|
|
136
|
+
</CanvasPanel>
|
|
137
|
+
),
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
interface DocumentPreviewCanvasProps {
|
|
141
|
+
filename: string;
|
|
142
|
+
onDownload: () => void;
|
|
143
|
+
onRename: () => void;
|
|
34
144
|
onClose: () => void;
|
|
35
|
-
onOption: (option: string) => void;
|
|
36
145
|
}
|
|
37
146
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
hasFooter,
|
|
44
|
-
hasOptions,
|
|
147
|
+
/** The canvas a document opens in. The host owns full screen: it flips the flag and widens the panel. */
|
|
148
|
+
function DocumentPreviewCanvas({
|
|
149
|
+
filename,
|
|
150
|
+
onDownload,
|
|
151
|
+
onRename,
|
|
45
152
|
onClose,
|
|
46
|
-
|
|
47
|
-
}: CanvasShellStoryArgs) {
|
|
153
|
+
}: DocumentPreviewCanvasProps) {
|
|
48
154
|
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
49
155
|
|
|
50
156
|
return (
|
|
51
|
-
<
|
|
52
|
-
<
|
|
53
|
-
<
|
|
54
|
-
|
|
157
|
+
<CanvasPanel label="Document preview" isFullScreen={isFullScreen}>
|
|
158
|
+
<CanvasShell>
|
|
159
|
+
<CanvasShellHeader>
|
|
160
|
+
<CanvasShellTitle>{filename}</CanvasShellTitle>
|
|
55
161
|
<CanvasShellOptionsButton>
|
|
56
162
|
<DropdownMenuList>
|
|
57
|
-
<DropdownMenuListItem onClick={
|
|
163
|
+
<DropdownMenuListItem onClick={onDownload}>
|
|
58
164
|
<MenuItemIcon>
|
|
59
|
-
<DownloadIcon
|
|
165
|
+
<DownloadIcon className="size-20" />
|
|
60
166
|
</MenuItemIcon>
|
|
61
167
|
<MenuItemLabel>Download</MenuItemLabel>
|
|
62
168
|
</DropdownMenuListItem>
|
|
63
|
-
<DropdownMenuListItem onClick={
|
|
169
|
+
<DropdownMenuListItem onClick={onRename}>
|
|
64
170
|
<MenuItemIcon>
|
|
65
|
-
<EditIcon
|
|
171
|
+
<EditIcon className="size-20" />
|
|
66
172
|
</MenuItemIcon>
|
|
67
173
|
<MenuItemLabel>Rename</MenuItemLabel>
|
|
68
174
|
</DropdownMenuListItem>
|
|
69
175
|
</DropdownMenuList>
|
|
70
176
|
</CanvasShellOptionsButton>
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
</
|
|
87
|
-
</
|
|
88
|
-
|
|
89
|
-
{hasFooter && (
|
|
90
|
-
<CanvasShellFooter>
|
|
91
|
-
<Button variant="secondary">Cancel</Button>
|
|
92
|
-
<Button>Save changes</Button>
|
|
93
|
-
</CanvasShellFooter>
|
|
94
|
-
)}
|
|
95
|
-
</CanvasShell>
|
|
177
|
+
<CanvasShellFullScreenTrigger
|
|
178
|
+
isFullScreen={isFullScreen}
|
|
179
|
+
onClick={() => setIsFullScreen((current) => !current)}
|
|
180
|
+
/>
|
|
181
|
+
<CanvasShellCloseTrigger aria-label="Close preview" onClick={onClose} />
|
|
182
|
+
</CanvasShellHeader>
|
|
183
|
+
|
|
184
|
+
<CanvasShellContent>
|
|
185
|
+
<article className="flex flex-col gap-12">
|
|
186
|
+
{PREVIEW_PARAGRAPHS.map((paragraph) => (
|
|
187
|
+
<Typography key={paragraph} variant="body-medium" asChild>
|
|
188
|
+
<p>{paragraph}</p>
|
|
189
|
+
</Typography>
|
|
190
|
+
))}
|
|
191
|
+
</article>
|
|
192
|
+
</CanvasShellContent>
|
|
193
|
+
</CanvasShell>
|
|
194
|
+
</CanvasPanel>
|
|
96
195
|
);
|
|
97
196
|
}
|
|
98
197
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
198
|
+
type DocumentPreviewStory = StoryObj<typeof DocumentPreviewCanvas>;
|
|
199
|
+
|
|
200
|
+
const documentPreviewArgs: DocumentPreviewCanvasProps = {
|
|
201
|
+
filename: PREVIEW_FILENAME,
|
|
202
|
+
onDownload: fn(),
|
|
203
|
+
onRename: fn(),
|
|
204
|
+
onClose: fn(),
|
|
205
|
+
};
|
|
206
|
+
|
|
207
|
+
/** A filename longer than the header: it truncates to one line instead of pushing the buttons out. */
|
|
208
|
+
export const LongTitle: DocumentPreviewStory = {
|
|
209
|
+
args: { ...documentPreviewArgs, filename: LONG_PREVIEW_FILENAME },
|
|
210
|
+
render: (args) => <DocumentPreviewCanvas {...args} />,
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
interface DocumentsLibraryCanvasProps {
|
|
214
|
+
onClose: () => void;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** The chat's documents library: a list longer than the panel and nothing to confirm, so no footer. */
|
|
218
|
+
function DocumentsLibraryCanvas({ onClose }: DocumentsLibraryCanvasProps) {
|
|
219
|
+
return (
|
|
220
|
+
<CanvasPanel label="Documents">
|
|
221
|
+
<CanvasShell>
|
|
222
|
+
<CanvasShellHeader>
|
|
223
|
+
<CanvasShellTitle>Documents</CanvasShellTitle>
|
|
224
|
+
<CanvasShellCloseTrigger onClick={onClose} />
|
|
225
|
+
</CanvasShellHeader>
|
|
226
|
+
|
|
227
|
+
<CanvasShellContent>
|
|
228
|
+
<DocumentList documents={LIBRARY_DOCUMENTS} />
|
|
229
|
+
</CanvasShellContent>
|
|
230
|
+
</CanvasShell>
|
|
231
|
+
</CanvasPanel>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
type DocumentsLibraryStory = StoryObj<typeof DocumentsLibraryCanvas>;
|
|
236
|
+
|
|
237
|
+
/** No footer: the content region extends to the bottom of the shell. */
|
|
238
|
+
export const WithoutFooter: DocumentsLibraryStory = {
|
|
239
|
+
args: { onClose: fn() },
|
|
240
|
+
render: (args) => <DocumentsLibraryCanvas {...args} />,
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
/** A table wider and taller than the shell: it scrolls on both axes instead of growing the shell, edge to edge with `hasPadding={false}`. */
|
|
244
|
+
export const WideContent: Story = {
|
|
245
|
+
parameters: { controls: { disable: true } },
|
|
246
|
+
render: () => (
|
|
247
|
+
<CanvasPanel label="Table">
|
|
248
|
+
<CanvasShell>
|
|
249
|
+
<CanvasShellHeader>
|
|
250
|
+
<CanvasShellTitle>Table</CanvasShellTitle>
|
|
251
|
+
<CanvasShellCloseTrigger onClick={fn()} />
|
|
252
|
+
</CanvasShellHeader>
|
|
253
|
+
|
|
254
|
+
<CanvasShellContent hasPadding={false}>
|
|
255
|
+
<HoldingsTable columns={HOLDING_COLUMNS} holdings={HOLDINGS} />
|
|
256
|
+
</CanvasShellContent>
|
|
257
|
+
</CanvasShell>
|
|
258
|
+
</CanvasPanel>
|
|
259
|
+
),
|
|
260
|
+
};
|
|
261
|
+
|
|
262
|
+
/** Options button in the header: the canvas's secondary actions, download and rename, in a dropdown. */
|
|
263
|
+
export const WithOptions: DocumentPreviewStory = {
|
|
264
|
+
args: documentPreviewArgs,
|
|
265
|
+
render: (args) => <DocumentPreviewCanvas {...args} />,
|
|
266
|
+
};
|
|
267
|
+
|
|
268
|
+
/** The shell in each place it goes: a side panel beside the chat, and a full-height aside holding a chat of its own. */
|
|
269
|
+
export const Examples: Story = {
|
|
270
|
+
// The thread's scroll-to-latest button is wrapped in a Tooltip, which needs a TooltipProvider above it.
|
|
271
|
+
decorators: [withTooltip],
|
|
272
|
+
parameters: { controls: { disable: true } },
|
|
273
|
+
render: () => (
|
|
274
|
+
<div className="flex flex-col gap-24 p-16">
|
|
275
|
+
<ParentBlock parent="side panel beside the chat">
|
|
276
|
+
<div className="flex h-120 rounded-10 border border-divider-border-base">
|
|
277
|
+
<section aria-label="Chat" className="flex min-w-0 flex-1 flex-col gap-12 p-16">
|
|
278
|
+
<ChatMessage isQuestion>
|
|
279
|
+
<ChatMessageContent>Show my positions as a table</ChatMessageContent>
|
|
280
|
+
</ChatMessage>
|
|
281
|
+
<ChatMessage>
|
|
282
|
+
<ChatMessageContent>
|
|
283
|
+
Here are your 14 positions. The table is open in the panel.
|
|
284
|
+
</ChatMessageContent>
|
|
285
|
+
</ChatMessage>
|
|
286
|
+
</section>
|
|
287
|
+
|
|
288
|
+
<aside aria-label="Table" className="w-90 shrink-0 border-l border-divider-border-base">
|
|
289
|
+
<CanvasShell>
|
|
290
|
+
<CanvasShellHeader>
|
|
291
|
+
<CanvasShellTitle>Table</CanvasShellTitle>
|
|
292
|
+
<CanvasShellCloseTrigger />
|
|
293
|
+
</CanvasShellHeader>
|
|
294
|
+
<CanvasShellContent hasPadding={false}>
|
|
295
|
+
<HoldingsTable columns={HOLDING_COLUMNS} holdings={HOLDINGS} />
|
|
296
|
+
</CanvasShellContent>
|
|
297
|
+
</CanvasShell>
|
|
298
|
+
</aside>
|
|
299
|
+
</div>
|
|
300
|
+
</ParentBlock>
|
|
301
|
+
|
|
302
|
+
<ParentBlock parent="full-height aside">
|
|
303
|
+
<div className="h-120">
|
|
304
|
+
<aside
|
|
305
|
+
aria-label={TRIP_CHAT_TITLE}
|
|
306
|
+
className="h-full max-w-105 rounded-10 border border-divider-border-base"
|
|
307
|
+
>
|
|
308
|
+
<CanvasShell>
|
|
309
|
+
<CanvasShellHeader>
|
|
310
|
+
<CanvasShellTitle>{TRIP_CHAT_TITLE}</CanvasShellTitle>
|
|
311
|
+
<CanvasShellCloseTrigger />
|
|
312
|
+
</CanvasShellHeader>
|
|
313
|
+
|
|
314
|
+
<CanvasShellContent hasPadding={false} hasScroll={false}>
|
|
315
|
+
<ChatThreadProvider
|
|
316
|
+
conversationId="trip-chat"
|
|
317
|
+
groupIds={TRIP_CHAT_TURNS.map((turn) => turn.id)}
|
|
318
|
+
>
|
|
319
|
+
<ChatThread
|
|
320
|
+
className="h-full"
|
|
321
|
+
contentClassName={canvasShellContentPadding}
|
|
322
|
+
scrollButtonTooltip="Scroll to the latest"
|
|
323
|
+
>
|
|
324
|
+
{TRIP_CHAT_TURNS.map((turn) => (
|
|
325
|
+
<ChatThreadGroup key={turn.id} groupId={turn.id}>
|
|
326
|
+
<ChatThreadQuestion messageId={`${turn.id}-question`}>
|
|
327
|
+
<ChatMessage isQuestion>
|
|
328
|
+
<ChatMessageContent>{turn.question}</ChatMessageContent>
|
|
329
|
+
</ChatMessage>
|
|
330
|
+
</ChatThreadQuestion>
|
|
331
|
+
<ChatThreadAnswer messageId={`${turn.id}-answer`}>
|
|
332
|
+
<ChatMessage>
|
|
333
|
+
<ChatMessageContent>{turn.answer}</ChatMessageContent>
|
|
334
|
+
</ChatMessage>
|
|
335
|
+
</ChatThreadAnswer>
|
|
336
|
+
</ChatThreadGroup>
|
|
337
|
+
))}
|
|
338
|
+
</ChatThread>
|
|
339
|
+
</ChatThreadProvider>
|
|
340
|
+
</CanvasShellContent>
|
|
341
|
+
|
|
342
|
+
<CanvasShellFooter className="flex-col items-stretch">
|
|
343
|
+
<ChatSuggestions aria-label="Suggested questions">
|
|
344
|
+
{TRIP_CHAT_FOLLOW_UPS.map((text) => (
|
|
345
|
+
<ChatSuggestion key={text}>
|
|
346
|
+
<ChatSuggestionLabelIcon />
|
|
347
|
+
<ChatSuggestionLabel isMultiline={false}>{text}</ChatSuggestionLabel>
|
|
348
|
+
<ChatSuggestionActions>
|
|
349
|
+
<EnterIcon />
|
|
350
|
+
</ChatSuggestionActions>
|
|
351
|
+
</ChatSuggestion>
|
|
352
|
+
))}
|
|
353
|
+
</ChatSuggestions>
|
|
354
|
+
<ChatInput>
|
|
355
|
+
<ChatInputTextarea placeholder="How can I help?" />
|
|
356
|
+
</ChatInput>
|
|
357
|
+
</CanvasShellFooter>
|
|
358
|
+
</CanvasShell>
|
|
359
|
+
</aside>
|
|
360
|
+
</div>
|
|
361
|
+
</ParentBlock>
|
|
362
|
+
</div>
|
|
363
|
+
),
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
/** Picks an action from the options menu with the pointer, then opens and dismisses it from the keyboard. */
|
|
367
|
+
export const OptionsMenuPick: DocumentPreviewStory = {
|
|
368
|
+
tags: ['e2e', '!autodocs'],
|
|
369
|
+
args: { ...documentPreviewArgs, onDownload: fn(), onRename: fn() },
|
|
370
|
+
render: (args) => <DocumentPreviewCanvas {...args} />,
|
|
371
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
372
|
+
// The dropdown portals into document.body, outside the canvas.
|
|
373
|
+
const page = within(document.body);
|
|
374
|
+
const optionsButton = canvas.getByRole('button', { name: 'More options' });
|
|
375
|
+
|
|
376
|
+
await step('Runs the picked action and closes the menu', async () => {
|
|
377
|
+
await userEvent.click(optionsButton);
|
|
378
|
+
const menu = within(await page.findByRole('menu'));
|
|
379
|
+
await expect(menu.getByRole('menuitem', { name: 'Rename' })).toBeVisible();
|
|
380
|
+
|
|
381
|
+
await userEvent.click(menu.getByRole('menuitem', { name: 'Download' }));
|
|
382
|
+
|
|
383
|
+
await expect(args.onDownload).toHaveBeenCalledTimes(1);
|
|
384
|
+
await expect(args.onRename).not.toHaveBeenCalled();
|
|
385
|
+
await waitFor(() => expect(page.queryByRole('menu')).not.toBeInTheDocument());
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
await step('Opens with Enter; Escape closes it and returns focus to the button', async () => {
|
|
389
|
+
optionsButton.focus();
|
|
390
|
+
await userEvent.keyboard('{Enter}');
|
|
391
|
+
await expect(await page.findByRole('menu')).toBeVisible();
|
|
392
|
+
|
|
393
|
+
await userEvent.keyboard('{Escape}');
|
|
394
|
+
|
|
395
|
+
await waitFor(() => expect(page.queryByRole('menu')).not.toBeInTheDocument());
|
|
396
|
+
await expect(optionsButton).toHaveFocus();
|
|
397
|
+
await expect(args.onDownload).toHaveBeenCalledTimes(1);
|
|
398
|
+
});
|
|
104
399
|
},
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
/** Toggles full screen: the button reports the state and the host's panel, not the shell, changes width. */
|
|
403
|
+
export const FullScreenToggle: DocumentPreviewStory = {
|
|
404
|
+
tags: ['e2e', '!autodocs'],
|
|
405
|
+
args: { ...documentPreviewArgs, onClose: fn() },
|
|
406
|
+
render: (args) => <DocumentPreviewCanvas {...args} />,
|
|
407
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
408
|
+
const panel = canvas.getByRole('complementary', { name: 'Document preview' });
|
|
409
|
+
const panelWidth = panel.getBoundingClientRect().width;
|
|
410
|
+
|
|
411
|
+
await step('Enters full screen', async () => {
|
|
412
|
+
const enterButton = canvas.getByRole('button', { name: 'Full screen' });
|
|
413
|
+
await expect(enterButton).toHaveAttribute('aria-pressed', 'false');
|
|
414
|
+
|
|
415
|
+
await userEvent.click(enterButton);
|
|
416
|
+
|
|
417
|
+
const exitButton = canvas.getByRole('button', { name: 'Exit full screen' });
|
|
418
|
+
await expect(exitButton).toHaveAttribute('aria-pressed', 'true');
|
|
419
|
+
await expect(panel.getBoundingClientRect().width).toBeGreaterThan(panelWidth);
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
await step('Leaves full screen', async () => {
|
|
423
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Exit full screen' }));
|
|
424
|
+
|
|
425
|
+
await expect(canvas.getByRole('button', { name: 'Full screen' })).toHaveAttribute(
|
|
426
|
+
'aria-pressed',
|
|
427
|
+
'false',
|
|
428
|
+
);
|
|
429
|
+
await expect(panel.getBoundingClientRect().width).toBe(panelWidth);
|
|
430
|
+
});
|
|
431
|
+
|
|
432
|
+
await step('Leaves closing to the host', async () => {
|
|
433
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Close preview' }));
|
|
434
|
+
|
|
435
|
+
await expect(args.onClose).toHaveBeenCalledTimes(1);
|
|
436
|
+
await expect(panel).toBeVisible();
|
|
437
|
+
});
|
|
438
|
+
},
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
/** A title too long for the header is cut to one line, and every header button stays inside the panel. */
|
|
442
|
+
export const LongTitleKeepsButtons: DocumentPreviewStory = {
|
|
443
|
+
tags: ['e2e', '!autodocs'],
|
|
444
|
+
args: { ...documentPreviewArgs, filename: LONG_PREVIEW_FILENAME },
|
|
445
|
+
render: (args) => <DocumentPreviewCanvas {...args} />,
|
|
446
|
+
play: async ({ canvas }) => {
|
|
447
|
+
const panel = canvas.getByRole('complementary', { name: 'Document preview' });
|
|
448
|
+
const title = canvas.getByText(LONG_PREVIEW_FILENAME);
|
|
449
|
+
|
|
450
|
+
await expect(title.scrollWidth).toBeGreaterThan(title.clientWidth);
|
|
451
|
+
|
|
452
|
+
const panelRight = panel.getBoundingClientRect().right;
|
|
453
|
+
for (const name of ['More options', 'Full screen', 'Close preview']) {
|
|
454
|
+
const button = canvas.getByRole('button', { name });
|
|
455
|
+
await expect(button).toBeVisible();
|
|
456
|
+
await expect(button.getBoundingClientRect().right).toBeLessThanOrEqual(panelRight);
|
|
457
|
+
}
|
|
458
|
+
},
|
|
459
|
+
};
|
|
460
|
+
|
|
461
|
+
/** A list longer than the panel scrolls inside the content region: the shell keeps its parent's height and the header stays put. */
|
|
462
|
+
export const LongContentScrolls: DocumentsLibraryStory = {
|
|
463
|
+
tags: ['e2e', '!autodocs'],
|
|
464
|
+
args: { onClose: fn() },
|
|
465
|
+
render: (args) => <DocumentsLibraryCanvas {...args} />,
|
|
466
|
+
play: async ({ canvas, canvasElement, step }) => {
|
|
467
|
+
const panel = canvas.getByRole('complementary', { name: 'Documents' });
|
|
468
|
+
const shell = canvasElement.querySelector<HTMLElement>('[data-slot="canvas-shell"]');
|
|
469
|
+
const body = canvasElement.querySelector<HTMLElement>(
|
|
470
|
+
'[data-slot="canvas-shell-content-body"]',
|
|
471
|
+
);
|
|
472
|
+
if (!shell || !body) throw new Error('The shell did not render its content region');
|
|
473
|
+
|
|
474
|
+
const title = canvas.getByText('Documents');
|
|
475
|
+
const lastDocument = canvas.getByText(LIBRARY_DOCUMENTS[LIBRARY_DOCUMENTS.length - 1].name);
|
|
476
|
+
|
|
477
|
+
await step('The shell is as tall as its parent, not as its content', async () => {
|
|
478
|
+
await expect(shell.getBoundingClientRect().height).toBe(panel.getBoundingClientRect().height);
|
|
479
|
+
await expect(body.scrollHeight).toBeGreaterThan(body.clientHeight);
|
|
480
|
+
});
|
|
481
|
+
|
|
482
|
+
await step(
|
|
483
|
+
'Scrolling the region reaches the last row and leaves the header in place',
|
|
484
|
+
async () => {
|
|
485
|
+
const titleTop = title.getBoundingClientRect().top;
|
|
486
|
+
const panelBottom = panel.getBoundingClientRect().bottom;
|
|
487
|
+
await expect(lastDocument.getBoundingClientRect().top).toBeGreaterThan(panelBottom);
|
|
488
|
+
|
|
489
|
+
body.scrollTo({ top: body.scrollHeight });
|
|
490
|
+
|
|
491
|
+
await waitFor(() =>
|
|
492
|
+
expect(lastDocument.getBoundingClientRect().bottom).toBeLessThanOrEqual(panelBottom),
|
|
493
|
+
);
|
|
494
|
+
await expect(title.getBoundingClientRect().top).toBe(titleTop);
|
|
495
|
+
},
|
|
496
|
+
);
|
|
497
|
+
},
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
interface CanvasShellPlaygroundProps {
|
|
501
|
+
title: string;
|
|
502
|
+
itemCount: number;
|
|
503
|
+
hasBorder: boolean;
|
|
504
|
+
hasOptions: boolean;
|
|
505
|
+
hasFullScreenTrigger: boolean;
|
|
506
|
+
hasPadding: boolean;
|
|
507
|
+
hasScroll: boolean;
|
|
508
|
+
hasWideContent: boolean;
|
|
509
|
+
hasFooter: boolean;
|
|
510
|
+
onOption: (option: string) => void;
|
|
511
|
+
onOptionsOpenChange: (isOpen: boolean) => void;
|
|
512
|
+
onClose: () => void;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
function CanvasShellPlayground({
|
|
516
|
+
title,
|
|
517
|
+
itemCount,
|
|
518
|
+
hasBorder,
|
|
519
|
+
hasOptions,
|
|
520
|
+
hasFullScreenTrigger,
|
|
521
|
+
hasPadding,
|
|
522
|
+
hasScroll,
|
|
523
|
+
hasWideContent,
|
|
524
|
+
hasFooter,
|
|
525
|
+
onOption,
|
|
526
|
+
onOptionsOpenChange,
|
|
527
|
+
onClose,
|
|
528
|
+
}: CanvasShellPlaygroundProps) {
|
|
529
|
+
const [isFullScreen, setIsFullScreen] = useState(false);
|
|
530
|
+
|
|
531
|
+
return (
|
|
532
|
+
<CanvasPanel label={title} isFullScreen={isFullScreen}>
|
|
533
|
+
<CanvasShell>
|
|
534
|
+
<CanvasShellHeader hasBorder={hasBorder}>
|
|
535
|
+
<CanvasShellTitle>{title}</CanvasShellTitle>
|
|
536
|
+
{hasOptions && (
|
|
537
|
+
<CanvasShellOptionsButton onOpenChange={onOptionsOpenChange}>
|
|
538
|
+
<DropdownMenuList>
|
|
539
|
+
<DropdownMenuListItem onClick={() => onOption('download')}>
|
|
540
|
+
<MenuItemIcon>
|
|
541
|
+
<DownloadIcon className="size-20" />
|
|
542
|
+
</MenuItemIcon>
|
|
543
|
+
<MenuItemLabel>Download</MenuItemLabel>
|
|
544
|
+
</DropdownMenuListItem>
|
|
545
|
+
<DropdownMenuListItem onClick={() => onOption('rename')}>
|
|
546
|
+
<MenuItemIcon>
|
|
547
|
+
<EditIcon className="size-20" />
|
|
548
|
+
</MenuItemIcon>
|
|
549
|
+
<MenuItemLabel>Rename</MenuItemLabel>
|
|
550
|
+
</DropdownMenuListItem>
|
|
551
|
+
</DropdownMenuList>
|
|
552
|
+
</CanvasShellOptionsButton>
|
|
553
|
+
)}
|
|
554
|
+
{hasFullScreenTrigger && (
|
|
555
|
+
<CanvasShellFullScreenTrigger
|
|
556
|
+
isFullScreen={isFullScreen}
|
|
557
|
+
onClick={() => setIsFullScreen((current) => !current)}
|
|
558
|
+
/>
|
|
559
|
+
)}
|
|
560
|
+
<CanvasShellCloseTrigger onClick={onClose} />
|
|
561
|
+
</CanvasShellHeader>
|
|
562
|
+
|
|
563
|
+
<CanvasShellContent hasPadding={hasPadding} hasScroll={hasScroll}>
|
|
564
|
+
<DocumentList
|
|
565
|
+
documents={LIBRARY_DOCUMENTS.slice(0, itemCount)}
|
|
566
|
+
className={hasWideContent ? 'w-225' : undefined}
|
|
567
|
+
/>
|
|
568
|
+
</CanvasShellContent>
|
|
569
|
+
|
|
570
|
+
{hasFooter && (
|
|
571
|
+
<CanvasShellFooter>
|
|
572
|
+
<Button variant="secondary" onClick={onClose}>
|
|
573
|
+
Cancel
|
|
574
|
+
</Button>
|
|
575
|
+
<Button onClick={() => onOption('download-all')}>Download all</Button>
|
|
576
|
+
</CanvasShellFooter>
|
|
577
|
+
)}
|
|
578
|
+
</CanvasShell>
|
|
579
|
+
</CanvasPanel>
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/** Every part of the shell at once, with each part and prop on the Controls panel. */
|
|
584
|
+
export const Playground: StoryObj<typeof CanvasShellPlayground> = {
|
|
585
|
+
tags: ['!autodocs'],
|
|
113
586
|
args: {
|
|
114
|
-
title: '
|
|
115
|
-
itemCount:
|
|
587
|
+
title: 'Documents',
|
|
588
|
+
itemCount: LIBRARY_DOCUMENTS.length,
|
|
589
|
+
hasBorder: true,
|
|
590
|
+
hasOptions: true,
|
|
591
|
+
hasFullScreenTrigger: true,
|
|
592
|
+
hasPadding: true,
|
|
116
593
|
hasScroll: true,
|
|
117
594
|
hasWideContent: false,
|
|
118
595
|
hasFooter: true,
|
|
119
|
-
hasOptions: false,
|
|
120
|
-
onClose: fn(),
|
|
121
596
|
onOption: fn(),
|
|
597
|
+
onOptionsOpenChange: fn(),
|
|
598
|
+
onClose: fn(),
|
|
122
599
|
},
|
|
123
600
|
argTypes: {
|
|
124
601
|
title: {
|
|
125
602
|
control: 'text',
|
|
126
|
-
description: '
|
|
603
|
+
description: 'Text of `CanvasShellTitle`. It truncates to one line when too long.',
|
|
127
604
|
},
|
|
128
605
|
itemCount: {
|
|
129
|
-
control: { type: 'number', min: 0, max:
|
|
130
|
-
description: 'Number of
|
|
606
|
+
control: { type: 'number', min: 0, max: LIBRARY_DOCUMENTS.length },
|
|
607
|
+
description: 'Number of documents in `CanvasShellContent`.',
|
|
608
|
+
},
|
|
609
|
+
hasBorder: {
|
|
610
|
+
control: 'boolean',
|
|
611
|
+
description: '`hasBorder` on `CanvasShellHeader`: the separator under the header.',
|
|
612
|
+
},
|
|
613
|
+
hasOptions: {
|
|
614
|
+
control: 'boolean',
|
|
615
|
+
description: 'Renders `CanvasShellOptionsButton` with a dropdown of actions.',
|
|
616
|
+
},
|
|
617
|
+
hasFullScreenTrigger: {
|
|
618
|
+
control: 'boolean',
|
|
619
|
+
description:
|
|
620
|
+
'Renders `CanvasShellFullScreenTrigger`. It is hidden below the `md` breakpoint whatever this says.',
|
|
621
|
+
},
|
|
622
|
+
hasPadding: {
|
|
623
|
+
control: 'boolean',
|
|
624
|
+
description:
|
|
625
|
+
'`hasPadding` on `CanvasShellContent`: the horizontal padding. Off for edge-to-edge children.',
|
|
131
626
|
},
|
|
132
627
|
hasScroll: {
|
|
133
628
|
control: 'boolean',
|
|
134
629
|
description:
|
|
135
|
-
'
|
|
136
|
-
table: { defaultValue: { summary: 'true' } },
|
|
630
|
+
'`hasScroll` on `CanvasShellContent`: scroll what overflows, on either axis. Off clips it, for children that scroll themselves.',
|
|
137
631
|
},
|
|
138
632
|
hasWideContent: {
|
|
139
633
|
control: 'boolean',
|
|
140
|
-
description: '
|
|
634
|
+
description: 'Makes the list wider than the shell, to show horizontal scrolling.',
|
|
141
635
|
},
|
|
142
636
|
hasFooter: {
|
|
143
637
|
control: 'boolean',
|
|
144
|
-
description: '
|
|
145
|
-
},
|
|
146
|
-
hasOptions: {
|
|
147
|
-
control: 'boolean',
|
|
148
|
-
description: 'Render the options (⋯) button with a dropdown of actions.',
|
|
638
|
+
description: 'Renders `CanvasShellFooter` with its two actions.',
|
|
149
639
|
},
|
|
150
640
|
onOption: {
|
|
151
|
-
|
|
152
|
-
|
|
641
|
+
description: 'Called with the id of the picked menu item or footer action.',
|
|
642
|
+
},
|
|
643
|
+
onOptionsOpenChange: {
|
|
644
|
+
description: '`onOpenChange` on `CanvasShellOptionsButton`: the menu opened or closed.',
|
|
153
645
|
},
|
|
154
646
|
onClose: {
|
|
155
|
-
|
|
156
|
-
description: 'Called when the close button is pressed.',
|
|
647
|
+
description: '`onClick` on `CanvasShellCloseTrigger`, and on the footer Cancel button.',
|
|
157
648
|
},
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
type Story = StoryObj<typeof CanvasShellStory>;
|
|
163
|
-
|
|
164
|
-
export const Default: Story = {};
|
|
165
|
-
|
|
166
|
-
/** A title longer than the header: it truncates instead of pushing the close button out. */
|
|
167
|
-
export const LongTitle: Story = {
|
|
168
|
-
args: {
|
|
169
|
-
title: 'A very long canvas title that does not fit in the header on a narrow panel',
|
|
170
|
-
},
|
|
171
|
-
};
|
|
172
|
-
|
|
173
|
-
/** No footer: the content region extends to the bottom of the shell. */
|
|
174
|
-
export const WithoutFooter: Story = {
|
|
175
|
-
args: {
|
|
176
|
-
hasFooter: false,
|
|
177
|
-
},
|
|
649
|
+
children: { table: { disable: true } },
|
|
650
|
+
className: { table: { disable: true } },
|
|
651
|
+
} as StoryObj<typeof CanvasShellPlayground>['argTypes'],
|
|
652
|
+
render: (args) => <CanvasShellPlayground {...args} />,
|
|
178
653
|
};
|
|
179
|
-
|
|
180
|
-
/** Content wider and taller than the shell: it scrolls on both axes instead of growing the shell. */
|
|
181
|
-
export const WideContent: Story = {
|
|
182
|
-
args: {
|
|
183
|
-
hasWideContent: true,
|
|
184
|
-
},
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
/** Options button in the header: opens a dropdown of canvas actions. */
|
|
188
|
-
export const WithOptions: Story = {
|
|
189
|
-
args: {
|
|
190
|
-
hasOptions: true,
|
|
191
|
-
},
|
|
192
|
-
};
|
|
193
|
-
|
|
194
|
-
export const Playground: Story = {};
|