@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,144 @@
|
|
|
1
|
+
import { useVirtualizer } from '@tanstack/react-virtual';
|
|
2
|
+
import { memo, useCallback, useEffect, type ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { ScrollArea } from '@swisper.ai/ui';
|
|
5
|
+
import { cn } from '@swisper.ai/web-core';
|
|
6
|
+
|
|
7
|
+
import { useChatListContext } from './chat-list';
|
|
8
|
+
|
|
9
|
+
const LOAD_MORE_KEY = 'chat-list-load-more';
|
|
10
|
+
|
|
11
|
+
export interface ChatListItemsProps {
|
|
12
|
+
children: (index: number) => ReactNode;
|
|
13
|
+
className?: string;
|
|
14
|
+
listClassName?: string;
|
|
15
|
+
estimateSize?: number;
|
|
16
|
+
overscan?: number;
|
|
17
|
+
gap?: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const ChatListItems = memo(function ChatListItems({
|
|
21
|
+
children,
|
|
22
|
+
className,
|
|
23
|
+
listClassName,
|
|
24
|
+
estimateSize = 54,
|
|
25
|
+
overscan = 6,
|
|
26
|
+
gap = 4,
|
|
27
|
+
}: ChatListItemsProps) {
|
|
28
|
+
const {
|
|
29
|
+
loadedCount,
|
|
30
|
+
hasMore,
|
|
31
|
+
isLoading,
|
|
32
|
+
isLoadingMore,
|
|
33
|
+
onLoadMore,
|
|
34
|
+
getItemKey,
|
|
35
|
+
scrollElementRef,
|
|
36
|
+
setScrollElement,
|
|
37
|
+
loadMoreContentRef,
|
|
38
|
+
loadMoreVersion,
|
|
39
|
+
setSkeletonContainer,
|
|
40
|
+
} = useChatListContext();
|
|
41
|
+
|
|
42
|
+
// Re-read registered sentinel content when ChatListLoadMore mounts/unmounts.
|
|
43
|
+
const loadMoreContent = loadMoreVersion >= 0 ? loadMoreContentRef.current : null;
|
|
44
|
+
|
|
45
|
+
const showSkeleton = isLoading && loadedCount === 0;
|
|
46
|
+
const count = hasMore ? loadedCount + 1 : loadedCount;
|
|
47
|
+
|
|
48
|
+
const getItemKeyStable = useCallback(
|
|
49
|
+
(index: number) => {
|
|
50
|
+
if (index >= loadedCount) {
|
|
51
|
+
return LOAD_MORE_KEY;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return getItemKey(index);
|
|
55
|
+
},
|
|
56
|
+
[getItemKey, loadedCount],
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const virtualizer = useVirtualizer({
|
|
60
|
+
count: showSkeleton ? 0 : count,
|
|
61
|
+
getScrollElement: () => scrollElementRef.current,
|
|
62
|
+
estimateSize: () => estimateSize,
|
|
63
|
+
overscan,
|
|
64
|
+
gap,
|
|
65
|
+
getItemKey: getItemKeyStable,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const virtualItems = virtualizer.getVirtualItems();
|
|
69
|
+
|
|
70
|
+
useEffect(() => {
|
|
71
|
+
if (showSkeleton) {
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
const [lastItem] = [...virtualItems].reverse();
|
|
76
|
+
|
|
77
|
+
if (!lastItem) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (lastItem.index >= loadedCount - 1 && hasMore && !isLoadingMore) {
|
|
82
|
+
onLoadMore?.();
|
|
83
|
+
}
|
|
84
|
+
}, [virtualItems, loadedCount, hasMore, isLoadingMore, onLoadMore, showSkeleton]);
|
|
85
|
+
|
|
86
|
+
// The skeleton sits outside the ScrollArea: Radix wraps the viewport's content in a
|
|
87
|
+
// `display: table` box, where the skeleton could neither fill the list height nor clip to it.
|
|
88
|
+
if (showSkeleton) {
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
ref={setSkeletonContainer}
|
|
92
|
+
data-slot="chat-list-items"
|
|
93
|
+
data-testid="chat-list-items"
|
|
94
|
+
className={cn('flex min-h-0 flex-1 flex-col overflow-hidden', className)}
|
|
95
|
+
/>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return (
|
|
100
|
+
<ScrollArea
|
|
101
|
+
ref={setScrollElement}
|
|
102
|
+
data-slot="chat-list-items"
|
|
103
|
+
data-testid="chat-list-items"
|
|
104
|
+
className={cn('min-h-0 flex-1', 'overflow-auto', className)}
|
|
105
|
+
>
|
|
106
|
+
<ul
|
|
107
|
+
role="list"
|
|
108
|
+
aria-label="Chats"
|
|
109
|
+
className={cn(
|
|
110
|
+
'table relative w-full transform-gpu table-fixed',
|
|
111
|
+
'space-y-[4px]',
|
|
112
|
+
listClassName,
|
|
113
|
+
)}
|
|
114
|
+
style={{
|
|
115
|
+
height: `${virtualizer.getTotalSize()}px`,
|
|
116
|
+
}}
|
|
117
|
+
>
|
|
118
|
+
{virtualItems.map((virtualItem) => {
|
|
119
|
+
const isLoaderRow = virtualItem.index >= loadedCount;
|
|
120
|
+
|
|
121
|
+
return (
|
|
122
|
+
<li
|
|
123
|
+
key={virtualItem.key}
|
|
124
|
+
data-index={virtualItem.index}
|
|
125
|
+
ref={virtualizer.measureElement}
|
|
126
|
+
role={isLoaderRow ? 'status' : 'listitem'}
|
|
127
|
+
aria-live={isLoaderRow ? 'polite' : undefined}
|
|
128
|
+
aria-busy={isLoaderRow ? isLoadingMore : undefined}
|
|
129
|
+
style={{
|
|
130
|
+
position: 'absolute',
|
|
131
|
+
top: 0,
|
|
132
|
+
left: 0,
|
|
133
|
+
width: '100%',
|
|
134
|
+
transform: `translateY(${virtualItem.start}px)`,
|
|
135
|
+
}}
|
|
136
|
+
>
|
|
137
|
+
{isLoaderRow ? loadMoreContent : children(virtualItem.index)}
|
|
138
|
+
</li>
|
|
139
|
+
);
|
|
140
|
+
})}
|
|
141
|
+
</ul>
|
|
142
|
+
</ScrollArea>
|
|
143
|
+
);
|
|
144
|
+
});
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-list",
|
|
4
|
+
"purpose": "Virtualised, paginated list of the user's conversations for a navigation sidebar, with infinite loading and built-in slots for the first-page skeleton, the load-more row, the empty state and the error state.",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"A sidebar or drawer lists past conversations to switch between",
|
|
7
|
+
"The list is long or paginated and loads more pages as the user scrolls",
|
|
8
|
+
"The list needs consistent loading, empty and error states driven by the fetch state"
|
|
9
|
+
],
|
|
10
|
+
"avoidWhen": [
|
|
11
|
+
"Showing the messages of one conversation — use web-chat-ui/chat-thread",
|
|
12
|
+
"A short static list of items or links that does not paginate — use ui/list",
|
|
13
|
+
"Tabular data with columns — use ui/table"
|
|
14
|
+
],
|
|
15
|
+
"uxPrinciples": [
|
|
16
|
+
"Show the selected conversation clearly, so the user knows which chat is open.",
|
|
17
|
+
"Loading never blanks the list: the skeleton holds the first page's place, and later pages load in a row under the loaded chats.",
|
|
18
|
+
"Each row shows a title the user recognises, with a one-line preview at most."
|
|
19
|
+
],
|
|
20
|
+
"accessibility": {
|
|
21
|
+
"required": [
|
|
22
|
+
"Render each ChatListItem asChild over a button or link: it is a plain div with no role, tabIndex or key handling, so a bare item cannot be reached or activated from the keyboard",
|
|
23
|
+
"Give the list an aria-label that names it when the page has more than one navigation landmark (it defaults to \"Chat list\")",
|
|
24
|
+
"Keep the selected row visibly distinct; style it with data-[selected=true]"
|
|
25
|
+
],
|
|
26
|
+
"keyboard": [
|
|
27
|
+
"No keyboard handling of its own: Tab moves through the interactive elements rendered in the rows",
|
|
28
|
+
"The scroll area scrolls with the keyboard once an element inside it is focused"
|
|
29
|
+
],
|
|
30
|
+
"aria": [
|
|
31
|
+
"The root is role=navigation with aria-label (default \"Chat list\"); the rows are a ul with aria-label=\"Chats\" and listitem rows",
|
|
32
|
+
"The load-more row is role=status with aria-live=polite and aria-busy while isLoadingMore",
|
|
33
|
+
"ChatListSkeleton is role=status, aria-busy, aria-label=\"Loading chats\"; its Skeleton rows are aria-hidden",
|
|
34
|
+
"ChatListEmptyState is role=status with aria-live=polite, aria-label=\"No chats\"",
|
|
35
|
+
"ChatListError is role=alert with aria-live=assertive, aria-label=\"Error loading chats\"",
|
|
36
|
+
"isSelected sets aria-selected on the item; on a link, also set aria-current=\"page\" for the open conversation"
|
|
37
|
+
],
|
|
38
|
+
"focus": [
|
|
39
|
+
"The list never moves focus, including when a page loads",
|
|
40
|
+
"Rows are virtualised, so a focused row that scrolls far out of view unmounts; keep selection in state, not in DOM focus"
|
|
41
|
+
]
|
|
42
|
+
},
|
|
43
|
+
"behaviour": {
|
|
44
|
+
"states": ["loading", "loaded", "loading more", "empty", "error", "selected item"],
|
|
45
|
+
"rules": [
|
|
46
|
+
"loadedCount is the number of rows ChatListItems renders; its children is a render function called with each row's index",
|
|
47
|
+
"getItemKey returns a stable key per index (the chat id), so rows keep their identity as pages load",
|
|
48
|
+
"hasMore defaults to loadedCount < totalCount, and to false when totalCount is unknown; pass hasMore when the server only says whether another page exists",
|
|
49
|
+
"While hasMore is true, ChatListItems appends one extra row at the end holding the ChatListLoadMore content",
|
|
50
|
+
"onLoadMore fires when the last rendered row reaches the end of the loaded rows, hasMore is true and isLoadingMore is false; set isLoadingMore as soon as the request starts so it isn't called twice",
|
|
51
|
+
"isLoading with no loaded rows shows ChatListSkeleton in place of the rows; ChatListSkeleton draws into a container that ChatListItems provides, so both must be rendered",
|
|
52
|
+
"ChatListSkeleton renders rows default Skeleton rows (title and preview) unless you pass your own children; rows past the list's height are clipped",
|
|
53
|
+
"ChatListEmptyState shows only when nothing is loaded, nothing is loading and there is no error",
|
|
54
|
+
"ChatListError shows only when hasError is true and no rows are loaded; a failed later page leaves the loaded rows on screen without an error",
|
|
55
|
+
"ChatListError renders children, or else the error's message, or \"An error occurred\"",
|
|
56
|
+
"ChatListLoadMore renders nothing in place; it registers its children as the content of the load-more row",
|
|
57
|
+
"Rows are measured after render, so items may vary in height; estimateSize is only the first guess, and gap is the space between rows"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"composition": {
|
|
61
|
+
"allowedParents": [],
|
|
62
|
+
"allowedChildren": [
|
|
63
|
+
"web-chat-ui/ChatListItems",
|
|
64
|
+
"web-chat-ui/ChatListItem",
|
|
65
|
+
"web-chat-ui/ChatListSkeleton",
|
|
66
|
+
"web-chat-ui/ChatListLoadMore",
|
|
67
|
+
"web-chat-ui/ChatListEmptyState",
|
|
68
|
+
"web-chat-ui/ChatListError"
|
|
69
|
+
],
|
|
70
|
+
"avoidCombinations": [
|
|
71
|
+
"ChatListItem outside ChatListItems' render function — it is only the row content",
|
|
72
|
+
"ChatListSkeleton without ChatListItems — the skeleton has nowhere to render",
|
|
73
|
+
"Wrapping ChatList in another scroll container — ChatListItems scrolls itself; give ChatList a bounded height instead"
|
|
74
|
+
],
|
|
75
|
+
"contexts": ["sidebar", "navigation drawer"]
|
|
76
|
+
},
|
|
77
|
+
"content": {
|
|
78
|
+
"labelRules": [
|
|
79
|
+
"Row title: the conversation's title, truncated to one line",
|
|
80
|
+
"Row preview: the last message, truncated to one line",
|
|
81
|
+
"Empty state: say there are no conversations yet and how to start one, e.g. \"No conversations yet\" / \"Start a new chat to see it here.\""
|
|
82
|
+
],
|
|
83
|
+
"helperTextRules": ["Load-more row: a short progress phrase such as \"Loading more…\""],
|
|
84
|
+
"errorRules": [
|
|
85
|
+
"Say what failed and what to do next, e.g. \"Failed to load chats\" / \"Please try again later.\"; style the headline with text-text-error-main"
|
|
86
|
+
]
|
|
87
|
+
},
|
|
88
|
+
"aiDecisionRules": [
|
|
89
|
+
{
|
|
90
|
+
"condition": "Rows open a conversation by route",
|
|
91
|
+
"decision": "Render ChatListItem asChild over a link, with isSelected and aria-current=\"page\" on the open chat",
|
|
92
|
+
"reason": "A link is keyboard reachable and announces navigation; ChatListItem itself has no role or keyboard handling"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"condition": "The API returns a cursor but no total",
|
|
96
|
+
"decision": "Pass hasMore from the cursor and leave totalCount out",
|
|
97
|
+
"reason": "hasMore falls back to loadedCount < totalCount, which is false when the total is unknown, so pages would never load"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"condition": "Building the list's loading, empty and error UI",
|
|
101
|
+
"decision": "Render ChatListSkeleton, ChatListLoadMore, ChatListEmptyState and ChatListError as children of ChatList and drive them with isLoading, isLoadingMore and hasError",
|
|
102
|
+
"reason": "Each part decides from the list state when to show, with the right live-region role, so the screen never shows two states at once"
|
|
103
|
+
}
|
|
104
|
+
],
|
|
105
|
+
"relatedComponents": [
|
|
106
|
+
"web-chat-ui/NewChatTrigger",
|
|
107
|
+
"web-chat-ui/chat-thread",
|
|
108
|
+
"ui/skeleton",
|
|
109
|
+
"ui/scroll-area",
|
|
110
|
+
"ui/list"
|
|
111
|
+
],
|
|
112
|
+
"tokenReferences": {
|
|
113
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
114
|
+
"categories": ["text-text-primary", "text-text-secondary", "text-text-error-main"],
|
|
115
|
+
"rule": "ChatList does not style rows; style the row element passed to ChatListItem with token classes and data-[selected=true]."
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { fn } from 'storybook/test';
|
|
4
|
+
|
|
5
|
+
import { cn } from '@swisper.ai/web-core';
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
ChatList,
|
|
9
|
+
ChatListEmptyState,
|
|
10
|
+
ChatListError,
|
|
11
|
+
ChatListItem,
|
|
12
|
+
type ChatListItemProps,
|
|
13
|
+
ChatListItems,
|
|
14
|
+
ChatListLoadMore,
|
|
15
|
+
ChatListSkeleton,
|
|
16
|
+
} from './index';
|
|
17
|
+
|
|
18
|
+
interface MockChat {
|
|
19
|
+
id: string;
|
|
20
|
+
title: string;
|
|
21
|
+
preview: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const TOTAL_CHATS = 80;
|
|
25
|
+
const PAGE_SIZE = 20;
|
|
26
|
+
|
|
27
|
+
function createMockChats(count: number, offset = 0): MockChat[] {
|
|
28
|
+
return Array.from({ length: count }, (_, index) => {
|
|
29
|
+
const n = offset + index + 1;
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
id: `chat-${n}`,
|
|
33
|
+
title: `Conversation ${n}`,
|
|
34
|
+
preview: `Last message preview for chat ${n}`,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ListItem({
|
|
40
|
+
chat: { title, preview },
|
|
41
|
+
className,
|
|
42
|
+
...rest
|
|
43
|
+
}: ChatListItemProps & { chat: MockChat; className?: string }) {
|
|
44
|
+
return (
|
|
45
|
+
<div
|
|
46
|
+
className={cn(
|
|
47
|
+
'flex min-w-0 flex-1 flex-col gap-4',
|
|
48
|
+
'rounded-[12px] px-12 py-8',
|
|
49
|
+
'hover:bg-avatar-background-hover',
|
|
50
|
+
'data-[selected=true]:bg-avatar-background',
|
|
51
|
+
className,
|
|
52
|
+
)}
|
|
53
|
+
{...rest}
|
|
54
|
+
>
|
|
55
|
+
<span className="truncate text-sm font-medium text-text-primary">{title}</span>
|
|
56
|
+
<span className="truncate text-xs text-text-secondary">{preview}</span>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const ALL_CHATS = createMockChats(TOTAL_CHATS);
|
|
62
|
+
|
|
63
|
+
function ChatListDemo({
|
|
64
|
+
initialCount = PAGE_SIZE,
|
|
65
|
+
totalCount = TOTAL_CHATS,
|
|
66
|
+
isLoading = false,
|
|
67
|
+
hasError = false,
|
|
68
|
+
selectedId,
|
|
69
|
+
}: {
|
|
70
|
+
initialCount?: number;
|
|
71
|
+
totalCount?: number;
|
|
72
|
+
isLoading?: boolean;
|
|
73
|
+
hasError?: boolean;
|
|
74
|
+
selectedId?: string;
|
|
75
|
+
}) {
|
|
76
|
+
const [chats, setChats] = useState(() => ALL_CHATS.slice(0, initialCount));
|
|
77
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
78
|
+
const [selected, setSelected] = useState(selectedId);
|
|
79
|
+
|
|
80
|
+
const getItemKey = useCallback((index: number) => chats[index].id, [chats]);
|
|
81
|
+
|
|
82
|
+
const handleLoadMore = useCallback(() => {
|
|
83
|
+
if (isLoadingMore || chats.length >= totalCount) {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
setIsLoadingMore(true);
|
|
88
|
+
|
|
89
|
+
window.setTimeout(() => {
|
|
90
|
+
setChats((current) => {
|
|
91
|
+
const next = ALL_CHATS.slice(current.length, current.length + PAGE_SIZE);
|
|
92
|
+
return [...current, ...next];
|
|
93
|
+
});
|
|
94
|
+
setIsLoadingMore(false);
|
|
95
|
+
}, 600);
|
|
96
|
+
}, [chats.length, isLoadingMore, totalCount]);
|
|
97
|
+
|
|
98
|
+
return (
|
|
99
|
+
<ChatList
|
|
100
|
+
className="h-full"
|
|
101
|
+
loadedCount={chats.length}
|
|
102
|
+
totalCount={totalCount}
|
|
103
|
+
isLoading={isLoading}
|
|
104
|
+
isLoadingMore={isLoadingMore}
|
|
105
|
+
hasError={hasError}
|
|
106
|
+
onLoadMore={handleLoadMore}
|
|
107
|
+
getItemKey={getItemKey}
|
|
108
|
+
>
|
|
109
|
+
<ChatListItems>
|
|
110
|
+
{(index) => {
|
|
111
|
+
const chat = chats[index];
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<ChatListItem
|
|
115
|
+
isSelected={selected === chat.id}
|
|
116
|
+
onClick={() => setSelected(chat.id)}
|
|
117
|
+
asChild
|
|
118
|
+
>
|
|
119
|
+
<ListItem chat={chat} />
|
|
120
|
+
</ChatListItem>
|
|
121
|
+
);
|
|
122
|
+
}}
|
|
123
|
+
</ChatListItems>
|
|
124
|
+
|
|
125
|
+
<ChatListSkeleton />
|
|
126
|
+
|
|
127
|
+
<ChatListLoadMore>
|
|
128
|
+
<div className="flex items-center justify-center py-3 text-xs text-text-secondary">
|
|
129
|
+
Loading more…
|
|
130
|
+
</div>
|
|
131
|
+
</ChatListLoadMore>
|
|
132
|
+
|
|
133
|
+
<ChatListEmptyState>
|
|
134
|
+
<div className="flex flex-col items-center gap-2 px-6 text-center">
|
|
135
|
+
<p className="text-sm font-medium text-text-primary">No conversations yet</p>
|
|
136
|
+
<p className="text-xs text-text-secondary">Start a new chat to see it here.</p>
|
|
137
|
+
</div>
|
|
138
|
+
</ChatListEmptyState>
|
|
139
|
+
|
|
140
|
+
<ChatListError>
|
|
141
|
+
<div className="flex flex-col items-center gap-2 px-6 text-center">
|
|
142
|
+
<p className="text-sm font-medium text-text-error-main">Failed to load chats</p>
|
|
143
|
+
<p className="text-xs text-text-secondary">Please try again later.</p>
|
|
144
|
+
</div>
|
|
145
|
+
</ChatListError>
|
|
146
|
+
</ChatList>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const meta: Meta<typeof ChatList> = {
|
|
151
|
+
title: 'Chatbot/ChatList',
|
|
152
|
+
component: ChatList,
|
|
153
|
+
parameters: { layout: 'padded' },
|
|
154
|
+
tags: ['autodocs'],
|
|
155
|
+
decorators: [
|
|
156
|
+
(Story) => (
|
|
157
|
+
<div className="relative h-[480px] w-[320px] overflow-hidden bg-paper-elevation-2">
|
|
158
|
+
<Story />
|
|
159
|
+
</div>
|
|
160
|
+
),
|
|
161
|
+
],
|
|
162
|
+
argTypes: {
|
|
163
|
+
loadedCount: {
|
|
164
|
+
control: { type: 'number', min: 0 },
|
|
165
|
+
description: 'Number of chats already loaded; `ChatListItems` renders this many rows.',
|
|
166
|
+
},
|
|
167
|
+
totalCount: {
|
|
168
|
+
control: { type: 'number', min: 0 },
|
|
169
|
+
description: 'Total chats on the server, when known; used to work out `hasMore`.',
|
|
170
|
+
},
|
|
171
|
+
hasMore: {
|
|
172
|
+
control: 'boolean',
|
|
173
|
+
description:
|
|
174
|
+
'Whether another page can be loaded. Defaults to `loadedCount < totalCount`; pass it when the total is unknown.',
|
|
175
|
+
table: { defaultValue: { summary: 'loadedCount < totalCount' } },
|
|
176
|
+
},
|
|
177
|
+
isLoading: {
|
|
178
|
+
control: 'boolean',
|
|
179
|
+
description: 'First page is loading: shows `ChatListSkeleton` instead of the rows.',
|
|
180
|
+
table: { defaultValue: { summary: 'false' } },
|
|
181
|
+
},
|
|
182
|
+
isLoadingMore: {
|
|
183
|
+
control: 'boolean',
|
|
184
|
+
description: 'The next page is loading: shows `ChatListLoadMore` under the rows.',
|
|
185
|
+
table: { defaultValue: { summary: 'false' } },
|
|
186
|
+
},
|
|
187
|
+
hasError: {
|
|
188
|
+
control: 'boolean',
|
|
189
|
+
description: 'Loading failed: shows `ChatListError` instead of the rows.',
|
|
190
|
+
table: { defaultValue: { summary: 'false' } },
|
|
191
|
+
},
|
|
192
|
+
onLoadMore: {
|
|
193
|
+
description:
|
|
194
|
+
'Called when the user scrolls near the end of the loaded rows and `hasMore` is true.',
|
|
195
|
+
},
|
|
196
|
+
getItemKey: {
|
|
197
|
+
control: false,
|
|
198
|
+
description: 'Returns a stable key for the row at an index, e.g. the chat id.',
|
|
199
|
+
},
|
|
200
|
+
'aria-label': {
|
|
201
|
+
control: 'text',
|
|
202
|
+
description: 'Accessible name of the navigation landmark.',
|
|
203
|
+
table: { defaultValue: { summary: 'Chat list' } },
|
|
204
|
+
},
|
|
205
|
+
children: {
|
|
206
|
+
control: false,
|
|
207
|
+
description:
|
|
208
|
+
'The list parts: `ChatListItems`, `ChatListSkeleton`, `ChatListLoadMore`, `ChatListEmptyState` and `ChatListError`.',
|
|
209
|
+
},
|
|
210
|
+
className: {
|
|
211
|
+
control: 'text',
|
|
212
|
+
description: 'Extra classes merged onto the root.',
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
args: {
|
|
216
|
+
loadedCount: PAGE_SIZE,
|
|
217
|
+
totalCount: TOTAL_CHATS,
|
|
218
|
+
isLoading: false,
|
|
219
|
+
isLoadingMore: false,
|
|
220
|
+
hasError: false,
|
|
221
|
+
onLoadMore: fn(),
|
|
222
|
+
'aria-label': 'Chat list',
|
|
223
|
+
},
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
export default meta;
|
|
227
|
+
type Story = StoryObj<typeof ChatList>;
|
|
228
|
+
|
|
229
|
+
export const Playground: Story = {
|
|
230
|
+
render: () => <ChatListDemo selectedId="chat-1" />,
|
|
231
|
+
};
|
|
232
|
+
|
|
233
|
+
export const Empty: Story = {
|
|
234
|
+
render: () => <ChatListDemo initialCount={0} totalCount={0} />,
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
export const ErrorState: Story = {
|
|
238
|
+
render: () => <ChatListDemo initialCount={0} totalCount={0} hasError />,
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
export const InitialSkeleton: Story = {
|
|
242
|
+
render: () => <ChatListDemo initialCount={0} isLoading />,
|
|
243
|
+
};
|
|
244
|
+
|
|
245
|
+
function ChatListInitialLongLoadDemo({ delayMs = 30_000 }: { delayMs?: number }) {
|
|
246
|
+
const [chats, setChats] = useState<MockChat[]>([]);
|
|
247
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
248
|
+
const [isLoadingMore, setIsLoadingMore] = useState(false);
|
|
249
|
+
const [selected, setSelected] = useState<string>();
|
|
250
|
+
|
|
251
|
+
useEffect(() => {
|
|
252
|
+
const timeoutId = window.setTimeout(() => {
|
|
253
|
+
setChats(ALL_CHATS.slice(0, PAGE_SIZE));
|
|
254
|
+
setIsLoading(false);
|
|
255
|
+
}, delayMs);
|
|
256
|
+
|
|
257
|
+
return () => window.clearTimeout(timeoutId);
|
|
258
|
+
}, [delayMs]);
|
|
259
|
+
|
|
260
|
+
const getItemKey = useCallback((index: number) => chats[index].id, [chats]);
|
|
261
|
+
|
|
262
|
+
const handleLoadMore = useCallback(() => {
|
|
263
|
+
if (isLoadingMore || chats.length >= TOTAL_CHATS) {
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
setIsLoadingMore(true);
|
|
268
|
+
|
|
269
|
+
window.setTimeout(() => {
|
|
270
|
+
setChats((current) => {
|
|
271
|
+
const next = ALL_CHATS.slice(current.length, current.length + PAGE_SIZE);
|
|
272
|
+
return [...current, ...next];
|
|
273
|
+
});
|
|
274
|
+
setIsLoadingMore(false);
|
|
275
|
+
}, 600);
|
|
276
|
+
}, [chats.length, isLoadingMore]);
|
|
277
|
+
|
|
278
|
+
return (
|
|
279
|
+
<ChatList
|
|
280
|
+
className="h-full"
|
|
281
|
+
loadedCount={chats.length}
|
|
282
|
+
totalCount={TOTAL_CHATS}
|
|
283
|
+
isLoading={isLoading}
|
|
284
|
+
isLoadingMore={isLoadingMore}
|
|
285
|
+
onLoadMore={handleLoadMore}
|
|
286
|
+
getItemKey={getItemKey}
|
|
287
|
+
>
|
|
288
|
+
<ChatListItems>
|
|
289
|
+
{(index) => {
|
|
290
|
+
const chat = chats[index];
|
|
291
|
+
|
|
292
|
+
return (
|
|
293
|
+
<ChatListItem
|
|
294
|
+
isSelected={selected === chat.id}
|
|
295
|
+
onClick={() => setSelected(chat.id)}
|
|
296
|
+
asChild
|
|
297
|
+
>
|
|
298
|
+
<ListItem chat={chat} />
|
|
299
|
+
</ChatListItem>
|
|
300
|
+
);
|
|
301
|
+
}}
|
|
302
|
+
</ChatListItems>
|
|
303
|
+
|
|
304
|
+
<ChatListSkeleton />
|
|
305
|
+
|
|
306
|
+
<ChatListLoadMore>
|
|
307
|
+
<div className="flex items-center justify-center py-3 text-xs text-text-secondary">
|
|
308
|
+
Loading more…
|
|
309
|
+
</div>
|
|
310
|
+
</ChatListLoadMore>
|
|
311
|
+
|
|
312
|
+
<ChatListEmptyState>
|
|
313
|
+
<div className="flex flex-col items-center gap-2 px-6 text-center">
|
|
314
|
+
<p className="text-sm font-medium text-text-primary">No conversations yet</p>
|
|
315
|
+
<p className="text-xs text-text-secondary">Start a new chat to see it here.</p>
|
|
316
|
+
</div>
|
|
317
|
+
</ChatListEmptyState>
|
|
318
|
+
</ChatList>
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
export const InitialLongLoad: Story = {
|
|
323
|
+
render: () => <ChatListInitialLongLoadDemo />,
|
|
324
|
+
};
|
|
325
|
+
|
|
326
|
+
export const LoadingMore: Story = {
|
|
327
|
+
render: () => <ChatListDemo initialCount={PAGE_SIZE} totalCount={TOTAL_CHATS} />,
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
export const LongList: Story = {
|
|
331
|
+
render: () => <ChatListDemo initialCount={TOTAL_CHATS} totalCount={TOTAL_CHATS} />,
|
|
332
|
+
};
|