@swisper.ai/web-chat-ui 0.0.2
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/LICENSE +202 -0
- package/README.md +251 -0
- package/dist/components/canvas-shell/canvas-shell.d.ts +64 -0
- package/dist/components/canvas-shell/canvas-shell.d.ts.map +1 -0
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts +26 -0
- package/dist/components/canvas-shell/canvas-shell.stories.d.ts.map +1 -0
- package/dist/components/canvas-shell/index.d.ts +2 -0
- package/dist/components/canvas-shell/index.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-context.d.ts +21 -0
- package/dist/components/card-item-picker/card-item-picker-context.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-list.d.ts +24 -0
- package/dist/components/card-item-picker/card-item-picker-list.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts +28 -0
- package/dist/components/card-item-picker/card-item-picker-row-parts.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker-row.d.ts +12 -0
- package/dist/components/card-item-picker/card-item-picker-row.d.ts.map +1 -0
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts +19 -0
- package/dist/components/card-item-picker/card-item-picker.stories.d.ts.map +1 -0
- package/dist/components/card-item-picker/index.d.ts +9 -0
- package/dist/components/card-item-picker/index.d.ts.map +1 -0
- package/dist/components/chat-card/chat-card.d.ts +4 -0
- package/dist/components/chat-card/chat-card.d.ts.map +1 -0
- package/dist/components/chat-card/chat-card.stories.d.ts +11 -0
- package/dist/components/chat-card/chat-card.stories.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts +22 -0
- package/dist/components/chat-card/components/chat-card-body.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts +20 -0
- package/dist/components/chat-card/components/chat-card-footer.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-form.d.ts +28 -0
- package/dist/components/chat-card/components/chat-card-form.d.ts.map +1 -0
- package/dist/components/chat-card/components/chat-card-header.d.ts +36 -0
- package/dist/components/chat-card/components/chat-card-header.d.ts.map +1 -0
- package/dist/components/chat-card/components/index.d.ts +5 -0
- package/dist/components/chat-card/components/index.d.ts.map +1 -0
- package/dist/components/chat-card/context.d.ts +13 -0
- package/dist/components/chat-card/context.d.ts.map +1 -0
- package/dist/components/chat-card/contexts.d.ts +16 -0
- package/dist/components/chat-card/contexts.d.ts.map +1 -0
- package/dist/components/chat-card/hooks.d.ts +13 -0
- package/dist/components/chat-card/hooks.d.ts.map +1 -0
- package/dist/components/chat-card/index.d.ts +6 -0
- package/dist/components/chat-card/index.d.ts.map +1 -0
- package/dist/components/chat-card/types.d.ts +21 -0
- package/dist/components/chat-card/types.d.ts.map +1 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts +43 -0
- package/dist/components/chat-card-container/chat-card-container.d.ts.map +1 -0
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts +17 -0
- package/dist/components/chat-card-container/chat-card-container.stories.d.ts.map +1 -0
- package/dist/components/chat-card-container/index.d.ts +3 -0
- package/dist/components/chat-card-container/index.d.ts.map +1 -0
- package/dist/components/chat-container/chat-container.d.ts +51 -0
- package/dist/components/chat-container/chat-container.d.ts.map +1 -0
- package/dist/components/chat-container/chat-container.stories.d.ts +21 -0
- package/dist/components/chat-container/chat-container.stories.d.ts.map +1 -0
- package/dist/components/chat-container/index.d.ts +3 -0
- package/dist/components/chat-container/index.d.ts.map +1 -0
- package/dist/components/chat-input/chat-input.d.ts +35 -0
- package/dist/components/chat-input/chat-input.d.ts.map +1 -0
- package/dist/components/chat-input/chat-input.stories.d.ts +14 -0
- package/dist/components/chat-input/chat-input.stories.d.ts.map +1 -0
- package/dist/components/chat-input/index.d.ts +3 -0
- package/dist/components/chat-input/index.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts +8 -0
- package/dist/components/chat-input/plugins/auto-focus-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/controlled-value-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/disabled-plugin.d.ts +7 -0
- package/dist/components/chat-input/plugins/disabled-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/focus-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/focus-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/has-value-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/has-value-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/hooks.d.ts +2 -0
- package/dist/components/chat-input/plugins/hooks.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/index.d.ts +8 -0
- package/dist/components/chat-input/plugins/index.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts +2 -0
- package/dist/components/chat-input/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/utils.d.ts +4 -0
- package/dist/components/chat-input/plugins/utils.d.ts.map +1 -0
- package/dist/components/chat-input/plugins/value-plugin.d.ts +6 -0
- package/dist/components/chat-input/plugins/value-plugin.d.ts.map +1 -0
- package/dist/components/chat-input/transformers.d.ts +3 -0
- package/dist/components/chat-input/transformers.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list-item.d.ts +8 -0
- package/dist/components/chat-list/chat-list-item.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list-items.d.ts +11 -0
- package/dist/components/chat-list/chat-list-items.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list.d.ts +63 -0
- package/dist/components/chat-list/chat-list.d.ts.map +1 -0
- package/dist/components/chat-list/chat-list.stories.d.ts +13 -0
- package/dist/components/chat-list/chat-list.stories.d.ts.map +1 -0
- package/dist/components/chat-list/index.d.ts +4 -0
- package/dist/components/chat-list/index.d.ts.map +1 -0
- package/dist/components/chat-message/chat-message.d.ts +17 -0
- package/dist/components/chat-message/chat-message.d.ts.map +1 -0
- package/dist/components/chat-message/chat-message.stories.d.ts +11 -0
- package/dist/components/chat-message/chat-message.stories.d.ts.map +1 -0
- package/dist/components/chat-message/index.d.ts +2 -0
- package/dist/components/chat-message/index.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts +9 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card-icon.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts +30 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts +11 -0
- package/dist/components/chat-message-attachment-card/chat-message-attachment-card.stories.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/index.d.ts +4 -0
- package/dist/components/chat-message-attachment-card/index.d.ts.map +1 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts +5 -0
- package/dist/components/chat-message-attachment-card/utils.d.ts.map +1 -0
- package/dist/components/chat-message-history/chat-message-history.d.ts +48 -0
- package/dist/components/chat-message-history/chat-message-history.d.ts.map +1 -0
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts +7 -0
- package/dist/components/chat-message-history/chat-message-history.stories.d.ts.map +1 -0
- package/dist/components/chat-message-history/index.d.ts +2 -0
- package/dist/components/chat-message-history/index.d.ts.map +1 -0
- package/dist/components/chat-message-response/chat-message-response.d.ts +7 -0
- package/dist/components/chat-message-response/chat-message-response.d.ts.map +1 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts +7 -0
- package/dist/components/chat-message-response/chat-message-response.stories.d.ts.map +1 -0
- package/dist/components/chat-message-response/index.d.ts +2 -0
- package/dist/components/chat-message-response/index.d.ts.map +1 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts +25 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.d.ts.map +1 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts +7 -0
- package/dist/components/chat-message-toolbar/chat-message-toolbar.stories.d.ts.map +1 -0
- package/dist/components/chat-message-toolbar/index.d.ts +2 -0
- package/dist/components/chat-message-toolbar/index.d.ts.map +1 -0
- package/dist/components/chat-messages/chat-messages.d.ts +24 -0
- package/dist/components/chat-messages/chat-messages.d.ts.map +1 -0
- package/dist/components/chat-messages/chat-messages.stories.d.ts +8 -0
- package/dist/components/chat-messages/chat-messages.stories.d.ts.map +1 -0
- package/dist/components/chat-messages/index.d.ts +2 -0
- package/dist/components/chat-messages/index.d.ts.map +1 -0
- package/dist/components/chat-notification-card/chat-notification-card.d.ts +114 -0
- package/dist/components/chat-notification-card/chat-notification-card.d.ts.map +1 -0
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts +10 -0
- package/dist/components/chat-notification-card/chat-notification-card.stories.d.ts.map +1 -0
- package/dist/components/chat-notification-card/index.d.ts +4 -0
- package/dist/components/chat-notification-card/index.d.ts.map +1 -0
- package/dist/components/chat-notification-card/types.d.ts +2 -0
- package/dist/components/chat-notification-card/types.d.ts.map +1 -0
- package/dist/components/chat-notification-card/utils.d.ts +3 -0
- package/dist/components/chat-notification-card/utils.d.ts.map +1 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts +12 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.d.ts.map +1 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts +8 -0
- package/dist/components/chat-notification-popup/chat-notification-popup.stories.d.ts.map +1 -0
- package/dist/components/chat-notification-popup/index.d.ts +2 -0
- package/dist/components/chat-notification-popup/index.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts +17 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-context.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts +2 -0
- package/dist/components/chat-prompt-box/chat-prompt-box-focus-plugin.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts +27 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts +9 -0
- package/dist/components/chat-prompt-box/chat-prompt-box.stories.d.ts.map +1 -0
- package/dist/components/chat-prompt-box/index.d.ts +3 -0
- package/dist/components/chat-prompt-box/index.d.ts.map +1 -0
- package/dist/components/chat-reply/chat-reply.d.ts +23 -0
- package/dist/components/chat-reply/chat-reply.d.ts.map +1 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts +7 -0
- package/dist/components/chat-reply/chat-reply.stories.d.ts.map +1 -0
- package/dist/components/chat-reply/index.d.ts +2 -0
- package/dist/components/chat-reply/index.d.ts.map +1 -0
- package/dist/components/chat-suggestion/chat-suggestion.d.ts +37 -0
- package/dist/components/chat-suggestion/chat-suggestion.d.ts.map +1 -0
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts +9 -0
- package/dist/components/chat-suggestion/chat-suggestion.stories.d.ts.map +1 -0
- package/dist/components/chat-suggestion/index.d.ts +2 -0
- package/dist/components/chat-suggestion/index.d.ts.map +1 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts +47 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.d.ts.map +1 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts +10 -0
- package/dist/components/chat-thinking-process/chat-thinking-process.stories.d.ts.map +1 -0
- package/dist/components/chat-thinking-process/index.d.ts +2 -0
- package/dist/components/chat-thinking-process/index.d.ts.map +1 -0
- package/dist/components/chat-thread/chat-thread.d.ts +78 -0
- package/dist/components/chat-thread/chat-thread.d.ts.map +1 -0
- package/dist/components/chat-thread/chat-thread.stories.d.ts +14 -0
- package/dist/components/chat-thread/chat-thread.stories.d.ts.map +1 -0
- package/dist/components/chat-thread/index.d.ts +2 -0
- package/dist/components/chat-thread/index.d.ts.map +1 -0
- package/dist/components/deprecated-empty-state.d.ts +22 -0
- package/dist/components/deprecated-empty-state.d.ts.map +1 -0
- package/dist/components/index.d.ts +27 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/markdown-viewer/hooks.d.ts +9 -0
- package/dist/components/markdown-viewer/hooks.d.ts.map +1 -0
- package/dist/components/markdown-viewer/index.d.ts +3 -0
- package/dist/components/markdown-viewer/index.d.ts.map +1 -0
- package/dist/components/markdown-viewer/markdown-viewer.d.ts +10 -0
- package/dist/components/markdown-viewer/markdown-viewer.d.ts.map +1 -0
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts +9 -0
- package/dist/components/markdown-viewer/markdown-viewer.stories.d.ts.map +1 -0
- package/dist/components/markdown-viewer/types.d.ts +9 -0
- package/dist/components/markdown-viewer/types.d.ts.map +1 -0
- package/dist/components/markdown-viewer/utils.d.ts +3 -0
- package/dist/components/markdown-viewer/utils.d.ts.map +1 -0
- package/dist/components/new-chat-trigger/index.d.ts +2 -0
- package/dist/components/new-chat-trigger/index.d.ts.map +1 -0
- package/dist/components/new-chat-trigger/new-chat-trigger.d.ts +8 -0
- package/dist/components/new-chat-trigger/new-chat-trigger.d.ts.map +1 -0
- package/dist/components/rich-text-area/constants/index.d.ts +3 -0
- package/dist/components/rich-text-area/constants/index.d.ts.map +1 -0
- package/dist/components/rich-text-area/hooks.d.ts +3 -0
- package/dist/components/rich-text-area/hooks.d.ts.map +1 -0
- package/dist/components/rich-text-area/html-config.d.ts +4 -0
- package/dist/components/rich-text-area/html-config.d.ts.map +1 -0
- package/dist/components/rich-text-area/index.d.ts +7 -0
- package/dist/components/rich-text-area/index.d.ts.map +1 -0
- package/dist/components/rich-text-area/nodes/div-block-node.d.ts +18 -0
- package/dist/components/rich-text-area/nodes/div-block-node.d.ts.map +1 -0
- package/dist/components/rich-text-area/nodes/image-node.d.ts +24 -0
- package/dist/components/rich-text-area/nodes/image-node.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/blur-plugin.d.ts +6 -0
- package/dist/components/rich-text-area/plugins/blur-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts +7 -0
- package/dist/components/rich-text-area/plugins/controlled-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts +7 -0
- package/dist/components/rich-text-area/plugins/controlled-value-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts +6 -0
- package/dist/components/rich-text-area/plugins/disabled-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts +10 -0
- package/dist/components/rich-text-area/plugins/file-attachment-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/focus-plugin.d.ts +6 -0
- package/dist/components/rich-text-area/plugins/focus-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts +19 -0
- package/dist/components/rich-text-area/plugins/html-paste-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts +12 -0
- package/dist/components/rich-text-area/plugins/image-drop-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/index.d.ts +11 -0
- package/dist/components/rich-text-area/plugins/index.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts +2 -0
- package/dist/components/rich-text-area/plugins/markdown-plain-paste-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts +7 -0
- package/dist/components/rich-text-area/plugins/value-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts +20 -0
- package/dist/components/rich-text-area/rich-text-area.d.ts.map +1 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts +7 -0
- package/dist/components/rich-text-area/rich-text-area.stories.d.ts.map +1 -0
- package/dist/components/rich-text-area/styled.d.ts +3 -0
- package/dist/components/rich-text-area/styled.d.ts.map +1 -0
- package/dist/components/rich-text-area/transformers.d.ts +16 -0
- package/dist/components/rich-text-area/transformers.d.ts.map +1 -0
- package/dist/components/rich-text-area/types.d.ts +8 -0
- package/dist/components/rich-text-area/types.d.ts.map +1 -0
- package/dist/components/rich-text-area/utils/index.d.ts +6 -0
- package/dist/components/rich-text-area/utils/index.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/alignment-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/alignment-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/attachment-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/attachment-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/bold-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/bold-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/clean-format-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/clean-format-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts +11 -0
- package/dist/components/rich-text-field/components/formatting-toolbar-plugin.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/image-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/image-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/index.d.ts +14 -0
- package/dist/components/rich-text-field/components/index.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/italic-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/italic-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/link-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/link-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/size-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/size-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/text-color-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/text-color-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/toolbar-button.d.ts +6 -0
- package/dist/components/rich-text-field/components/toolbar-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/toolbar-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/toolbar-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/typography-select.d.ts +5 -0
- package/dist/components/rich-text-field/components/typography-select.d.ts.map +1 -0
- package/dist/components/rich-text-field/components/underline-button.d.ts +3 -0
- package/dist/components/rich-text-field/components/underline-button.d.ts.map +1 -0
- package/dist/components/rich-text-field/constants.d.ts +57 -0
- package/dist/components/rich-text-field/constants.d.ts.map +1 -0
- package/dist/components/rich-text-field/context.d.ts +26 -0
- package/dist/components/rich-text-field/context.d.ts.map +1 -0
- package/dist/components/rich-text-field/index.d.ts +3 -0
- package/dist/components/rich-text-field/index.d.ts.map +1 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts +17 -0
- package/dist/components/rich-text-field/rich-text-field.d.ts.map +1 -0
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts +10 -0
- package/dist/components/rich-text-field/rich-text-field.stories.d.ts.map +1 -0
- package/dist/components/rich-text-field/utils.d.ts +1759 -0
- package/dist/components/rich-text-field/utils.d.ts.map +1 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.d.ts.map +1 -0
- package/dist/components/spinner/spinner.d.ts +9 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -0
- package/dist/components/spinner/spinner.stories.d.ts +8 -0
- package/dist/components/spinner/spinner.stories.d.ts.map +1 -0
- package/dist/contexts/chat-context/chat-context.d.ts +20 -0
- package/dist/contexts/chat-context/chat-context.d.ts.map +1 -0
- package/dist/contexts/chat-context/index.d.ts +2 -0
- package/dist/contexts/chat-context/index.d.ts.map +1 -0
- package/dist/contexts/chat-context/utils.d.ts +3 -0
- package/dist/contexts/chat-context/utils.d.ts.map +1 -0
- package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts +20 -0
- package/dist/contexts/chat-conversation-context/chat-conversation-context.d.ts.map +1 -0
- package/dist/contexts/chat-conversation-context/index.d.ts +2 -0
- package/dist/contexts/chat-conversation-context/index.d.ts.map +1 -0
- package/dist/contexts/index.d.ts +3 -0
- package/dist/contexts/index.d.ts.map +1 -0
- package/dist/docs/agent.stories.d.ts +41 -0
- package/dist/docs/agent.stories.d.ts.map +1 -0
- package/dist/docs/chat-panel.d.ts +33 -0
- package/dist/docs/chat-panel.d.ts.map +1 -0
- package/dist/docs/chatbot-panel.d.ts +20 -0
- package/dist/docs/chatbot-panel.d.ts.map +1 -0
- package/dist/docs/chatbot.stories.d.ts +11 -0
- package/dist/docs/chatbot.stories.d.ts.map +1 -0
- package/dist/domain/actions/constants.d.ts +2 -0
- package/dist/domain/actions/constants.d.ts.map +1 -0
- package/dist/domain/actions/hooks/index.d.ts +3 -0
- package/dist/domain/actions/hooks/index.d.ts.map +1 -0
- package/dist/domain/actions/index.d.ts +5 -0
- package/dist/domain/actions/index.d.ts.map +1 -0
- package/dist/domain/actions/types.d.ts +7 -0
- package/dist/domain/actions/types.d.ts.map +1 -0
- package/dist/domain/actions/utils/index.d.ts +11 -0
- package/dist/domain/actions/utils/index.d.ts.map +1 -0
- package/dist/domain/index.d.ts +2 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +7 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/use-chat-prompt-placeholder.d.ts +6 -0
- package/dist/hooks/use-chat-prompt-placeholder.d.ts.map +1 -0
- package/dist/hooks/use-chat-stream-message.d.ts +42 -0
- package/dist/hooks/use-chat-stream-message.d.ts.map +1 -0
- package/dist/hooks/use-current-chat-id.d.ts +2 -0
- package/dist/hooks/use-current-chat-id.d.ts.map +1 -0
- package/dist/hooks/use-is-current-chat-new.d.ts +2 -0
- package/dist/hooks/use-is-current-chat-new.d.ts.map +1 -0
- package/dist/hooks/use-loaded-chat-ids.d.ts +9 -0
- package/dist/hooks/use-loaded-chat-ids.d.ts.map +1 -0
- package/dist/hooks/use-on-chat-changed.d.ts +9 -0
- package/dist/hooks/use-on-chat-changed.d.ts.map +1 -0
- package/dist/index.css +2 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.es.js +4404 -0
- package/dist/index.es.js.map +1 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts +95 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.d.ts.map +1 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts +24 -0
- package/dist/layouts/chat-card-list-layout/chat-card-list-layout.stories.d.ts.map +1 -0
- package/dist/layouts/chat-card-list-layout/index.d.ts +3 -0
- package/dist/layouts/chat-card-list-layout/index.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts +84 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts +45 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts +37 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts +81 -0
- package/dist/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.d.ts.map +1 -0
- package/dist/layouts/chat-card-three-column-layout/index.d.ts +5 -0
- package/dist/layouts/chat-card-three-column-layout/index.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts +31 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts +12 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts +19 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts +35 -0
- package/dist/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.d.ts.map +1 -0
- package/dist/layouts/chat-card-two-column-layout/index.d.ts +4 -0
- package/dist/layouts/chat-card-two-column-layout/index.d.ts.map +1 -0
- package/dist/layouts/index.d.ts +4 -0
- package/dist/layouts/index.d.ts.map +1 -0
- package/dist/types.d.ts +22 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils/use-streaming-markdown.d.ts +18 -0
- package/dist/utils/use-streaming-markdown.d.ts.map +1 -0
- package/package.json +155 -0
- package/src/__tests__/setup.ts +5 -0
- package/src/components/canvas-shell/canvas-shell.json +126 -0
- package/src/components/canvas-shell/canvas-shell.stories.tsx +194 -0
- package/src/components/canvas-shell/canvas-shell.test.tsx +205 -0
- package/src/components/canvas-shell/canvas-shell.tsx +250 -0
- package/src/components/canvas-shell/index.ts +19 -0
- package/src/components/card-item-picker/__tests__/card-item-picker.spec.tsx +279 -0
- package/src/components/card-item-picker/card-item-picker-context.tsx +44 -0
- package/src/components/card-item-picker/card-item-picker-list.tsx +95 -0
- package/src/components/card-item-picker/card-item-picker-row-parts.tsx +96 -0
- package/src/components/card-item-picker/card-item-picker-row.tsx +109 -0
- package/src/components/card-item-picker/card-item-picker.json +147 -0
- package/src/components/card-item-picker/card-item-picker.stories.tsx +158 -0
- package/src/components/card-item-picker/index.ts +24 -0
- package/src/components/chat-card/__tests__/chat-card.spec.tsx +118 -0
- package/src/components/chat-card/chat-card.json +162 -0
- package/src/components/chat-card/chat-card.stories.tsx +349 -0
- package/src/components/chat-card/chat-card.tsx +106 -0
- package/src/components/chat-card/components/chat-card-body.tsx +115 -0
- package/src/components/chat-card/components/chat-card-footer.tsx +95 -0
- package/src/components/chat-card/components/chat-card-form.tsx +120 -0
- package/src/components/chat-card/components/chat-card-header.tsx +240 -0
- package/src/components/chat-card/components/index.ts +4 -0
- package/src/components/chat-card/context.tsx +34 -0
- package/src/components/chat-card/contexts.tsx +42 -0
- package/src/components/chat-card/hooks.ts +51 -0
- package/src/components/chat-card/index.ts +5 -0
- package/src/components/chat-card/types.ts +23 -0
- package/src/components/chat-card-container/chat-card-container.json +84 -0
- package/src/components/chat-card-container/chat-card-container.stories.tsx +149 -0
- package/src/components/chat-card-container/chat-card-container.tsx +75 -0
- package/src/components/chat-card-container/index.ts +2 -0
- package/src/components/chat-container/chat-container.json +93 -0
- package/src/components/chat-container/chat-container.stories.tsx +179 -0
- package/src/components/chat-container/chat-container.tsx +231 -0
- package/src/components/chat-container/index.ts +2 -0
- package/src/components/chat-input/chat-input.json +106 -0
- package/src/components/chat-input/chat-input.stories.tsx +291 -0
- package/src/components/chat-input/chat-input.tsx +220 -0
- package/src/components/chat-input/index.ts +2 -0
- package/src/components/chat-input/plugins/auto-focus-plugin.tsx +43 -0
- package/src/components/chat-input/plugins/controlled-value-plugin.tsx +47 -0
- package/src/components/chat-input/plugins/disabled-plugin.tsx +18 -0
- package/src/components/chat-input/plugins/focus-plugin.tsx +44 -0
- package/src/components/chat-input/plugins/has-value-plugin.tsx +51 -0
- package/src/components/chat-input/plugins/hooks.ts +7 -0
- package/src/components/chat-input/plugins/index.ts +7 -0
- package/src/components/chat-input/plugins/markdown-plain-paste-plugin.tsx +63 -0
- package/src/components/chat-input/plugins/utils.ts +48 -0
- package/src/components/chat-input/plugins/value-plugin.tsx +35 -0
- package/src/components/chat-input/transformers.ts +4 -0
- package/src/components/chat-list/chat-list-item.tsx +33 -0
- package/src/components/chat-list/chat-list-items.tsx +144 -0
- package/src/components/chat-list/chat-list.json +117 -0
- package/src/components/chat-list/chat-list.stories.tsx +332 -0
- package/src/components/chat-list/chat-list.tsx +278 -0
- package/src/components/chat-list/index.ts +18 -0
- package/src/components/chat-message/chat-message.json +105 -0
- package/src/components/chat-message/chat-message.stories.tsx +95 -0
- package/src/components/chat-message/chat-message.tsx +66 -0
- package/src/components/chat-message/index.ts +1 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card-icon.tsx +74 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.json +110 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.stories.tsx +131 -0
- package/src/components/chat-message-attachment-card/chat-message-attachment-card.tsx +142 -0
- package/src/components/chat-message-attachment-card/index.ts +12 -0
- package/src/components/chat-message-attachment-card/utils.ts +41 -0
- package/src/components/chat-message-history/chat-message-history.json +99 -0
- package/src/components/chat-message-history/chat-message-history.stories.tsx +136 -0
- package/src/components/chat-message-history/chat-message-history.tsx +277 -0
- package/src/components/chat-message-history/index.ts +13 -0
- package/src/components/chat-message-response/chat-message-response.json +68 -0
- package/src/components/chat-message-response/chat-message-response.stories.tsx +63 -0
- package/src/components/chat-message-response/chat-message-response.tsx +24 -0
- package/src/components/chat-message-response/index.ts +1 -0
- package/src/components/chat-message-toolbar/chat-message-toolbar.json +100 -0
- package/src/components/chat-message-toolbar/chat-message-toolbar.stories.tsx +62 -0
- package/src/components/chat-message-toolbar/chat-message-toolbar.tsx +97 -0
- package/src/components/chat-message-toolbar/index.ts +6 -0
- package/src/components/chat-messages/chat-messages.json +95 -0
- package/src/components/chat-messages/chat-messages.stories.tsx +284 -0
- package/src/components/chat-messages/chat-messages.tsx +264 -0
- package/src/components/chat-messages/index.ts +10 -0
- package/src/components/chat-notification-card/chat-notification-card.json +135 -0
- package/src/components/chat-notification-card/chat-notification-card.stories.tsx +290 -0
- package/src/components/chat-notification-card/chat-notification-card.tsx +684 -0
- package/src/components/chat-notification-card/index.ts +3 -0
- package/src/components/chat-notification-card/types.ts +1 -0
- package/src/components/chat-notification-card/utils.ts +34 -0
- package/src/components/chat-notification-popup/chat-notification-popup.json +97 -0
- package/src/components/chat-notification-popup/chat-notification-popup.stories.tsx +80 -0
- package/src/components/chat-notification-popup/chat-notification-popup.tsx +36 -0
- package/src/components/chat-notification-popup/index.ts +1 -0
- package/src/components/chat-prompt-box/chat-prompt-box-context.tsx +62 -0
- package/src/components/chat-prompt-box/chat-prompt-box-focus-plugin.tsx +22 -0
- package/src/components/chat-prompt-box/chat-prompt-box.json +106 -0
- package/src/components/chat-prompt-box/chat-prompt-box.stories.tsx +117 -0
- package/src/components/chat-prompt-box/chat-prompt-box.tsx +296 -0
- package/src/components/chat-prompt-box/index.ts +16 -0
- package/src/components/chat-reply/chat-reply.json +79 -0
- package/src/components/chat-reply/chat-reply.stories.tsx +72 -0
- package/src/components/chat-reply/chat-reply.tsx +103 -0
- package/src/components/chat-reply/index.ts +1 -0
- package/src/components/chat-suggestion/chat-suggestion.json +108 -0
- package/src/components/chat-suggestion/chat-suggestion.stories.tsx +147 -0
- package/src/components/chat-suggestion/chat-suggestion.tsx +184 -0
- package/src/components/chat-suggestion/index.ts +8 -0
- package/src/components/chat-thinking-process/chat-thinking-process.json +110 -0
- package/src/components/chat-thinking-process/chat-thinking-process.stories.tsx +202 -0
- package/src/components/chat-thinking-process/chat-thinking-process.tsx +268 -0
- package/src/components/chat-thinking-process/index.ts +9 -0
- package/src/components/chat-thread/__tests__/chat-thread.spec.tsx +385 -0
- package/src/components/chat-thread/chat-thread.json +120 -0
- package/src/components/chat-thread/chat-thread.stories.tsx +218 -0
- package/src/components/chat-thread/chat-thread.tsx +549 -0
- package/src/components/chat-thread/index.ts +18 -0
- package/src/components/deprecated-empty-state.ts +39 -0
- package/src/components/index.ts +26 -0
- package/src/components/markdown-viewer/hooks.ts +59 -0
- package/src/components/markdown-viewer/index.ts +2 -0
- package/src/components/markdown-viewer/markdown-viewer.json +84 -0
- package/src/components/markdown-viewer/markdown-viewer.stories.tsx +110 -0
- package/src/components/markdown-viewer/markdown-viewer.tsx +95 -0
- package/src/components/markdown-viewer/types.ts +10 -0
- package/src/components/markdown-viewer/utils.ts +5 -0
- package/src/components/new-chat-trigger/index.ts +1 -0
- package/src/components/new-chat-trigger/new-chat-trigger.tsx +29 -0
- package/src/components/rich-text-area/constants/index.ts +10 -0
- package/src/components/rich-text-area/hooks.ts +24 -0
- package/src/components/rich-text-area/html-config.ts +195 -0
- package/src/components/rich-text-area/index.ts +6 -0
- package/src/components/rich-text-area/nodes/div-block-node.tsx +145 -0
- package/src/components/rich-text-area/nodes/image-node.tsx +100 -0
- package/src/components/rich-text-area/plugins/blur-plugin.tsx +36 -0
- package/src/components/rich-text-area/plugins/controlled-plugin.tsx +23 -0
- package/src/components/rich-text-area/plugins/controlled-value-plugin.tsx +101 -0
- package/src/components/rich-text-area/plugins/disabled-plugin.tsx +17 -0
- package/src/components/rich-text-area/plugins/file-attachment-plugin.tsx +57 -0
- package/src/components/rich-text-area/plugins/focus-plugin.tsx +44 -0
- package/src/components/rich-text-area/plugins/html-paste-plugin.tsx +104 -0
- package/src/components/rich-text-area/plugins/image-drop-plugin.tsx +56 -0
- package/src/components/rich-text-area/plugins/index.ts +10 -0
- package/src/components/rich-text-area/plugins/markdown-plain-paste-plugin.tsx +63 -0
- package/src/components/rich-text-area/plugins/value-plugin.tsx +46 -0
- package/src/components/rich-text-area/rich-text-area.json +102 -0
- package/src/components/rich-text-area/rich-text-area.stories.tsx +140 -0
- package/src/components/rich-text-area/rich-text-area.tsx +156 -0
- package/src/components/rich-text-area/styled.tsx +20 -0
- package/src/components/rich-text-area/transformers.ts +175 -0
- package/src/components/rich-text-area/types.ts +8 -0
- package/src/components/rich-text-area/utils/index.ts +77 -0
- package/src/components/rich-text-field/components/alignment-select.tsx +103 -0
- package/src/components/rich-text-field/components/attachment-button.tsx +25 -0
- package/src/components/rich-text-field/components/bold-button.tsx +21 -0
- package/src/components/rich-text-field/components/clean-format-button.tsx +44 -0
- package/src/components/rich-text-field/components/formatting-toolbar-plugin.tsx +69 -0
- package/src/components/rich-text-field/components/image-button.tsx +11 -0
- package/src/components/rich-text-field/components/index.ts +14 -0
- package/src/components/rich-text-field/components/italic-button.tsx +21 -0
- package/src/components/rich-text-field/components/link-button.tsx +11 -0
- package/src/components/rich-text-field/components/size-select.tsx +27 -0
- package/src/components/rich-text-field/components/text-color-button.tsx +41 -0
- package/src/components/rich-text-field/components/toolbar-button.tsx +27 -0
- package/src/components/rich-text-field/components/toolbar-select.tsx +19 -0
- package/src/components/rich-text-field/components/typography-select.tsx +27 -0
- package/src/components/rich-text-field/components/underline-button.tsx +21 -0
- package/src/components/rich-text-field/constants.ts +33 -0
- package/src/components/rich-text-field/context.tsx +251 -0
- package/src/components/rich-text-field/index.tsx +6 -0
- package/src/components/rich-text-field/rich-text-field.json +118 -0
- package/src/components/rich-text-field/rich-text-field.stories.tsx +218 -0
- package/src/components/rich-text-field/rich-text-field.tsx +93 -0
- package/src/components/rich-text-field/utils.ts +532 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/spinner/spinner.json +73 -0
- package/src/components/spinner/spinner.stories.tsx +41 -0
- package/src/components/spinner/spinner.tsx +32 -0
- package/src/contexts/chat-context/chat-context.tsx +97 -0
- package/src/contexts/chat-context/index.ts +1 -0
- package/src/contexts/chat-context/utils.ts +7 -0
- package/src/contexts/chat-conversation-context/chat-conversation-context.tsx +608 -0
- package/src/contexts/chat-conversation-context/index.ts +1 -0
- package/src/contexts/index.ts +2 -0
- package/src/docs/agent.stories.tsx +567 -0
- package/src/docs/chat-panel.tsx +174 -0
- package/src/docs/chatbot-panel.tsx +381 -0
- package/src/docs/chatbot.mdx +144 -0
- package/src/docs/chatbot.stories.tsx +63 -0
- package/src/domain/actions/constants.ts +1 -0
- package/src/domain/actions/hooks/index.ts +22 -0
- package/src/domain/actions/index.ts +4 -0
- package/src/domain/actions/types.ts +6 -0
- package/src/domain/actions/utils/index.ts +112 -0
- package/src/domain/index.ts +1 -0
- package/src/hooks/index.tsx +10 -0
- package/src/hooks/use-chat-prompt-placeholder.ts +7 -0
- package/src/hooks/use-chat-stream-message.ts +189 -0
- package/src/hooks/use-current-chat-id.ts +6 -0
- package/src/hooks/use-is-current-chat-new.ts +6 -0
- package/src/hooks/use-loaded-chat-ids.ts +32 -0
- package/src/hooks/use-on-chat-changed.ts +33 -0
- package/src/index.css +1 -0
- package/src/index.ts +6 -0
- package/src/layouts/chat-card-list-layout/__tests__/chat-card-list-layout.spec.tsx +204 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.json +116 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.stories.tsx +190 -0
- package/src/layouts/chat-card-list-layout/chat-card-list-layout.tsx +250 -0
- package/src/layouts/chat-card-list-layout/index.ts +11 -0
- package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.sizing.test.ts +73 -0
- package/src/layouts/chat-card-three-column-layout/__tests__/chat-card-three-column-layout.spec.tsx +282 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.json +131 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.sizing.ts +78 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.stories.tsx +273 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.tsx +291 -0
- package/src/layouts/chat-card-three-column-layout/chat-card-three-column-layout.variants.ts +135 -0
- package/src/layouts/chat-card-three-column-layout/index.ts +24 -0
- package/src/layouts/chat-card-two-column-layout/__tests__/chat-card-two-column-layout.spec.tsx +109 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.json +97 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.sizing.ts +21 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.stories.tsx +138 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.tsx +132 -0
- package/src/layouts/chat-card-two-column-layout/chat-card-two-column-layout.variants.ts +65 -0
- package/src/layouts/chat-card-two-column-layout/index.ts +17 -0
- package/src/layouts/index.ts +3 -0
- package/src/types.ts +29 -0
- package/src/utils/use-streaming-markdown.ts +113 -0
- package/tailwind.css +7 -0
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
2
|
+
import {
|
|
3
|
+
createContext,
|
|
4
|
+
useCallback,
|
|
5
|
+
useContext,
|
|
6
|
+
useLayoutEffect,
|
|
7
|
+
useMemo,
|
|
8
|
+
useState,
|
|
9
|
+
type ComponentProps,
|
|
10
|
+
type CSSProperties,
|
|
11
|
+
type ReactNode,
|
|
12
|
+
} from 'react';
|
|
13
|
+
|
|
14
|
+
import { cn, useElementMeasure } from '@swisper.ai/web-core';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Width of the reading column when the consumer does not override it.
|
|
18
|
+
*
|
|
19
|
+
* Read from `--spacing-chat-area` (736px) rather than hardcoded, so a theme that
|
|
20
|
+
* retunes the chat area token moves the reading column with it.
|
|
21
|
+
*/
|
|
22
|
+
const DEFAULT_CONTENT_WIDTH = 'var(--spacing-chat-area)';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* The slots a child can measure itself into, and the custom property each publishes.
|
|
26
|
+
*
|
|
27
|
+
* These two heights cannot be measured by `ChatContainer` itself — they belong to
|
|
28
|
+
* specific children whose size the rest of the layout has to react to (the composer
|
|
29
|
+
* grows as the user types; the welcome box only exists on an empty chat). The slot
|
|
30
|
+
* reports upward so the variable lands on the container, where *siblings* can read it
|
|
31
|
+
* too; publishing it on the slot's own element would scope it to that subtree and the
|
|
32
|
+
* message list could not size against it.
|
|
33
|
+
*/
|
|
34
|
+
const SLOT_VARIABLES = {
|
|
35
|
+
prompt: '--type-window-height',
|
|
36
|
+
welcome: '--welcome-screen-box-height',
|
|
37
|
+
} as const;
|
|
38
|
+
|
|
39
|
+
type ChatContainerSlot = keyof typeof SLOT_VARIABLES;
|
|
40
|
+
|
|
41
|
+
type MeasuredLength = number | 'unset';
|
|
42
|
+
|
|
43
|
+
/** `unset` mirrors the pre-measurement state; for a height it computes as `auto`. */
|
|
44
|
+
function toCssLength(value: MeasuredLength): string {
|
|
45
|
+
return value === 'unset' ? 'unset' : `${value}px`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
interface ChatContainerContextValue {
|
|
49
|
+
setSlotHeight: (slot: ChatContainerSlot, height: MeasuredLength) => void;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
const ChatContainerContext = createContext<ChatContainerContextValue | null>(null);
|
|
53
|
+
|
|
54
|
+
function useChatContainerContext() {
|
|
55
|
+
const context = useContext(ChatContainerContext);
|
|
56
|
+
|
|
57
|
+
if (!context) {
|
|
58
|
+
throw new Error(
|
|
59
|
+
'[web-chat-ui] ChatContainer slot rendered outside a ChatContainer. ' +
|
|
60
|
+
'ChatContainerPrompt and ChatContainerWelcome report their measured height up ' +
|
|
61
|
+
'to the container, so one must be mounted above them. If it is mounted, check ' +
|
|
62
|
+
'the slot is not rendered through a portal that escapes the provider.',
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return context;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface ChatContainerProps extends ComponentProps<'section'> {
|
|
70
|
+
children: ReactNode;
|
|
71
|
+
/**
|
|
72
|
+
* Max width of the reading column, published as `--message-list-content-width` and
|
|
73
|
+
* consumed by `ChatCardContainer`'s `fixed` variant. Any CSS length.
|
|
74
|
+
*
|
|
75
|
+
* The published value is clamped with `min()` against the measured window width, so
|
|
76
|
+
* a container narrower than the reading column never sizes a child wider than
|
|
77
|
+
* itself — the case that makes a card overflow horizontally in a split-pane layout.
|
|
78
|
+
*/
|
|
79
|
+
contentWidth?: string;
|
|
80
|
+
asChild?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Root of a chat surface. Measures its own box and republishes it as CSS custom
|
|
85
|
+
* properties, so descendants size themselves against the chat window without a width
|
|
86
|
+
* being prop-drilled through every layer:
|
|
87
|
+
*
|
|
88
|
+
* - `--chat-window-width` / `--chat-window-height` — the measured border box, or
|
|
89
|
+
* `100%` until the first measurement lands.
|
|
90
|
+
* - `--message-list-content-width` — the reading column (see `contentWidth`).
|
|
91
|
+
* - `--type-window-height` / `--welcome-screen-box-height` — reported up by
|
|
92
|
+
* `ChatContainerPrompt` and `ChatContainerWelcome`; `unset` while unmounted.
|
|
93
|
+
*
|
|
94
|
+
* Deliberately applies **no horizontal padding of its own**. `useElementMeasure`
|
|
95
|
+
* reports the border box, so padding here would be counted inside
|
|
96
|
+
* `--chat-window-width`, and every child sizing against that variable would overflow
|
|
97
|
+
* by exactly that padding. Insetting is the child's job instead, through the
|
|
98
|
+
* `--spacing-message` gutter that `ChatCardContainer` subtracts.
|
|
99
|
+
*
|
|
100
|
+
* Every read site carries a `100%` fallback, so children still lay out sensibly when
|
|
101
|
+
* rendered outside a `ChatContainer` (portals, tests, Storybook).
|
|
102
|
+
*/
|
|
103
|
+
export function ChatContainer({
|
|
104
|
+
asChild = false,
|
|
105
|
+
children,
|
|
106
|
+
className,
|
|
107
|
+
contentWidth = DEFAULT_CONTENT_WIDTH,
|
|
108
|
+
style,
|
|
109
|
+
...rest
|
|
110
|
+
}: ChatContainerProps) {
|
|
111
|
+
const Comp = asChild ? Slot : 'section';
|
|
112
|
+
const { ref, width, height } = useElementMeasure<HTMLElement>();
|
|
113
|
+
const [slotHeights, setSlotHeights] = useState<Record<ChatContainerSlot, MeasuredLength>>({
|
|
114
|
+
prompt: 'unset',
|
|
115
|
+
welcome: 'unset',
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
const setSlotHeight = useCallback((slot: ChatContainerSlot, slotHeight: MeasuredLength) => {
|
|
119
|
+
// Returning the same object on an unchanged height keeps a slot's resize effect
|
|
120
|
+
// from re-rendering the whole chat on every observer callback.
|
|
121
|
+
setSlotHeights((current) =>
|
|
122
|
+
current[slot] === slotHeight ? current : { ...current, [slot]: slotHeight },
|
|
123
|
+
);
|
|
124
|
+
}, []);
|
|
125
|
+
|
|
126
|
+
const contextValue = useMemo<ChatContainerContextValue>(
|
|
127
|
+
() => ({ setSlotHeight }),
|
|
128
|
+
[setSlotHeight],
|
|
129
|
+
);
|
|
130
|
+
|
|
131
|
+
const containerStyle = useMemo(
|
|
132
|
+
() =>
|
|
133
|
+
({
|
|
134
|
+
'--chat-window-width': width === 'unset' ? '100%' : `${width}px`,
|
|
135
|
+
'--chat-window-height': height === 'unset' ? '100%' : `${height}px`,
|
|
136
|
+
'--message-list-content-width': `min(${contentWidth}, var(--chat-window-width))`,
|
|
137
|
+
[SLOT_VARIABLES.prompt]: toCssLength(slotHeights.prompt),
|
|
138
|
+
[SLOT_VARIABLES.welcome]: toCssLength(slotHeights.welcome),
|
|
139
|
+
...style,
|
|
140
|
+
}) as CSSProperties,
|
|
141
|
+
[width, height, contentWidth, slotHeights, style],
|
|
142
|
+
);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<ChatContainerContext.Provider value={contextValue}>
|
|
146
|
+
<Comp
|
|
147
|
+
ref={ref}
|
|
148
|
+
data-testid="chat-container"
|
|
149
|
+
className={cn('relative flex h-full min-h-0 w-full flex-col', className)}
|
|
150
|
+
style={containerStyle}
|
|
151
|
+
{...rest}
|
|
152
|
+
>
|
|
153
|
+
{children}
|
|
154
|
+
</Comp>
|
|
155
|
+
</ChatContainerContext.Provider>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** Measures the slot element and reports its height to the nearest `ChatContainer`. */
|
|
160
|
+
function useChatContainerSlot(slot: ChatContainerSlot) {
|
|
161
|
+
const { setSlotHeight } = useChatContainerContext();
|
|
162
|
+
// `HTMLElement`, not `HTMLDivElement`: with `asChild` the measured node is whatever
|
|
163
|
+
// element the consumer rendered, and the callback ref has to accept all of them.
|
|
164
|
+
const { ref, height } = useElementMeasure<HTMLElement>();
|
|
165
|
+
|
|
166
|
+
useLayoutEffect(() => {
|
|
167
|
+
setSlotHeight(slot, height);
|
|
168
|
+
|
|
169
|
+
// Reset on unmount so a layout that hides the welcome box after the first message
|
|
170
|
+
// does not leave a stale height behind for the message list to reserve space for.
|
|
171
|
+
return () => setSlotHeight(slot, 'unset');
|
|
172
|
+
}, [slot, height, setSlotHeight]);
|
|
173
|
+
|
|
174
|
+
return ref;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface ChatContainerSlotProps extends ComponentProps<'div'> {
|
|
178
|
+
children: ReactNode;
|
|
179
|
+
asChild?: boolean;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* Wraps the composer. Publishes its measured height as `--type-window-height` on the
|
|
184
|
+
* container, so the message list can reserve room for a composer that grows as the
|
|
185
|
+
* user types.
|
|
186
|
+
*/
|
|
187
|
+
export function ChatContainerPrompt({
|
|
188
|
+
asChild = false,
|
|
189
|
+
children,
|
|
190
|
+
className,
|
|
191
|
+
...rest
|
|
192
|
+
}: ChatContainerSlotProps) {
|
|
193
|
+
const ref = useChatContainerSlot('prompt');
|
|
194
|
+
const Comp = asChild ? Slot : 'div';
|
|
195
|
+
|
|
196
|
+
return (
|
|
197
|
+
<Comp
|
|
198
|
+
ref={ref}
|
|
199
|
+
data-testid="chat-container-prompt"
|
|
200
|
+
className={cn('shrink-0', className)}
|
|
201
|
+
{...rest}
|
|
202
|
+
>
|
|
203
|
+
{children}
|
|
204
|
+
</Comp>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Wraps the empty-chat welcome box. Publishes its measured height as
|
|
210
|
+
* `--welcome-screen-box-height` on the container.
|
|
211
|
+
*/
|
|
212
|
+
export function ChatContainerWelcome({
|
|
213
|
+
asChild = false,
|
|
214
|
+
children,
|
|
215
|
+
className,
|
|
216
|
+
...rest
|
|
217
|
+
}: ChatContainerSlotProps) {
|
|
218
|
+
const ref = useChatContainerSlot('welcome');
|
|
219
|
+
const Comp = asChild ? Slot : 'div';
|
|
220
|
+
|
|
221
|
+
return (
|
|
222
|
+
<Comp
|
|
223
|
+
ref={ref}
|
|
224
|
+
data-testid="chat-container-welcome"
|
|
225
|
+
className={cn('shrink-0', className)}
|
|
226
|
+
{...rest}
|
|
227
|
+
>
|
|
228
|
+
{children}
|
|
229
|
+
</Comp>
|
|
230
|
+
);
|
|
231
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-input",
|
|
4
|
+
"purpose": "Unstyled Lexical message editor for a chat composer: ChatInput holds the editor state and exposes focused, empty and error data attributes for styling, and ChatInputTextarea is the editable area whose value is a Markdown string.",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Building a custom chat composer whose look is set by the consumer (side-panel chat in web-chat-ui/CanvasShellFooter, agent composer)",
|
|
7
|
+
"The message text must round-trip as Markdown (paragraphs, lists, headings, code, quotes, links)",
|
|
8
|
+
"The composer styles itself from editor state (focused, empty) through data attributes or useChatInputContext"
|
|
9
|
+
],
|
|
10
|
+
"avoidWhen": [
|
|
11
|
+
"You want the styled Swisper prompt box with action slots and the compact/expanded layout — use web-chat-ui/chat-prompt-box",
|
|
12
|
+
"The user writes formatted long-form text with a toolbar (font, size, colour, alignment) — use web-chat-ui/rich-text-field",
|
|
13
|
+
"A plain form field with a label and helper text — use ui/text-area or ui/text-field"
|
|
14
|
+
],
|
|
15
|
+
"uxPrinciples": [
|
|
16
|
+
"Enter sends and Shift+Enter adds a line; this is the consumer's onKeyDown, not built in.",
|
|
17
|
+
"Keep the send button next to the input and disable it (or turn it into Stop) while a reply streams."
|
|
18
|
+
],
|
|
19
|
+
"accessibility": {
|
|
20
|
+
"required": [
|
|
21
|
+
"Give the send button next to the input an aria-label (e.g. \"Send message\")",
|
|
22
|
+
"Implement send on Enter in onKeyDown and call event.preventDefault(), leaving Shift+Enter to insert a new line"
|
|
23
|
+
],
|
|
24
|
+
"keyboard": [
|
|
25
|
+
"Typing edits the content; Lexical's rich-text and history plugins handle Ctrl/Cmd+Z, Ctrl/Cmd+Shift+Z and the bold, italic and underline shortcuts",
|
|
26
|
+
"Enter inserts a paragraph unless the consumer's onKeyDown prevents it",
|
|
27
|
+
"Paste inserts the clipboard's plain text, never pasted HTML"
|
|
28
|
+
],
|
|
29
|
+
"aria": [
|
|
30
|
+
"The editable element has role=textbox, aria-label=\"Chat input\" (fixed, not configurable) and aria-placeholder set to the placeholder; it gets aria-readonly when not editable",
|
|
31
|
+
"ChatInputTextarea's wrapper sets aria-disabled for isDisabled and aria-readonly for isReadOnly",
|
|
32
|
+
"ChatInput sets aria-invalid from its hasError state"
|
|
33
|
+
],
|
|
34
|
+
"focus": [
|
|
35
|
+
"autoFocus (on by default) focuses the editor on mount with the caret at the end; it is skipped when isDisabled or isReadOnly",
|
|
36
|
+
"isDisabled and isReadOnly both make the editor non-editable (contenteditable=false), which takes it out of the tab order; read-only text can still be selected with the pointer",
|
|
37
|
+
"The editor draws no focus ring (outline-none); style the ChatInput wrapper with data-[focused=true] so focus stays visible"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"behaviour": {
|
|
41
|
+
"states": ["empty", "has value", "focused", "disabled", "read-only"],
|
|
42
|
+
"rules": [
|
|
43
|
+
"ChatInput sets data-focused, data-empty and data-error on its wrapper and exposes the same state through useChatInputContext; style the composer from these, not from local state",
|
|
44
|
+
"value and onChange use Markdown: value is imported with the Lexical Markdown transformers and onChange receives the content exported as Markdown",
|
|
45
|
+
"value is controlled one-way: when it changes and differs from the editor's Markdown, the editor content is replaced and the caret moves to the end; setting value to '' clears the composer after send",
|
|
46
|
+
"The empty state is computed from the plain text, so a draft of only formatting counts as empty",
|
|
47
|
+
"Paste always inserts plain text: at the caret when there is a selection, otherwise it replaces the content line by line",
|
|
48
|
+
"isDisabled blocks editing, dims the textarea and prevents text selection; isReadOnly blocks editing without dimming, so the text stays readable and selectable",
|
|
49
|
+
"initialConfig is the Lexical composer config, read once on mount; override it only to add nodes or retheme the editor",
|
|
50
|
+
"ChatInputTextarea renders its children inside the Lexical composer, so custom Lexical plugins go there"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"composition": {
|
|
54
|
+
"allowedParents": ["web-chat-ui/CanvasShellFooter", "web-chat-ui/ChatContainerPrompt"],
|
|
55
|
+
"allowedChildren": [
|
|
56
|
+
"web-chat-ui/ChatInputTextarea",
|
|
57
|
+
"elements reading useChatInputContext",
|
|
58
|
+
"Lexical plugins (inside ChatInputTextarea)"
|
|
59
|
+
],
|
|
60
|
+
"avoidCombinations": [
|
|
61
|
+
"ChatInputTextarea outside a ChatInput — it reads the ChatInput context and the Lexical composer and throws without them",
|
|
62
|
+
"Nesting ChatInput inside web-chat-ui/chat-prompt-box — ChatPromptBox already renders a ChatInput; use ChatPromptBoxInput"
|
|
63
|
+
],
|
|
64
|
+
"contexts": ["chat composer", "panel footer"]
|
|
65
|
+
},
|
|
66
|
+
"content": {
|
|
67
|
+
"labelRules": [
|
|
68
|
+
"Placeholder: a short invitation in sentence case that says what to ask, e.g. \"Ask Swisper anything\"; it is also the editor's aria-placeholder"
|
|
69
|
+
],
|
|
70
|
+
"helperTextRules": [],
|
|
71
|
+
"errorRules": []
|
|
72
|
+
},
|
|
73
|
+
"aiDecisionRules": [
|
|
74
|
+
{
|
|
75
|
+
"condition": "A chat composer needs Swisper's standard prompt box look with attach and send buttons",
|
|
76
|
+
"decision": "Use web-chat-ui/chat-prompt-box instead of styling ChatInput",
|
|
77
|
+
"reason": "ChatPromptBox wraps ChatInput with the borders, focus glow, compact/expanded layout and action slots already designed"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"condition": "Messages should send on Enter",
|
|
81
|
+
"decision": "Handle onKeyDown on ChatInputTextarea: on Enter without Shift, call event.preventDefault() and send; then set value to ''",
|
|
82
|
+
"reason": "ChatInput has no submit behaviour of its own; preventing the default stops Lexical inserting a paragraph"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"condition": "The composer sits in a panel that opens with other content in focus, or on mobile",
|
|
86
|
+
"decision": "Pass autoFocus={false}",
|
|
87
|
+
"reason": "autoFocus is on by default and steals focus on mount"
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
"relatedComponents": [
|
|
91
|
+
"web-chat-ui/chat-prompt-box",
|
|
92
|
+
"web-chat-ui/rich-text-area",
|
|
93
|
+
"web-chat-ui/chat-suggestion",
|
|
94
|
+
"web-chat-ui/canvas-shell",
|
|
95
|
+
"ui/icon-button"
|
|
96
|
+
],
|
|
97
|
+
"tokenReferences": {
|
|
98
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
99
|
+
"categories": [
|
|
100
|
+
"text-text-tertiary (placeholder)",
|
|
101
|
+
"bg-paper-elevation-*",
|
|
102
|
+
"border-primary-main"
|
|
103
|
+
],
|
|
104
|
+
"rule": "ChatInput ships unstyled apart from the placeholder colour; style the wrapper with design-token classes such as bg-paper-elevation-2 and data-[focused=true]:border-primary-main, not hex values."
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { EnterIcon } from '@swisper.ai/icons';
|
|
5
|
+
import { IconButton } from '@swisper.ai/ui';
|
|
6
|
+
import { cn } from '@swisper.ai/web-core';
|
|
7
|
+
|
|
8
|
+
import { ChatInput, ChatInputTextarea, useChatInputContext } from './chat-input';
|
|
9
|
+
|
|
10
|
+
function ChatInputStateDebug() {
|
|
11
|
+
const { isFocused, hasValue } = useChatInputContext();
|
|
12
|
+
|
|
13
|
+
return (
|
|
14
|
+
<div>
|
|
15
|
+
<p className="text-sm text-text-secondary">
|
|
16
|
+
State: focused={String(isFocused)}, empty={String(!hasValue)}
|
|
17
|
+
</p>
|
|
18
|
+
</div>
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const meta: Meta<typeof ChatInput> = {
|
|
23
|
+
title: 'Chatbot/ChatInput',
|
|
24
|
+
component: ChatInput,
|
|
25
|
+
tags: ['autodocs'],
|
|
26
|
+
decorators: [
|
|
27
|
+
(Story) => (
|
|
28
|
+
<div className="max-w-[420px]">
|
|
29
|
+
<Story />
|
|
30
|
+
</div>
|
|
31
|
+
),
|
|
32
|
+
],
|
|
33
|
+
argTypes: {
|
|
34
|
+
initialConfig: {
|
|
35
|
+
control: false,
|
|
36
|
+
description:
|
|
37
|
+
'Lexical composer config (namespace, nodes, theme, `onError`). Override only to add nodes or retheme the editor.',
|
|
38
|
+
table: { defaultValue: { summary: 'DEFAULT_CONFIG' } },
|
|
39
|
+
},
|
|
40
|
+
children: {
|
|
41
|
+
control: false,
|
|
42
|
+
description:
|
|
43
|
+
'The editor and anything that reads its state: a `ChatInputTextarea`, plus optional siblings using `useChatInputContext`.',
|
|
44
|
+
},
|
|
45
|
+
className: {
|
|
46
|
+
control: 'text',
|
|
47
|
+
description:
|
|
48
|
+
'Extra classes on the wrapper; style focus and empty states with `data-[focused=true]` and `data-[empty=true]`.',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
args: {
|
|
52
|
+
className: 'min-h-[80px]',
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export default meta;
|
|
57
|
+
type Story = StoryObj<typeof ChatInput>;
|
|
58
|
+
|
|
59
|
+
export const Default: Story = {
|
|
60
|
+
render: () => (
|
|
61
|
+
<div className="flex flex-col gap-2">
|
|
62
|
+
<ChatInput className="min-h-[80px]">
|
|
63
|
+
<ChatInputTextarea placeholder="Input your message..." />
|
|
64
|
+
<ChatInputStateDebug />
|
|
65
|
+
</ChatInput>
|
|
66
|
+
</div>
|
|
67
|
+
),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const AutoFocus: Story = {
|
|
71
|
+
render: () => (
|
|
72
|
+
<div className="flex flex-col gap-2">
|
|
73
|
+
<ChatInput className="min-h-[80px]">
|
|
74
|
+
<ChatInputTextarea autoFocus placeholder="Focused on mount..." />
|
|
75
|
+
<ChatInputStateDebug />
|
|
76
|
+
</ChatInput>
|
|
77
|
+
<p className="text-sm text-text-secondary">
|
|
78
|
+
The editor receives focus when the story loads (focused=true in state debug).
|
|
79
|
+
</p>
|
|
80
|
+
</div>
|
|
81
|
+
),
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
export const Controlled: Story = {
|
|
85
|
+
render: function ControlledStory() {
|
|
86
|
+
const [value, setValue] = useState('');
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<div className="flex flex-col gap-2">
|
|
90
|
+
<ChatInput className="min-h-[80px]">
|
|
91
|
+
<ChatInputTextarea
|
|
92
|
+
value={value}
|
|
93
|
+
onChange={setValue}
|
|
94
|
+
placeholder="Input your message..."
|
|
95
|
+
/>
|
|
96
|
+
<ChatInputStateDebug />
|
|
97
|
+
</ChatInput>
|
|
98
|
+
|
|
99
|
+
<div>
|
|
100
|
+
<button
|
|
101
|
+
type="button"
|
|
102
|
+
onClick={() =>
|
|
103
|
+
setValue(
|
|
104
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
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>
|
|
116
|
+
</div>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const presetMessage =
|
|
123
|
+
'Hello! This message is preset. You can focus and select it, but editing depends on the story state.';
|
|
124
|
+
|
|
125
|
+
export const Disabled: Story = {
|
|
126
|
+
render: function DisabledStory() {
|
|
127
|
+
const [value] = useState(presetMessage);
|
|
128
|
+
|
|
129
|
+
return (
|
|
130
|
+
<div className="flex flex-col gap-2">
|
|
131
|
+
<ChatInput className="min-h-[80px]">
|
|
132
|
+
<ChatInputTextarea value={value} isDisabled placeholder="Disabled chat input" />
|
|
133
|
+
<ChatInputStateDebug />
|
|
134
|
+
</ChatInput>
|
|
135
|
+
<p className="text-sm text-text-secondary">Disabled: not editable and not tab-focusable.</p>
|
|
136
|
+
</div>
|
|
137
|
+
);
|
|
138
|
+
},
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
export const ReadOnly: Story = {
|
|
142
|
+
render: function ReadOnlyStory() {
|
|
143
|
+
const [value] = useState(presetMessage);
|
|
144
|
+
|
|
145
|
+
return (
|
|
146
|
+
<div className="flex flex-col gap-2">
|
|
147
|
+
<ChatInput className="min-h-[80px]">
|
|
148
|
+
<ChatInputTextarea value={value} isReadOnly placeholder="Read-only chat input" />
|
|
149
|
+
<ChatInputStateDebug />
|
|
150
|
+
</ChatInput>
|
|
151
|
+
<p className="text-sm text-text-secondary">
|
|
152
|
+
Read-only: not editable, but focusable and selectable.
|
|
153
|
+
</p>
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
},
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
const LOREM_MARKDOWN = `# Lorem ipsum dolor
|
|
160
|
+
|
|
161
|
+
**Bold lorem** and *italic dolor* sit amet, consectetur adipiscing elit.
|
|
162
|
+
|
|
163
|
+
## Consectetur adipiscing
|
|
164
|
+
|
|
165
|
+
- First bullet with lorem ipsum
|
|
166
|
+
- Second item with **emphasis**
|
|
167
|
+
- Third item with *italic notes*
|
|
168
|
+
|
|
169
|
+
\`\`\`
|
|
170
|
+
const example = "fenced code block";
|
|
171
|
+
console.log(example);
|
|
172
|
+
\`\`\`
|
|
173
|
+
|
|
174
|
+
> Blockquote: Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
|
|
175
|
+
|
|
176
|
+
Plain paragraph ending the sample.`;
|
|
177
|
+
|
|
178
|
+
export const ControlledMarkdown: Story = {
|
|
179
|
+
render: function ControlledMarkdownStory() {
|
|
180
|
+
const [value, setValue] = useState(LOREM_MARKDOWN);
|
|
181
|
+
|
|
182
|
+
return (
|
|
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>
|
|
192
|
+
|
|
193
|
+
<div className="flex gap-2">
|
|
194
|
+
<button type="button" onClick={() => setValue(LOREM_MARKDOWN)}>
|
|
195
|
+
Load sample
|
|
196
|
+
</button>
|
|
197
|
+
<button type="button" onClick={() => setValue('')}>
|
|
198
|
+
Clear
|
|
199
|
+
</button>
|
|
200
|
+
</div>
|
|
201
|
+
|
|
202
|
+
<pre
|
|
203
|
+
className="rounded-lg p-3 text-xs whitespace-pre-wrap"
|
|
204
|
+
style={{ background: '#1a1a2e', color: '#e0e0e0' }}
|
|
205
|
+
>
|
|
206
|
+
{value || '(empty)'}
|
|
207
|
+
</pre>
|
|
208
|
+
</div>
|
|
209
|
+
);
|
|
210
|
+
},
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export const SubmitOnEnter: Story = {
|
|
214
|
+
render: function SubmitOnEnterStory() {
|
|
215
|
+
const [value, setValue] = useState('');
|
|
216
|
+
const [lastSubmitted, setLastSubmitted] = useState<string | null>(null);
|
|
217
|
+
|
|
218
|
+
return (
|
|
219
|
+
<div className="flex flex-col gap-2">
|
|
220
|
+
<ChatInput className="min-h-[80px]">
|
|
221
|
+
<ChatInputTextarea
|
|
222
|
+
value={value}
|
|
223
|
+
onChange={setValue}
|
|
224
|
+
placeholder="Press Enter to submit, Shift+Enter for newline"
|
|
225
|
+
onKeyDown={(event) => {
|
|
226
|
+
if (event.key !== 'Enter' || event.shiftKey || !value.trim()) {
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
setLastSubmitted(value);
|
|
232
|
+
setValue('');
|
|
233
|
+
}}
|
|
234
|
+
/>
|
|
235
|
+
<ChatInputStateDebug />
|
|
236
|
+
</ChatInput>
|
|
237
|
+
|
|
238
|
+
<p className="text-sm text-text-secondary">
|
|
239
|
+
Enter submits and clears. Shift+Enter inserts a newline.
|
|
240
|
+
</p>
|
|
241
|
+
<p className="text-sm text-text-secondary">Last submitted: {lastSubmitted ?? '(none)'}</p>
|
|
242
|
+
</div>
|
|
243
|
+
);
|
|
244
|
+
},
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
export const SimplePromptBox: Story = {
|
|
248
|
+
render: function SimplePromptBoxStory() {
|
|
249
|
+
const [value, setValue] = useState('');
|
|
250
|
+
|
|
251
|
+
function handlePostMessage() {
|
|
252
|
+
setValue('');
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return (
|
|
256
|
+
<div className="flex w-full items-end gap-4 p-4">
|
|
257
|
+
<ChatInput
|
|
258
|
+
className={cn(
|
|
259
|
+
'max-h-[120px] min-h-[36px]',
|
|
260
|
+
'w-full overflow-y-auto rounded-[20px]',
|
|
261
|
+
'border border-solid border-transparent bg-paper-elevation-1 px-2.5 py-1.5 transition-[border-color] duration-150 outline-none',
|
|
262
|
+
'data-[focused=true]:border-primary-main data-[focused=true]:bg-paper-elevation-2',
|
|
263
|
+
)}
|
|
264
|
+
>
|
|
265
|
+
<ChatInputTextarea
|
|
266
|
+
placeholder="Input your message..."
|
|
267
|
+
className="text-white"
|
|
268
|
+
value={value}
|
|
269
|
+
onChange={setValue}
|
|
270
|
+
onKeyDown={(event) => {
|
|
271
|
+
if (event.key === 'Enter' && !event.shiftKey) {
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
handlePostMessage();
|
|
274
|
+
}
|
|
275
|
+
}}
|
|
276
|
+
/>
|
|
277
|
+
</ChatInput>
|
|
278
|
+
|
|
279
|
+
<IconButton
|
|
280
|
+
size="md"
|
|
281
|
+
variant="primary"
|
|
282
|
+
color="primary"
|
|
283
|
+
aria-label="Send message"
|
|
284
|
+
onClick={handlePostMessage}
|
|
285
|
+
>
|
|
286
|
+
<EnterIcon />
|
|
287
|
+
</IconButton>
|
|
288
|
+
</div>
|
|
289
|
+
);
|
|
290
|
+
},
|
|
291
|
+
};
|