@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,110 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-message-attachment-card",
|
|
4
|
+
"purpose": "A compact chip for a file attached to a chat prompt or message: a file-type icon (ChatMessageAttachmentCardIcon) or image thumbnail (ChatMessageAttachmentCardPreview), the truncated file name, and a hover remove button (ChatMessageAttachmentCardActions).",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Listing the files a user has attached to the prompt before sending, with a remove action on each",
|
|
7
|
+
"Showing the files that were sent with a question, read-only (isInteractive=false)",
|
|
8
|
+
"Showing an attached image as a small square thumbnail (isPreview with ChatMessageAttachmentCardPreview)"
|
|
9
|
+
],
|
|
10
|
+
"avoidWhen": [
|
|
11
|
+
"Opening or reading a file's contents — use web-file-preview/file-preview",
|
|
12
|
+
"A tile that shows a picture of the file itself (a PDF's first page, a sheet) — use web-file-preview/file-thumbnail",
|
|
13
|
+
"Listing documents as results of an answer, with metadata and actions — use a web-chat-ui/chat-card"
|
|
14
|
+
],
|
|
15
|
+
"uxPrinciples": [
|
|
16
|
+
"Recognise the file at a glance: a coloured file-type icon plus the file name, truncated rather than wrapped",
|
|
17
|
+
"Removing is only offered while the attachment can still change; a sent message's attachments are read-only"
|
|
18
|
+
],
|
|
19
|
+
"accessibility": {
|
|
20
|
+
"required": [
|
|
21
|
+
"The remove button has no accessible name and ChatMessageAttachmentCardActions does not accept one; an accessible remove action needs a change to the component",
|
|
22
|
+
"The remove button is display:none until the card is hovered, so keyboard and touch users cannot reach it; offer another way to remove the attachment",
|
|
23
|
+
"ChatMessageAttachmentCardPreview's image always has alt=\"Preview\"; show the file name elsewhere when the name matters"
|
|
24
|
+
],
|
|
25
|
+
"keyboard": [
|
|
26
|
+
"The card itself is not focusable and has no keyboard handling",
|
|
27
|
+
"The remove button can only be tabbed to while the pointer hovers the card"
|
|
28
|
+
],
|
|
29
|
+
"aria": [
|
|
30
|
+
"The card and the actions wrapper both set role=group without an accessible name",
|
|
31
|
+
"The file-type icon sets no role or label; the file name in ChatMessageAttachmentCardTitle is the only text"
|
|
32
|
+
],
|
|
33
|
+
"focus": [
|
|
34
|
+
"No focus management; the remove button uses ui/icon-button's focus ring when visible"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"behaviour": {
|
|
38
|
+
"states": ["default", "hover", "non-interactive", "preview"],
|
|
39
|
+
"rules": [
|
|
40
|
+
"isInteractive=true (the default) shows a pointer cursor and a hover background, and reveals the remove button on hover; false makes the card static and never shows the remove button",
|
|
41
|
+
"isPreview=true shrinks the card to a 56px square for an image; ChatMessageAttachmentCardPreview then covers the whole card with the image (object-cover)",
|
|
42
|
+
"ChatMessageAttachmentCardActions renders a single remove (close) icon button pinned over the card's top-right corner and calls onDelete when it is clicked",
|
|
43
|
+
"ChatMessageAttachmentCardTitle truncates a long file name to one line; ChatMessageAttachmentCardContent takes the remaining width",
|
|
44
|
+
"ChatMessageAttachmentCardIcon shows a fixed icon and background colour per file type: spreadsheet, pdf, presentation, document, code, or unknown (draft icon)",
|
|
45
|
+
"getAttachmentIcon(file) picks the icon type from the file name's extension: known office, PDF, CSV and text MIME types map to their type, other text, JavaScript and JSON files to code, anything else to unknown",
|
|
46
|
+
"The card does not read or upload the file; the consumer owns the attachment list and removes the item in onDelete"
|
|
47
|
+
]
|
|
48
|
+
},
|
|
49
|
+
"composition": {
|
|
50
|
+
"allowedParents": ["web-chat-ui/ChatPromptBoxToolbar", "web-chat-ui/chat-message"],
|
|
51
|
+
"allowedChildren": [
|
|
52
|
+
"web-chat-ui/ChatMessageAttachmentCardIcon",
|
|
53
|
+
"web-chat-ui/ChatMessageAttachmentCardPreview",
|
|
54
|
+
"web-chat-ui/ChatMessageAttachmentCardContent",
|
|
55
|
+
"web-chat-ui/ChatMessageAttachmentCardTitle",
|
|
56
|
+
"web-chat-ui/ChatMessageAttachmentCardActions"
|
|
57
|
+
],
|
|
58
|
+
"avoidCombinations": [
|
|
59
|
+
"ChatMessageAttachmentCardPreview without isPreview — the image is positioned over the whole card, covering the icon and title",
|
|
60
|
+
"ChatMessageAttachmentCardActions on a card with isInteractive=false — it never shows, so leave it out",
|
|
61
|
+
"ChatMessageAttachmentCardIcon together with ChatMessageAttachmentCardPreview — use one or the other"
|
|
62
|
+
],
|
|
63
|
+
"contexts": ["prompt box attachment row", "sent question's attachments"]
|
|
64
|
+
},
|
|
65
|
+
"content": {
|
|
66
|
+
"labelRules": [
|
|
67
|
+
"ChatMessageAttachmentCardTitle shows the file name as uploaded, including its extension"
|
|
68
|
+
],
|
|
69
|
+
"helperTextRules": [],
|
|
70
|
+
"errorRules": []
|
|
71
|
+
},
|
|
72
|
+
"aiDecisionRules": [
|
|
73
|
+
{
|
|
74
|
+
"condition": "The attachment is still in the prompt and can be removed",
|
|
75
|
+
"decision": "Keep isInteractive (default) and add ChatMessageAttachmentCardActions with onDelete",
|
|
76
|
+
"reason": "The remove button only appears on interactive cards"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"condition": "The attachment belongs to a message that was already sent",
|
|
80
|
+
"decision": "Set isInteractive=false and leave out ChatMessageAttachmentCardActions",
|
|
81
|
+
"reason": "A sent message's attachments can't change"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"condition": "The attachment is an image",
|
|
85
|
+
"decision": "Set isPreview and render ChatMessageAttachmentCardPreview with the image URL instead of an icon and title",
|
|
86
|
+
"reason": "The icon set has no image type; images show as a thumbnail"
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
"condition": "The attachment is any other file",
|
|
90
|
+
"decision": "Render ChatMessageAttachmentCardIcon with icon={getAttachmentIcon(file)} and the file name in ChatMessageAttachmentCardTitle",
|
|
91
|
+
"reason": "getAttachmentIcon maps the file name to the matching icon type"
|
|
92
|
+
}
|
|
93
|
+
],
|
|
94
|
+
"relatedComponents": [
|
|
95
|
+
"web-chat-ui/chat-prompt-box",
|
|
96
|
+
"web-chat-ui/chat-message",
|
|
97
|
+
"web-file-preview/file-preview",
|
|
98
|
+
"web-file-preview/file-thumbnail"
|
|
99
|
+
],
|
|
100
|
+
"tokenReferences": {
|
|
101
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
102
|
+
"categories": [
|
|
103
|
+
"promptbox-attachment-* (background, background-hover, radius, icon container size)",
|
|
104
|
+
"data-a … data-f (file-type icon backgrounds)",
|
|
105
|
+
"overlay-tools-* (remove button wrapper)",
|
|
106
|
+
"icon-fill-inverse"
|
|
107
|
+
],
|
|
108
|
+
"rule": "File-type colours come from the data palette per type; don't pick icon backgrounds by hand."
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
ChatMessageAttachmentCard,
|
|
5
|
+
ChatMessageAttachmentCardActions,
|
|
6
|
+
ChatMessageAttachmentCardContent,
|
|
7
|
+
ChatMessageAttachmentCardPreview,
|
|
8
|
+
ChatMessageAttachmentCardTitle,
|
|
9
|
+
} from './chat-message-attachment-card';
|
|
10
|
+
import {
|
|
11
|
+
ChatMessageAttachmentCardIcon,
|
|
12
|
+
type ChatMessageAttachmentCardIconType,
|
|
13
|
+
} from './chat-message-attachment-card-icon';
|
|
14
|
+
|
|
15
|
+
const meta: Meta<typeof ChatMessageAttachmentCard> = {
|
|
16
|
+
title: 'Chatbot/ChatMessageAttachmentCard',
|
|
17
|
+
component: ChatMessageAttachmentCard,
|
|
18
|
+
tags: ['autodocs'],
|
|
19
|
+
decorators: [
|
|
20
|
+
(Story) => (
|
|
21
|
+
<div className="max-w-[229px]">
|
|
22
|
+
<Story />
|
|
23
|
+
</div>
|
|
24
|
+
),
|
|
25
|
+
],
|
|
26
|
+
args: {
|
|
27
|
+
isPreview: false,
|
|
28
|
+
isInteractive: true,
|
|
29
|
+
},
|
|
30
|
+
argTypes: {
|
|
31
|
+
isPreview: {
|
|
32
|
+
control: 'boolean',
|
|
33
|
+
description:
|
|
34
|
+
'Renders the card as a compact 56px square thumbnail, for an image shown through `ChatMessageAttachmentCardPreview`.',
|
|
35
|
+
table: { defaultValue: { summary: 'false' } },
|
|
36
|
+
},
|
|
37
|
+
isInteractive: {
|
|
38
|
+
control: 'boolean',
|
|
39
|
+
description:
|
|
40
|
+
'Shows the remove action and a hover background on hover. Set false for attachments in a sent message.',
|
|
41
|
+
table: { defaultValue: { summary: 'true' } },
|
|
42
|
+
},
|
|
43
|
+
children: {
|
|
44
|
+
control: false,
|
|
45
|
+
description:
|
|
46
|
+
'The card parts: an icon or `ChatMessageAttachmentCardPreview`, `ChatMessageAttachmentCardContent` with the file name, and `ChatMessageAttachmentCardActions`.',
|
|
47
|
+
table: { disable: true },
|
|
48
|
+
},
|
|
49
|
+
className: {
|
|
50
|
+
control: 'text',
|
|
51
|
+
description: 'Extra classes merged onto the card root.',
|
|
52
|
+
table: { disable: true },
|
|
53
|
+
},
|
|
54
|
+
},
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
export default meta;
|
|
58
|
+
type Story = StoryObj<typeof ChatMessageAttachmentCard>;
|
|
59
|
+
|
|
60
|
+
export const Default: Story = {
|
|
61
|
+
render: (args) => (
|
|
62
|
+
<ChatMessageAttachmentCard {...args}>
|
|
63
|
+
<ChatMessageAttachmentCardIcon icon="document" />
|
|
64
|
+
<ChatMessageAttachmentCardContent>
|
|
65
|
+
<ChatMessageAttachmentCardTitle>
|
|
66
|
+
Long_document_name_with_spaces.pdf
|
|
67
|
+
</ChatMessageAttachmentCardTitle>
|
|
68
|
+
</ChatMessageAttachmentCardContent>
|
|
69
|
+
<ChatMessageAttachmentCardActions />
|
|
70
|
+
</ChatMessageAttachmentCard>
|
|
71
|
+
),
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export const NonInteractive: Story = {
|
|
75
|
+
args: { isInteractive: false },
|
|
76
|
+
render: (args) => (
|
|
77
|
+
<ChatMessageAttachmentCard {...args}>
|
|
78
|
+
<ChatMessageAttachmentCardIcon icon="document" />
|
|
79
|
+
<ChatMessageAttachmentCardContent>
|
|
80
|
+
<ChatMessageAttachmentCardTitle>
|
|
81
|
+
Long_document_name_with_spaces.pdf
|
|
82
|
+
</ChatMessageAttachmentCardTitle>
|
|
83
|
+
</ChatMessageAttachmentCardContent>
|
|
84
|
+
<ChatMessageAttachmentCardActions />
|
|
85
|
+
</ChatMessageAttachmentCard>
|
|
86
|
+
),
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const WithPreview: Story = {
|
|
90
|
+
args: { isPreview: true },
|
|
91
|
+
render: (args) => (
|
|
92
|
+
<ChatMessageAttachmentCard {...args} className="h-[200px]">
|
|
93
|
+
<ChatMessageAttachmentCardPreview previewSrc="https://picsum.photos/420/200" />
|
|
94
|
+
<ChatMessageAttachmentCardActions />
|
|
95
|
+
</ChatMessageAttachmentCard>
|
|
96
|
+
),
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
export const Playground: Story = {
|
|
100
|
+
render: (args) => (
|
|
101
|
+
<ChatMessageAttachmentCard {...args}>
|
|
102
|
+
<ChatMessageAttachmentCardIcon icon="pdf" />
|
|
103
|
+
<ChatMessageAttachmentCardContent>
|
|
104
|
+
<ChatMessageAttachmentCardTitle>document.pdf</ChatMessageAttachmentCardTitle>
|
|
105
|
+
</ChatMessageAttachmentCardContent>
|
|
106
|
+
<ChatMessageAttachmentCardActions />
|
|
107
|
+
</ChatMessageAttachmentCard>
|
|
108
|
+
),
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
export const Icon: Story = {
|
|
112
|
+
render: () => (
|
|
113
|
+
<div className="flex flex-wrap gap-3">
|
|
114
|
+
{(
|
|
115
|
+
[
|
|
116
|
+
'spreadsheet',
|
|
117
|
+
'pdf',
|
|
118
|
+
'presentation',
|
|
119
|
+
'document',
|
|
120
|
+
'code',
|
|
121
|
+
'unknown',
|
|
122
|
+
] satisfies ChatMessageAttachmentCardIconType[]
|
|
123
|
+
).map((icon) => (
|
|
124
|
+
<div key={icon} className="flex flex-col items-center gap-1">
|
|
125
|
+
<ChatMessageAttachmentCardIcon icon={icon} />
|
|
126
|
+
<span className="text-xs text-gray-500">{icon}</span>
|
|
127
|
+
</div>
|
|
128
|
+
))}
|
|
129
|
+
</div>
|
|
130
|
+
),
|
|
131
|
+
};
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { CloseIcon } from '@swisper.ai/icons';
|
|
4
|
+
import { IconButton, Typography } from '@swisper.ai/ui';
|
|
5
|
+
import { cn } from '@swisper.ai/web-core';
|
|
6
|
+
|
|
7
|
+
export interface ChatMessageAttachmentCardProps {
|
|
8
|
+
className?: string;
|
|
9
|
+
children?: ReactNode;
|
|
10
|
+
isPreview?: boolean;
|
|
11
|
+
isInteractive?: boolean;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ChatMessageAttachmentCard({
|
|
15
|
+
className,
|
|
16
|
+
children,
|
|
17
|
+
isPreview,
|
|
18
|
+
isInteractive = true,
|
|
19
|
+
}: ChatMessageAttachmentCardProps) {
|
|
20
|
+
return (
|
|
21
|
+
<div
|
|
22
|
+
role="group"
|
|
23
|
+
data-testid="chat-message-attachment-card"
|
|
24
|
+
data-preview={isPreview}
|
|
25
|
+
data-interactive={isInteractive}
|
|
26
|
+
className={cn(
|
|
27
|
+
'group/chat-message-attachment-card',
|
|
28
|
+
'relative',
|
|
29
|
+
'flex flex-row gap-8',
|
|
30
|
+
'p-8 rounded-promptbox-attachment',
|
|
31
|
+
'bg-promptbox-attachment-background',
|
|
32
|
+
'data-[interactive=true]:cursor-pointer',
|
|
33
|
+
'data-[interactive=true]:hover:bg-[linear-gradient(var(--color-promptbox-attachment-background-hover),var(--color-promptbox-attachment-background-hover)),linear-gradient(var(--color-promptbox-attachment-background),var(--color-promptbox-attachment-background))]',
|
|
34
|
+
'data-[preview=true]:m-px',
|
|
35
|
+
'data-[preview=true]:size-[56px]',
|
|
36
|
+
className,
|
|
37
|
+
)}
|
|
38
|
+
>
|
|
39
|
+
{children}
|
|
40
|
+
</div>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ChatMessageAttachmentCardContentProps {
|
|
45
|
+
className?: string;
|
|
46
|
+
children?: ReactNode;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function ChatMessageAttachmentCardContent({
|
|
50
|
+
className,
|
|
51
|
+
children,
|
|
52
|
+
}: ChatMessageAttachmentCardContentProps) {
|
|
53
|
+
return (
|
|
54
|
+
<div
|
|
55
|
+
data-testid="chat-message-attachment-card-content"
|
|
56
|
+
className={cn('flex-1', 'flex items-center', 'overflow-hidden', className)}
|
|
57
|
+
>
|
|
58
|
+
{children}
|
|
59
|
+
</div>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
interface ChatMessageAttachmentCardTitleProps {
|
|
64
|
+
className?: string;
|
|
65
|
+
children?: ReactNode;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function ChatMessageAttachmentCardTitle({
|
|
69
|
+
className,
|
|
70
|
+
children,
|
|
71
|
+
}: ChatMessageAttachmentCardTitleProps) {
|
|
72
|
+
return (
|
|
73
|
+
<Typography
|
|
74
|
+
variant="body-sm"
|
|
75
|
+
data-testid="chat-message-attachment-card-title"
|
|
76
|
+
className={cn('truncate', className)}
|
|
77
|
+
>
|
|
78
|
+
{children}
|
|
79
|
+
</Typography>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
interface ChatMessageAttachmentCardPreviewProps {
|
|
84
|
+
className?: string;
|
|
85
|
+
previewSrc: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function ChatMessageAttachmentCardPreview({
|
|
89
|
+
className,
|
|
90
|
+
previewSrc,
|
|
91
|
+
}: ChatMessageAttachmentCardPreviewProps) {
|
|
92
|
+
return (
|
|
93
|
+
<figure
|
|
94
|
+
data-testid="chat-message-attachment-card-preview"
|
|
95
|
+
className={cn(
|
|
96
|
+
'absolute top-0 left-0',
|
|
97
|
+
'inset-0 w-full h-full',
|
|
98
|
+
'overflow-hidden rounded-promptbox-attachment',
|
|
99
|
+
'pointer-events-none',
|
|
100
|
+
className,
|
|
101
|
+
)}
|
|
102
|
+
>
|
|
103
|
+
<img src={previewSrc} alt="Preview" className="w-full h-full object-cover" />
|
|
104
|
+
</figure>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface ChatMessageAttachmentCardActionsProps {
|
|
109
|
+
className?: string;
|
|
110
|
+
onDelete?: () => void;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function ChatMessageAttachmentCardActions({
|
|
114
|
+
className,
|
|
115
|
+
onDelete,
|
|
116
|
+
}: ChatMessageAttachmentCardActionsProps) {
|
|
117
|
+
return (
|
|
118
|
+
<div
|
|
119
|
+
role="group"
|
|
120
|
+
data-testid="chat-message-attachment-card-actions"
|
|
121
|
+
className={cn(
|
|
122
|
+
'absolute top-0 right-0',
|
|
123
|
+
'translate-x-1/2 -translate-y-1/2',
|
|
124
|
+
'hidden',
|
|
125
|
+
'group-data-[interactive=true]/chat-message-attachment-card:group-hover/chat-message-attachment-card:flex',
|
|
126
|
+
'rounded-overlay-tools-wrapper',
|
|
127
|
+
'bg-overlay-tools-background-base',
|
|
128
|
+
className,
|
|
129
|
+
)}
|
|
130
|
+
>
|
|
131
|
+
<IconButton
|
|
132
|
+
variant="tertiary"
|
|
133
|
+
isSemantic={false}
|
|
134
|
+
onClick={onDelete}
|
|
135
|
+
size="xs"
|
|
136
|
+
className={cn('size-[24px]', 'text-icon-button-tertiary-icon', className)}
|
|
137
|
+
>
|
|
138
|
+
<CloseIcon />
|
|
139
|
+
</IconButton>
|
|
140
|
+
</div>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export {
|
|
2
|
+
ChatMessageAttachmentCard,
|
|
3
|
+
ChatMessageAttachmentCardContent,
|
|
4
|
+
ChatMessageAttachmentCardTitle,
|
|
5
|
+
ChatMessageAttachmentCardPreview,
|
|
6
|
+
ChatMessageAttachmentCardActions,
|
|
7
|
+
} from './chat-message-attachment-card';
|
|
8
|
+
export {
|
|
9
|
+
ChatMessageAttachmentCardIcon,
|
|
10
|
+
type ChatMessageAttachmentCardIconType,
|
|
11
|
+
} from './chat-message-attachment-card-icon';
|
|
12
|
+
export { getAttachmentIcon } from './utils';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import mime from 'mime';
|
|
2
|
+
|
|
3
|
+
import type { ChatMessageAttachmentCardIconType } from './chat-message-attachment-card-icon';
|
|
4
|
+
|
|
5
|
+
type IconType = Exclude<ChatMessageAttachmentCardIconType, 'image'>;
|
|
6
|
+
|
|
7
|
+
const MIME_TO_ICON: Record<string, IconType> = {
|
|
8
|
+
'application/pdf': 'pdf',
|
|
9
|
+
'application/vnd.ms-excel': 'spreadsheet',
|
|
10
|
+
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet': 'spreadsheet',
|
|
11
|
+
'text/csv': 'spreadsheet',
|
|
12
|
+
'application/vnd.ms-powerpoint': 'presentation',
|
|
13
|
+
'application/vnd.openxmlformats-officedocument.presentationml.presentation': 'presentation',
|
|
14
|
+
'application/msword': 'document',
|
|
15
|
+
'application/vnd.openxmlformats-officedocument.wordprocessingml.document': 'document',
|
|
16
|
+
'text/plain': 'document',
|
|
17
|
+
'application/rtf': 'document',
|
|
18
|
+
'application/vnd.oasis.opendocument.text': 'document',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export function getAttachmentIcon(file: File): IconType {
|
|
22
|
+
const mimeType = mime.getType(file.name);
|
|
23
|
+
|
|
24
|
+
if (!mimeType) {
|
|
25
|
+
return 'unknown';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (mimeType in MIME_TO_ICON) {
|
|
29
|
+
return MIME_TO_ICON[mimeType];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
mimeType.startsWith('text/') ||
|
|
34
|
+
mimeType.includes('javascript') ||
|
|
35
|
+
mimeType.includes('json')
|
|
36
|
+
) {
|
|
37
|
+
return 'code';
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return 'unknown';
|
|
41
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-message-history",
|
|
4
|
+
"purpose": "A scroll container for a chat conversation that sticks to the bottom: it opens at the latest message, follows new content while the reader is at the end, and shows a scroll-to-latest button (ChatMessageHistoryScrollButton) once they scroll up.",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Maintaining an existing screen already built on ChatMessageHistory and ChatMessageHistoryList",
|
|
7
|
+
"A simple log-style message list that should always stick to the newest message at the bottom, without anchoring questions at the top"
|
|
8
|
+
],
|
|
9
|
+
"avoidWhen": [
|
|
10
|
+
"Building a new question-and-answer chat or agent transcript — use web-chat-ui/chat-thread, which anchors new questions and supports a follow mode",
|
|
11
|
+
"Inside a web-chat-ui/chat-thread or another scroller — the composition rules allow one scroller per conversation",
|
|
12
|
+
"Scrolling generic page content — use ui/scroll-area"
|
|
13
|
+
],
|
|
14
|
+
"uxPrinciples": [
|
|
15
|
+
"The newest message is where the reader is: open at the end and stay there while content arrives",
|
|
16
|
+
"Never pull the reader back while they read history; offer a scroll-to-latest button instead"
|
|
17
|
+
],
|
|
18
|
+
"accessibility": {
|
|
19
|
+
"required": [
|
|
20
|
+
"Wrap each message in an <li> inside ChatMessageHistoryList, which renders a <ul>",
|
|
21
|
+
"Pass tooltip to ChatMessageHistoryScrollButton: it is the button's aria-label as well as its tooltip",
|
|
22
|
+
"Render inside a ui/TooltipProvider: the scroll button always renders a ui/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; keyboard users reach the end by scrolling"
|
|
27
|
+
],
|
|
28
|
+
"aria": [
|
|
29
|
+
"ChatMessageHistoryList is a role=log list labelled \"Message list\" with aria-atomic=false, so assistive technology announces appended messages",
|
|
30
|
+
"The root carries aria-label=\"Chat message history\" but no role",
|
|
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 bottom", "scrolled up (scroll button visible)", "loading", "error", "empty"],
|
|
38
|
+
"rules": [
|
|
39
|
+
"On mount the view jumps to the bottom instantly; when content grows while the reader is at the bottom it stays pinned to the bottom",
|
|
40
|
+
"Once the reader scrolls up, new content no longer moves the view and ChatMessageHistoryScrollButton fades in; clicking it scrolls to the last message",
|
|
41
|
+
"totalMessages only decides emptiness: 0 marks the history empty (data-empty); it does not drive scrolling",
|
|
42
|
+
"isLoading and hasError are reflected as data attributes and shared through context with ChatMessageHistoryEmptyState and ChatMessageHistoryErrorState",
|
|
43
|
+
"ChatMessageHistoryEmptyState renders only while isLoading or hasError is true, and ChatMessageHistoryErrorState renders whenever there is no error or while loading; their conditions don't match their names, so check them before relying on either",
|
|
44
|
+
"The scrollbar is a custom overlay that appears on hover of the scroll area",
|
|
45
|
+
"useChatMessageHistoryContext exposes isCurrentScrollBottom, isLoading, isEmpty, hasError and scrollToLastMessage to custom parts inside the history"
|
|
46
|
+
]
|
|
47
|
+
},
|
|
48
|
+
"composition": {
|
|
49
|
+
"allowedParents": ["web-chat-ui/CanvasShellContent"],
|
|
50
|
+
"allowedChildren": [
|
|
51
|
+
"web-chat-ui/ChatMessageHistoryList",
|
|
52
|
+
"web-chat-ui/ChatMessageHistoryScrollButton",
|
|
53
|
+
"web-chat-ui/ChatMessageHistoryEmptyState",
|
|
54
|
+
"web-chat-ui/ChatMessageHistoryErrorState"
|
|
55
|
+
],
|
|
56
|
+
"avoidCombinations": [
|
|
57
|
+
"Nesting it in web-chat-ui/chat-thread or web-chat-ui/chat-messages — two scrollers fight over the scroll position",
|
|
58
|
+
"Mixing its parts with ChatMessages or ChatThread parts — each reads its own context"
|
|
59
|
+
],
|
|
60
|
+
"contexts": ["assistant side panel", "full-page chat"]
|
|
61
|
+
},
|
|
62
|
+
"content": {
|
|
63
|
+
"labelRules": [
|
|
64
|
+
"Scroll button tooltip: short and about the destination, e.g. \"Scroll to latest message\""
|
|
65
|
+
],
|
|
66
|
+
"helperTextRules": [],
|
|
67
|
+
"errorRules": [
|
|
68
|
+
"ChatMessageHistoryErrorState shows its children, or else the error's message, or \"An error occurred\"; pass a message that says what failed and what to do"
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"aiDecisionRules": [
|
|
72
|
+
{
|
|
73
|
+
"condition": "Starting a new chat or agent UI",
|
|
74
|
+
"decision": "Use web-chat-ui/chat-thread with ChatThreadProvider instead of ChatMessageHistory",
|
|
75
|
+
"reason": "The Chatbot overview builds the conversation on ChatThread, which owns scrolling, anchors new questions and offers a follow mode"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"condition": "Keeping ChatMessageHistory in an existing screen",
|
|
79
|
+
"decision": "Give it a height (className=\"h-full\" in a sized parent), put messages in ChatMessageHistoryList as <li> items and add a ChatMessageHistoryScrollButton with a tooltip",
|
|
80
|
+
"reason": "It only scrolls with a bounded height, and the button's tooltip is also its accessible name"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"condition": "The history needs a loading, empty or error view",
|
|
84
|
+
"decision": "Render it yourself from isLoading, hasError and totalMessages, or use web-chat-ui/ChatThreadErrorState in a ChatThread",
|
|
85
|
+
"reason": "ChatMessageHistoryEmptyState and ChatMessageHistoryErrorState show under conditions that don't match their names"
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"relatedComponents": [
|
|
89
|
+
"web-chat-ui/chat-thread",
|
|
90
|
+
"web-chat-ui/chat-messages",
|
|
91
|
+
"web-chat-ui/chat-message",
|
|
92
|
+
"ui/scroll-area"
|
|
93
|
+
],
|
|
94
|
+
"tokenReferences": {
|
|
95
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
96
|
+
"categories": ["scrollbar-* (track, thumb, width)", "bg-paper-elevation-2 (scroll button)"],
|
|
97
|
+
"rule": "The scrollbar takes its colours and sizes from the scrollbar tokens; don't restyle it per screen."
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { TooltipProvider } from '@swisper.ai/ui';
|
|
5
|
+
|
|
6
|
+
import { ChatMessage, ChatMessageContent } from '../chat-message/chat-message';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
ChatMessageHistory,
|
|
10
|
+
ChatMessageHistoryList,
|
|
11
|
+
ChatMessageHistoryScrollButton,
|
|
12
|
+
} from './chat-message-history';
|
|
13
|
+
|
|
14
|
+
const initialMessages = [
|
|
15
|
+
{ isQuestion: true, text: 'What are my recent transactions?' },
|
|
16
|
+
{ isQuestion: false, text: 'Here is the history of your recent transactions.' },
|
|
17
|
+
{ isQuestion: true, text: 'Can you show the largest one?' },
|
|
18
|
+
{
|
|
19
|
+
isQuestion: false,
|
|
20
|
+
text: 'Your largest transaction this month was $1,240.50 at Acme Corp on May 12.',
|
|
21
|
+
},
|
|
22
|
+
{ isQuestion: true, text: 'How does that compare to last month?' },
|
|
23
|
+
{
|
|
24
|
+
isQuestion: false,
|
|
25
|
+
text: 'Last month your largest transaction was $980.20, so spending is up about 27% on your top purchase.',
|
|
26
|
+
},
|
|
27
|
+
{ isQuestion: true, text: 'Break down my spending by category this month.' },
|
|
28
|
+
{
|
|
29
|
+
isQuestion: false,
|
|
30
|
+
text: 'Sure. Groceries: $412.30, Dining: $286.15, Transport: $154.00, Subscriptions: $89.99, Other: $298.06.',
|
|
31
|
+
},
|
|
32
|
+
{ isQuestion: true, text: 'Which subscriptions am I paying for?' },
|
|
33
|
+
{
|
|
34
|
+
isQuestion: false,
|
|
35
|
+
text: 'You have four active subscriptions: StreamPlus ($14.99), Cloud Storage ($2.99), Fitness App ($29.99), and News Daily ($41.02).',
|
|
36
|
+
},
|
|
37
|
+
{ isQuestion: true, text: 'Can I set a budget alert for dining?' },
|
|
38
|
+
{
|
|
39
|
+
isQuestion: false,
|
|
40
|
+
text: 'Yes. I can notify you when dining spending reaches a limit you choose. What monthly cap would you like?',
|
|
41
|
+
},
|
|
42
|
+
{ isQuestion: true, text: 'Set it to $300.' },
|
|
43
|
+
{
|
|
44
|
+
isQuestion: false,
|
|
45
|
+
text: 'Done. You will get an alert when dining spending hits $300 this month. You are currently at $286.15.',
|
|
46
|
+
},
|
|
47
|
+
{ isQuestion: true, text: 'Show pending transactions too.' },
|
|
48
|
+
{
|
|
49
|
+
isQuestion: false,
|
|
50
|
+
text: 'You have two pending charges: $45.00 at City Parking (May 23) and $12.50 at Metro Coffee (May 24).',
|
|
51
|
+
},
|
|
52
|
+
{ isQuestion: true, text: 'Thanks!' },
|
|
53
|
+
{ isQuestion: false, text: 'You are welcome. Let me know if you need anything else.' },
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
const meta: Meta<typeof ChatMessageHistory> = {
|
|
57
|
+
title: 'Chatbot/ChatMessageHistory',
|
|
58
|
+
component: ChatMessageHistory,
|
|
59
|
+
parameters: { layout: 'padded' },
|
|
60
|
+
tags: ['autodocs'],
|
|
61
|
+
decorators: [
|
|
62
|
+
(Story) => (
|
|
63
|
+
<TooltipProvider>
|
|
64
|
+
<Story />
|
|
65
|
+
</TooltipProvider>
|
|
66
|
+
),
|
|
67
|
+
(Story) => (
|
|
68
|
+
<div className="relative h-[480px] w-[700px] bg-paper-1">
|
|
69
|
+
<Story />
|
|
70
|
+
</div>
|
|
71
|
+
),
|
|
72
|
+
],
|
|
73
|
+
argTypes: {
|
|
74
|
+
totalMessages: {
|
|
75
|
+
control: { type: 'number', min: 0 },
|
|
76
|
+
description: 'Number of messages in the thread; `0` marks the history as empty.',
|
|
77
|
+
},
|
|
78
|
+
isLoading: {
|
|
79
|
+
control: 'boolean',
|
|
80
|
+
description: 'Messages are loading; exposed to the empty and error state parts.',
|
|
81
|
+
table: { defaultValue: { summary: 'false' } },
|
|
82
|
+
},
|
|
83
|
+
hasError: {
|
|
84
|
+
control: 'boolean',
|
|
85
|
+
description: 'Loading the messages failed; exposed to the empty and error state parts.',
|
|
86
|
+
table: { defaultValue: { summary: 'false' } },
|
|
87
|
+
},
|
|
88
|
+
children: {
|
|
89
|
+
control: false,
|
|
90
|
+
description:
|
|
91
|
+
'The scrollable content: a `ChatMessageHistoryList` of messages and a `ChatMessageHistoryScrollButton`.',
|
|
92
|
+
},
|
|
93
|
+
className: {
|
|
94
|
+
control: 'text',
|
|
95
|
+
description: 'Extra classes merged onto the root, e.g. `h-full`.',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
args: {
|
|
99
|
+
totalMessages: initialMessages.length,
|
|
100
|
+
isLoading: false,
|
|
101
|
+
hasError: false,
|
|
102
|
+
className: 'h-full',
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default meta;
|
|
107
|
+
type Story = StoryObj<typeof ChatMessageHistory>;
|
|
108
|
+
|
|
109
|
+
export const Default: Story = {
|
|
110
|
+
render: () => {
|
|
111
|
+
const [messages, setMessages] = useState(initialMessages);
|
|
112
|
+
|
|
113
|
+
function handleAddMessage() {
|
|
114
|
+
setMessages([...messages, { isQuestion: true, text: 'What are my recent transactions?' }]);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<>
|
|
119
|
+
<ChatMessageHistory totalMessages={messages.length} className="h-full">
|
|
120
|
+
<ChatMessageHistoryList>
|
|
121
|
+
{messages.map((message, index) => (
|
|
122
|
+
<li key={index}>
|
|
123
|
+
<ChatMessage isQuestion={message.isQuestion}>
|
|
124
|
+
<ChatMessageContent>{message.text}</ChatMessageContent>
|
|
125
|
+
</ChatMessage>
|
|
126
|
+
</li>
|
|
127
|
+
))}
|
|
128
|
+
</ChatMessageHistoryList>
|
|
129
|
+
<ChatMessageHistoryScrollButton tooltip="Scroll to latest message" />
|
|
130
|
+
</ChatMessageHistory>
|
|
131
|
+
|
|
132
|
+
<button onClick={handleAddMessage}>add message</button>
|
|
133
|
+
</>
|
|
134
|
+
);
|
|
135
|
+
},
|
|
136
|
+
};
|