@ctrl-ui/react 0.8.6 → 0.8.8
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/dist/action-bar.d.ts +15 -7
- package/dist/action-bar.js +39 -19
- package/dist/activity.js +7 -15
- package/dist/audio-recorder.d.ts +14 -4
- package/dist/audio-recorder.js +82 -29
- package/dist/audio-visualizer.js +1 -1
- package/dist/blocks/coding-agent.js +54 -57
- package/dist/blocks/design-canvas-data.d.ts +32 -0
- package/dist/blocks/design-canvas-data.js +100 -0
- package/dist/blocks/design-canvas-inspector.d.ts +8 -0
- package/dist/blocks/design-canvas-inspector.js +238 -0
- package/dist/blocks/design-canvas.d.ts +21 -0
- package/dist/blocks/design-canvas.js +452 -0
- package/dist/blocks/discussion.d.ts +28 -0
- package/dist/blocks/discussion.js +67 -0
- package/dist/blocks/file-explorer-data.d.ts +1 -0
- package/dist/blocks/file-explorer-data.js +4 -1
- package/dist/blocks/file-explorer.d.ts +9 -1
- package/dist/blocks/file-explorer.js +461 -192
- package/dist/blocks/settings.d.ts +2 -1
- package/dist/blocks/settings.js +101 -79
- package/dist/blocks/team-chat.d.ts +12 -0
- package/dist/blocks/team-chat.js +26 -0
- package/dist/blocks/theme-toggle.js +23 -31
- package/dist/chat-composer-attachment.d.ts +12 -3
- package/dist/chat-composer-attachment.js +61 -19
- package/dist/chat-composer-editor/extensions/mention.d.ts +5 -1
- package/dist/chat-composer-editor/extensions/mention.js +58 -27
- package/dist/chat-composer-editor/ghost.js +2 -4
- package/dist/chat-composer-editor/types.d.ts +5 -0
- package/dist/chat-composer-editor.d.ts +1 -1
- package/dist/chat-composer-editor.js +71 -28
- package/dist/chat-composer.d.ts +13 -32
- package/dist/chat-composer.js +54 -13
- package/dist/chat-layout.d.ts +19 -0
- package/dist/chat-layout.js +96 -32
- package/dist/chat-message/social.d.ts +26 -0
- package/dist/chat-message/social.js +122 -0
- package/dist/chat-message.d.ts +28 -29
- package/dist/chat-message.js +106 -25
- package/dist/context.d.ts +2 -2
- package/dist/context.js +38 -23
- package/dist/dynamic-notification-canvas-loop.d.ts +24 -0
- package/dist/dynamic-notification-canvas-loop.js +113 -0
- package/dist/dynamic-notification-glass.js +23 -114
- package/dist/dynamic-notification-liquid.js +14 -118
- package/dist/dynamic-notification.d.ts +16 -8
- package/dist/dynamic-notification.js +85 -22
- package/dist/email/email-brand.d.ts +7 -4
- package/dist/email/email-brand.js +9 -6
- package/dist/email/email-code.d.ts +3 -2
- package/dist/email/email-code.js +11 -9
- package/dist/email/email-footer.d.ts +5 -3
- package/dist/email/email-footer.js +11 -5
- package/dist/email/email.d.ts +31 -9
- package/dist/email/email.js +50 -26
- package/dist/email/templates.d.ts +10 -9
- package/dist/email/templates.js +102 -38
- package/dist/email/theme.js +1 -1
- package/dist/environment-variables.d.ts +4 -2
- package/dist/environment-variables.js +52 -32
- package/dist/filter-bar/context.d.ts +32 -0
- package/dist/filter-bar/context.js +11 -0
- package/dist/filter-bar/editor.d.ts +14 -0
- package/dist/filter-bar/editor.js +216 -0
- package/dist/filter-bar/model.d.ts +10 -0
- package/dist/filter-bar/model.js +57 -0
- package/dist/filter-bar/motion.d.ts +10 -0
- package/dist/filter-bar/motion.js +84 -0
- package/dist/filter-bar/parts.d.ts +19 -0
- package/dist/filter-bar/parts.js +244 -0
- package/dist/filter-bar/types.d.ts +54 -0
- package/dist/filter-bar/types.js +0 -0
- package/dist/filter-bar.d.ts +27 -0
- package/dist/filter-bar.js +310 -0
- package/dist/hooks/use-audio-recorder.js +12 -6
- package/dist/hooks/use-chat-composer.d.ts +21 -7
- package/dist/hooks/use-chat-composer.js +32 -5
- package/dist/hooks/use-chat-message.d.ts +28 -2
- package/dist/hooks/use-chat-message.js +41 -10
- package/dist/hooks/use-chat-thread-scroll.js +43 -7
- package/dist/hooks/use-color-area.d.ts +3 -3
- package/dist/hooks/use-color-area.js +13 -12
- package/dist/hooks/use-copy-to-clipboard.d.ts +2 -1
- package/dist/hooks/use-copy-to-clipboard.js +20 -20
- package/dist/hooks/use-dropzone.d.ts +7 -4
- package/dist/hooks/use-dropzone.js +34 -3
- package/dist/hooks/use-dynamic-notification.d.ts +6 -2
- package/dist/hooks/use-dynamic-notification.js +26 -10
- package/dist/hooks/use-mobile.d.ts +3 -2
- package/dist/hooks/use-mobile.js +8 -4
- package/dist/hooks/use-textarea-trigger-menu.js +2 -1
- package/dist/hooks/use-trigger-menu.d.ts +54 -0
- package/dist/hooks/use-trigger-menu.js +102 -47
- package/dist/hooks/use-user-ask.d.ts +2 -0
- package/dist/hooks/use-user-ask.js +35 -41
- package/dist/inline-attachment.d.ts +6 -2
- package/dist/inline-attachment.js +44 -29
- package/dist/inline-citation.d.ts +12 -5
- package/dist/inline-citation.js +25 -16
- package/dist/knob-contracts/audio-recorder-knobs.d.ts +1 -1
- package/dist/knob-contracts/audio-recorder-knobs.js +2 -1
- package/dist/knob-contracts/audio-visualizer-knobs.d.ts +1 -1
- package/dist/knob-contracts/audio-visualizer-knobs.js +2 -1
- package/dist/knob-contracts/avatar-knobs.d.ts +1 -1
- package/dist/knob-contracts/avatar-knobs.js +6 -1
- package/dist/knob-contracts/badge-knobs.d.ts +1 -1
- package/dist/knob-contracts/badge-knobs.js +2 -1
- package/dist/knob-contracts/breadcrumb-knobs.d.ts +4 -0
- package/dist/knob-contracts/breadcrumb-knobs.js +8 -0
- package/dist/knob-contracts/button-knobs.d.ts +1 -1
- package/dist/knob-contracts/button-knobs.js +1 -0
- package/dist/knob-contracts/chat-layout-knobs.d.ts +1 -1
- package/dist/knob-contracts/chat-layout-knobs.js +2 -1
- package/dist/knob-contracts/chat-message-knobs.d.ts +1 -1
- package/dist/knob-contracts/chat-message-knobs.js +8 -1
- package/dist/knob-contracts/choice-knobs.d.ts +1 -1
- package/dist/knob-contracts/choice-knobs.js +1 -0
- package/dist/knob-contracts/code-diff-knobs.d.ts +1 -1
- package/dist/knob-contracts/code-diff-knobs.js +2 -0
- package/dist/knob-contracts/code-knobs.d.ts +1 -1
- package/dist/knob-contracts/code-knobs.js +2 -1
- package/dist/knob-contracts/collapsible-knobs.d.ts +1 -1
- package/dist/knob-contracts/collapsible-knobs.js +1 -1
- package/dist/knob-contracts/dynamic-notification-knobs.d.ts +1 -1
- package/dist/knob-contracts/dynamic-notification-knobs.js +2 -0
- package/dist/knob-contracts/emoji-picker-knobs.d.ts +4 -0
- package/dist/knob-contracts/emoji-picker-knobs.js +10 -0
- package/dist/knob-contracts/field-knobs.d.ts +1 -1
- package/dist/knob-contracts/field-knobs.js +5 -1
- package/dist/knob-contracts/filter-bar-knobs.d.ts +4 -0
- package/dist/knob-contracts/filter-bar-knobs.js +15 -0
- package/dist/knob-contracts/infinite-canvas-knobs.d.ts +1 -1
- package/dist/knob-contracts/infinite-canvas-knobs.js +3 -0
- package/dist/knob-contracts/markdown-knobs.d.ts +1 -1
- package/dist/knob-contracts/markdown-knobs.js +3 -1
- package/dist/knob-contracts/page-layout-knobs.d.ts +1 -1
- package/dist/knob-contracts/page-layout-knobs.js +4 -1
- package/dist/knob-contracts/popup-knobs.d.ts +1 -1
- package/dist/knob-contracts/popup-knobs.js +28 -0
- package/dist/knob-contracts/range-knobs.d.ts +1 -1
- package/dist/knob-contracts/range-knobs.js +1 -0
- package/dist/knob-contracts/rich-tooltip-knobs.d.ts +1 -1
- package/dist/knob-contracts/rich-tooltip-knobs.js +2 -1
- package/dist/knob-contracts/sidebar-knobs.d.ts +1 -1
- package/dist/knob-contracts/sidebar-knobs.js +27 -2
- package/dist/knob-contracts/spinner-knobs.d.ts +1 -1
- package/dist/knob-contracts/spinner-knobs.js +1 -1
- package/dist/knob-contracts/stepper-knobs.d.ts +1 -1
- package/dist/knob-contracts/stepper-knobs.js +4 -1
- package/dist/knob-contracts/switch-knobs.d.ts +1 -1
- package/dist/knob-contracts/switch-knobs.js +5 -0
- package/dist/knob-contracts/table-of-contents-knobs.d.ts +1 -1
- package/dist/knob-contracts/table-of-contents-knobs.js +4 -5
- package/dist/knob-contracts/tabs-knobs.d.ts +1 -1
- package/dist/knob-contracts/tabs-knobs.js +1 -0
- package/dist/knob-contracts/tree-knobs.d.ts +1 -1
- package/dist/knob-contracts/tree-knobs.js +2 -1
- package/dist/lib/cn.js +0 -4
- package/dist/lib/contrast.d.ts +1 -0
- package/dist/lib/contrast.js +17 -5
- package/dist/lib/dropzone-validation.js +41 -28
- package/dist/lib/env-file.d.ts +1 -1
- package/dist/lib/env-file.js +5 -5
- package/dist/lib/motion.d.ts +4 -0
- package/dist/lib/motion.js +15 -0
- package/dist/lib/trigger-detect.js +6 -8
- package/dist/markdown-block.js +13 -8
- package/dist/popup-parts.d.ts +8 -0
- package/dist/popup-parts.js +43 -0
- package/dist/scripts/contrast-eval.js +5 -4
- package/dist/source-badge.js +3 -1
- package/dist/styles/code.css +0 -2
- package/dist/styles/effects.css +6 -32
- package/dist/styles/index.css +14 -8
- package/dist/styles/recipes/accordion.css +9 -6
- package/dist/styles/recipes/action-bar.css +0 -15
- package/dist/styles/recipes/activity.css +5 -11
- package/dist/styles/recipes/alert.css +4 -4
- package/dist/styles/recipes/audio-recorder.css +15 -3
- package/dist/styles/recipes/audio-visualizer.css +13 -2
- package/dist/styles/recipes/avatar.css +78 -1
- package/dist/styles/recipes/badge.css +14 -4
- package/dist/styles/recipes/breadcrumb.css +77 -0
- package/dist/styles/recipes/button-group.css +6 -8
- package/dist/styles/recipes/button-states.css +66 -0
- package/dist/styles/recipes/button.css +26 -85
- package/dist/styles/recipes/calendar.css +17 -23
- package/dist/styles/recipes/card.css +2 -2
- package/dist/styles/recipes/chat-composer-attachment.css +9 -3
- package/dist/styles/recipes/chat-composer.css +21 -16
- package/dist/styles/recipes/chat-layout.css +64 -2
- package/dist/styles/recipes/chat-message-social.css +123 -0
- package/dist/styles/recipes/chat-message.css +157 -37
- package/dist/styles/recipes/choice.css +25 -21
- package/dist/styles/recipes/code-diff.css +51 -26
- package/dist/styles/recipes/code.css +44 -18
- package/dist/styles/recipes/collapsible.css +43 -1
- package/dist/styles/recipes/color-picker-details.css +3 -4
- package/dist/styles/recipes/color-picker-values.css +9 -8
- package/dist/styles/recipes/color-picker.css +23 -4
- package/dist/styles/recipes/context.css +3 -3
- package/dist/styles/recipes/dockable-panel.css +18 -7
- package/dist/styles/recipes/dropzone.css +7 -8
- package/dist/styles/recipes/dynamic-notification-input.css +8 -5
- package/dist/styles/recipes/dynamic-notification-motion.css +12 -21
- package/dist/styles/recipes/dynamic-notification.css +40 -26
- package/dist/styles/recipes/emoji-picker.css +132 -0
- package/dist/styles/recipes/empty.css +5 -4
- package/dist/styles/recipes/environment-variables.css +4 -15
- package/dist/styles/recipes/field-parts.css +89 -21
- package/dist/styles/recipes/field.css +83 -26
- package/dist/styles/recipes/filter-bar.css +161 -0
- package/dist/styles/recipes/gradient-editor.css +18 -7
- package/dist/styles/recipes/infinite-canvas.css +51 -4
- package/dist/styles/recipes/inline-attachment.css +9 -4
- package/dist/styles/recipes/inline-citation.css +10 -4
- package/dist/styles/recipes/item.css +23 -9
- package/dist/styles/recipes/markdown-block.css +5 -4
- package/dist/styles/recipes/markdown.css +68 -26
- package/dist/styles/recipes/morphing-panel.css +8 -8
- package/dist/styles/recipes/page-layout.css +36 -10
- package/dist/styles/recipes/pagination.css +5 -6
- package/dist/styles/recipes/phone-input.css +12 -8
- package/dist/styles/recipes/popup-controls.css +175 -26
- package/dist/styles/recipes/popup-drawer.css +35 -44
- package/dist/styles/recipes/popup-lists.css +139 -29
- package/dist/styles/recipes/popup-motion.css +4 -45
- package/dist/styles/recipes/popup-toast.css +55 -26
- package/dist/styles/recipes/popup.css +149 -153
- package/dist/styles/recipes/range.css +55 -19
- package/dist/styles/recipes/resizable.css +36 -7
- package/dist/styles/recipes/rich-tooltip.css +24 -34
- package/dist/styles/recipes/scroll-area.css +8 -1
- package/dist/styles/recipes/sidebar-menu.css +149 -34
- package/dist/styles/recipes/sidebar-parts.css +154 -0
- package/dist/styles/recipes/sidebar.css +187 -128
- package/dist/styles/recipes/source-badge.css +1 -1
- package/dist/styles/recipes/spinner.css +12 -1
- package/dist/styles/recipes/stepper.css +31 -13
- package/dist/styles/recipes/switch.css +68 -23
- package/dist/styles/recipes/table-of-contents.css +49 -41
- package/dist/styles/recipes/table.css +14 -10
- package/dist/styles/recipes/tabs.css +38 -12
- package/dist/styles/recipes/task-list.css +7 -14
- package/dist/styles/recipes/thread-rail.css +42 -19
- package/dist/styles/recipes/timeline.css +2 -0
- package/dist/styles/recipes/toolbar.css +27 -25
- package/dist/styles/recipes/track-highlight.css +12 -8
- package/dist/styles/recipes/transcript-divider.css +2 -2
- package/dist/styles/recipes/tree.css +31 -4
- package/dist/styles/recipes/user-ask-details.css +0 -1
- package/dist/styles/recipes/user-ask.css +4 -4
- package/dist/styles/theme.css +287 -107
- package/dist/task-list.d.ts +4 -1
- package/dist/task-list.js +24 -8
- package/dist/thread-rail.d.ts +1 -1
- package/dist/thread-rail.js +61 -19
- package/dist/transcript-divider.js +2 -1
- package/dist/ui/alert.d.ts +3 -1
- package/dist/ui/alert.js +14 -8
- package/dist/ui/autocomplete.js +7 -1
- package/dist/ui/avatar.d.ts +8 -0
- package/dist/ui/avatar.js +23 -3
- package/dist/ui/badge.js +1 -1
- package/dist/ui/breadcrumb.d.ts +27 -0
- package/dist/ui/breadcrumb.js +88 -0
- package/dist/ui/button.d.ts +2 -1
- package/dist/ui/button.js +1 -1
- package/dist/ui/calendar.js +2 -2
- package/dist/ui/card.d.ts +3 -1
- package/dist/ui/card.js +12 -7
- package/dist/ui/checkbox-group.js +1 -1
- package/dist/ui/checkbox.d.ts +2 -0
- package/dist/ui/code-diff.d.ts +1 -1
- package/dist/ui/code-diff.js +71 -27
- package/dist/ui/code.d.ts +5 -3
- package/dist/ui/code.js +27 -28
- package/dist/ui/color-picker.d.ts +5 -2
- package/dist/ui/color-picker.js +84 -36
- package/dist/ui/combobox-disabled-selection.d.ts +1 -2
- package/dist/ui/combobox-disabled-selection.js +7 -8
- package/dist/ui/combobox.d.ts +5 -23
- package/dist/ui/combobox.js +36 -16
- package/dist/ui/command.d.ts +8 -2
- package/dist/ui/command.js +39 -15
- package/dist/ui/context-menu.js +3 -0
- package/dist/ui/dialog.d.ts +2 -1
- package/dist/ui/dialog.js +3 -22
- package/dist/ui/dockable-panel-geometry.d.ts +1 -0
- package/dist/ui/dockable-panel-geometry.js +7 -1
- package/dist/ui/dockable-panel.d.ts +9 -6
- package/dist/ui/dockable-panel.js +81 -33
- package/dist/ui/drawer.d.ts +7 -4
- package/dist/ui/drawer.js +35 -22
- package/dist/ui/dropdown-menu.js +4 -3
- package/dist/ui/dropzone.d.ts +5 -3
- package/dist/ui/dropzone.js +78 -17
- package/dist/ui/emoji-picker.d.ts +18 -0
- package/dist/ui/emoji-picker.js +136 -0
- package/dist/ui/empty.d.ts +3 -1
- package/dist/ui/empty.js +12 -7
- package/dist/ui/field.js +1 -1
- package/dist/ui/gradient-editor.d.ts +1 -1
- package/dist/ui/gradient-editor.js +37 -21
- package/dist/ui/infinite-canvas.d.ts +13 -1
- package/dist/ui/infinite-canvas.js +139 -20
- package/dist/ui/input-group.d.ts +2 -4
- package/dist/ui/input-group.js +13 -14
- package/dist/ui/input-otp.d.ts +1 -1
- package/dist/ui/input-otp.js +32 -15
- package/dist/ui/input.js +11 -2
- package/dist/ui/item.d.ts +2 -1
- package/dist/ui/item.js +11 -7
- package/dist/ui/live-status.d.ts +7 -0
- package/dist/ui/live-status.js +17 -0
- package/dist/ui/markdown-elements.d.ts +6 -0
- package/dist/ui/markdown-elements.js +42 -9
- package/dist/ui/menubar.js +2 -2
- package/dist/ui/morphing-panel.js +2 -1
- package/dist/ui/native-select.d.ts +1 -1
- package/dist/ui/native-select.js +24 -11
- package/dist/ui/number-field.d.ts +1 -1
- package/dist/ui/number-field.js +13 -2
- package/dist/ui/page-layout.d.ts +2 -2
- package/dist/ui/page-layout.js +2 -4
- package/dist/ui/pagination.d.ts +7 -5
- package/dist/ui/pagination.js +19 -13
- package/dist/ui/phone-input.d.ts +1 -0
- package/dist/ui/phone-input.js +56 -58
- package/dist/ui/radio-group.d.ts +3 -0
- package/dist/ui/radio-group.js +11 -1
- package/dist/ui/resizable.d.ts +20 -2
- package/dist/ui/resizable.js +130 -8
- package/dist/ui/responsive-dialog.d.ts +1 -1
- package/dist/ui/responsive-dialog.js +9 -23
- package/dist/ui/rich-tooltip.d.ts +10 -4
- package/dist/ui/rich-tooltip.js +81 -33
- package/dist/ui/scroll-area.d.ts +4 -1
- package/dist/ui/scroll-area.js +44 -28
- package/dist/ui/select.d.ts +2 -1
- package/dist/ui/select.js +57 -32
- package/dist/ui/sidebar-menu.d.ts +5 -1
- package/dist/ui/sidebar-menu.js +31 -33
- package/dist/ui/sidebar-provider.d.ts +10 -1
- package/dist/ui/sidebar-provider.js +38 -13
- package/dist/ui/sidebar-resize-rail.js +7 -3
- package/dist/ui/sidebar.d.ts +11 -6
- package/dist/ui/sidebar.js +46 -23
- package/dist/ui/slider.js +31 -22
- package/dist/ui/spinner.d.ts +3 -2
- package/dist/ui/spinner.js +3 -2
- package/dist/ui/stepper.d.ts +8 -1
- package/dist/ui/stepper.js +74 -25
- package/dist/ui/switch.d.ts +1 -0
- package/dist/ui/table-of-contents.d.ts +5 -4
- package/dist/ui/table-of-contents.js +143 -52
- package/dist/ui/table.js +15 -9
- package/dist/ui/textarea.d.ts +1 -1
- package/dist/ui/textarea.js +20 -9
- package/dist/ui/timeline.d.ts +3 -1
- package/dist/ui/timeline.js +17 -9
- package/dist/ui/toast.d.ts +11 -5
- package/dist/ui/toast.js +100 -54
- package/dist/ui/toggle.d.ts +1 -1
- package/dist/ui/toggle.js +2 -1
- package/dist/ui/toolbar.d.ts +3 -2
- package/dist/ui/toolbar.js +4 -2
- package/dist/ui/tooltip.js +3 -20
- package/dist/ui/tree.js +120 -80
- package/dist/ui/trigger-menu.js +7 -2
- package/dist/user-ask.d.ts +10 -5
- package/dist/user-ask.js +31 -11
- package/package.json +5 -1
- package/dist/hooks/use-keyboard-navigation.d.ts +0 -3
- package/dist/hooks/use-keyboard-navigation.js +0 -22
package/dist/chat-composer.js
CHANGED
|
@@ -3,10 +3,11 @@ import { cn } from "./lib/cn.js";
|
|
|
3
3
|
import { hasSkinAdornment, skinAdornment } from "./skin.js";
|
|
4
4
|
import { useSkin } from "./skin-provider.js";
|
|
5
5
|
import { Button } from "./ui/button.js";
|
|
6
|
+
import { Spinner } from "./ui/spinner.js";
|
|
6
7
|
import { useChatComposer } from "./hooks/use-chat-composer.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
8
|
+
import { createContext, useContext, useEffect, useRef } from "react";
|
|
9
|
+
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { Square } from "lucide-react";
|
|
10
11
|
//#region src/chat-composer.tsx
|
|
11
12
|
const ChatComposerContext = createContext(null);
|
|
12
13
|
function useChatComposerContext() {
|
|
@@ -14,7 +15,7 @@ function useChatComposerContext() {
|
|
|
14
15
|
if (!context) throw new Error("ChatComposer compound components must be rendered inside <ChatComposer>.");
|
|
15
16
|
return context;
|
|
16
17
|
}
|
|
17
|
-
function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "idle", density = "comfortable", disabled = false, className, children, ...props }) {
|
|
18
|
+
function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "idle", density = "comfortable", disabled = false, allowEmptySubmit = false, submitKey = "enter", className, children, ...props }) {
|
|
18
19
|
const skin = useSkin();
|
|
19
20
|
const input = useChatComposer({
|
|
20
21
|
value,
|
|
@@ -24,6 +25,8 @@ function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "i
|
|
|
24
25
|
state,
|
|
25
26
|
density,
|
|
26
27
|
disabled,
|
|
28
|
+
allowEmptySubmit,
|
|
29
|
+
submitKey,
|
|
27
30
|
trackSends: hasSkinAdornment(skin, "chat-composer", "send-layer")
|
|
28
31
|
});
|
|
29
32
|
const sendLayer = skinAdornment(skin, "chat-composer", "send-layer", { sendCount: input.sendCount });
|
|
@@ -48,9 +51,7 @@ function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "i
|
|
|
48
51
|
}
|
|
49
52
|
function ChatComposerShell({ className, ...props }) {
|
|
50
53
|
const input = useChatComposerContext();
|
|
51
|
-
const keyboardNavigation = useKeyboardNavigation();
|
|
52
54
|
return /* @__PURE__ */ jsx("div", {
|
|
53
|
-
"data-keyboard-navigation": keyboardNavigation ? "" : void 0,
|
|
54
55
|
"data-control-ui": "chat-composer",
|
|
55
56
|
"data-control-family": "chat-composer",
|
|
56
57
|
"data-slot": "shell",
|
|
@@ -70,8 +71,17 @@ function ChatComposerAccent({ className, ...props }) {
|
|
|
70
71
|
...props
|
|
71
72
|
});
|
|
72
73
|
}
|
|
73
|
-
function ChatComposerTextarea({ className, rows, disabled, onChange, onKeyDown, ...props }) {
|
|
74
|
+
function ChatComposerTextarea({ className, rows, disabled, readOnly, onChange, onKeyDown, ref, ...props }) {
|
|
74
75
|
const input = useChatComposerContext();
|
|
76
|
+
const textareaRef = useRef(null);
|
|
77
|
+
const { registerInsertionTarget } = input;
|
|
78
|
+
useEffect(() => registerInsertionTarget((text) => {
|
|
79
|
+
const textarea = textareaRef.current;
|
|
80
|
+
if (!textarea) return;
|
|
81
|
+
textarea.focus();
|
|
82
|
+
textarea.setRangeText(text, textarea.selectionStart, textarea.selectionEnd, "end");
|
|
83
|
+
textarea.dispatchEvent(new Event("input", { bubbles: true }));
|
|
84
|
+
}), [registerInsertionTarget]);
|
|
75
85
|
function handleChange(event) {
|
|
76
86
|
onChange?.(event);
|
|
77
87
|
if (!event.defaultPrevented) input.setValue(event.currentTarget.value);
|
|
@@ -80,7 +90,12 @@ function ChatComposerTextarea({ className, rows, disabled, onChange, onKeyDown,
|
|
|
80
90
|
onKeyDown?.(event);
|
|
81
91
|
input.handleKeyDown(event);
|
|
82
92
|
}
|
|
93
|
+
function attachTextarea(node) {
|
|
94
|
+
textareaRef.current = node;
|
|
95
|
+
assignRef(ref, node);
|
|
96
|
+
}
|
|
83
97
|
return /* @__PURE__ */ jsx("textarea", {
|
|
98
|
+
ref: attachTextarea,
|
|
84
99
|
"data-control-ui": "chat-composer",
|
|
85
100
|
"data-control-family": "chat-composer",
|
|
86
101
|
"data-slot": "textarea",
|
|
@@ -90,8 +105,10 @@ function ChatComposerTextarea({ className, rows, disabled, onChange, onKeyDown,
|
|
|
90
105
|
onChange: handleChange,
|
|
91
106
|
onKeyDown: handleKeyDown,
|
|
92
107
|
disabled: disabled || input.isDisabled,
|
|
108
|
+
readOnly: readOnly || input.isLocked,
|
|
109
|
+
"aria-busy": input.isLocked || void 0,
|
|
93
110
|
rows: rows ?? input.rows,
|
|
94
|
-
className: cn("field-sizing-content min-h-16 max-h-[40dvh] w-full resize-none
|
|
111
|
+
className: cn("field-sizing-content min-h-16 max-h-[40dvh] w-full resize-none px-[var(--padding-x)] py-[var(--padding-y)] disabled:cursor-not-allowed", className)
|
|
95
112
|
});
|
|
96
113
|
}
|
|
97
114
|
function ChatComposerToolbar({ className, ...props }) {
|
|
@@ -117,24 +134,48 @@ function ChatComposerFooter({ className, ...props }) {
|
|
|
117
134
|
"data-control-ui": "chat-composer",
|
|
118
135
|
"data-control-family": "chat-composer",
|
|
119
136
|
"data-slot": "footer",
|
|
120
|
-
className
|
|
137
|
+
className,
|
|
121
138
|
...props
|
|
122
139
|
});
|
|
123
140
|
}
|
|
124
|
-
function ChatComposerSubmit({ className, disabled, children = "Send",
|
|
141
|
+
function ChatComposerSubmit({ className, disabled, iconOnly = false, children = "Send", onStop, stopLabel = "Stop response", stopIcon = /* @__PURE__ */ jsx(Square, {
|
|
142
|
+
"aria-hidden": "true",
|
|
143
|
+
className: "fill-current"
|
|
144
|
+
}), onClick, "aria-label": ariaLabel, ...props }) {
|
|
125
145
|
const input = useChatComposerContext();
|
|
146
|
+
const isStop = input.isLocked && onStop !== void 0;
|
|
147
|
+
const isBusy = input.isLocked && !isStop;
|
|
148
|
+
function handleClick(event) {
|
|
149
|
+
onClick?.(event);
|
|
150
|
+
if (isStop && !event.defaultPrevented) onStop();
|
|
151
|
+
}
|
|
152
|
+
function content() {
|
|
153
|
+
if (isStop) return iconOnly ? stopIcon : stopLabel;
|
|
154
|
+
if (!isBusy) return children;
|
|
155
|
+
if (iconOnly) return /* @__PURE__ */ jsx(Spinner, { "aria-hidden": "true" });
|
|
156
|
+
return /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx(Spinner, { "aria-hidden": "true" }), children] });
|
|
157
|
+
}
|
|
126
158
|
return /* @__PURE__ */ jsx(Button, {
|
|
127
159
|
"data-control-ui": "chat-composer",
|
|
128
160
|
"data-slot": "submit",
|
|
129
|
-
|
|
161
|
+
"data-stop": isStop ? "true" : void 0,
|
|
162
|
+
type: isStop ? "button" : "submit",
|
|
130
163
|
variant: "solid",
|
|
131
164
|
tone: "primary",
|
|
132
165
|
size: "xs",
|
|
133
|
-
|
|
166
|
+
iconOnly,
|
|
167
|
+
disabled: isStop ? disabled : disabled || !input.canSubmit,
|
|
168
|
+
"aria-busy": isBusy || void 0,
|
|
169
|
+
"aria-label": isStop && iconOnly ? stopLabel : ariaLabel,
|
|
170
|
+
onClick: handleClick,
|
|
134
171
|
className,
|
|
135
172
|
...props,
|
|
136
|
-
children
|
|
173
|
+
children: content()
|
|
137
174
|
});
|
|
138
175
|
}
|
|
176
|
+
function assignRef(ref, node) {
|
|
177
|
+
if (typeof ref === "function") ref(node);
|
|
178
|
+
else if (ref) ref.current = node;
|
|
179
|
+
}
|
|
139
180
|
//#endregion
|
|
140
181
|
export { ChatComposer, ChatComposerAccent, ChatComposerFooter, ChatComposerShell, ChatComposerSubmit, ChatComposerTextarea, ChatComposerToolbar, ChatComposerTools, useChatComposerContext };
|
package/dist/chat-layout.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { RenderProp } from "./control-props.js";
|
|
1
2
|
import { Button } from "./ui/button.js";
|
|
2
3
|
import { ChatLayoutKnobStyle } from "./knob-contracts/chat-layout-knobs.js";
|
|
3
4
|
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
@@ -8,6 +9,24 @@ export type ChatLayoutProps = Omit<ComponentProps<"section">, "style"> & {
|
|
|
8
9
|
style?: CSSProperties & ChatLayoutKnobStyle;
|
|
9
10
|
};
|
|
10
11
|
export declare function ChatLayout({ children, chrome, className, ...props }: ChatLayoutProps): import("react").JSX.Element;
|
|
12
|
+
export type ChatLayoutHeaderProps = Omit<ComponentProps<"header">, "style"> & {
|
|
13
|
+
style?: CSSProperties & ChatLayoutKnobStyle;
|
|
14
|
+
};
|
|
15
|
+
export declare function ChatLayoutHeader({ className, ...props }: ChatLayoutHeaderProps): import("react").JSX.Element;
|
|
16
|
+
export type ChatLayoutTitleProps = Omit<ComponentProps<"div">, "style"> & {
|
|
17
|
+
render?: RenderProp<ComponentProps<"div">>;
|
|
18
|
+
style?: CSSProperties & ChatLayoutKnobStyle;
|
|
19
|
+
};
|
|
20
|
+
/** Renders a `div`; pass `render={(props) => <h2 {...props} />}` for the heading level the page needs. */
|
|
21
|
+
export declare function ChatLayoutTitle({ render, className, ...props }: ChatLayoutTitleProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
|
|
22
|
+
export type ChatLayoutDescriptionProps = Omit<ComponentProps<"p">, "style"> & {
|
|
23
|
+
style?: CSSProperties & ChatLayoutKnobStyle;
|
|
24
|
+
};
|
|
25
|
+
export declare function ChatLayoutDescription({ className, ...props }: ChatLayoutDescriptionProps): import("react").JSX.Element;
|
|
26
|
+
export type ChatLayoutActionsProps = Omit<ComponentProps<"div">, "style"> & {
|
|
27
|
+
style?: CSSProperties & ChatLayoutKnobStyle;
|
|
28
|
+
};
|
|
29
|
+
export declare function ChatLayoutActions({ className, ...props }: ChatLayoutActionsProps): import("react").JSX.Element;
|
|
11
30
|
export type ChatThreadProps = ComponentProps<"div"> & {
|
|
12
31
|
composer?: ReactNode;
|
|
13
32
|
};
|
package/dist/chat-layout.js
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
import { cn } from "./lib/cn.js";
|
|
3
3
|
import { SkinAdornment } from "./skin-provider.js";
|
|
4
4
|
import { Button } from "./ui/button.js";
|
|
5
|
+
import { LiveStatus } from "./ui/live-status.js";
|
|
6
|
+
import { ScrollArea } from "./ui/scroll-area.js";
|
|
7
|
+
import { ChatThreadAnnounceContext } from "./hooks/use-chat-message.js";
|
|
5
8
|
import { useChatThreadScroll } from "./hooks/use-chat-thread-scroll.js";
|
|
6
|
-
import { createContext, useContext } from "react";
|
|
9
|
+
import { createContext, useContext, useState } from "react";
|
|
10
|
+
import { useRender } from "@base-ui/react/use-render";
|
|
7
11
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
12
|
import { ArrowDown } from "lucide-react";
|
|
9
13
|
//#region src/chat-layout.tsx
|
|
14
|
+
const chromeSizing = {
|
|
15
|
+
panel: "mx-auto min-h-[640px] max-w-3xl",
|
|
16
|
+
embedded: "h-full min-h-0 flex-1"
|
|
17
|
+
};
|
|
10
18
|
function ChatLayout({ children, chrome = "panel", className, ...props }) {
|
|
11
19
|
return /* @__PURE__ */ jsxs("section", {
|
|
12
20
|
"data-control-ui": "chat-layout",
|
|
@@ -14,7 +22,7 @@ function ChatLayout({ children, chrome = "panel", className, ...props }) {
|
|
|
14
22
|
"data-slot": "root",
|
|
15
23
|
"data-chrome": chrome,
|
|
16
24
|
"data-surface": chrome === "panel" ? "panel" : void 0,
|
|
17
|
-
className: cn("relative
|
|
25
|
+
className: cn("relative flex w-full flex-col overflow-hidden", chromeSizing[chrome], className),
|
|
18
26
|
...props,
|
|
19
27
|
children: [chrome === "panel" ? /* @__PURE__ */ jsx(SkinAdornment, {
|
|
20
28
|
scope: "chat-layout",
|
|
@@ -23,39 +31,95 @@ function ChatLayout({ children, chrome = "panel", className, ...props }) {
|
|
|
23
31
|
}) : null, children]
|
|
24
32
|
});
|
|
25
33
|
}
|
|
34
|
+
function ChatLayoutHeader({ className, ...props }) {
|
|
35
|
+
return /* @__PURE__ */ jsx("header", {
|
|
36
|
+
"data-control-ui": "chat-layout",
|
|
37
|
+
"data-control-family": "chat-layout",
|
|
38
|
+
"data-slot": "header",
|
|
39
|
+
className: cn("grid shrink-0 grid-cols-[auto_minmax(0,1fr)_auto] items-center", className),
|
|
40
|
+
...props
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
/** Renders a `div`; pass `render={(props) => <h2 {...props} />}` for the heading level the page needs. */
|
|
44
|
+
function ChatLayoutTitle({ render, className, ...props }) {
|
|
45
|
+
return useRender({
|
|
46
|
+
defaultTagName: "div",
|
|
47
|
+
render,
|
|
48
|
+
props: {
|
|
49
|
+
...props,
|
|
50
|
+
className: cn("col-start-2 min-w-0 truncate", className),
|
|
51
|
+
"data-control-ui": "chat-layout",
|
|
52
|
+
"data-control-family": "chat-layout",
|
|
53
|
+
"data-slot": "title"
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
function ChatLayoutDescription({ className, ...props }) {
|
|
58
|
+
return /* @__PURE__ */ jsx("p", {
|
|
59
|
+
"data-control-ui": "chat-layout",
|
|
60
|
+
"data-control-family": "chat-layout",
|
|
61
|
+
"data-slot": "description",
|
|
62
|
+
className: cn("col-start-2 truncate", className),
|
|
63
|
+
...props
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
function ChatLayoutActions({ className, ...props }) {
|
|
67
|
+
return /* @__PURE__ */ jsx("div", {
|
|
68
|
+
"data-control-ui": "chat-layout",
|
|
69
|
+
"data-control-family": "chat-layout",
|
|
70
|
+
"data-slot": "actions",
|
|
71
|
+
className: cn("col-start-3 row-span-2 row-start-1 flex items-center", className),
|
|
72
|
+
...props
|
|
73
|
+
});
|
|
74
|
+
}
|
|
26
75
|
const ChatThreadScrollContext = createContext(null);
|
|
27
76
|
function ChatThread({ children, composer, className, ...props }) {
|
|
28
77
|
const { viewportRef, contentRef, atBottom, scrollToBottom } = useChatThreadScroll();
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"data-at-bottom": atBottom ? "" : void 0,
|
|
41
|
-
className: cn("min-h-0 min-w-0 flex-1 overflow-y-auto", className),
|
|
42
|
-
...props,
|
|
78
|
+
const [announcement, setAnnouncement] = useState("");
|
|
79
|
+
const [announce] = useState(() => (message) => {
|
|
80
|
+
setAnnouncement((current) => current === message ? `${message}\u00a0` : message);
|
|
81
|
+
});
|
|
82
|
+
return /* @__PURE__ */ jsx(ChatThreadAnnounceContext.Provider, {
|
|
83
|
+
value: announce,
|
|
84
|
+
children: /* @__PURE__ */ jsx(ChatThreadScrollContext.Provider, {
|
|
85
|
+
value: {
|
|
86
|
+
atBottom,
|
|
87
|
+
scrollToBottom
|
|
88
|
+
},
|
|
43
89
|
children: /* @__PURE__ */ jsxs("div", {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
90
|
+
"data-control-ui": "chat-thread",
|
|
91
|
+
"data-control-family": "chat-layout",
|
|
92
|
+
"data-chat-layout-kind": "thread",
|
|
93
|
+
"data-slot": "root",
|
|
94
|
+
"data-at-bottom": atBottom ? "" : void 0,
|
|
95
|
+
className: cn("flex min-h-0 min-w-0 flex-1 flex-col", className),
|
|
96
|
+
...props,
|
|
97
|
+
children: [/* @__PURE__ */ jsx(ScrollArea, {
|
|
98
|
+
className: "flex min-h-0 flex-1 flex-col",
|
|
99
|
+
viewportClassName: "min-h-0 flex-1",
|
|
100
|
+
contentClassName: "flex min-h-full flex-col",
|
|
101
|
+
viewportRef,
|
|
102
|
+
lockAxis: "x",
|
|
103
|
+
mask: false,
|
|
104
|
+
blur: false,
|
|
105
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
106
|
+
ref: contentRef,
|
|
107
|
+
className: "relative flex min-w-0 flex-1 flex-col",
|
|
108
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
109
|
+
"data-control-ui": "chat-thread",
|
|
110
|
+
"data-control-family": "chat-layout",
|
|
111
|
+
"data-slot": "thread-content",
|
|
112
|
+
className: "flex min-w-0 flex-1 flex-col",
|
|
113
|
+
children
|
|
114
|
+
}), composer ? /* @__PURE__ */ jsx("div", {
|
|
115
|
+
"data-control-ui": "chat-thread",
|
|
116
|
+
"data-control-family": "chat-layout",
|
|
117
|
+
"data-slot": "dock",
|
|
118
|
+
className: "sticky bottom-0 z-10 shrink-0",
|
|
119
|
+
children: composer
|
|
120
|
+
}) : null]
|
|
121
|
+
})
|
|
122
|
+
}), /* @__PURE__ */ jsx(LiveStatus, { message: announcement })]
|
|
59
123
|
})
|
|
60
124
|
})
|
|
61
125
|
});
|
|
@@ -97,4 +161,4 @@ function ChatTurn({ from, children, className, ...props }) {
|
|
|
97
161
|
});
|
|
98
162
|
}
|
|
99
163
|
//#endregion
|
|
100
|
-
export { ChatLayout, ChatThread, ChatThreadScrollButton, ChatTurn };
|
|
164
|
+
export { ChatLayout, ChatLayoutActions, ChatLayoutDescription, ChatLayoutHeader, ChatLayoutTitle, ChatThread, ChatThreadScrollButton, ChatTurn };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { ChatMessagePartProps } from "../chat-message.js";
|
|
2
|
+
//#region src/chat-message/social.d.ts
|
|
3
|
+
export type ChatMessageReactionsProps = ChatMessagePartProps<"div">;
|
|
4
|
+
export declare function ChatMessageReactions({ className, "aria-label": ariaLabel, ...props }: ChatMessageReactionsProps): import("react").JSX.Element;
|
|
5
|
+
type ChatMessageReactionChip = {
|
|
6
|
+
emoji: string;
|
|
7
|
+
count: number;
|
|
8
|
+
pressed?: boolean;
|
|
9
|
+
label?: string;
|
|
10
|
+
};
|
|
11
|
+
export type ChatMessageReactionProps = (Omit<ChatMessagePartProps<"button">, "children" | "onClick"> & ChatMessageReactionChip & {
|
|
12
|
+
onPressedChange: (pressed: boolean) => void;
|
|
13
|
+
}) | (Omit<ChatMessagePartProps<"span">, "children"> & ChatMessageReactionChip & {
|
|
14
|
+
/** Omitted for viewers who can see reactions but not add them: the chip renders as static text. */
|
|
15
|
+
onPressedChange?: undefined;
|
|
16
|
+
});
|
|
17
|
+
export declare function ChatMessageReaction(props: ChatMessageReactionProps): import("react").JSX.Element;
|
|
18
|
+
export type ChatMessageReplySummaryProps = ChatMessagePartProps<"button">;
|
|
19
|
+
export declare function ChatMessageReplySummary({ className, type, ...props }: ChatMessageReplySummaryProps): import("react").JSX.Element;
|
|
20
|
+
export type ChatMessageRepliesProps = ChatMessagePartProps<"div">;
|
|
21
|
+
/** Replies shown in place, nested under the message they answer, as in comment discussions. */
|
|
22
|
+
export declare function ChatMessageReplies({ className, ...props }: ChatMessageRepliesProps): import("react").JSX.Element;
|
|
23
|
+
export type ChatTypingIndicatorProps = ChatMessagePartProps<"div">;
|
|
24
|
+
/** A polite status region that stays mounted; pass children only while someone is typing so the change is announced. */
|
|
25
|
+
export declare function ChatTypingIndicator({ className, children, ...props }: ChatTypingIndicatorProps): import("react").JSX.Element;
|
|
26
|
+
//#endregion
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
import { useChatMessageContext } from "../hooks/use-chat-message.js";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
//#region src/chat-message/social.tsx
|
|
6
|
+
function ChatMessageReactions({ className, "aria-label": ariaLabel = "Reactions", ...props }) {
|
|
7
|
+
const message = useChatMessageContext();
|
|
8
|
+
return /* @__PURE__ */ jsx("div", {
|
|
9
|
+
role: "group",
|
|
10
|
+
"aria-label": ariaLabel,
|
|
11
|
+
"data-control-ui": "chat-message",
|
|
12
|
+
"data-control-family": "chat-message",
|
|
13
|
+
"data-slot": "reactions",
|
|
14
|
+
"data-layout": message.layout,
|
|
15
|
+
"data-role": message.from,
|
|
16
|
+
className: cn("flex flex-wrap items-center", className),
|
|
17
|
+
...props
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
function reactionAttributes(pressed, className) {
|
|
21
|
+
return {
|
|
22
|
+
"data-control-ui": "chat-message",
|
|
23
|
+
"data-control-family": "chat-message",
|
|
24
|
+
"data-slot": "reaction",
|
|
25
|
+
"data-pressed": pressed ? "" : void 0,
|
|
26
|
+
className: cn("inline-flex items-center", className)
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function ReactionChipContent({ emoji, count, label }) {
|
|
30
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
31
|
+
/* @__PURE__ */ jsx("span", {
|
|
32
|
+
"aria-hidden": "true",
|
|
33
|
+
"data-control-ui": "chat-message",
|
|
34
|
+
"data-control-family": "chat-message",
|
|
35
|
+
"data-slot": "reaction-emoji",
|
|
36
|
+
children: emoji
|
|
37
|
+
}),
|
|
38
|
+
/* @__PURE__ */ jsx("span", {
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
className: "tabular-nums",
|
|
41
|
+
children: count
|
|
42
|
+
}),
|
|
43
|
+
/* @__PURE__ */ jsx("span", {
|
|
44
|
+
className: "sr-only",
|
|
45
|
+
children: label
|
|
46
|
+
})
|
|
47
|
+
] });
|
|
48
|
+
}
|
|
49
|
+
function ChatMessageReaction(props) {
|
|
50
|
+
const chip = /* @__PURE__ */ jsx(ReactionChipContent, {
|
|
51
|
+
emoji: props.emoji,
|
|
52
|
+
count: props.count,
|
|
53
|
+
label: props.label ?? `${props.emoji} ${props.count}`
|
|
54
|
+
});
|
|
55
|
+
if (props.onPressedChange === void 0) {
|
|
56
|
+
const { emoji, count, pressed = false, label, onPressedChange, className, ...spanProps } = props;
|
|
57
|
+
return /* @__PURE__ */ jsx("span", {
|
|
58
|
+
...reactionAttributes(pressed, className),
|
|
59
|
+
...spanProps,
|
|
60
|
+
children: chip
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
const { emoji, count, pressed = false, label, onPressedChange, className, ...buttonProps } = props;
|
|
64
|
+
return /* @__PURE__ */ jsx("button", {
|
|
65
|
+
type: "button",
|
|
66
|
+
"aria-pressed": pressed,
|
|
67
|
+
onClick: () => onPressedChange(!pressed),
|
|
68
|
+
...reactionAttributes(pressed, className),
|
|
69
|
+
...buttonProps,
|
|
70
|
+
children: chip
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
function ChatMessageReplySummary({ className, type = "button", ...props }) {
|
|
74
|
+
return /* @__PURE__ */ jsx("button", {
|
|
75
|
+
type,
|
|
76
|
+
"data-control-ui": "chat-message",
|
|
77
|
+
"data-control-family": "chat-message",
|
|
78
|
+
"data-slot": "reply-summary",
|
|
79
|
+
className: cn("inline-flex max-w-full items-center self-start text-start", className),
|
|
80
|
+
...props
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
/** Replies shown in place, nested under the message they answer, as in comment discussions. */
|
|
84
|
+
function ChatMessageReplies({ className, ...props }) {
|
|
85
|
+
return /* @__PURE__ */ jsx("div", {
|
|
86
|
+
"data-control-ui": "chat-message",
|
|
87
|
+
"data-control-family": "chat-message",
|
|
88
|
+
"data-slot": "replies",
|
|
89
|
+
className: cn("flex flex-col", className),
|
|
90
|
+
...props
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
/** A polite status region that stays mounted; pass children only while someone is typing so the change is announced. */
|
|
94
|
+
function ChatTypingIndicator({ className, children, ...props }) {
|
|
95
|
+
const someoneIsTyping = children !== null && children !== void 0 && children !== false && children !== "";
|
|
96
|
+
return /* @__PURE__ */ jsx("div", {
|
|
97
|
+
role: "status",
|
|
98
|
+
"data-control-ui": "chat-message",
|
|
99
|
+
"data-control-family": "chat-message",
|
|
100
|
+
"data-slot": "root",
|
|
101
|
+
"data-kind": "typing",
|
|
102
|
+
className: cn("flex min-w-0 items-center", className),
|
|
103
|
+
...props,
|
|
104
|
+
children: someoneIsTyping ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsxs("span", {
|
|
105
|
+
"aria-hidden": "true",
|
|
106
|
+
"data-control-ui": "chat-message",
|
|
107
|
+
"data-control-family": "chat-message",
|
|
108
|
+
"data-slot": "typing-dots",
|
|
109
|
+
className: "inline-flex items-center",
|
|
110
|
+
children: [
|
|
111
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
112
|
+
/* @__PURE__ */ jsx("span", {}),
|
|
113
|
+
/* @__PURE__ */ jsx("span", {})
|
|
114
|
+
]
|
|
115
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
116
|
+
className: "truncate",
|
|
117
|
+
children
|
|
118
|
+
})] }) : null
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
//#endregion
|
|
122
|
+
export { ChatMessageReaction, ChatMessageReactions, ChatMessageReplies, ChatMessageReplySummary, ChatTypingIndicator };
|
package/dist/chat-message.d.ts
CHANGED
|
@@ -1,35 +1,34 @@
|
|
|
1
1
|
import { ChatMessageKnobStyle } from "./knob-contracts/chat-message-knobs.js";
|
|
2
2
|
import { ChatMessageProps } from "./hooks/use-chat-message.js";
|
|
3
|
-
import {
|
|
3
|
+
import { ChatMessageReaction, ChatMessageReactionProps, ChatMessageReactions, ChatMessageReactionsProps, ChatMessageReplies, ChatMessageRepliesProps, ChatMessageReplySummary, ChatMessageReplySummaryProps, ChatTypingIndicator, ChatTypingIndicatorProps } from "./chat-message/social.js";
|
|
4
|
+
import { CSSProperties, ComponentProps, JSX } from "react";
|
|
4
5
|
//#region src/chat-message.d.ts
|
|
5
|
-
export
|
|
6
|
-
export type ChatMessageRowProps = ComponentProps<"div"> & {
|
|
6
|
+
export type ChatMessagePartProps<Element extends keyof JSX.IntrinsicElements> = Omit<ComponentProps<Element>, "style"> & {
|
|
7
7
|
style?: CSSProperties & ChatMessageKnobStyle;
|
|
8
8
|
};
|
|
9
|
-
export declare function
|
|
10
|
-
export type
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export declare function ChatMessageAvatar({ className, ...props }: ChatMessageAvatarProps):
|
|
14
|
-
export type ChatMessageBodyProps =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
export declare function
|
|
18
|
-
export type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
export type ChatMessageContentProps = Omit<ComponentProps<"div">, "style"> & {
|
|
23
|
-
style?: CSSProperties & ChatMessageKnobStyle;
|
|
24
|
-
};
|
|
25
|
-
export declare function ChatMessageContent({ className, ...props }: ChatMessageContentProps): import("react").JSX.Element;
|
|
26
|
-
export type ChatMessagePendingProps = Omit<ComponentProps<"div">, "style" | "children"> & {
|
|
27
|
-
label?: string;
|
|
28
|
-
style?: CSSProperties & ChatMessageKnobStyle;
|
|
29
|
-
};
|
|
30
|
-
export declare function ChatMessagePending({ label, className, ...props }: ChatMessagePendingProps): import("react").JSX.Element | null;
|
|
31
|
-
export type ChatMessageActionsProps = Omit<ComponentProps<"div">, "style"> & {
|
|
32
|
-
style?: CSSProperties & ChatMessageKnobStyle;
|
|
9
|
+
export declare function ChatMessage({ from, state, density, layout, continuation, authorLabel, statusLabels, className, children, ...props }: ChatMessageProps): JSX.Element;
|
|
10
|
+
export type ChatMessageRowProps = ChatMessagePartProps<"div">;
|
|
11
|
+
export declare function ChatMessageRow({ className, children, ...props }: ChatMessageRowProps): JSX.Element;
|
|
12
|
+
export type ChatMessageAvatarProps = ChatMessagePartProps<"div">;
|
|
13
|
+
export declare function ChatMessageAvatar({ className, ...props }: ChatMessageAvatarProps): JSX.Element;
|
|
14
|
+
export type ChatMessageBodyProps = ChatMessagePartProps<"div">;
|
|
15
|
+
export declare function ChatMessageBody({ className, ...props }: ChatMessageBodyProps): JSX.Element;
|
|
16
|
+
export type ChatMessageHeaderProps = ChatMessagePartProps<"div">;
|
|
17
|
+
export declare function ChatMessageHeader({ className, ...props }: ChatMessageHeaderProps): JSX.Element;
|
|
18
|
+
export type ChatMessageAuthorProps = ChatMessagePartProps<"span">;
|
|
19
|
+
export declare function ChatMessageAuthor({ className, ...props }: ChatMessageAuthorProps): JSX.Element;
|
|
20
|
+
export type ChatMessageTimeProps = ChatMessagePartProps<"time"> & {
|
|
21
|
+
dateTime: string;
|
|
33
22
|
};
|
|
34
|
-
export declare function
|
|
35
|
-
|
|
23
|
+
export declare function ChatMessageTime({ className, ...props }: ChatMessageTimeProps): JSX.Element;
|
|
24
|
+
export type ChatMessageContentProps = ChatMessagePartProps<"div">;
|
|
25
|
+
export declare function ChatMessageContent({ className, ...props }: ChatMessageContentProps): JSX.Element;
|
|
26
|
+
export type ChatMessagePendingProps = Omit<ChatMessagePartProps<"div">, "children">;
|
|
27
|
+
/** Visual only: the pending transition is announced by `ChatMessage` through the thread's status region. */
|
|
28
|
+
export declare function ChatMessagePending({ className, ...props }: ChatMessagePendingProps): JSX.Element | null;
|
|
29
|
+
export type ChatMessageFooterProps = ChatMessagePartProps<"div">;
|
|
30
|
+
export declare function ChatMessageFooter({ className, ...props }: ChatMessageFooterProps): JSX.Element;
|
|
31
|
+
export type ChatMessageActionsProps = ChatMessagePartProps<"div">;
|
|
32
|
+
export declare function ChatMessageActions({ className, children, ...props }: ChatMessageActionsProps): JSX.Element;
|
|
33
|
+
//#endregion
|
|
34
|
+
export { ChatMessageReaction, type ChatMessageReactionProps, ChatMessageReactions, type ChatMessageReactionsProps, ChatMessageReplies, type ChatMessageRepliesProps, ChatMessageReplySummary, type ChatMessageReplySummaryProps, ChatTypingIndicator, type ChatTypingIndicatorProps };
|