@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,10 +1,30 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { fn } from 'storybook/test';
|
|
2
|
+
import { useMemo, useState, type ReactNode } from 'react';
|
|
3
|
+
import { expect, fn } from 'storybook/test';
|
|
4
4
|
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import {
|
|
6
|
+
AssignmentLateIcon,
|
|
7
|
+
FlightIcon,
|
|
8
|
+
HourglassBottomIcon,
|
|
9
|
+
MailIcon,
|
|
10
|
+
NotificationsIcon,
|
|
11
|
+
} from '@swisper.ai/icons';
|
|
12
|
+
import { Button, IconButton, Typography } from '@swisper.ai/ui';
|
|
13
|
+
|
|
14
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
15
|
+
import {
|
|
16
|
+
ChatNotificationPopup,
|
|
17
|
+
ChatNotificationPopupContent,
|
|
18
|
+
ChatNotificationPopupTrigger,
|
|
19
|
+
} from '../chat-notification-popup';
|
|
7
20
|
|
|
21
|
+
import {
|
|
22
|
+
BOARD_MEETING_MOVED,
|
|
23
|
+
FLIGHT_CHECK_IN,
|
|
24
|
+
INVOICE_DUE,
|
|
25
|
+
NOTIFICATIONS,
|
|
26
|
+
} from './__stories__/fixtures';
|
|
27
|
+
import type { NotificationSignal } from './__stories__/types';
|
|
8
28
|
import {
|
|
9
29
|
ChatNotificationCard,
|
|
10
30
|
ChatNotificationCardActions,
|
|
@@ -18,21 +38,24 @@ import {
|
|
|
18
38
|
ChatNotificationCardSnoozeButton,
|
|
19
39
|
ChatNotificationCardDeleteButton,
|
|
20
40
|
ChatNotificationCardContent,
|
|
41
|
+
ChatNotificationCardContentTitle,
|
|
21
42
|
ChatNotificationCardContentDescription,
|
|
22
43
|
ChatNotificationCardContentActions,
|
|
23
44
|
ChatNotificationCardHead,
|
|
24
45
|
ChatNotificationCardButtons,
|
|
25
46
|
ChatNotificationCardCloseButton,
|
|
47
|
+
type ChatNotificationCardProps,
|
|
26
48
|
} from './chat-notification-card';
|
|
49
|
+
import type { ChatNotificationCardPriority } from './types';
|
|
27
50
|
import { getSnoozeUntilDate } from './utils';
|
|
28
51
|
|
|
29
52
|
const meta: Meta<typeof ChatNotificationCard> = {
|
|
30
|
-
title: '
|
|
53
|
+
title: 'Chat/ChatNotificationCard',
|
|
31
54
|
component: ChatNotificationCard,
|
|
32
55
|
tags: ['autodocs'],
|
|
33
56
|
decorators: [
|
|
34
57
|
(Story) => (
|
|
35
|
-
<div className="max-w-
|
|
58
|
+
<div className="max-w-144">
|
|
36
59
|
<Story />
|
|
37
60
|
</div>
|
|
38
61
|
),
|
|
@@ -49,6 +72,10 @@ const meta: Meta<typeof ChatNotificationCard> = {
|
|
|
49
72
|
control: 'text',
|
|
50
73
|
description: 'Additional CSS classes for the card',
|
|
51
74
|
},
|
|
75
|
+
overlayClassName: {
|
|
76
|
+
control: 'text',
|
|
77
|
+
description: 'Classes for the hover overlay that covers the card.',
|
|
78
|
+
},
|
|
52
79
|
children: {
|
|
53
80
|
description:
|
|
54
81
|
'The card parts: a `ChatNotificationCardHead` (header and actions) and a `ChatNotificationCardContent`.',
|
|
@@ -58,7 +85,7 @@ const meta: Meta<typeof ChatNotificationCard> = {
|
|
|
58
85
|
control: 'select',
|
|
59
86
|
options: ['default', 'floating'],
|
|
60
87
|
description:
|
|
61
|
-
'`default` for a card in the notification list, `floating` for a card shown on its own over the chat (e.g. in a popup).',
|
|
88
|
+
'`default` for a card in the notification list, `floating` (bordered) for a card shown on its own over the chat (e.g. in a popup).',
|
|
62
89
|
},
|
|
63
90
|
defaultExpanded: {
|
|
64
91
|
control: 'boolean',
|
|
@@ -84,9 +111,10 @@ const meta: Meta<typeof ChatNotificationCard> = {
|
|
|
84
111
|
export default meta;
|
|
85
112
|
type Story = StoryObj<typeof ChatNotificationCard>;
|
|
86
113
|
|
|
114
|
+
/** A notification in a list: category and priority, time, the list actions, and a follow-up action that shows on expand. */
|
|
87
115
|
export const Default: Story = {
|
|
88
|
-
render: (
|
|
89
|
-
<ChatNotificationCard {...
|
|
116
|
+
render: (args) => (
|
|
117
|
+
<ChatNotificationCard {...args}>
|
|
90
118
|
<ChatNotificationCardHead>
|
|
91
119
|
<ChatNotificationCardHeader>
|
|
92
120
|
<ChatNotificationCardHeaderIcon>
|
|
@@ -94,14 +122,14 @@ export const Default: Story = {
|
|
|
94
122
|
</ChatNotificationCardHeaderIcon>
|
|
95
123
|
<ChatNotificationCardHeaderTitle>
|
|
96
124
|
<ChatNotificationCardHeaderTitleLabel>
|
|
97
|
-
|
|
125
|
+
{FLIGHT_CHECK_IN.category}
|
|
98
126
|
</ChatNotificationCardHeaderTitleLabel>
|
|
99
|
-
<ChatNotificationCardHeaderStatus>
|
|
127
|
+
<ChatNotificationCardHeaderStatus>Medium</ChatNotificationCardHeaderStatus>
|
|
100
128
|
</ChatNotificationCardHeaderTitle>
|
|
101
129
|
</ChatNotificationCardHeader>
|
|
102
130
|
|
|
103
131
|
<ChatNotificationCardActions>
|
|
104
|
-
<ChatNotificationCardTimestamp>
|
|
132
|
+
<ChatNotificationCardTimestamp>{FLIGHT_CHECK_IN.createdAt}</ChatNotificationCardTimestamp>
|
|
105
133
|
<ChatNotificationCardButtons>
|
|
106
134
|
<ChatNotificationCardReadActionButton />
|
|
107
135
|
<ChatNotificationCardSnoozeButton />
|
|
@@ -110,16 +138,23 @@ export const Default: Story = {
|
|
|
110
138
|
</ChatNotificationCardActions>
|
|
111
139
|
</ChatNotificationCardHead>
|
|
112
140
|
<ChatNotificationCardContent>
|
|
141
|
+
<ChatNotificationCardContentTitle>{FLIGHT_CHECK_IN.title}</ChatNotificationCardContentTitle>
|
|
113
142
|
<ChatNotificationCardContentDescription>
|
|
114
|
-
|
|
143
|
+
{FLIGHT_CHECK_IN.body}
|
|
115
144
|
</ChatNotificationCardContentDescription>
|
|
145
|
+
<ChatNotificationCardContentActions>
|
|
146
|
+
<Button variant="secondary" size="sm">
|
|
147
|
+
Check in now
|
|
148
|
+
</Button>
|
|
149
|
+
</ChatNotificationCardContentActions>
|
|
116
150
|
</ChatNotificationCardContent>
|
|
117
151
|
</ChatNotificationCard>
|
|
118
152
|
),
|
|
119
153
|
};
|
|
120
154
|
|
|
155
|
+
/** A snoozed notification: the snooze button shows the time left, and cancels the snooze on click. */
|
|
121
156
|
export const Snoozed: Story = {
|
|
122
|
-
render: (
|
|
157
|
+
render: (args) => {
|
|
123
158
|
const [snoozeUntilDate, setSnoozeUntilDate] = useState<Date | undefined>(getSnoozeUntilDate(2));
|
|
124
159
|
|
|
125
160
|
function handleCancel() {
|
|
@@ -131,8 +166,7 @@ export const Snoozed: Story = {
|
|
|
131
166
|
}
|
|
132
167
|
|
|
133
168
|
return (
|
|
134
|
-
<ChatNotificationCard {...
|
|
135
|
-
{/* Header */}
|
|
169
|
+
<ChatNotificationCard {...args}>
|
|
136
170
|
<ChatNotificationCardHead>
|
|
137
171
|
<ChatNotificationCardHeader>
|
|
138
172
|
<ChatNotificationCardHeaderIcon>
|
|
@@ -140,7 +174,7 @@ export const Snoozed: Story = {
|
|
|
140
174
|
</ChatNotificationCardHeaderIcon>
|
|
141
175
|
<ChatNotificationCardHeaderTitle>
|
|
142
176
|
<ChatNotificationCardHeaderTitleLabel>
|
|
143
|
-
|
|
177
|
+
Overdue task
|
|
144
178
|
</ChatNotificationCardHeaderTitleLabel>
|
|
145
179
|
<ChatNotificationCardHeaderStatus>Medium</ChatNotificationCardHeaderStatus>
|
|
146
180
|
</ChatNotificationCardHeaderTitle>
|
|
@@ -158,10 +192,10 @@ export const Snoozed: Story = {
|
|
|
158
192
|
</ChatNotificationCardButtons>
|
|
159
193
|
</ChatNotificationCardActions>
|
|
160
194
|
</ChatNotificationCardHead>
|
|
161
|
-
{/* Content */}
|
|
162
195
|
<ChatNotificationCardContent>
|
|
163
196
|
<ChatNotificationCardContentDescription>
|
|
164
|
-
|
|
197
|
+
The expense report for the Lisbon trip was due yesterday. Three receipts are still
|
|
198
|
+
missing.
|
|
165
199
|
</ChatNotificationCardContentDescription>
|
|
166
200
|
</ChatNotificationCardContent>
|
|
167
201
|
</ChatNotificationCard>
|
|
@@ -169,8 +203,9 @@ export const Snoozed: Story = {
|
|
|
169
203
|
},
|
|
170
204
|
};
|
|
171
205
|
|
|
206
|
+
/** The read toggle, on a notification whose long description clamps to two lines until the card is expanded. */
|
|
172
207
|
export const Read: Story = {
|
|
173
|
-
render: (
|
|
208
|
+
render: (args) => {
|
|
174
209
|
const [isRead, setIsRead] = useState(false);
|
|
175
210
|
|
|
176
211
|
function toggleRead() {
|
|
@@ -178,8 +213,7 @@ export const Read: Story = {
|
|
|
178
213
|
}
|
|
179
214
|
|
|
180
215
|
return (
|
|
181
|
-
<ChatNotificationCard {...
|
|
182
|
-
{/* Header */}
|
|
216
|
+
<ChatNotificationCard {...args}>
|
|
183
217
|
<ChatNotificationCardHead>
|
|
184
218
|
<ChatNotificationCardHeader>
|
|
185
219
|
<ChatNotificationCardHeaderIcon>
|
|
@@ -187,7 +221,7 @@ export const Read: Story = {
|
|
|
187
221
|
</ChatNotificationCardHeaderIcon>
|
|
188
222
|
<ChatNotificationCardHeaderTitle>
|
|
189
223
|
<ChatNotificationCardHeaderTitleLabel>
|
|
190
|
-
|
|
224
|
+
Overdue task: quarterly budget review for the product team
|
|
191
225
|
</ChatNotificationCardHeaderTitleLabel>
|
|
192
226
|
<ChatNotificationCardHeaderStatus>Medium</ChatNotificationCardHeaderStatus>
|
|
193
227
|
</ChatNotificationCardHeaderTitle>
|
|
@@ -202,38 +236,16 @@ export const Read: Story = {
|
|
|
202
236
|
</ChatNotificationCardActions>
|
|
203
237
|
</ChatNotificationCardHead>
|
|
204
238
|
|
|
205
|
-
{/* Content */}
|
|
206
239
|
<ChatNotificationCardContent>
|
|
207
240
|
<ChatNotificationCardContentDescription>
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
magna nec nisi. Nunc et enim non neque dignissim lacinia. Nulla posuere turpis aliquam
|
|
217
|
-
fringilla tempor. Donec volutpat lorem urna, quis condimentum sem mollis in. Aliquam
|
|
218
|
-
tincidunt felis nec enim rhoncus tempus commodo sed ligula. In blandit sem lobortis diam
|
|
219
|
-
eleifend, vel rhoncus velit volutpat. Mauris feugiat, nisi in pellentesque tincidunt,
|
|
220
|
-
dolor justo faucibus ipsum, non consectetur nisi elit in nunc. Ut dictum in velit nec
|
|
221
|
-
placerat. Aliquam sollicitudin tellus sed sollicitudin faucibus. Nulla ac elit id est
|
|
222
|
-
interdum tempor sed semper est. Nam nulla lectus, varius ut nibh et, auctor auctor
|
|
223
|
-
magna. Mauris in ornare orci. Maecenas convallis orci vitae laoreet eleifend.
|
|
224
|
-
Pellentesque dignissim laoreet ex non molestie. Pellentesque convallis pretium
|
|
225
|
-
porttitor. Maecenas vitae tortor id felis tincidunt blandit. Nam at diam fermentum,
|
|
226
|
-
vestibulum nisl tristique, iaculis felis. Aenean ut libero tellus. Nam blandit rhoncus
|
|
227
|
-
congue. Cras aliquet ultricies nisl, sit amet imperdiet mi faucibus in. Maecenas et ex
|
|
228
|
-
et sem luctus varius. Vestibulum fringilla, sapien ac imperdiet semper, enim risus
|
|
229
|
-
bibendum erat, vitae lacinia massa magna feugiat nulla. Nulla a est vel arcu mollis
|
|
230
|
-
rutrum. Integer nec nulla feugiat augue dapibus pellentesque nec non dolor. Ut lacinia
|
|
231
|
-
mauris eget orci dapibus pulvinar. Morbi erat odio, elementum sed libero sodales, varius
|
|
232
|
-
viverra odio. Nunc dignissim tortor dolor, quis egestas nibh sollicitudin ac. Cras
|
|
233
|
-
luctus nibh quis purus ornare, et placerat nulla pulvinar. Nam cursus urna quis justo
|
|
234
|
-
suscipit venenatis. Vestibulum euismod viverra fringilla. Duis sit amet leo eget velit
|
|
235
|
-
semper pharetra eget ac purus. Aliquam gravida varius ex suscipit ultrices. Mauris sit
|
|
236
|
-
amet faucibus eros.
|
|
241
|
+
The quarterly budget review was due on Monday and is still open. Finance needs the
|
|
242
|
+
updated headcount plan and the tooling costs before they can close the quarter, and the
|
|
243
|
+
leadership meeting on Friday depends on both. The draft you started last week covers
|
|
244
|
+
salaries and contractors but leaves out the two open engineering roles, the design
|
|
245
|
+
tooling renewal in May and the travel budget for the customer summit. Two teammates have
|
|
246
|
+
commented on the draft: one asks to split infrastructure costs by environment, the other
|
|
247
|
+
flags that the training budget was counted twice. Once the review is submitted, finance
|
|
248
|
+
takes about two working days to confirm it, so sending it today keeps Friday on track.
|
|
237
249
|
</ChatNotificationCardContentDescription>
|
|
238
250
|
<ChatNotificationCardContentActions>
|
|
239
251
|
<Button variant="secondary" size="sm">
|
|
@@ -246,11 +258,12 @@ export const Read: Story = {
|
|
|
246
258
|
},
|
|
247
259
|
};
|
|
248
260
|
|
|
261
|
+
/** One notification shown on its own over the chat: bordered, with snooze and close instead of read and delete. */
|
|
249
262
|
export const Floating: Story = {
|
|
250
|
-
|
|
263
|
+
args: { variant: 'floating' },
|
|
264
|
+
render: (args) => {
|
|
251
265
|
return (
|
|
252
|
-
<ChatNotificationCard {...
|
|
253
|
-
{/* Header */}
|
|
266
|
+
<ChatNotificationCard {...args}>
|
|
254
267
|
<ChatNotificationCardHead>
|
|
255
268
|
<ChatNotificationCardHeader>
|
|
256
269
|
<ChatNotificationCardHeaderIcon>
|
|
@@ -258,9 +271,11 @@ export const Floating: Story = {
|
|
|
258
271
|
</ChatNotificationCardHeaderIcon>
|
|
259
272
|
<ChatNotificationCardHeaderTitle>
|
|
260
273
|
<ChatNotificationCardHeaderTitleLabel>
|
|
261
|
-
|
|
274
|
+
Overdue task
|
|
262
275
|
</ChatNotificationCardHeaderTitleLabel>
|
|
263
|
-
<ChatNotificationCardHeaderStatus>
|
|
276
|
+
<ChatNotificationCardHeaderStatus priority="high">
|
|
277
|
+
High
|
|
278
|
+
</ChatNotificationCardHeaderStatus>
|
|
264
279
|
</ChatNotificationCardHeaderTitle>
|
|
265
280
|
</ChatNotificationCardHeader>
|
|
266
281
|
<ChatNotificationCardActions>
|
|
@@ -271,12 +286,10 @@ export const Floating: Story = {
|
|
|
271
286
|
</ChatNotificationCardActions>
|
|
272
287
|
</ChatNotificationCardHead>
|
|
273
288
|
|
|
274
|
-
{/* Content */}
|
|
275
289
|
<ChatNotificationCardContent>
|
|
276
290
|
<ChatNotificationCardContentDescription>
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
reprehenderit maiores delectus quam, non illum ratione.
|
|
291
|
+
The signed supplier contract was due at 12:00 today. Legal can't release the purchase
|
|
292
|
+
order until it arrives, and the supplier's offer expires on Friday.
|
|
280
293
|
</ChatNotificationCardContentDescription>
|
|
281
294
|
<ChatNotificationCardContentActions>
|
|
282
295
|
<Button variant="secondary" size="sm">
|
|
@@ -288,3 +301,470 @@ export const Floating: Story = {
|
|
|
288
301
|
);
|
|
289
302
|
},
|
|
290
303
|
};
|
|
304
|
+
|
|
305
|
+
/** The expand button reveals the follow-up action and reports the new state without firing the card's `onClick`. */
|
|
306
|
+
export const ExpandAndCollapse: Story = {
|
|
307
|
+
...Default,
|
|
308
|
+
tags: ['e2e', '!autodocs'],
|
|
309
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
310
|
+
// TODO(echo-ds): the expand button has no accessible name; it is found by its aria-expanded state.
|
|
311
|
+
await step('Collapsed hides the follow-up action', async () => {
|
|
312
|
+
await expect(canvas.queryByRole('button', { name: 'Check in now' })).not.toBeInTheDocument();
|
|
313
|
+
});
|
|
314
|
+
|
|
315
|
+
await step('Expanding shows it', async () => {
|
|
316
|
+
await userEvent.click(canvas.getByRole('button', { expanded: false }));
|
|
317
|
+
await expect(canvas.getByRole('button', { name: 'Check in now' })).toBeVisible();
|
|
318
|
+
await expect(args.onExpandedChange).toHaveBeenLastCalledWith(true);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
await step('Collapsing hides it again', async () => {
|
|
322
|
+
await userEvent.click(canvas.getByRole('button', { expanded: true }));
|
|
323
|
+
await expect(canvas.queryByRole('button', { name: 'Check in now' })).not.toBeInTheDocument();
|
|
324
|
+
await expect(args.onExpandedChange).toHaveBeenLastCalledWith(false);
|
|
325
|
+
await expect(args.onClick).not.toHaveBeenCalled();
|
|
326
|
+
});
|
|
327
|
+
},
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/** A click on the card body fires `onClick`; a click on a button in `ChatNotificationCardButtons` does not. */
|
|
331
|
+
export const CardClick: Story = {
|
|
332
|
+
...Default,
|
|
333
|
+
tags: ['e2e', '!autodocs'],
|
|
334
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
335
|
+
await step('The card body opens the notification', async () => {
|
|
336
|
+
await userEvent.click(canvas.getByText(FLIGHT_CHECK_IN.title));
|
|
337
|
+
await expect(args.onClick).toHaveBeenCalledTimes(1);
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
await step('The action buttons keep their clicks', async () => {
|
|
341
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Delete notification' }));
|
|
342
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Snooze notification' }));
|
|
343
|
+
await expect(args.onClick).toHaveBeenCalledTimes(1);
|
|
344
|
+
});
|
|
345
|
+
},
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
/** Cancelling a snooze brings the icon button back, and snoozing again brings back the time left. */
|
|
349
|
+
export const SnoozeAndCancel: Story = {
|
|
350
|
+
...Snoozed,
|
|
351
|
+
tags: ['e2e', '!autodocs'],
|
|
352
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
353
|
+
await step('Clicking the time left cancels the snooze', async () => {
|
|
354
|
+
await userEvent.click(canvas.getByRole('button', { name: /in 2 minutes/ }));
|
|
355
|
+
await expect(
|
|
356
|
+
await canvas.findByRole('button', { name: 'Snooze notification' }),
|
|
357
|
+
).toBeVisible();
|
|
358
|
+
});
|
|
359
|
+
|
|
360
|
+
await step('Clicking the icon button snoozes again', async () => {
|
|
361
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Snooze notification' }));
|
|
362
|
+
await expect(await canvas.findByRole('button', { name: /in 2 minutes/ })).toBeVisible();
|
|
363
|
+
await expect(args.onClick).not.toHaveBeenCalled();
|
|
364
|
+
});
|
|
365
|
+
},
|
|
366
|
+
};
|
|
367
|
+
|
|
368
|
+
/** The read button toggles the read state and exposes it as `data-read`. */
|
|
369
|
+
export const MarkAsRead: Story = {
|
|
370
|
+
...Read,
|
|
371
|
+
tags: ['e2e', '!autodocs'],
|
|
372
|
+
play: async ({ canvas, userEvent, step }) => {
|
|
373
|
+
const readButton = canvas.getByRole('button', { name: 'Mark notifications as read' });
|
|
374
|
+
|
|
375
|
+
await step('Marks the notification as read', async () => {
|
|
376
|
+
await expect(readButton).toHaveAttribute('data-read', 'false');
|
|
377
|
+
await userEvent.click(readButton);
|
|
378
|
+
await expect(readButton).toHaveAttribute('data-read', 'true');
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
await step('Marks it as unread again', async () => {
|
|
382
|
+
await userEvent.click(readButton);
|
|
383
|
+
await expect(readButton).toHaveAttribute('data-read', 'false');
|
|
384
|
+
});
|
|
385
|
+
},
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
interface NotificationSignalListItemProps {
|
|
389
|
+
signal: NotificationSignal;
|
|
390
|
+
onRead: (id: string) => void;
|
|
391
|
+
onAction: (action: string) => void;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
function NotificationSignalListItem({ signal, onRead, onAction }: NotificationSignalListItemProps) {
|
|
395
|
+
const [isRead, setIsRead] = useState(signal.isRead);
|
|
396
|
+
|
|
397
|
+
function handleMarkAsRead() {
|
|
398
|
+
if (isRead) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
setIsRead(true);
|
|
403
|
+
onRead(signal.id);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return (
|
|
407
|
+
<ChatNotificationCard className="w-full" onClick={handleMarkAsRead}>
|
|
408
|
+
<ChatNotificationCardHead>
|
|
409
|
+
<ChatNotificationCardHeader>
|
|
410
|
+
<ChatNotificationCardHeaderIcon>
|
|
411
|
+
<HourglassBottomIcon />
|
|
412
|
+
</ChatNotificationCardHeaderIcon>
|
|
413
|
+
<ChatNotificationCardHeaderTitle>
|
|
414
|
+
<ChatNotificationCardHeaderTitleLabel>
|
|
415
|
+
{signal.category}
|
|
416
|
+
</ChatNotificationCardHeaderTitleLabel>
|
|
417
|
+
<ChatNotificationCardHeaderStatus>Medium</ChatNotificationCardHeaderStatus>
|
|
418
|
+
</ChatNotificationCardHeaderTitle>
|
|
419
|
+
</ChatNotificationCardHeader>
|
|
420
|
+
<ChatNotificationCardActions>
|
|
421
|
+
<ChatNotificationCardTimestamp>{signal.createdAt}</ChatNotificationCardTimestamp>
|
|
422
|
+
<ChatNotificationCardButtons>
|
|
423
|
+
<ChatNotificationCardReadActionButton isRead={isRead} onRead={handleMarkAsRead} />
|
|
424
|
+
</ChatNotificationCardButtons>
|
|
425
|
+
</ChatNotificationCardActions>
|
|
426
|
+
</ChatNotificationCardHead>
|
|
427
|
+
<ChatNotificationCardContent>
|
|
428
|
+
<ChatNotificationCardContentTitle>{signal.title}</ChatNotificationCardContentTitle>
|
|
429
|
+
<ChatNotificationCardContentDescription>
|
|
430
|
+
{signal.body}
|
|
431
|
+
</ChatNotificationCardContentDescription>
|
|
432
|
+
{signal.actions.length > 0 && (
|
|
433
|
+
<ChatNotificationCardContentActions>
|
|
434
|
+
{signal.actions.map((action) => (
|
|
435
|
+
<Button key={action} variant="secondary" size="sm" onClick={() => onAction(action)}>
|
|
436
|
+
{action}
|
|
437
|
+
</Button>
|
|
438
|
+
))}
|
|
439
|
+
</ChatNotificationCardContentActions>
|
|
440
|
+
)}
|
|
441
|
+
</ChatNotificationCardContent>
|
|
442
|
+
</ChatNotificationCard>
|
|
443
|
+
);
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
/**
|
|
447
|
+
* The card in each place it belongs: the notification centre popover, a floating popup over the
|
|
448
|
+
* chat, the notification panel and a plain notification list.
|
|
449
|
+
*/
|
|
450
|
+
export const Examples: Story = {
|
|
451
|
+
parameters: {
|
|
452
|
+
controls: { disable: true },
|
|
453
|
+
docs: { story: { inline: false, height: '1520px' } },
|
|
454
|
+
},
|
|
455
|
+
render: () => (
|
|
456
|
+
<div className="flex flex-col gap-24">
|
|
457
|
+
<ParentBlock parent="web-chat-ui/ChatNotificationPopupContent">
|
|
458
|
+
<div className="min-h-120">
|
|
459
|
+
<ChatNotificationPopup defaultOpen>
|
|
460
|
+
<ChatNotificationPopupTrigger asChild>
|
|
461
|
+
<IconButton variant="tertiary" aria-label="Notifications">
|
|
462
|
+
<NotificationsIcon />
|
|
463
|
+
</IconButton>
|
|
464
|
+
</ChatNotificationPopupTrigger>
|
|
465
|
+
<ChatNotificationPopupContent
|
|
466
|
+
className="flex flex-col gap-16 p-16"
|
|
467
|
+
onOpenAutoFocus={(event) => event.preventDefault()}
|
|
468
|
+
>
|
|
469
|
+
<Typography variant="h4" fontWeight="medium">
|
|
470
|
+
Notification centre
|
|
471
|
+
</Typography>
|
|
472
|
+
<ul className="flex flex-col gap-8">
|
|
473
|
+
{[FLIGHT_CHECK_IN, INVOICE_DUE].map((signal) => (
|
|
474
|
+
<li key={signal.id}>
|
|
475
|
+
<NotificationSignalListItem signal={signal} onRead={fn()} onAction={fn()} />
|
|
476
|
+
</li>
|
|
477
|
+
))}
|
|
478
|
+
</ul>
|
|
479
|
+
</ChatNotificationPopupContent>
|
|
480
|
+
</ChatNotificationPopup>
|
|
481
|
+
</div>
|
|
482
|
+
</ParentBlock>
|
|
483
|
+
|
|
484
|
+
<ParentBlock parent="notification popup">
|
|
485
|
+
<div
|
|
486
|
+
role="region"
|
|
487
|
+
aria-label="Notification popup"
|
|
488
|
+
className="rounded-10 border border-component-divider p-16"
|
|
489
|
+
>
|
|
490
|
+
<ChatNotificationCard variant="floating" className="w-full">
|
|
491
|
+
<ChatNotificationCardHead>
|
|
492
|
+
<ChatNotificationCardHeader>
|
|
493
|
+
<ChatNotificationCardHeaderIcon>
|
|
494
|
+
<AssignmentLateIcon />
|
|
495
|
+
</ChatNotificationCardHeaderIcon>
|
|
496
|
+
<ChatNotificationCardHeaderTitle>
|
|
497
|
+
<ChatNotificationCardHeaderTitleLabel>
|
|
498
|
+
{BOARD_MEETING_MOVED.category}
|
|
499
|
+
</ChatNotificationCardHeaderTitleLabel>
|
|
500
|
+
<ChatNotificationCardHeaderStatus>Medium</ChatNotificationCardHeaderStatus>
|
|
501
|
+
</ChatNotificationCardHeaderTitle>
|
|
502
|
+
</ChatNotificationCardHeader>
|
|
503
|
+
<ChatNotificationCardActions>
|
|
504
|
+
<ChatNotificationCardButtons>
|
|
505
|
+
<ChatNotificationCardSnoozeButton onClick={fn()} />
|
|
506
|
+
<ChatNotificationCardCloseButton onClick={fn()} />
|
|
507
|
+
</ChatNotificationCardButtons>
|
|
508
|
+
</ChatNotificationCardActions>
|
|
509
|
+
</ChatNotificationCardHead>
|
|
510
|
+
<ChatNotificationCardContent>
|
|
511
|
+
<ChatNotificationCardContentTitle>
|
|
512
|
+
{BOARD_MEETING_MOVED.title}
|
|
513
|
+
</ChatNotificationCardContentTitle>
|
|
514
|
+
<ChatNotificationCardContentDescription>
|
|
515
|
+
{BOARD_MEETING_MOVED.body}
|
|
516
|
+
</ChatNotificationCardContentDescription>
|
|
517
|
+
</ChatNotificationCardContent>
|
|
518
|
+
</ChatNotificationCard>
|
|
519
|
+
</div>
|
|
520
|
+
</ParentBlock>
|
|
521
|
+
|
|
522
|
+
<ParentBlock parent="notification panel">
|
|
523
|
+
<aside
|
|
524
|
+
aria-label="Notification centre"
|
|
525
|
+
className="flex flex-col gap-8 rounded-10 border border-component-divider p-16"
|
|
526
|
+
>
|
|
527
|
+
<Typography variant="h4" fontWeight="bold">
|
|
528
|
+
Notification centre
|
|
529
|
+
</Typography>
|
|
530
|
+
<div className="flex justify-end">
|
|
531
|
+
<Button variant="tertiary">Mark all as viewed</Button>
|
|
532
|
+
</div>
|
|
533
|
+
<NotificationSignalListItem signal={BOARD_MEETING_MOVED} onRead={fn()} onAction={fn()} />
|
|
534
|
+
</aside>
|
|
535
|
+
</ParentBlock>
|
|
536
|
+
|
|
537
|
+
<ParentBlock parent="notification list">
|
|
538
|
+
<ul aria-label="Notifications" className="flex flex-col gap-8">
|
|
539
|
+
{NOTIFICATIONS.map((signal) => (
|
|
540
|
+
<li key={signal.id}>
|
|
541
|
+
<NotificationSignalListItem signal={signal} onRead={fn()} onAction={fn()} />
|
|
542
|
+
</li>
|
|
543
|
+
))}
|
|
544
|
+
</ul>
|
|
545
|
+
</ParentBlock>
|
|
546
|
+
</div>
|
|
547
|
+
),
|
|
548
|
+
};
|
|
549
|
+
|
|
550
|
+
interface ChatNotificationCardPlaygroundProps extends Omit<ChatNotificationCardProps, 'children'> {
|
|
551
|
+
icon: ReactNode;
|
|
552
|
+
label: string;
|
|
553
|
+
hasStatus: boolean;
|
|
554
|
+
status: string;
|
|
555
|
+
priority: ChatNotificationCardPriority;
|
|
556
|
+
hasTimestamp: boolean;
|
|
557
|
+
timestamp: string;
|
|
558
|
+
hasReadButton: boolean;
|
|
559
|
+
isRead: boolean;
|
|
560
|
+
hasSnoozeButton: boolean;
|
|
561
|
+
isSnoozed: boolean;
|
|
562
|
+
cancelLabel: string;
|
|
563
|
+
hasDeleteButton: boolean;
|
|
564
|
+
hasCloseButton: boolean;
|
|
565
|
+
hasContentTitle: boolean;
|
|
566
|
+
title: string;
|
|
567
|
+
description: string;
|
|
568
|
+
hasContentActions: boolean;
|
|
569
|
+
actionLabel: string;
|
|
570
|
+
onRead: (isRead: boolean) => void;
|
|
571
|
+
onSnooze: () => void;
|
|
572
|
+
onCancelSnooze: () => void;
|
|
573
|
+
onDelete: () => void;
|
|
574
|
+
onClose: () => void;
|
|
575
|
+
onAction: () => void;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
function ChatNotificationCardPlayground({
|
|
579
|
+
icon,
|
|
580
|
+
label,
|
|
581
|
+
hasStatus,
|
|
582
|
+
status,
|
|
583
|
+
priority,
|
|
584
|
+
hasTimestamp,
|
|
585
|
+
timestamp,
|
|
586
|
+
hasReadButton,
|
|
587
|
+
isRead,
|
|
588
|
+
hasSnoozeButton,
|
|
589
|
+
isSnoozed,
|
|
590
|
+
cancelLabel,
|
|
591
|
+
hasDeleteButton,
|
|
592
|
+
hasCloseButton,
|
|
593
|
+
hasContentTitle,
|
|
594
|
+
title,
|
|
595
|
+
description,
|
|
596
|
+
hasContentActions,
|
|
597
|
+
actionLabel,
|
|
598
|
+
onRead,
|
|
599
|
+
onSnooze,
|
|
600
|
+
onCancelSnooze,
|
|
601
|
+
onDelete,
|
|
602
|
+
onClose,
|
|
603
|
+
onAction,
|
|
604
|
+
...rest
|
|
605
|
+
}: ChatNotificationCardPlaygroundProps) {
|
|
606
|
+
const snoozeUntilDate = useMemo(
|
|
607
|
+
() => (isSnoozed ? getSnoozeUntilDate(90) : undefined),
|
|
608
|
+
[isSnoozed],
|
|
609
|
+
);
|
|
610
|
+
|
|
611
|
+
return (
|
|
612
|
+
<ChatNotificationCard {...rest}>
|
|
613
|
+
<ChatNotificationCardHead>
|
|
614
|
+
<ChatNotificationCardHeader>
|
|
615
|
+
{icon && <ChatNotificationCardHeaderIcon>{icon}</ChatNotificationCardHeaderIcon>}
|
|
616
|
+
<ChatNotificationCardHeaderTitle>
|
|
617
|
+
<ChatNotificationCardHeaderTitleLabel>{label}</ChatNotificationCardHeaderTitleLabel>
|
|
618
|
+
{hasStatus && (
|
|
619
|
+
<ChatNotificationCardHeaderStatus priority={priority}>
|
|
620
|
+
{status}
|
|
621
|
+
</ChatNotificationCardHeaderStatus>
|
|
622
|
+
)}
|
|
623
|
+
</ChatNotificationCardHeaderTitle>
|
|
624
|
+
</ChatNotificationCardHeader>
|
|
625
|
+
<ChatNotificationCardActions>
|
|
626
|
+
{hasTimestamp && (
|
|
627
|
+
<ChatNotificationCardTimestamp>{timestamp}</ChatNotificationCardTimestamp>
|
|
628
|
+
)}
|
|
629
|
+
<ChatNotificationCardButtons>
|
|
630
|
+
{hasReadButton && (
|
|
631
|
+
<ChatNotificationCardReadActionButton isRead={isRead} onRead={onRead} />
|
|
632
|
+
)}
|
|
633
|
+
{hasSnoozeButton && (
|
|
634
|
+
<ChatNotificationCardSnoozeButton
|
|
635
|
+
snoozeUntilDate={snoozeUntilDate}
|
|
636
|
+
cancelLabel={cancelLabel}
|
|
637
|
+
onCancel={onCancelSnooze}
|
|
638
|
+
onClick={onSnooze}
|
|
639
|
+
/>
|
|
640
|
+
)}
|
|
641
|
+
{hasDeleteButton && <ChatNotificationCardDeleteButton onClick={onDelete} />}
|
|
642
|
+
{hasCloseButton && <ChatNotificationCardCloseButton onClick={onClose} />}
|
|
643
|
+
</ChatNotificationCardButtons>
|
|
644
|
+
</ChatNotificationCardActions>
|
|
645
|
+
</ChatNotificationCardHead>
|
|
646
|
+
<ChatNotificationCardContent>
|
|
647
|
+
{hasContentTitle && (
|
|
648
|
+
<ChatNotificationCardContentTitle>{title}</ChatNotificationCardContentTitle>
|
|
649
|
+
)}
|
|
650
|
+
<ChatNotificationCardContentDescription>
|
|
651
|
+
{description}
|
|
652
|
+
</ChatNotificationCardContentDescription>
|
|
653
|
+
{hasContentActions && (
|
|
654
|
+
<ChatNotificationCardContentActions>
|
|
655
|
+
<Button variant="secondary" size="sm" onClick={onAction}>
|
|
656
|
+
{actionLabel}
|
|
657
|
+
</Button>
|
|
658
|
+
</ChatNotificationCardContentActions>
|
|
659
|
+
)}
|
|
660
|
+
</ChatNotificationCardContent>
|
|
661
|
+
</ChatNotificationCard>
|
|
662
|
+
);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/** Every part of the card at once, with each part and prop on the Controls panel. */
|
|
666
|
+
export const Playground: StoryObj<typeof ChatNotificationCardPlayground> = {
|
|
667
|
+
tags: ['!autodocs'],
|
|
668
|
+
args: {
|
|
669
|
+
variant: 'default',
|
|
670
|
+
defaultExpanded: true,
|
|
671
|
+
icon: 'Mail',
|
|
672
|
+
label: BOARD_MEETING_MOVED.category,
|
|
673
|
+
hasStatus: true,
|
|
674
|
+
status: 'High',
|
|
675
|
+
priority: 'high',
|
|
676
|
+
hasTimestamp: true,
|
|
677
|
+
timestamp: BOARD_MEETING_MOVED.createdAt,
|
|
678
|
+
hasReadButton: true,
|
|
679
|
+
isRead: false,
|
|
680
|
+
hasSnoozeButton: true,
|
|
681
|
+
isSnoozed: false,
|
|
682
|
+
cancelLabel: 'Cancel',
|
|
683
|
+
hasDeleteButton: true,
|
|
684
|
+
hasCloseButton: true,
|
|
685
|
+
hasContentTitle: true,
|
|
686
|
+
title: BOARD_MEETING_MOVED.title,
|
|
687
|
+
description: BOARD_MEETING_MOVED.body,
|
|
688
|
+
hasContentActions: true,
|
|
689
|
+
actionLabel: 'Confirm attendance',
|
|
690
|
+
onRead: fn(),
|
|
691
|
+
onSnooze: fn(),
|
|
692
|
+
onCancelSnooze: fn(),
|
|
693
|
+
onDelete: fn(),
|
|
694
|
+
onClose: fn(),
|
|
695
|
+
onAction: fn(),
|
|
696
|
+
},
|
|
697
|
+
argTypes: {
|
|
698
|
+
icon: {
|
|
699
|
+
control: 'select',
|
|
700
|
+
options: ['None', 'Mail', 'Flight', 'Hourglass', 'AssignmentLate'],
|
|
701
|
+
mapping: {
|
|
702
|
+
None: undefined,
|
|
703
|
+
Mail: <MailIcon />,
|
|
704
|
+
Flight: <FlightIcon />,
|
|
705
|
+
Hourglass: <HourglassBottomIcon />,
|
|
706
|
+
AssignmentLate: <AssignmentLateIcon />,
|
|
707
|
+
},
|
|
708
|
+
description: 'Icon in `ChatNotificationCardHeaderIcon`.',
|
|
709
|
+
},
|
|
710
|
+
label: { control: 'text', description: 'Text of `ChatNotificationCardHeaderTitleLabel`.' },
|
|
711
|
+
hasStatus: { control: 'boolean', description: 'Renders `ChatNotificationCardHeaderStatus`.' },
|
|
712
|
+
status: { control: 'text', description: 'Text of the status chip.' },
|
|
713
|
+
priority: {
|
|
714
|
+
control: 'select',
|
|
715
|
+
options: ['low', 'medium', 'high'],
|
|
716
|
+
description:
|
|
717
|
+
'`priority` on the status chip: `high` is an error chip, `medium` a warning chip, `low` renders nothing.',
|
|
718
|
+
},
|
|
719
|
+
hasTimestamp: { control: 'boolean', description: 'Renders `ChatNotificationCardTimestamp`.' },
|
|
720
|
+
timestamp: { control: 'text', description: 'Text of the timestamp.' },
|
|
721
|
+
hasReadButton: {
|
|
722
|
+
control: 'boolean',
|
|
723
|
+
description: 'Renders `ChatNotificationCardReadActionButton`.',
|
|
724
|
+
},
|
|
725
|
+
isRead: { control: 'boolean', description: '`isRead` on the read button; swaps its icon.' },
|
|
726
|
+
hasSnoozeButton: {
|
|
727
|
+
control: 'boolean',
|
|
728
|
+
description: 'Renders `ChatNotificationCardSnoozeButton`.',
|
|
729
|
+
},
|
|
730
|
+
isSnoozed: {
|
|
731
|
+
control: 'boolean',
|
|
732
|
+
description:
|
|
733
|
+
'Passes a `snoozeUntilDate` 90 minutes from now, so the snooze button shows the time left.',
|
|
734
|
+
},
|
|
735
|
+
cancelLabel: {
|
|
736
|
+
control: 'text',
|
|
737
|
+
description: '`cancelLabel` on the snooze button, shown on hover while snoozed.',
|
|
738
|
+
},
|
|
739
|
+
hasDeleteButton: {
|
|
740
|
+
control: 'boolean',
|
|
741
|
+
description: 'Renders `ChatNotificationCardDeleteButton`.',
|
|
742
|
+
},
|
|
743
|
+
hasCloseButton: {
|
|
744
|
+
control: 'boolean',
|
|
745
|
+
description: 'Renders `ChatNotificationCardCloseButton`.',
|
|
746
|
+
},
|
|
747
|
+
hasContentTitle: {
|
|
748
|
+
control: 'boolean',
|
|
749
|
+
description: 'Renders `ChatNotificationCardContentTitle`.',
|
|
750
|
+
},
|
|
751
|
+
title: { control: 'text', description: 'Text of `ChatNotificationCardContentTitle`.' },
|
|
752
|
+
description: {
|
|
753
|
+
control: 'text',
|
|
754
|
+
description: 'Text of `ChatNotificationCardContentDescription`.',
|
|
755
|
+
},
|
|
756
|
+
hasContentActions: {
|
|
757
|
+
control: 'boolean',
|
|
758
|
+
description:
|
|
759
|
+
'Renders `ChatNotificationCardContentActions`, visible while the card is expanded.',
|
|
760
|
+
},
|
|
761
|
+
actionLabel: { control: 'text', description: 'Label of the button in the content actions.' },
|
|
762
|
+
onRead: { description: 'Called with the toggled read state.' },
|
|
763
|
+
onSnooze: { description: 'Called when the snooze icon button is clicked.' },
|
|
764
|
+
onCancelSnooze: { description: '`onCancel` on the snooze button, called while snoozed.' },
|
|
765
|
+
onDelete: { description: 'Called when the delete button is clicked.' },
|
|
766
|
+
onClose: { description: 'Called when the close button is clicked.' },
|
|
767
|
+
onAction: { description: 'Called when the content action is clicked.' },
|
|
768
|
+
},
|
|
769
|
+
render: (args) => <ChatNotificationCardPlayground {...args} />,
|
|
770
|
+
};
|