@swisper.ai/web-chat-ui 0.0.2 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -12
- package/dist/components/canvas-shell/canvas-shell.d.ts +32 -10
- package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -1
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts +49 -17
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.d.ts +1 -0
- package/dist/components/chat-card/chat-card.d.ts.map +1 -1
- package/dist/components/chat-card/chat-card.stories.d.ts +47 -1
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-body.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-footer.d.ts +8 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-form.d.ts +15 -2
- package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -1
- package/dist/components/chat-card/components/chat-card-header.d.ts +23 -2
- package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -1
- package/dist/components/chat-card/contexts.d.ts +2 -0
- package/dist/components/chat-card/contexts.d.ts.map +1 -1
- package/dist/components/chat-card/hooks.d.ts +1 -0
- package/dist/components/chat-card/hooks.d.ts.map +1 -1
- package/dist/components/chat-card/types.d.ts +3 -0
- package/dist/components/chat-card/types.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.d.ts +4 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts +12 -1
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.d.ts.map +1 -1
- package/dist/components/chat-container/chat-container.stories.d.ts +36 -11
- package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.d.ts +30 -2
- package/dist/components/chat-input/chat-input.d.ts.map +1 -1
- package/dist/components/chat-input/chat-input.stories.d.ts +63 -3
- package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -1
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +4 -1
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -1
- package/dist/components/chat-input/plugins/value-plugin.d.ts +4 -1
- package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-item.d.ts +6 -0
- package/dist/components/chat-list/chat-list-item.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list-items.d.ts +12 -1
- package/dist/components/chat-list/chat-list-items.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.d.ts +36 -2
- package/dist/components/chat-list/chat-list.d.ts.map +1 -1
- package/dist/components/chat-list/chat-list.stories.d.ts +67 -9
- package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.d.ts +12 -1
- package/dist/components/chat-message/chat-message.d.ts.map +1 -1
- package/dist/components/chat-message/chat-message.stories.d.ts +31 -0
- package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -1
- package/dist/components/chat-message/index.d.ts +1 -1
- package/dist/components/chat-message/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +3 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +25 -5
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +32 -1
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/index.d.ts +2 -2
- package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -1
- package/dist/components/chat-message-attachment-card/utils.d.ts +1 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -1
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts +13 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +22 -5
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +42 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts +1 -1
- package/dist/components/chat-message-toolbar/index.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.d.ts +34 -2
- package/dist/components/chat-messages/chat-messages.d.ts.map +1 -1
- package/dist/components/chat-messages/chat-messages.stories.d.ts +33 -2
- package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.d.ts +56 -4
- package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +50 -1
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +6 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +43 -1
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +37 -17
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +53 -1
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.d.ts +11 -0
- package/dist/components/chat-reply/chat-reply.d.ts.map +1 -1
- package/dist/components/chat-reply/chat-reply.stories.d.ts +23 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -1
- package/dist/components/chat-reply/index.d.ts +1 -1
- package/dist/components/chat-reply/index.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.d.ts +36 -10
- package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -1
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +66 -2
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -1
- package/dist/components/chat-suggestion/index.d.ts +2 -1
- package/dist/components/chat-suggestion/index.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +26 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +25 -1
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.d.ts +17 -2
- package/dist/components/chat-thread/chat-thread.d.ts.map +1 -1
- package/dist/components/chat-thread/chat-thread.stories.d.ts +75 -10
- package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -1
- package/dist/components/index.d.ts +1 -3
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts +8 -1
- package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +18 -1
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +4 -1
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts +4 -1
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.d.ts +17 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -1
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts +52 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -1
- package/dist/components/rich-text-area/styled.d.ts +6 -2
- package/dist/components/rich-text-area/styled.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +9 -2
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/index.d.ts +5 -5
- package/dist/components/rich-text-field/components/index.d.ts.map +1 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts +12 -1
- package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.d.ts +22 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts +28 -1
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -1
- package/dist/components/topmenu/index.d.ts +2 -0
- package/dist/components/topmenu/index.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.d.ts +22 -0
- package/dist/components/topmenu/topmenu.d.ts.map +1 -0
- package/dist/components/topmenu/topmenu.stories.d.ts +31 -0
- package/dist/components/topmenu/topmenu.stories.d.ts.map +1 -0
- package/dist/docs/agent.stories.d.ts.map +1 -1
- package/dist/docs/chat-panel.d.ts +7 -5
- package/dist/docs/chat-panel.d.ts.map +1 -1
- package/dist/docs/chatbot-panel.d.ts.map +1 -1
- package/dist/docs/chatbot.stories.d.ts.map +1 -1
- package/dist/index.css +1 -1
- package/dist/index.es.js +1801 -1806
- package/dist/index.es.js.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +9 -7
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +37 -9
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +41 -16
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +6 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +22 -1
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -1
- package/package.json +16 -10
- package/src/__storybook__/parent-block.tsx +21 -0
- package/src/components/canvas-shell/__stories__/canvas-panel.tsx +25 -0
- package/src/components/canvas-shell/__stories__/document-list.tsx +29 -0
- package/src/components/canvas-shell/__stories__/fixtures.ts +222 -0
- package/src/components/canvas-shell/__stories__/holdings-table.tsx +56 -0
- package/src/components/canvas-shell/__stories__/types.ts +47 -0
- package/src/components/canvas-shell/{canvas-shell.test.tsx → __tests__/canvas-shell.spec.tsx} +1 -1
- package/src/components/canvas-shell/canvas-shell.json +24 -0
- package/src/components/canvas-shell/canvas-shell.stories.tsx +581 -122
- package/src/components/canvas-shell/canvas-shell.tsx +44 -17
- package/src/components/chat-card/__stories__/fixtures.ts +119 -0
- package/src/components/chat-card/__stories__/types.ts +44 -0
- package/src/components/chat-card/chat-card.json +67 -3
- package/src/components/chat-card/chat-card.stories.tsx +872 -148
- package/src/components/chat-card/chat-card.tsx +2 -0
- package/src/components/chat-card/components/chat-card-body.tsx +12 -0
- package/src/components/chat-card/components/chat-card-footer.tsx +11 -0
- package/src/components/chat-card/components/chat-card-form.tsx +21 -2
- package/src/components/chat-card/components/chat-card-header.tsx +39 -2
- package/src/components/chat-card/contexts.tsx +2 -0
- package/src/components/chat-card/hooks.ts +1 -0
- package/src/components/chat-card/types.ts +3 -0
- package/src/components/chat-card-container/__stories__/fixtures.ts +54 -0
- package/src/components/chat-card-container/__stories__/resizable-chat-window.tsx +19 -0
- package/src/components/chat-card-container/__stories__/result-card.tsx +31 -0
- package/src/components/chat-card-container/__stories__/types.ts +16 -0
- package/src/components/chat-card-container/chat-card-container.json +7 -0
- package/src/components/chat-card-container/chat-card-container.stories.tsx +209 -56
- package/src/components/chat-card-container/chat-card-container.tsx +5 -0
- package/src/components/chat-container/__stories__/chat-composer.tsx +67 -0
- package/src/components/chat-container/__stories__/fixtures.ts +27 -0
- package/src/components/chat-container/__stories__/measure.ts +22 -0
- package/src/components/chat-container/__stories__/types.ts +7 -0
- package/src/components/chat-container/__stories__/variable-readout.tsx +64 -0
- package/src/components/chat-container/chat-container.json +9 -1
- package/src/components/chat-container/chat-container.stories.tsx +538 -106
- package/src/components/chat-container/chat-container.tsx +3 -0
- package/src/components/chat-input/__stories__/fixtures.ts +31 -0
- package/src/components/chat-input/__tests__/chat-input.spec.tsx +100 -0
- package/src/components/chat-input/chat-input.json +11 -2
- package/src/components/chat-input/chat-input.stories.tsx +660 -197
- package/src/components/chat-input/chat-input.tsx +39 -5
- package/src/components/chat-input/plugins/controlled-value-plugin.tsx +16 -3
- package/src/components/chat-input/plugins/value-plugin.tsx +19 -4
- package/src/components/chat-list/__stories__/chat-row.tsx +41 -0
- package/src/components/chat-list/__stories__/fixtures.ts +94 -0
- package/src/components/chat-list/__stories__/types.ts +13 -0
- package/src/components/chat-list/chat-list-item.tsx +6 -0
- package/src/components/chat-list/chat-list-items.tsx +16 -0
- package/src/components/chat-list/chat-list.json +24 -2
- package/src/components/chat-list/chat-list.stories.tsx +631 -215
- package/src/components/chat-list/chat-list.tsx +51 -4
- package/src/components/chat-message/__stories__/fixtures.ts +53 -0
- package/src/components/chat-message/__stories__/sent-attachment.tsx +22 -0
- package/src/components/chat-message/__stories__/tool-steps.tsx +37 -0
- package/src/components/chat-message/chat-message.json +10 -1
- package/src/components/chat-message/chat-message.stories.tsx +282 -20
- package/src/components/chat-message/chat-message.tsx +16 -1
- package/src/components/chat-message/index.ts +8 -1
- package/src/components/chat-message-attachment-card/__stories__/fixtures.ts +30 -0
- package/src/components/chat-message-attachment-card/__stories__/types.ts +14 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +4 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +20 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +266 -51
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +37 -4
- package/src/components/chat-message-attachment-card/index.ts +6 -0
- package/src/components/chat-message-attachment-card/utils.ts +1 -0
- package/src/components/chat-message-response/__stories__/fixtures.ts +50 -0
- package/src/components/chat-message-response/chat-message-response.json +5 -0
- package/src/components/chat-message-response/chat-message-response.stories.tsx +135 -26
- package/src/components/chat-message-toolbar/chat-message-toolbar.json +21 -3
- package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +377 -6
- package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +47 -12
- package/src/components/chat-message-toolbar/index.ts +4 -0
- package/src/components/chat-messages/__stories__/conversation-frame.tsx +25 -0
- package/src/components/chat-messages/__stories__/conversation-group.tsx +22 -0
- package/src/components/chat-messages/__stories__/fixtures.ts +70 -0
- package/src/components/chat-messages/__stories__/types.ts +5 -0
- package/src/components/chat-messages/chat-messages.json +30 -12
- package/src/components/chat-messages/chat-messages.stories.tsx +439 -212
- package/src/components/chat-messages/chat-messages.tsx +46 -3
- package/src/components/chat-notification-card/__stories__/fixtures.ts +38 -0
- package/src/components/chat-notification-card/__stories__/types.ts +13 -0
- package/src/components/chat-notification-card/chat-notification-card.json +52 -2
- package/src/components/chat-notification-card/chat-notification-card.stories.tsx +542 -62
- package/src/components/chat-notification-card/chat-notification-card.tsx +97 -6
- package/src/components/chat-notification-popup/__stories__/fixtures.ts +36 -0
- package/src/components/chat-notification-popup/__stories__/notification-item.tsx +93 -0
- package/src/components/chat-notification-popup/__stories__/types.ts +14 -0
- package/src/components/chat-notification-popup/chat-notification-popup.json +14 -1
- package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +467 -17
- package/src/components/chat-notification-popup/chat-notification-popup.tsx +18 -3
- package/src/components/chat-prompt-box/__stories__/fixtures.ts +16 -0
- package/src/components/chat-prompt-box/__stories__/types.ts +8 -0
- package/src/components/chat-prompt-box/chat-prompt-box.json +25 -2
- package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +535 -43
- package/src/components/chat-prompt-box/chat-prompt-box.tsx +73 -19
- package/src/components/chat-reply/chat-reply.json +10 -0
- package/src/components/chat-reply/chat-reply.stories.tsx +264 -21
- package/src/components/chat-reply/chat-reply.tsx +15 -0
- package/src/components/chat-reply/index.ts +10 -1
- package/src/components/chat-suggestion/__stories__/fixtures.ts +16 -0
- package/src/components/chat-suggestion/__tests__/chat-suggestion.spec.tsx +185 -0
- package/src/components/chat-suggestion/chat-suggestion.json +62 -20
- package/src/components/chat-suggestion/chat-suggestion.stories.tsx +542 -58
- package/src/components/chat-suggestion/chat-suggestion.tsx +154 -65
- package/src/components/chat-suggestion/index.ts +9 -0
- package/src/components/chat-thinking-process/__stories__/fixtures.ts +56 -0
- package/src/components/chat-thinking-process/chat-thinking-process.json +28 -3
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +354 -78
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +55 -4
- package/src/components/chat-thread/__stories__/fixtures.ts +171 -0
- package/src/components/chat-thread/__stories__/scroll-position.ts +9 -0
- package/src/components/chat-thread/__stories__/snippets.ts +129 -0
- package/src/components/chat-thread/__stories__/thread-frame.tsx +22 -0
- package/src/components/chat-thread/__stories__/thread-turns.tsx +35 -0
- package/src/components/chat-thread/__stories__/types.ts +12 -0
- package/src/components/chat-thread/__stories__/use-turn-stream.ts +78 -0
- package/src/components/chat-thread/chat-thread.json +23 -3
- package/src/components/chat-thread/chat-thread.stories.tsx +804 -142
- package/src/components/chat-thread/chat-thread.tsx +64 -16
- package/src/components/index.ts +1 -3
- package/src/components/markdown-viewer/__stories__/fixtures.ts +67 -0
- package/src/components/markdown-viewer/markdown-viewer.json +7 -1
- package/src/components/markdown-viewer/markdown-viewer.stories.tsx +219 -50
- package/src/components/markdown-viewer/markdown-viewer.tsx +9 -0
- package/src/components/rich-text-area/__stories__/fixtures.ts +30 -0
- package/src/components/rich-text-area/__tests__/rich-text-area.spec.tsx +114 -0
- package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +20 -3
- package/src/components/rich-text-area/plugins/value-plugin.tsx +16 -3
- package/src/components/rich-text-area/rich-text-area.json +7 -4
- package/src/components/rich-text-area/rich-text-area.stories.tsx +597 -41
- package/src/components/rich-text-area/rich-text-area.tsx +27 -4
- package/src/components/rich-text-area/styled.tsx +11 -5
- package/src/components/rich-text-field/__stories__/fixtures.ts +29 -0
- package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +10 -1
- package/src/components/rich-text-field/components/index.ts +8 -5
- package/src/components/rich-text-field/components/text-color-button.tsx +16 -2
- package/src/components/rich-text-field/rich-text-field.json +3 -1
- package/src/components/rich-text-field/rich-text-field.stories.tsx +452 -61
- package/src/components/rich-text-field/rich-text-field.tsx +23 -0
- package/src/components/topmenu/index.ts +1 -0
- package/src/components/topmenu/topmenu.json +107 -0
- package/src/components/topmenu/topmenu.stories.tsx +334 -0
- package/src/components/topmenu/topmenu.tsx +71 -0
- package/src/docs/agent.stories.tsx +16 -16
- package/src/docs/chat-panel.tsx +37 -32
- package/src/docs/chatbot-panel.tsx +11 -2
- package/src/docs/chatbot.mdx +17 -12
- package/src/docs/chatbot.stories.tsx +7 -8
- package/src/layouts/chat-card-list-layout/__stories__/fixtures.ts +112 -0
- package/src/layouts/chat-card-list-layout/__stories__/result-card.tsx +36 -0
- package/src/layouts/chat-card-list-layout/__stories__/types.ts +31 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +14 -1
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +316 -84
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +11 -7
- package/src/layouts/chat-card-three-column-layout/__stories__/fixtures.ts +117 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/resizable-chat-window.tsx +18 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-details.tsx +85 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-list.tsx +50 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-map.tsx +44 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/stay-rooms.tsx +61 -0
- package/src/layouts/chat-card-three-column-layout/__stories__/types.ts +35 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +16 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +603 -182
- package/src/layouts/chat-card-two-column-layout/__stories__/connection-itinerary.tsx +51 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/fixtures.ts +83 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/route-map.tsx +24 -0
- package/src/layouts/chat-card-two-column-layout/__stories__/types.ts +15 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +13 -1
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +368 -67
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +11 -2
- package/dist/components/card-item-picker/card-item-picker-context.d.ts +0 -21
- package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-list.d.ts +0 -24
- package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +0 -28
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker-row.d.ts +0 -12
- package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +0 -1
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts +0 -19
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +0 -1
- package/dist/components/card-item-picker/index.d.ts +0 -9
- package/dist/components/card-item-picker/index.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.d.ts +0 -48
- package/dist/components/chat-message-history/chat-message-history.d.ts.map +0 -1
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts +0 -7
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +0 -1
- package/dist/components/chat-message-history/index.d.ts +0 -2
- package/dist/components/chat-message-history/index.d.ts.map +0 -1
- package/dist/components/spinner/index.d.ts +0 -2
- package/dist/components/spinner/index.d.ts.map +0 -1
- package/dist/components/spinner/spinner.d.ts +0 -9
- package/dist/components/spinner/spinner.d.ts.map +0 -1
- package/dist/components/spinner/spinner.stories.d.ts +0 -8
- package/dist/components/spinner/spinner.stories.d.ts.map +0 -1
- package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +0 -279
- package/src/components/card-item-picker/card-item-picker-context.tsx +0 -44
- package/src/components/card-item-picker/card-item-picker-list.tsx +0 -95
- package/src/components/card-item-picker/card-item-picker-row-parts.tsx +0 -96
- package/src/components/card-item-picker/card-item-picker-row.tsx +0 -109
- package/src/components/card-item-picker/card-item-picker.json +0 -147
- package/src/components/card-item-picker/card-item-picker.stories.tsx +0 -158
- package/src/components/card-item-picker/index.ts +0 -24
- package/src/components/chat-message-history/chat-message-history.json +0 -99
- package/src/components/chat-message-history/chat-message-history.stories.tsx +0 -136
- package/src/components/chat-message-history/chat-message-history.tsx +0 -277
- package/src/components/chat-message-history/index.ts +0 -13
- package/src/components/spinner/index.ts +0 -1
- package/src/components/spinner/spinner.json +0 -73
- package/src/components/spinner/spinner.stories.tsx +0 -41
- package/src/components/spinner/spinner.tsx +0 -32
|
@@ -1,29 +1,50 @@
|
|
|
1
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import { useState } from 'react';
|
|
3
|
-
import { fn } from 'storybook/test';
|
|
2
|
+
import { useId, useState } from 'react';
|
|
3
|
+
import { expect, fn } from 'storybook/test';
|
|
4
4
|
|
|
5
|
-
import {
|
|
5
|
+
import { SignatureIcon } from '@swisper.ai/icons';
|
|
6
|
+
import { Button, Divider, Typography } from '@swisper.ai/ui';
|
|
6
7
|
|
|
7
|
-
import {
|
|
8
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
EMAIL_ATTACHMENT_TYPES,
|
|
12
|
+
EVENT_DESCRIPTION_HTML,
|
|
13
|
+
HANDOVER_NOTE_MARKDOWN,
|
|
14
|
+
INCOMING_MESSAGE,
|
|
15
|
+
REPLY_DRAFT_MARKDOWN,
|
|
16
|
+
} from './__stories__/fixtures';
|
|
17
|
+
import {
|
|
18
|
+
AlignmentSelect,
|
|
19
|
+
AttachmentButton,
|
|
20
|
+
BoldButton,
|
|
21
|
+
CleanFormatButton,
|
|
22
|
+
ImageButton,
|
|
23
|
+
ItalicButton,
|
|
24
|
+
LinkButton,
|
|
25
|
+
SizeSelect,
|
|
26
|
+
TextColorButton,
|
|
27
|
+
ToolbarButton,
|
|
28
|
+
TypographySelect,
|
|
29
|
+
UnderlineButton,
|
|
30
|
+
} from './components';
|
|
31
|
+
import { RichTextField, type RichTextFieldProps } from './rich-text-field';
|
|
8
32
|
|
|
9
33
|
const meta: Meta<typeof RichTextField> = {
|
|
10
|
-
title: '
|
|
34
|
+
title: 'Chat/RichTextField',
|
|
11
35
|
component: RichTextField,
|
|
12
36
|
parameters: {
|
|
13
37
|
layout: 'padded',
|
|
14
38
|
},
|
|
15
39
|
decorators: [
|
|
16
40
|
(Story) => (
|
|
17
|
-
<div
|
|
41
|
+
<div className="relative w-full max-w-172">
|
|
18
42
|
<Story />
|
|
19
43
|
</div>
|
|
20
44
|
),
|
|
21
45
|
],
|
|
22
46
|
args: {
|
|
23
|
-
className:
|
|
24
|
-
'rich-text-area w-full h-full',
|
|
25
|
-
'text-text-primary font-noto-sans font-normal text-base leading-[160%]',
|
|
26
|
-
),
|
|
47
|
+
className: 'font-noto-sans text-base leading-relaxed text-text-primary',
|
|
27
48
|
toolbarPlacement: 'top',
|
|
28
49
|
source: 'markdown',
|
|
29
50
|
placeholder: 'Write a reply',
|
|
@@ -135,84 +156,454 @@ const meta: Meta<typeof RichTextField> = {
|
|
|
135
156
|
export default meta;
|
|
136
157
|
type Story = StoryObj<typeof RichTextField>;
|
|
137
158
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
159
|
+
/** The reply body as a form holds it: every edit is written back to the value, shown underneath as it is stored. */
|
|
160
|
+
function ReplyBodyField({ value: initialValue, onChange, ...rest }: RichTextFieldProps) {
|
|
161
|
+
const [value, setValue] = useState(initialValue);
|
|
141
162
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
163
|
+
const handleChange = (nextValue: string) => {
|
|
164
|
+
setValue(nextValue);
|
|
165
|
+
onChange?.(nextValue);
|
|
166
|
+
};
|
|
146
167
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
placeholder: 'Type something...',
|
|
151
|
-
},
|
|
152
|
-
render: (args) => {
|
|
153
|
-
const [value, setValue] = useState(args.value);
|
|
168
|
+
return (
|
|
169
|
+
<div className="flex flex-col gap-16">
|
|
170
|
+
<RichTextField {...rest} value={value} onChange={handleChange} />
|
|
154
171
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
<pre
|
|
160
|
-
style={{
|
|
161
|
-
padding: 12,
|
|
162
|
-
borderRadius: 8,
|
|
163
|
-
background: '#1a1a2e',
|
|
164
|
-
color: '#e0e0e0',
|
|
165
|
-
fontSize: 12,
|
|
166
|
-
whiteSpace: 'pre-wrap',
|
|
167
|
-
}}
|
|
168
|
-
>
|
|
172
|
+
<div className="flex flex-col gap-4">
|
|
173
|
+
<Typography variant="caption-md" className="text-text-tertiary">
|
|
174
|
+
Stored value
|
|
175
|
+
</Typography>
|
|
176
|
+
<pre className="rounded-sm bg-paper-elevation-1 p-12 font-mono text-xs whitespace-pre-wrap text-text-secondary">
|
|
169
177
|
{value}
|
|
170
178
|
</pre>
|
|
171
179
|
</div>
|
|
172
|
-
|
|
180
|
+
</div>
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** An email reply with the full toolbar above the text, and the Markdown it is stored as underneath. */
|
|
185
|
+
export const Default: Story = {
|
|
186
|
+
args: {
|
|
187
|
+
value: REPLY_DRAFT_MARKDOWN,
|
|
173
188
|
},
|
|
189
|
+
render: (args) => <ReplyBodyField {...args} />,
|
|
174
190
|
};
|
|
175
191
|
|
|
192
|
+
/** A new reply: the placeholder says what to write and sits below the toolbar. */
|
|
176
193
|
export const Empty: Story = {
|
|
177
194
|
args: {
|
|
178
|
-
placeholder: '
|
|
195
|
+
placeholder: 'Write a reply',
|
|
179
196
|
},
|
|
180
197
|
};
|
|
181
198
|
|
|
199
|
+
/** The reply while it is being sent: the text is dimmed and can't be edited. */
|
|
182
200
|
export const Disabled: Story = {
|
|
183
201
|
args: {
|
|
184
|
-
value:
|
|
202
|
+
value: REPLY_DRAFT_MARKDOWN,
|
|
185
203
|
isDisabled: true,
|
|
186
|
-
placeholder: 'Disabled editor',
|
|
187
204
|
},
|
|
188
205
|
};
|
|
189
206
|
|
|
207
|
+
/** The toolbar under the text, for a reply written below the message it answers. */
|
|
190
208
|
export const ToolbarBottom: Story = {
|
|
191
209
|
args: {
|
|
192
|
-
value:
|
|
193
|
-
placeholder: 'Type something...',
|
|
210
|
+
value: REPLY_DRAFT_MARKDOWN,
|
|
194
211
|
toolbarPlacement: 'bottom',
|
|
195
212
|
},
|
|
196
|
-
render: (args) => {
|
|
197
|
-
|
|
213
|
+
render: (args) => <ReplyBodyField {...args} />,
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
/** A calendar event description with only the controls its HTML keeps: no typeface, size, link, attachment or image. */
|
|
217
|
+
export const CustomToolbar: Story = {
|
|
218
|
+
args: {
|
|
219
|
+
source: 'html',
|
|
220
|
+
value: EVENT_DESCRIPTION_HTML,
|
|
221
|
+
placeholder: 'Add a description',
|
|
222
|
+
toolbarChildren: () => (
|
|
223
|
+
<>
|
|
224
|
+
<BoldButton />
|
|
225
|
+
<ItalicButton />
|
|
226
|
+
<UnderlineButton />
|
|
227
|
+
<TextColorButton />
|
|
228
|
+
|
|
229
|
+
<Divider orientation="vertical" />
|
|
230
|
+
|
|
231
|
+
<AlignmentSelect />
|
|
232
|
+
|
|
233
|
+
<Divider orientation="vertical" />
|
|
234
|
+
|
|
235
|
+
<CleanFormatButton />
|
|
236
|
+
</>
|
|
237
|
+
),
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
/** The email body with its attachments: the field hands over the picked files, and the form lists them. */
|
|
242
|
+
function EmailBodyField({ onFileAttach, ...rest }: RichTextFieldProps) {
|
|
243
|
+
const [attachments, setAttachments] = useState<string[]>([]);
|
|
244
|
+
|
|
245
|
+
const handleFileAttach = (files: File[]) => {
|
|
246
|
+
setAttachments((current) => [...current, ...files.map((file) => file.name)]);
|
|
247
|
+
onFileAttach?.(files);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
return (
|
|
251
|
+
<div className="flex flex-col gap-8">
|
|
252
|
+
<RichTextField {...rest} onFileAttach={handleFileAttach} />
|
|
253
|
+
|
|
254
|
+
{attachments.length > 0 && (
|
|
255
|
+
<ul aria-label="Attachments" className="flex flex-col gap-4">
|
|
256
|
+
{attachments.map((name, index) => (
|
|
257
|
+
<Typography key={`${name}-${index}`} variant="caption-md" asChild>
|
|
258
|
+
<li>{name}</li>
|
|
259
|
+
</Typography>
|
|
260
|
+
))}
|
|
261
|
+
</ul>
|
|
262
|
+
)}
|
|
263
|
+
</div>
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** An email body that takes several documents: the attachment button is enabled and the picker is limited to document types. */
|
|
268
|
+
export const WithAttachments: Story = {
|
|
269
|
+
args: {
|
|
270
|
+
source: 'html',
|
|
271
|
+
toolbarPlacement: 'bottom',
|
|
272
|
+
placeholder: 'Write your email',
|
|
273
|
+
enableAttachments: true,
|
|
274
|
+
isMultipleAttachments: true,
|
|
275
|
+
acceptedFiles: EMAIL_ATTACHMENT_TYPES,
|
|
276
|
+
onFileAttach: fn(),
|
|
277
|
+
},
|
|
278
|
+
render: (args) => <EmailBodyField {...args} />,
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
/** Typing fills the reply and reports it as Markdown; the bold shortcut formats the next words and lights the bold button. */
|
|
282
|
+
export const EmptyTypeAndFormat: Story = {
|
|
283
|
+
...Empty,
|
|
284
|
+
tags: ['e2e', '!autodocs'],
|
|
285
|
+
args: { placeholder: 'Write a reply', onChange: fn() },
|
|
286
|
+
play: async ({ args, canvas, canvasElement, userEvent, step }) => {
|
|
287
|
+
// TODO(echo-ds): the field has no label prop, so the editable element has no accessible name.
|
|
288
|
+
const editor = canvas.getByRole('textbox');
|
|
289
|
+
const root = canvasElement.querySelector('[data-slot="rich-text-field"]');
|
|
290
|
+
const boldButton = canvas.getByRole('button', { name: 'Format Bold' });
|
|
291
|
+
|
|
292
|
+
await step('Starts empty with the placeholder and the toolbar on top', async () => {
|
|
293
|
+
await expect(root).toHaveAttribute('data-toolbar-placement', 'top');
|
|
294
|
+
await expect(editor).toHaveAttribute('aria-placeholder', 'Write a reply');
|
|
295
|
+
await expect(canvas.getByText('Write a reply')).toBeVisible();
|
|
296
|
+
await expect(canvasElement.querySelector('[data-slot="rich-text-field-toolbar"]')).toBe(
|
|
297
|
+
boldButton.parentElement,
|
|
298
|
+
);
|
|
299
|
+
});
|
|
300
|
+
|
|
301
|
+
await step('The default toolbar disables link, image and attachment', async () => {
|
|
302
|
+
await expect(canvas.getByRole('button', { name: 'Add Link' })).toBeDisabled();
|
|
303
|
+
await expect(canvas.getByRole('button', { name: 'Add Image' })).toBeDisabled();
|
|
304
|
+
await expect(canvas.getByRole('button', { name: 'Add Attachment' })).toBeDisabled();
|
|
305
|
+
await expect(canvas.getByRole('button', { name: 'Reset Formatting' })).toBeEnabled();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
await step('Typing replaces the placeholder and reports the text', async () => {
|
|
309
|
+
await userEvent.click(editor);
|
|
310
|
+
await userEvent.keyboard('Tuesday works');
|
|
311
|
+
await expect(editor).toHaveTextContent('Tuesday works');
|
|
312
|
+
await expect(canvas.queryByText('Write a reply')).toBeNull();
|
|
313
|
+
await expect(args.onChange).toHaveBeenLastCalledWith('Tuesday works');
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
await step('The bold button formats what is typed next', async () => {
|
|
317
|
+
await expect(boldButton).not.toHaveAttribute('data-active');
|
|
318
|
+
await userEvent.click(boldButton);
|
|
319
|
+
await expect(boldButton).toHaveAttribute('data-active');
|
|
320
|
+
await userEvent.click(editor);
|
|
321
|
+
await userEvent.keyboard(' for us');
|
|
322
|
+
await expect(editor).toHaveTextContent('Tuesday works for us');
|
|
323
|
+
await expect(args.onChange).toHaveBeenLastCalledWith(expect.stringContaining('**'));
|
|
324
|
+
});
|
|
325
|
+
},
|
|
326
|
+
};
|
|
327
|
+
|
|
328
|
+
/** A disabled field marks itself disabled and its text can't be edited or reached with Tab. */
|
|
329
|
+
export const DisabledIsReadOnly: Story = {
|
|
330
|
+
...Disabled,
|
|
331
|
+
tags: ['e2e', '!autodocs'],
|
|
332
|
+
args: { value: REPLY_DRAFT_MARKDOWN, isDisabled: true, onChange: fn() },
|
|
333
|
+
play: async ({ canvas, canvasElement }) => {
|
|
334
|
+
const editor = canvas.getByRole('textbox');
|
|
335
|
+
const root = canvasElement.querySelector('[data-slot="rich-text-field"]');
|
|
336
|
+
|
|
337
|
+
await expect(root).toHaveAttribute('data-disabled', 'true');
|
|
338
|
+
await expect(root).toHaveAttribute('aria-disabled', 'true');
|
|
339
|
+
await expect(editor).toHaveAttribute('contenteditable', 'false');
|
|
340
|
+
await expect(editor).toHaveAttribute('aria-readonly', 'true');
|
|
341
|
+
await expect(editor).toHaveTextContent('Tuesday at 14:00 works for us');
|
|
342
|
+
},
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
/** The toolbar placement is on the root, and the toolbar follows the text in the bottom layout. */
|
|
346
|
+
export const ToolbarBottomPlacement: Story = {
|
|
347
|
+
...ToolbarBottom,
|
|
348
|
+
tags: ['e2e', '!autodocs'],
|
|
349
|
+
args: { value: REPLY_DRAFT_MARKDOWN, toolbarPlacement: 'bottom' },
|
|
350
|
+
play: async ({ canvas, canvasElement }) => {
|
|
351
|
+
const editor = canvas.getByRole('textbox');
|
|
352
|
+
const root = canvasElement.querySelector('[data-slot="rich-text-field"]');
|
|
353
|
+
const toolbar = canvasElement.querySelector('[data-slot="rich-text-field-toolbar"]');
|
|
354
|
+
|
|
355
|
+
await expect(root).toHaveAttribute('data-toolbar-placement', 'bottom');
|
|
356
|
+
await expect(toolbar).toBeVisible();
|
|
357
|
+
await expect(toolbar?.getBoundingClientRect().top).toBeGreaterThan(
|
|
358
|
+
editor.getBoundingClientRect().top,
|
|
359
|
+
);
|
|
360
|
+
await expect(toolbar?.getBoundingClientRect().bottom).toBe(
|
|
361
|
+
root?.getBoundingClientRect().bottom,
|
|
362
|
+
);
|
|
363
|
+
await expect(canvas.getByText(/Tuesday at 14:00/, { selector: 'pre' })).toBeVisible();
|
|
364
|
+
},
|
|
365
|
+
};
|
|
366
|
+
|
|
367
|
+
/** A custom toolbar renders only the controls it was given. */
|
|
368
|
+
export const CustomToolbarControls: Story = {
|
|
369
|
+
...CustomToolbar,
|
|
370
|
+
tags: ['e2e', '!autodocs'],
|
|
371
|
+
play: async ({ canvas, canvasElement }) => {
|
|
372
|
+
await expect(canvas.getByRole('textbox')).toHaveTextContent('Agenda for the quarterly');
|
|
373
|
+
|
|
374
|
+
for (const name of [
|
|
375
|
+
'Format Bold',
|
|
376
|
+
'Format Italics',
|
|
377
|
+
'Format Underline',
|
|
378
|
+
'Text Color',
|
|
379
|
+
'Reset Formatting',
|
|
380
|
+
]) {
|
|
381
|
+
await expect(canvas.getByRole('button', { name })).toBeEnabled();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
for (const name of ['Add Link', 'Add Attachment', 'Add Image']) {
|
|
385
|
+
await expect(canvas.queryByRole('button', { name })).toBeNull();
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// Only the alignment select is left: the typeface and size selects were not passed.
|
|
389
|
+
await expect(canvas.getAllByRole('combobox')).toHaveLength(1);
|
|
390
|
+
await expect(
|
|
391
|
+
canvasElement.querySelector('[data-slot="rich-text-field-text-color"]'),
|
|
392
|
+
).toContainElement(canvas.getByRole('button', { name: 'Text Color' }));
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
/** Picking documents hands every file to `onFileAttach`, and the picker is limited to the accepted types. */
|
|
397
|
+
export const WithAttachmentsPickFiles: Story = {
|
|
398
|
+
...WithAttachments,
|
|
399
|
+
tags: ['e2e', '!autodocs'],
|
|
400
|
+
args: {
|
|
401
|
+
source: 'html',
|
|
402
|
+
toolbarPlacement: 'bottom',
|
|
403
|
+
placeholder: 'Write your email',
|
|
404
|
+
enableAttachments: true,
|
|
405
|
+
isMultipleAttachments: true,
|
|
406
|
+
acceptedFiles: EMAIL_ATTACHMENT_TYPES,
|
|
407
|
+
onFileAttach: fn(),
|
|
408
|
+
},
|
|
409
|
+
play: async ({ args, canvas, canvasElement, userEvent, step }) => {
|
|
410
|
+
// The file input is hidden from assistive technology on purpose; the attachment button is its
|
|
411
|
+
// accessible control, and a test can't drive the browser's file dialog through it.
|
|
412
|
+
const picker = canvasElement.querySelector<HTMLInputElement>('input[type="file"]');
|
|
413
|
+
const offer = new File(['offer'], 'offer-2026-014.pdf', { type: 'application/pdf' });
|
|
414
|
+
const priceList = new File(['prices'], 'price-list.xlsx', {
|
|
415
|
+
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
|
416
|
+
});
|
|
417
|
+
|
|
418
|
+
await step('The attachment button is enabled and the picker takes documents', async () => {
|
|
419
|
+
await expect(canvas.getByRole('button', { name: 'Add Attachment' })).toBeEnabled();
|
|
420
|
+
await expect(picker).toHaveAttribute('accept', EMAIL_ATTACHMENT_TYPES.join(','));
|
|
421
|
+
await expect(picker).toHaveAttribute('multiple');
|
|
422
|
+
});
|
|
423
|
+
|
|
424
|
+
await step('Picked files reach the form', async () => {
|
|
425
|
+
await userEvent.upload(picker!, [offer, priceList]);
|
|
426
|
+
await expect(args.onFileAttach).toHaveBeenCalledWith([offer, priceList]);
|
|
427
|
+
|
|
428
|
+
const attachments = canvas.getByRole('list', { name: 'Attachments' });
|
|
429
|
+
await expect(attachments).toHaveTextContent('offer-2026-014.pdf');
|
|
430
|
+
await expect(attachments).toHaveTextContent('price-list.xlsx');
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
const formattingOnlyToolbar: RichTextFieldProps['toolbarChildren'] = () => (
|
|
436
|
+
<>
|
|
437
|
+
<BoldButton />
|
|
438
|
+
<ItalicButton />
|
|
439
|
+
<UnderlineButton />
|
|
440
|
+
<TextColorButton />
|
|
441
|
+
|
|
442
|
+
<Divider orientation="vertical" />
|
|
443
|
+
|
|
444
|
+
<AlignmentSelect />
|
|
445
|
+
|
|
446
|
+
<Divider orientation="vertical" />
|
|
447
|
+
|
|
448
|
+
<CleanFormatButton />
|
|
449
|
+
</>
|
|
450
|
+
);
|
|
451
|
+
|
|
452
|
+
/** The field in each place it's used: a reply composer, a form section and a dialog body. */
|
|
453
|
+
export const Examples: Story = {
|
|
454
|
+
parameters: { controls: { disable: true } },
|
|
455
|
+
render: function ExamplesStory(args) {
|
|
456
|
+
const descriptionLabelId = useId();
|
|
457
|
+
const noteTitleId = useId();
|
|
198
458
|
|
|
199
459
|
return (
|
|
200
|
-
<div
|
|
201
|
-
<
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
460
|
+
<div className="flex flex-col gap-24">
|
|
461
|
+
<ParentBlock parent="reply composer">
|
|
462
|
+
<section aria-label="Reply to Lena Brunner" className="flex flex-col gap-12">
|
|
463
|
+
<div className="flex flex-col gap-4 rounded-sm border border-divider-border-base p-12">
|
|
464
|
+
<Typography variant="caption-md" className="text-text-tertiary">
|
|
465
|
+
{INCOMING_MESSAGE.sender} · {INCOMING_MESSAGE.receivedAt}
|
|
466
|
+
</Typography>
|
|
467
|
+
<Typography variant="body-small-high">{INCOMING_MESSAGE.text}</Typography>
|
|
468
|
+
</div>
|
|
469
|
+
<RichTextField
|
|
470
|
+
className={args.className}
|
|
471
|
+
source="html"
|
|
472
|
+
toolbarPlacement="bottom"
|
|
473
|
+
placeholder="Write a reply"
|
|
474
|
+
enableAttachments
|
|
475
|
+
isMultipleAttachments
|
|
476
|
+
acceptedFiles={EMAIL_ATTACHMENT_TYPES}
|
|
477
|
+
onFileAttach={fn()}
|
|
478
|
+
onChange={fn()}
|
|
479
|
+
/>
|
|
480
|
+
<div className="flex justify-end">
|
|
481
|
+
<Button variant="primary">Send reply</Button>
|
|
482
|
+
</div>
|
|
483
|
+
</section>
|
|
484
|
+
</ParentBlock>
|
|
485
|
+
|
|
486
|
+
<ParentBlock parent="form section">
|
|
487
|
+
<section
|
|
488
|
+
aria-labelledby={descriptionLabelId}
|
|
489
|
+
className="flex flex-col gap-8 rounded-sm border border-divider-border-base p-16"
|
|
490
|
+
>
|
|
491
|
+
<Typography id={descriptionLabelId} variant="body-small-high" fontWeight="medium">
|
|
492
|
+
Description
|
|
493
|
+
</Typography>
|
|
494
|
+
<RichTextField
|
|
495
|
+
className={args.className}
|
|
496
|
+
name="description"
|
|
497
|
+
source="html"
|
|
498
|
+
value={EVENT_DESCRIPTION_HTML}
|
|
499
|
+
placeholder="Add a description"
|
|
500
|
+
toolbarChildren={formattingOnlyToolbar}
|
|
501
|
+
onChange={fn()}
|
|
502
|
+
/>
|
|
503
|
+
</section>
|
|
504
|
+
</ParentBlock>
|
|
505
|
+
|
|
506
|
+
<ParentBlock parent="dialog body">
|
|
507
|
+
<section
|
|
508
|
+
aria-labelledby={noteTitleId}
|
|
509
|
+
className="flex max-w-120 flex-col gap-16 rounded-15 border border-divider-border-base bg-paper-elevation-0 p-24"
|
|
510
|
+
>
|
|
511
|
+
<Typography id={noteTitleId} variant="body-small-high" fontWeight="medium">
|
|
512
|
+
Add a handover note
|
|
513
|
+
</Typography>
|
|
514
|
+
<RichTextField
|
|
515
|
+
className={args.className}
|
|
516
|
+
value={HANDOVER_NOTE_MARKDOWN}
|
|
517
|
+
placeholder="Write a note for the next shift"
|
|
518
|
+
toolbarChildren={formattingOnlyToolbar}
|
|
519
|
+
onChange={fn()}
|
|
520
|
+
/>
|
|
521
|
+
<div className="flex justify-end gap-8">
|
|
522
|
+
<Button variant="tertiary">Cancel</Button>
|
|
523
|
+
<Button variant="primary">Save note</Button>
|
|
524
|
+
</div>
|
|
525
|
+
</section>
|
|
526
|
+
</ParentBlock>
|
|
215
527
|
</div>
|
|
216
528
|
);
|
|
217
529
|
},
|
|
218
530
|
};
|
|
531
|
+
|
|
532
|
+
type PlaygroundToolbar = 'Default' | 'Formatting only' | 'Every control';
|
|
533
|
+
|
|
534
|
+
const PLAYGROUND_TOOLBARS: Record<PlaygroundToolbar, RichTextFieldProps['toolbarChildren']> = {
|
|
535
|
+
Default: undefined,
|
|
536
|
+
'Formatting only': formattingOnlyToolbar,
|
|
537
|
+
'Every control': ({ hasAttachments }) => (
|
|
538
|
+
<>
|
|
539
|
+
<TypographySelect />
|
|
540
|
+
<SizeSelect />
|
|
541
|
+
|
|
542
|
+
<Divider orientation="vertical" />
|
|
543
|
+
|
|
544
|
+
<BoldButton />
|
|
545
|
+
<ItalicButton />
|
|
546
|
+
<UnderlineButton />
|
|
547
|
+
<TextColorButton />
|
|
548
|
+
|
|
549
|
+
<Divider orientation="vertical" />
|
|
550
|
+
|
|
551
|
+
<LinkButton isDisabled />
|
|
552
|
+
<AttachmentButton isDisabled={!hasAttachments} />
|
|
553
|
+
<ImageButton isDisabled />
|
|
554
|
+
|
|
555
|
+
<Divider orientation="vertical" />
|
|
556
|
+
|
|
557
|
+
<AlignmentSelect />
|
|
558
|
+
|
|
559
|
+
<Divider orientation="vertical" />
|
|
560
|
+
|
|
561
|
+
<CleanFormatButton />
|
|
562
|
+
<ToolbarButton aria-label="Insert signature">
|
|
563
|
+
<SignatureIcon />
|
|
564
|
+
</ToolbarButton>
|
|
565
|
+
</>
|
|
566
|
+
),
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
interface RichTextFieldPlaygroundProps extends Omit<RichTextFieldProps, 'toolbarChildren'> {
|
|
570
|
+
toolbar: PlaygroundToolbar;
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function RichTextFieldPlayground({ toolbar, ...rest }: RichTextFieldPlaygroundProps) {
|
|
574
|
+
return <RichTextField {...rest} toolbarChildren={PLAYGROUND_TOOLBARS[toolbar]} />;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** Every toolbar control at once, including a custom `ToolbarButton`, with each prop of the field on the Controls panel. */
|
|
578
|
+
export const Playground: StoryObj<typeof RichTextFieldPlayground> = {
|
|
579
|
+
tags: ['!autodocs'],
|
|
580
|
+
args: {
|
|
581
|
+
toolbar: 'Every control',
|
|
582
|
+
value: REPLY_DRAFT_MARKDOWN,
|
|
583
|
+
source: 'markdown',
|
|
584
|
+
placeholder: 'Write a reply',
|
|
585
|
+
toolbarPlacement: 'top',
|
|
586
|
+
isDisabled: false,
|
|
587
|
+
enableAttachments: true,
|
|
588
|
+
isMultipleAttachments: true,
|
|
589
|
+
acceptedFiles: EMAIL_ATTACHMENT_TYPES,
|
|
590
|
+
name: 'body',
|
|
591
|
+
containerClassName: '',
|
|
592
|
+
placeholderClassName: '',
|
|
593
|
+
toolbarClassName: '',
|
|
594
|
+
onChange: fn(),
|
|
595
|
+
onBlur: fn(),
|
|
596
|
+
onKeyDown: fn(),
|
|
597
|
+
onFocusChange: fn(),
|
|
598
|
+
onFileAttach: fn(),
|
|
599
|
+
},
|
|
600
|
+
argTypes: {
|
|
601
|
+
toolbar: {
|
|
602
|
+
control: 'select',
|
|
603
|
+
options: ['Default', 'Formatting only', 'Every control'],
|
|
604
|
+
description:
|
|
605
|
+
'What `toolbarChildren` renders: nothing passed (the default set), the formatting buttons only, or every exported control plus a custom `ToolbarButton`.',
|
|
606
|
+
},
|
|
607
|
+
},
|
|
608
|
+
render: (args) => <RichTextFieldPlayground {...args} />,
|
|
609
|
+
};
|
|
@@ -8,19 +8,41 @@ import { FileAttachmentPlugin } from '../rich-text-area/plugins/file-attachment-
|
|
|
8
8
|
import { FormattingToolbarPlugin } from './components/formatting-toolbar-plugin';
|
|
9
9
|
import { RichTextFieldContextProvider } from './context';
|
|
10
10
|
|
|
11
|
+
/** Where the formatting toolbar sits inside the field: above or below the text. */
|
|
11
12
|
export type RichTextFieldToolbarPlacement = 'top' | 'bottom';
|
|
12
13
|
|
|
13
14
|
export interface RichTextFieldProps extends Omit<RichTextAreaProps, 'children'> {
|
|
15
|
+
/** Accepted for type compatibility with `RichTextArea` but not rendered; use `toolbarChildren`. */
|
|
14
16
|
children?: ReactNode;
|
|
17
|
+
/**
|
|
18
|
+
* Puts the toolbar above or below the text. The text padding and the placeholder offset follow
|
|
19
|
+
* it, and the root carries it as `data-toolbar-placement`.
|
|
20
|
+
* @default 'top'
|
|
21
|
+
*/
|
|
15
22
|
toolbarPlacement?: RichTextFieldToolbarPlacement;
|
|
23
|
+
/** Classes for the toolbar (`data-slot="rich-text-field-toolbar"`), merged last. */
|
|
16
24
|
toolbarClassName?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Replaces the default toolbar controls. Receives `{ hasAttachments }` (the `enableAttachments`
|
|
27
|
+
* value) and returns the toolbar content, built from the exported buttons and selects.
|
|
28
|
+
*/
|
|
17
29
|
toolbarChildren?: ({ hasAttachments }: { hasAttachments: boolean }) => ReactNode;
|
|
30
|
+
/** Lets the file picker select several files; `onFileAttach` gets only the first otherwise. */
|
|
18
31
|
isMultipleAttachments?: boolean;
|
|
32
|
+
/** Enables the attachment button of the default toolbar; it is shown disabled otherwise. */
|
|
19
33
|
enableAttachments?: boolean;
|
|
34
|
+
/** File types the picker accepts, as extensions or MIME types (`['.pdf', 'image/*']`). */
|
|
20
35
|
acceptedFiles?: string[];
|
|
36
|
+
/** Called with the picked files after the attachment button opens the file picker. */
|
|
21
37
|
onFileAttach?: (files: File[]) => void;
|
|
22
38
|
}
|
|
23
39
|
|
|
40
|
+
/**
|
|
41
|
+
* A fixed-height rich-text editor with a formatting toolbar above or below the text, built on
|
|
42
|
+
* `RichTextArea`. `className` styles the editable text, `containerClassName` the root
|
|
43
|
+
* (`data-slot="rich-text-field"`), `placeholderClassName` the placeholder and `toolbarClassName`
|
|
44
|
+
* the toolbar; each is merged last.
|
|
45
|
+
*/
|
|
24
46
|
export const RichTextField = forwardRef<HTMLInputElement, RichTextFieldProps>(
|
|
25
47
|
(
|
|
26
48
|
{
|
|
@@ -45,6 +67,7 @@ export const RichTextField = forwardRef<HTMLInputElement, RichTextFieldProps>(
|
|
|
45
67
|
<RichTextArea
|
|
46
68
|
ref={ref}
|
|
47
69
|
data-testid="rich-text-field"
|
|
70
|
+
data-slot="rich-text-field"
|
|
48
71
|
data-toolbar-placement={toolbarPlacement}
|
|
49
72
|
placeholderClassName={cn(
|
|
50
73
|
'left-(--rich-text-field-editor-padding)',
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { TopMenu, TopMenuActions, type TopMenuActionsProps, type TopMenuProps } from './topmenu';
|