@ctrl-ui/react 0.8.0
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/README.md +70 -0
- package/dist/action-bar.d.ts +44 -0
- package/dist/action-bar.js +89 -0
- package/dist/activity.d.ts +53 -0
- package/dist/activity.js +188 -0
- package/dist/audio-recorder.d.ts +32 -0
- package/dist/audio-recorder.js +235 -0
- package/dist/audio-visualizer.d.ts +12 -0
- package/dist/audio-visualizer.js +58 -0
- package/dist/blocks/chat.d.ts +10 -0
- package/dist/blocks/chat.js +12 -0
- package/dist/blocks/coding-agent.d.ts +61 -0
- package/dist/blocks/coding-agent.js +255 -0
- package/dist/blocks/file-explorer-data.d.ts +57 -0
- package/dist/blocks/file-explorer-data.js +74 -0
- package/dist/blocks/file-explorer.d.ts +24 -0
- package/dist/blocks/file-explorer.js +427 -0
- package/dist/blocks/settings-data.d.ts +36 -0
- package/dist/blocks/settings-data.js +66 -0
- package/dist/blocks/settings.d.ts +19 -0
- package/dist/blocks/settings.js +282 -0
- package/dist/blocks/theme-toggle.d.ts +43 -0
- package/dist/blocks/theme-toggle.js +180 -0
- package/dist/chat-composer-attachment.d.ts +55 -0
- package/dist/chat-composer-attachment.js +267 -0
- package/dist/chat-composer-editor/extensions/mention.d.ts +14 -0
- package/dist/chat-composer-editor/extensions/mention.js +278 -0
- package/dist/chat-composer-editor/ghost.d.ts +5 -0
- package/dist/chat-composer-editor/ghost.js +55 -0
- package/dist/chat-composer-editor/schema.d.ts +6 -0
- package/dist/chat-composer-editor/schema.js +25 -0
- package/dist/chat-composer-editor/serialize.d.ts +6 -0
- package/dist/chat-composer-editor/serialize.js +16 -0
- package/dist/chat-composer-editor/types.d.ts +29 -0
- package/dist/chat-composer-editor/types.js +0 -0
- package/dist/chat-composer-editor.d.ts +9 -0
- package/dist/chat-composer-editor.js +154 -0
- package/dist/chat-composer.d.ts +60 -0
- package/dist/chat-composer.js +134 -0
- package/dist/chat-layout.d.ts +27 -0
- package/dist/chat-layout.js +114 -0
- package/dist/chat-message.d.ts +31 -0
- package/dist/chat-message.js +95 -0
- package/dist/code-block-editor.d.ts +59 -0
- package/dist/code-block-editor.js +250 -0
- package/dist/context-model.d.ts +33 -0
- package/dist/context-model.js +52 -0
- package/dist/context.d.ts +47 -0
- package/dist/context.js +335 -0
- package/dist/control-props.d.ts +28 -0
- package/dist/control-props.js +4 -0
- package/dist/control-variants.d.ts +8 -0
- package/dist/control-variants.js +14 -0
- package/dist/dynamic-notification-glass.d.ts +10 -0
- package/dist/dynamic-notification-glass.js +311 -0
- package/dist/dynamic-notification-liquid.d.ts +24 -0
- package/dist/dynamic-notification-liquid.js +682 -0
- package/dist/dynamic-notification-siri-wave.d.ts +4 -0
- package/dist/dynamic-notification-siri-wave.js +82 -0
- package/dist/dynamic-notification.d.ts +74 -0
- package/dist/dynamic-notification.js +342 -0
- package/dist/environment-variables.d.ts +124 -0
- package/dist/environment-variables.js +492 -0
- package/dist/extensions/create-track-highlight.d.ts +12 -0
- package/dist/extensions/create-track-highlight.js +147 -0
- package/dist/extensions/track-highlight.d.ts +22 -0
- package/dist/extensions/track-highlight.js +52 -0
- package/dist/hooks/use-audio-recorder.d.ts +107 -0
- package/dist/hooks/use-audio-recorder.js +577 -0
- package/dist/hooks/use-chat-composer.d.ts +56 -0
- package/dist/hooks/use-chat-composer.js +63 -0
- package/dist/hooks/use-chat-message.d.ts +28 -0
- package/dist/hooks/use-chat-message.js +24 -0
- package/dist/hooks/use-color-area.d.ts +18 -0
- package/dist/hooks/use-color-area.js +60 -0
- package/dist/hooks/use-copy-to-clipboard.d.ts +22 -0
- package/dist/hooks/use-copy-to-clipboard.js +90 -0
- package/dist/hooks/use-dropzone.d.ts +59 -0
- package/dist/hooks/use-dropzone.js +372 -0
- package/dist/hooks/use-dynamic-notification.d.ts +37 -0
- package/dist/hooks/use-dynamic-notification.js +87 -0
- package/dist/hooks/use-environment-variables.d.ts +51 -0
- package/dist/hooks/use-environment-variables.js +188 -0
- package/dist/hooks/use-mobile.d.ts +5 -0
- package/dist/hooks/use-mobile.js +29 -0
- package/dist/hooks/use-textarea-trigger-menu.d.ts +8 -0
- package/dist/hooks/use-textarea-trigger-menu.js +69 -0
- package/dist/hooks/use-trigger-menu.d.ts +49 -0
- package/dist/hooks/use-trigger-menu.js +102 -0
- package/dist/hooks/use-user-ask.d.ts +48 -0
- package/dist/hooks/use-user-ask.js +167 -0
- package/dist/inline-attachment.d.ts +37 -0
- package/dist/inline-attachment.js +192 -0
- package/dist/inline-citation.d.ts +56 -0
- package/dist/inline-citation.js +319 -0
- package/dist/knob-contracts/accordion-knobs.d.ts +5 -0
- package/dist/knob-contracts/accordion-knobs.js +9 -0
- package/dist/knob-contracts/action-bar-knobs.d.ts +5 -0
- package/dist/knob-contracts/action-bar-knobs.js +4 -0
- package/dist/knob-contracts/activity-knobs.d.ts +5 -0
- package/dist/knob-contracts/activity-knobs.js +9 -0
- package/dist/knob-contracts/alert-knobs.d.ts +5 -0
- package/dist/knob-contracts/alert-knobs.js +9 -0
- package/dist/knob-contracts/audio-recorder-knobs.d.ts +5 -0
- package/dist/knob-contracts/audio-recorder-knobs.js +9 -0
- package/dist/knob-contracts/audio-visualizer-knobs.d.ts +5 -0
- package/dist/knob-contracts/audio-visualizer-knobs.js +9 -0
- package/dist/knob-contracts/avatar-knobs.d.ts +5 -0
- package/dist/knob-contracts/avatar-knobs.js +9 -0
- package/dist/knob-contracts/badge-knobs.d.ts +5 -0
- package/dist/knob-contracts/badge-knobs.js +9 -0
- package/dist/knob-contracts/button-group-knobs.d.ts +5 -0
- package/dist/knob-contracts/button-group-knobs.js +9 -0
- package/dist/knob-contracts/button-knobs.d.ts +5 -0
- package/dist/knob-contracts/button-knobs.js +25 -0
- package/dist/knob-contracts/calendar-knobs.d.ts +5 -0
- package/dist/knob-contracts/calendar-knobs.js +10 -0
- package/dist/knob-contracts/card-knobs.d.ts +5 -0
- package/dist/knob-contracts/card-knobs.js +11 -0
- package/dist/knob-contracts/chat-composer-attachment-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-composer-attachment-knobs.js +11 -0
- package/dist/knob-contracts/chat-composer-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-composer-knobs.js +18 -0
- package/dist/knob-contracts/chat-layout-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-layout-knobs.js +11 -0
- package/dist/knob-contracts/chat-message-knobs.d.ts +5 -0
- package/dist/knob-contracts/chat-message-knobs.js +17 -0
- package/dist/knob-contracts/choice-knobs.d.ts +5 -0
- package/dist/knob-contracts/choice-knobs.js +9 -0
- package/dist/knob-contracts/code-block-editor-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-block-editor-knobs.js +11 -0
- package/dist/knob-contracts/code-diff-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-diff-knobs.js +18 -0
- package/dist/knob-contracts/code-knobs.d.ts +5 -0
- package/dist/knob-contracts/code-knobs.js +11 -0
- package/dist/knob-contracts/collapsible-knobs.d.ts +5 -0
- package/dist/knob-contracts/collapsible-knobs.js +4 -0
- package/dist/knob-contracts/color-picker-knobs.d.ts +5 -0
- package/dist/knob-contracts/color-picker-knobs.js +12 -0
- package/dist/knob-contracts/context-knobs.d.ts +5 -0
- package/dist/knob-contracts/context-knobs.js +13 -0
- package/dist/knob-contracts/dockable-panel-knobs.d.ts +5 -0
- package/dist/knob-contracts/dockable-panel-knobs.js +12 -0
- package/dist/knob-contracts/dropzone-knobs.d.ts +5 -0
- package/dist/knob-contracts/dropzone-knobs.js +11 -0
- package/dist/knob-contracts/dynamic-notification-knobs.d.ts +5 -0
- package/dist/knob-contracts/dynamic-notification-knobs.js +18 -0
- package/dist/knob-contracts/empty-knobs.d.ts +5 -0
- package/dist/knob-contracts/empty-knobs.js +12 -0
- package/dist/knob-contracts/environment-variables-knobs.d.ts +5 -0
- package/dist/knob-contracts/environment-variables-knobs.js +11 -0
- package/dist/knob-contracts/field-knobs.d.ts +5 -0
- package/dist/knob-contracts/field-knobs.js +16 -0
- package/dist/knob-contracts/gradient-editor-knobs.d.ts +5 -0
- package/dist/knob-contracts/gradient-editor-knobs.js +13 -0
- package/dist/knob-contracts/infinite-canvas-knobs.d.ts +5 -0
- package/dist/knob-contracts/infinite-canvas-knobs.js +13 -0
- package/dist/knob-contracts/inline-attachment-knobs.d.ts +5 -0
- package/dist/knob-contracts/inline-attachment-knobs.js +14 -0
- package/dist/knob-contracts/inline-citation-knobs.d.ts +5 -0
- package/dist/knob-contracts/inline-citation-knobs.js +14 -0
- package/dist/knob-contracts/item-knobs.d.ts +5 -0
- package/dist/knob-contracts/item-knobs.js +10 -0
- package/dist/knob-contracts/kbd-knobs.d.ts +5 -0
- package/dist/knob-contracts/kbd-knobs.js +10 -0
- package/dist/knob-contracts/markdown-block-knobs.d.ts +5 -0
- package/dist/knob-contracts/markdown-block-knobs.js +11 -0
- package/dist/knob-contracts/markdown-knobs.d.ts +5 -0
- package/dist/knob-contracts/markdown-knobs.js +14 -0
- package/dist/knob-contracts/morphing-panel-knobs.d.ts +5 -0
- package/dist/knob-contracts/morphing-panel-knobs.js +11 -0
- package/dist/knob-contracts/pagination-knobs.d.ts +5 -0
- package/dist/knob-contracts/pagination-knobs.js +10 -0
- package/dist/knob-contracts/phone-input-knobs.d.ts +5 -0
- package/dist/knob-contracts/phone-input-knobs.js +10 -0
- package/dist/knob-contracts/popup-knobs.d.ts +5 -0
- package/dist/knob-contracts/popup-knobs.js +21 -0
- package/dist/knob-contracts/range-knobs.d.ts +5 -0
- package/dist/knob-contracts/range-knobs.js +13 -0
- package/dist/knob-contracts/resizable-knobs.d.ts +5 -0
- package/dist/knob-contracts/resizable-knobs.js +14 -0
- package/dist/knob-contracts/rich-tooltip-knobs.d.ts +5 -0
- package/dist/knob-contracts/rich-tooltip-knobs.js +13 -0
- package/dist/knob-contracts/scroll-area-knobs.d.ts +5 -0
- package/dist/knob-contracts/scroll-area-knobs.js +8 -0
- package/dist/knob-contracts/separator-knobs.d.ts +5 -0
- package/dist/knob-contracts/separator-knobs.js +4 -0
- package/dist/knob-contracts/sidebar-knobs.d.ts +5 -0
- package/dist/knob-contracts/sidebar-knobs.js +26 -0
- package/dist/knob-contracts/skeleton-knobs.d.ts +5 -0
- package/dist/knob-contracts/skeleton-knobs.js +4 -0
- package/dist/knob-contracts/source-badge-knobs.d.ts +5 -0
- package/dist/knob-contracts/source-badge-knobs.js +11 -0
- package/dist/knob-contracts/spinner-knobs.d.ts +5 -0
- package/dist/knob-contracts/spinner-knobs.js +4 -0
- package/dist/knob-contracts/stepper-knobs.d.ts +5 -0
- package/dist/knob-contracts/stepper-knobs.js +11 -0
- package/dist/knob-contracts/switch-knobs.d.ts +5 -0
- package/dist/knob-contracts/switch-knobs.js +12 -0
- package/dist/knob-contracts/table-knobs.d.ts +5 -0
- package/dist/knob-contracts/table-knobs.js +12 -0
- package/dist/knob-contracts/table-of-contents-knobs.d.ts +5 -0
- package/dist/knob-contracts/table-of-contents-knobs.js +8 -0
- package/dist/knob-contracts/tabs-knobs.d.ts +5 -0
- package/dist/knob-contracts/tabs-knobs.js +16 -0
- package/dist/knob-contracts/task-list-knobs.d.ts +5 -0
- package/dist/knob-contracts/task-list-knobs.js +14 -0
- package/dist/knob-contracts/thread-rail-knobs.d.ts +5 -0
- package/dist/knob-contracts/thread-rail-knobs.js +14 -0
- package/dist/knob-contracts/timeline-knobs.d.ts +5 -0
- package/dist/knob-contracts/timeline-knobs.js +12 -0
- package/dist/knob-contracts/toolbar-knobs.d.ts +5 -0
- package/dist/knob-contracts/toolbar-knobs.js +20 -0
- package/dist/knob-contracts/track-highlight-knobs.d.ts +5 -0
- package/dist/knob-contracts/track-highlight-knobs.js +11 -0
- package/dist/knob-contracts/transcript-divider-knobs.d.ts +5 -0
- package/dist/knob-contracts/transcript-divider-knobs.js +10 -0
- package/dist/knob-contracts/tree-knobs.d.ts +5 -0
- package/dist/knob-contracts/tree-knobs.js +13 -0
- package/dist/knob-contracts/user-ask-knobs.d.ts +5 -0
- package/dist/knob-contracts/user-ask-knobs.js +17 -0
- package/dist/lib/cn.d.ts +5 -0
- package/dist/lib/cn.js +34 -0
- package/dist/lib/code-block-shiki.d.ts +9 -0
- package/dist/lib/code-block-shiki.js +6 -0
- package/dist/lib/code-tokens.d.ts +28 -0
- package/dist/lib/code-tokens.js +160 -0
- package/dist/lib/color.d.ts +72 -0
- package/dist/lib/color.js +490 -0
- package/dist/lib/contrast.d.ts +30 -0
- package/dist/lib/contrast.js +64 -0
- package/dist/lib/diff.d.ts +50 -0
- package/dist/lib/diff.js +315 -0
- package/dist/lib/dropzone-validation.d.ts +66 -0
- package/dist/lib/dropzone-validation.js +228 -0
- package/dist/lib/env-file.d.ts +28 -0
- package/dist/lib/env-file.js +218 -0
- package/dist/lib/format-audio-recorder-duration.d.ts +4 -0
- package/dist/lib/format-audio-recorder-duration.js +7 -0
- package/dist/lib/liquid-glass-optics.d.ts +4 -0
- package/dist/lib/liquid-glass-optics.js +96 -0
- package/dist/lib/phone-input-format.d.ts +6 -0
- package/dist/lib/phone-input-format.js +26 -0
- package/dist/lib/phone-number.d.ts +18 -0
- package/dist/lib/phone-number.js +28 -0
- package/dist/lib/trigger-detect.d.ts +15 -0
- package/dist/lib/trigger-detect.js +77 -0
- package/dist/markdown-block.d.ts +25 -0
- package/dist/markdown-block.js +77 -0
- package/dist/skin.config.d.ts +5 -0
- package/dist/skin.config.js +4 -0
- package/dist/skin.d.ts +69 -0
- package/dist/skin.js +62 -0
- package/dist/source-badge.d.ts +23 -0
- package/dist/source-badge.js +72 -0
- package/dist/styles/chat-composer-editor.css +44 -0
- package/dist/styles/code.css +57 -0
- package/dist/styles/effects.css +126 -0
- package/dist/styles/index.css +81 -0
- package/dist/styles/recipes/accordion.css +87 -0
- package/dist/styles/recipes/action-bar.css +19 -0
- package/dist/styles/recipes/activity.css +129 -0
- package/dist/styles/recipes/alert.css +75 -0
- package/dist/styles/recipes/audio-recorder.css +102 -0
- package/dist/styles/recipes/audio-visualizer.css +90 -0
- package/dist/styles/recipes/avatar.css +52 -0
- package/dist/styles/recipes/badge.css +110 -0
- package/dist/styles/recipes/button-group.css +64 -0
- package/dist/styles/recipes/button.css +305 -0
- package/dist/styles/recipes/calendar.css +152 -0
- package/dist/styles/recipes/card.css +93 -0
- package/dist/styles/recipes/chat-composer-attachment.css +177 -0
- package/dist/styles/recipes/chat-composer.css +195 -0
- package/dist/styles/recipes/chat-layout.css +108 -0
- package/dist/styles/recipes/chat-message.css +160 -0
- package/dist/styles/recipes/choice.css +108 -0
- package/dist/styles/recipes/code-block-editor.css +136 -0
- package/dist/styles/recipes/code-diff.css +256 -0
- package/dist/styles/recipes/code.css +136 -0
- package/dist/styles/recipes/collapsible.css +27 -0
- package/dist/styles/recipes/color-picker-details.css +61 -0
- package/dist/styles/recipes/color-picker-values.css +117 -0
- package/dist/styles/recipes/color-picker.css +158 -0
- package/dist/styles/recipes/context.css +237 -0
- package/dist/styles/recipes/dockable-panel.css +106 -0
- package/dist/styles/recipes/dropzone.css +149 -0
- package/dist/styles/recipes/dynamic-notification-input.css +29 -0
- package/dist/styles/recipes/dynamic-notification-motion.css +298 -0
- package/dist/styles/recipes/dynamic-notification.css +241 -0
- package/dist/styles/recipes/empty.css +96 -0
- package/dist/styles/recipes/environment-variables.css +173 -0
- package/dist/styles/recipes/field-parts.css +148 -0
- package/dist/styles/recipes/field.css +234 -0
- package/dist/styles/recipes/gradient-editor.css +109 -0
- package/dist/styles/recipes/infinite-canvas.css +78 -0
- package/dist/styles/recipes/inline-attachment.css +182 -0
- package/dist/styles/recipes/inline-citation.css +174 -0
- package/dist/styles/recipes/item.css +107 -0
- package/dist/styles/recipes/kbd.css +55 -0
- package/dist/styles/recipes/markdown-block.css +75 -0
- package/dist/styles/recipes/markdown.css +204 -0
- package/dist/styles/recipes/morphing-panel.css +123 -0
- package/dist/styles/recipes/pagination.css +86 -0
- package/dist/styles/recipes/phone-input.css +105 -0
- package/dist/styles/recipes/popup-controls.css +59 -0
- package/dist/styles/recipes/popup-drawer.css +162 -0
- package/dist/styles/recipes/popup-lists.css +198 -0
- package/dist/styles/recipes/popup-motion.css +94 -0
- package/dist/styles/recipes/popup-toast.css +126 -0
- package/dist/styles/recipes/popup.css +396 -0
- package/dist/styles/recipes/range.css +259 -0
- package/dist/styles/recipes/resizable.css +170 -0
- package/dist/styles/recipes/rich-tooltip.css +272 -0
- package/dist/styles/recipes/scroll-area.css +59 -0
- package/dist/styles/recipes/separator.css +12 -0
- package/dist/styles/recipes/sidebar.css +345 -0
- package/dist/styles/recipes/skeleton.css +23 -0
- package/dist/styles/recipes/source-badge.css +77 -0
- package/dist/styles/recipes/spinner.css +33 -0
- package/dist/styles/recipes/stepper.css +178 -0
- package/dist/styles/recipes/switch.css +149 -0
- package/dist/styles/recipes/table-of-contents.css +107 -0
- package/dist/styles/recipes/table.css +124 -0
- package/dist/styles/recipes/tabs.css +235 -0
- package/dist/styles/recipes/task-list.css +146 -0
- package/dist/styles/recipes/thread-rail.css +247 -0
- package/dist/styles/recipes/timeline.css +107 -0
- package/dist/styles/recipes/toolbar.css +260 -0
- package/dist/styles/recipes/track-highlight.css +73 -0
- package/dist/styles/recipes/transcript-divider.css +64 -0
- package/dist/styles/recipes/tree.css +137 -0
- package/dist/styles/recipes/user-ask-details.css +45 -0
- package/dist/styles/recipes/user-ask.css +204 -0
- package/dist/styles/skin-theme.css +137 -0
- package/dist/styles/skin.css +143 -0
- package/dist/styles/theme.css +628 -0
- package/dist/styles/type-scale.css +45 -0
- package/dist/surface-variants.d.ts +6 -0
- package/dist/surface-variants.js +16 -0
- package/dist/task-list.d.ts +34 -0
- package/dist/task-list.js +177 -0
- package/dist/thread-rail.d.ts +52 -0
- package/dist/thread-rail.js +190 -0
- package/dist/transcript-divider.d.ts +15 -0
- package/dist/transcript-divider.js +25 -0
- package/dist/ui/accordion.d.ts +31 -0
- package/dist/ui/accordion.js +60 -0
- package/dist/ui/alert-dialog.d.ts +36 -0
- package/dist/ui/alert-dialog.js +100 -0
- package/dist/ui/alert.d.ts +21 -0
- package/dist/ui/alert.js +36 -0
- package/dist/ui/aspect-ratio.d.ts +8 -0
- package/dist/ui/aspect-ratio.js +17 -0
- package/dist/ui/autocomplete.d.ts +70 -0
- package/dist/ui/autocomplete.js +150 -0
- package/dist/ui/avatar.d.ts +24 -0
- package/dist/ui/avatar.js +44 -0
- package/dist/ui/badge.d.ts +20 -0
- package/dist/ui/badge.js +36 -0
- package/dist/ui/button-group.d.ts +24 -0
- package/dist/ui/button-group.js +45 -0
- package/dist/ui/button.d.ts +36 -0
- package/dist/ui/button.js +104 -0
- package/dist/ui/calendar.d.ts +11 -0
- package/dist/ui/calendar.js +160 -0
- package/dist/ui/card.d.ts +36 -0
- package/dist/ui/card.js +70 -0
- package/dist/ui/checkbox-group.d.ts +11 -0
- package/dist/ui/checkbox-group.js +16 -0
- package/dist/ui/checkbox.d.ts +23 -0
- package/dist/ui/checkbox.js +58 -0
- package/dist/ui/code-diff.d.ts +28 -0
- package/dist/ui/code-diff.js +561 -0
- package/dist/ui/code.d.ts +62 -0
- package/dist/ui/code.js +292 -0
- package/dist/ui/collapsible.d.ts +31 -0
- package/dist/ui/collapsible.js +72 -0
- package/dist/ui/color-picker.d.ts +137 -0
- package/dist/ui/color-picker.js +797 -0
- package/dist/ui/combobox-disabled-selection.d.ts +5 -0
- package/dist/ui/combobox-disabled-selection.js +11 -0
- package/dist/ui/combobox.d.ts +70 -0
- package/dist/ui/combobox.js +194 -0
- package/dist/ui/command.d.ts +44 -0
- package/dist/ui/command.js +166 -0
- package/dist/ui/context-menu.d.ts +86 -0
- package/dist/ui/context-menu.js +202 -0
- package/dist/ui/dialog.d.ts +38 -0
- package/dist/ui/dialog.js +124 -0
- package/dist/ui/dockable-panel-geometry.d.ts +18 -0
- package/dist/ui/dockable-panel-geometry.js +17 -0
- package/dist/ui/dockable-panel.d.ts +58 -0
- package/dist/ui/dockable-panel.js +366 -0
- package/dist/ui/drawer.d.ts +42 -0
- package/dist/ui/drawer.js +182 -0
- package/dist/ui/dropdown-menu.d.ts +46 -0
- package/dist/ui/dropdown-menu.js +89 -0
- package/dist/ui/dropzone.d.ts +66 -0
- package/dist/ui/dropzone.js +311 -0
- package/dist/ui/empty.d.ts +28 -0
- package/dist/ui/empty.js +59 -0
- package/dist/ui/field.d.ts +64 -0
- package/dist/ui/field.js +166 -0
- package/dist/ui/form.d.ts +10 -0
- package/dist/ui/form.js +17 -0
- package/dist/ui/gradient-editor.d.ts +47 -0
- package/dist/ui/gradient-editor.js +301 -0
- package/dist/ui/hover-card.d.ts +25 -0
- package/dist/ui/hover-card.js +46 -0
- package/dist/ui/infinite-canvas.d.ts +40 -0
- package/dist/ui/infinite-canvas.js +278 -0
- package/dist/ui/input-group.d.ts +21 -0
- package/dist/ui/input-group.js +44 -0
- package/dist/ui/input-otp.d.ts +38 -0
- package/dist/ui/input-otp.js +45 -0
- package/dist/ui/input.d.ts +12 -0
- package/dist/ui/input.js +18 -0
- package/dist/ui/item.d.ts +46 -0
- package/dist/ui/item.js +110 -0
- package/dist/ui/kbd.d.ts +12 -0
- package/dist/ui/kbd.js +23 -0
- package/dist/ui/markdown-elements.d.ts +52 -0
- package/dist/ui/markdown-elements.js +211 -0
- package/dist/ui/markdown.d.ts +14 -0
- package/dist/ui/markdown.js +31 -0
- package/dist/ui/menubar.d.ts +74 -0
- package/dist/ui/menubar.js +162 -0
- package/dist/ui/meter.d.ts +34 -0
- package/dist/ui/meter.js +57 -0
- package/dist/ui/morphing-panel.d.ts +24 -0
- package/dist/ui/morphing-panel.js +87 -0
- package/dist/ui/native-select.d.ts +12 -0
- package/dist/ui/native-select.js +41 -0
- package/dist/ui/navigation-menu.d.ts +51 -0
- package/dist/ui/navigation-menu.js +135 -0
- package/dist/ui/number-field.d.ts +72 -0
- package/dist/ui/number-field.js +124 -0
- package/dist/ui/pagination.d.ts +26 -0
- package/dist/ui/pagination.js +77 -0
- package/dist/ui/phone-input.d.ts +30 -0
- package/dist/ui/phone-input.js +263 -0
- package/dist/ui/popover.d.ts +34 -0
- package/dist/ui/popover.js +87 -0
- package/dist/ui/progress.d.ts +34 -0
- package/dist/ui/progress.js +57 -0
- package/dist/ui/radio-group.d.ts +29 -0
- package/dist/ui/radio-group.js +37 -0
- package/dist/ui/resizable.d.ts +56 -0
- package/dist/ui/resizable.js +82 -0
- package/dist/ui/responsive-dialog.d.ts +18 -0
- package/dist/ui/responsive-dialog.js +121 -0
- package/dist/ui/rich-tooltip-tour.d.ts +12 -0
- package/dist/ui/rich-tooltip-tour.js +20 -0
- package/dist/ui/rich-tooltip.d.ts +83 -0
- package/dist/ui/rich-tooltip.js +331 -0
- package/dist/ui/scroll-area.d.ts +25 -0
- package/dist/ui/scroll-area.js +93 -0
- package/dist/ui/select.d.ts +44 -0
- package/dist/ui/select.js +124 -0
- package/dist/ui/separator.d.ts +9 -0
- package/dist/ui/separator.js +16 -0
- package/dist/ui/sheet.d.ts +25 -0
- package/dist/ui/sheet.js +76 -0
- package/dist/ui/sidebar.d.ts +88 -0
- package/dist/ui/sidebar.js +362 -0
- package/dist/ui/skeleton.d.ts +8 -0
- package/dist/ui/skeleton.js +13 -0
- package/dist/ui/slider.d.ts +24 -0
- package/dist/ui/slider.js +114 -0
- package/dist/ui/spinner.d.ts +12 -0
- package/dist/ui/spinner.js +26 -0
- package/dist/ui/stepper.d.ts +58 -0
- package/dist/ui/stepper.js +232 -0
- package/dist/ui/switch.d.ts +26 -0
- package/dist/ui/switch.js +71 -0
- package/dist/ui/table-of-contents.d.ts +22 -0
- package/dist/ui/table-of-contents.js +181 -0
- package/dist/ui/table.d.ts +37 -0
- package/dist/ui/table.js +83 -0
- package/dist/ui/tabs.d.ts +36 -0
- package/dist/ui/tabs.js +127 -0
- package/dist/ui/textarea.d.ts +9 -0
- package/dist/ui/textarea.js +16 -0
- package/dist/ui/timeline.d.ts +40 -0
- package/dist/ui/timeline.js +80 -0
- package/dist/ui/toast.d.ts +28 -0
- package/dist/ui/toast.js +132 -0
- package/dist/ui/toggle.d.ts +20 -0
- package/dist/ui/toggle.js +71 -0
- package/dist/ui/toolbar.d.ts +40 -0
- package/dist/ui/toolbar.js +72 -0
- package/dist/ui/tooltip.d.ts +27 -0
- package/dist/ui/tooltip.js +93 -0
- package/dist/ui/tree.d.ts +56 -0
- package/dist/ui/tree.js +438 -0
- package/dist/ui/trigger-menu.d.ts +46 -0
- package/dist/ui/trigger-menu.js +116 -0
- package/dist/user-ask.d.ts +50 -0
- package/dist/user-ask.js +398 -0
- package/package.json +115 -0
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "./lib/cn.js";
|
|
3
|
+
import { Button } from "./ui/button.js";
|
|
4
|
+
import { ScrollArea } from "./ui/scroll-area.js";
|
|
5
|
+
import { createContext, useContext } from "react";
|
|
6
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
import { XIcon } from "lucide-react";
|
|
8
|
+
//#region src/chat-composer-attachment.tsx
|
|
9
|
+
const ChatComposerAttachmentContext = createContext(null);
|
|
10
|
+
function useChatComposerAttachmentContext() {
|
|
11
|
+
const context = useContext(ChatComposerAttachmentContext);
|
|
12
|
+
if (!context) throw new Error("ChatComposerAttachment compound components must be rendered inside <ChatComposerAttachment>.");
|
|
13
|
+
return context;
|
|
14
|
+
}
|
|
15
|
+
function extensionFromName(name) {
|
|
16
|
+
return name.match(/\.([a-z0-9]+)$/i)?.[1]?.toLowerCase() ?? "";
|
|
17
|
+
}
|
|
18
|
+
function kindFromAttachment(type, name) {
|
|
19
|
+
const mime = type?.toLowerCase() ?? "";
|
|
20
|
+
const extension = extensionFromName(name);
|
|
21
|
+
if (mime.startsWith("image/") || [
|
|
22
|
+
"avif",
|
|
23
|
+
"gif",
|
|
24
|
+
"heic",
|
|
25
|
+
"jpeg",
|
|
26
|
+
"jpg",
|
|
27
|
+
"png",
|
|
28
|
+
"webp"
|
|
29
|
+
].includes(extension)) return "image";
|
|
30
|
+
if (mime === "application/pdf" || extension === "pdf") return "pdf";
|
|
31
|
+
if (mime.includes("spreadsheet") || mime.includes("excel") || mime.includes("csv") || [
|
|
32
|
+
"csv",
|
|
33
|
+
"numbers",
|
|
34
|
+
"ods",
|
|
35
|
+
"tsv",
|
|
36
|
+
"xls",
|
|
37
|
+
"xlsx"
|
|
38
|
+
].includes(extension)) return "spreadsheet";
|
|
39
|
+
if (mime.startsWith("audio/") || [
|
|
40
|
+
"aac",
|
|
41
|
+
"flac",
|
|
42
|
+
"m4a",
|
|
43
|
+
"mp3",
|
|
44
|
+
"ogg",
|
|
45
|
+
"wav"
|
|
46
|
+
].includes(extension)) return "audio";
|
|
47
|
+
if (mime.startsWith("video/") || [
|
|
48
|
+
"avi",
|
|
49
|
+
"mov",
|
|
50
|
+
"mp4",
|
|
51
|
+
"webm"
|
|
52
|
+
].includes(extension)) return "video";
|
|
53
|
+
if (mime.includes("zip") || [
|
|
54
|
+
"7z",
|
|
55
|
+
"gz",
|
|
56
|
+
"rar",
|
|
57
|
+
"tar",
|
|
58
|
+
"zip"
|
|
59
|
+
].includes(extension)) return "archive";
|
|
60
|
+
if (mime.includes("document") || mime.includes("text") || [
|
|
61
|
+
"doc",
|
|
62
|
+
"docx",
|
|
63
|
+
"md",
|
|
64
|
+
"rtf",
|
|
65
|
+
"txt"
|
|
66
|
+
].includes(extension)) return "document";
|
|
67
|
+
return "file";
|
|
68
|
+
}
|
|
69
|
+
function progressValue(progress) {
|
|
70
|
+
if (typeof progress !== "number" || Number.isNaN(progress)) return void 0;
|
|
71
|
+
return Math.min(100, Math.max(0, progress));
|
|
72
|
+
}
|
|
73
|
+
function fallbackLabel(kind, extension) {
|
|
74
|
+
if (extension && extension.length <= 4) return extension.toUpperCase();
|
|
75
|
+
return {
|
|
76
|
+
image: "IMG",
|
|
77
|
+
pdf: "PDF",
|
|
78
|
+
spreadsheet: "XLS",
|
|
79
|
+
document: "DOC",
|
|
80
|
+
archive: "ZIP",
|
|
81
|
+
audio: "AUD",
|
|
82
|
+
video: "VID",
|
|
83
|
+
file: "FILE"
|
|
84
|
+
}[kind];
|
|
85
|
+
}
|
|
86
|
+
function defaultDescription(context) {
|
|
87
|
+
const progress = progressValue(context.progress);
|
|
88
|
+
if (context.description) return context.description;
|
|
89
|
+
if (context.status === "uploading") return `Uploading ${Math.round(progress ?? 0)}%`;
|
|
90
|
+
if (context.status === "error") return "Upload failed";
|
|
91
|
+
return fallbackLabel(context.kind, context.extension);
|
|
92
|
+
}
|
|
93
|
+
function ChatComposerAttachments({ label = "Attachments", className, viewportClassName, children, ...props }) {
|
|
94
|
+
return /* @__PURE__ */ jsx("div", {
|
|
95
|
+
"data-control-ui": "chat-composer-attachments",
|
|
96
|
+
"data-control-family": "chat-composer-attachment",
|
|
97
|
+
"data-slot": "root",
|
|
98
|
+
className: cn("min-w-0", className),
|
|
99
|
+
...props,
|
|
100
|
+
children: /* @__PURE__ */ jsx(ScrollArea, {
|
|
101
|
+
"data-control-ui": "chat-composer-attachments",
|
|
102
|
+
"data-slot": "scroll",
|
|
103
|
+
"aria-label": label,
|
|
104
|
+
lockAxis: "y",
|
|
105
|
+
mask: true,
|
|
106
|
+
scrollbarVisibility: "hover",
|
|
107
|
+
className: "w-full",
|
|
108
|
+
viewportClassName,
|
|
109
|
+
children: /* @__PURE__ */ jsx("ul", {
|
|
110
|
+
"data-control-ui": "chat-composer-attachments",
|
|
111
|
+
"data-control-family": "chat-composer-attachment",
|
|
112
|
+
"data-slot": "list",
|
|
113
|
+
className: "flex w-max min-w-full list-none",
|
|
114
|
+
children
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
function ChatComposerAttachment({ name, type, description, status = "idle", progress: progressInput, previewUrl, kind, variant = "auto", onRemove, removeLabel, className, children, role, "aria-label": ariaLabel, ...props }) {
|
|
120
|
+
const resolvedKind = kind ?? kindFromAttachment(type, name);
|
|
121
|
+
let resolvedVariant;
|
|
122
|
+
if (variant === "auto") resolvedVariant = previewUrl || resolvedKind === "image" ? "preview" : "file";
|
|
123
|
+
else resolvedVariant = variant;
|
|
124
|
+
const extension = extensionFromName(name);
|
|
125
|
+
const progress = progressValue(progressInput);
|
|
126
|
+
return /* @__PURE__ */ jsx(ChatComposerAttachmentContext.Provider, {
|
|
127
|
+
value: {
|
|
128
|
+
name,
|
|
129
|
+
type,
|
|
130
|
+
description,
|
|
131
|
+
status,
|
|
132
|
+
progress,
|
|
133
|
+
previewUrl,
|
|
134
|
+
kind: resolvedKind,
|
|
135
|
+
variant: resolvedVariant,
|
|
136
|
+
extension,
|
|
137
|
+
onRemove,
|
|
138
|
+
removeLabel
|
|
139
|
+
},
|
|
140
|
+
children: /* @__PURE__ */ jsx("li", {
|
|
141
|
+
role,
|
|
142
|
+
"aria-label": ariaLabel ?? name,
|
|
143
|
+
"data-control-ui": "chat-composer-attachment",
|
|
144
|
+
"data-control-family": "chat-composer-attachment",
|
|
145
|
+
"data-slot": "root",
|
|
146
|
+
"data-surface": "panel",
|
|
147
|
+
"data-kind": resolvedKind,
|
|
148
|
+
"data-state": status,
|
|
149
|
+
"data-variant": resolvedVariant,
|
|
150
|
+
className: cn("relative shrink-0 overflow-hidden", "flex items-center", className),
|
|
151
|
+
...props,
|
|
152
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
153
|
+
/* @__PURE__ */ jsx(ChatComposerAttachmentPreview, {}),
|
|
154
|
+
resolvedVariant === "file" && /* @__PURE__ */ jsxs(ChatComposerAttachmentContent, { children: [/* @__PURE__ */ jsx(ChatComposerAttachmentTitle, {}), /* @__PURE__ */ jsx(ChatComposerAttachmentDescription, {})] }),
|
|
155
|
+
/* @__PURE__ */ jsx(ChatComposerAttachmentRemove, {}),
|
|
156
|
+
/* @__PURE__ */ jsx(ChatComposerAttachmentProgress, {})
|
|
157
|
+
] })
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
function ChatComposerAttachmentPreview({ className, children, ...props }) {
|
|
162
|
+
const context = useChatComposerAttachmentContext();
|
|
163
|
+
const label = fallbackLabel(context.kind, context.extension);
|
|
164
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
165
|
+
"data-control-ui": "chat-composer-attachment",
|
|
166
|
+
"data-control-family": "chat-composer-attachment",
|
|
167
|
+
"data-slot": "preview",
|
|
168
|
+
className: cn("relative grid shrink-0 place-items-center overflow-hidden", className),
|
|
169
|
+
...props,
|
|
170
|
+
children: [children ?? (context.previewUrl ? /* @__PURE__ */ jsx("img", {
|
|
171
|
+
src: context.previewUrl,
|
|
172
|
+
alt: context.name,
|
|
173
|
+
loading: "lazy",
|
|
174
|
+
decoding: "async",
|
|
175
|
+
className: "h-full w-auto max-w-full object-contain"
|
|
176
|
+
}) : /* @__PURE__ */ jsx("span", {
|
|
177
|
+
"data-control-ui": "chat-composer-attachment",
|
|
178
|
+
"data-control-family": "chat-composer-attachment",
|
|
179
|
+
"data-slot": "preview-label",
|
|
180
|
+
className: "uppercase",
|
|
181
|
+
children: label
|
|
182
|
+
})), context.status === "uploading" && /* @__PURE__ */ jsx("span", {
|
|
183
|
+
"aria-hidden": "true",
|
|
184
|
+
"data-control-ui": "chat-composer-attachment",
|
|
185
|
+
"data-control-family": "chat-composer-attachment",
|
|
186
|
+
"data-slot": "status",
|
|
187
|
+
className: "absolute right-1 top-1"
|
|
188
|
+
})]
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function ChatComposerAttachmentContent({ className, ...props }) {
|
|
192
|
+
return /* @__PURE__ */ jsx("div", {
|
|
193
|
+
"data-control-ui": "chat-composer-attachment",
|
|
194
|
+
"data-control-family": "chat-composer-attachment",
|
|
195
|
+
"data-slot": "content",
|
|
196
|
+
className: cn("min-w-0 flex-1", className),
|
|
197
|
+
...props
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
function ChatComposerAttachmentTitle({ className, children, ...props }) {
|
|
201
|
+
const { name } = useChatComposerAttachmentContext();
|
|
202
|
+
return /* @__PURE__ */ jsx("div", {
|
|
203
|
+
"data-control-ui": "chat-composer-attachment",
|
|
204
|
+
"data-control-family": "chat-composer-attachment",
|
|
205
|
+
"data-slot": "title",
|
|
206
|
+
className: cn("truncate", className),
|
|
207
|
+
...props,
|
|
208
|
+
children: children ?? name
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
function ChatComposerAttachmentDescription({ className, children, ...props }) {
|
|
212
|
+
const context = useChatComposerAttachmentContext();
|
|
213
|
+
return /* @__PURE__ */ jsx("div", {
|
|
214
|
+
"data-control-ui": "chat-composer-attachment",
|
|
215
|
+
"data-control-family": "chat-composer-attachment",
|
|
216
|
+
"data-slot": "description",
|
|
217
|
+
className: cn("truncate", className),
|
|
218
|
+
"data-state": context.status,
|
|
219
|
+
...props,
|
|
220
|
+
children: children ?? defaultDescription(context)
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
function ChatComposerAttachmentRemove({ className, onClick, children, "aria-label": ariaLabel, ...props }) {
|
|
224
|
+
const { name, onRemove, removeLabel } = useChatComposerAttachmentContext();
|
|
225
|
+
if (!onRemove) return null;
|
|
226
|
+
function handleClick(event) {
|
|
227
|
+
onClick?.(event);
|
|
228
|
+
if (!event.defaultPrevented) onRemove?.();
|
|
229
|
+
}
|
|
230
|
+
return /* @__PURE__ */ jsx(Button, {
|
|
231
|
+
"data-control-ui": "chat-composer-attachment",
|
|
232
|
+
"data-chat-composer-attachment-remove": "true",
|
|
233
|
+
"data-slot": "remove",
|
|
234
|
+
"aria-label": ariaLabel ?? removeLabel ?? `Remove ${name}`,
|
|
235
|
+
size: "xs",
|
|
236
|
+
variant: "solid",
|
|
237
|
+
className: cn("absolute right-1 top-1 z-10", className),
|
|
238
|
+
onClick: handleClick,
|
|
239
|
+
...props,
|
|
240
|
+
children: children ?? /* @__PURE__ */ jsx(XIcon, {
|
|
241
|
+
"aria-hidden": "true",
|
|
242
|
+
className: "size-3"
|
|
243
|
+
})
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
function ChatComposerAttachmentProgress({ className, children, style, ...props }) {
|
|
247
|
+
const { status, progress } = useChatComposerAttachmentContext();
|
|
248
|
+
if (status !== "uploading" && progress == null) return null;
|
|
249
|
+
return /* @__PURE__ */ jsx("div", {
|
|
250
|
+
"aria-hidden": "true",
|
|
251
|
+
"data-control-ui": "chat-composer-attachment",
|
|
252
|
+
"data-control-family": "chat-composer-attachment",
|
|
253
|
+
"data-slot": "progress",
|
|
254
|
+
className: cn("absolute inset-x-0 bottom-0", className),
|
|
255
|
+
style,
|
|
256
|
+
...props,
|
|
257
|
+
children: children ?? /* @__PURE__ */ jsx("div", {
|
|
258
|
+
"data-control-ui": "chat-composer-attachment",
|
|
259
|
+
"data-control-family": "chat-composer-attachment",
|
|
260
|
+
"data-slot": "progress-indicator",
|
|
261
|
+
className: "h-full",
|
|
262
|
+
style: { width: `${progress ?? 0}%` }
|
|
263
|
+
})
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
//#endregion
|
|
267
|
+
export { ChatComposerAttachment, ChatComposerAttachmentContent, ChatComposerAttachmentDescription, ChatComposerAttachmentPreview, ChatComposerAttachmentProgress, ChatComposerAttachmentRemove, ChatComposerAttachmentTitle, ChatComposerAttachments };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChatComposerEditorExtension } from "../types.js";
|
|
2
|
+
import { TriggerConfig, TriggerMenuItemData } from "../../hooks/use-trigger-menu.js";
|
|
3
|
+
import { Command } from "prosemirror-state";
|
|
4
|
+
//#region src/chat-composer-editor/extensions/mention.d.ts
|
|
5
|
+
declare const deleteMentionBackward: Command;
|
|
6
|
+
declare const deleteMentionForward: Command;
|
|
7
|
+
type MentionExtensionConfig<Item extends TriggerMenuItemData = TriggerMenuItemData> = {
|
|
8
|
+
triggers: readonly TriggerConfig<Item>[];
|
|
9
|
+
side?: "top" | "bottom";
|
|
10
|
+
align?: "start" | "center" | "end";
|
|
11
|
+
};
|
|
12
|
+
declare function mentionExtension<Item extends TriggerMenuItemData = TriggerMenuItemData>({ triggers, side, align }: MentionExtensionConfig<Item>): ChatComposerEditorExtension;
|
|
13
|
+
//#endregion
|
|
14
|
+
export { MentionExtensionConfig, deleteMentionBackward, deleteMentionForward, mentionExtension };
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { spawnExitGhost } from "../ghost.js";
|
|
3
|
+
import { detectTrigger } from "../../lib/trigger-detect.js";
|
|
4
|
+
import { useTriggerMenu } from "../../hooks/use-trigger-menu.js";
|
|
5
|
+
import { TriggerMenu, TriggerMenuEmpty, TriggerMenuIcon, TriggerMenuItem, TriggerMenuList } from "../../ui/trigger-menu.js";
|
|
6
|
+
import { useEffect } from "react";
|
|
7
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
//#region src/chat-composer-editor/extensions/mention.tsx
|
|
9
|
+
function attrString(value, fallback) {
|
|
10
|
+
return typeof value === "string" ? value : fallback;
|
|
11
|
+
}
|
|
12
|
+
const mentionNode = {
|
|
13
|
+
group: "inline",
|
|
14
|
+
inline: true,
|
|
15
|
+
atom: true,
|
|
16
|
+
selectable: true,
|
|
17
|
+
draggable: false,
|
|
18
|
+
attrs: {
|
|
19
|
+
id: { default: "" },
|
|
20
|
+
label: { default: "" },
|
|
21
|
+
kind: { default: "mention" },
|
|
22
|
+
icon: { default: null }
|
|
23
|
+
},
|
|
24
|
+
parseDOM: [{
|
|
25
|
+
tag: "span[data-mention]",
|
|
26
|
+
getAttrs: (dom) => {
|
|
27
|
+
if (typeof dom === "string") return false;
|
|
28
|
+
return {
|
|
29
|
+
id: dom.getAttribute("data-id") ?? "",
|
|
30
|
+
label: dom.textContent ?? "",
|
|
31
|
+
kind: dom.getAttribute("data-mention") ?? "mention",
|
|
32
|
+
icon: dom.getAttribute("data-icon")
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}],
|
|
36
|
+
toDOM: (node) => {
|
|
37
|
+
const label = attrString(node.attrs.label, "");
|
|
38
|
+
const id = attrString(node.attrs.id, "");
|
|
39
|
+
const kind = attrString(node.attrs.kind, "mention");
|
|
40
|
+
const icon = typeof node.attrs.icon === "string" ? node.attrs.icon : null;
|
|
41
|
+
const attrs = {
|
|
42
|
+
class: "inline-flex items-center align-baseline",
|
|
43
|
+
"data-control-ui": "chat-composer",
|
|
44
|
+
"data-control-family": "chat-composer",
|
|
45
|
+
"data-slot": "mention",
|
|
46
|
+
"data-mention": kind,
|
|
47
|
+
"data-id": id,
|
|
48
|
+
"data-icon": icon ?? "",
|
|
49
|
+
contenteditable: "false"
|
|
50
|
+
};
|
|
51
|
+
const labelSpan = [
|
|
52
|
+
"span",
|
|
53
|
+
{
|
|
54
|
+
class: "truncate",
|
|
55
|
+
"data-control-ui": "chat-composer",
|
|
56
|
+
"data-control-family": "chat-composer",
|
|
57
|
+
"data-slot": "mention-label"
|
|
58
|
+
},
|
|
59
|
+
label
|
|
60
|
+
];
|
|
61
|
+
return icon === null ? [
|
|
62
|
+
"span",
|
|
63
|
+
attrs,
|
|
64
|
+
labelSpan
|
|
65
|
+
] : [
|
|
66
|
+
"span",
|
|
67
|
+
attrs,
|
|
68
|
+
["img", {
|
|
69
|
+
src: icon,
|
|
70
|
+
alt: "",
|
|
71
|
+
class: "shrink-0",
|
|
72
|
+
"data-control-ui": "chat-composer",
|
|
73
|
+
"data-control-family": "chat-composer",
|
|
74
|
+
"data-slot": "mention-icon"
|
|
75
|
+
}],
|
|
76
|
+
labelSpan
|
|
77
|
+
];
|
|
78
|
+
},
|
|
79
|
+
leafText: (node) => `@${attrString(node.attrs.label, "")}`
|
|
80
|
+
};
|
|
81
|
+
const INACTIVE = {
|
|
82
|
+
active: false,
|
|
83
|
+
from: 0,
|
|
84
|
+
to: 0,
|
|
85
|
+
char: "",
|
|
86
|
+
query: "",
|
|
87
|
+
rect: null
|
|
88
|
+
};
|
|
89
|
+
function readEditorTrigger(view, triggerChars) {
|
|
90
|
+
const { selection } = view.state;
|
|
91
|
+
if (!selection.empty) return INACTIVE;
|
|
92
|
+
const { $from } = selection;
|
|
93
|
+
if (!$from.parent.isTextblock) return INACTIVE;
|
|
94
|
+
const start = $from.start();
|
|
95
|
+
const textBefore = view.state.doc.textBetween(start, $from.pos, void 0, () => "");
|
|
96
|
+
const match = detectTrigger(textBefore, triggerChars);
|
|
97
|
+
if (match === null) return INACTIVE;
|
|
98
|
+
const coords = view.coordsAtPos($from.pos);
|
|
99
|
+
return {
|
|
100
|
+
active: true,
|
|
101
|
+
from: start + match.start,
|
|
102
|
+
to: $from.pos,
|
|
103
|
+
char: match.char,
|
|
104
|
+
query: match.query,
|
|
105
|
+
rect: new DOMRect(coords.left, coords.top, 1, coords.bottom - coords.top)
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
function insertMention(view, from, to, attrs) {
|
|
109
|
+
const mention = view.state.schema.nodes.mention;
|
|
110
|
+
if (!mention) throw new Error("Mention extension requires a mention node in the editor schema.");
|
|
111
|
+
const node = mention.create({
|
|
112
|
+
id: attrs.id,
|
|
113
|
+
label: attrs.label,
|
|
114
|
+
kind: attrs.kind ?? "mention",
|
|
115
|
+
icon: attrs.icon ?? null
|
|
116
|
+
});
|
|
117
|
+
const transaction = view.state.tr.replaceWith(from, to, node);
|
|
118
|
+
transaction.insertText(" ");
|
|
119
|
+
view.dispatch(transaction);
|
|
120
|
+
view.focus();
|
|
121
|
+
}
|
|
122
|
+
function deleteTriggerToken(view, from, to) {
|
|
123
|
+
view.dispatch(view.state.tr.delete(from, to));
|
|
124
|
+
view.focus();
|
|
125
|
+
}
|
|
126
|
+
function ghostPill(view, pillPos) {
|
|
127
|
+
const dom = view?.nodeDOM(pillPos);
|
|
128
|
+
if (dom instanceof HTMLElement) spawnExitGhost(dom);
|
|
129
|
+
}
|
|
130
|
+
const deleteMentionBackward = (state, dispatch, view) => {
|
|
131
|
+
const { selection } = state;
|
|
132
|
+
if (!selection.empty) return false;
|
|
133
|
+
const { $from } = selection;
|
|
134
|
+
const before = $from.nodeBefore;
|
|
135
|
+
if (!before) return false;
|
|
136
|
+
if (before.type.name === "mention") {
|
|
137
|
+
const pillPos = $from.pos - before.nodeSize;
|
|
138
|
+
if (dispatch) {
|
|
139
|
+
ghostPill(view, pillPos);
|
|
140
|
+
dispatch(state.tr.delete(pillPos, $from.pos).scrollIntoView());
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
}
|
|
144
|
+
if (before.isText && before.text === " " && $from.pos === $from.end()) {
|
|
145
|
+
const beforeSpace = state.doc.resolve($from.pos - before.nodeSize).nodeBefore;
|
|
146
|
+
if (beforeSpace && beforeSpace.type.name === "mention") {
|
|
147
|
+
const pillPos = $from.pos - before.nodeSize - beforeSpace.nodeSize;
|
|
148
|
+
if (dispatch) {
|
|
149
|
+
ghostPill(view, pillPos);
|
|
150
|
+
dispatch(state.tr.delete(pillPos, $from.pos).scrollIntoView());
|
|
151
|
+
}
|
|
152
|
+
return true;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return false;
|
|
156
|
+
};
|
|
157
|
+
const deleteMentionForward = (state, dispatch, view) => {
|
|
158
|
+
const { selection } = state;
|
|
159
|
+
if (!selection.empty) return false;
|
|
160
|
+
const { $from } = selection;
|
|
161
|
+
const after = $from.nodeAfter;
|
|
162
|
+
if (after?.type.name !== "mention") return false;
|
|
163
|
+
if (dispatch) {
|
|
164
|
+
ghostPill(view, $from.pos);
|
|
165
|
+
dispatch(state.tr.delete($from.pos, $from.pos + after.nodeSize).scrollIntoView());
|
|
166
|
+
}
|
|
167
|
+
return true;
|
|
168
|
+
};
|
|
169
|
+
function collectMentions(doc) {
|
|
170
|
+
const mentions = [];
|
|
171
|
+
doc.descendants((node) => {
|
|
172
|
+
if (node.type.name === "mention") mentions.push({
|
|
173
|
+
id: attrString(node.attrs.id, ""),
|
|
174
|
+
label: attrString(node.attrs.label, ""),
|
|
175
|
+
kind: attrString(node.attrs.kind, "mention")
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
return mentions;
|
|
179
|
+
}
|
|
180
|
+
function MentionOverlay({ editor, triggers, side, align }) {
|
|
181
|
+
const chars = triggers.map((trigger) => trigger.char);
|
|
182
|
+
const controller = useTriggerMenu({
|
|
183
|
+
triggers,
|
|
184
|
+
onCommit: (item, trigger) => {
|
|
185
|
+
const view = editor.getView();
|
|
186
|
+
if (!view) return;
|
|
187
|
+
const state = readEditorTrigger(view, chars);
|
|
188
|
+
if (!state.active) return;
|
|
189
|
+
if ((trigger.insert ?? "replace") === "none") deleteTriggerToken(view, state.from, state.to);
|
|
190
|
+
else insertMention(view, state.from, state.to, {
|
|
191
|
+
id: item.id,
|
|
192
|
+
label: item.label,
|
|
193
|
+
kind: item.kind,
|
|
194
|
+
icon: item.image ?? null
|
|
195
|
+
});
|
|
196
|
+
trigger.onSelect?.(item, {
|
|
197
|
+
char: state.char,
|
|
198
|
+
query: state.query
|
|
199
|
+
});
|
|
200
|
+
}
|
|
201
|
+
});
|
|
202
|
+
useEffect(() => {
|
|
203
|
+
return editor.subscribe(() => {
|
|
204
|
+
const view = editor.getView();
|
|
205
|
+
if (!view) return;
|
|
206
|
+
const state = readEditorTrigger(view, chars);
|
|
207
|
+
controller.report(state.active ? {
|
|
208
|
+
char: state.char,
|
|
209
|
+
query: state.query,
|
|
210
|
+
start: state.from,
|
|
211
|
+
end: state.to
|
|
212
|
+
} : null, state.rect);
|
|
213
|
+
});
|
|
214
|
+
}, [
|
|
215
|
+
editor,
|
|
216
|
+
controller,
|
|
217
|
+
chars
|
|
218
|
+
]);
|
|
219
|
+
useEffect(() => {
|
|
220
|
+
return editor.registerKeyHandler((event) => {
|
|
221
|
+
const view = editor.getView();
|
|
222
|
+
if (!view) return false;
|
|
223
|
+
if (!readEditorTrigger(view, chars).active) return false;
|
|
224
|
+
return controller.handleKeyDown(event.key);
|
|
225
|
+
});
|
|
226
|
+
}, [
|
|
227
|
+
editor,
|
|
228
|
+
controller,
|
|
229
|
+
chars
|
|
230
|
+
]);
|
|
231
|
+
if (triggers.length === 0) return null;
|
|
232
|
+
return /* @__PURE__ */ jsx(TriggerMenu, {
|
|
233
|
+
open: controller.open,
|
|
234
|
+
onOpenChange: controller.setOpen,
|
|
235
|
+
anchorRect: controller.anchorRect,
|
|
236
|
+
side,
|
|
237
|
+
align,
|
|
238
|
+
children: /* @__PURE__ */ jsx(TriggerMenuList, { children: controller.items.length === 0 ? /* @__PURE__ */ jsx(TriggerMenuEmpty, { children: "No results" }) : controller.items.map((item, index) => /* @__PURE__ */ jsxs(TriggerMenuItem, {
|
|
239
|
+
active: index === controller.activeIndex,
|
|
240
|
+
disabled: item.disabled,
|
|
241
|
+
onPointerMove: () => controller.setActiveIndex(index),
|
|
242
|
+
onClick: () => controller.select(item),
|
|
243
|
+
children: [
|
|
244
|
+
item.icon ? /* @__PURE__ */ jsx(TriggerMenuIcon, { children: item.icon }) : null,
|
|
245
|
+
/* @__PURE__ */ jsx("span", {
|
|
246
|
+
className: "flex-1 truncate",
|
|
247
|
+
children: item.label
|
|
248
|
+
}),
|
|
249
|
+
item.description ? /* @__PURE__ */ jsx("span", {
|
|
250
|
+
"data-control-ui": "chat-composer",
|
|
251
|
+
"data-control-family": "chat-composer",
|
|
252
|
+
"data-slot": "mention-description",
|
|
253
|
+
className: "truncate",
|
|
254
|
+
children: item.description
|
|
255
|
+
}) : null
|
|
256
|
+
]
|
|
257
|
+
}, item.id)) })
|
|
258
|
+
});
|
|
259
|
+
}
|
|
260
|
+
function mentionExtension({ triggers, side = "top", align = "start" }) {
|
|
261
|
+
return {
|
|
262
|
+
name: "mention",
|
|
263
|
+
nodes: { mention: mentionNode },
|
|
264
|
+
keymap: () => ({
|
|
265
|
+
Backspace: deleteMentionBackward,
|
|
266
|
+
Delete: deleteMentionForward
|
|
267
|
+
}),
|
|
268
|
+
submitPayload: (doc) => ({ mentions: collectMentions(doc) }),
|
|
269
|
+
Overlay: ({ editor }) => /* @__PURE__ */ jsx(MentionOverlay, {
|
|
270
|
+
editor,
|
|
271
|
+
triggers,
|
|
272
|
+
side,
|
|
273
|
+
align
|
|
274
|
+
})
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
//#endregion
|
|
278
|
+
export { deleteMentionBackward, deleteMentionForward, mentionExtension };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
//#region src/chat-composer-editor/ghost.d.ts
|
|
2
|
+
declare function spawnExitGhost(source: HTMLElement, inherit?: readonly string[]): void;
|
|
3
|
+
declare const MESSAGE_GHOST_INHERIT: readonly ["font-family", "font-size", "font-weight", "font-style", "line-height", "letter-spacing", "color", "padding", "white-space", "overflow-wrap", "word-break", "text-align"];
|
|
4
|
+
//#endregion
|
|
5
|
+
export { MESSAGE_GHOST_INHERIT, spawnExitGhost };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
//#region src/chat-composer-editor/ghost.ts
|
|
3
|
+
const MESSAGE_INHERIT = [
|
|
4
|
+
"font-family",
|
|
5
|
+
"font-size",
|
|
6
|
+
"font-weight",
|
|
7
|
+
"font-style",
|
|
8
|
+
"line-height",
|
|
9
|
+
"letter-spacing",
|
|
10
|
+
"color",
|
|
11
|
+
"padding",
|
|
12
|
+
"white-space",
|
|
13
|
+
"overflow-wrap",
|
|
14
|
+
"word-break",
|
|
15
|
+
"text-align"
|
|
16
|
+
];
|
|
17
|
+
function prefersReducedMotion() {
|
|
18
|
+
return typeof window !== "undefined" && typeof window.matchMedia === "function" ? window.matchMedia("(prefers-reduced-motion: reduce)").matches : false;
|
|
19
|
+
}
|
|
20
|
+
function spawnExitGhost(source, inherit = []) {
|
|
21
|
+
if (typeof document === "undefined") return;
|
|
22
|
+
if (prefersReducedMotion()) return;
|
|
23
|
+
const rect = source.getBoundingClientRect();
|
|
24
|
+
if (rect.width === 0 && rect.height === 0) return;
|
|
25
|
+
const ghost = document.createElement(source.tagName.toLowerCase());
|
|
26
|
+
for (const name of source.getAttributeNames()) {
|
|
27
|
+
const value = source.getAttribute(name);
|
|
28
|
+
if (value !== null) ghost.setAttribute(name, value);
|
|
29
|
+
}
|
|
30
|
+
ghost.innerHTML = source.innerHTML;
|
|
31
|
+
ghost.setAttribute("data-chat-composer-exit", "");
|
|
32
|
+
ghost.setAttribute("data-exiting", "");
|
|
33
|
+
ghost.setAttribute("aria-hidden", "true");
|
|
34
|
+
ghost.removeAttribute("contenteditable");
|
|
35
|
+
if (inherit.length > 0 && typeof getComputedStyle === "function") {
|
|
36
|
+
const computed = getComputedStyle(source);
|
|
37
|
+
for (const property of inherit) ghost.style.setProperty(property, computed.getPropertyValue(property));
|
|
38
|
+
}
|
|
39
|
+
ghost.style.position = "fixed";
|
|
40
|
+
ghost.style.left = `${rect.left}px`;
|
|
41
|
+
ghost.style.top = `${rect.top}px`;
|
|
42
|
+
ghost.style.width = `${rect.width}px`;
|
|
43
|
+
ghost.style.height = `${rect.height}px`;
|
|
44
|
+
ghost.style.margin = "0";
|
|
45
|
+
ghost.style.overflow = "hidden";
|
|
46
|
+
ghost.style.pointerEvents = "none";
|
|
47
|
+
ghost.style.zIndex = "50";
|
|
48
|
+
document.body.appendChild(ghost);
|
|
49
|
+
const remove = () => ghost.remove();
|
|
50
|
+
ghost.addEventListener("animationend", remove, { once: true });
|
|
51
|
+
window.setTimeout(remove, 600);
|
|
52
|
+
}
|
|
53
|
+
const MESSAGE_GHOST_INHERIT = MESSAGE_INHERIT;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { MESSAGE_GHOST_INHERIT, spawnExitGhost };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChatComposerEditorExtension } from "./types.js";
|
|
2
|
+
import { Schema } from "prosemirror-model";
|
|
3
|
+
//#region src/chat-composer-editor/schema.d.ts
|
|
4
|
+
declare function createEditorSchema(extensions: readonly ChatComposerEditorExtension[]): Schema;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { createEditorSchema };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Schema } from "prosemirror-model";
|
|
2
|
+
//#region src/chat-composer-editor/schema.ts
|
|
3
|
+
const baseNodes = {
|
|
4
|
+
doc: { content: "block+" },
|
|
5
|
+
paragraph: {
|
|
6
|
+
group: "block",
|
|
7
|
+
content: "inline*",
|
|
8
|
+
parseDOM: [{ tag: "p" }],
|
|
9
|
+
toDOM: () => ["p", 0]
|
|
10
|
+
},
|
|
11
|
+
text: { group: "inline" }
|
|
12
|
+
};
|
|
13
|
+
function createEditorSchema(extensions) {
|
|
14
|
+
let nodes = { ...baseNodes };
|
|
15
|
+
for (const extension of extensions) if (extension.nodes) nodes = {
|
|
16
|
+
...nodes,
|
|
17
|
+
...extension.nodes
|
|
18
|
+
};
|
|
19
|
+
return new Schema({
|
|
20
|
+
nodes,
|
|
21
|
+
marks: {}
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
//#endregion
|
|
25
|
+
export { createEditorSchema };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Node, Schema } from "prosemirror-model";
|
|
2
|
+
//#region src/chat-composer-editor/serialize.d.ts
|
|
3
|
+
declare function serializeDoc(doc: Node): string;
|
|
4
|
+
declare function docFromText(schema: Schema, text: string): Node;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { docFromText, serializeDoc };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
//#region src/chat-composer-editor/serialize.ts
|
|
2
|
+
function serializeDoc(doc) {
|
|
3
|
+
return doc.textBetween(0, doc.content.size, "\n", (leaf) => {
|
|
4
|
+
const leafText = leaf.type.spec.leafText;
|
|
5
|
+
return typeof leafText === "function" ? leafText(leaf) : "";
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
function docFromText(schema, text) {
|
|
9
|
+
const paragraph = schema.nodes.paragraph;
|
|
10
|
+
const doc = schema.nodes.doc;
|
|
11
|
+
if (!paragraph || !doc) throw new Error("Chat composer schema requires doc and paragraph nodes.");
|
|
12
|
+
const blocks = text.split("\n").map((line) => paragraph.create(null, line === "" ? null : schema.text(line)));
|
|
13
|
+
return doc.create(null, blocks.length === 0 ? paragraph.create() : blocks);
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { docFromText, serializeDoc };
|