@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,296 @@
|
|
|
1
|
+
import type { MouseEvent, ReactNode } from 'react';
|
|
2
|
+
import { forwardRef, useCallback, useLayoutEffect, useState } from 'react';
|
|
3
|
+
|
|
4
|
+
import { cn, useElementMeasure } from '@swisper.ai/web-core';
|
|
5
|
+
|
|
6
|
+
import { ChatInput, ChatInputTextarea, useChatInputContext } from '../chat-input';
|
|
7
|
+
import type { ChatInputProps, ChatInputTextareaProps } from '../chat-input';
|
|
8
|
+
|
|
9
|
+
import { ChatPromptBoxContextProvider, useChatPromptBoxContext } from './chat-prompt-box-context';
|
|
10
|
+
import { ChatPromptBoxFocusPlugin } from './chat-prompt-box-focus-plugin';
|
|
11
|
+
|
|
12
|
+
export type ChatPromptBoxProps = ChatInputProps;
|
|
13
|
+
|
|
14
|
+
const COMPACT_INPUT_HEIGHT_THRESHOLD = 40;
|
|
15
|
+
|
|
16
|
+
const INTERACTIVE_SELECTOR = 'button, a, input, select, textarea, [role="button"]';
|
|
17
|
+
|
|
18
|
+
function shouldSkipFocus(target: EventTarget | null): boolean {
|
|
19
|
+
if (!(target instanceof HTMLElement)) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return Boolean(target.closest(INTERACTIVE_SELECTOR));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export const ChatPromptBox = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
27
|
+
function ChatPromptBox(props, ref) {
|
|
28
|
+
const [isCompact, setIsCompact] = useState(true);
|
|
29
|
+
|
|
30
|
+
const reportInputHeight = useCallback((height: number) => {
|
|
31
|
+
if (height > COMPACT_INPUT_HEIGHT_THRESHOLD) {
|
|
32
|
+
setIsCompact(false);
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
|
|
36
|
+
const resetCompact = useCallback(() => {
|
|
37
|
+
setIsCompact(true);
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<ChatPromptBoxContextProvider
|
|
42
|
+
reportInputHeight={reportInputHeight}
|
|
43
|
+
resetCompact={resetCompact}
|
|
44
|
+
>
|
|
45
|
+
<ChatPromptBoxContainer ref={ref} data-compact={isCompact} {...props} />
|
|
46
|
+
</ChatPromptBoxContextProvider>
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
ChatPromptBox.displayName = 'ChatPromptBox';
|
|
52
|
+
|
|
53
|
+
const ChatPromptBoxContainer = forwardRef<HTMLDivElement, ChatPromptBoxProps>(
|
|
54
|
+
function ChatPromptBoxContainer({ className, onMouseDown, children, ...rest }, ref) {
|
|
55
|
+
const { focusInput } = useChatPromptBoxContext();
|
|
56
|
+
|
|
57
|
+
const handleMouseDown = useCallback(
|
|
58
|
+
(event: MouseEvent<HTMLDivElement>) => {
|
|
59
|
+
if (!shouldSkipFocus(event.target)) {
|
|
60
|
+
focusInput();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
onMouseDown?.(event);
|
|
64
|
+
},
|
|
65
|
+
[focusInput, onMouseDown],
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<ChatInput
|
|
70
|
+
ref={ref}
|
|
71
|
+
className={cn(
|
|
72
|
+
'group/chat-prompt-box',
|
|
73
|
+
'relative overflow-hidden',
|
|
74
|
+
'cursor-text',
|
|
75
|
+
'p-px',
|
|
76
|
+
'rounded-[16px]',
|
|
77
|
+
// border color
|
|
78
|
+
'bg-transparent',
|
|
79
|
+
'hover:bg-promptbox-background-border-base',
|
|
80
|
+
'data-[focused=true]:bg-promptbox-background-border-base',
|
|
81
|
+
className,
|
|
82
|
+
)}
|
|
83
|
+
onMouseDown={handleMouseDown}
|
|
84
|
+
{...rest}
|
|
85
|
+
>
|
|
86
|
+
<div
|
|
87
|
+
className={cn(
|
|
88
|
+
'rounded-[15px]',
|
|
89
|
+
'p-[4px]',
|
|
90
|
+
// regular bg
|
|
91
|
+
'bg-[#171A20]',
|
|
92
|
+
// hover bg
|
|
93
|
+
'group-hover/chat-prompt-box:bg-[#252931]',
|
|
94
|
+
// focused bg
|
|
95
|
+
'group-data-[focused=true]/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]',
|
|
96
|
+
// focused & hover bg
|
|
97
|
+
'group-data-[focused=true]/chat-prompt-box:group-hover/chat-prompt-box:bg-[linear-gradient(var(--color-promptbox-background-hover),var(--color-promptbox-background-hover)),var(--color-promptbox-background-base)]',
|
|
98
|
+
)}
|
|
99
|
+
>
|
|
100
|
+
{children}
|
|
101
|
+
</div>
|
|
102
|
+
|
|
103
|
+
<ChatPromptBoxFocusRadials />
|
|
104
|
+
</ChatInput>
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
);
|
|
108
|
+
|
|
109
|
+
function ChatPromptBoxFocusRadials() {
|
|
110
|
+
return (
|
|
111
|
+
<>
|
|
112
|
+
<div
|
|
113
|
+
className={cn(
|
|
114
|
+
'absolute left-1/2 top-[-40px]',
|
|
115
|
+
'translate-x-[-50%]',
|
|
116
|
+
'pointer-events-none',
|
|
117
|
+
'w-[380px] h-[72px]',
|
|
118
|
+
'opacity-0 group-data-[focused=true]/chat-prompt-box:opacity-50',
|
|
119
|
+
)}
|
|
120
|
+
style={{
|
|
121
|
+
borderRadius: '380px',
|
|
122
|
+
background:
|
|
123
|
+
'gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.00) 100%)',
|
|
124
|
+
}}
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
<div
|
|
128
|
+
className={cn(
|
|
129
|
+
'absolute left-1/2 -bottom-22',
|
|
130
|
+
'translate-x-[-50%]',
|
|
131
|
+
'pointer-events-none',
|
|
132
|
+
'w-[1082px] h-[172px]',
|
|
133
|
+
'opacity-0 group-data-[focused=true]/chat-prompt-box:opacity-5',
|
|
134
|
+
)}
|
|
135
|
+
style={{
|
|
136
|
+
borderRadius: '1082px',
|
|
137
|
+
background:
|
|
138
|
+
'radial-gradient(50% 50% at 50% 50%, rgba(255, 255, 255, 0.80) 0%, #2979FF 28%, rgba(63, 70, 88, 0.00) 100%)',
|
|
139
|
+
}}
|
|
140
|
+
/>
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface ChatPromptBoxToolbarProps {
|
|
146
|
+
children: ReactNode;
|
|
147
|
+
className?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function ChatPromptBoxToolbar({ children, className }: ChatPromptBoxToolbarProps) {
|
|
151
|
+
return (
|
|
152
|
+
<div data-testid="chat-prompt-box-toolbar" className={cn(className)}>
|
|
153
|
+
{children}
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export interface ChatPromptBoxContentProps {
|
|
159
|
+
children: ReactNode;
|
|
160
|
+
className?: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function ChatPromptBoxContent({ children, className }: ChatPromptBoxContentProps) {
|
|
164
|
+
return (
|
|
165
|
+
<div
|
|
166
|
+
data-testid="chat-prompt-box-content"
|
|
167
|
+
className={cn(
|
|
168
|
+
'relative',
|
|
169
|
+
'px-[8px] py-[8px]',
|
|
170
|
+
'flex flex-row gap-[8px]',
|
|
171
|
+
'group-data-[compact=false]/chat-prompt-box:pb-[calc(8px+4px+40px)]',
|
|
172
|
+
className,
|
|
173
|
+
)}
|
|
174
|
+
>
|
|
175
|
+
{children}
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export type ChatPromptBoxInputProps = ChatInputTextareaProps;
|
|
181
|
+
|
|
182
|
+
export const ChatPromptBoxInput = forwardRef<HTMLDivElement, ChatPromptBoxInputProps>(
|
|
183
|
+
function ChatPromptBoxInput({ className, placeholderClassName, ...rest }, ref) {
|
|
184
|
+
const { reportInputHeight, resetCompact } = useChatPromptBoxContext();
|
|
185
|
+
const { hasValue } = useChatInputContext();
|
|
186
|
+
const { ref: measureRef, height } = useElementMeasure<HTMLDivElement>();
|
|
187
|
+
|
|
188
|
+
useLayoutEffect(() => {
|
|
189
|
+
if (typeof height === 'number') {
|
|
190
|
+
reportInputHeight(height);
|
|
191
|
+
}
|
|
192
|
+
}, [height, reportInputHeight]);
|
|
193
|
+
|
|
194
|
+
useLayoutEffect(() => {
|
|
195
|
+
return () => {
|
|
196
|
+
resetCompact();
|
|
197
|
+
};
|
|
198
|
+
}, [resetCompact]);
|
|
199
|
+
|
|
200
|
+
useLayoutEffect(() => {
|
|
201
|
+
if (!hasValue) {
|
|
202
|
+
resetCompact();
|
|
203
|
+
}
|
|
204
|
+
}, [hasValue, resetCompact]);
|
|
205
|
+
|
|
206
|
+
const setRef = useCallback(
|
|
207
|
+
(element: HTMLDivElement | null) => {
|
|
208
|
+
measureRef(element);
|
|
209
|
+
|
|
210
|
+
if (typeof ref === 'function') {
|
|
211
|
+
ref(element);
|
|
212
|
+
} else if (ref) {
|
|
213
|
+
ref.current = element;
|
|
214
|
+
}
|
|
215
|
+
},
|
|
216
|
+
[measureRef, ref],
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
return (
|
|
220
|
+
<div
|
|
221
|
+
data-testid="chat-prompt-box-input"
|
|
222
|
+
className={cn(
|
|
223
|
+
'min-h-[40px]',
|
|
224
|
+
'inline-flex justify-center items-center',
|
|
225
|
+
'group-data-[compact=false]/chat-prompt-box:items-start',
|
|
226
|
+
'group-data-[compact=false]/chat-prompt-box:min-h-[48px]',
|
|
227
|
+
'order-2 grow min-w-0 flex-1',
|
|
228
|
+
'[&>div]:flex-1 [&>div]:min-w-0',
|
|
229
|
+
className,
|
|
230
|
+
)}
|
|
231
|
+
>
|
|
232
|
+
<ChatInputTextarea
|
|
233
|
+
ref={setRef}
|
|
234
|
+
className="max-h-[72px]!"
|
|
235
|
+
placeholderClassName={cn('leading-[24px]!', placeholderClassName)}
|
|
236
|
+
{...rest}
|
|
237
|
+
>
|
|
238
|
+
<ChatPromptBoxFocusPlugin />
|
|
239
|
+
</ChatInputTextarea>
|
|
240
|
+
</div>
|
|
241
|
+
);
|
|
242
|
+
},
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
ChatPromptBoxInput.displayName = 'ChatPromptBoxInput';
|
|
246
|
+
|
|
247
|
+
export interface ChatPromptBoxActionsLeftProps {
|
|
248
|
+
children: ReactNode;
|
|
249
|
+
className?: string;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export function ChatPromptBoxActionsLeft({ children, className }: ChatPromptBoxActionsLeftProps) {
|
|
253
|
+
return (
|
|
254
|
+
<div
|
|
255
|
+
data-testid="chat-prompt-box-actions-left"
|
|
256
|
+
role="group"
|
|
257
|
+
className={cn(
|
|
258
|
+
'order-1 shrink-0',
|
|
259
|
+
'group-data-[compact=false]/chat-prompt-box:absolute',
|
|
260
|
+
'group-data-[compact=false]/chat-prompt-box:bottom-[8px]',
|
|
261
|
+
'group-data-[compact=false]/chat-prompt-box:left-[8px]',
|
|
262
|
+
'flex items-center gap-[8px]',
|
|
263
|
+
'[grid-area:left]',
|
|
264
|
+
className,
|
|
265
|
+
)}
|
|
266
|
+
>
|
|
267
|
+
{children}
|
|
268
|
+
</div>
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
export interface ChatPromptBoxActionsRightProps {
|
|
273
|
+
children: ReactNode;
|
|
274
|
+
className?: string;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
export function ChatPromptBoxActionsRight({ children, className }: ChatPromptBoxActionsRightProps) {
|
|
278
|
+
return (
|
|
279
|
+
<div
|
|
280
|
+
data-testid="chat-prompt-box-actions-right"
|
|
281
|
+
role="group"
|
|
282
|
+
className={cn(
|
|
283
|
+
'order-3 shrink-0',
|
|
284
|
+
'group-data-[compact=false]/chat-prompt-box:order-3',
|
|
285
|
+
'group-data-[compact=false]/chat-prompt-box:absolute',
|
|
286
|
+
'group-data-[compact=false]/chat-prompt-box:bottom-[8px]',
|
|
287
|
+
'group-data-[compact=false]/chat-prompt-box:right-[8px]',
|
|
288
|
+
'flex items-center justify-end gap-[8px]',
|
|
289
|
+
'[grid-area:right]',
|
|
290
|
+
className,
|
|
291
|
+
)}
|
|
292
|
+
>
|
|
293
|
+
{children}
|
|
294
|
+
</div>
|
|
295
|
+
);
|
|
296
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export {
|
|
2
|
+
ChatPromptBox,
|
|
3
|
+
ChatPromptBoxInput,
|
|
4
|
+
ChatPromptBoxToolbar,
|
|
5
|
+
ChatPromptBoxContent,
|
|
6
|
+
ChatPromptBoxActionsLeft,
|
|
7
|
+
ChatPromptBoxActionsRight,
|
|
8
|
+
} from './chat-prompt-box';
|
|
9
|
+
export type {
|
|
10
|
+
ChatPromptBoxProps,
|
|
11
|
+
ChatPromptBoxInputProps,
|
|
12
|
+
ChatPromptBoxToolbarProps,
|
|
13
|
+
ChatPromptBoxContentProps,
|
|
14
|
+
ChatPromptBoxActionsLeftProps,
|
|
15
|
+
ChatPromptBoxActionsRightProps,
|
|
16
|
+
} from './chat-prompt-box';
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-reply",
|
|
4
|
+
"purpose": "List of label/value rows that summarise the fields of a drafted reply or message, such as its subject and recipients, with a chip label per row.",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Showing the fields of something the assistant drafted for the user, like an e-mail's subject and recipients, before it is sent",
|
|
7
|
+
"A value is a set of chips (recipients) that should wrap onto several lines"
|
|
8
|
+
],
|
|
9
|
+
"avoidWhen": [
|
|
10
|
+
"Label/value attributes inside a ChatCardForm, with labels aligned in one column — use ChatCardAttributes from web-chat-ui/chat-card instead",
|
|
11
|
+
"A single line of metadata separated by bullets — use ui/meta-list instead",
|
|
12
|
+
"Tabular data with several columns — use ui/table instead"
|
|
13
|
+
],
|
|
14
|
+
"uxPrinciples": [
|
|
15
|
+
"Each row answers one question about the draft (who, what); the label names it, the value shows it.",
|
|
16
|
+
"Single-line rows truncate so the summary stays compact; only lists of chips wrap."
|
|
17
|
+
],
|
|
18
|
+
"accessibility": {
|
|
19
|
+
"required": [
|
|
20
|
+
"Render ChatReply only inside ChatReplies, so each li has its ul",
|
|
21
|
+
"Keep the label text meaningful on its own ('To', 'Subject'): it is the only thing that tells a screen reader what the value is"
|
|
22
|
+
],
|
|
23
|
+
"keyboard": [
|
|
24
|
+
"No keyboard handling; interactive chips or buttons in a value follow their own behaviour"
|
|
25
|
+
],
|
|
26
|
+
"aria": ["ChatReplies is a ul and each ChatReply an li, so the rows are exposed as a list"],
|
|
27
|
+
"focus": ["Not focusable"]
|
|
28
|
+
},
|
|
29
|
+
"behaviour": {
|
|
30
|
+
"states": ["single-line", "multiline"],
|
|
31
|
+
"rules": [
|
|
32
|
+
"ChatReplies stacks its rows with an 8px gap and pads the list; hasPadding=false removes the padding when the parent already provides it",
|
|
33
|
+
"ChatReply with isMultiline=false keeps the label and value on one line and truncates the value; isMultiline=true lets the row wrap and lays the value's children out as wrapping items with a 4px gap, for lists of chips",
|
|
34
|
+
"ChatReplyLabel is an outlined ui Chip and accepts Chip props; ChatReplyValue is body-sm text in the secondary colour"
|
|
35
|
+
]
|
|
36
|
+
},
|
|
37
|
+
"composition": {
|
|
38
|
+
"allowedParents": ["web-chat-ui/ChatReplies"],
|
|
39
|
+
"allowedChildren": [
|
|
40
|
+
"web-chat-ui/ChatReplyLabel",
|
|
41
|
+
"web-chat-ui/ChatReplyValue",
|
|
42
|
+
"ui/chip",
|
|
43
|
+
"text"
|
|
44
|
+
],
|
|
45
|
+
"avoidCombinations": [
|
|
46
|
+
"Long prose in ChatReplyValue — it truncates to one line unless isMultiline is set; put the body text below the list instead",
|
|
47
|
+
"Mixing ChatReply rows and ChatCardAttribute rows in one card — they align labels differently"
|
|
48
|
+
],
|
|
49
|
+
"contexts": ["chat card body", "chat message body"]
|
|
50
|
+
},
|
|
51
|
+
"content": {
|
|
52
|
+
"labelRules": [
|
|
53
|
+
"Label: the field name, one or two words ('To', 'Reply e-mail')",
|
|
54
|
+
"Value: the field's content as the recipient will see it ('Job application'); one chip per address for recipients"
|
|
55
|
+
],
|
|
56
|
+
"helperTextRules": [],
|
|
57
|
+
"errorRules": [
|
|
58
|
+
"Mark an invalid recipient by giving its chip color='error', as the Default story does"
|
|
59
|
+
]
|
|
60
|
+
},
|
|
61
|
+
"aiDecisionRules": [
|
|
62
|
+
{
|
|
63
|
+
"condition": "A row's value is a list of recipients or tags",
|
|
64
|
+
"decision": "Set isMultiline and render one ui Chip per item in ChatReplyValue",
|
|
65
|
+
"reason": "Multiline rows wrap and space the chips; single-line rows would truncate them"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"condition": "The summary sits inside a ChatCardContent that already has padding",
|
|
69
|
+
"decision": "Pass hasPadding={false} to ChatReplies",
|
|
70
|
+
"reason": "Avoids doubling the inset between the card edge and the rows"
|
|
71
|
+
}
|
|
72
|
+
],
|
|
73
|
+
"relatedComponents": ["web-chat-ui/chat-card", "ui/chip", "ui/meta-list"],
|
|
74
|
+
"tokenReferences": {
|
|
75
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
76
|
+
"categories": ["text-text-secondary"],
|
|
77
|
+
"rule": "Use the tokens the parts already apply; override with token utilities through className only."
|
|
78
|
+
}
|
|
79
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
2
|
+
|
|
3
|
+
import { Chip } from '@swisper.ai/ui';
|
|
4
|
+
|
|
5
|
+
import { ChatReplies, ChatReply, ChatReplyLabel, ChatReplyValue } from './chat-reply';
|
|
6
|
+
|
|
7
|
+
const meta: Meta<typeof ChatReply> = {
|
|
8
|
+
title: 'Chatbot/ChatReply',
|
|
9
|
+
component: ChatReply,
|
|
10
|
+
tags: ['autodocs'],
|
|
11
|
+
decorators: [
|
|
12
|
+
(Story) => (
|
|
13
|
+
<div className="max-w-[420px]">
|
|
14
|
+
<Story />
|
|
15
|
+
</div>
|
|
16
|
+
),
|
|
17
|
+
],
|
|
18
|
+
argTypes: {
|
|
19
|
+
isMultiline: {
|
|
20
|
+
control: 'boolean',
|
|
21
|
+
description:
|
|
22
|
+
'Lets the value wrap onto several lines (e.g. a list of recipient chips) instead of truncating it on one line.',
|
|
23
|
+
table: { defaultValue: { summary: 'false' } },
|
|
24
|
+
},
|
|
25
|
+
children: {
|
|
26
|
+
control: false,
|
|
27
|
+
description: 'A `ChatReplyLabel` naming the field followed by a `ChatReplyValue`.',
|
|
28
|
+
},
|
|
29
|
+
className: {
|
|
30
|
+
control: 'text',
|
|
31
|
+
description: 'Extra classes merged onto the `<li>` root.',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
args: {
|
|
35
|
+
isMultiline: false,
|
|
36
|
+
children: (
|
|
37
|
+
<>
|
|
38
|
+
<ChatReplyLabel>Reply e-mail</ChatReplyLabel>
|
|
39
|
+
<ChatReplyValue>Job application</ChatReplyValue>
|
|
40
|
+
</>
|
|
41
|
+
),
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default meta;
|
|
46
|
+
type Story = StoryObj<typeof ChatReply>;
|
|
47
|
+
|
|
48
|
+
export const Default: Story = {
|
|
49
|
+
render: () => (
|
|
50
|
+
<ChatReplies>
|
|
51
|
+
<ChatReply>
|
|
52
|
+
<ChatReplyLabel>Reply e-mail</ChatReplyLabel>
|
|
53
|
+
<ChatReplyValue>Job application</ChatReplyValue>
|
|
54
|
+
</ChatReply>
|
|
55
|
+
|
|
56
|
+
<ChatReply isMultiline>
|
|
57
|
+
<ChatReplyLabel>To</ChatReplyLabel>
|
|
58
|
+
<ChatReplyValue>
|
|
59
|
+
<Chip variant="filled" color="primary" size="md">
|
|
60
|
+
andrea.panzitta@email.com
|
|
61
|
+
</Chip>
|
|
62
|
+
<Chip variant="filled" color="primary" size="md">
|
|
63
|
+
test@email.com
|
|
64
|
+
</Chip>
|
|
65
|
+
<Chip variant="filled" color="error" size="md">
|
|
66
|
+
test2@email.com
|
|
67
|
+
</Chip>
|
|
68
|
+
</ChatReplyValue>
|
|
69
|
+
</ChatReply>
|
|
70
|
+
</ChatReplies>
|
|
71
|
+
),
|
|
72
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Chip, Typography, type TypographyProps } from '@swisper.ai/ui';
|
|
4
|
+
import { cn } from '@swisper.ai/web-core';
|
|
5
|
+
|
|
6
|
+
export interface ChatRepliesProps {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
className?: string;
|
|
9
|
+
hasPadding?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export function ChatReplies({ className, children, hasPadding = true }: ChatRepliesProps) {
|
|
13
|
+
return (
|
|
14
|
+
<ul
|
|
15
|
+
data-testid="chat-replies"
|
|
16
|
+
data-padding={hasPadding}
|
|
17
|
+
className={cn(
|
|
18
|
+
'flex flex-col justify-start items-start gap-8',
|
|
19
|
+
'data-[padding=true]:py-8 data-[padding=true]:px-16',
|
|
20
|
+
className,
|
|
21
|
+
)}
|
|
22
|
+
>
|
|
23
|
+
{children}
|
|
24
|
+
</ul>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ChatReplyProps extends ComponentProps<'li'> {
|
|
29
|
+
children: ReactNode;
|
|
30
|
+
isMultiline?: boolean;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function ChatReply({ className, children, isMultiline = false, ...rest }: ChatReplyProps) {
|
|
34
|
+
return (
|
|
35
|
+
<li
|
|
36
|
+
data-testid="chat-reply"
|
|
37
|
+
data-multiline={isMultiline}
|
|
38
|
+
className={cn(
|
|
39
|
+
'group/chat-reply',
|
|
40
|
+
'flex gap-8 w-full min-h-[24px]',
|
|
41
|
+
'data-[multiline=false]:flex-row items-center',
|
|
42
|
+
'data-[multiline=true]:flex-wrap items-start',
|
|
43
|
+
className,
|
|
44
|
+
)}
|
|
45
|
+
{...rest}
|
|
46
|
+
>
|
|
47
|
+
{children}
|
|
48
|
+
</li>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ChatReplyLabelProps extends ComponentProps<typeof Chip> {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function ChatReplyLabel({ className, children, ...rest }: ChatReplyLabelProps) {
|
|
57
|
+
return (
|
|
58
|
+
<Chip
|
|
59
|
+
variant="outlined"
|
|
60
|
+
// @ts-expect-error TODO(design): Chip has no `sm` size since the size scale changed (md is the old sm); renders without size classes.
|
|
61
|
+
size="sm"
|
|
62
|
+
// @ts-expect-error TODO(design): Chip has no `secondary` color any more; renders without color classes.
|
|
63
|
+
color="secondary"
|
|
64
|
+
data-testid="chat-reply-label"
|
|
65
|
+
className={cn('shrink-0', className)}
|
|
66
|
+
{...rest}
|
|
67
|
+
>
|
|
68
|
+
{children}
|
|
69
|
+
</Chip>
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface ChatReplyValueProps extends Omit<TypographyProps, 'variant'> {
|
|
74
|
+
children: ReactNode;
|
|
75
|
+
asChild?: boolean;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export function ChatReplyValue({
|
|
79
|
+
className,
|
|
80
|
+
children,
|
|
81
|
+
asChild = false,
|
|
82
|
+
...rest
|
|
83
|
+
}: ChatReplyValueProps) {
|
|
84
|
+
return (
|
|
85
|
+
<Typography
|
|
86
|
+
data-testid="chat-reply-value"
|
|
87
|
+
variant="body-sm"
|
|
88
|
+
className={cn(
|
|
89
|
+
'leading-[24px]',
|
|
90
|
+
'flex flex-1 min-w-0 text-text-secondary',
|
|
91
|
+
'items-start',
|
|
92
|
+
'group-data-[multiline=false]/chat-reply:flex-1 truncate',
|
|
93
|
+
'group-data-[multiline=true]/chat-reply:flex-wrap',
|
|
94
|
+
'group-data-[multiline=true]/chat-reply:gap-4',
|
|
95
|
+
className,
|
|
96
|
+
)}
|
|
97
|
+
asChild
|
|
98
|
+
{...rest}
|
|
99
|
+
>
|
|
100
|
+
<div>{children}</div>
|
|
101
|
+
</Typography>
|
|
102
|
+
);
|
|
103
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ChatReplies, ChatReply, ChatReplyLabel, ChatReplyValue } from './chat-reply';
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "../../../../int-eslint-config/schemas/component.schema.json",
|
|
3
|
+
"component": "chat-suggestion",
|
|
4
|
+
"purpose": "Numbered list of follow-up questions or quick replies above the chat input; picking one sends it.",
|
|
5
|
+
"useWhen": [
|
|
6
|
+
"Offering follow-up questions after an answer has finished streaming",
|
|
7
|
+
"Starting an empty conversation with a few example questions",
|
|
8
|
+
"Offering quick replies to a question the assistant asked ('Yes', 'No', 'Maybe later')"
|
|
9
|
+
],
|
|
10
|
+
"avoidWhen": [
|
|
11
|
+
"Commands that change data or navigate — use ui/button or ui/contextual-menu instead",
|
|
12
|
+
"Filters or selected values — use ui/chip instead",
|
|
13
|
+
"Choosing one item from a card's collection — use web-chat-ui/card-item-picker instead"
|
|
14
|
+
],
|
|
15
|
+
"uxPrinciples": [
|
|
16
|
+
"Suggestions are shortcuts for what the user could type; the input stays the primary way to ask.",
|
|
17
|
+
"Quiet while streaming: hide suggestions until the answer finishes so a second question can't start mid-answer.",
|
|
18
|
+
"Few and specific: a handful of concrete questions beats a long generic list."
|
|
19
|
+
],
|
|
20
|
+
"accessibility": {
|
|
21
|
+
"required": [
|
|
22
|
+
"ChatSuggestion is a div with onClick and no tabIndex or key handler, and it accepts no props to add them — it cannot be reached or activated by keyboard, so keep ChatInput available so keyboard users can type the same question",
|
|
23
|
+
"ChatSuggestionLabelIcon is aria-hidden; the label text must carry the full meaning",
|
|
24
|
+
"A button placed in ChatSuggestionActions needs an aria-label"
|
|
25
|
+
],
|
|
26
|
+
"keyboard": [
|
|
27
|
+
"No keyboard interaction on the suggestion itself",
|
|
28
|
+
"Buttons inside ChatSuggestionActions follow standard button behaviour"
|
|
29
|
+
],
|
|
30
|
+
"aria": [
|
|
31
|
+
"ChatSuggestions renders role=list and each ChatSuggestion role=listitem",
|
|
32
|
+
"ChatSuggestionLabelIcon is aria-hidden",
|
|
33
|
+
"ChatSuggestionActions renders role=group"
|
|
34
|
+
],
|
|
35
|
+
"focus": [
|
|
36
|
+
"The suggestion is not a tab stop; it has a focus-visible style, but with no tabIndex it never receives focus"
|
|
37
|
+
]
|
|
38
|
+
},
|
|
39
|
+
"behaviour": {
|
|
40
|
+
"states": ["default", "hover (background highlight, actions revealed)"],
|
|
41
|
+
"rules": [
|
|
42
|
+
"ChatSuggestions passes each direct child its zero-based index; ChatSuggestionLabelIcon shows index + 1 unless it is given an icon as children",
|
|
43
|
+
"onClick fires on a click anywhere in the suggestion, usually to send its text as the next message",
|
|
44
|
+
"onHover fires when the pointer enters a suggestion; ChatSuggestions.onMouseLeave fires when it leaves the list, so the pair can drive a preview or highlight",
|
|
45
|
+
"ChatSuggestionLabel wraps up to three lines by default; isMultiline=false truncates it to one line",
|
|
46
|
+
"ChatSuggestionActions is invisible until the suggestion is hovered; it holds a hint icon (EnterIcon) or small buttons",
|
|
47
|
+
"Clicks in ChatSuggestionActions bubble to the suggestion's onClick; stop propagation in an action that should not also send the suggestion"
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
"composition": {
|
|
51
|
+
"allowedParents": ["web-chat-ui/CanvasShellFooter"],
|
|
52
|
+
"allowedChildren": [
|
|
53
|
+
"web-chat-ui/ChatSuggestion",
|
|
54
|
+
"web-chat-ui/ChatSuggestionLabelIcon",
|
|
55
|
+
"web-chat-ui/ChatSuggestionLabel",
|
|
56
|
+
"web-chat-ui/ChatSuggestionActions",
|
|
57
|
+
"ui/icon-button",
|
|
58
|
+
"icon"
|
|
59
|
+
],
|
|
60
|
+
"avoidCombinations": [
|
|
61
|
+
"Wrapping each ChatSuggestion in another element inside ChatSuggestions — the index goes to the wrapper, so unless the wrapper forwards it every number shows 1",
|
|
62
|
+
"Showing suggestions while an answer streams — hide them until it finishes",
|
|
63
|
+
"Interactive controls in ChatSuggestionActions that don't stop propagation — they also send the suggestion"
|
|
64
|
+
],
|
|
65
|
+
"contexts": ["chat footer, above ChatInput", "empty conversation"]
|
|
66
|
+
},
|
|
67
|
+
"content": {
|
|
68
|
+
"labelRules": [
|
|
69
|
+
"Write the suggestion as the user would type it, a full question or reply in the first person ('Show my subscriptions')",
|
|
70
|
+
"Keep each one to a line where possible; use isMultiline=false in a narrow panel so long suggestions truncate"
|
|
71
|
+
],
|
|
72
|
+
"helperTextRules": [],
|
|
73
|
+
"errorRules": []
|
|
74
|
+
},
|
|
75
|
+
"aiDecisionRules": [
|
|
76
|
+
{
|
|
77
|
+
"condition": "Rendering follow-up questions in a chat panel",
|
|
78
|
+
"decision": "Put ChatSuggestions in CanvasShellFooter above ChatInput, one ChatSuggestion per question with ChatSuggestionLabelIcon, ChatSuggestionLabel and ChatSuggestionActions holding EnterIcon",
|
|
79
|
+
"reason": "This is the chatbot overview composition; picking a suggestion sends it like typing it"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"condition": "The assistant is still streaming",
|
|
83
|
+
"decision": "Don't render the suggestions",
|
|
84
|
+
"reason": "The chatbot composition rules keep the UI quiet while streaming so a second question can't start mid-answer"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"condition": "A suggestion needs a secondary action such as dismiss",
|
|
88
|
+
"decision": "Put a small IconButton with an aria-label in ChatSuggestionActions and stop click propagation in its handler",
|
|
89
|
+
"reason": "Otherwise the click also triggers the suggestion's onClick"
|
|
90
|
+
}
|
|
91
|
+
],
|
|
92
|
+
"relatedComponents": [
|
|
93
|
+
"web-chat-ui/chat-input",
|
|
94
|
+
"web-chat-ui/canvas-shell",
|
|
95
|
+
"web-chat-ui/chat-thread",
|
|
96
|
+
"ui/chip",
|
|
97
|
+
"ui/empty-state"
|
|
98
|
+
],
|
|
99
|
+
"tokenReferences": {
|
|
100
|
+
"source": "packages/design-system/src/tailwind.css",
|
|
101
|
+
"categories": [
|
|
102
|
+
"typography-text-secondary",
|
|
103
|
+
"layout-accent-low-background-hover-default",
|
|
104
|
+
"secondary-main"
|
|
105
|
+
],
|
|
106
|
+
"rule": "Use the tokens the parts already apply; override with token utilities through className only."
|
|
107
|
+
}
|
|
108
|
+
}
|