@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,278 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useLayoutEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type MutableRefObject,
|
|
10
|
+
type ReactNode,
|
|
11
|
+
type RefObject,
|
|
12
|
+
} from 'react';
|
|
13
|
+
import { createPortal } from 'react-dom';
|
|
14
|
+
|
|
15
|
+
import { Skeleton } from '@swisper.ai/ui';
|
|
16
|
+
import { cn } from '@swisper.ai/web-core';
|
|
17
|
+
|
|
18
|
+
export interface ChatListContextValue {
|
|
19
|
+
loadedCount: number;
|
|
20
|
+
totalCount?: number;
|
|
21
|
+
hasMore: boolean;
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
isLoadingMore: boolean;
|
|
24
|
+
isEmpty: boolean;
|
|
25
|
+
hasError: boolean;
|
|
26
|
+
onLoadMore?: () => void;
|
|
27
|
+
getItemKey: (index: number) => string | number;
|
|
28
|
+
scrollElementRef: RefObject<HTMLDivElement | null>;
|
|
29
|
+
setScrollElement: (node: HTMLDivElement | null) => void;
|
|
30
|
+
loadMoreContentRef: MutableRefObject<ReactNode>;
|
|
31
|
+
loadMoreVersion: number;
|
|
32
|
+
bumpLoadMore: () => void;
|
|
33
|
+
skeletonContainer: HTMLElement | null;
|
|
34
|
+
setSkeletonContainer: (node: HTMLElement | null) => void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const ChatListContext = createContext<ChatListContextValue | null>(null);
|
|
38
|
+
|
|
39
|
+
export function useChatListContext() {
|
|
40
|
+
const context = useContext(ChatListContext);
|
|
41
|
+
|
|
42
|
+
if (!context) {
|
|
43
|
+
throw new Error('"useChatListContext" must be used within a ChatList');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return context;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ChatListProps {
|
|
50
|
+
children: ReactNode;
|
|
51
|
+
className?: string;
|
|
52
|
+
loadedCount: number;
|
|
53
|
+
totalCount?: number;
|
|
54
|
+
hasMore?: boolean;
|
|
55
|
+
isLoading?: boolean;
|
|
56
|
+
isLoadingMore?: boolean;
|
|
57
|
+
hasError?: boolean;
|
|
58
|
+
onLoadMore?: () => void;
|
|
59
|
+
getItemKey: (index: number) => string | number;
|
|
60
|
+
'aria-label'?: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function ChatList({
|
|
64
|
+
children,
|
|
65
|
+
className,
|
|
66
|
+
loadedCount,
|
|
67
|
+
totalCount,
|
|
68
|
+
hasMore: hasMoreProp,
|
|
69
|
+
isLoading = false,
|
|
70
|
+
isLoadingMore = false,
|
|
71
|
+
hasError = false,
|
|
72
|
+
onLoadMore,
|
|
73
|
+
getItemKey,
|
|
74
|
+
'aria-label': ariaLabel = 'Chat list',
|
|
75
|
+
}: ChatListProps) {
|
|
76
|
+
const scrollElementRef = useRef<HTMLDivElement | null>(null);
|
|
77
|
+
const loadMoreContentRef = useRef<ReactNode>(null);
|
|
78
|
+
const [loadMoreVersion, setLoadMoreVersion] = useState(0);
|
|
79
|
+
const [skeletonContainer, setSkeletonContainer] = useState<HTMLElement | null>(null);
|
|
80
|
+
const [, setScrollElementVersion] = useState(0);
|
|
81
|
+
|
|
82
|
+
const setScrollElement = useCallback((node: HTMLDivElement | null) => {
|
|
83
|
+
scrollElementRef.current = node;
|
|
84
|
+
setScrollElementVersion((version) => version + 1);
|
|
85
|
+
}, []);
|
|
86
|
+
|
|
87
|
+
const bumpLoadMore = useCallback(() => {
|
|
88
|
+
setLoadMoreVersion((version) => version + 1);
|
|
89
|
+
}, []);
|
|
90
|
+
|
|
91
|
+
const hasMore = hasMoreProp ?? (totalCount != null ? loadedCount < totalCount : false);
|
|
92
|
+
const isEmpty = loadedCount === 0 && !isLoading && !hasError;
|
|
93
|
+
|
|
94
|
+
const contextValue = useMemo<ChatListContextValue>(
|
|
95
|
+
() => ({
|
|
96
|
+
loadedCount,
|
|
97
|
+
totalCount,
|
|
98
|
+
hasMore,
|
|
99
|
+
isLoading,
|
|
100
|
+
isLoadingMore,
|
|
101
|
+
isEmpty,
|
|
102
|
+
hasError,
|
|
103
|
+
onLoadMore,
|
|
104
|
+
getItemKey,
|
|
105
|
+
scrollElementRef,
|
|
106
|
+
setScrollElement,
|
|
107
|
+
loadMoreContentRef,
|
|
108
|
+
loadMoreVersion,
|
|
109
|
+
bumpLoadMore,
|
|
110
|
+
skeletonContainer,
|
|
111
|
+
setSkeletonContainer,
|
|
112
|
+
}),
|
|
113
|
+
[
|
|
114
|
+
loadedCount,
|
|
115
|
+
totalCount,
|
|
116
|
+
hasMore,
|
|
117
|
+
isLoading,
|
|
118
|
+
isLoadingMore,
|
|
119
|
+
isEmpty,
|
|
120
|
+
hasError,
|
|
121
|
+
onLoadMore,
|
|
122
|
+
getItemKey,
|
|
123
|
+
setScrollElement,
|
|
124
|
+
loadMoreVersion,
|
|
125
|
+
bumpLoadMore,
|
|
126
|
+
skeletonContainer,
|
|
127
|
+
],
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
return (
|
|
131
|
+
<ChatListContext.Provider value={contextValue}>
|
|
132
|
+
<div
|
|
133
|
+
data-slot="chat-list"
|
|
134
|
+
data-testid="chat-list"
|
|
135
|
+
data-loading={isLoading}
|
|
136
|
+
data-loading-more={isLoadingMore}
|
|
137
|
+
data-empty={isEmpty}
|
|
138
|
+
data-error={hasError}
|
|
139
|
+
role="navigation"
|
|
140
|
+
aria-label={ariaLabel}
|
|
141
|
+
className={cn('group/chat-list relative flex min-h-0 flex-1 flex-col', className)}
|
|
142
|
+
>
|
|
143
|
+
{children}
|
|
144
|
+
</div>
|
|
145
|
+
</ChatListContext.Provider>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export interface ChatListSkeletonProps {
|
|
150
|
+
/** Your own placeholder rows. Leave it out to get `rows` default rows built from `Skeleton`. */
|
|
151
|
+
children?: ReactNode;
|
|
152
|
+
/** Number of default rows, used only when `children` is not passed. Rows past the list's height are clipped. */
|
|
153
|
+
rows?: number;
|
|
154
|
+
className?: string;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// Title and preview widths alternate per row, so the placeholder reads as a list of chats.
|
|
158
|
+
const TITLE_WIDTHS = ['w-2/3', 'w-1/2'] as const;
|
|
159
|
+
const PREVIEW_WIDTHS = ['w-full', 'w-4/5'] as const;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Placeholder for the first page of chats. Renders only while `isLoading` is true and no chats are
|
|
163
|
+
* loaded, in the space `ChatListItems` will fill. It is a `role="status"` region named
|
|
164
|
+
* "Loading chats"; its rows are `Skeleton`s from `@swisper.ai/ui`, which are `aria-hidden`.
|
|
165
|
+
*/
|
|
166
|
+
export function ChatListSkeleton({ children, rows = 16, className }: ChatListSkeletonProps) {
|
|
167
|
+
const { isLoading, loadedCount, skeletonContainer } = useChatListContext();
|
|
168
|
+
|
|
169
|
+
if (!(isLoading && loadedCount === 0) || !skeletonContainer) {
|
|
170
|
+
return null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
return createPortal(
|
|
174
|
+
<div
|
|
175
|
+
data-slot="chat-list-skeleton"
|
|
176
|
+
data-testid="chat-list-skeleton"
|
|
177
|
+
role="status"
|
|
178
|
+
aria-busy="true"
|
|
179
|
+
aria-label="Loading chats"
|
|
180
|
+
className={cn('flex min-h-0 flex-1 flex-col gap-4 overflow-hidden', className)}
|
|
181
|
+
>
|
|
182
|
+
{children ??
|
|
183
|
+
Array.from({ length: rows }, (_, index) => (
|
|
184
|
+
<div
|
|
185
|
+
key={index}
|
|
186
|
+
data-slot="chat-list-skeleton-row"
|
|
187
|
+
className="flex shrink-0 flex-col gap-4 px-12 py-8"
|
|
188
|
+
>
|
|
189
|
+
<div className="flex h-20 items-center">
|
|
190
|
+
<Skeleton className={cn('h-12', TITLE_WIDTHS[index % 2])} />
|
|
191
|
+
</div>
|
|
192
|
+
<div className="flex h-16 items-center">
|
|
193
|
+
<Skeleton className={cn('h-10', PREVIEW_WIDTHS[index % 2])} />
|
|
194
|
+
</div>
|
|
195
|
+
</div>
|
|
196
|
+
))}
|
|
197
|
+
</div>,
|
|
198
|
+
skeletonContainer,
|
|
199
|
+
);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface ChatListEmptyStateProps {
|
|
203
|
+
children?: ReactNode;
|
|
204
|
+
className?: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export function ChatListEmptyState({ children, className }: ChatListEmptyStateProps) {
|
|
208
|
+
const { isEmpty } = useChatListContext();
|
|
209
|
+
|
|
210
|
+
if (!isEmpty) {
|
|
211
|
+
return null;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
<div
|
|
216
|
+
data-slot="chat-list-empty-state"
|
|
217
|
+
data-testid="chat-list-empty-state"
|
|
218
|
+
role="status"
|
|
219
|
+
aria-live="polite"
|
|
220
|
+
aria-label="No chats"
|
|
221
|
+
className={cn('flex flex-1 items-center justify-center', className)}
|
|
222
|
+
>
|
|
223
|
+
{children}
|
|
224
|
+
</div>
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
export interface ChatListErrorProps {
|
|
229
|
+
children?: ReactNode;
|
|
230
|
+
error?: Error | string;
|
|
231
|
+
className?: string;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function ChatListError({ children, error, className }: ChatListErrorProps) {
|
|
235
|
+
const { hasError, loadedCount } = useChatListContext();
|
|
236
|
+
|
|
237
|
+
if (!(hasError && loadedCount === 0)) {
|
|
238
|
+
return null;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return (
|
|
242
|
+
<div
|
|
243
|
+
data-slot="chat-list-error"
|
|
244
|
+
data-testid="chat-list-error"
|
|
245
|
+
role="alert"
|
|
246
|
+
aria-live="assertive"
|
|
247
|
+
aria-label="Error loading chats"
|
|
248
|
+
className={cn('flex flex-1 items-center justify-center', className)}
|
|
249
|
+
>
|
|
250
|
+
{children || (
|
|
251
|
+
<div className="text-text-error-main">
|
|
252
|
+
{error instanceof Error ? error.message : error || 'An error occurred'}
|
|
253
|
+
</div>
|
|
254
|
+
)}
|
|
255
|
+
</div>
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export interface ChatListLoadMoreProps {
|
|
260
|
+
children?: ReactNode;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function ChatListLoadMore({ children }: ChatListLoadMoreProps) {
|
|
264
|
+
const { loadMoreContentRef, bumpLoadMore } = useChatListContext();
|
|
265
|
+
|
|
266
|
+
loadMoreContentRef.current = children ?? null;
|
|
267
|
+
|
|
268
|
+
useLayoutEffect(() => {
|
|
269
|
+
bumpLoadMore();
|
|
270
|
+
|
|
271
|
+
return () => {
|
|
272
|
+
loadMoreContentRef.current = null;
|
|
273
|
+
bumpLoadMore();
|
|
274
|
+
};
|
|
275
|
+
}, [bumpLoadMore, loadMoreContentRef]);
|
|
276
|
+
|
|
277
|
+
return null;
|
|
278
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export {
|
|
2
|
+
useChatListContext,
|
|
3
|
+
ChatList,
|
|
4
|
+
ChatListSkeleton,
|
|
5
|
+
ChatListEmptyState,
|
|
6
|
+
ChatListError,
|
|
7
|
+
ChatListLoadMore,
|
|
8
|
+
type ChatListProps,
|
|
9
|
+
type ChatListSkeletonProps,
|
|
10
|
+
type ChatListEmptyStateProps,
|
|
11
|
+
type ChatListErrorProps,
|
|
12
|
+
type ChatListLoadMoreProps,
|
|
13
|
+
type ChatListContextValue,
|
|
14
|
+
} from './chat-list';
|
|
15
|
+
|
|
16
|
+
export { ChatListItems, type ChatListItemsProps } from './chat-list-items';
|
|
17
|
+
|
|
18
|
+
export { ChatListItem, type ChatListItemProps } from './chat-list-item';
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-message",
|
|
4
|
+
"purpose": "One message in a chat conversation: the user's question as an end-aligned bubble, or the assistant's answer at full width, with its parts ChatMessageContent (the message body) and ChatMessageActions (a hover-revealed row under it).",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Rendering a user question or an assistant answer inside a chat thread",
|
|
7
|
+
"Stacking an answer's parts in order: ChatThinkingProcess, one or more ChatMessageContent blocks, then ChatMessageActions with a ChatMessageToolbar",
|
|
8
|
+
"Showing an agent transcript turn, where tool-call blocks and Markdown text alternate inside one answer message"
|
|
9
|
+
],
|
|
10
|
+
"avoidWhen": [
|
|
11
|
+
"Laying out a structured result (table, list of entities, form) — put web-chat-ui/chat-card items in a web-chat-ui/chat-card-container inside the answer's ChatMessageContent instead of styling the bubble",
|
|
12
|
+
"Notifications outside the conversation — use web-chat-ui/chat-notification-card",
|
|
13
|
+
"Follow-up questions the user can pick — use web-chat-ui/chat-suggestion",
|
|
14
|
+
"Scrolling a conversation — ChatMessage has no scroll behaviour; place it in web-chat-ui/chat-thread"
|
|
15
|
+
],
|
|
16
|
+
"uxPrinciples": [
|
|
17
|
+
"The bubble marks who is speaking: only the user's question gets a filled bubble; the answer reads as page content at full width",
|
|
18
|
+
"Secondary actions stay out of the way: ChatMessageActions is hidden until the message is hovered on desktop, so the conversation reads cleanly"
|
|
19
|
+
],
|
|
20
|
+
"accessibility": {
|
|
21
|
+
"required": [
|
|
22
|
+
"Render the message inside a conversation container that announces new messages (web-chat-ui/chat-thread or a role=log list); ChatMessage itself sets no role",
|
|
23
|
+
"Give every icon-only action inside ChatMessageActions an aria-label",
|
|
24
|
+
"Convey who wrote the message through context (thread order, question/answer wrappers) and not only through the bubble styling"
|
|
25
|
+
],
|
|
26
|
+
"keyboard": [
|
|
27
|
+
"No keyboard handling of its own; buttons and links inside follow their own keyboard behaviour"
|
|
28
|
+
],
|
|
29
|
+
"aria": [
|
|
30
|
+
"No ARIA roles or attributes are set on ChatMessage, ChatMessageContent or ChatMessageActions"
|
|
31
|
+
],
|
|
32
|
+
"focus": [
|
|
33
|
+
"Not focusable",
|
|
34
|
+
"ChatMessageActions is hidden with opacity only, so its buttons stay in the tab order on desktop while invisible; it becomes visible on hover of the message, not on keyboard focus"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"behaviour": {
|
|
38
|
+
"states": ["question", "answer", "actions hidden", "actions visible (hover)"],
|
|
39
|
+
"rules": [
|
|
40
|
+
"isQuestion=true end-aligns the message and turns each ChatMessageContent into a padded, rounded, filled bubble; isQuestion false keeps the content start-aligned with no bubble",
|
|
41
|
+
"Children stack vertically with an 8px gap; pass a className such as gap-12 to change it",
|
|
42
|
+
"ChatMessageContent sizes to its content (w-fit) and keeps a minimum width on small screens",
|
|
43
|
+
"ChatMessageActions is fully visible below the md breakpoint and fades in on hover of its ChatMessage from md up",
|
|
44
|
+
"ChatMessageContent takes plain text, a web-chat-ui/markdown-viewer or a web-chat-ui/chat-card-container; ChatMessageActions takes a web-chat-ui/chat-message-toolbar or other controls",
|
|
45
|
+
"The parts read the question state from the parent ChatMessage through a group selector, so ChatMessageContent and ChatMessageActions only work inside a ChatMessage"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"composition": {
|
|
49
|
+
"allowedParents": [
|
|
50
|
+
"web-chat-ui/ChatThreadQuestion",
|
|
51
|
+
"web-chat-ui/ChatThreadAnswer",
|
|
52
|
+
"web-chat-ui/ChatMessageListGroup"
|
|
53
|
+
],
|
|
54
|
+
"allowedChildren": [
|
|
55
|
+
"web-chat-ui/ChatMessageContent",
|
|
56
|
+
"web-chat-ui/ChatMessageActions",
|
|
57
|
+
"web-chat-ui/chat-thinking-process",
|
|
58
|
+
"web-chat-ui/chat-message-attachment-card"
|
|
59
|
+
],
|
|
60
|
+
"avoidCombinations": [
|
|
61
|
+
"ChatMessageContent or ChatMessageActions outside a ChatMessage — the bubble and hover styles depend on the parent",
|
|
62
|
+
"A ChatMessageToolbar on an answer that is still streaming — render ChatMessageActions only once the reply has finished",
|
|
63
|
+
"A ChatMessage nested in another ChatMessage — each message is one question or one answer"
|
|
64
|
+
],
|
|
65
|
+
"contexts": ["chat thread", "agent transcript", "assistant side panel"]
|
|
66
|
+
},
|
|
67
|
+
"content": {
|
|
68
|
+
"labelRules": [
|
|
69
|
+
"A question shows the user's text exactly as sent",
|
|
70
|
+
"Render an answer's Markdown with web-chat-ui/markdown-viewer inside ChatMessageContent rather than pre-formatted HTML"
|
|
71
|
+
],
|
|
72
|
+
"helperTextRules": [],
|
|
73
|
+
"errorRules": []
|
|
74
|
+
},
|
|
75
|
+
"aiDecisionRules": [
|
|
76
|
+
{
|
|
77
|
+
"condition": "The message is what the user sent",
|
|
78
|
+
"decision": "Set isQuestion and wrap the text in ChatMessageContent",
|
|
79
|
+
"reason": "isQuestion is what end-aligns the message and draws the bubble"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"condition": "The assistant's answer has tool steps, a reply and actions",
|
|
83
|
+
"decision": "Order the children ChatThinkingProcess, ChatMessageContent with a MarkdownViewer, then ChatMessageActions holding a ChatMessageToolbar",
|
|
84
|
+
"reason": "This is the anatomy the Chatbot overview documents and the panel examples render"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"condition": "The answer is still streaming",
|
|
88
|
+
"decision": "Leave out ChatMessageActions until streaming ends",
|
|
89
|
+
"reason": "The composition rules keep the answer's toolbar hidden while the reply arrives"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"relatedComponents": [
|
|
93
|
+
"web-chat-ui/chat-thread",
|
|
94
|
+
"web-chat-ui/chat-message-toolbar",
|
|
95
|
+
"web-chat-ui/markdown-viewer",
|
|
96
|
+
"web-chat-ui/chat-thinking-process",
|
|
97
|
+
"web-chat-ui/chat-message-response",
|
|
98
|
+
"web-chat-ui/chat-card"
|
|
99
|
+
],
|
|
100
|
+
"tokenReferences": {
|
|
101
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
102
|
+
"categories": ["spacing (gap-8, p-16)", "min-w-message-mobile-min"],
|
|
103
|
+
"rule": "The question bubble's background (#22283499) and 20px radius are hard-coded in ChatMessageContent; don't copy them into other components — use theme tokens."
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { ChatMessage, ChatMessageContent, ChatMessageActions } from './chat-message';
|
|
4
|
+
|
|
5
|
+
const meta: Meta<typeof ChatMessage> = {
|
|
6
|
+
title: 'Chatbot/ChatMessage',
|
|
7
|
+
component: ChatMessage,
|
|
8
|
+
parameters: { layout: 'padded' },
|
|
9
|
+
tags: ['autodocs'],
|
|
10
|
+
decorators: [
|
|
11
|
+
(Story) => (
|
|
12
|
+
<div className="w-[700px]">
|
|
13
|
+
<Story />
|
|
14
|
+
</div>
|
|
15
|
+
),
|
|
16
|
+
],
|
|
17
|
+
argTypes: {
|
|
18
|
+
isQuestion: {
|
|
19
|
+
control: 'boolean',
|
|
20
|
+
description:
|
|
21
|
+
"Marks the message as the user's question: right-aligns it and renders its `ChatMessageContent` as a filled bubble.",
|
|
22
|
+
table: { defaultValue: { summary: 'false' } },
|
|
23
|
+
},
|
|
24
|
+
children: {
|
|
25
|
+
control: false,
|
|
26
|
+
description:
|
|
27
|
+
'The message parts, usually a `ChatMessageContent` followed by optional `ChatMessageActions`.',
|
|
28
|
+
},
|
|
29
|
+
className: {
|
|
30
|
+
control: 'text',
|
|
31
|
+
description: 'Extra classes merged onto the root.',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
args: {
|
|
35
|
+
isQuestion: false,
|
|
36
|
+
children: <ChatMessageContent>What are my recent transactions?</ChatMessageContent>,
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
export default meta;
|
|
41
|
+
type Story = StoryObj<typeof ChatMessage>;
|
|
42
|
+
|
|
43
|
+
export const Question: Story = {
|
|
44
|
+
render: () => (
|
|
45
|
+
<ChatMessage isQuestion>
|
|
46
|
+
<ChatMessageContent>Hello, how can I help you today?</ChatMessageContent>
|
|
47
|
+
</ChatMessage>
|
|
48
|
+
),
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const Answer: Story = {
|
|
52
|
+
render: () => (
|
|
53
|
+
<ChatMessage>
|
|
54
|
+
<ChatMessageContent>Hello, how can I help you today?</ChatMessageContent>
|
|
55
|
+
</ChatMessage>
|
|
56
|
+
),
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const WithActions: Story = {
|
|
60
|
+
render: () => (
|
|
61
|
+
<ChatMessage>
|
|
62
|
+
<ChatMessageContent>Hello, how can I help you today?</ChatMessageContent>
|
|
63
|
+
<ChatMessageActions>
|
|
64
|
+
<button type="button">Copy</button>
|
|
65
|
+
</ChatMessageActions>
|
|
66
|
+
</ChatMessage>
|
|
67
|
+
),
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const History: Story = {
|
|
71
|
+
render: () => (
|
|
72
|
+
<div className="flex flex-col gap-8">
|
|
73
|
+
<ChatMessage isQuestion>
|
|
74
|
+
<ChatMessageContent>What are my recent transactions?</ChatMessageContent>
|
|
75
|
+
</ChatMessage>
|
|
76
|
+
<ChatMessage>
|
|
77
|
+
<ChatMessageContent>Here is the history of your transactions</ChatMessageContent>
|
|
78
|
+
</ChatMessage>
|
|
79
|
+
</div>
|
|
80
|
+
),
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
export const LongMessage: Story = {
|
|
84
|
+
render: () => (
|
|
85
|
+
<ChatMessage isQuestion>
|
|
86
|
+
<ChatMessageContent>
|
|
87
|
+
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut
|
|
88
|
+
labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco
|
|
89
|
+
laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in
|
|
90
|
+
voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat
|
|
91
|
+
cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
|
|
92
|
+
</ChatMessageContent>
|
|
93
|
+
</ChatMessage>
|
|
94
|
+
),
|
|
95
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { cn } from '@swisper.ai/web-core';
|
|
4
|
+
|
|
5
|
+
export interface ChatMessageProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
className?: string;
|
|
8
|
+
isQuestion?: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function ChatMessage({ children, className, isQuestion }: ChatMessageProps) {
|
|
12
|
+
return (
|
|
13
|
+
<div
|
|
14
|
+
data-question={isQuestion}
|
|
15
|
+
className={cn(
|
|
16
|
+
'group/message',
|
|
17
|
+
'flex flex-col',
|
|
18
|
+
'data-[question=true]:items-end',
|
|
19
|
+
'gap-8',
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</div>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ChatMessageContentProps {
|
|
29
|
+
children: React.ReactNode;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function ChatMessageContent({ children }: ChatMessageContentProps) {
|
|
33
|
+
return (
|
|
34
|
+
<div
|
|
35
|
+
data-bubble={true}
|
|
36
|
+
className={cn(
|
|
37
|
+
'w-fit',
|
|
38
|
+
'min-w-message-mobile-min md:min-w-auto',
|
|
39
|
+
'group-data-[question=true]/message:data-[bubble=true]:p-16',
|
|
40
|
+
'group-data-[question=true]/message:data-[bubble=true]:rounded-[20px]',
|
|
41
|
+
'group-data-[question=true]/message:data-[bubble=true]:bg-[#22283499]',
|
|
42
|
+
)}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</div>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ChatMessageActionsProps {
|
|
50
|
+
children: React.ReactNode;
|
|
51
|
+
className?: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function ChatMessageActions({ children, className }: ChatMessageActionsProps) {
|
|
55
|
+
return (
|
|
56
|
+
<div
|
|
57
|
+
className={cn(
|
|
58
|
+
'transition-opacity duration-300',
|
|
59
|
+
'md:opacity-0 group-hover/message:opacity-100',
|
|
60
|
+
className,
|
|
61
|
+
)}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</div>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChatMessage, ChatMessageContent, ChatMessageActions } from './chat-message';
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { SvgIconProps } from '@mui/material/SvgIcon';
|
|
2
|
+
import { type FunctionComponent } from 'react';
|
|
3
|
+
|
|
4
|
+
import { PdfIcon, PptIcon, CodeIcon, DocIcon, XlsIcon, DraftIcon } from '@swisper.ai/icons';
|
|
5
|
+
import { cn } from '@swisper.ai/web-core';
|
|
6
|
+
|
|
7
|
+
type IconProps = SvgIconProps;
|
|
8
|
+
|
|
9
|
+
export type ChatMessageAttachmentCardIconType =
|
|
10
|
+
'spreadsheet' | 'pdf' | 'presentation' | 'document' | 'code' | 'image' | 'unknown';
|
|
11
|
+
|
|
12
|
+
const CHAT_ATTACHMENT_ICON_MAP: Record<
|
|
13
|
+
Exclude<ChatMessageAttachmentCardIconType, 'image'>,
|
|
14
|
+
{
|
|
15
|
+
component: FunctionComponent<IconProps>;
|
|
16
|
+
className?: string;
|
|
17
|
+
}
|
|
18
|
+
> = {
|
|
19
|
+
spreadsheet: {
|
|
20
|
+
component: XlsIcon,
|
|
21
|
+
className: 'bg-data-d',
|
|
22
|
+
},
|
|
23
|
+
pdf: {
|
|
24
|
+
component: PdfIcon,
|
|
25
|
+
className: 'bg-data-a',
|
|
26
|
+
},
|
|
27
|
+
presentation: {
|
|
28
|
+
component: PptIcon,
|
|
29
|
+
className: 'bg-data-e',
|
|
30
|
+
},
|
|
31
|
+
document: {
|
|
32
|
+
component: DocIcon,
|
|
33
|
+
className: 'bg-data-c',
|
|
34
|
+
},
|
|
35
|
+
code: {
|
|
36
|
+
component: CodeIcon,
|
|
37
|
+
className: 'bg-data-f',
|
|
38
|
+
},
|
|
39
|
+
unknown: {
|
|
40
|
+
component: DraftIcon,
|
|
41
|
+
className: 'bg-data-f',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export interface ChatMessageAttachmentCardIconProps extends IconProps {
|
|
46
|
+
icon: Exclude<ChatMessageAttachmentCardIconType, 'image'>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function ChatMessageAttachmentCardIcon({
|
|
50
|
+
icon,
|
|
51
|
+
className,
|
|
52
|
+
...rest
|
|
53
|
+
}: ChatMessageAttachmentCardIconProps) {
|
|
54
|
+
const { component: Icon, className: iconClassName } = CHAT_ATTACHMENT_ICON_MAP[icon];
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<span
|
|
58
|
+
data-testid="chat-attachment-icon"
|
|
59
|
+
data-icon={icon}
|
|
60
|
+
className={cn(
|
|
61
|
+
'inline-flex items-center justify-center',
|
|
62
|
+
'rounded-[8px]',
|
|
63
|
+
'p-8',
|
|
64
|
+
'size-promptbox-attachment-size-icon-container',
|
|
65
|
+
'text-icon-fill-inverse',
|
|
66
|
+
'[&_svg]:size-[24px]',
|
|
67
|
+
iconClassName,
|
|
68
|
+
className,
|
|
69
|
+
)}
|
|
70
|
+
>
|
|
71
|
+
<Icon {...rest} />
|
|
72
|
+
</span>
|
|
73
|
+
);
|
|
74
|
+
}
|