@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,97 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { IconButton, Tooltip, type IconButtonProps } from '@swisper.ai/ui';
|
|
4
|
+
import { cn } from '@swisper.ai/web-core';
|
|
5
|
+
|
|
6
|
+
export interface ChatMessageToolbarProps extends ComponentProps<'div'> {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
reverse?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ChatMessageToolbar({
|
|
13
|
+
children,
|
|
14
|
+
className,
|
|
15
|
+
reverse = false,
|
|
16
|
+
...rest
|
|
17
|
+
}: ChatMessageToolbarProps) {
|
|
18
|
+
return (
|
|
19
|
+
<div
|
|
20
|
+
data-testid="chat-message-toolbar"
|
|
21
|
+
data-reverse={reverse}
|
|
22
|
+
className={cn(
|
|
23
|
+
'flex items-center justify-between',
|
|
24
|
+
'gap-16',
|
|
25
|
+
'h-24',
|
|
26
|
+
'data-[reverse=true]:flex-row-reverse',
|
|
27
|
+
className,
|
|
28
|
+
)}
|
|
29
|
+
{...rest}
|
|
30
|
+
>
|
|
31
|
+
{children}
|
|
32
|
+
</div>
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ChatMessageToolbarActionsProps {
|
|
37
|
+
children: ReactNode;
|
|
38
|
+
className?: string;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function ChatMessageToolbarActions({ children, className }: ChatMessageToolbarActionsProps) {
|
|
42
|
+
return (
|
|
43
|
+
<div
|
|
44
|
+
data-testid="chat-message-toolbar-actions"
|
|
45
|
+
role="group"
|
|
46
|
+
className={cn('flex items-center gap-8', className)}
|
|
47
|
+
>
|
|
48
|
+
{children}
|
|
49
|
+
</div>
|
|
50
|
+
);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ChatMessageToolbarActionButtonProps extends Omit<
|
|
54
|
+
IconButtonProps,
|
|
55
|
+
'variant' | 'size'
|
|
56
|
+
> {
|
|
57
|
+
children: ReactNode;
|
|
58
|
+
className?: string;
|
|
59
|
+
tooltip?: string;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function ChatMessageToolbarActionButton({
|
|
63
|
+
children,
|
|
64
|
+
className,
|
|
65
|
+
tooltip,
|
|
66
|
+
...rest
|
|
67
|
+
}: ChatMessageToolbarActionButtonProps) {
|
|
68
|
+
const content = (
|
|
69
|
+
<IconButton
|
|
70
|
+
variant="tertiary"
|
|
71
|
+
isSemantic={false}
|
|
72
|
+
size="xs"
|
|
73
|
+
className={cn('text-action-active', className)}
|
|
74
|
+
{...rest}
|
|
75
|
+
>
|
|
76
|
+
{children}
|
|
77
|
+
</IconButton>
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
if (!tooltip) {
|
|
81
|
+
return content;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return <Tooltip tooltip={tooltip}>{content}</Tooltip>;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ChatMessageToolbarTimestampProps {
|
|
88
|
+
children: ReactNode;
|
|
89
|
+
className?: string;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function ChatMessageToolbarTimestamp({
|
|
93
|
+
className,
|
|
94
|
+
children,
|
|
95
|
+
}: ChatMessageToolbarTimestampProps) {
|
|
96
|
+
return <div className={cn('text-action-active', className)}>{children}</div>;
|
|
97
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-messages",
|
|
4
|
+
"purpose": "A scrolling conversation driven by ChatConversationProvider: ChatMessagesList renders one row per question/answer group from a render function, scrolls each new group to the top of the view, and ChatMessagesScrollButton returns the reader to the end.",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Maintaining an existing screen built on ChatConversationProvider with ChatMessages and ChatMessagesList",
|
|
7
|
+
"A conversation rendered by index from a render function, where each row is one question with its answer (ChatMessageListGroup)"
|
|
8
|
+
],
|
|
9
|
+
"avoidWhen": [
|
|
10
|
+
"Building a new question-and-answer chat or agent transcript — use web-chat-ui/chat-thread, which the Chatbot overview builds on",
|
|
11
|
+
"Inside a web-chat-ui/chat-thread — the composition rules forbid nesting ChatMessages or ChatMessagesList in it, because ChatThread owns scrolling",
|
|
12
|
+
"Scrolling generic page content — use ui/scroll-area"
|
|
13
|
+
],
|
|
14
|
+
"uxPrinciples": [
|
|
15
|
+
"Read each answer from its start: a new question settles at the top of the view and its answer grows below it",
|
|
16
|
+
"Never pull the reader away while they read history; offer a scroll-to-latest button instead"
|
|
17
|
+
],
|
|
18
|
+
"accessibility": {
|
|
19
|
+
"required": [
|
|
20
|
+
"Render ChatMessages inside a web-chat-ui/ChatConversationProvider; it throws without one",
|
|
21
|
+
"Render inside a ui/TooltipProvider: ChatMessagesScrollButton always renders a ui/tooltip",
|
|
22
|
+
"Pass tooltip to ChatMessagesScrollButton: it is the button's aria-label as well as its tooltip"
|
|
23
|
+
],
|
|
24
|
+
"keyboard": [
|
|
25
|
+
"The viewport sets no tabIndex, so arrow and page keys scroll it only while focus is on an element inside it",
|
|
26
|
+
"The scroll-to-latest button has tabIndex=-1, so it is pointer-only"
|
|
27
|
+
],
|
|
28
|
+
"aria": [
|
|
29
|
+
"ChatMessagesList renders a role=log <ul> labelled \"Message list\" with aria-atomic=false, so appended rows are announced; each row is an <li>",
|
|
30
|
+
"A hidden 1px sentinel <li> at the end is aria-hidden",
|
|
31
|
+
"The scroll button wrapper is aria-hidden while the view is at the bottom",
|
|
32
|
+
"The built-in labels are fixed English strings"
|
|
33
|
+
],
|
|
34
|
+
"focus": ["No focus management; the scroll button is not a tab stop"]
|
|
35
|
+
},
|
|
36
|
+
"behaviour": {
|
|
37
|
+
"states": ["at latest", "scrolled up (scroll button visible)", "following the end"],
|
|
38
|
+
"rules": [
|
|
39
|
+
"messageCount is the number of rows ChatMessagesList renders, usually the number of question/answer groups; the render function receives each row's index",
|
|
40
|
+
"When messageCount changes, the list scrolls the last row's ChatMessageListGroup to the top of the view (instantly the first time, smoothly after that)",
|
|
41
|
+
"The last ChatMessageListGroup is at least as tall as the viewport, so a new question can settle at the top while its answer streams in below",
|
|
42
|
+
"Scrolling up (wheel or drag) stops the automatic scrolling and shows ChatMessagesScrollButton; clicking it scrolls to the bottom",
|
|
43
|
+
"When the reader scrolls back to the bottom themselves, the view keeps following the end of the last group as it grows; a new group switches back to settling at the top",
|
|
44
|
+
"ChatMessagesList's render function returns the row content: a ChatMessageListGroup holding that group's ChatMessage items",
|
|
45
|
+
"gap is the space in px between rows and between the messages inside a ChatMessageListGroup",
|
|
46
|
+
"ChatMessagesScrollButton shows a chevron icon unless children replace it",
|
|
47
|
+
"bottomTriggerClassName styles the hidden end sentinel the list uses to detect the bottom"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"composition": {
|
|
51
|
+
"allowedParents": ["web-chat-ui/ChatConversationProvider", "web-chat-ui/CanvasShellContent"],
|
|
52
|
+
"allowedChildren": ["web-chat-ui/ChatMessagesList", "web-chat-ui/ChatMessagesScrollButton"],
|
|
53
|
+
"avoidCombinations": [
|
|
54
|
+
"Nesting it in web-chat-ui/chat-thread or web-chat-ui/chat-message-history — two scrollers fight over the scroll position",
|
|
55
|
+
"ChatMessageListGroup outside a ChatMessagesList row — it reads the row's last-row flag and the conversation context",
|
|
56
|
+
"More than one ChatMessages under the same ChatConversationProvider — they share one scroll state"
|
|
57
|
+
],
|
|
58
|
+
"contexts": ["assistant side panel", "full-page chat"]
|
|
59
|
+
},
|
|
60
|
+
"content": {
|
|
61
|
+
"labelRules": [
|
|
62
|
+
"Scroll button tooltip: short and about the destination, e.g. \"Scroll to latest message\""
|
|
63
|
+
],
|
|
64
|
+
"helperTextRules": [],
|
|
65
|
+
"errorRules": []
|
|
66
|
+
},
|
|
67
|
+
"aiDecisionRules": [
|
|
68
|
+
{
|
|
69
|
+
"condition": "Starting a new chat or agent UI",
|
|
70
|
+
"decision": "Use web-chat-ui/chat-thread with ChatThreadProvider instead of ChatMessages",
|
|
71
|
+
"reason": "The Chatbot overview builds the conversation on ChatThread, which owns scrolling and offers anchor and follow modes"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"condition": "Keeping ChatMessages in an existing screen",
|
|
75
|
+
"decision": "Wrap it in ChatConversationProvider and a ui/TooltipProvider, pass messageCount as the number of groups, and return one ChatMessageListGroup with its ChatMessage items from the ChatMessagesList render function",
|
|
76
|
+
"reason": "The provider holds the scroll state, the scroll button needs the tooltip provider, and only ChatMessageListGroup marks the last row for anchoring"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"condition": "ChatMessages sits in a flex column with other content (such as an input below)",
|
|
80
|
+
"decision": "Give it className=\"min-h-0\" inside a parent with a fixed height",
|
|
81
|
+
"reason": "It is a flex-1 column; without a bounded height the list grows instead of scrolling"
|
|
82
|
+
}
|
|
83
|
+
],
|
|
84
|
+
"relatedComponents": [
|
|
85
|
+
"web-chat-ui/chat-thread",
|
|
86
|
+
"web-chat-ui/chat-message-history",
|
|
87
|
+
"web-chat-ui/chat-message",
|
|
88
|
+
"ui/scroll-area"
|
|
89
|
+
],
|
|
90
|
+
"tokenReferences": {
|
|
91
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
92
|
+
"categories": ["scrollbar-* (track, thumb, width)", "bg-paper-elevation-2 (scroll button)"],
|
|
93
|
+
"rule": "The scrollbar takes its colours and sizes from the scrollbar tokens; don't restyle it per screen."
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { ChatConversationProvider } from '@/contexts';
|
|
5
|
+
|
|
6
|
+
import { ChatMessage, ChatMessageContent } from '../chat-message';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ChatMessageListGroup,
|
|
10
|
+
ChatMessages,
|
|
11
|
+
ChatMessagesList,
|
|
12
|
+
ChatMessagesScrollButton,
|
|
13
|
+
} from './chat-messages';
|
|
14
|
+
|
|
15
|
+
interface DemoMessage {
|
|
16
|
+
isQuestion: boolean;
|
|
17
|
+
text: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const defaultMessages: DemoMessage[] = [
|
|
21
|
+
{ isQuestion: true, text: 'What are my recent transactions?' },
|
|
22
|
+
{ isQuestion: false, text: 'Here is the history of your recent transactions.' },
|
|
23
|
+
{ isQuestion: true, text: 'Can you show the largest one?' },
|
|
24
|
+
{
|
|
25
|
+
isQuestion: false,
|
|
26
|
+
text: 'Your largest transaction this month was $1,240.50 at Acme Corp on May 12.',
|
|
27
|
+
},
|
|
28
|
+
{ isQuestion: true, text: 'How does that compare to last month?' },
|
|
29
|
+
{
|
|
30
|
+
isQuestion: false,
|
|
31
|
+
text: 'Last month your largest transaction was $980.20, so spending is up about 27%.',
|
|
32
|
+
},
|
|
33
|
+
{ isQuestion: true, text: 'Break down my spending by category this month.' },
|
|
34
|
+
{
|
|
35
|
+
isQuestion: false,
|
|
36
|
+
text: 'Groceries: $412.30, Dining: $286.15, Transport: $154.00, Subscriptions: $89.99.',
|
|
37
|
+
},
|
|
38
|
+
{ isQuestion: true, text: 'Which subscriptions am I paying for?' },
|
|
39
|
+
{
|
|
40
|
+
isQuestion: false,
|
|
41
|
+
text: 'You have four active subscriptions: StreamPlus, Cloud Storage, Fitness App, and News Daily.',
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
|
|
45
|
+
const addedMessages: DemoMessage[] = [
|
|
46
|
+
{ isQuestion: true, text: 'Can I set a budget alert for dining?' },
|
|
47
|
+
{ isQuestion: false, text: 'Yes. What monthly cap would you like?' },
|
|
48
|
+
{ isQuestion: true, text: 'Set it to $300.' },
|
|
49
|
+
{ isQuestion: false, text: 'Done. You will get an alert when dining spending hits $300.' },
|
|
50
|
+
];
|
|
51
|
+
|
|
52
|
+
const loremIpsumParagraph =
|
|
53
|
+
'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.';
|
|
54
|
+
|
|
55
|
+
const streamingAnswers = [
|
|
56
|
+
Array.from({ length: 8 }, () => loremIpsumParagraph).join(' '),
|
|
57
|
+
Array.from({ length: 10 }, () => loremIpsumParagraph).join(' '),
|
|
58
|
+
Array.from({ length: 12 }, () => loremIpsumParagraph).join(' '),
|
|
59
|
+
];
|
|
60
|
+
|
|
61
|
+
const streamingQuestions = [
|
|
62
|
+
'Summarize my financial activity.',
|
|
63
|
+
'What are my largest expenses this month?',
|
|
64
|
+
'How can I reduce my subscription spending?',
|
|
65
|
+
'Break down my cash flow for the last quarter.',
|
|
66
|
+
'What is the weather in Tokyo?',
|
|
67
|
+
'Compare my dining spend to last month.',
|
|
68
|
+
];
|
|
69
|
+
|
|
70
|
+
function pickRandomItem<T>(items: T[]): T {
|
|
71
|
+
return items[Math.floor(Math.random() * items.length)];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
const meta: Meta<typeof ChatMessages> = {
|
|
75
|
+
title: 'Chatbot/ChatMessages',
|
|
76
|
+
component: ChatMessages,
|
|
77
|
+
parameters: { layout: 'padded' },
|
|
78
|
+
tags: ['autodocs'],
|
|
79
|
+
decorators: [
|
|
80
|
+
(Story) => (
|
|
81
|
+
<ChatConversationProvider chatId="storybook-chat">
|
|
82
|
+
<div className="relative h-[480px] w-[700px] bg-paper-1">
|
|
83
|
+
<Story />
|
|
84
|
+
</div>
|
|
85
|
+
</ChatConversationProvider>
|
|
86
|
+
),
|
|
87
|
+
],
|
|
88
|
+
argTypes: {
|
|
89
|
+
messageCount: {
|
|
90
|
+
control: 'number',
|
|
91
|
+
description:
|
|
92
|
+
'Number of rows `ChatMessagesList` renders; changing it scrolls to the latest row. Usually the number of question/answer groups.',
|
|
93
|
+
table: { defaultValue: { summary: '0' } },
|
|
94
|
+
},
|
|
95
|
+
gap: {
|
|
96
|
+
control: 'number',
|
|
97
|
+
description: 'Vertical space between rows and between messages inside a group, in px.',
|
|
98
|
+
table: { defaultValue: { summary: '16' } },
|
|
99
|
+
},
|
|
100
|
+
children: {
|
|
101
|
+
control: false,
|
|
102
|
+
description:
|
|
103
|
+
'A `ChatMessagesList` (render function per row) and an optional `ChatMessagesScrollButton`.',
|
|
104
|
+
},
|
|
105
|
+
className: {
|
|
106
|
+
control: 'text',
|
|
107
|
+
description: 'Extra classes merged onto the root.',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
args: {
|
|
111
|
+
messageCount: 0,
|
|
112
|
+
gap: 16,
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
function useGroupMessages(messages: DemoMessage[]) {
|
|
117
|
+
return useMemo(() => {
|
|
118
|
+
const groups: DemoMessage[][] = [];
|
|
119
|
+
|
|
120
|
+
for (let i = 0; i < messages.length; i += 2) {
|
|
121
|
+
groups.push(messages.slice(i, i + 2));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return groups;
|
|
125
|
+
}, [messages]);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export default meta;
|
|
129
|
+
type Story = StoryObj<typeof ChatMessages>;
|
|
130
|
+
|
|
131
|
+
export const Default: Story = {
|
|
132
|
+
render: () => {
|
|
133
|
+
const [messages, setMessages] = useState(defaultMessages);
|
|
134
|
+
const groupedMessages = useGroupMessages(messages);
|
|
135
|
+
|
|
136
|
+
function handleAddMessage() {
|
|
137
|
+
setMessages((currentMessages) => [
|
|
138
|
+
...currentMessages,
|
|
139
|
+
addedMessages[currentMessages.length % addedMessages.length],
|
|
140
|
+
]);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return (
|
|
144
|
+
<div className="flex h-full flex-col gap-12">
|
|
145
|
+
<ChatMessages messageCount={groupedMessages.length} className="min-h-0">
|
|
146
|
+
<ChatMessagesList className="px-16 py-16">
|
|
147
|
+
{(groupIndex) => {
|
|
148
|
+
const group = groupedMessages[groupIndex];
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<ChatMessageListGroup>
|
|
152
|
+
{group.map((message, messageIndex) => (
|
|
153
|
+
<ChatMessage
|
|
154
|
+
key={`${groupIndex}-${messageIndex}`}
|
|
155
|
+
isQuestion={message.isQuestion}
|
|
156
|
+
>
|
|
157
|
+
<ChatMessageContent>{message.text}</ChatMessageContent>
|
|
158
|
+
</ChatMessage>
|
|
159
|
+
))}
|
|
160
|
+
</ChatMessageListGroup>
|
|
161
|
+
);
|
|
162
|
+
}}
|
|
163
|
+
</ChatMessagesList>
|
|
164
|
+
<ChatMessagesScrollButton />
|
|
165
|
+
</ChatMessages>
|
|
166
|
+
|
|
167
|
+
<button type="button" onClick={handleAddMessage}>
|
|
168
|
+
Add message
|
|
169
|
+
</button>
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export const Streaming: Story = {
|
|
176
|
+
render: () => {
|
|
177
|
+
const [messages, setMessages] = useState<DemoMessage[]>([
|
|
178
|
+
{ isQuestion: true, text: streamingQuestions[0] },
|
|
179
|
+
{ isQuestion: false, text: streamingAnswers[0] },
|
|
180
|
+
]);
|
|
181
|
+
const [activeAnswer, setActiveAnswer] = useState('');
|
|
182
|
+
const streamIndexRef = useRef(0);
|
|
183
|
+
const answerIndexRef = useRef(0);
|
|
184
|
+
const activeAnswerRef = useRef('');
|
|
185
|
+
const intervalRef = useRef<number | null>(null);
|
|
186
|
+
|
|
187
|
+
function clearStreamInterval() {
|
|
188
|
+
if (intervalRef.current === null) {
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
window.clearInterval(intervalRef.current);
|
|
193
|
+
intervalRef.current = null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
useEffect(() => () => clearStreamInterval(), []);
|
|
197
|
+
|
|
198
|
+
function setStreamingAnswer(value: string) {
|
|
199
|
+
activeAnswerRef.current = value;
|
|
200
|
+
setActiveAnswer(value);
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function startNextStream() {
|
|
204
|
+
clearStreamInterval();
|
|
205
|
+
|
|
206
|
+
const answer = streamingAnswers[answerIndexRef.current % streamingAnswers.length];
|
|
207
|
+
streamIndexRef.current = 1;
|
|
208
|
+
setStreamingAnswer(answer.slice(0, streamIndexRef.current));
|
|
209
|
+
|
|
210
|
+
intervalRef.current = window.setInterval(() => {
|
|
211
|
+
streamIndexRef.current += 3;
|
|
212
|
+
const nextValue = answer.slice(0, streamIndexRef.current);
|
|
213
|
+
|
|
214
|
+
setStreamingAnswer(nextValue);
|
|
215
|
+
|
|
216
|
+
if (nextValue.length >= answer.length) {
|
|
217
|
+
clearStreamInterval();
|
|
218
|
+
}
|
|
219
|
+
}, 40);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function finishCurrentStream() {
|
|
223
|
+
if (!activeAnswerRef.current) {
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
clearStreamInterval();
|
|
228
|
+
|
|
229
|
+
const answer = streamingAnswers[answerIndexRef.current % streamingAnswers.length];
|
|
230
|
+
|
|
231
|
+
setMessages((currentMessages) => [...currentMessages, { isQuestion: false, text: answer }]);
|
|
232
|
+
setStreamingAnswer('');
|
|
233
|
+
streamIndexRef.current = 0;
|
|
234
|
+
answerIndexRef.current += 1;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
function handleAddMessage() {
|
|
238
|
+
finishCurrentStream();
|
|
239
|
+
|
|
240
|
+
setMessages((currentMessages) => [
|
|
241
|
+
...currentMessages,
|
|
242
|
+
{ isQuestion: true, text: pickRandomItem(streamingQuestions) },
|
|
243
|
+
]);
|
|
244
|
+
|
|
245
|
+
startNextStream();
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const visibleMessages = activeAnswer
|
|
249
|
+
? [...messages, { isQuestion: false, text: activeAnswer }]
|
|
250
|
+
: messages;
|
|
251
|
+
|
|
252
|
+
const groupedMessages = useGroupMessages(visibleMessages);
|
|
253
|
+
|
|
254
|
+
return (
|
|
255
|
+
<div className="flex h-full flex-col gap-12">
|
|
256
|
+
<ChatMessages messageCount={groupedMessages.length} className="min-h-0">
|
|
257
|
+
<ChatMessagesList className="px-16 py-16">
|
|
258
|
+
{(groupIndex) => {
|
|
259
|
+
const group = groupedMessages[groupIndex];
|
|
260
|
+
|
|
261
|
+
return (
|
|
262
|
+
<ChatMessageListGroup>
|
|
263
|
+
{group.map((message, messageIndex) => (
|
|
264
|
+
<ChatMessage
|
|
265
|
+
key={`${groupIndex}-${messageIndex}`}
|
|
266
|
+
isQuestion={message.isQuestion}
|
|
267
|
+
>
|
|
268
|
+
<ChatMessageContent>{message.text}</ChatMessageContent>
|
|
269
|
+
</ChatMessage>
|
|
270
|
+
))}
|
|
271
|
+
</ChatMessageListGroup>
|
|
272
|
+
);
|
|
273
|
+
}}
|
|
274
|
+
</ChatMessagesList>
|
|
275
|
+
<ChatMessagesScrollButton />
|
|
276
|
+
</ChatMessages>
|
|
277
|
+
|
|
278
|
+
<button type="button" onClick={handleAddMessage}>
|
|
279
|
+
Add message
|
|
280
|
+
</button>
|
|
281
|
+
</div>
|
|
282
|
+
);
|
|
283
|
+
},
|
|
284
|
+
};
|