@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,31 +1,38 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
1
2
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
-
import {
|
|
3
|
+
import { $getRoot, COMMAND_PRIORITY_LOW, KEY_ESCAPE_COMMAND } from 'lexical';
|
|
4
|
+
import { useEffect, useState } from 'react';
|
|
5
|
+
import type { FormEvent, KeyboardEvent } from 'react';
|
|
6
|
+
import { expect, fn } from 'storybook/test';
|
|
3
7
|
|
|
4
8
|
import { EnterIcon } from '@swisper.ai/icons';
|
|
5
|
-
import { IconButton } from '@swisper.ai/ui';
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
import { Button, IconButton, Typography } from '@swisper.ai/ui';
|
|
10
|
+
|
|
11
|
+
import { ParentBlock } from '../../__storybook__/parent-block';
|
|
12
|
+
import {
|
|
13
|
+
CanvasShell,
|
|
14
|
+
CanvasShellContent,
|
|
15
|
+
CanvasShellFooter,
|
|
16
|
+
CanvasShellHeader,
|
|
17
|
+
CanvasShellTitle,
|
|
18
|
+
} from '../canvas-shell';
|
|
19
|
+
import { ChatContainer, ChatContainerPrompt } from '../chat-container';
|
|
20
|
+
|
|
21
|
+
import { CALENDAR_SIGNAL, MARKDOWN_DRAFT, SIGNAL_REPLIES } from './__stories__/fixtures';
|
|
8
22
|
import { ChatInput, ChatInputTextarea, useChatInputContext } from './chat-input';
|
|
9
23
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
<div>
|
|
15
|
-
<p className="text-sm text-text-secondary">
|
|
16
|
-
State: focused={String(isFocused)}, empty={String(!hasValue)}
|
|
17
|
-
</p>
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
24
|
+
// ChatInput ships unstyled. This is the look a consumer gives it: a bordered field that takes its
|
|
25
|
+
// focus colour from the `data-focused` attribute the root sets.
|
|
26
|
+
const fieldClassName =
|
|
27
|
+
'max-h-30 min-h-40 w-full overflow-y-auto rounded-md border border-form-fields-border bg-paper-elevation-1 px-12 py-6 transition-colors hover:border-form-fields-border-hover data-[focused=true]:border-primary-main data-[focused=true]:bg-paper-elevation-2';
|
|
21
28
|
|
|
22
29
|
const meta: Meta<typeof ChatInput> = {
|
|
23
|
-
title: '
|
|
30
|
+
title: 'Chat/ChatInput',
|
|
24
31
|
component: ChatInput,
|
|
25
32
|
tags: ['autodocs'],
|
|
26
33
|
decorators: [
|
|
27
34
|
(Story) => (
|
|
28
|
-
<div className="max-w-
|
|
35
|
+
<div className="max-w-105">
|
|
29
36
|
<Story />
|
|
30
37
|
</div>
|
|
31
38
|
),
|
|
@@ -34,7 +41,7 @@ const meta: Meta<typeof ChatInput> = {
|
|
|
34
41
|
initialConfig: {
|
|
35
42
|
control: false,
|
|
36
43
|
description:
|
|
37
|
-
'Lexical composer config (namespace, nodes, theme, `onError`). Override only to add nodes or retheme the editor.',
|
|
44
|
+
'Lexical composer config (namespace, nodes, theme, `onError`), read once on mount. Override only to add nodes or retheme the editor.',
|
|
38
45
|
table: { defaultValue: { summary: 'DEFAULT_CONFIG' } },
|
|
39
46
|
},
|
|
40
47
|
children: {
|
|
@@ -45,247 +52,703 @@ const meta: Meta<typeof ChatInput> = {
|
|
|
45
52
|
className: {
|
|
46
53
|
control: 'text',
|
|
47
54
|
description:
|
|
48
|
-
'
|
|
55
|
+
'Classes on the wrapper, which ships unstyled; style focus and empty states with `data-[focused=true]` and `data-[empty=true]`.',
|
|
49
56
|
},
|
|
50
57
|
},
|
|
51
58
|
args: {
|
|
52
|
-
className:
|
|
59
|
+
className: fieldClassName,
|
|
53
60
|
},
|
|
54
61
|
};
|
|
55
62
|
|
|
56
63
|
export default meta;
|
|
57
64
|
type Story = StoryObj<typeof ChatInput>;
|
|
58
65
|
|
|
66
|
+
/** The reply field under a notification: the unstyled editor with the border and focus colour its consumer gives it. */
|
|
59
67
|
export const Default: Story = {
|
|
60
|
-
render: () => (
|
|
61
|
-
<
|
|
62
|
-
<
|
|
63
|
-
|
|
64
|
-
<ChatInputStateDebug />
|
|
65
|
-
</ChatInput>
|
|
66
|
-
</div>
|
|
68
|
+
render: (args) => (
|
|
69
|
+
<ChatInput {...args}>
|
|
70
|
+
<ChatInputTextarea autoFocus={false} placeholder="Tell Swisper what to do instead" />
|
|
71
|
+
</ChatInput>
|
|
67
72
|
),
|
|
68
73
|
};
|
|
69
74
|
|
|
75
|
+
function ComposerStateReadout() {
|
|
76
|
+
const { isFocused, hasValue } = useChatInputContext();
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<Typography variant="caption-md" className="text-text-tertiary">
|
|
80
|
+
{isFocused ? 'Focused' : 'Not focused'} · {hasValue ? 'Has a draft' : 'Empty'}
|
|
81
|
+
</Typography>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The editor takes focus on mount, which is the default; the line below reads the state from `useChatInputContext`. */
|
|
70
86
|
export const AutoFocus: Story = {
|
|
87
|
+
parameters: { controls: { disable: true } },
|
|
71
88
|
render: () => (
|
|
72
|
-
<
|
|
73
|
-
<
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
<ChatInput className={fieldClassName}>
|
|
90
|
+
<ChatInputTextarea autoFocus placeholder="How can I help?" />
|
|
91
|
+
<ComposerStateReadout />
|
|
92
|
+
</ChatInput>
|
|
93
|
+
),
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
interface ReplyDraftProps {
|
|
97
|
+
suggestions: string[];
|
|
98
|
+
onChange: (value: string) => void;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function ReplyDraft({ suggestions, onChange }: ReplyDraftProps) {
|
|
102
|
+
const [value, setValue] = useState('');
|
|
103
|
+
|
|
104
|
+
function handleChange(nextValue: string) {
|
|
105
|
+
setValue(nextValue);
|
|
106
|
+
onChange(nextValue);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
return (
|
|
110
|
+
<div className="flex flex-col gap-8">
|
|
111
|
+
<ChatInput className={fieldClassName}>
|
|
112
|
+
<ChatInputTextarea
|
|
113
|
+
autoFocus={false}
|
|
114
|
+
value={value}
|
|
115
|
+
placeholder="Tell Swisper what to do instead"
|
|
116
|
+
onChange={handleChange}
|
|
117
|
+
/>
|
|
76
118
|
</ChatInput>
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
119
|
+
|
|
120
|
+
<div className="flex flex-wrap gap-8">
|
|
121
|
+
{suggestions.map((suggestion) => (
|
|
122
|
+
<Button key={suggestion} size="sm" onClick={() => setValue(suggestion)}>
|
|
123
|
+
{suggestion}
|
|
124
|
+
</Button>
|
|
125
|
+
))}
|
|
126
|
+
<Button size="sm" variant="tertiary" onClick={() => setValue('')}>
|
|
127
|
+
Clear draft
|
|
128
|
+
</Button>
|
|
129
|
+
</div>
|
|
80
130
|
</div>
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
type ReplyDraftStory = StoryObj<typeof ReplyDraft>;
|
|
135
|
+
|
|
136
|
+
/** A controlled draft: picking a reply replaces the content, including one long enough to wrap, and clearing sets it to an empty string. */
|
|
137
|
+
export const Controlled: ReplyDraftStory = {
|
|
138
|
+
parameters: { controls: { disable: true } },
|
|
139
|
+
args: { suggestions: SIGNAL_REPLIES.slice(1), onChange: fn() },
|
|
140
|
+
render: (args) => <ReplyDraft {...args} />,
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/** A reply that is being sent: the draft stays visible but dimmed, and can't be edited or selected. */
|
|
144
|
+
export const Disabled: Story = {
|
|
145
|
+
parameters: { controls: { disable: true } },
|
|
146
|
+
render: () => (
|
|
147
|
+
<ChatInput className={fieldClassName}>
|
|
148
|
+
<ChatInputTextarea
|
|
149
|
+
value={SIGNAL_REPLIES[0]}
|
|
150
|
+
isDisabled
|
|
151
|
+
placeholder="Tell Swisper what to do instead"
|
|
152
|
+
/>
|
|
153
|
+
</ChatInput>
|
|
81
154
|
),
|
|
82
155
|
};
|
|
83
156
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
157
|
+
/** A reply Swisper is already acting on: it can't be edited, but stays readable and selectable. */
|
|
158
|
+
export const ReadOnly: Story = {
|
|
159
|
+
parameters: { controls: { disable: true } },
|
|
160
|
+
render: () => (
|
|
161
|
+
<ChatInput className={fieldClassName}>
|
|
162
|
+
<ChatInputTextarea
|
|
163
|
+
value={SIGNAL_REPLIES[0]}
|
|
164
|
+
isReadOnly
|
|
165
|
+
placeholder="Tell Swisper what to do instead"
|
|
166
|
+
/>
|
|
167
|
+
</ChatInput>
|
|
168
|
+
),
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
/** The value is Markdown both ways: headings, lists, code and quotes load into the editor and come back in `onChange`, shown below it. */
|
|
172
|
+
export const ControlledMarkdown: Story = {
|
|
173
|
+
parameters: { controls: { disable: true } },
|
|
174
|
+
render: function ControlledMarkdownStory() {
|
|
175
|
+
const [value, setValue] = useState(MARKDOWN_DRAFT);
|
|
87
176
|
|
|
88
177
|
return (
|
|
89
|
-
<div className="flex flex-col gap-
|
|
90
|
-
<ChatInput className="
|
|
178
|
+
<div className="flex flex-col gap-8">
|
|
179
|
+
<ChatInput className="w-full rounded-md border border-form-fields-border bg-paper-elevation-1 px-12 py-6 data-[focused=true]:border-primary-main">
|
|
91
180
|
<ChatInputTextarea
|
|
181
|
+
autoFocus={false}
|
|
92
182
|
value={value}
|
|
183
|
+
placeholder="Write a follow-up"
|
|
93
184
|
onChange={setValue}
|
|
94
|
-
placeholder="Input your message..."
|
|
95
185
|
/>
|
|
96
|
-
<ChatInputStateDebug />
|
|
97
186
|
</ChatInput>
|
|
98
187
|
|
|
99
|
-
<div>
|
|
100
|
-
<
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
>
|
|
108
|
-
Set long value
|
|
109
|
-
</button>
|
|
110
|
-
<button type="button" onClick={() => setValue('')}>
|
|
111
|
-
Clear
|
|
112
|
-
</button>
|
|
113
|
-
<p className="text-sm text-text-secondary">
|
|
114
|
-
Value: {value.length > 0 ? value : '(empty)'}
|
|
115
|
-
</p>
|
|
188
|
+
<div className="flex gap-8">
|
|
189
|
+
<Button size="sm" onClick={() => setValue(MARKDOWN_DRAFT)}>
|
|
190
|
+
Load the draft
|
|
191
|
+
</Button>
|
|
192
|
+
<Button size="sm" variant="tertiary" onClick={() => setValue('')}>
|
|
193
|
+
Clear draft
|
|
194
|
+
</Button>
|
|
116
195
|
</div>
|
|
196
|
+
|
|
197
|
+
<Typography variant="caption-md" fontFamily="mono" asChild>
|
|
198
|
+
<pre
|
|
199
|
+
aria-label="Markdown value"
|
|
200
|
+
className="rounded-sm bg-paper-elevation-1 p-12 whitespace-pre-wrap text-text-secondary"
|
|
201
|
+
>
|
|
202
|
+
{value || 'No draft'}
|
|
203
|
+
</pre>
|
|
204
|
+
</Typography>
|
|
117
205
|
</div>
|
|
118
206
|
);
|
|
119
207
|
},
|
|
120
208
|
};
|
|
121
209
|
|
|
122
|
-
|
|
123
|
-
|
|
210
|
+
interface QuickReplyProps {
|
|
211
|
+
placeholder: string;
|
|
212
|
+
onSend: (message: string) => void;
|
|
213
|
+
}
|
|
124
214
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
215
|
+
function QuickReply({ placeholder, onSend }: QuickReplyProps) {
|
|
216
|
+
const [value, setValue] = useState('');
|
|
217
|
+
const [lastSent, setLastSent] = useState<string | null>(null);
|
|
128
218
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
</ChatInput>
|
|
135
|
-
<p className="text-sm text-text-secondary">Disabled: not editable and not tab-focusable.</p>
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
},
|
|
139
|
-
};
|
|
219
|
+
function handleKeyDown(event: KeyboardEvent<HTMLDivElement>) {
|
|
220
|
+
// Shift+Enter falls through to the editor, which adds a line.
|
|
221
|
+
if (event.key !== 'Enter' || event.shiftKey) {
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
140
224
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
const [value] = useState(presetMessage);
|
|
225
|
+
// Without this the editor inserts a paragraph as well.
|
|
226
|
+
event.preventDefault();
|
|
144
227
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
228
|
+
const message = value.trim();
|
|
229
|
+
|
|
230
|
+
if (!message) {
|
|
231
|
+
return;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
onSend(message);
|
|
235
|
+
setLastSent(message);
|
|
236
|
+
setValue('');
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return (
|
|
240
|
+
<div className="flex flex-col gap-8">
|
|
241
|
+
<ChatInput className={fieldClassName}>
|
|
242
|
+
<ChatInputTextarea
|
|
243
|
+
autoFocus={false}
|
|
244
|
+
value={value}
|
|
245
|
+
placeholder={placeholder}
|
|
246
|
+
onChange={setValue}
|
|
247
|
+
onKeyDown={handleKeyDown}
|
|
248
|
+
/>
|
|
249
|
+
</ChatInput>
|
|
250
|
+
<Typography variant="caption-md" className="text-text-tertiary">
|
|
251
|
+
Enter sends, Shift+Enter adds a line.
|
|
252
|
+
</Typography>
|
|
253
|
+
{lastSent !== null && (
|
|
254
|
+
<Typography variant="caption-md" className="text-text-secondary">
|
|
255
|
+
Sent: {lastSent}
|
|
256
|
+
</Typography>
|
|
257
|
+
)}
|
|
258
|
+
</div>
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
type QuickReplyStory = StoryObj<typeof QuickReply>;
|
|
263
|
+
|
|
264
|
+
/** Send on Enter is the consumer's `onKeyDown`: it prevents the default, sends the trimmed draft and clears the value. */
|
|
265
|
+
export const SubmitOnEnter: QuickReplyStory = {
|
|
266
|
+
parameters: { controls: { disable: true } },
|
|
267
|
+
args: { placeholder: 'Tell Swisper what to do instead', onSend: fn() },
|
|
268
|
+
render: (args) => <QuickReply {...args} />,
|
|
157
269
|
};
|
|
158
270
|
|
|
159
|
-
|
|
271
|
+
interface SignalReplyInputProps {
|
|
272
|
+
placeholder: string;
|
|
273
|
+
onAction: (action: string) => void;
|
|
274
|
+
}
|
|
160
275
|
|
|
161
|
-
|
|
276
|
+
function SignalReplyInput({ placeholder, onAction }: SignalReplyInputProps) {
|
|
277
|
+
const [value, setValue] = useState('');
|
|
162
278
|
|
|
163
|
-
|
|
279
|
+
function handleSubmit() {
|
|
280
|
+
const trimmed = value.trim();
|
|
164
281
|
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
282
|
+
if (!trimmed) {
|
|
283
|
+
return;
|
|
284
|
+
}
|
|
168
285
|
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
\`\`\`
|
|
286
|
+
onAction(trimmed);
|
|
287
|
+
setValue('');
|
|
288
|
+
}
|
|
173
289
|
|
|
174
|
-
|
|
290
|
+
function handleFormSubmit(event: FormEvent<HTMLFormElement>) {
|
|
291
|
+
event.preventDefault();
|
|
292
|
+
handleSubmit();
|
|
293
|
+
}
|
|
175
294
|
|
|
176
|
-
|
|
295
|
+
function handleKeyDown(event: KeyboardEvent<HTMLDivElement>) {
|
|
296
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
297
|
+
event.preventDefault();
|
|
298
|
+
handleSubmit();
|
|
299
|
+
}
|
|
300
|
+
}
|
|
177
301
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
302
|
+
return (
|
|
303
|
+
<form className="flex w-full items-end gap-8" onSubmit={handleFormSubmit}>
|
|
304
|
+
<ChatInput className={fieldClassName}>
|
|
305
|
+
<ChatInputTextarea
|
|
306
|
+
autoFocus={false}
|
|
307
|
+
value={value}
|
|
308
|
+
placeholder={placeholder}
|
|
309
|
+
onChange={setValue}
|
|
310
|
+
onKeyDown={handleKeyDown}
|
|
311
|
+
/>
|
|
312
|
+
</ChatInput>
|
|
313
|
+
<IconButton type="submit" size="md" variant="primary" aria-label="Send reply">
|
|
314
|
+
<EnterIcon />
|
|
315
|
+
</IconButton>
|
|
316
|
+
</form>
|
|
317
|
+
);
|
|
318
|
+
}
|
|
181
319
|
|
|
182
|
-
|
|
183
|
-
<div className="flex flex-col gap-4">
|
|
184
|
-
<ChatInput className="min-h-[80px]">
|
|
185
|
-
<ChatInputTextarea
|
|
186
|
-
value={value}
|
|
187
|
-
onChange={setValue}
|
|
188
|
-
placeholder="Input your message..."
|
|
189
|
-
/>
|
|
190
|
-
<ChatInputStateDebug />
|
|
191
|
-
</ChatInput>
|
|
320
|
+
type SignalReplyInputStory = StoryObj<typeof SignalReplyInput>;
|
|
192
321
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
</button>
|
|
200
|
-
</div>
|
|
322
|
+
/** A small composer built from the editor and a send button beside it: the custom reply under a notification's suggested actions. */
|
|
323
|
+
export const SimplePromptBox: SignalReplyInputStory = {
|
|
324
|
+
parameters: { controls: { disable: true } },
|
|
325
|
+
args: { placeholder: 'Tell Swisper what to do instead', onAction: fn() },
|
|
326
|
+
render: (args) => <SignalReplyInput {...args} />,
|
|
327
|
+
};
|
|
201
328
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
329
|
+
/** Typing fills the editor and flips the root's empty and focused attributes; an empty draft shows the placeholder. */
|
|
330
|
+
export const DefaultTypeAndFocus: Story = {
|
|
331
|
+
...Default,
|
|
332
|
+
tags: ['e2e', '!autodocs'],
|
|
333
|
+
play: async ({ canvas, canvasElement, userEvent, step }) => {
|
|
334
|
+
const editor = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
335
|
+
const root = canvasElement.querySelector('[data-slot="chat-input"]');
|
|
336
|
+
|
|
337
|
+
await step('Starts empty, unfocused, with the placeholder', async () => {
|
|
338
|
+
await expect(root).toHaveAttribute('data-empty', 'true');
|
|
339
|
+
await expect(root).toHaveAttribute('data-focused', 'false');
|
|
340
|
+
await expect(root).toHaveAttribute('aria-invalid', 'false');
|
|
341
|
+
await expect(editor).toHaveAttribute('aria-placeholder', 'Tell Swisper what to do instead');
|
|
342
|
+
await expect(canvas.getByText('Tell Swisper what to do instead')).toBeVisible();
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
await step('Every element a consumer styles carries its slot name', async () => {
|
|
346
|
+
await expect(editor).toHaveAttribute('data-slot', 'chat-input-editable');
|
|
347
|
+
await expect(editor.parentElement).toHaveAttribute('data-slot', 'chat-input-textarea');
|
|
348
|
+
await expect(canvas.getByText('Tell Swisper what to do instead')).toHaveAttribute(
|
|
349
|
+
'data-slot',
|
|
350
|
+
'chat-input-placeholder',
|
|
351
|
+
);
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
await step('Clicking focuses the editor', async () => {
|
|
355
|
+
await userEvent.click(editor);
|
|
356
|
+
await expect(root).toHaveAttribute('data-focused', 'true');
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
await step('Typing hides the placeholder', async () => {
|
|
360
|
+
await userEvent.keyboard('Move it to Friday');
|
|
361
|
+
await expect(editor).toHaveTextContent('Move it to Friday');
|
|
362
|
+
await expect(root).toHaveAttribute('data-empty', 'false');
|
|
363
|
+
await expect(canvas.queryByText('Tell Swisper what to do instead')).toBeNull();
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
await step('Leaving the editor clears the focused state', async () => {
|
|
367
|
+
await userEvent.tab();
|
|
368
|
+
await expect(root).toHaveAttribute('data-focused', 'false');
|
|
369
|
+
});
|
|
210
370
|
},
|
|
211
371
|
};
|
|
212
372
|
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
373
|
+
/** The editor is focused as soon as the story mounts, and the context reports it. */
|
|
374
|
+
export const AutoFocusOnMount: Story = {
|
|
375
|
+
...AutoFocus,
|
|
376
|
+
tags: ['e2e', '!autodocs'],
|
|
377
|
+
play: async ({ canvas }) => {
|
|
378
|
+
await expect(canvas.getByRole('textbox', { name: 'Chat input' })).toHaveFocus();
|
|
379
|
+
await expect(await canvas.findByText('Focused · Empty')).toBeVisible();
|
|
380
|
+
},
|
|
381
|
+
};
|
|
217
382
|
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
383
|
+
/** Setting `value` replaces the content, and an empty string clears it and brings the placeholder back. */
|
|
384
|
+
export const ControlledFillAndClear: ReplyDraftStory = {
|
|
385
|
+
...Controlled,
|
|
386
|
+
tags: ['e2e', '!autodocs'],
|
|
387
|
+
args: { suggestions: SIGNAL_REPLIES.slice(1), onChange: fn() },
|
|
388
|
+
play: async ({ args, canvas, canvasElement, userEvent, step }) => {
|
|
389
|
+
const editor = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
390
|
+
const root = canvasElement.querySelector('[data-slot="chat-input"]');
|
|
391
|
+
|
|
392
|
+
await step('Picking a reply fills the editor', async () => {
|
|
393
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Decline the design review' }));
|
|
394
|
+
await expect(editor).toHaveTextContent('Decline the design review');
|
|
395
|
+
await expect(root).toHaveAttribute('data-empty', 'false');
|
|
396
|
+
await expect(args.onChange).toHaveBeenLastCalledWith('Decline the design review');
|
|
397
|
+
});
|
|
398
|
+
|
|
399
|
+
await step('Picking another replaces it', async () => {
|
|
400
|
+
await userEvent.click(canvas.getByRole('button', { name: /^Ask Marc/ }));
|
|
401
|
+
await expect(editor).toHaveTextContent(SIGNAL_REPLIES[2]);
|
|
402
|
+
await expect(editor).not.toHaveTextContent('Decline the design review');
|
|
403
|
+
});
|
|
404
|
+
|
|
405
|
+
await step('Clearing empties it and brings the placeholder back', async () => {
|
|
406
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Clear draft' }));
|
|
407
|
+
await expect(editor).toHaveTextContent('');
|
|
408
|
+
await expect(root).toHaveAttribute('data-empty', 'true');
|
|
409
|
+
await expect(canvas.getByText('Tell Swisper what to do instead')).toBeVisible();
|
|
410
|
+
});
|
|
411
|
+
},
|
|
412
|
+
};
|
|
237
413
|
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
);
|
|
414
|
+
/** A disabled editor is not editable, is marked disabled, and typing at it changes nothing. */
|
|
415
|
+
export const DisabledBlocksEditing: Story = {
|
|
416
|
+
...Disabled,
|
|
417
|
+
tags: ['e2e', '!autodocs'],
|
|
418
|
+
play: async ({ canvas, canvasElement, userEvent }) => {
|
|
419
|
+
const editor = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
420
|
+
const textarea = canvasElement.querySelector('[data-slot="chat-input-textarea"]');
|
|
421
|
+
|
|
422
|
+
await expect(editor).toHaveTextContent(SIGNAL_REPLIES[0]);
|
|
423
|
+
await expect(editor).toHaveAttribute('contenteditable', 'false');
|
|
424
|
+
await expect(textarea).toHaveAttribute('data-disabled', 'true');
|
|
425
|
+
await expect(textarea).toHaveAttribute('aria-disabled', 'true');
|
|
426
|
+
await expect(textarea).toHaveAttribute('data-readonly', 'false');
|
|
427
|
+
|
|
428
|
+
// Disabled also skips autoFocus, which is on by default here.
|
|
429
|
+
await expect(editor).not.toHaveFocus();
|
|
430
|
+
await userEvent.click(editor);
|
|
431
|
+
await userEvent.keyboard(' today');
|
|
432
|
+
await expect(editor).toHaveTextContent(SIGNAL_REPLIES[0]);
|
|
244
433
|
},
|
|
245
434
|
};
|
|
246
435
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
436
|
+
/** A read-only editor is not editable and is marked read-only, not disabled. */
|
|
437
|
+
export const ReadOnlyBlocksEditing: Story = {
|
|
438
|
+
...ReadOnly,
|
|
439
|
+
tags: ['e2e', '!autodocs'],
|
|
440
|
+
play: async ({ canvas, canvasElement, userEvent }) => {
|
|
441
|
+
const editor = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
442
|
+
const textarea = canvasElement.querySelector('[data-slot="chat-input-textarea"]');
|
|
443
|
+
|
|
444
|
+
await expect(editor).toHaveAttribute('contenteditable', 'false');
|
|
445
|
+
await expect(editor).toHaveAttribute('aria-readonly', 'true');
|
|
446
|
+
await expect(textarea).toHaveAttribute('data-readonly', 'true');
|
|
447
|
+
await expect(textarea).toHaveAttribute('aria-readonly', 'true');
|
|
448
|
+
await expect(textarea).toHaveAttribute('data-disabled', 'false');
|
|
449
|
+
|
|
450
|
+
await expect(editor).not.toHaveFocus();
|
|
451
|
+
await userEvent.click(editor);
|
|
452
|
+
await userEvent.keyboard(' today');
|
|
453
|
+
await expect(editor).toHaveTextContent(SIGNAL_REPLIES[0]);
|
|
454
|
+
},
|
|
455
|
+
};
|
|
250
456
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
457
|
+
/** Loads a Markdown draft as formatted blocks and reports edits back as Markdown. */
|
|
458
|
+
export const ControlledMarkdownRoundTrip: Story = {
|
|
459
|
+
...ControlledMarkdown,
|
|
460
|
+
tags: ['e2e', '!autodocs'],
|
|
461
|
+
play: async ({ canvas, userEvent, step }) => {
|
|
462
|
+
const editor = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
463
|
+
const markdown = canvas.getByLabelText('Markdown value');
|
|
464
|
+
|
|
465
|
+
await step('Renders the Markdown as blocks, not as source', async () => {
|
|
466
|
+
await expect(editor.querySelector('h1')).toHaveTextContent('Board meeting follow-up');
|
|
467
|
+
await expect(editor.querySelectorAll('li')).toHaveLength(3);
|
|
468
|
+
await expect(editor.querySelector('blockquote')).toHaveTextContent(/12 November/);
|
|
469
|
+
await expect(editor).not.toHaveTextContent('# Board');
|
|
470
|
+
});
|
|
471
|
+
|
|
472
|
+
await step('Clearing and typing reports plain Markdown', async () => {
|
|
473
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Clear draft' }));
|
|
474
|
+
await expect(markdown).toHaveTextContent('No draft');
|
|
475
|
+
await userEvent.click(editor);
|
|
476
|
+
await userEvent.keyboard('Thanks, all good');
|
|
477
|
+
await expect(markdown).toHaveTextContent('Thanks, all good');
|
|
478
|
+
});
|
|
479
|
+
|
|
480
|
+
await step('Loading the draft again restores the blocks', async () => {
|
|
481
|
+
await userEvent.click(canvas.getByRole('button', { name: 'Load the draft' }));
|
|
482
|
+
await expect(editor.querySelector('h2')).toHaveTextContent('Next steps');
|
|
483
|
+
await expect(markdown).toHaveTextContent('## Next steps');
|
|
484
|
+
});
|
|
485
|
+
},
|
|
486
|
+
};
|
|
254
487
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
488
|
+
/** Enter sends the trimmed draft and clears the editor; Shift+Enter and an empty draft send nothing. */
|
|
489
|
+
export const SubmitOnEnterSends: QuickReplyStory = {
|
|
490
|
+
...SubmitOnEnter,
|
|
491
|
+
tags: ['e2e', '!autodocs'],
|
|
492
|
+
args: { placeholder: 'Tell Swisper what to do instead', onSend: fn() },
|
|
493
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
494
|
+
const editor = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
495
|
+
|
|
496
|
+
await step('Enter on an empty draft sends nothing', async () => {
|
|
497
|
+
await userEvent.click(editor);
|
|
498
|
+
await userEvent.keyboard('{Enter}');
|
|
499
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
500
|
+
await expect(editor).toHaveTextContent('');
|
|
501
|
+
});
|
|
502
|
+
|
|
503
|
+
await step('Shift+Enter adds a line and does not send', async () => {
|
|
504
|
+
await userEvent.keyboard('Move the design review');
|
|
505
|
+
await userEvent.keyboard('{Shift>}{Enter}{/Shift}');
|
|
506
|
+
await userEvent.keyboard('to Friday');
|
|
507
|
+
await expect(args.onSend).not.toHaveBeenCalled();
|
|
508
|
+
await expect(editor).toHaveTextContent(/Move the design review\s*to Friday/);
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
await step('Enter sends once and clears the editor', async () => {
|
|
512
|
+
await userEvent.keyboard('{Enter}');
|
|
513
|
+
await expect(args.onSend).toHaveBeenCalledTimes(1);
|
|
514
|
+
await expect(args.onSend).toHaveBeenCalledWith(
|
|
515
|
+
expect.stringMatching(/^Move the design review/),
|
|
516
|
+
);
|
|
517
|
+
await expect(editor).toHaveTextContent('');
|
|
518
|
+
await expect(await canvas.findByText(/^Sent: Move the design review/)).toBeVisible();
|
|
519
|
+
});
|
|
520
|
+
},
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
/** The send button submits the draft the same way Enter does, and does nothing while the draft is empty. */
|
|
524
|
+
export const SimplePromptBoxSendWithButton: SignalReplyInputStory = {
|
|
525
|
+
...SimplePromptBox,
|
|
526
|
+
tags: ['e2e', '!autodocs'],
|
|
527
|
+
args: { placeholder: 'Tell Swisper what to do instead', onAction: fn() },
|
|
528
|
+
play: async ({ args, canvas, userEvent, step }) => {
|
|
529
|
+
const editor = canvas.getByRole('textbox', { name: 'Chat input' });
|
|
530
|
+
const send = canvas.getByRole('button', { name: 'Send reply' });
|
|
531
|
+
|
|
532
|
+
await step('An empty draft is not sent', async () => {
|
|
533
|
+
await userEvent.click(send);
|
|
534
|
+
await expect(args.onAction).not.toHaveBeenCalled();
|
|
535
|
+
});
|
|
536
|
+
|
|
537
|
+
await step('The button sends the draft and clears the editor', async () => {
|
|
538
|
+
await userEvent.click(editor);
|
|
539
|
+
await userEvent.keyboard(' Decline the design review ');
|
|
540
|
+
await userEvent.click(send);
|
|
541
|
+
await expect(args.onAction).toHaveBeenCalledTimes(1);
|
|
542
|
+
await expect(args.onAction).toHaveBeenCalledWith('Decline the design review');
|
|
543
|
+
await expect(editor).toHaveTextContent('');
|
|
544
|
+
});
|
|
545
|
+
|
|
546
|
+
await step('Enter sends the next one', async () => {
|
|
547
|
+
await userEvent.click(editor);
|
|
548
|
+
await userEvent.keyboard('Move it to Friday{Enter}');
|
|
549
|
+
await expect(args.onAction).toHaveBeenLastCalledWith('Move it to Friday');
|
|
550
|
+
await expect(args.onAction).toHaveBeenCalledTimes(2);
|
|
551
|
+
await expect(editor).toHaveTextContent('');
|
|
552
|
+
});
|
|
553
|
+
},
|
|
554
|
+
};
|
|
278
555
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
556
|
+
/** The editor in each place it's allowed: a canvas footer, the chat container's prompt slot, a chat composer and a panel footer. */
|
|
557
|
+
export const Examples: Story = {
|
|
558
|
+
parameters: { controls: { disable: true } },
|
|
559
|
+
render: () => (
|
|
560
|
+
<div className="flex flex-col gap-24">
|
|
561
|
+
<ParentBlock parent="web-chat-ui/CanvasShellFooter">
|
|
562
|
+
<div className="h-70 rounded-md border border-component-divider">
|
|
563
|
+
<CanvasShell>
|
|
564
|
+
<CanvasShellHeader>
|
|
565
|
+
<CanvasShellTitle>Board meeting follow-up</CanvasShellTitle>
|
|
566
|
+
</CanvasShellHeader>
|
|
567
|
+
<CanvasShellContent>
|
|
568
|
+
<Typography variant="body-small-high" className="text-text-secondary">
|
|
569
|
+
Thanks for joining on short notice. The revised budget follows by Friday, and the
|
|
570
|
+
next session is on 12 November at 14:00.
|
|
571
|
+
</Typography>
|
|
572
|
+
</CanvasShellContent>
|
|
573
|
+
<CanvasShellFooter className="flex-col items-stretch">
|
|
574
|
+
<ChatInput className={fieldClassName}>
|
|
575
|
+
<ChatInputTextarea autoFocus={false} placeholder="Ask for a change to this draft" />
|
|
576
|
+
</ChatInput>
|
|
577
|
+
</CanvasShellFooter>
|
|
578
|
+
</CanvasShell>
|
|
579
|
+
</div>
|
|
580
|
+
</ParentBlock>
|
|
581
|
+
|
|
582
|
+
<ParentBlock parent="web-chat-ui/ChatContainerPrompt">
|
|
583
|
+
<div className="h-50 rounded-md border border-component-divider">
|
|
584
|
+
<ChatContainer>
|
|
585
|
+
<Typography
|
|
586
|
+
variant="body-small-high"
|
|
587
|
+
className="m-message min-h-0 flex-1 text-text-secondary"
|
|
588
|
+
>
|
|
589
|
+
Your Thursday has one conflict: the board meeting and the design review both start at
|
|
590
|
+
14:00.
|
|
591
|
+
</Typography>
|
|
592
|
+
<ChatContainerPrompt className="m-message">
|
|
593
|
+
<ChatInput className={fieldClassName}>
|
|
594
|
+
<ChatInputTextarea autoFocus={false} placeholder="How can I help?" />
|
|
595
|
+
</ChatInput>
|
|
596
|
+
</ChatContainerPrompt>
|
|
597
|
+
</ChatContainer>
|
|
598
|
+
</div>
|
|
599
|
+
</ParentBlock>
|
|
600
|
+
|
|
601
|
+
<ParentBlock parent="chat composer">
|
|
602
|
+
<div role="group" aria-label="Chat composer">
|
|
603
|
+
<SignalReplyInput placeholder="How can I help?" onAction={fn()} />
|
|
604
|
+
</div>
|
|
605
|
+
</ParentBlock>
|
|
606
|
+
|
|
607
|
+
<ParentBlock parent="panel footer">
|
|
608
|
+
<aside
|
|
609
|
+
aria-label="Notifications"
|
|
610
|
+
className="flex flex-col rounded-md border border-component-divider bg-paper-elevation-0"
|
|
285
611
|
>
|
|
286
|
-
<
|
|
287
|
-
|
|
288
|
-
|
|
612
|
+
<div className="flex flex-col gap-4 p-16">
|
|
613
|
+
<Typography variant="body-small-high" fontWeight="medium">
|
|
614
|
+
{CALENDAR_SIGNAL.title}
|
|
615
|
+
</Typography>
|
|
616
|
+
<Typography variant="body-small-high" className="text-text-secondary">
|
|
617
|
+
{CALENDAR_SIGNAL.body}
|
|
618
|
+
</Typography>
|
|
619
|
+
</div>
|
|
620
|
+
<footer className="border-t border-component-divider p-16">
|
|
621
|
+
<ChatInput className={fieldClassName}>
|
|
622
|
+
<ChatInputTextarea autoFocus={false} placeholder="Tell Swisper what to do instead" />
|
|
623
|
+
</ChatInput>
|
|
624
|
+
</footer>
|
|
625
|
+
</aside>
|
|
626
|
+
</ParentBlock>
|
|
627
|
+
</div>
|
|
628
|
+
),
|
|
629
|
+
};
|
|
630
|
+
|
|
631
|
+
// A custom Lexical plugin: anything rendered inside ChatInputTextarea can reach the editor.
|
|
632
|
+
function ClearOnEscapePlugin() {
|
|
633
|
+
const [editor] = useLexicalComposerContext();
|
|
634
|
+
|
|
635
|
+
useEffect(() => {
|
|
636
|
+
return editor.registerCommand(
|
|
637
|
+
KEY_ESCAPE_COMMAND,
|
|
638
|
+
() => {
|
|
639
|
+
editor.update(() => {
|
|
640
|
+
$getRoot().clear();
|
|
641
|
+
});
|
|
642
|
+
|
|
643
|
+
return true;
|
|
644
|
+
},
|
|
645
|
+
COMMAND_PRIORITY_LOW,
|
|
289
646
|
);
|
|
647
|
+
}, [editor]);
|
|
648
|
+
|
|
649
|
+
return null;
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
interface ChatInputPlaygroundProps {
|
|
653
|
+
className: string;
|
|
654
|
+
placeholder: string;
|
|
655
|
+
value: string;
|
|
656
|
+
autoFocus: boolean;
|
|
657
|
+
isDisabled: boolean;
|
|
658
|
+
isReadOnly: boolean;
|
|
659
|
+
hasStateReadout: boolean;
|
|
660
|
+
hasClearOnEscape: boolean;
|
|
661
|
+
onChange: (value: string) => void;
|
|
662
|
+
onKeyDown: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
function ChatInputPlayground({
|
|
666
|
+
className,
|
|
667
|
+
placeholder,
|
|
668
|
+
value,
|
|
669
|
+
autoFocus,
|
|
670
|
+
isDisabled,
|
|
671
|
+
isReadOnly,
|
|
672
|
+
hasStateReadout,
|
|
673
|
+
hasClearOnEscape,
|
|
674
|
+
onChange,
|
|
675
|
+
onKeyDown,
|
|
676
|
+
}: ChatInputPlaygroundProps) {
|
|
677
|
+
return (
|
|
678
|
+
<ChatInput className={className}>
|
|
679
|
+
<ChatInputTextarea
|
|
680
|
+
value={value}
|
|
681
|
+
placeholder={placeholder}
|
|
682
|
+
autoFocus={autoFocus}
|
|
683
|
+
isDisabled={isDisabled}
|
|
684
|
+
isReadOnly={isReadOnly}
|
|
685
|
+
onChange={onChange}
|
|
686
|
+
onKeyDown={onKeyDown}
|
|
687
|
+
>
|
|
688
|
+
{hasClearOnEscape && <ClearOnEscapePlugin />}
|
|
689
|
+
</ChatInputTextarea>
|
|
690
|
+
{hasStateReadout && <ComposerStateReadout />}
|
|
691
|
+
</ChatInput>
|
|
692
|
+
);
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
/** The editor with a state readout and a custom plugin, and every textarea prop on the Controls panel. */
|
|
696
|
+
export const Playground: StoryObj<typeof ChatInputPlayground> = {
|
|
697
|
+
tags: ['!autodocs'],
|
|
698
|
+
args: {
|
|
699
|
+
className: fieldClassName,
|
|
700
|
+
placeholder: 'Tell Swisper what to do instead',
|
|
701
|
+
value: SIGNAL_REPLIES[2],
|
|
702
|
+
autoFocus: false,
|
|
703
|
+
isDisabled: false,
|
|
704
|
+
isReadOnly: false,
|
|
705
|
+
hasStateReadout: true,
|
|
706
|
+
hasClearOnEscape: true,
|
|
707
|
+
onChange: fn(),
|
|
708
|
+
onKeyDown: fn(),
|
|
709
|
+
},
|
|
710
|
+
argTypes: {
|
|
711
|
+
className: {
|
|
712
|
+
control: 'text',
|
|
713
|
+
description:
|
|
714
|
+
'`className` on `ChatInput`, which ships unstyled: the border, background and focus colour of the field.',
|
|
715
|
+
},
|
|
716
|
+
placeholder: {
|
|
717
|
+
control: 'text',
|
|
718
|
+
description: '`placeholder` on `ChatInputTextarea`; also its `aria-placeholder`.',
|
|
719
|
+
},
|
|
720
|
+
value: {
|
|
721
|
+
control: 'text',
|
|
722
|
+
description:
|
|
723
|
+
'`value` on `ChatInputTextarea`, as Markdown. Changing it replaces what is in the editor.',
|
|
724
|
+
},
|
|
725
|
+
autoFocus: {
|
|
726
|
+
control: 'boolean',
|
|
727
|
+
description:
|
|
728
|
+
'`autoFocus` on `ChatInputTextarea`. Read on mount, so remount the story to see it.',
|
|
729
|
+
table: { defaultValue: { summary: 'true' } },
|
|
730
|
+
},
|
|
731
|
+
isDisabled: {
|
|
732
|
+
control: 'boolean',
|
|
733
|
+
description: 'Blocks editing and selection and dims the textarea.',
|
|
734
|
+
table: { defaultValue: { summary: 'false' } },
|
|
735
|
+
},
|
|
736
|
+
isReadOnly: {
|
|
737
|
+
control: 'boolean',
|
|
738
|
+
description: 'Blocks editing but keeps the text selectable.',
|
|
739
|
+
table: { defaultValue: { summary: 'false' } },
|
|
740
|
+
},
|
|
741
|
+
hasStateReadout: {
|
|
742
|
+
control: 'boolean',
|
|
743
|
+
description: 'Renders a sibling that reads `useChatInputContext`.',
|
|
744
|
+
},
|
|
745
|
+
hasClearOnEscape: {
|
|
746
|
+
control: 'boolean',
|
|
747
|
+
description:
|
|
748
|
+
'Renders a custom Lexical plugin inside `ChatInputTextarea`: Escape clears the draft.',
|
|
749
|
+
},
|
|
750
|
+
onChange: { description: 'Called with the content as Markdown on every edit.' },
|
|
751
|
+
onKeyDown: { description: 'Key handler on the editable element.' },
|
|
290
752
|
},
|
|
753
|
+
render: (args) => <ChatInputPlayground {...args} />,
|
|
291
754
|
};
|