@ctrl-ui/react 0.8.2 → 0.8.4
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 +32 -23
- package/dist/action-bar.d.ts +11 -12
- package/dist/activity.d.ts +24 -25
- package/dist/audio-recorder.d.ts +16 -16
- package/dist/audio-visualizer.d.ts +3 -4
- package/dist/blocks/chat.d.ts +3 -4
- package/dist/blocks/chat.js +6 -3
- package/dist/blocks/coding-agent.d.ts +11 -12
- package/dist/blocks/coding-agent.js +10 -9
- package/dist/blocks/file-explorer-data.d.ts +11 -12
- package/dist/blocks/file-explorer.d.ts +3 -3
- package/dist/blocks/settings-data.d.ts +8 -9
- package/dist/blocks/settings.d.ts +4 -4
- package/dist/blocks/theme-toggle.d.ts +11 -12
- package/dist/blocks/theme-toggle.js +14 -4
- package/dist/chat-composer-attachment.d.ts +20 -21
- package/dist/chat-composer-attachment.js +24 -20
- package/dist/chat-composer-editor/extensions/mention.d.ts +5 -6
- package/dist/chat-composer-editor/ghost.d.ts +3 -4
- package/dist/chat-composer-editor/schema.d.ts +2 -3
- package/dist/chat-composer-editor/serialize.d.ts +3 -4
- package/dist/chat-composer-editor/types.d.ts +5 -6
- package/dist/chat-composer-editor.d.ts +2 -3
- package/dist/chat-composer-editor.js +18 -4
- package/dist/chat-composer.d.ts +17 -18
- package/dist/chat-composer.js +14 -8
- package/dist/chat-layout.d.ts +12 -21
- package/dist/chat-layout.js +28 -83
- package/dist/chat-message.d.ts +14 -15
- package/dist/context-model.d.ts +7 -8
- package/dist/context.d.ts +21 -22
- package/dist/control-props.d.ts +10 -11
- package/dist/control-variants.d.ts +6 -7
- package/dist/dynamic-notification-glass.d.ts +3 -4
- package/dist/dynamic-notification-liquid.d.ts +3 -4
- package/dist/dynamic-notification-siri-wave.d.ts +2 -3
- package/dist/dynamic-notification.d.ts +28 -29
- package/dist/email/email.d.ts +6 -7
- package/dist/email/length.d.ts +2 -3
- package/dist/email/templates.d.ts +7 -8
- package/dist/email/theme.d.ts +4 -5
- package/dist/environment-variables.d.ts +35 -36
- package/dist/extensions/create-track-highlight.d.ts +3 -4
- package/dist/extensions/supports-anchor-transitions.d.ts +2 -3
- package/dist/extensions/track-highlight.d.ts +3 -4
- package/dist/hooks/use-audio-recorder.d.ts +14 -15
- package/dist/hooks/use-chat-composer.d.ts +5 -6
- package/dist/hooks/use-chat-message.d.ts +7 -8
- package/dist/hooks/use-color-area.d.ts +5 -6
- package/dist/hooks/use-copy-to-clipboard.d.ts +7 -8
- package/dist/hooks/use-dropzone.d.ts +11 -12
- package/dist/hooks/use-dynamic-notification.d.ts +6 -7
- package/dist/hooks/use-environment-variables.d.ts +9 -10
- package/dist/hooks/use-keyboard-navigation.d.ts +3 -0
- package/dist/hooks/use-keyboard-navigation.js +22 -0
- package/dist/hooks/use-mobile.d.ts +2 -3
- package/dist/hooks/use-textarea-trigger-menu.d.ts +2 -3
- package/dist/hooks/use-trigger-menu.d.ts +7 -8
- package/dist/hooks/use-user-ask.d.ts +6 -7
- package/dist/inline-attachment.d.ts +16 -17
- package/dist/inline-citation.d.ts +22 -23
- package/dist/knob-contracts/accordion-knobs.d.ts +3 -4
- package/dist/knob-contracts/accordion-knobs.js +1 -0
- package/dist/knob-contracts/action-bar-knobs.d.ts +3 -4
- package/dist/knob-contracts/activity-knobs.d.ts +3 -4
- package/dist/knob-contracts/alert-knobs.d.ts +3 -4
- package/dist/knob-contracts/alert-knobs.js +12 -1
- package/dist/knob-contracts/audio-recorder-knobs.d.ts +3 -4
- package/dist/knob-contracts/audio-visualizer-knobs.d.ts +3 -4
- package/dist/knob-contracts/avatar-knobs.d.ts +3 -4
- package/dist/knob-contracts/avatar-knobs.js +2 -1
- package/dist/knob-contracts/badge-knobs.d.ts +3 -4
- package/dist/knob-contracts/button-group-knobs.d.ts +3 -4
- package/dist/knob-contracts/button-knobs.d.ts +3 -4
- package/dist/knob-contracts/button-knobs.js +1 -0
- package/dist/knob-contracts/calendar-knobs.d.ts +3 -4
- package/dist/knob-contracts/card-knobs.d.ts +3 -4
- package/dist/knob-contracts/chat-composer-attachment-knobs.d.ts +3 -4
- package/dist/knob-contracts/chat-composer-attachment-knobs.js +3 -1
- package/dist/knob-contracts/chat-composer-knobs.d.ts +3 -4
- package/dist/knob-contracts/chat-composer-knobs.js +1 -0
- package/dist/knob-contracts/chat-layout-knobs.d.ts +3 -4
- package/dist/knob-contracts/chat-layout-knobs.js +2 -3
- package/dist/knob-contracts/chat-message-knobs.d.ts +3 -4
- package/dist/knob-contracts/choice-knobs.d.ts +3 -4
- package/dist/knob-contracts/choice-knobs.js +2 -1
- package/dist/knob-contracts/code-diff-knobs.d.ts +3 -4
- package/dist/knob-contracts/code-diff-knobs.js +1 -0
- package/dist/knob-contracts/code-knobs.d.ts +3 -4
- package/dist/knob-contracts/code-knobs.js +3 -1
- package/dist/knob-contracts/collapsible-knobs.d.ts +3 -4
- package/dist/knob-contracts/color-picker-knobs.d.ts +3 -4
- package/dist/knob-contracts/context-knobs.d.ts +3 -4
- package/dist/knob-contracts/dockable-panel-knobs.d.ts +3 -4
- package/dist/knob-contracts/dockable-panel-knobs.js +1 -0
- package/dist/knob-contracts/dropzone-knobs.d.ts +3 -4
- package/dist/knob-contracts/dropzone-knobs.js +1 -0
- package/dist/knob-contracts/dynamic-notification-knobs.d.ts +3 -4
- package/dist/knob-contracts/empty-knobs.d.ts +3 -4
- package/dist/knob-contracts/empty-knobs.js +14 -1
- package/dist/knob-contracts/environment-variables-knobs.d.ts +3 -4
- package/dist/knob-contracts/environment-variables-knobs.js +2 -1
- package/dist/knob-contracts/field-knobs.d.ts +3 -4
- package/dist/knob-contracts/gradient-editor-knobs.d.ts +3 -4
- package/dist/knob-contracts/gradient-editor-knobs.js +3 -1
- package/dist/knob-contracts/infinite-canvas-knobs.d.ts +3 -4
- package/dist/knob-contracts/inline-attachment-knobs.d.ts +3 -4
- package/dist/knob-contracts/inline-attachment-knobs.js +2 -1
- package/dist/knob-contracts/inline-citation-knobs.d.ts +3 -4
- package/dist/knob-contracts/inline-citation-knobs.js +1 -0
- package/dist/knob-contracts/item-knobs.d.ts +3 -4
- package/dist/knob-contracts/kbd-knobs.d.ts +3 -4
- package/dist/knob-contracts/markdown-block-knobs.d.ts +3 -4
- package/dist/knob-contracts/markdown-block-knobs.js +2 -0
- package/dist/knob-contracts/markdown-knobs.d.ts +3 -4
- package/dist/knob-contracts/markdown-knobs.js +1 -0
- package/dist/knob-contracts/morphing-panel-knobs.d.ts +3 -4
- package/dist/knob-contracts/pagination-knobs.d.ts +3 -4
- package/dist/knob-contracts/phone-input-knobs.d.ts +3 -4
- package/dist/knob-contracts/phone-input-knobs.js +1 -0
- package/dist/knob-contracts/popup-knobs.d.ts +3 -4
- package/dist/knob-contracts/progressive-blur-knobs.d.ts +3 -4
- package/dist/knob-contracts/progressive-blur-knobs.js +1 -0
- package/dist/knob-contracts/range-knobs.d.ts +3 -4
- package/dist/knob-contracts/resizable-knobs.d.ts +3 -4
- package/dist/knob-contracts/resizable-knobs.js +1 -0
- package/dist/knob-contracts/rich-tooltip-knobs.d.ts +3 -4
- package/dist/knob-contracts/scroll-area-knobs.d.ts +3 -4
- package/dist/knob-contracts/separator-knobs.d.ts +3 -4
- package/dist/knob-contracts/sidebar-knobs.d.ts +3 -4
- package/dist/knob-contracts/sidebar-knobs.js +1 -0
- package/dist/knob-contracts/skeleton-knobs.d.ts +3 -4
- package/dist/knob-contracts/skeleton-knobs.js +9 -1
- package/dist/knob-contracts/source-badge-knobs.d.ts +3 -4
- package/dist/knob-contracts/spinner-knobs.d.ts +3 -4
- package/dist/knob-contracts/stepper-knobs.d.ts +3 -4
- package/dist/knob-contracts/stepper-knobs.js +1 -0
- package/dist/knob-contracts/switch-knobs.d.ts +3 -4
- package/dist/knob-contracts/switch-knobs.js +7 -1
- package/dist/knob-contracts/table-knobs.d.ts +3 -4
- package/dist/knob-contracts/table-of-contents-knobs.d.ts +3 -4
- package/dist/knob-contracts/table-of-contents-knobs.js +25 -0
- package/dist/knob-contracts/tabs-knobs.d.ts +3 -4
- package/dist/knob-contracts/tabs-knobs.js +2 -1
- package/dist/knob-contracts/task-list-knobs.d.ts +3 -4
- package/dist/knob-contracts/task-list-knobs.js +1 -0
- package/dist/knob-contracts/thread-rail-knobs.d.ts +3 -4
- package/dist/knob-contracts/timeline-knobs.d.ts +3 -4
- package/dist/knob-contracts/toolbar-knobs.d.ts +3 -4
- package/dist/knob-contracts/toolbar-knobs.js +1 -0
- package/dist/knob-contracts/track-highlight-knobs.d.ts +3 -4
- package/dist/knob-contracts/transcript-divider-knobs.d.ts +3 -4
- package/dist/knob-contracts/tree-knobs.d.ts +3 -4
- package/dist/knob-contracts/user-ask-knobs.d.ts +3 -4
- package/dist/knob-contracts/user-ask-knobs.js +1 -0
- package/dist/lib/cn.d.ts +2 -3
- package/dist/lib/code-tokens.d.ts +12 -13
- package/dist/lib/color.d.ts +26 -27
- package/dist/lib/contrast.d.ts +12 -13
- package/dist/lib/diff.d.ts +14 -15
- package/dist/lib/dropzone-validation.d.ts +25 -26
- package/dist/lib/env-file.d.ts +12 -13
- package/dist/lib/format-audio-recorder-duration.d.ts +2 -3
- package/dist/lib/liquid-glass-optics.d.ts +2 -3
- package/dist/lib/phone-input-format.d.ts +3 -4
- package/dist/lib/phone-input-format.js +1 -1
- package/dist/lib/phone-number.d.ts +8 -9
- package/dist/lib/trigger-detect.d.ts +4 -5
- package/dist/markdown-block.d.ts +11 -12
- package/dist/scripts/contrast-eval.d.ts +16 -17
- package/dist/scripts/contrast-eval.js +13 -7
- package/dist/skin-provider.d.ts +14 -0
- package/dist/skin-provider.js +21 -0
- package/dist/skin.d.ts +14 -33
- package/dist/skin.js +3 -46
- package/dist/source-badge.d.ts +7 -8
- package/dist/styles/index.css +1 -4
- package/dist/styles/recipes/accordion.css +8 -2
- package/dist/styles/recipes/action-bar.css +5 -2
- package/dist/styles/recipes/alert.css +95 -16
- package/dist/styles/recipes/avatar.css +17 -1
- package/dist/styles/recipes/badge.css +0 -1
- package/dist/styles/recipes/button.css +34 -8
- package/dist/styles/recipes/calendar.css +0 -6
- package/dist/styles/recipes/chat-composer-attachment.css +51 -53
- package/dist/styles/recipes/chat-composer.css +26 -21
- package/dist/styles/recipes/chat-layout.css +21 -62
- package/dist/styles/recipes/chat-message.css +11 -5
- package/dist/styles/recipes/choice.css +9 -2
- package/dist/styles/recipes/code-diff.css +8 -1
- package/dist/styles/recipes/code.css +39 -17
- package/dist/styles/recipes/collapsible.css +0 -3
- package/dist/styles/recipes/color-picker-details.css +1 -2
- package/dist/styles/recipes/color-picker-values.css +0 -4
- package/dist/styles/recipes/dockable-panel.css +8 -1
- package/dist/styles/recipes/dropzone.css +9 -2
- package/dist/styles/recipes/empty.css +118 -17
- package/dist/styles/recipes/environment-variables.css +8 -1
- package/dist/styles/recipes/field-parts.css +1 -6
- package/dist/styles/recipes/field.css +9 -5
- package/dist/styles/recipes/gradient-editor.css +16 -5
- package/dist/styles/recipes/inline-attachment.css +13 -8
- package/dist/styles/recipes/inline-citation.css +8 -4
- package/dist/styles/recipes/item.css +1 -1
- package/dist/styles/recipes/kbd.css +8 -0
- package/dist/styles/recipes/markdown-block.css +16 -2
- package/dist/styles/recipes/markdown.css +12 -0
- package/dist/styles/recipes/morphing-panel.css +1 -1
- package/dist/styles/recipes/pagination.css +0 -4
- package/dist/styles/recipes/phone-input.css +8 -4
- package/dist/styles/recipes/popup-lists.css +11 -0
- package/dist/styles/recipes/popup-toast.css +1 -29
- package/dist/styles/recipes/popup.css +2 -2
- package/dist/styles/recipes/progressive-blur.css +28 -7
- package/dist/styles/recipes/range.css +50 -1
- package/dist/styles/recipes/resizable.css +8 -10
- package/dist/styles/recipes/rich-tooltip.css +0 -4
- package/dist/styles/recipes/scroll-area.css +8 -2
- package/dist/styles/recipes/sidebar-menu.css +0 -6
- package/dist/styles/recipes/sidebar.css +56 -17
- package/dist/styles/recipes/skeleton.css +85 -3
- package/dist/styles/recipes/source-badge.css +0 -3
- package/dist/styles/recipes/stepper.css +8 -1
- package/dist/styles/recipes/switch.css +89 -17
- package/dist/styles/recipes/table-of-contents.css +211 -45
- package/dist/styles/recipes/table.css +0 -1
- package/dist/styles/recipes/tabs.css +19 -2
- package/dist/styles/recipes/task-list.css +8 -2
- package/dist/styles/recipes/thread-rail.css +0 -4
- package/dist/styles/recipes/toolbar.css +18 -4
- package/dist/styles/recipes/track-highlight.css +63 -5
- package/dist/styles/recipes/tree.css +2 -0
- package/dist/styles/recipes/user-ask.css +8 -4
- package/dist/styles/theme.css +130 -138
- package/dist/surface-variants.d.ts +4 -5
- package/dist/task-list.d.ts +16 -17
- package/dist/thread-rail.d.ts +21 -22
- package/dist/transcript-divider.d.ts +6 -7
- package/dist/ui/accordion.d.ts +10 -11
- package/dist/ui/alert-dialog.d.ts +11 -12
- package/dist/ui/alert-dialog.js +8 -6
- package/dist/ui/alert.d.ts +9 -10
- package/dist/ui/alert.js +3 -3
- package/dist/ui/aspect-ratio.d.ts +3 -4
- package/dist/ui/autocomplete.d.ts +19 -20
- package/dist/ui/autocomplete.js +5 -3
- package/dist/ui/avatar.d.ts +9 -10
- package/dist/ui/badge.d.ts +9 -10
- package/dist/ui/button-group.d.ts +7 -8
- package/dist/ui/button-group.js +3 -2
- package/dist/ui/button.d.ts +17 -18
- package/dist/ui/button.js +20 -5
- package/dist/ui/calendar.d.ts +3 -4
- package/dist/ui/card.d.ts +16 -17
- package/dist/ui/checkbox-group.d.ts +4 -5
- package/dist/ui/checkbox-group.js +3 -2
- package/dist/ui/checkbox.d.ts +3 -4
- package/dist/ui/code-diff.d.ts +8 -9
- package/dist/ui/code.d.ts +32 -23
- package/dist/ui/code.js +41 -20
- package/dist/ui/collapsible.d.ts +7 -8
- package/dist/ui/color-picker.d.ts +40 -41
- package/dist/ui/color-picker.js +6 -4
- package/dist/ui/combobox-disabled-selection.d.ts +3 -4
- package/dist/ui/combobox.d.ts +19 -20
- package/dist/ui/combobox.js +5 -3
- package/dist/ui/command.d.ts +19 -18
- package/dist/ui/command.js +38 -12
- package/dist/ui/context-menu.d.ts +30 -31
- package/dist/ui/context-menu.js +8 -5
- package/dist/ui/dialog.d.ts +13 -13
- package/dist/ui/dialog.js +10 -8
- package/dist/ui/dockable-panel-geometry.d.ts +7 -8
- package/dist/ui/dockable-panel.d.ts +21 -22
- package/dist/ui/drawer.d.ts +17 -18
- package/dist/ui/drawer.js +7 -6
- package/dist/ui/dropdown-menu.d.ts +32 -33
- package/dist/ui/dropdown-menu.js +5 -3
- package/dist/ui/dropzone.d.ts +24 -24
- package/dist/ui/empty.d.ts +14 -14
- package/dist/ui/empty.js +3 -3
- package/dist/ui/field.d.ts +26 -27
- package/dist/ui/form.d.ts +4 -5
- package/dist/ui/gradient-editor.d.ts +16 -17
- package/dist/ui/hover-card.d.ts +6 -7
- package/dist/ui/hover-card.js +5 -3
- package/dist/ui/infinite-canvas.d.ts +11 -12
- package/dist/ui/input-group.d.ts +6 -7
- package/dist/ui/input-otp.d.ts +7 -8
- package/dist/ui/input.d.ts +3 -4
- package/dist/ui/item.d.ts +20 -21
- package/dist/ui/kbd.d.ts +7 -5
- package/dist/ui/kbd.js +4 -2
- package/dist/ui/markdown-elements.d.ts +20 -21
- package/dist/ui/markdown.d.ts +5 -6
- package/dist/ui/menubar.d.ts +25 -26
- package/dist/ui/menubar.js +8 -5
- package/dist/ui/meter.d.ts +11 -12
- package/dist/ui/morphing-panel.d.ts +8 -9
- package/dist/ui/native-select.d.ts +3 -4
- package/dist/ui/native-select.js +1 -1
- package/dist/ui/navigation-menu.d.ts +17 -18
- package/dist/ui/navigation-menu.js +5 -3
- package/dist/ui/number-field.d.ts +15 -16
- package/dist/ui/pagination.d.ts +10 -11
- package/dist/ui/phone-input.d.ts +5 -6
- package/dist/ui/phone-input.js +40 -37
- package/dist/ui/popover.d.ts +11 -12
- package/dist/ui/popover.js +5 -3
- package/dist/ui/progress.d.ts +11 -12
- package/dist/ui/progressive-blur.d.ts +4 -5
- package/dist/ui/radio-group.d.ts +5 -6
- package/dist/ui/resizable.d.ts +12 -13
- package/dist/ui/responsive-dialog.d.ts +11 -12
- package/dist/ui/rich-tooltip-tour.d.ts +5 -6
- package/dist/ui/rich-tooltip.d.ts +21 -23
- package/dist/ui/rich-tooltip.js +5 -5
- package/dist/ui/scroll-area.d.ts +7 -8
- package/dist/ui/scroll-area.js +9 -6
- package/dist/ui/select.d.ts +21 -14
- package/dist/ui/select.js +7 -4
- package/dist/ui/separator.d.ts +2 -3
- package/dist/ui/sheet.d.ts +8 -9
- package/dist/ui/sheet.js +7 -5
- package/dist/ui/sidebar-menu.d.ts +18 -19
- package/dist/ui/sidebar-menu.js +4 -3
- package/dist/ui/sidebar-provider.d.ts +32 -7
- package/dist/ui/sidebar-provider.js +82 -22
- package/dist/ui/sidebar-resize-rail.d.ts +8 -0
- package/dist/ui/sidebar-resize-rail.js +192 -0
- package/dist/ui/sidebar.d.ts +19 -13
- package/dist/ui/sidebar.js +120 -55
- package/dist/ui/skeleton.d.ts +7 -4
- package/dist/ui/skeleton.js +9 -2
- package/dist/ui/slider.d.ts +6 -5
- package/dist/ui/slider.js +16 -13
- package/dist/ui/spinner.d.ts +3 -4
- package/dist/ui/stepper.d.ts +22 -23
- package/dist/ui/switch.d.ts +3 -4
- package/dist/ui/switch.js +12 -1
- package/dist/ui/table-of-contents.d.ts +7 -8
- package/dist/ui/table-of-contents.js +4 -2
- package/dist/ui/table.d.ts +17 -18
- package/dist/ui/tabs.d.ts +14 -11
- package/dist/ui/textarea.d.ts +3 -4
- package/dist/ui/timeline.d.ts +18 -19
- package/dist/ui/toast.d.ts +9 -9
- package/dist/ui/toast.js +21 -14
- package/dist/ui/toggle.d.ts +5 -6
- package/dist/ui/toggle.js +3 -2
- package/dist/ui/toolbar.d.ts +15 -16
- package/dist/ui/toolbar.js +15 -4
- package/dist/ui/tooltip.d.ts +6 -13
- package/dist/ui/tooltip.js +7 -8
- package/dist/ui/tree.d.ts +18 -19
- package/dist/ui/tree.js +3 -2
- package/dist/ui/trigger-menu.d.ts +15 -16
- package/dist/ui/trigger-menu.js +5 -3
- package/dist/ui/use-switch-drag.d.ts +7 -0
- package/dist/ui/use-switch-drag.js +104 -0
- package/dist/user-ask.d.ts +24 -25
- package/package.json +15 -15
- package/dist/code-block-editor.d.ts +0 -59
- package/dist/code-block-editor.js +0 -250
- package/dist/knob-contracts/code-block-editor-knobs.d.ts +0 -5
- package/dist/knob-contracts/code-block-editor-knobs.js +0 -11
- package/dist/lib/code-block-shiki.d.ts +0 -9
- package/dist/lib/code-block-shiki.js +0 -6
- package/dist/skin.config.d.ts +0 -5
- package/dist/skin.config.js +0 -12
- package/dist/styles/recipes/code-block-editor.css +0 -136
- package/dist/styles/skin-theme.css +0 -137
- package/dist/styles/skin.css +0 -143
|
@@ -63,26 +63,36 @@ function ThemeSegmentedSwitch({ value, onValueChange, options = defaultThemeOpti
|
|
|
63
63
|
const currentValue = effectiveThemeValue(value, choices);
|
|
64
64
|
const activeIndex = Math.max(0, choices.findIndex((option) => option.value === currentValue));
|
|
65
65
|
const indicatorStyle = {
|
|
66
|
-
width: `calc((100% -
|
|
66
|
+
width: `calc((100% - var(--_theme-switch-padding) * 2) / ${choices.length})`,
|
|
67
67
|
transform: `translateX(${activeIndex * 100}%)`
|
|
68
68
|
};
|
|
69
69
|
return /* @__PURE__ */ jsxs("div", {
|
|
70
70
|
role: "radiogroup",
|
|
71
71
|
"aria-label": ariaLabel,
|
|
72
|
-
|
|
72
|
+
"data-control-ui": "theme-toggle",
|
|
73
|
+
"data-control-family": "theme-toggle",
|
|
74
|
+
"data-slot": "root",
|
|
75
|
+
className: classes("relative isolate inline-grid w-fit shrink-0 auto-cols-fr grid-flow-col [--_theme-switch-padding:calc(var(--spacing)*0.5)] [--_theme-switch-radius:min(var(--radius-control),calc(var(--control-h-xs)/2))] rounded-[calc(var(--_theme-switch-radius)+clamp(0px,var(--_theme-switch-radius)*1000,var(--_theme-switch-padding)))] border-(length:--control-rim-width) border-(--control-rim) bg-(--hover-fill) p-(--_theme-switch-padding) text-muted-foreground shadow-(--shadow-inset)", className),
|
|
73
76
|
style,
|
|
74
77
|
...props,
|
|
75
78
|
children: [/* @__PURE__ */ jsx("span", {
|
|
76
79
|
"aria-hidden": true,
|
|
77
|
-
|
|
80
|
+
"data-control-ui": "theme-toggle",
|
|
81
|
+
"data-control-family": "theme-toggle",
|
|
82
|
+
"data-slot": "indicator",
|
|
83
|
+
className: "pointer-events-none absolute inset-y-(--_theme-switch-padding) left-(--_theme-switch-padding) rounded-(--_theme-switch-radius) bg-background shadow-(--shadow-sm) transition-transform duration-(--duration-base) ease-(--ease-standard)",
|
|
78
84
|
style: indicatorStyle
|
|
79
85
|
}), choices.map((option) => {
|
|
80
86
|
const selected = option.value === currentValue;
|
|
81
87
|
const Icon = option.icon;
|
|
82
88
|
return /* @__PURE__ */ jsxs("label", {
|
|
89
|
+
"data-control-ui": "theme-toggle",
|
|
90
|
+
"data-control-family": "theme-toggle",
|
|
91
|
+
"data-slot": "option",
|
|
92
|
+
"data-control": "true",
|
|
83
93
|
"data-selected": selected ? "true" : void 0,
|
|
84
94
|
"data-disabled": option.disabled ? "true" : void 0,
|
|
85
|
-
className: classes("relative z-[1] inline-flex h-
|
|
95
|
+
className: classes("relative z-[1] inline-flex h-(--control-h-xs) cursor-pointer items-center justify-center gap-1.5 rounded-(--_theme-switch-radius) px-1.5 text-label font-medium transition-colors duration-(--duration-fast) ease-(--ease-standard) hover:text-foreground data-[disabled=true]:cursor-not-allowed data-[disabled=true]:opacity-45 data-[selected=true]:text-foreground", showLabels ? "min-w-20" : "w-(--control-h-xs)"),
|
|
86
96
|
children: [
|
|
87
97
|
/* @__PURE__ */ jsx("input", {
|
|
88
98
|
type: "radio",
|
|
@@ -3,17 +3,17 @@ import { Button } from "./ui/button.js";
|
|
|
3
3
|
import { ChatComposerAttachmentKnobStyle } from "./knob-contracts/chat-composer-attachment-knobs.js";
|
|
4
4
|
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
5
5
|
//#region src/chat-composer-attachment.d.ts
|
|
6
|
-
type ChatComposerAttachmentKind = "image" | "pdf" | "spreadsheet" | "document" | "archive" | "audio" | "video" | "file";
|
|
7
|
-
type ChatComposerAttachmentStatus = "idle" | "uploading" | "uploaded" | "error";
|
|
8
|
-
type ChatComposerAttachmentVariant = "auto" | "preview" | "file";
|
|
9
|
-
type ChatComposerAttachmentsProps = ComponentProps<"div"> & {
|
|
6
|
+
export type ChatComposerAttachmentKind = "image" | "pdf" | "spreadsheet" | "document" | "archive" | "audio" | "video" | "file";
|
|
7
|
+
export type ChatComposerAttachmentStatus = "idle" | "uploading" | "uploaded" | "error";
|
|
8
|
+
export type ChatComposerAttachmentVariant = "auto" | "preview" | "file";
|
|
9
|
+
export type ChatComposerAttachmentsProps = ComponentProps<"div"> & {
|
|
10
10
|
label?: string;
|
|
11
11
|
viewportClassName?: string;
|
|
12
12
|
} & {
|
|
13
13
|
style?: CSSProperties & ChatComposerAttachmentKnobStyle;
|
|
14
14
|
};
|
|
15
|
-
declare function ChatComposerAttachments({ label, className, viewportClassName, children, ...props }: ChatComposerAttachmentsProps): import("react").JSX.Element;
|
|
16
|
-
type ChatComposerAttachmentProps = Omit<ComponentProps<"li">, "style"> & {
|
|
15
|
+
export declare function ChatComposerAttachments({ label, className, viewportClassName, children, ...props }: ChatComposerAttachmentsProps): import("react").JSX.Element;
|
|
16
|
+
export type ChatComposerAttachmentProps = Omit<ComponentProps<"li">, "style"> & {
|
|
17
17
|
name: string;
|
|
18
18
|
type?: string;
|
|
19
19
|
description?: ReactNode;
|
|
@@ -26,30 +26,29 @@ type ChatComposerAttachmentProps = Omit<ComponentProps<"li">, "style"> & {
|
|
|
26
26
|
removeLabel?: string;
|
|
27
27
|
style?: CSSProperties & ChatComposerAttachmentKnobStyle;
|
|
28
28
|
};
|
|
29
|
-
declare function ChatComposerAttachment({ name, type, description, status, progress: progressInput, previewUrl, kind, variant, onRemove, removeLabel, className, children, role, "aria-label": ariaLabel, ...props }: ChatComposerAttachmentProps): import("react").JSX.Element;
|
|
30
|
-
type ChatComposerAttachmentPreviewProps = Omit<ComponentProps<"div">, "style"> & {
|
|
29
|
+
export declare function ChatComposerAttachment({ name, type, description, status, progress: progressInput, previewUrl, kind, variant, onRemove, removeLabel, className, children, role, "aria-label": ariaLabel, ...props }: ChatComposerAttachmentProps): import("react").JSX.Element;
|
|
30
|
+
export type ChatComposerAttachmentPreviewProps = Omit<ComponentProps<"div">, "style"> & {
|
|
31
31
|
style?: CSSProperties & ChatComposerAttachmentKnobStyle;
|
|
32
32
|
};
|
|
33
|
-
declare function ChatComposerAttachmentPreview({ className, children, ...props }: ChatComposerAttachmentPreviewProps): import("react").JSX.Element;
|
|
34
|
-
type ChatComposerAttachmentContentProps = ComponentProps<"div"> & {
|
|
33
|
+
export declare function ChatComposerAttachmentPreview({ className, children, ...props }: ChatComposerAttachmentPreviewProps): import("react").JSX.Element;
|
|
34
|
+
export type ChatComposerAttachmentContentProps = ComponentProps<"div"> & {
|
|
35
35
|
style?: CSSProperties & ChatComposerAttachmentKnobStyle;
|
|
36
36
|
};
|
|
37
|
-
declare function ChatComposerAttachmentContent({ className, ...props }: ChatComposerAttachmentContentProps): import("react").JSX.Element;
|
|
38
|
-
type ChatComposerAttachmentTitleProps = Omit<ComponentProps<"div">, "style"> & {
|
|
37
|
+
export declare function ChatComposerAttachmentContent({ className, ...props }: ChatComposerAttachmentContentProps): import("react").JSX.Element;
|
|
38
|
+
export type ChatComposerAttachmentTitleProps = Omit<ComponentProps<"div">, "style"> & {
|
|
39
39
|
style?: CSSProperties & ChatComposerAttachmentKnobStyle;
|
|
40
40
|
};
|
|
41
|
-
declare function ChatComposerAttachmentTitle({ className, children, ...props }: ChatComposerAttachmentTitleProps): import("react").JSX.Element;
|
|
42
|
-
type ChatComposerAttachmentDescriptionProps = Omit<ComponentProps<"div">, "style"> & {
|
|
41
|
+
export declare function ChatComposerAttachmentTitle({ className, children, ...props }: ChatComposerAttachmentTitleProps): import("react").JSX.Element;
|
|
42
|
+
export type ChatComposerAttachmentDescriptionProps = Omit<ComponentProps<"div">, "style"> & {
|
|
43
43
|
style?: CSSProperties & ChatComposerAttachmentKnobStyle;
|
|
44
44
|
};
|
|
45
|
-
declare function ChatComposerAttachmentDescription({ className, children, ...props }: ChatComposerAttachmentDescriptionProps): import("react").JSX.Element;
|
|
46
|
-
type ChatComposerAttachmentRemoveProps = Omit<ComponentProps<typeof Button>, "style"> & {
|
|
45
|
+
export declare function ChatComposerAttachmentDescription({ className, children, ...props }: ChatComposerAttachmentDescriptionProps): import("react").JSX.Element;
|
|
46
|
+
export type ChatComposerAttachmentRemoveProps = Omit<ComponentProps<typeof Button>, "style"> & {
|
|
47
47
|
style?: CSSProperties & ButtonKnobStyle & ChatComposerAttachmentKnobStyle;
|
|
48
48
|
};
|
|
49
|
-
declare function ChatComposerAttachmentRemove({ className, onClick, children, "aria-label": ariaLabel, ...props }: ChatComposerAttachmentRemoveProps): import("react").JSX.Element | null;
|
|
50
|
-
type ChatComposerAttachmentProgressProps = Omit<ComponentProps<"div">, "style"> & {
|
|
49
|
+
export declare function ChatComposerAttachmentRemove({ className, onClick, children, "aria-label": ariaLabel, ...props }: ChatComposerAttachmentRemoveProps): import("react").JSX.Element | null;
|
|
50
|
+
export type ChatComposerAttachmentProgressProps = Omit<ComponentProps<"div">, "style"> & {
|
|
51
51
|
style?: CSSProperties & ChatComposerAttachmentKnobStyle;
|
|
52
52
|
};
|
|
53
|
-
declare function ChatComposerAttachmentProgress({ className, children, style, ...props }: ChatComposerAttachmentProgressProps): import("react").JSX.Element | null;
|
|
54
|
-
//#endregion
|
|
55
|
-
export { ChatComposerAttachment, ChatComposerAttachmentContent, ChatComposerAttachmentContentProps, ChatComposerAttachmentDescription, ChatComposerAttachmentDescriptionProps, ChatComposerAttachmentKind, ChatComposerAttachmentPreview, ChatComposerAttachmentPreviewProps, ChatComposerAttachmentProgress, ChatComposerAttachmentProgressProps, ChatComposerAttachmentProps, ChatComposerAttachmentRemove, ChatComposerAttachmentRemoveProps, ChatComposerAttachmentStatus, ChatComposerAttachmentTitle, ChatComposerAttachmentTitleProps, ChatComposerAttachmentVariant, ChatComposerAttachments, ChatComposerAttachmentsProps };
|
|
53
|
+
export declare function ChatComposerAttachmentProgress({ className, children, style, ...props }: ChatComposerAttachmentProgressProps): import("react").JSX.Element | null;
|
|
54
|
+
//#endregion
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { cn } from "./lib/cn.js";
|
|
3
3
|
import { Button } from "./ui/button.js";
|
|
4
4
|
import { ScrollArea } from "./ui/scroll-area.js";
|
|
5
|
+
import { Spinner } from "./ui/spinner.js";
|
|
5
6
|
import { createContext, useContext } from "react";
|
|
6
7
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
7
8
|
import { XIcon } from "lucide-react";
|
|
@@ -84,9 +85,9 @@ function fallbackLabel(kind, extension) {
|
|
|
84
85
|
}[kind];
|
|
85
86
|
}
|
|
86
87
|
function defaultDescription(context) {
|
|
87
|
-
const progress =
|
|
88
|
+
const { progress } = context;
|
|
88
89
|
if (context.description) return context.description;
|
|
89
|
-
if (context.status === "uploading") return `Uploading ${Math.round(progress
|
|
90
|
+
if (context.status === "uploading") return progress === void 0 ? "Uploading…" : `Uploading ${Math.round(progress)}%`;
|
|
90
91
|
if (context.status === "error") return "Upload failed";
|
|
91
92
|
return fallbackLabel(context.kind, context.extension);
|
|
92
93
|
}
|
|
@@ -147,7 +148,7 @@ function ChatComposerAttachment({ name, type, description, status = "idle", prog
|
|
|
147
148
|
"data-kind": resolvedKind,
|
|
148
149
|
"data-state": status,
|
|
149
150
|
"data-variant": resolvedVariant,
|
|
150
|
-
className: cn("relative shrink-0 overflow-hidden",
|
|
151
|
+
className: cn("relative isolate flex shrink-0 items-center overflow-hidden", className),
|
|
151
152
|
...props,
|
|
152
153
|
children: children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
153
154
|
/* @__PURE__ */ jsx(ChatComposerAttachmentPreview, {}),
|
|
@@ -161,13 +162,13 @@ function ChatComposerAttachment({ name, type, description, status = "idle", prog
|
|
|
161
162
|
function ChatComposerAttachmentPreview({ className, children, ...props }) {
|
|
162
163
|
const context = useChatComposerAttachmentContext();
|
|
163
164
|
const label = fallbackLabel(context.kind, context.extension);
|
|
164
|
-
return /* @__PURE__ */
|
|
165
|
+
return /* @__PURE__ */ jsx("div", {
|
|
165
166
|
"data-control-ui": "chat-composer-attachment",
|
|
166
167
|
"data-control-family": "chat-composer-attachment",
|
|
167
168
|
"data-slot": "preview",
|
|
168
169
|
className: cn("relative grid shrink-0 place-items-center overflow-hidden", className),
|
|
169
170
|
...props,
|
|
170
|
-
children:
|
|
171
|
+
children: children ?? (context.previewUrl ? /* @__PURE__ */ jsx("img", {
|
|
171
172
|
src: context.previewUrl,
|
|
172
173
|
alt: context.name,
|
|
173
174
|
loading: "lazy",
|
|
@@ -179,13 +180,7 @@ function ChatComposerAttachmentPreview({ className, children, ...props }) {
|
|
|
179
180
|
"data-slot": "preview-label",
|
|
180
181
|
className: "uppercase",
|
|
181
182
|
children: label
|
|
182
|
-
}))
|
|
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
|
-
})]
|
|
183
|
+
}))
|
|
189
184
|
});
|
|
190
185
|
}
|
|
191
186
|
function ChatComposerAttachmentContent({ className, ...props }) {
|
|
@@ -230,6 +225,7 @@ function ChatComposerAttachmentRemove({ className, onClick, children, "aria-labe
|
|
|
230
225
|
return /* @__PURE__ */ jsx(Button, {
|
|
231
226
|
"data-control-ui": "chat-composer-attachment",
|
|
232
227
|
"data-chat-composer-attachment-remove": "true",
|
|
228
|
+
iconOnly: true,
|
|
233
229
|
"data-slot": "remove",
|
|
234
230
|
"aria-label": ariaLabel ?? removeLabel ?? `Remove ${name}`,
|
|
235
231
|
size: "xs",
|
|
@@ -244,23 +240,31 @@ function ChatComposerAttachmentRemove({ className, onClick, children, "aria-labe
|
|
|
244
240
|
});
|
|
245
241
|
}
|
|
246
242
|
function ChatComposerAttachmentProgress({ className, children, style, ...props }) {
|
|
247
|
-
const { status, progress } = useChatComposerAttachmentContext();
|
|
248
|
-
if (status !== "uploading"
|
|
243
|
+
const { name, status, progress } = useChatComposerAttachmentContext();
|
|
244
|
+
if (status !== "uploading") return null;
|
|
249
245
|
return /* @__PURE__ */ jsx("div", {
|
|
250
|
-
|
|
246
|
+
role: "progressbar",
|
|
247
|
+
"aria-label": `Uploading ${name}`,
|
|
248
|
+
"aria-valuemin": 0,
|
|
249
|
+
"aria-valuemax": 100,
|
|
250
|
+
"aria-valuenow": progress,
|
|
251
251
|
"data-control-ui": "chat-composer-attachment",
|
|
252
252
|
"data-control-family": "chat-composer-attachment",
|
|
253
253
|
"data-slot": "progress",
|
|
254
|
-
className: cn("absolute inset-
|
|
254
|
+
className: cn("pointer-events-none absolute inset-0 z-1 grid place-items-center", className),
|
|
255
255
|
style,
|
|
256
256
|
...props,
|
|
257
|
-
children: children ?? /* @__PURE__ */ jsx("div", {
|
|
257
|
+
children: children ?? /* @__PURE__ */ jsxs(Fragment$1, { children: [/* @__PURE__ */ jsx("div", {
|
|
258
258
|
"data-control-ui": "chat-composer-attachment",
|
|
259
259
|
"data-control-family": "chat-composer-attachment",
|
|
260
260
|
"data-slot": "progress-indicator",
|
|
261
|
-
className: "
|
|
262
|
-
style: {
|
|
263
|
-
})
|
|
261
|
+
className: "absolute inset-y-0 end-0",
|
|
262
|
+
style: { inlineSize: `${100 - (progress ?? 0)}%` }
|
|
263
|
+
}), progress === void 0 && /* @__PURE__ */ jsx(Spinner, {
|
|
264
|
+
"aria-hidden": "true",
|
|
265
|
+
className: "relative",
|
|
266
|
+
size: "xs"
|
|
267
|
+
})] })
|
|
264
268
|
});
|
|
265
269
|
}
|
|
266
270
|
//#endregion
|
|
@@ -2,13 +2,12 @@ import { ChatComposerEditorExtension } from "../types.js";
|
|
|
2
2
|
import { TriggerConfig, TriggerMenuItemData } from "../../hooks/use-trigger-menu.js";
|
|
3
3
|
import { Command } from "prosemirror-state";
|
|
4
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> = {
|
|
5
|
+
export declare const deleteMentionBackward: Command;
|
|
6
|
+
export declare const deleteMentionForward: Command;
|
|
7
|
+
export type MentionExtensionConfig<Item extends TriggerMenuItemData = TriggerMenuItemData> = {
|
|
8
8
|
triggers: readonly TriggerConfig<Item>[];
|
|
9
9
|
side?: "top" | "bottom";
|
|
10
10
|
align?: "start" | "center" | "end";
|
|
11
11
|
};
|
|
12
|
-
declare function mentionExtension<Item extends TriggerMenuItemData = TriggerMenuItemData>({ triggers, side, align }: MentionExtensionConfig<Item>): ChatComposerEditorExtension;
|
|
13
|
-
//#endregion
|
|
14
|
-
export { MentionExtensionConfig, deleteMentionBackward, deleteMentionForward, mentionExtension };
|
|
12
|
+
export declare function mentionExtension<Item extends TriggerMenuItemData = TriggerMenuItemData>({ triggers, side, align }: MentionExtensionConfig<Item>): ChatComposerEditorExtension;
|
|
13
|
+
//#endregion
|
|
@@ -1,5 +1,4 @@
|
|
|
1
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 };
|
|
2
|
+
export declare function spawnExitGhost(source: HTMLElement, inherit?: readonly string[]): void;
|
|
3
|
+
export 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
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { ChatComposerEditorExtension } from "./types.js";
|
|
2
2
|
import { Schema } from "prosemirror-model";
|
|
3
3
|
//#region src/chat-composer-editor/schema.d.ts
|
|
4
|
-
declare function createEditorSchema(extensions: readonly ChatComposerEditorExtension[]): Schema;
|
|
5
|
-
//#endregion
|
|
6
|
-
export { createEditorSchema };
|
|
4
|
+
export declare function createEditorSchema(extensions: readonly ChatComposerEditorExtension[]): Schema;
|
|
5
|
+
//#endregion
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Node, Schema } from "prosemirror-model";
|
|
2
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 };
|
|
3
|
+
export declare function serializeDoc(doc: Node): string;
|
|
4
|
+
export declare function docFromText(schema: Schema, text: string): Node;
|
|
5
|
+
//#endregion
|
|
@@ -4,15 +4,15 @@ import { Command, Plugin } from "prosemirror-state";
|
|
|
4
4
|
import { EditorView } from "prosemirror-view";
|
|
5
5
|
import { Node, NodeSpec, Schema } from "prosemirror-model";
|
|
6
6
|
//#region src/chat-composer-editor/types.d.ts
|
|
7
|
-
type ChatComposerEditorApi = {
|
|
7
|
+
export type ChatComposerEditorApi = {
|
|
8
8
|
getView: () => EditorView | null;
|
|
9
9
|
subscribe: (listener: () => void) => () => void;
|
|
10
10
|
registerKeyHandler: (handler: (event: KeyboardEvent) => boolean) => () => void;
|
|
11
11
|
};
|
|
12
|
-
type ChatComposerEditorOverlayProps = {
|
|
12
|
+
export type ChatComposerEditorOverlayProps = {
|
|
13
13
|
editor: ChatComposerEditorApi;
|
|
14
14
|
};
|
|
15
|
-
type ChatComposerEditorExtension = {
|
|
15
|
+
export type ChatComposerEditorExtension = {
|
|
16
16
|
name: string;
|
|
17
17
|
nodes?: Record<string, NodeSpec>;
|
|
18
18
|
plugins?: (schema: Schema, editor: ChatComposerEditorApi) => Plugin[];
|
|
@@ -20,10 +20,9 @@ type ChatComposerEditorExtension = {
|
|
|
20
20
|
submitPayload?: (doc: Node) => Partial<ChatComposerSubmitPayload>;
|
|
21
21
|
Overlay?: (props: ChatComposerEditorOverlayProps) => ReactNode;
|
|
22
22
|
};
|
|
23
|
-
type ChatComposerEditorProps = {
|
|
23
|
+
export type ChatComposerEditorProps = {
|
|
24
24
|
className?: string;
|
|
25
25
|
placeholder?: string;
|
|
26
26
|
extensions?: readonly ChatComposerEditorExtension[];
|
|
27
27
|
};
|
|
28
|
-
//#endregion
|
|
29
|
-
export { ChatComposerEditorApi, ChatComposerEditorExtension, ChatComposerEditorOverlayProps, ChatComposerEditorProps };
|
|
28
|
+
//#endregion
|
|
@@ -2,8 +2,7 @@ import { ChatComposerKnobStyle } from "./knob-contracts/chat-composer-knobs.js";
|
|
|
2
2
|
import { ChatComposerEditorProps } from "./chat-composer-editor/types.js";
|
|
3
3
|
import { CSSProperties } from "react";
|
|
4
4
|
//#region src/chat-composer-editor.d.ts
|
|
5
|
-
declare function ChatComposerEditor({ className, placeholder, extensions }: ChatComposerEditorProps & {
|
|
5
|
+
export declare function ChatComposerEditor({ className, placeholder, style, extensions }: ChatComposerEditorProps & {
|
|
6
6
|
style?: CSSProperties & ChatComposerKnobStyle;
|
|
7
7
|
}): import("react").JSX.Element;
|
|
8
|
-
//#endregion
|
|
9
|
-
export { ChatComposerEditor };
|
|
8
|
+
//#endregion
|
|
@@ -13,7 +13,7 @@ import { EditorState, Plugin } from "prosemirror-state";
|
|
|
13
13
|
import { EditorView } from "prosemirror-view";
|
|
14
14
|
//#region src/chat-composer-editor.tsx
|
|
15
15
|
const SUBMIT_KEY = "Enter";
|
|
16
|
-
function ChatComposerEditor({ className, placeholder, extensions = [] }) {
|
|
16
|
+
function ChatComposerEditor({ className, placeholder, style, extensions = [] }) {
|
|
17
17
|
const input = useChatComposerContext();
|
|
18
18
|
const mountRef = useRef(null);
|
|
19
19
|
const viewRef = useRef(null);
|
|
@@ -78,6 +78,7 @@ function ChatComposerEditor({ className, placeholder, extensions = [] }) {
|
|
|
78
78
|
});
|
|
79
79
|
const view = new EditorView(mount, {
|
|
80
80
|
state,
|
|
81
|
+
editable: () => !inputRef.current.isDisabled,
|
|
81
82
|
attributes: {
|
|
82
83
|
"aria-label": "Message",
|
|
83
84
|
"aria-multiline": "true",
|
|
@@ -114,10 +115,22 @@ function ChatComposerEditor({ className, placeholder, extensions = [] }) {
|
|
|
114
115
|
plugins: view.state.plugins
|
|
115
116
|
}));
|
|
116
117
|
}, [input.value]);
|
|
118
|
+
useEffect(() => {
|
|
119
|
+
viewRef.current?.setProps({
|
|
120
|
+
editable: () => !input.isDisabled,
|
|
121
|
+
attributes: {
|
|
122
|
+
"aria-label": "Message",
|
|
123
|
+
"aria-multiline": "true",
|
|
124
|
+
"aria-disabled": String(input.isDisabled),
|
|
125
|
+
role: "textbox"
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
}, [input.isDisabled]);
|
|
117
129
|
return /* @__PURE__ */ jsxs("div", {
|
|
118
130
|
"data-control-ui": "chat-composer-editor",
|
|
119
131
|
"data-control-family": "chat-composer",
|
|
120
|
-
"data-slot": "root",
|
|
132
|
+
"data-slot": "editor-root",
|
|
133
|
+
style,
|
|
121
134
|
className: cn("relative", className),
|
|
122
135
|
children: [
|
|
123
136
|
input.value === "" && placeholder ? /* @__PURE__ */ jsx("div", {
|
|
@@ -133,7 +146,7 @@ function ChatComposerEditor({ className, placeholder, extensions = [] }) {
|
|
|
133
146
|
"data-control-ui": "chat-composer-editor",
|
|
134
147
|
"data-control-family": "chat-composer",
|
|
135
148
|
"data-slot": "editor",
|
|
136
|
-
className: cn("[&_.ProseMirror]:max-h-[40dvh] [&_.ProseMirror]:min-h-16 [&_.ProseMirror]:w-full [&_.ProseMirror]:overflow-y-auto [&_.ProseMirror]:whitespace-pre-wrap [&_.ProseMirror]:break-words [&_.ProseMirror]:px-[var(--padding-x)] [&_.ProseMirror]:py-[var(--padding-y)]", mounted ? "" : "hidden")
|
|
149
|
+
className: cn("[&_.ProseMirror]:max-h-[40dvh] [&_.ProseMirror]:min-h-16 [&_.ProseMirror]:w-full [&_.ProseMirror]:overflow-y-auto [&_.ProseMirror]:outline-none [&_.ProseMirror]:whitespace-pre-wrap [&_.ProseMirror]:break-words [&_.ProseMirror]:px-[var(--padding-x)] [&_.ProseMirror]:py-[var(--padding-y)]", mounted ? "" : "hidden")
|
|
137
150
|
}),
|
|
138
151
|
mounted ? null : /* @__PURE__ */ jsx("textarea", {
|
|
139
152
|
"data-control-ui": "chat-composer-editor",
|
|
@@ -142,9 +155,10 @@ function ChatComposerEditor({ className, placeholder, extensions = [] }) {
|
|
|
142
155
|
"aria-label": "Message",
|
|
143
156
|
defaultValue: input.value,
|
|
144
157
|
readOnly: true,
|
|
158
|
+
disabled: input.isDisabled,
|
|
145
159
|
rows: 2,
|
|
146
160
|
placeholder,
|
|
147
|
-
className: "min-h-16 w-full resize-none px-[var(--padding-x)] py-[var(--padding-y)]"
|
|
161
|
+
className: "min-h-16 w-full resize-none outline-none px-[var(--padding-x)] py-[var(--padding-y)]"
|
|
148
162
|
}),
|
|
149
163
|
mounted ? initialExtensions.map((extension) => extension.Overlay ? /* @__PURE__ */ jsx(extension.Overlay, { editor: api }, extension.name) : null) : null
|
|
150
164
|
]
|
package/dist/chat-composer.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ChatDensity } from "./hooks/use-chat-message.js";
|
|
|
5
5
|
import { ChatComposerProps, ChatComposerSubmitPayload } from "./hooks/use-chat-composer.js";
|
|
6
6
|
import { CSSProperties, ComponentProps } from "react";
|
|
7
7
|
//#region src/chat-composer.d.ts
|
|
8
|
-
declare function useChatComposerContext(): {
|
|
8
|
+
export declare function useChatComposerContext(): {
|
|
9
9
|
value: string;
|
|
10
10
|
setValue: (nextValue: string) => void;
|
|
11
11
|
normalizedValue: string;
|
|
@@ -29,32 +29,31 @@ declare function useChatComposerContext(): {
|
|
|
29
29
|
preventDefault: () => void;
|
|
30
30
|
}) => void;
|
|
31
31
|
};
|
|
32
|
-
declare function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state, density, disabled, className, children, ...props }: ChatComposerProps): import("react").JSX.Element;
|
|
33
|
-
type ChatComposerShellProps = Omit<ComponentProps<"div">, "style"> & {
|
|
32
|
+
export declare function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state, density, disabled, className, children, ...props }: ChatComposerProps): import("react").JSX.Element;
|
|
33
|
+
export type ChatComposerShellProps = Omit<ComponentProps<"div">, "style"> & {
|
|
34
34
|
style?: CSSProperties & ChatComposerKnobStyle;
|
|
35
35
|
};
|
|
36
|
-
declare function ChatComposerShell({ className, ...props }: ChatComposerShellProps): import("react").JSX.Element;
|
|
37
|
-
type ChatComposerAccentProps = Omit<ComponentProps<"div">, "style"> & {
|
|
36
|
+
export declare function ChatComposerShell({ className, ...props }: ChatComposerShellProps): import("react").JSX.Element;
|
|
37
|
+
export type ChatComposerAccentProps = Omit<ComponentProps<"div">, "style"> & {
|
|
38
38
|
style?: CSSProperties & ChatComposerKnobStyle;
|
|
39
39
|
};
|
|
40
|
-
declare function ChatComposerAccent({ className, ...props }: ChatComposerAccentProps): import("react").JSX.Element;
|
|
41
|
-
type ChatComposerTextareaProps = Omit<ComponentProps<"textarea">, "style"> & {
|
|
40
|
+
export declare function ChatComposerAccent({ className, ...props }: ChatComposerAccentProps): import("react").JSX.Element;
|
|
41
|
+
export type ChatComposerTextareaProps = Omit<ComponentProps<"textarea">, "style"> & {
|
|
42
42
|
style?: CSSProperties & ChatComposerKnobStyle;
|
|
43
43
|
};
|
|
44
|
-
declare function ChatComposerTextarea({ className, rows, disabled, onChange, onKeyDown, ...props }: ChatComposerTextareaProps): import("react").JSX.Element;
|
|
45
|
-
type ChatComposerToolbarProps = ComponentProps<"div"> & {
|
|
44
|
+
export declare function ChatComposerTextarea({ className, rows, disabled, onChange, onKeyDown, ...props }: ChatComposerTextareaProps): import("react").JSX.Element;
|
|
45
|
+
export type ChatComposerToolbarProps = ComponentProps<"div"> & {
|
|
46
46
|
style?: CSSProperties & ChatComposerKnobStyle;
|
|
47
47
|
};
|
|
48
|
-
declare function ChatComposerToolbar({ className, ...props }: ChatComposerToolbarProps): import("react").JSX.Element;
|
|
49
|
-
type ChatComposerToolsProps = Omit<ComponentProps<"div">, "style"> & {
|
|
48
|
+
export declare function ChatComposerToolbar({ className, ...props }: ChatComposerToolbarProps): import("react").JSX.Element;
|
|
49
|
+
export type ChatComposerToolsProps = Omit<ComponentProps<"div">, "style"> & {
|
|
50
50
|
style?: CSSProperties & ChatComposerKnobStyle;
|
|
51
51
|
};
|
|
52
|
-
declare function ChatComposerTools({ className, ...props }: ChatComposerToolsProps): import("react").JSX.Element;
|
|
53
|
-
type ChatComposerFooterProps = Omit<ComponentProps<"div">, "style"> & {
|
|
52
|
+
export declare function ChatComposerTools({ className, ...props }: ChatComposerToolsProps): import("react").JSX.Element;
|
|
53
|
+
export type ChatComposerFooterProps = Omit<ComponentProps<"div">, "style"> & {
|
|
54
54
|
style?: CSSProperties & ChatComposerKnobStyle;
|
|
55
55
|
};
|
|
56
|
-
declare function ChatComposerFooter({ className, ...props }: ChatComposerFooterProps): import("react").JSX.Element;
|
|
57
|
-
type ChatComposerSubmitProps = ComponentProps<typeof Button>;
|
|
58
|
-
declare function ChatComposerSubmit({ className, disabled, children, ...props }: ChatComposerSubmitProps): import("react").JSX.Element;
|
|
59
|
-
//#endregion
|
|
60
|
-
export { ChatComposer, ChatComposerAccent, ChatComposerAccentProps, ChatComposerFooter, ChatComposerFooterProps, ChatComposerShell, ChatComposerShellProps, ChatComposerSubmit, ChatComposerSubmitProps, ChatComposerTextarea, ChatComposerTextareaProps, ChatComposerToolbar, ChatComposerToolbarProps, ChatComposerTools, ChatComposerToolsProps, useChatComposerContext };
|
|
56
|
+
export declare function ChatComposerFooter({ className, ...props }: ChatComposerFooterProps): import("react").JSX.Element;
|
|
57
|
+
export type ChatComposerSubmitProps = ComponentProps<typeof Button>;
|
|
58
|
+
export declare function ChatComposerSubmit({ className, disabled, children, ...props }: ChatComposerSubmitProps): import("react").JSX.Element;
|
|
59
|
+
//#endregion
|
package/dist/chat-composer.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { cn } from "./lib/cn.js";
|
|
3
3
|
import { hasSkinAdornment, skinAdornment } from "./skin.js";
|
|
4
|
+
import { useSkin } from "./skin-provider.js";
|
|
4
5
|
import { Button } from "./ui/button.js";
|
|
5
6
|
import { useChatComposer } from "./hooks/use-chat-composer.js";
|
|
7
|
+
import { useKeyboardNavigation } from "./hooks/use-keyboard-navigation.js";
|
|
6
8
|
import { createContext, useContext } from "react";
|
|
7
9
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
10
|
//#region src/chat-composer.tsx
|
|
@@ -13,6 +15,7 @@ function useChatComposerContext() {
|
|
|
13
15
|
return context;
|
|
14
16
|
}
|
|
15
17
|
function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "idle", density = "comfortable", disabled = false, className, children, ...props }) {
|
|
18
|
+
const skin = useSkin();
|
|
16
19
|
const input = useChatComposer({
|
|
17
20
|
value,
|
|
18
21
|
defaultValue,
|
|
@@ -21,9 +24,9 @@ function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "i
|
|
|
21
24
|
state,
|
|
22
25
|
density,
|
|
23
26
|
disabled,
|
|
24
|
-
trackSends: hasSkinAdornment("chat-composer", "send-layer")
|
|
27
|
+
trackSends: hasSkinAdornment(skin, "chat-composer", "send-layer")
|
|
25
28
|
});
|
|
26
|
-
const sendLayer = skinAdornment("chat-composer", "send-layer", { sendCount: input.sendCount });
|
|
29
|
+
const sendLayer = skinAdornment(skin, "chat-composer", "send-layer", { sendCount: input.sendCount });
|
|
27
30
|
return /* @__PURE__ */ jsx(ChatComposerContext.Provider, {
|
|
28
31
|
value: input,
|
|
29
32
|
children: /* @__PURE__ */ jsxs("form", {
|
|
@@ -33,7 +36,7 @@ function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "i
|
|
|
33
36
|
"data-state": state,
|
|
34
37
|
"data-density": density,
|
|
35
38
|
onSubmit: input.handleSubmit,
|
|
36
|
-
className: cn("
|
|
39
|
+
className: cn("relative min-w-0 w-full", className),
|
|
37
40
|
...props,
|
|
38
41
|
children: [sendLayer !== void 0 && sendLayer !== null ? /* @__PURE__ */ jsx("div", {
|
|
39
42
|
"aria-hidden": "true",
|
|
@@ -45,11 +48,14 @@ function ChatComposer({ value, defaultValue, onValueChange, onSubmit, state = "i
|
|
|
45
48
|
}
|
|
46
49
|
function ChatComposerShell({ className, ...props }) {
|
|
47
50
|
const input = useChatComposerContext();
|
|
51
|
+
const keyboardNavigation = useKeyboardNavigation();
|
|
48
52
|
return /* @__PURE__ */ jsx("div", {
|
|
53
|
+
"data-keyboard-navigation": keyboardNavigation ? "" : void 0,
|
|
49
54
|
"data-control-ui": "chat-composer",
|
|
50
55
|
"data-control-family": "chat-composer",
|
|
51
56
|
"data-slot": "shell",
|
|
52
57
|
"data-state": input.state,
|
|
58
|
+
"data-surface": "panel",
|
|
53
59
|
className: cn("relative overflow-hidden", className),
|
|
54
60
|
...props
|
|
55
61
|
});
|
|
@@ -75,17 +81,17 @@ function ChatComposerTextarea({ className, rows, disabled, onChange, onKeyDown,
|
|
|
75
81
|
input.handleKeyDown(event);
|
|
76
82
|
}
|
|
77
83
|
return /* @__PURE__ */ jsx("textarea", {
|
|
78
|
-
...props,
|
|
79
84
|
"data-control-ui": "chat-composer",
|
|
80
85
|
"data-control-family": "chat-composer",
|
|
81
86
|
"data-slot": "textarea",
|
|
82
87
|
"aria-label": "Message",
|
|
88
|
+
...props,
|
|
83
89
|
value: input.value,
|
|
84
90
|
onChange: handleChange,
|
|
85
91
|
onKeyDown: handleKeyDown,
|
|
86
|
-
disabled: disabled
|
|
92
|
+
disabled: disabled || input.isDisabled,
|
|
87
93
|
rows: rows ?? input.rows,
|
|
88
|
-
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)
|
|
94
|
+
className: cn("field-sizing-content min-h-16 max-h-[40dvh] w-full resize-none outline-none px-[var(--padding-x)] py-[var(--padding-y)] disabled:cursor-not-allowed", className)
|
|
89
95
|
});
|
|
90
96
|
}
|
|
91
97
|
function ChatComposerToolbar({ className, ...props }) {
|
|
@@ -102,7 +108,7 @@ function ChatComposerTools({ className, ...props }) {
|
|
|
102
108
|
"data-control-ui": "chat-composer",
|
|
103
109
|
"data-control-family": "chat-composer",
|
|
104
110
|
"data-slot": "tools",
|
|
105
|
-
className: cn("flex min-w-0 items-center", className),
|
|
111
|
+
className: cn("flex min-w-0 flex-wrap items-center", className),
|
|
106
112
|
...props
|
|
107
113
|
});
|
|
108
114
|
}
|
|
@@ -124,7 +130,7 @@ function ChatComposerSubmit({ className, disabled, children = "Send", ...props }
|
|
|
124
130
|
variant: "solid",
|
|
125
131
|
tone: "primary",
|
|
126
132
|
size: "xs",
|
|
127
|
-
disabled: disabled
|
|
133
|
+
disabled: disabled || !input.canSubmit,
|
|
128
134
|
className,
|
|
129
135
|
...props,
|
|
130
136
|
children
|
package/dist/chat-layout.d.ts
CHANGED
|
@@ -1,27 +1,18 @@
|
|
|
1
1
|
import { ChatLayoutKnobStyle } from "./knob-contracts/chat-layout-knobs.js";
|
|
2
|
-
import { CSSProperties, ComponentProps,
|
|
2
|
+
import { CSSProperties, ComponentProps, ReactNode } from "react";
|
|
3
3
|
//#region src/chat-layout.d.ts
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Content: ElementType;
|
|
8
|
-
};
|
|
9
|
-
type ChatLayoutProps = Omit<ComponentProps<"section">, "style"> & {
|
|
4
|
+
export type ChatLayoutChrome = "panel" | "embedded";
|
|
5
|
+
export type ChatLayoutProps = Omit<ComponentProps<"section">, "style"> & {
|
|
6
|
+
chrome?: ChatLayoutChrome;
|
|
10
7
|
style?: CSSProperties & ChatLayoutKnobStyle;
|
|
11
8
|
};
|
|
12
|
-
declare function ChatLayout({ children, className, ...props }: ChatLayoutProps): import("react").JSX.Element;
|
|
13
|
-
type ChatThreadProps = ComponentProps<"div"
|
|
14
|
-
|
|
15
|
-
type ChatTurnProps = ComponentProps<"section"> & {
|
|
16
|
-
from: "user" | "assistant";
|
|
9
|
+
export declare function ChatLayout({ children, chrome, className, ...props }: ChatLayoutProps): import("react").JSX.Element;
|
|
10
|
+
export type ChatThreadProps = ComponentProps<"div"> & {
|
|
11
|
+
composer?: ReactNode;
|
|
17
12
|
};
|
|
18
|
-
declare function
|
|
19
|
-
type
|
|
20
|
-
|
|
21
|
-
defaultOpen?: boolean;
|
|
22
|
-
collapsible?: ChatThoughtCollapsible;
|
|
23
|
-
style?: CSSProperties & ChatLayoutKnobStyle;
|
|
13
|
+
export declare function ChatThread({ children, composer, className, ...props }: ChatThreadProps): import("react").JSX.Element;
|
|
14
|
+
export type ChatTurnProps = ComponentProps<"section"> & {
|
|
15
|
+
from: "user" | "assistant";
|
|
24
16
|
};
|
|
25
|
-
declare function
|
|
26
|
-
//#endregion
|
|
27
|
-
export { ChatLayout, ChatLayoutProps, ChatThought, ChatThoughtProps, ChatThread, ChatThreadProps, ChatTurn, ChatTurnProps };
|
|
17
|
+
export declare function ChatTurn({ from, children, className, ...props }: ChatTurnProps): import("react").JSX.Element;
|
|
18
|
+
//#endregion
|