@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,220 @@
|
|
|
1
|
+
import { CodeNode } from '@lexical/code';
|
|
2
|
+
import { LinkNode } from '@lexical/link';
|
|
3
|
+
import { ListItemNode, ListNode } from '@lexical/list';
|
|
4
|
+
import { type InitialConfigType, LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
5
|
+
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
6
|
+
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
7
|
+
import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
|
|
8
|
+
import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
|
|
9
|
+
import { HeadingNode, QuoteNode } from '@lexical/rich-text';
|
|
10
|
+
import { createContext, forwardRef, useContext, useMemo, useState } from 'react';
|
|
11
|
+
import type { CSSProperties, ComponentPropsWithoutRef, KeyboardEvent, ReactNode } from 'react';
|
|
12
|
+
|
|
13
|
+
import { Typography } from '@swisper.ai/ui';
|
|
14
|
+
import { cn } from '@swisper.ai/web-core';
|
|
15
|
+
|
|
16
|
+
import {
|
|
17
|
+
AutoFocusPlugin,
|
|
18
|
+
ControlledValuePlugin,
|
|
19
|
+
DisabledPlugin,
|
|
20
|
+
FocusPlugin,
|
|
21
|
+
HasValuePlugin,
|
|
22
|
+
MarkdownPlainPastePlugin,
|
|
23
|
+
ValuePlugin,
|
|
24
|
+
} from './plugins';
|
|
25
|
+
|
|
26
|
+
export type ChatInputConfig = InitialConfigType;
|
|
27
|
+
|
|
28
|
+
interface ChatInputContextValue {
|
|
29
|
+
isFocused: boolean;
|
|
30
|
+
hasError: boolean;
|
|
31
|
+
hasValue: boolean;
|
|
32
|
+
|
|
33
|
+
setIsFocused: (isFocused: boolean) => void;
|
|
34
|
+
setHasError: (hasError: boolean) => void;
|
|
35
|
+
setHasValue: (hasValue: boolean) => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const ChatInputContext = createContext<ChatInputContextValue>(null!);
|
|
39
|
+
|
|
40
|
+
export function useChatInputContext() {
|
|
41
|
+
const context = useContext(ChatInputContext);
|
|
42
|
+
|
|
43
|
+
if (!context) {
|
|
44
|
+
throw new Error('"useChatInputContext" must be used within a ChatInputContextProvider');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return context;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const DEFAULT_CONFIG: ChatInputConfig = {
|
|
51
|
+
namespace: 'chat-input',
|
|
52
|
+
editable: true,
|
|
53
|
+
nodes: [HeadingNode, QuoteNode, ListNode, ListItemNode, CodeNode, LinkNode],
|
|
54
|
+
theme: {
|
|
55
|
+
paragraph: 'm-0 min-h-[26px]',
|
|
56
|
+
text: {
|
|
57
|
+
bold: 'font-bold',
|
|
58
|
+
italic: 'italic',
|
|
59
|
+
underline: 'underline',
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
onError: (error) => {
|
|
63
|
+
console.error('ChatInput Lexical error:', error);
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export interface ChatInputProps extends ComponentPropsWithoutRef<'div'> {
|
|
68
|
+
initialConfig?: ChatInputConfig;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export const ChatInput = forwardRef<HTMLDivElement, ChatInputProps>(function ChatInput(
|
|
72
|
+
{ className, children, initialConfig = DEFAULT_CONFIG, ...rest },
|
|
73
|
+
ref,
|
|
74
|
+
) {
|
|
75
|
+
const [hasError, setHasError] = useState(false);
|
|
76
|
+
const [hasValue, setHasValue] = useState(false);
|
|
77
|
+
const [isFocused, setIsFocused] = useState(false);
|
|
78
|
+
|
|
79
|
+
const contextValue = useMemo(
|
|
80
|
+
() => ({
|
|
81
|
+
hasError,
|
|
82
|
+
hasValue,
|
|
83
|
+
isFocused,
|
|
84
|
+
setHasError,
|
|
85
|
+
setHasValue,
|
|
86
|
+
setIsFocused,
|
|
87
|
+
}),
|
|
88
|
+
[hasError, hasValue, isFocused],
|
|
89
|
+
);
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<ChatInputContext.Provider value={contextValue}>
|
|
93
|
+
<LexicalComposer initialConfig={initialConfig}>
|
|
94
|
+
<div
|
|
95
|
+
ref={ref}
|
|
96
|
+
data-testid="chat-input"
|
|
97
|
+
data-focused={isFocused}
|
|
98
|
+
data-empty={!hasValue}
|
|
99
|
+
data-error={hasError}
|
|
100
|
+
aria-invalid={hasError}
|
|
101
|
+
className={cn('group/chat-input', 'relative', className)}
|
|
102
|
+
{...rest}
|
|
103
|
+
>
|
|
104
|
+
{children}
|
|
105
|
+
</div>
|
|
106
|
+
</LexicalComposer>
|
|
107
|
+
</ChatInputContext.Provider>
|
|
108
|
+
);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
ChatInput.displayName = 'ChatInput';
|
|
112
|
+
|
|
113
|
+
export type ChatInputPlaceholderProps = ComponentPropsWithoutRef<'span'>;
|
|
114
|
+
|
|
115
|
+
export const ChatInputPlaceholder = forwardRef<HTMLSpanElement, ChatInputPlaceholderProps>(
|
|
116
|
+
function ChatInputPlaceholder({ className, children, ...rest }, ref) {
|
|
117
|
+
return (
|
|
118
|
+
<Typography
|
|
119
|
+
ref={ref}
|
|
120
|
+
variant="body"
|
|
121
|
+
className={cn(
|
|
122
|
+
'pointer-events-none absolute inset-0 z-0',
|
|
123
|
+
'min-h-[26px]',
|
|
124
|
+
'text-text-tertiary',
|
|
125
|
+
className,
|
|
126
|
+
)}
|
|
127
|
+
{...rest}
|
|
128
|
+
>
|
|
129
|
+
{children}
|
|
130
|
+
</Typography>
|
|
131
|
+
);
|
|
132
|
+
},
|
|
133
|
+
);
|
|
134
|
+
|
|
135
|
+
ChatInputPlaceholder.displayName = 'ChatInputPlaceholder';
|
|
136
|
+
|
|
137
|
+
export interface ChatInputTextareaProps {
|
|
138
|
+
className?: string;
|
|
139
|
+
style?: CSSProperties | undefined;
|
|
140
|
+
placeholderClassName?: string;
|
|
141
|
+
placeholder?: string;
|
|
142
|
+
children?: ReactNode;
|
|
143
|
+
value?: string;
|
|
144
|
+
autoFocus?: boolean;
|
|
145
|
+
isDisabled?: boolean;
|
|
146
|
+
isReadOnly?: boolean;
|
|
147
|
+
onChange?: (value: string) => void;
|
|
148
|
+
onKeyDown?: (event: KeyboardEvent<HTMLDivElement>) => void;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export const ChatInputTextarea = forwardRef<HTMLDivElement, ChatInputTextareaProps>(
|
|
152
|
+
function ChatInputTextarea(
|
|
153
|
+
{
|
|
154
|
+
className,
|
|
155
|
+
style,
|
|
156
|
+
placeholderClassName,
|
|
157
|
+
placeholder = 'Input your message...',
|
|
158
|
+
children,
|
|
159
|
+
value,
|
|
160
|
+
autoFocus = true,
|
|
161
|
+
isDisabled = false,
|
|
162
|
+
isReadOnly = false,
|
|
163
|
+
onChange,
|
|
164
|
+
onKeyDown,
|
|
165
|
+
...rest
|
|
166
|
+
},
|
|
167
|
+
ref,
|
|
168
|
+
) {
|
|
169
|
+
const { setHasValue, setIsFocused } = useChatInputContext();
|
|
170
|
+
const isReadOnlyState = isReadOnly && !isDisabled;
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<div
|
|
174
|
+
data-testid="chat-input-textarea"
|
|
175
|
+
data-disabled={isDisabled}
|
|
176
|
+
aria-disabled={isDisabled}
|
|
177
|
+
aria-readonly={isReadOnlyState}
|
|
178
|
+
className={cn(
|
|
179
|
+
'group/chat-input-textarea',
|
|
180
|
+
'relative',
|
|
181
|
+
'data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-80 data-[disabled=true]:select-none',
|
|
182
|
+
'data-[readonly=true]:text-text-secondary',
|
|
183
|
+
)}
|
|
184
|
+
style={style}
|
|
185
|
+
{...rest}
|
|
186
|
+
>
|
|
187
|
+
<RichTextPlugin
|
|
188
|
+
contentEditable={
|
|
189
|
+
<ContentEditable
|
|
190
|
+
ref={ref}
|
|
191
|
+
className={cn('min-h-[26px]!', 'overflow-y-auto text-wrap outline-none', className)}
|
|
192
|
+
aria-label="Chat input"
|
|
193
|
+
aria-placeholder={placeholder}
|
|
194
|
+
placeholder={
|
|
195
|
+
<ChatInputPlaceholder className={placeholderClassName}>
|
|
196
|
+
{placeholder}
|
|
197
|
+
</ChatInputPlaceholder>
|
|
198
|
+
}
|
|
199
|
+
onKeyDown={onKeyDown}
|
|
200
|
+
/>
|
|
201
|
+
}
|
|
202
|
+
ErrorBoundary={LexicalErrorBoundary}
|
|
203
|
+
/>
|
|
204
|
+
|
|
205
|
+
<HistoryPlugin />
|
|
206
|
+
<DisabledPlugin isDisabled={isDisabled} isReadOnly={isReadOnly} />
|
|
207
|
+
<ControlledValuePlugin value={value} />
|
|
208
|
+
<ValuePlugin onChange={onChange} />
|
|
209
|
+
<MarkdownPlainPastePlugin />
|
|
210
|
+
<HasValuePlugin onHasValueChange={setHasValue} />
|
|
211
|
+
<FocusPlugin onFocusChange={setIsFocused} />
|
|
212
|
+
<AutoFocusPlugin autoFocus={autoFocus} isDisabled={isDisabled || isReadOnly} />
|
|
213
|
+
|
|
214
|
+
{children}
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
},
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
ChatInputTextarea.displayName = 'ChatInputTextarea';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
|
|
4
|
+
interface AutoFocusPluginProps {
|
|
5
|
+
autoFocus?: boolean;
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
defaultSelection?: 'rootStart' | 'rootEnd';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function AutoFocusPlugin({
|
|
11
|
+
defaultSelection = 'rootEnd',
|
|
12
|
+
autoFocus,
|
|
13
|
+
isDisabled,
|
|
14
|
+
}: AutoFocusPluginProps) {
|
|
15
|
+
const [editor] = useLexicalComposerContext();
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (!autoFocus || isDisabled) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
editor.focus(
|
|
23
|
+
() => {
|
|
24
|
+
// If we try and move selection to the same point with setBaseAndExtent, it won't
|
|
25
|
+
// trigger a re-focus on the element. So in the case this occurs, we'll need to correct it.
|
|
26
|
+
// Normally this is fine, Selection API !== Focus API, but fore the intents of the naming
|
|
27
|
+
// of this plugin, which should preserve focus too.
|
|
28
|
+
const activeElement = document.activeElement;
|
|
29
|
+
const rootElement = editor.getRootElement() as HTMLDivElement;
|
|
30
|
+
if (
|
|
31
|
+
rootElement !== null &&
|
|
32
|
+
(activeElement === null || !rootElement.contains(activeElement))
|
|
33
|
+
) {
|
|
34
|
+
// Note: preventScroll won't work in Webkit.
|
|
35
|
+
rootElement.focus({ preventScroll: true });
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
{ defaultSelection },
|
|
39
|
+
);
|
|
40
|
+
}, [defaultSelection, editor, autoFocus, isDisabled]);
|
|
41
|
+
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { $convertFromMarkdownString, $convertToMarkdownString } from '@lexical/markdown';
|
|
2
|
+
import { $addUpdateTag, SKIP_DOM_SELECTION_TAG } from 'lexical';
|
|
3
|
+
import { useEffect, useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
import { EXPORT_TRANSFORMERS, IMPORT_TRANSFORMERS } from '../transformers';
|
|
6
|
+
|
|
7
|
+
import { useChatInputEditor } from './hooks';
|
|
8
|
+
import { $setSelectionToEnd } from './utils';
|
|
9
|
+
|
|
10
|
+
interface ControlledValuePluginProps {
|
|
11
|
+
value?: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function ControlledValuePlugin({ value }: ControlledValuePluginProps) {
|
|
15
|
+
const editor = useChatInputEditor();
|
|
16
|
+
const previousValueRef = useRef<string | undefined>();
|
|
17
|
+
|
|
18
|
+
useEffect(() => {
|
|
19
|
+
if (!editor) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (value === previousValueRef.current) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
previousValueRef.current = value;
|
|
28
|
+
|
|
29
|
+
let currentValue = '';
|
|
30
|
+
editor.getEditorState().read(() => {
|
|
31
|
+
currentValue = $convertToMarkdownString(EXPORT_TRANSFORMERS);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
if (value !== undefined && value !== currentValue) {
|
|
35
|
+
editor.update(
|
|
36
|
+
() => {
|
|
37
|
+
$addUpdateTag(SKIP_DOM_SELECTION_TAG);
|
|
38
|
+
$convertFromMarkdownString(value ?? '', IMPORT_TRANSFORMERS);
|
|
39
|
+
$setSelectionToEnd();
|
|
40
|
+
},
|
|
41
|
+
{ discrete: true },
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
}, [editor, value]);
|
|
45
|
+
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useChatInputEditor } from './hooks';
|
|
4
|
+
|
|
5
|
+
interface DisabledPluginProps {
|
|
6
|
+
isDisabled?: boolean;
|
|
7
|
+
isReadOnly?: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function DisabledPlugin({ isDisabled, isReadOnly }: DisabledPluginProps) {
|
|
11
|
+
const editor = useChatInputEditor();
|
|
12
|
+
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
editor.setEditable(!isDisabled && !isReadOnly);
|
|
15
|
+
}, [editor, isDisabled, isReadOnly]);
|
|
16
|
+
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useChatInputEditor } from './hooks';
|
|
4
|
+
|
|
5
|
+
interface FocusPluginProps {
|
|
6
|
+
onFocusChange?: (isFocused: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function FocusPlugin({ onFocusChange }: FocusPluginProps) {
|
|
10
|
+
const editor = useChatInputEditor();
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
if (!onFocusChange) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const rootElement = editor.getRootElement();
|
|
18
|
+
if (!rootElement) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function handleFocus() {
|
|
23
|
+
if (rootElement && onFocusChange) {
|
|
24
|
+
onFocusChange(true);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function handleBlur(event: FocusEvent) {
|
|
29
|
+
if (rootElement && onFocusChange && !rootElement.contains(event.relatedTarget as Node)) {
|
|
30
|
+
onFocusChange(false);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
rootElement.addEventListener('focus', handleFocus, true);
|
|
35
|
+
rootElement.addEventListener('blur', handleBlur, true);
|
|
36
|
+
|
|
37
|
+
return () => {
|
|
38
|
+
rootElement.removeEventListener('focus', handleFocus, true);
|
|
39
|
+
rootElement.removeEventListener('blur', handleBlur, true);
|
|
40
|
+
};
|
|
41
|
+
}, [editor, onFocusChange]);
|
|
42
|
+
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { LexicalEditor } from 'lexical';
|
|
2
|
+
import { useEffect, useRef } from 'react';
|
|
3
|
+
|
|
4
|
+
import { useChatInputEditor } from './hooks';
|
|
5
|
+
import { $getEditorPlainText } from './utils';
|
|
6
|
+
|
|
7
|
+
interface HasValuePluginProps {
|
|
8
|
+
onHasValueChange?: (hasValue: boolean) => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getHasValue(editor: LexicalEditor): boolean {
|
|
12
|
+
let hasValue = false;
|
|
13
|
+
editor.getEditorState().read(() => {
|
|
14
|
+
hasValue = $getEditorPlainText().length > 0;
|
|
15
|
+
});
|
|
16
|
+
return hasValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function syncHasValue(
|
|
20
|
+
editor: LexicalEditor,
|
|
21
|
+
onHasValueChange: ((hasValue: boolean) => void) | undefined,
|
|
22
|
+
lastHasValueRef: { current: boolean | undefined },
|
|
23
|
+
): void {
|
|
24
|
+
const hasValue = getHasValue(editor);
|
|
25
|
+
|
|
26
|
+
if (lastHasValueRef.current === hasValue) {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
lastHasValueRef.current = hasValue;
|
|
31
|
+
onHasValueChange?.(hasValue);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function HasValuePlugin({ onHasValueChange }: HasValuePluginProps) {
|
|
35
|
+
const editor = useChatInputEditor();
|
|
36
|
+
const lastHasValueRef = useRef<boolean | undefined>();
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (!editor) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
syncHasValue(editor, onHasValueChange, lastHasValueRef);
|
|
44
|
+
|
|
45
|
+
return editor.registerUpdateListener(() => {
|
|
46
|
+
syncHasValue(editor, onHasValueChange, lastHasValueRef);
|
|
47
|
+
});
|
|
48
|
+
}, [editor, onHasValueChange]);
|
|
49
|
+
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { AutoFocusPlugin } from './auto-focus-plugin';
|
|
2
|
+
export { ControlledValuePlugin } from './controlled-value-plugin';
|
|
3
|
+
export { DisabledPlugin } from './disabled-plugin';
|
|
4
|
+
export { FocusPlugin } from './focus-plugin';
|
|
5
|
+
export { HasValuePlugin } from './has-value-plugin';
|
|
6
|
+
export { MarkdownPlainPastePlugin } from './markdown-plain-paste-plugin';
|
|
7
|
+
export { ValuePlugin } from './value-plugin';
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$createParagraphNode,
|
|
3
|
+
$createTextNode,
|
|
4
|
+
$getRoot,
|
|
5
|
+
$getSelection,
|
|
6
|
+
$isRangeSelection,
|
|
7
|
+
COMMAND_PRIORITY_CRITICAL,
|
|
8
|
+
PASTE_COMMAND,
|
|
9
|
+
} from 'lexical';
|
|
10
|
+
import { useEffect } from 'react';
|
|
11
|
+
|
|
12
|
+
import { useChatInputEditor } from './hooks';
|
|
13
|
+
|
|
14
|
+
export function MarkdownPlainPastePlugin() {
|
|
15
|
+
const editor = useChatInputEditor();
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
return editor.registerCommand<ClipboardEvent>(
|
|
19
|
+
PASTE_COMMAND,
|
|
20
|
+
(event) => {
|
|
21
|
+
const { clipboardData } = event;
|
|
22
|
+
|
|
23
|
+
if (!clipboardData) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const plainText = clipboardData.getData('text/plain');
|
|
28
|
+
|
|
29
|
+
if (!plainText) {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
|
|
35
|
+
editor.update(() => {
|
|
36
|
+
const selection = $getSelection();
|
|
37
|
+
|
|
38
|
+
if ($isRangeSelection(selection)) {
|
|
39
|
+
selection.insertText(plainText);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const root = $getRoot();
|
|
44
|
+
root.clear();
|
|
45
|
+
|
|
46
|
+
const lines = plainText.split(/\r?\n/);
|
|
47
|
+
lines.forEach((line) => {
|
|
48
|
+
const paragraph = $createParagraphNode();
|
|
49
|
+
if (line.length > 0) {
|
|
50
|
+
paragraph.append($createTextNode(line));
|
|
51
|
+
}
|
|
52
|
+
root.append(paragraph);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
return true;
|
|
57
|
+
},
|
|
58
|
+
COMMAND_PRIORITY_CRITICAL,
|
|
59
|
+
);
|
|
60
|
+
}, [editor]);
|
|
61
|
+
|
|
62
|
+
return null;
|
|
63
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import {
|
|
2
|
+
$createParagraphNode,
|
|
3
|
+
$createRangeSelection,
|
|
4
|
+
$createTextNode,
|
|
5
|
+
$getRoot,
|
|
6
|
+
$getSelection,
|
|
7
|
+
$isRangeSelection,
|
|
8
|
+
$isTextNode,
|
|
9
|
+
$selectAll,
|
|
10
|
+
$setSelection,
|
|
11
|
+
} from 'lexical';
|
|
12
|
+
|
|
13
|
+
export function $getEditorPlainText(): string {
|
|
14
|
+
return $getRoot().getTextContent();
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function $setEditorPlainText(value: string): void {
|
|
18
|
+
const root = $getRoot();
|
|
19
|
+
root.clear();
|
|
20
|
+
const paragraph = $createParagraphNode();
|
|
21
|
+
if (value) {
|
|
22
|
+
paragraph.append($createTextNode(value));
|
|
23
|
+
}
|
|
24
|
+
root.append(paragraph);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function $setSelectionToEnd(): void {
|
|
28
|
+
const root = $getRoot();
|
|
29
|
+
const lastDescendant = root.getLastDescendant();
|
|
30
|
+
|
|
31
|
+
if (lastDescendant && $isTextNode(lastDescendant)) {
|
|
32
|
+
const selection = $createRangeSelection();
|
|
33
|
+
const endOffset = lastDescendant.getTextContentSize();
|
|
34
|
+
selection.anchor.set(lastDescendant.getKey(), endOffset, 'text');
|
|
35
|
+
selection.focus.set(lastDescendant.getKey(), endOffset, 'text');
|
|
36
|
+
$setSelection(selection);
|
|
37
|
+
} else {
|
|
38
|
+
$selectAll();
|
|
39
|
+
const selection = $getSelection();
|
|
40
|
+
if ($isRangeSelection(selection)) {
|
|
41
|
+
const focusNode = selection.focus.getNode();
|
|
42
|
+
const focusOffset = $isTextNode(focusNode) ? focusNode.getTextContentSize() : 0;
|
|
43
|
+
selection.anchor.set(selection.focus.key, selection.focus.offset, selection.focus.type);
|
|
44
|
+
selection.focus.set(selection.focus.key, focusOffset, selection.focus.type);
|
|
45
|
+
$setSelection(selection);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { $convertToMarkdownString } from '@lexical/markdown';
|
|
2
|
+
import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
|
|
3
|
+
import type { EditorState, LexicalEditor } from 'lexical';
|
|
4
|
+
import { useCallback } from 'react';
|
|
5
|
+
|
|
6
|
+
import { EXPORT_TRANSFORMERS } from '../transformers';
|
|
7
|
+
|
|
8
|
+
interface ValuePluginProps {
|
|
9
|
+
onChange?: (value: string) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ValuePlugin({ onChange }: ValuePluginProps) {
|
|
13
|
+
const handleChange = useCallback(
|
|
14
|
+
(editorState: EditorState, _editor: LexicalEditor, tags: Set<string>) => {
|
|
15
|
+
if (tags.has('focus')) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (!onChange) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
try {
|
|
24
|
+
editorState.read(() => {
|
|
25
|
+
onChange($convertToMarkdownString(EXPORT_TRANSFORMERS));
|
|
26
|
+
});
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error('ValuePlugin error:', error);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
[onChange],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
return <OnChangePlugin onChange={handleChange} />;
|
|
35
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Slot } from '@radix-ui/react-slot';
|
|
2
|
+
import { forwardRef, type ComponentPropsWithoutRef, type ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn } from '@swisper.ai/web-core';
|
|
5
|
+
|
|
6
|
+
export interface ChatListItemProps extends ComponentPropsWithoutRef<'div'> {
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
asChild?: boolean;
|
|
9
|
+
isSelected?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const ChatListItem = forwardRef<HTMLDivElement, ChatListItemProps>(function ChatListItem(
|
|
13
|
+
{ children, className, asChild = false, isSelected = false, ...rest },
|
|
14
|
+
ref,
|
|
15
|
+
) {
|
|
16
|
+
const Component = asChild ? Slot : 'div';
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Component
|
|
20
|
+
ref={ref}
|
|
21
|
+
data-slot="chat-list-item"
|
|
22
|
+
data-testid="chat-list-item"
|
|
23
|
+
data-selected={isSelected}
|
|
24
|
+
aria-selected={isSelected || undefined}
|
|
25
|
+
className={cn('cursor-pointer outline-none', className)}
|
|
26
|
+
{...rest}
|
|
27
|
+
>
|
|
28
|
+
{children}
|
|
29
|
+
</Component>
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
ChatListItem.displayName = 'ChatListItem';
|