@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,18 +1,40 @@
|
|
|
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 {
|
|
5
|
+
import {
|
|
6
|
+
MenuIcon,
|
|
7
|
+
NotificationsIcon,
|
|
8
|
+
NotificationsMarkedIcon,
|
|
9
|
+
SettingsIcon,
|
|
10
|
+
ShareIcon,
|
|
11
|
+
WalletIcon,
|
|
12
|
+
} from '@swisper.ai/icons';
|
|
13
|
+
import { Button, IconButton, Typography } from '@swisper.ai/ui';
|
|
14
|
+
|
|
15
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
6
16
|
|
|
17
|
+
import { NOTIFICATIONS } from './__stories__/fixtures';
|
|
18
|
+
import { NotificationItem } from './__stories__/notification-item';
|
|
19
|
+
import type { NotificationSignal } from './__stories__/types';
|
|
7
20
|
import {
|
|
8
21
|
ChatNotificationPopup,
|
|
9
22
|
ChatNotificationPopupContent,
|
|
10
23
|
ChatNotificationPopupTrigger,
|
|
24
|
+
type ChatNotificationPopupContentProps,
|
|
25
|
+
type ChatNotificationPopupProps,
|
|
11
26
|
} from './chat-notification-popup';
|
|
12
27
|
|
|
13
28
|
const meta: Meta<typeof ChatNotificationPopup> = {
|
|
14
|
-
title: '
|
|
29
|
+
title: 'Chat/ChatNotificationPopup',
|
|
15
30
|
component: ChatNotificationPopup,
|
|
31
|
+
subcomponents: { ChatNotificationPopupTrigger, ChatNotificationPopupContent },
|
|
32
|
+
parameters: {
|
|
33
|
+
layout: 'padded',
|
|
34
|
+
// Several stories render the popup open, and it portals into document.body. Rendering each
|
|
35
|
+
// docs story in its own iframe keeps the open popup inside its canvas.
|
|
36
|
+
docs: { story: { inline: false, height: '560px' } },
|
|
37
|
+
},
|
|
16
38
|
tags: ['autodocs'],
|
|
17
39
|
argTypes: {
|
|
18
40
|
defaultOpen: {
|
|
@@ -51,30 +73,458 @@ const meta: Meta<typeof ChatNotificationPopup> = {
|
|
|
51
73
|
export default meta;
|
|
52
74
|
type Story = StoryObj<typeof ChatNotificationPopup>;
|
|
53
75
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
76
|
+
interface NotificationCentreProps extends Omit<ChatNotificationPopupProps, 'children'> {
|
|
77
|
+
notifications: NotificationSignal[];
|
|
78
|
+
onRead?: (id: string) => void;
|
|
79
|
+
onMarkAllAsViewed?: () => void;
|
|
80
|
+
onAction?: (notification: NotificationSignal, action: string) => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function NotificationCentre({
|
|
84
|
+
notifications,
|
|
85
|
+
open,
|
|
86
|
+
onRead,
|
|
87
|
+
onMarkAllAsViewed,
|
|
88
|
+
onAction,
|
|
89
|
+
...rootProps
|
|
90
|
+
}: NotificationCentreProps) {
|
|
91
|
+
const [readIds, setReadIds] = useState(() =>
|
|
92
|
+
notifications.filter((notification) => notification.isRead).map(({ id }) => id),
|
|
93
|
+
);
|
|
94
|
+
const unreadCount = notifications.length - readIds.length;
|
|
95
|
+
|
|
96
|
+
const markAsRead = (id: string) => {
|
|
97
|
+
if (readIds.includes(id)) {
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
setReadIds([...readIds, id]);
|
|
102
|
+
onRead?.(id);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const markAllAsViewed = () => {
|
|
106
|
+
setReadIds(notifications.map(({ id }) => id));
|
|
107
|
+
onMarkAllAsViewed?.();
|
|
108
|
+
};
|
|
109
|
+
|
|
110
|
+
return (
|
|
111
|
+
<ChatNotificationPopup open={open} {...rootProps}>
|
|
57
112
|
<ChatNotificationPopupTrigger asChild>
|
|
58
|
-
<
|
|
113
|
+
<IconButton
|
|
114
|
+
variant="tertiary"
|
|
115
|
+
aria-label={unreadCount > 0 ? `Notifications, ${unreadCount} unread` : 'Notifications'}
|
|
116
|
+
isActive={open ?? false}
|
|
117
|
+
>
|
|
118
|
+
{unreadCount > 0 ? <NotificationsMarkedIcon /> : <NotificationsIcon />}
|
|
119
|
+
</IconButton>
|
|
59
120
|
</ChatNotificationPopupTrigger>
|
|
60
121
|
|
|
61
|
-
<ChatNotificationPopupContent
|
|
122
|
+
<ChatNotificationPopupContent
|
|
123
|
+
align="end"
|
|
124
|
+
aria-label="Notification centre"
|
|
125
|
+
className="flex max-h-120 flex-col gap-8 p-16"
|
|
126
|
+
>
|
|
127
|
+
<div className="flex shrink-0 justify-end">
|
|
128
|
+
<Button variant="tertiary" isDisabled={unreadCount === 0} onClick={markAllAsViewed}>
|
|
129
|
+
Mark all as viewed
|
|
130
|
+
</Button>
|
|
131
|
+
</div>
|
|
132
|
+
<ul className="flex min-h-0 flex-col gap-8 overflow-y-auto">
|
|
133
|
+
{notifications.map((notification, index) => (
|
|
134
|
+
<li key={notification.id}>
|
|
135
|
+
<NotificationItem
|
|
136
|
+
notification={notification}
|
|
137
|
+
isRead={readIds.includes(notification.id)}
|
|
138
|
+
// The newest notification opens expanded, so its follow-ups are one click away.
|
|
139
|
+
isDefaultExpanded={index === 0}
|
|
140
|
+
onRead={() => markAsRead(notification.id)}
|
|
141
|
+
onAction={(action) => {
|
|
142
|
+
markAsRead(notification.id);
|
|
143
|
+
onAction?.(notification, action);
|
|
144
|
+
}}
|
|
145
|
+
/>
|
|
146
|
+
</li>
|
|
147
|
+
))}
|
|
148
|
+
</ul>
|
|
149
|
+
</ChatNotificationPopupContent>
|
|
62
150
|
</ChatNotificationPopup>
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The notification centre opened from the bell in the chat header: the trigger shows there is
|
|
156
|
+
* something unread, and the popup lists the notifications over the chat.
|
|
157
|
+
*/
|
|
158
|
+
export const Default: Story = {
|
|
159
|
+
args: { defaultOpen: true },
|
|
160
|
+
render: (args) => (
|
|
161
|
+
<div className="flex justify-end">
|
|
162
|
+
<NotificationCentre notifications={NOTIFICATIONS} {...args} />
|
|
163
|
+
</div>
|
|
63
164
|
),
|
|
64
165
|
};
|
|
65
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Open state owned by the parent, so the bell stays active while the popup is open and a follow-up
|
|
169
|
+
* action can close it before the chat it starts takes over.
|
|
170
|
+
*/
|
|
66
171
|
export const Controlled: Story = {
|
|
67
|
-
render: (args)
|
|
68
|
-
const [
|
|
172
|
+
render: function Render({ onOpenChange, ...args }) {
|
|
173
|
+
const [isOpen, setIsOpen] = useState(true);
|
|
69
174
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
</ChatNotificationPopupTrigger>
|
|
175
|
+
const changeOpen = (next: boolean) => {
|
|
176
|
+
setIsOpen(next);
|
|
177
|
+
onOpenChange?.(next);
|
|
178
|
+
};
|
|
75
179
|
|
|
76
|
-
|
|
77
|
-
|
|
180
|
+
return (
|
|
181
|
+
<div className="flex justify-end">
|
|
182
|
+
<NotificationCentre
|
|
183
|
+
{...args}
|
|
184
|
+
notifications={NOTIFICATIONS}
|
|
185
|
+
open={isOpen}
|
|
186
|
+
onOpenChange={changeOpen}
|
|
187
|
+
onAction={() => changeOpen(false)}
|
|
188
|
+
/>
|
|
189
|
+
</div>
|
|
78
190
|
);
|
|
79
191
|
},
|
|
80
192
|
};
|
|
193
|
+
|
|
194
|
+
/** The bell in each place the popup opens from: the chat header, an app top bar and a toolbar. */
|
|
195
|
+
export const Examples: Story = {
|
|
196
|
+
parameters: { controls: { disable: true } },
|
|
197
|
+
render: () => (
|
|
198
|
+
<div className="flex max-w-180 flex-col gap-24">
|
|
199
|
+
<ParentBlock parent="chat header">
|
|
200
|
+
<header
|
|
201
|
+
aria-label="Chat header"
|
|
202
|
+
className="flex items-center gap-8 rounded-10 border border-component-divider px-12 py-8"
|
|
203
|
+
>
|
|
204
|
+
<IconButton variant="tertiary" aria-label="Open side menu">
|
|
205
|
+
<MenuIcon />
|
|
206
|
+
</IconButton>
|
|
207
|
+
<Typography variant="body-sm" fontWeight="medium" className="min-w-0 flex-1 truncate">
|
|
208
|
+
Edinburgh trip in May
|
|
209
|
+
</Typography>
|
|
210
|
+
<IconButton variant="tertiary" aria-label="Share conversation">
|
|
211
|
+
<ShareIcon />
|
|
212
|
+
</IconButton>
|
|
213
|
+
<NotificationCentre notifications={NOTIFICATIONS} />
|
|
214
|
+
</header>
|
|
215
|
+
</ParentBlock>
|
|
216
|
+
|
|
217
|
+
<ParentBlock parent="app top bar">
|
|
218
|
+
<header
|
|
219
|
+
aria-label="App top bar"
|
|
220
|
+
className="flex items-center gap-8 rounded-10 border border-component-divider px-16 py-8"
|
|
221
|
+
>
|
|
222
|
+
<Typography variant="body-sm" fontWeight="semibold" className="flex-1">
|
|
223
|
+
Swisper
|
|
224
|
+
</Typography>
|
|
225
|
+
<NotificationCentre notifications={NOTIFICATIONS.slice(0, 2)} />
|
|
226
|
+
<IconButton variant="tertiary" aria-label="Settings">
|
|
227
|
+
<SettingsIcon />
|
|
228
|
+
</IconButton>
|
|
229
|
+
</header>
|
|
230
|
+
</ParentBlock>
|
|
231
|
+
|
|
232
|
+
<ParentBlock parent="toolbar">
|
|
233
|
+
<div
|
|
234
|
+
role="toolbar"
|
|
235
|
+
aria-label="Chat actions"
|
|
236
|
+
className="flex w-fit items-center gap-4 self-end rounded-10 border border-component-divider p-4"
|
|
237
|
+
>
|
|
238
|
+
<IconButton variant="tertiary" aria-label="Open wallet">
|
|
239
|
+
<WalletIcon />
|
|
240
|
+
</IconButton>
|
|
241
|
+
<IconButton variant="tertiary" aria-label="Share conversation">
|
|
242
|
+
<ShareIcon />
|
|
243
|
+
</IconButton>
|
|
244
|
+
{/* Everything here is already read, so the bell carries no unread mark. */}
|
|
245
|
+
<NotificationCentre notifications={NOTIFICATIONS.slice(2)} />
|
|
246
|
+
</div>
|
|
247
|
+
</ParentBlock>
|
|
248
|
+
</div>
|
|
249
|
+
),
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
type NotificationCentreStory = StoryObj<typeof NotificationCentre>;
|
|
253
|
+
|
|
254
|
+
/** Opens from the bell, and closes on Escape with focus back on the bell. */
|
|
255
|
+
export const OpenAndCloseWithKeyboard: NotificationCentreStory = {
|
|
256
|
+
tags: ['e2e', '!autodocs'],
|
|
257
|
+
args: { notifications: NOTIFICATIONS, onOpenChange: fn() },
|
|
258
|
+
render: (args) => (
|
|
259
|
+
<div className="flex justify-end">
|
|
260
|
+
<NotificationCentre {...args} />
|
|
261
|
+
</div>
|
|
262
|
+
),
|
|
263
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
264
|
+
// The popup portals into document.body, outside the canvas.
|
|
265
|
+
const page = within(document.body);
|
|
266
|
+
const trigger = canvas.getByRole('button', { name: 'Notifications, 2 unread' });
|
|
267
|
+
|
|
268
|
+
await step('The bell opens the popup and reports it', async () => {
|
|
269
|
+
await expect(page.queryByRole('dialog')).not.toBeInTheDocument();
|
|
270
|
+
await userEvent.click(trigger);
|
|
271
|
+
const popup = await page.findByRole('dialog', { name: 'Notification centre' });
|
|
272
|
+
// The popup fades in from opacity 0, which toBeVisible treats as hidden.
|
|
273
|
+
await waitFor(() => expect(popup).toBeVisible());
|
|
274
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'true');
|
|
275
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(true);
|
|
276
|
+
});
|
|
277
|
+
|
|
278
|
+
await step('Escape closes it and returns focus to the bell', async () => {
|
|
279
|
+
await userEvent.keyboard('{Escape}');
|
|
280
|
+
await waitFor(() => expect(page.queryByRole('dialog')).not.toBeInTheDocument());
|
|
281
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(false);
|
|
282
|
+
await expect(trigger).toHaveFocus();
|
|
283
|
+
});
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
/** Reading notifications inside the popup updates the bell, and the popup stays open. */
|
|
288
|
+
export const MarksNotificationsAsRead: NotificationCentreStory = {
|
|
289
|
+
tags: ['e2e', '!autodocs'],
|
|
290
|
+
args: {
|
|
291
|
+
notifications: NOTIFICATIONS,
|
|
292
|
+
defaultOpen: true,
|
|
293
|
+
onRead: fn(),
|
|
294
|
+
onMarkAllAsViewed: fn(),
|
|
295
|
+
},
|
|
296
|
+
render: (args) => (
|
|
297
|
+
<div className="flex justify-end">
|
|
298
|
+
<NotificationCentre {...args} />
|
|
299
|
+
</div>
|
|
300
|
+
),
|
|
301
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
302
|
+
const page = within(document.body);
|
|
303
|
+
const popup = within(await page.findByRole('dialog', { name: 'Notification centre' }));
|
|
304
|
+
|
|
305
|
+
await step('Marking one as read lowers the count on the bell', async () => {
|
|
306
|
+
await userEvent.click(
|
|
307
|
+
popup.getByRole('button', {
|
|
308
|
+
name: 'Mark as read: Online check-in is open for Hotel Seeblick',
|
|
309
|
+
}),
|
|
310
|
+
);
|
|
311
|
+
await expect(args.onRead).toHaveBeenCalledWith('ntf_02');
|
|
312
|
+
// While the popup is open the page behind it is hidden from assistive technology.
|
|
313
|
+
await expect(
|
|
314
|
+
canvas.getByRole('button', { name: 'Notifications, 1 unread', hidden: true }),
|
|
315
|
+
).toBeInTheDocument();
|
|
316
|
+
});
|
|
317
|
+
|
|
318
|
+
await step('Mark all as viewed clears the count and disables itself', async () => {
|
|
319
|
+
const markAll = popup.getByRole('button', { name: 'Mark all as viewed' });
|
|
320
|
+
await userEvent.click(markAll);
|
|
321
|
+
await expect(args.onMarkAllAsViewed).toHaveBeenCalledTimes(1);
|
|
322
|
+
await expect(markAll).toBeDisabled();
|
|
323
|
+
await expect(
|
|
324
|
+
canvas.getByRole('button', { name: 'Notifications', hidden: true }),
|
|
325
|
+
).toBeInTheDocument();
|
|
326
|
+
await expect(page.getByRole('dialog', { name: 'Notification centre' })).toBeVisible();
|
|
327
|
+
});
|
|
328
|
+
},
|
|
329
|
+
};
|
|
330
|
+
|
|
331
|
+
/** A click outside the non-modal popup closes it, so the chat chrome beside the bell stays usable. */
|
|
332
|
+
export const ClosesOnOutsideClick: NotificationCentreStory = {
|
|
333
|
+
tags: ['e2e', '!autodocs'],
|
|
334
|
+
args: { notifications: NOTIFICATIONS, defaultOpen: true, onOpenChange: fn() },
|
|
335
|
+
render: (args) => (
|
|
336
|
+
<div className="flex items-center justify-between">
|
|
337
|
+
<IconButton variant="tertiary" aria-label="Open side menu">
|
|
338
|
+
<MenuIcon />
|
|
339
|
+
</IconButton>
|
|
340
|
+
<NotificationCentre {...args} />
|
|
341
|
+
</div>
|
|
342
|
+
),
|
|
343
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
344
|
+
const page = within(document.body);
|
|
345
|
+
|
|
346
|
+
await step('It starts open', async () => {
|
|
347
|
+
const popup = await page.findByRole('dialog', { name: 'Notification centre' });
|
|
348
|
+
await waitFor(() => expect(popup).toBeVisible());
|
|
349
|
+
});
|
|
350
|
+
|
|
351
|
+
await step('Clicking a button beside the bell closes it', async () => {
|
|
352
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Open side menu', hidden: true }));
|
|
353
|
+
await waitFor(() => expect(page.queryByRole('dialog')).not.toBeInTheDocument());
|
|
354
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(false);
|
|
355
|
+
});
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
/** A follow-up action in a controlled popup marks the notification as read and closes the popup. */
|
|
360
|
+
export const ControlledClosesAfterAction: Story = {
|
|
361
|
+
tags: ['e2e', '!autodocs'],
|
|
362
|
+
render: Controlled.render,
|
|
363
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
364
|
+
const page = within(document.body);
|
|
365
|
+
const popup = await page.findByRole('dialog', { name: 'Notification centre' });
|
|
366
|
+
|
|
367
|
+
await step('It starts open, with the bell marked as expanded', async () => {
|
|
368
|
+
await waitFor(() => expect(popup).toBeVisible());
|
|
369
|
+
await expect(
|
|
370
|
+
canvas.getByRole('button', { name: 'Notifications, 2 unread', hidden: true }),
|
|
371
|
+
).toHaveAttribute('aria-expanded', 'true');
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
await step('Choosing a follow-up closes the popup', async () => {
|
|
375
|
+
await userEvent.click(within(popup).getByRole('button', { name: 'Find an earlier flight' }));
|
|
376
|
+
await waitFor(() => expect(page.queryByRole('dialog')).not.toBeInTheDocument());
|
|
377
|
+
await expect(args.onOpenChange).toHaveBeenLastCalledWith(false);
|
|
378
|
+
const trigger = canvas.getByRole('button', { name: 'Notifications, 1 unread' });
|
|
379
|
+
await expect(trigger).toHaveAttribute('aria-expanded', 'false');
|
|
380
|
+
await expect(trigger).toHaveFocus();
|
|
381
|
+
});
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
|
|
385
|
+
interface ChatNotificationPopupPlaygroundProps
|
|
386
|
+
extends
|
|
387
|
+
Omit<ChatNotificationPopupProps, 'children'>,
|
|
388
|
+
Pick<ChatNotificationPopupContentProps, 'side' | 'align' | 'sideOffset'> {
|
|
389
|
+
triggerLabel: string;
|
|
390
|
+
title: string;
|
|
391
|
+
notificationCount: number;
|
|
392
|
+
hasUnreadMark: boolean;
|
|
393
|
+
hasMarkAllAction: boolean;
|
|
394
|
+
hasFollowUpActions: boolean;
|
|
395
|
+
onRead: (id: string) => void;
|
|
396
|
+
onMarkAllAsViewed: () => void;
|
|
397
|
+
onAction: (action: string) => void;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/** The notification centre with every allowed child in it, each switchable from the Controls panel. */
|
|
401
|
+
function ChatNotificationPopupPlayground({
|
|
402
|
+
triggerLabel,
|
|
403
|
+
title,
|
|
404
|
+
notificationCount,
|
|
405
|
+
side,
|
|
406
|
+
align,
|
|
407
|
+
sideOffset,
|
|
408
|
+
hasUnreadMark,
|
|
409
|
+
hasMarkAllAction,
|
|
410
|
+
hasFollowUpActions,
|
|
411
|
+
onRead,
|
|
412
|
+
onMarkAllAsViewed,
|
|
413
|
+
onAction,
|
|
414
|
+
...rootProps
|
|
415
|
+
}: ChatNotificationPopupPlaygroundProps) {
|
|
416
|
+
return (
|
|
417
|
+
<ChatNotificationPopup {...rootProps}>
|
|
418
|
+
<ChatNotificationPopupTrigger asChild>
|
|
419
|
+
<IconButton variant="tertiary" aria-label={triggerLabel}>
|
|
420
|
+
{hasUnreadMark ? <NotificationsMarkedIcon /> : <NotificationsIcon />}
|
|
421
|
+
</IconButton>
|
|
422
|
+
</ChatNotificationPopupTrigger>
|
|
423
|
+
|
|
424
|
+
<ChatNotificationPopupContent
|
|
425
|
+
side={side}
|
|
426
|
+
align={align}
|
|
427
|
+
sideOffset={sideOffset}
|
|
428
|
+
aria-label={title}
|
|
429
|
+
className="flex max-h-120 flex-col gap-8 p-16"
|
|
430
|
+
>
|
|
431
|
+
{hasMarkAllAction && (
|
|
432
|
+
<div className="flex shrink-0 justify-end">
|
|
433
|
+
<Button variant="tertiary" isDisabled={!hasUnreadMark} onClick={onMarkAllAsViewed}>
|
|
434
|
+
Mark all as viewed
|
|
435
|
+
</Button>
|
|
436
|
+
</div>
|
|
437
|
+
)}
|
|
438
|
+
<ul className="flex min-h-0 flex-col gap-8 overflow-y-auto">
|
|
439
|
+
{NOTIFICATIONS.slice(0, notificationCount).map((notification, index) => (
|
|
440
|
+
<li key={notification.id}>
|
|
441
|
+
<NotificationItem
|
|
442
|
+
notification={notification}
|
|
443
|
+
isRead={!hasUnreadMark || notification.isRead}
|
|
444
|
+
isDefaultExpanded={index === 0}
|
|
445
|
+
hasActions={hasFollowUpActions}
|
|
446
|
+
onRead={() => onRead(notification.id)}
|
|
447
|
+
onAction={onAction}
|
|
448
|
+
/>
|
|
449
|
+
</li>
|
|
450
|
+
))}
|
|
451
|
+
</ul>
|
|
452
|
+
</ChatNotificationPopupContent>
|
|
453
|
+
</ChatNotificationPopup>
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
/** Every allowed child in one popup, with each part and prop on the Controls panel. */
|
|
458
|
+
export const Playground: StoryObj<typeof ChatNotificationPopupPlayground> = {
|
|
459
|
+
tags: ['!autodocs'],
|
|
460
|
+
args: {
|
|
461
|
+
triggerLabel: 'Notifications, 2 unread',
|
|
462
|
+
title: 'Notification centre',
|
|
463
|
+
notificationCount: NOTIFICATIONS.length,
|
|
464
|
+
defaultOpen: true,
|
|
465
|
+
modal: false,
|
|
466
|
+
side: 'bottom',
|
|
467
|
+
align: 'end',
|
|
468
|
+
sideOffset: 8,
|
|
469
|
+
hasUnreadMark: true,
|
|
470
|
+
hasMarkAllAction: true,
|
|
471
|
+
hasFollowUpActions: true,
|
|
472
|
+
onRead: fn(),
|
|
473
|
+
onMarkAllAsViewed: fn(),
|
|
474
|
+
onAction: fn(),
|
|
475
|
+
},
|
|
476
|
+
argTypes: {
|
|
477
|
+
triggerLabel: {
|
|
478
|
+
control: 'text',
|
|
479
|
+
description: 'The `aria-label` of the icon button in `ChatNotificationPopupTrigger`.',
|
|
480
|
+
},
|
|
481
|
+
title: {
|
|
482
|
+
control: 'text',
|
|
483
|
+
description: 'The `aria-label` that names `ChatNotificationPopupContent`.',
|
|
484
|
+
},
|
|
485
|
+
notificationCount: {
|
|
486
|
+
control: { type: 'number', min: 0, max: NOTIFICATIONS.length },
|
|
487
|
+
description: 'Number of `ChatNotificationCard` rows in the popup.',
|
|
488
|
+
},
|
|
489
|
+
side: {
|
|
490
|
+
control: 'inline-radio',
|
|
491
|
+
options: ['top', 'right', 'bottom', 'left'],
|
|
492
|
+
description:
|
|
493
|
+
'Preferred side of the trigger to open on (`ChatNotificationPopupContent`); it flips when there is no room.',
|
|
494
|
+
table: { defaultValue: { summary: 'bottom' } },
|
|
495
|
+
},
|
|
496
|
+
align: {
|
|
497
|
+
control: 'inline-radio',
|
|
498
|
+
options: ['start', 'center', 'end'],
|
|
499
|
+
description:
|
|
500
|
+
'Alignment against the trigger (`ChatNotificationPopupContent`). Use `end` for a bell at the right edge.',
|
|
501
|
+
table: { defaultValue: { summary: 'start' } },
|
|
502
|
+
},
|
|
503
|
+
sideOffset: {
|
|
504
|
+
control: 'number',
|
|
505
|
+
description: 'Gap in px between the trigger and the popup (`ChatNotificationPopupContent`).',
|
|
506
|
+
table: { defaultValue: { summary: '8' } },
|
|
507
|
+
},
|
|
508
|
+
hasUnreadMark: {
|
|
509
|
+
control: 'boolean',
|
|
510
|
+
description: 'Shows the unread mark on the bell and the unread state of the cards.',
|
|
511
|
+
},
|
|
512
|
+
hasMarkAllAction: {
|
|
513
|
+
control: 'boolean',
|
|
514
|
+
description: 'Renders the "Mark all as viewed" button above the list.',
|
|
515
|
+
},
|
|
516
|
+
hasFollowUpActions: {
|
|
517
|
+
control: 'boolean',
|
|
518
|
+
description: 'Renders the follow-up buttons inside the cards.',
|
|
519
|
+
},
|
|
520
|
+
onRead: { description: 'Called with the notification id when a card is marked as read.' },
|
|
521
|
+
onMarkAllAsViewed: { description: 'Called when "Mark all as viewed" is clicked.' },
|
|
522
|
+
onAction: { description: 'Called with the label of the follow-up that was clicked.' },
|
|
523
|
+
},
|
|
524
|
+
// `defaultOpen` is read once, on mount, so remount when the control changes it.
|
|
525
|
+
render: (args) => (
|
|
526
|
+
<div className="flex justify-end">
|
|
527
|
+
<ChatNotificationPopupPlayground key={String(args.defaultOpen)} {...args} />
|
|
528
|
+
</div>
|
|
529
|
+
),
|
|
530
|
+
};
|
|
@@ -5,29 +5,44 @@ import { cn } from '@swisper.ai/web-core';
|
|
|
5
5
|
|
|
6
6
|
export interface ChatNotificationPopupProps extends ComponentProps<typeof Popover> {}
|
|
7
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Root of the notification popup. Holds the open state, uncontrolled through `defaultOpen` or
|
|
10
|
+
* controlled through `open` and `onOpenChange`. Renders no element of its own.
|
|
11
|
+
*/
|
|
8
12
|
export function ChatNotificationPopup({ children, ...rest }: ChatNotificationPopupProps) {
|
|
9
13
|
return <Popover {...rest}>{children}</Popover>;
|
|
10
14
|
}
|
|
11
15
|
|
|
12
16
|
export interface ChatNotificationPopupTriggerProps extends ComponentProps<typeof PopoverTrigger> {}
|
|
13
17
|
|
|
18
|
+
/** The button that opens and closes the popup. Pass `asChild` to use your own button. */
|
|
14
19
|
export const ChatNotificationPopupTrigger = forwardRef<
|
|
15
20
|
HTMLButtonElement,
|
|
16
21
|
ChatNotificationPopupTriggerProps
|
|
17
|
-
>(function ChatNotificationPopupTrigger(
|
|
18
|
-
return
|
|
22
|
+
>(function ChatNotificationPopupTrigger({ children, ...rest }, ref) {
|
|
23
|
+
return (
|
|
24
|
+
<PopoverTrigger ref={ref} data-slot="chat-notification-popup-trigger" {...rest}>
|
|
25
|
+
{children}
|
|
26
|
+
</PopoverTrigger>
|
|
27
|
+
);
|
|
19
28
|
});
|
|
20
29
|
|
|
21
30
|
ChatNotificationPopupTrigger.displayName = 'ChatNotificationPopupTrigger';
|
|
22
31
|
|
|
23
32
|
export interface ChatNotificationPopupContentProps extends ComponentProps<typeof PopoverContent> {}
|
|
24
33
|
|
|
34
|
+
/** The panel that holds the notifications. Portalled, and 467px wide from `md` up. */
|
|
25
35
|
export const ChatNotificationPopupContent = forwardRef<
|
|
26
36
|
HTMLDivElement,
|
|
27
37
|
ChatNotificationPopupContentProps
|
|
28
38
|
>(function ChatNotificationPopupContent({ children, className, ...rest }, ref) {
|
|
29
39
|
return (
|
|
30
|
-
<PopoverContent
|
|
40
|
+
<PopoverContent
|
|
41
|
+
ref={ref}
|
|
42
|
+
data-slot="chat-notification-popup-content"
|
|
43
|
+
className={cn('md:w-[467px]', className)}
|
|
44
|
+
{...rest}
|
|
45
|
+
>
|
|
31
46
|
{children}
|
|
32
47
|
</PopoverContent>
|
|
33
48
|
);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { AttachedFile } from './types';
|
|
2
|
+
|
|
3
|
+
// Long enough to wrap at the chat width, so the box expands and moves the actions under the text.
|
|
4
|
+
export const LONG_PROMPT =
|
|
5
|
+
'Summarise the three unread emails from the facilities team, draft a reply that confirms the office move for Friday 16 October, and add a reminder to my calendar for Thursday afternoon so I can pack up my desk before the movers arrive.';
|
|
6
|
+
|
|
7
|
+
// Files waiting in the toolbar before the message is sent. The last name is long enough to truncate.
|
|
8
|
+
export const ATTACHED_FILES: AttachedFile[] = [
|
|
9
|
+
{ id: 'file_01', name: 'Office move plan.pdf', icon: 'pdf' },
|
|
10
|
+
{ id: 'file_02', name: 'Desk allocation.xlsx', icon: 'spreadsheet' },
|
|
11
|
+
{
|
|
12
|
+
id: 'file_03',
|
|
13
|
+
name: 'Facilities team notes on the fourth floor layout, final draft.docx',
|
|
14
|
+
icon: 'document',
|
|
15
|
+
},
|
|
16
|
+
];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChatMessageAttachmentCardIconType } from '../../chat-message-attachment-card';
|
|
2
|
+
|
|
3
|
+
/** A file the user attached to the message they are writing. */
|
|
4
|
+
export interface AttachedFile {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
icon: Exclude<ChatMessageAttachmentCardIconType, 'image'>;
|
|
8
|
+
}
|
|
@@ -2,6 +2,25 @@
|
|
|
2
2
|
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
3
|
"component": "chat-prompt-box",
|
|
4
4
|
"purpose": "Swisper's styled message composer: a ChatInput in a rounded box with hover and focus styling, a focus glow, and left and right action slots that sit inline while the text is one line and move under it once the text grows.",
|
|
5
|
+
"anatomy": [
|
|
6
|
+
"import {",
|
|
7
|
+
" ChatPromptBox,",
|
|
8
|
+
" ChatPromptBoxToolbar,",
|
|
9
|
+
" ChatPromptBoxContent,",
|
|
10
|
+
" ChatPromptBoxInput,",
|
|
11
|
+
" ChatPromptBoxActionsLeft,",
|
|
12
|
+
" ChatPromptBoxActionsRight,",
|
|
13
|
+
"} from '@swisper.ai/web-chat-ui';",
|
|
14
|
+
"",
|
|
15
|
+
"<ChatPromptBox>",
|
|
16
|
+
" <ChatPromptBoxToolbar />",
|
|
17
|
+
" <ChatPromptBoxContent>",
|
|
18
|
+
" <ChatPromptBoxInput />",
|
|
19
|
+
" <ChatPromptBoxActionsLeft />",
|
|
20
|
+
" <ChatPromptBoxActionsRight />",
|
|
21
|
+
" </ChatPromptBoxContent>",
|
|
22
|
+
"</ChatPromptBox>"
|
|
23
|
+
],
|
|
5
24
|
"useWhen": [
|
|
6
25
|
"The main composer of a Swisper chat, where the user types a question and sends it",
|
|
7
26
|
"The composer needs action buttons beside the text, such as attach on the left and send on the right",
|
|
@@ -27,7 +46,7 @@
|
|
|
27
46
|
],
|
|
28
47
|
"aria": [
|
|
29
48
|
"The editable element is ChatInput's textbox, labelled \"Chat input\"",
|
|
30
|
-
"ChatPromptBoxActionsLeft and ChatPromptBoxActionsRight render role=group
|
|
49
|
+
"ChatPromptBoxActionsLeft and ChatPromptBoxActionsRight render role=group with no name of their own; pass aria-label to name each group (\"Attachments\", \"Message actions\")"
|
|
31
50
|
],
|
|
32
51
|
"focus": [
|
|
33
52
|
"Mouse down anywhere in the box focuses the input, except on a button, link, input, select, textarea or role=button element",
|
|
@@ -44,7 +63,11 @@
|
|
|
44
63
|
"The input grows up to 72px and then scrolls",
|
|
45
64
|
"ChatPromptBoxInput takes ChatInputTextarea's props: value and onChange use Markdown, isDisabled and isReadOnly block editing",
|
|
46
65
|
"onMouseDown on the root still fires after the box has focused the input",
|
|
47
|
-
"ChatPromptBoxContent orders the parts visually as left actions, input, right actions regardless of source order"
|
|
66
|
+
"ChatPromptBoxContent orders the parts visually as left actions, input, right actions regardless of source order",
|
|
67
|
+
"Every part sets data-slot=chat-prompt-box-{part} and merges className last. On ChatPromptBox, className styles the root (the 1px border ring) and innerClassName the surface inside it that carries the background and padding",
|
|
68
|
+
"On ChatPromptBoxInput, className styles the wrapper that lays the input out in the row and textareaClassName the editable element; its 72px max height is set with !, so override it with ! too",
|
|
69
|
+
"ChatPromptBoxInput renders its children inside the editor, after its own focus plugin; use them for extra Lexical plugins",
|
|
70
|
+
"ChatPromptBoxToolbar, ChatPromptBoxContent and both action groups pass other div props (aria-label, data-*, event handlers) to their element"
|
|
48
71
|
]
|
|
49
72
|
},
|
|
50
73
|
"composition": {
|