@djangocfg/ui-tools 2.1.407 → 2.1.409
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 +9 -10
- package/dist/file-icon/index.cjs +449 -61
- package/dist/file-icon/index.cjs.map +1 -1
- package/dist/file-icon/index.d.cts +56 -18
- package/dist/file-icon/index.d.ts +56 -18
- package/dist/file-icon/index.mjs +448 -62
- package/dist/file-icon/index.mjs.map +1 -1
- package/dist/tree/index.cjs +49 -22
- package/dist/tree/index.cjs.map +1 -1
- package/dist/tree/index.d.cts +9 -3
- package/dist/tree/index.d.ts +9 -3
- package/dist/tree/index.mjs +49 -22
- package/dist/tree/index.mjs.map +1 -1
- package/dist/{types-B_zhyAqR.d.cts → types-eEu8SeiQ.d.cts} +4 -0
- package/dist/{types-B_zhyAqR.d.ts → types-eEu8SeiQ.d.ts} +4 -0
- package/package.json +8 -13
- package/src/components/FloatingToolbar/index.tsx +37 -3
- package/src/lib/page-snapshot/__tests__/capture-integration.test.ts +85 -0
- package/src/lib/page-snapshot/__tests__/engine.test.ts +36 -0
- package/src/lib/page-snapshot/__tests__/redaction-integration.test.ts +99 -0
- package/src/lib/page-snapshot/__tests__/tokens.test.ts +17 -0
- package/src/lib/page-snapshot/capture/__tests__/budget.test.ts +49 -0
- package/src/lib/page-snapshot/capture/__tests__/chrome-filter.test.ts +47 -0
- package/src/lib/page-snapshot/capture/__tests__/fold.test.ts +66 -0
- package/src/lib/page-snapshot/capture/__tests__/scope.test.ts +74 -0
- package/src/lib/page-snapshot/capture/__tests__/walk.test.ts +129 -0
- package/src/lib/page-snapshot/capture/accessible-name.ts +73 -0
- package/src/lib/page-snapshot/capture/budget.ts +95 -0
- package/src/lib/page-snapshot/capture/chrome-filter.ts +81 -0
- package/src/lib/page-snapshot/capture/classify.ts +111 -0
- package/src/lib/page-snapshot/capture/dom-utils.ts +111 -0
- package/src/lib/page-snapshot/capture/fold.ts +96 -0
- package/src/lib/page-snapshot/capture/scope.ts +169 -0
- package/src/lib/page-snapshot/capture/walk.ts +250 -0
- package/src/lib/page-snapshot/cst/__tests__/serialize.test.ts +50 -0
- package/src/lib/page-snapshot/cst/directives.ts +47 -0
- package/src/lib/page-snapshot/cst/payload.ts +50 -0
- package/src/lib/page-snapshot/cst/serialize.ts +84 -0
- package/src/lib/page-snapshot/cst/types.ts +115 -0
- package/src/lib/page-snapshot/engine.ts +176 -0
- package/src/lib/page-snapshot/index.ts +93 -0
- package/src/lib/page-snapshot/react/PageSnapshotChip.tsx +72 -0
- package/src/lib/page-snapshot/react/PageSnapshotPreview.tsx +78 -0
- package/src/lib/page-snapshot/react/__tests__/PageSnapshotChip.test.tsx +54 -0
- package/src/lib/page-snapshot/react/__tests__/provider.test.tsx +103 -0
- package/src/lib/page-snapshot/react/__tests__/use-page-snapshot-toggle.test.tsx +62 -0
- package/src/lib/page-snapshot/react/provider.tsx +162 -0
- package/src/lib/page-snapshot/react/use-page-snapshot-toggle.ts +47 -0
- package/src/lib/page-snapshot/react/use-page-snapshot.ts +67 -0
- package/src/lib/page-snapshot/redaction/__tests__/audit.test.ts +25 -0
- package/src/lib/page-snapshot/redaction/__tests__/heuristics.test.ts +73 -0
- package/src/lib/page-snapshot/redaction/__tests__/luhn.test.ts +26 -0
- package/src/lib/page-snapshot/redaction/__tests__/patterns.test.ts +60 -0
- package/src/lib/page-snapshot/redaction/audit.ts +58 -0
- package/src/lib/page-snapshot/redaction/heuristics.ts +75 -0
- package/src/lib/page-snapshot/redaction/index.ts +75 -0
- package/src/lib/page-snapshot/redaction/luhn.ts +25 -0
- package/src/lib/page-snapshot/redaction/patterns.ts +111 -0
- package/src/lib/page-snapshot/refs/__tests__/registry.test.ts +24 -0
- package/src/lib/page-snapshot/refs/registry.ts +46 -0
- package/src/lib/page-snapshot/staleness/__tests__/hash.test.ts +34 -0
- package/src/lib/page-snapshot/staleness/hash.ts +20 -0
- package/src/lib/page-snapshot/tokens.ts +15 -0
- package/src/tools/AudioPlayer/context/PlayerProvider.tsx +13 -14
- package/src/tools/AudioPlayer/hooks/useAudioElementEvents.ts +55 -6
- package/src/tools/AudioPlayer/parts/Meta/TimeDisplay.tsx +2 -5
- package/src/tools/Chat/README.md +277 -39
- package/src/tools/Chat/composer/Composer.tsx +471 -0
- package/src/tools/Chat/composer/ComposerActionBar.tsx +65 -0
- package/src/tools/Chat/composer/ComposerBanner.tsx +128 -0
- package/src/tools/Chat/composer/ComposerButton.tsx +64 -0
- package/src/tools/Chat/composer/ComposerFooter.tsx +90 -0
- package/src/tools/Chat/composer/ComposerMenuButton.tsx +62 -0
- package/src/tools/Chat/composer/ComposerModelPicker.tsx +104 -0
- package/src/tools/Chat/composer/ComposerRichTextarea.tsx +88 -0
- package/src/tools/Chat/composer/ComposerToolPill.tsx +95 -0
- package/src/tools/Chat/composer/index.ts +45 -0
- package/src/tools/Chat/composer/size-context.tsx +26 -0
- package/src/tools/Chat/composer/types.ts +143 -0
- package/src/tools/Chat/composer/useComposerActions.tsx +164 -0
- package/src/tools/Chat/context/ChatProvider.tsx +54 -3
- package/src/tools/Chat/core/__tests__/metadata.test.ts +69 -0
- package/src/tools/Chat/core/index.ts +23 -1
- package/src/tools/Chat/core/markdown.ts +1 -1
- package/src/tools/Chat/core/metadata.ts +47 -0
- package/src/tools/Chat/core/payload-dispatch.ts +1 -1
- package/src/tools/Chat/core/transport/http.ts +71 -32
- package/src/tools/Chat/core/transport/sse.ts +18 -10
- package/src/tools/Chat/highlight/HighlightOverlay.tsx +101 -0
- package/src/tools/Chat/highlight/README.md +103 -0
- package/src/tools/Chat/highlight/SpotlightCanvas.tsx +153 -0
- package/src/tools/Chat/highlight/__tests__/HighlightOverlay.test.tsx +112 -0
- package/src/tools/Chat/highlight/__tests__/resolveRef.test.ts +55 -0
- package/src/tools/Chat/highlight/index.ts +21 -0
- package/src/tools/Chat/highlight/resolveRef.ts +42 -0
- package/src/tools/Chat/highlight/types.ts +49 -0
- package/src/tools/Chat/highlight/useHighlightTargets.ts +128 -0
- package/src/tools/Chat/hooks/index.ts +0 -5
- package/src/tools/Chat/hooks/useAutoFocusOnStreamEnd.ts +28 -47
- package/src/tools/Chat/hooks/useChat.ts +47 -14
- package/src/tools/Chat/hooks/useChatComposer.ts +2 -2
- package/src/tools/Chat/hooks/useChatLayout.ts +1 -1
- package/src/tools/Chat/hooks/useStreamEndFocus.ts +54 -0
- package/src/tools/Chat/index.ts +25 -219
- package/src/tools/Chat/launcher/ChatDock.tsx +1 -1
- package/src/tools/Chat/launcher/ChatLauncher.tsx +1 -1
- package/src/tools/Chat/launcher/{ChatHeader.tsx → header/ChatHeader.tsx} +24 -11
- package/src/tools/Chat/launcher/{ChatHeaderActionButton.tsx → header/ChatHeaderActionButton.tsx} +34 -3
- package/src/tools/Chat/launcher/{ChatHeaderLanguageButton.tsx → header/ChatHeaderLanguageButton.tsx} +2 -2
- package/src/tools/Chat/launcher/{ChatHeaderModeToggle.tsx → header/ChatHeaderModeToggle.tsx} +1 -1
- package/src/tools/Chat/launcher/{ChatHeaderResetButton.tsx → header/ChatHeaderResetButton.tsx} +2 -1
- package/src/tools/Chat/launcher/{HeaderSlots.tsx → header/HeaderSlots.tsx} +3 -3
- package/src/tools/Chat/launcher/header/index.ts +26 -0
- package/src/tools/Chat/launcher/index.ts +3 -10
- package/src/tools/Chat/lazy.tsx +38 -284
- package/src/tools/Chat/{components → messages}/MessageBubble.tsx +58 -5
- package/src/tools/Chat/{components → messages}/MessageList.tsx +8 -25
- package/src/tools/Chat/messages/blocks/MessageBlocks.tsx +131 -0
- package/src/tools/Chat/messages/blocks/builtin.tsx +91 -0
- package/src/tools/Chat/messages/blocks/index.ts +12 -0
- package/src/tools/Chat/messages/blocks/registry.tsx +42 -0
- package/src/tools/Chat/messages/blocks/renderers/AudioBlock.tsx +20 -0
- package/src/tools/Chat/messages/blocks/renderers/CodeBlock.tsx +19 -0
- package/src/tools/Chat/messages/blocks/renderers/GalleryBlock.tsx +26 -0
- package/src/tools/Chat/messages/blocks/renderers/ImageBlock.tsx +27 -0
- package/src/tools/Chat/messages/blocks/renderers/JsonBlock.tsx +12 -0
- package/src/tools/Chat/messages/blocks/renderers/LottieBlock.tsx +11 -0
- package/src/tools/Chat/messages/blocks/renderers/MapBlock.tsx +36 -0
- package/src/tools/Chat/messages/blocks/renderers/MermaidBlock.tsx +11 -0
- package/src/tools/Chat/messages/blocks/renderers/VideoBlock.tsx +24 -0
- package/src/tools/Chat/messages/blocks/renderers/types.ts +8 -0
- package/src/tools/Chat/{components → messages}/index.ts +11 -5
- package/src/tools/Chat/public.ts +212 -0
- package/src/tools/Chat/shell/ChatRoot.tsx +345 -0
- package/src/tools/Chat/{components → shell}/EmptyState.tsx +4 -2
- package/src/tools/Chat/shell/index.ts +15 -0
- package/src/tools/Chat/types/block.ts +120 -0
- package/src/tools/Chat/types/config.ts +0 -5
- package/src/tools/Chat/types/index.ts +17 -0
- package/src/tools/Chat/types/message.ts +3 -0
- package/src/tools/Chat/utils/index.ts +4 -0
- package/src/tools/CodeEditor/README.md +4 -6
- package/src/tools/CodeEditor/components/DiffEditor.tsx +48 -13
- package/src/tools/CodeEditor/components/Editor.tsx +96 -44
- package/src/tools/CodeEditor/context/EditorProvider.tsx +34 -17
- package/src/tools/CodeEditor/hooks/useEditorTheme.ts +92 -99
- package/src/tools/CodeEditor/hooks/useMonaco.ts +37 -22
- package/src/tools/CodeEditor/lazy.tsx +6 -0
- package/src/tools/CodeEditor/lib/index.ts +1 -1
- package/src/tools/CodeEditor/lib/themes.ts +3 -39
- package/src/tools/CronScheduler/CronScheduler.client.tsx +230 -61
- package/src/tools/CronScheduler/components/CustomInput.tsx +21 -4
- package/src/tools/CronScheduler/components/DayChips.tsx +13 -11
- package/src/tools/CronScheduler/components/MonthDayGrid.tsx +4 -4
- package/src/tools/CronScheduler/components/SchedulePreview.tsx +7 -3
- package/src/tools/CronScheduler/components/TimeSelector.tsx +1 -1
- package/src/tools/CronScheduler/index.tsx +1 -1
- package/src/tools/CronScheduler/types/index.ts +8 -3
- package/src/tools/CronScheduler/utils/cron-humanize.ts +61 -16
- package/src/tools/CronScheduler/utils/cron-parser.ts +13 -4
- package/src/tools/FileIcon/FileIcon.tsx +24 -39
- package/src/tools/FileIcon/get-file-icon.ts +73 -0
- package/src/tools/FileIcon/icons/icon-data.ts +399 -0
- package/src/tools/FileIcon/index.ts +4 -0
- package/src/tools/FileIcon/loader.ts +17 -35
- package/src/tools/FileIcon/specialFolders.ts +18 -0
- package/src/tools/Gallery/components/lightbox/GalleryLightbox.tsx +112 -35
- package/src/tools/Gallery/components/media/GalleryVideo.tsx +21 -2
- package/src/tools/Gallery/components/preview/GalleryCarousel.tsx +11 -1
- package/src/tools/Gallery/hooks/usePreloadImages.ts +54 -7
- package/src/tools/ImageViewer/components/ImageInfo.tsx +12 -1
- package/src/tools/ImageViewer/components/ImageToolbar.tsx +51 -43
- package/src/tools/ImageViewer/components/ImageViewer.tsx +96 -24
- package/src/tools/ImageViewer/hooks/useImageLoading.ts +13 -0
- package/src/tools/ImageViewer/utils/constants.ts +3 -0
- package/src/tools/ImageViewer/utils/index.ts +1 -0
- package/src/tools/JsonForm/JsonSchemaForm.tsx +4 -1
- package/src/tools/JsonForm/templates/ArrayFieldTemplate.tsx +5 -3
- package/src/tools/JsonForm/templates/BaseInputTemplate.tsx +7 -4
- package/src/tools/JsonForm/templates/ErrorListTemplate.tsx +3 -1
- package/src/tools/JsonForm/templates/ObjectFieldTemplate.tsx +23 -3
- package/src/tools/JsonForm/widgets/ColorWidget.tsx +20 -12
- package/src/tools/JsonForm/widgets/NumberWidget.tsx +14 -9
- package/src/tools/JsonForm/widgets/RadioWidget.tsx +78 -0
- package/src/tools/JsonForm/widgets/SelectWidget.tsx +1 -0
- package/src/tools/JsonForm/widgets/SliderWidget.tsx +7 -4
- package/src/tools/JsonForm/widgets/TextWidget.tsx +41 -17
- package/src/tools/JsonForm/widgets/index.ts +1 -0
- package/src/tools/JsonTree/components/JsonContent.tsx +115 -40
- package/src/tools/LottiePlayer/LottiePlayer.client.tsx +177 -72
- package/src/tools/LottiePlayer/index.tsx +14 -4
- package/src/tools/LottiePlayer/lazy.tsx +11 -3
- package/src/tools/LottiePlayer/types.ts +31 -1
- package/src/tools/LottiePlayer/useLottie.ts +32 -9
- package/src/tools/LottiePlayer/usePrefersReducedMotion.ts +46 -0
- package/src/tools/Map/components/LayerSwitcher.tsx +54 -21
- package/src/tools/Map/components/MapCluster.tsx +28 -21
- package/src/tools/Map/components/MapContainer.tsx +11 -4
- package/src/tools/Map/components/MapLegend.tsx +46 -15
- package/src/tools/Map/components/MapMarker.tsx +31 -2
- package/src/tools/Map/hooks/useMapEvents.ts +64 -105
- package/src/tools/MarkdownEditor/MarkdownEditor.tsx +61 -6
- package/src/tools/MarkdownEditor/MentionList.tsx +37 -4
- package/src/tools/MarkdownEditor/createMentionSuggestion.ts +11 -0
- package/src/tools/MarkdownEditor/lazy.tsx +32 -7
- package/src/tools/MarkdownEditor/styles.css +13 -0
- package/src/tools/MarkdownMessage/CodeBlock.tsx +40 -17
- package/src/tools/MarkdownMessage/MarkdownMessage.tsx +26 -6
- package/src/tools/MarkdownMessage/components.tsx +22 -9
- package/src/tools/MarkdownMessage/types.ts +24 -1
- package/src/tools/Mermaid/Mermaid.client.tsx +27 -5
- package/src/tools/Mermaid/components/MermaidErrorPanel.tsx +31 -0
- package/src/tools/Mermaid/components/MermaidFullscreenModal.tsx +14 -17
- package/src/tools/Mermaid/hooks/useMermaidRenderer.ts +264 -168
- package/src/tools/Mermaid/hooks/useMermaidValidation.ts +76 -10
- package/src/tools/Mermaid/index.tsx +6 -0
- package/src/tools/Mermaid/utils/mermaid-helpers.ts +141 -18
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/SchemaFields/FieldRow.tsx +11 -1
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/SchemaFields/buildTree.ts +49 -20
- package/src/tools/OpenapiViewer/components/DocsLayout/EndpointDoc/index.tsx +7 -0
- package/src/tools/OpenapiViewer/components/DocsLayout/grouping.ts +7 -4
- package/src/tools/OpenapiViewer/constants.ts +3 -0
- package/src/tools/OpenapiViewer/hooks/useOpenApiSchema.ts +73 -11
- package/src/tools/OpenapiViewer/utils/schemaExport.ts +26 -6
- package/src/tools/PrettyCode/PrettyCode.client.tsx +23 -16
- package/src/tools/PrettyCode/lazy.tsx +1 -1
- package/src/tools/SpeechRecognition/README.md +1 -1
- package/src/tools/SpeechRecognition/__tests__/language.test.ts +9 -3
- package/src/tools/SpeechRecognition/components/RecordingPulse.tsx +59 -0
- package/src/tools/SpeechRecognition/components/index.ts +2 -0
- package/src/tools/SpeechRecognition/core/engine/external.ts +24 -7
- package/src/tools/SpeechRecognition/core/language.ts +23 -6
- package/src/tools/SpeechRecognition/hooks/usePushToTalk.ts +36 -5
- package/src/tools/SpeechRecognition/hooks/useSpeechRecognition.ts +18 -11
- package/src/tools/SpeechRecognition/widgets/VoiceComposerSlot.tsx +94 -26
- package/src/tools/SpeechRecognition/widgets/index.ts +1 -1
- package/src/tools/Tree/README.md +4 -8
- package/src/tools/Tree/TreeRoot.tsx +22 -10
- package/src/tools/Tree/components/TreeContent.tsx +24 -4
- package/src/tools/Tree/components/TreeLabel.tsx +8 -2
- package/src/tools/Tree/components/TreeRow.tsx +16 -6
- package/src/tools/Tree/data/flatten.ts +10 -4
- package/src/tools/Tree/types.ts +4 -0
- package/src/tools/Uploader/components/UploadAddButton.tsx +29 -6
- package/src/tools/Uploader/components/UploadDropzone.tsx +63 -7
- package/src/tools/Uploader/components/UploadPageDropOverlay.tsx +19 -5
- package/src/tools/Uploader/components/UploadPreviewItem.tsx +47 -17
- package/src/tools/Uploader/components/UploadPreviewList.tsx +24 -12
- package/src/tools/Uploader/utils/formatters.ts +8 -3
- package/src/tools/VideoPlayer/canvas/hls-canvas.tsx +1 -0
- package/src/tools/VideoPlayer/canvas/{jsx.d.ts → jsx-augmentation.ts} +12 -19
- package/src/tools/VideoPlayer/canvas/vimeo-canvas.tsx +1 -0
- package/src/tools/VideoPlayer/canvas/youtube-canvas.tsx +1 -0
- package/src/tools/VideoPlayer/parts/fullscreen.tsx +1 -1
- package/src/tools/VideoPlayer/parts/pip.tsx +1 -1
- package/src/tools/VideoPlayer/parts/playback-rate.tsx +1 -1
- package/src/tools/VideoPlayer/parts/seek-bar.tsx +2 -2
- package/src/tools/VideoPlayer/parts/volume.tsx +2 -2
- package/src/tools/index.ts +2 -1
- package/src/tools/Chat/components/AudioToggle.tsx +0 -78
- package/src/tools/Chat/components/ChatRoot.tsx +0 -305
- package/src/tools/Chat/components/Composer.tsx +0 -216
- package/src/tools/Chat/hooks/useChatScroll.ts +0 -145
- package/src/tools/Chat/types.ts +0 -9
- package/src/tools/JsonTree/components/JsonToolbar.tsx +0 -95
- package/src/tools/JsonTree/hooks/useElementCorner.ts +0 -84
- package/src/tools/JsonTree/hooks/useNavbarHeight.ts +0 -83
- package/src/tools/OpenapiViewer/components/DocsLayout/schemaFields.ts +0 -121
- package/src/tools/Tour/README.md +0 -373
- package/src/tools/Tour/components/Tour.tsx +0 -12
- package/src/tools/Tour/components/TourContent.tsx +0 -171
- package/src/tools/Tour/components/TourNavigation.tsx +0 -77
- package/src/tools/Tour/components/TourProgress.tsx +0 -88
- package/src/tools/Tour/components/TourSpotlight.tsx +0 -199
- package/src/tools/Tour/components/index.ts +0 -5
- package/src/tools/Tour/context/TourContext.ts +0 -19
- package/src/tools/Tour/context/TourProvider.tsx +0 -292
- package/src/tools/Tour/context/index.ts +0 -2
- package/src/tools/Tour/hooks/index.ts +0 -3
- package/src/tools/Tour/hooks/useKeyboardNavigation.ts +0 -59
- package/src/tools/Tour/hooks/useStepTarget.ts +0 -121
- package/src/tools/Tour/hooks/useTour.ts +0 -42
- package/src/tools/Tour/index.ts +0 -38
- package/src/tools/Tour/types/index.ts +0 -224
- package/src/tools/Tour/utils/dom.ts +0 -98
- package/src/tools/Tour/utils/index.ts +0 -3
- package/src/tools/Tour/utils/logger.ts +0 -3
- package/src/tools/Tour/utils/scrollIntoView.ts +0 -24
- /package/src/tools/Chat/{config.ts → constants.ts} +0 -0
- /package/src/tools/Chat/launcher/{ChatHeaderAudioToggle.tsx → header/ChatHeaderAudioToggle.tsx} +0 -0
- /package/src/tools/Chat/{components → messages}/Attachments.tsx +0 -0
- /package/src/tools/Chat/{components → messages}/JumpToLatest.tsx +0 -0
- /package/src/tools/Chat/{components → messages}/MessageActions.tsx +0 -0
- /package/src/tools/Chat/{components → messages}/Sources.tsx +0 -0
- /package/src/tools/Chat/{components → messages}/StreamingIndicator.tsx +0 -0
- /package/src/tools/Chat/{components → messages}/ToolCalls.tsx +0 -0
- /package/src/tools/Chat/{components → shell}/ErrorBanner.tsx +0 -0
package/src/tools/Chat/lazy.tsx
CHANGED
|
@@ -12,28 +12,38 @@
|
|
|
12
12
|
* Rules of thumb:
|
|
13
13
|
* - **Heavy** (ChatRoot, ChatLauncher, ChatFAB, ChatDock, MessageList,
|
|
14
14
|
* MessageBubble, Composer, ToolCalls, Attachments*, ChatHeader*, …) —
|
|
15
|
-
* loaded only via `Lazy*` wrappers below
|
|
16
|
-
* re-
|
|
15
|
+
* loaded only via `Lazy*` wrappers below for maximum laziness. They are
|
|
16
|
+
* ALSO re-exported synchronously (composable surface, see note below)
|
|
17
|
+
* so custom chat shells can import them. The sync re-export is a flat
|
|
18
|
+
* `export *` from the domain barrels — never a hand-listed copy.
|
|
17
19
|
* - **Light** (types, config constants, pure core reducer/utils,
|
|
18
20
|
* transports, hooks without UI, audio prefs, draft sanitizer) —
|
|
19
|
-
* re-exported synchronously
|
|
20
|
-
* helpers and hooks pull in no UI components.
|
|
21
|
+
* re-exported synchronously via `./public`. Types are erased at compile
|
|
22
|
+
* time; helpers and hooks pull in no UI components.
|
|
21
23
|
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
24
|
+
* The light surface lives in `./public` and is shared verbatim with the
|
|
25
|
+
* root barrel `index.ts` — one list, edited once.
|
|
26
|
+
*
|
|
27
|
+
* Consumers that want maximum laziness should use `LazyChat` /
|
|
28
|
+
* `LazyChatLauncher` and skip the synchronous component re-exports.
|
|
25
29
|
*/
|
|
26
30
|
|
|
27
31
|
import { createLazyComponent, LoadingFallback } from '../../components/lazy-wrapper';
|
|
28
|
-
import type { ChatRootProps } from './
|
|
32
|
+
import type { ChatRootProps } from './shell/ChatRoot';
|
|
29
33
|
import type { ChatLauncherProps } from './launcher';
|
|
30
34
|
|
|
35
|
+
// ============================================================================
|
|
36
|
+
// Light surface — shared with the root barrel via ./public
|
|
37
|
+
// ============================================================================
|
|
38
|
+
|
|
39
|
+
export * from './public';
|
|
40
|
+
|
|
31
41
|
// ============================================================================
|
|
32
42
|
// Lazy UI components
|
|
33
43
|
// ============================================================================
|
|
34
44
|
|
|
35
45
|
export const LazyChat = createLazyComponent<ChatRootProps>(
|
|
36
|
-
() => import('./
|
|
46
|
+
() => import('./shell/ChatRoot').then((m) => ({ default: m.ChatRoot })),
|
|
37
47
|
{
|
|
38
48
|
displayName: 'LazyChat',
|
|
39
49
|
fallback: <LoadingFallback minHeight={320} text="Loading chat…" />,
|
|
@@ -49,289 +59,33 @@ export const LazyChatLauncher = createLazyComponent<ChatLauncherProps>(
|
|
|
49
59
|
},
|
|
50
60
|
);
|
|
51
61
|
|
|
52
|
-
// ============================================================================
|
|
53
|
-
// Light surface re-exports — types + pure helpers + hooks without UI
|
|
54
|
-
// ============================================================================
|
|
55
|
-
|
|
56
|
-
// Types (erased at compile time, free to re-export)
|
|
57
|
-
export type {
|
|
58
|
-
ChatRole,
|
|
59
|
-
ChatMessage,
|
|
60
|
-
ChatPersona,
|
|
61
|
-
ChatToolCall,
|
|
62
|
-
ChatAttachment,
|
|
63
|
-
ChatSource,
|
|
64
|
-
ChatDisplayMode,
|
|
65
|
-
ChatUserContext,
|
|
66
|
-
ChatAssistantContext,
|
|
67
|
-
ChatPrefs,
|
|
68
|
-
ChatConfig,
|
|
69
|
-
ChatLabels,
|
|
70
|
-
ChatTransport,
|
|
71
|
-
ChatStreamEvent,
|
|
72
|
-
CreateSessionOptions,
|
|
73
|
-
SessionInfo,
|
|
74
|
-
HistoryPage,
|
|
75
|
-
StreamOptions,
|
|
76
|
-
SendOptions,
|
|
77
|
-
} from './types';
|
|
78
|
-
export { DEFAULT_LABELS } from './types';
|
|
79
|
-
|
|
80
|
-
// Config — plain constants, no UI imports
|
|
81
|
-
export {
|
|
82
|
-
STORAGE_KEYS,
|
|
83
|
-
CSS_VARS,
|
|
84
|
-
DEFAULT_Z_INDEX,
|
|
85
|
-
LIMITS,
|
|
86
|
-
DEFAULT_SIDEBAR,
|
|
87
|
-
HOTKEYS,
|
|
88
|
-
CHAT_EVENT_NAME,
|
|
89
|
-
type ChatEventDetail,
|
|
90
|
-
} from './config';
|
|
91
|
-
|
|
92
|
-
// Core — pure reducer / id / token buffer / persona / initials
|
|
93
|
-
export {
|
|
94
|
-
reducer,
|
|
95
|
-
initialState,
|
|
96
|
-
createId,
|
|
97
|
-
createTokenBuffer,
|
|
98
|
-
resolvePersona,
|
|
99
|
-
deriveInitials,
|
|
100
|
-
type ChatState,
|
|
101
|
-
type ChatAction,
|
|
102
|
-
type TokenBuffer,
|
|
103
|
-
} from './core';
|
|
104
|
-
|
|
105
|
-
// Transports — pure functions, no UI
|
|
106
|
-
export {
|
|
107
|
-
createHttpTransport,
|
|
108
|
-
createMockTransport,
|
|
109
|
-
parseSSE,
|
|
110
|
-
TransportError,
|
|
111
|
-
createPydanticAIChatTransport,
|
|
112
|
-
createToolIdQueue,
|
|
113
|
-
mapPydanticAIEvent,
|
|
114
|
-
createPydanticAISSEMap,
|
|
115
|
-
type HttpTransportConfig,
|
|
116
|
-
type MockTransportOptions,
|
|
117
|
-
type ParseSSEOptions,
|
|
118
|
-
type PydanticAIChatTransportOpts,
|
|
119
|
-
type PydanticAIEvent,
|
|
120
|
-
type ToolIdQueue,
|
|
121
|
-
} from './core/transport';
|
|
122
|
-
|
|
123
|
-
// Hooks — no JSX, no UI
|
|
124
|
-
export {
|
|
125
|
-
useChat,
|
|
126
|
-
useChatComposer,
|
|
127
|
-
useChatScroll,
|
|
128
|
-
useChatHistory,
|
|
129
|
-
useChatLayout,
|
|
130
|
-
useChatAudio,
|
|
131
|
-
useAutoFocusOnStreamEnd,
|
|
132
|
-
useRegisterComposer,
|
|
133
|
-
useChatReset,
|
|
134
|
-
useVisitorFingerprint,
|
|
135
|
-
useChatDockPrefs,
|
|
136
|
-
DEFAULT_DOCK_PREFS,
|
|
137
|
-
useFocusOnEmptyClick,
|
|
138
|
-
useChatUnread,
|
|
139
|
-
useChatUnreadNotifier,
|
|
140
|
-
useChatLightbox,
|
|
141
|
-
type UseChatUnreadOptions,
|
|
142
|
-
type UseChatUnreadReturn,
|
|
143
|
-
type UseChatUnreadNotifierOptions,
|
|
144
|
-
type UseChatConfig,
|
|
145
|
-
type UseChatReturn,
|
|
146
|
-
type UseChatComposerOptions,
|
|
147
|
-
type UseChatComposerReturn,
|
|
148
|
-
type UseChatScrollOptions,
|
|
149
|
-
type UseChatScrollReturn,
|
|
150
|
-
type UseChatHistoryOptions,
|
|
151
|
-
type UseChatLayoutConfig,
|
|
152
|
-
type UseChatLayoutReturn,
|
|
153
|
-
type UseAutoFocusOnStreamEndOptions,
|
|
154
|
-
type Focusable,
|
|
155
|
-
type UseChatResetOptions,
|
|
156
|
-
type UseChatResetReturn,
|
|
157
|
-
type UseVisitorFingerprintOptions,
|
|
158
|
-
type ChatDockPrefs,
|
|
159
|
-
type UseChatDockPrefsOptions,
|
|
160
|
-
type UseChatDockPrefsReturn,
|
|
161
|
-
type UseFocusOnEmptyClickOptions,
|
|
162
|
-
type UseChatLightboxReturn,
|
|
163
|
-
type ChatLightboxState,
|
|
164
|
-
} from './hooks';
|
|
165
|
-
|
|
166
|
-
// Audio
|
|
167
|
-
export {
|
|
168
|
-
useChatAudioPrefs,
|
|
169
|
-
DEFAULT_CHAT_SOUNDS,
|
|
170
|
-
type ChatAudioEvent,
|
|
171
|
-
type ChatAudioSounds,
|
|
172
|
-
type ChatAudioConfig,
|
|
173
|
-
type UseChatAudioReturn,
|
|
174
|
-
} from './core/audio';
|
|
175
|
-
|
|
176
|
-
// Notifier — title rotation + favicon badge + cross-tab decorator. Pure
|
|
177
|
-
// browser-API code, no React, no UI components.
|
|
178
|
-
export {
|
|
179
|
-
createBrowserNotifier,
|
|
180
|
-
createNoopNotifier,
|
|
181
|
-
createTitleRotator,
|
|
182
|
-
createFaviconBadge,
|
|
183
|
-
createCrossTabNotifier,
|
|
184
|
-
isPageHidden,
|
|
185
|
-
onVisibilityChange,
|
|
186
|
-
type ChatNotifier,
|
|
187
|
-
type BrowserNotifierOptions,
|
|
188
|
-
type TitleRotatorOptions,
|
|
189
|
-
type TitleMode,
|
|
190
|
-
type FaviconBadgeOptions,
|
|
191
|
-
type CrossTabNotifierOptions,
|
|
192
|
-
} from './notifier';
|
|
193
|
-
|
|
194
|
-
// Tool-call payload dispatcher — pure
|
|
195
|
-
export {
|
|
196
|
-
dispatchToolPayload,
|
|
197
|
-
isPlainObject,
|
|
198
|
-
isLatLng,
|
|
199
|
-
isGeoJSONFeatureCollection,
|
|
200
|
-
isStringValue,
|
|
201
|
-
type ToolPayloadMatcher,
|
|
202
|
-
type ToolPayloadFallback,
|
|
203
|
-
} from './core/payload-dispatch';
|
|
204
|
-
|
|
205
|
-
// Logger — pure
|
|
206
|
-
export {
|
|
207
|
-
getChatLogger,
|
|
208
|
-
type ChatLogger,
|
|
209
|
-
type ChatLogScope,
|
|
210
|
-
} from './core/logger';
|
|
211
|
-
|
|
212
|
-
// Utils — pure
|
|
213
|
-
export { sanitizeDraft, isSubmittableDraft } from './utils/sanitizeDraft';
|
|
214
|
-
export { collectImageAttachments } from './utils/collectImageAttachments';
|
|
215
|
-
|
|
216
|
-
// Style tokens — strings + hooks, no UI components
|
|
217
|
-
export {
|
|
218
|
-
BUBBLE_SURFACE,
|
|
219
|
-
ANCHOR,
|
|
220
|
-
TOGGLE,
|
|
221
|
-
DESTRUCTIVE_SURFACE,
|
|
222
|
-
TOOL_CALL,
|
|
223
|
-
useChatBubbleStyles,
|
|
224
|
-
useChatRoleStyles,
|
|
225
|
-
useChatDestructiveStyles,
|
|
226
|
-
type ChatBubbleSurface,
|
|
227
|
-
type ChatBubbleStyles,
|
|
228
|
-
type ChatRoleStyles,
|
|
229
|
-
type ChatDestructiveStyles,
|
|
230
|
-
} from './styles';
|
|
231
|
-
|
|
232
|
-
// Provider / context — needed by callers wiring custom chat shells
|
|
233
|
-
export {
|
|
234
|
-
ChatProvider,
|
|
235
|
-
useChatContext,
|
|
236
|
-
useChatContextOptional,
|
|
237
|
-
type ChatContextValue,
|
|
238
|
-
type ChatProviderProps,
|
|
239
|
-
} from './context';
|
|
240
|
-
|
|
241
62
|
// ============================================================================
|
|
242
63
|
// Composable surface — synchronously re-exported components and their prop
|
|
243
64
|
// types. These are needed by consumers that build custom chat shells
|
|
244
|
-
// (e.g. `@djangocfg/crm`'s AdminChat / PublicChat
|
|
245
|
-
// `LazyChat` directly.
|
|
65
|
+
// (e.g. `@djangocfg/crm`'s AdminChat / PublicChat, Storybook stories)
|
|
66
|
+
// rather than rendering `LazyChat` directly.
|
|
246
67
|
//
|
|
247
68
|
// They DO transitively pull in MarkdownMessage / Sources / StreamingIndicator
|
|
248
69
|
// when actually rendered. Importing the types alone is free. Importing the
|
|
249
70
|
// component costs the dependency graph — that's the price of a custom shell.
|
|
250
|
-
//
|
|
251
|
-
// Apps that want maximum laziness should use `LazyChat` / `LazyChatLauncher`
|
|
252
|
-
// above and skip these.
|
|
253
71
|
// ============================================================================
|
|
254
72
|
|
|
255
|
-
export
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
ChatHeader,
|
|
260
|
-
ChatHeaderActionButton,
|
|
261
|
-
ChatHeaderAudioToggle,
|
|
262
|
-
ChatHeaderLanguageButton,
|
|
263
|
-
ChatHeaderModeToggle,
|
|
264
|
-
ChatHeaderResetButton,
|
|
265
|
-
ChatGreeting,
|
|
266
|
-
ChatUnreadPreview,
|
|
267
|
-
} from './launcher';
|
|
73
|
+
export * from './messages';
|
|
74
|
+
export * from './composer';
|
|
75
|
+
export * from './shell';
|
|
76
|
+
export * from './launcher';
|
|
268
77
|
|
|
78
|
+
// Highlight — AI-driven `point` directives (lightweight, no heavy deps).
|
|
269
79
|
export {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
JumpToLatest,
|
|
283
|
-
StreamingIndicator,
|
|
284
|
-
AudioToggle,
|
|
285
|
-
} from './components';
|
|
286
|
-
|
|
287
|
-
// Heavy-component prop types
|
|
288
|
-
export type {
|
|
289
|
-
ChatLauncherProps,
|
|
290
|
-
ChatLauncherHotkey,
|
|
291
|
-
ChatLauncherGreeting,
|
|
292
|
-
ChatHeaderSlots,
|
|
293
|
-
ChatHeaderResetSlot,
|
|
294
|
-
ChatHeaderLanguageSlot,
|
|
295
|
-
ChatHeaderModeToggleSlot,
|
|
296
|
-
ChatFABProps,
|
|
297
|
-
ChatFABPosition,
|
|
298
|
-
ChatFABVariant,
|
|
299
|
-
ChatFABSize,
|
|
300
|
-
ChatDockProps,
|
|
301
|
-
ChatDockMode,
|
|
302
|
-
ChatDockSide,
|
|
303
|
-
ChatHeaderProps,
|
|
304
|
-
ChatHeaderActionButtonProps,
|
|
305
|
-
ChatHeaderModeToggleProps,
|
|
306
|
-
ChatHeaderAudioToggleProps,
|
|
307
|
-
ChatHeaderResetButtonProps,
|
|
308
|
-
ChatHeaderLanguageButtonProps,
|
|
309
|
-
ChatGreetingProps,
|
|
310
|
-
ChatUnreadPreviewProps,
|
|
311
|
-
ChatPresencePhase,
|
|
312
|
-
} from './launcher';
|
|
313
|
-
|
|
314
|
-
export { useChatPresence } from './launcher';
|
|
315
|
-
|
|
316
|
-
export type {
|
|
317
|
-
ChatRootProps,
|
|
318
|
-
MessageListProps,
|
|
319
|
-
MessageListHandle,
|
|
320
|
-
MessageBubbleProps,
|
|
321
|
-
MessageActionsProps,
|
|
322
|
-
ComposerProps,
|
|
323
|
-
SourcesProps,
|
|
324
|
-
ToolCallsProps,
|
|
325
|
-
ToolPayloadKind,
|
|
326
|
-
AttachmentsProps,
|
|
327
|
-
AttachmentsGridProps,
|
|
328
|
-
AttachmentsListProps,
|
|
329
|
-
AttachmentRenderer,
|
|
330
|
-
AttachmentRendererArgs,
|
|
331
|
-
AttachmentRendererMap,
|
|
332
|
-
EmptyStateProps,
|
|
333
|
-
ErrorBannerProps,
|
|
334
|
-
JumpToLatestProps,
|
|
335
|
-
StreamingIndicatorProps,
|
|
336
|
-
AudioToggleProps,
|
|
337
|
-
} from './components';
|
|
80
|
+
HighlightOverlay,
|
|
81
|
+
SpotlightCanvas,
|
|
82
|
+
useHighlightTargets,
|
|
83
|
+
resolveRefs,
|
|
84
|
+
type HighlightOverlayProps,
|
|
85
|
+
type SpotlightCanvasProps,
|
|
86
|
+
type RefResolver,
|
|
87
|
+
type PointDirective,
|
|
88
|
+
type HighlightTarget,
|
|
89
|
+
type SpotlightRect,
|
|
90
|
+
type CSTRefId,
|
|
91
|
+
} from './highlight';
|
|
@@ -26,7 +26,10 @@ import {
|
|
|
26
26
|
type AttachmentRendererMap,
|
|
27
27
|
} from './Attachments';
|
|
28
28
|
import { MessageActions } from './MessageActions';
|
|
29
|
+
import { MessageBlocks } from './blocks';
|
|
30
|
+
import type { BlockRegistry } from './blocks';
|
|
29
31
|
import type { ToolCallsProps } from './ToolCalls';
|
|
32
|
+
import type { ComposerAppearance } from '../composer/types';
|
|
30
33
|
|
|
31
34
|
export interface MessageBubbleProps {
|
|
32
35
|
message: ChatMessage;
|
|
@@ -42,6 +45,9 @@ export interface MessageBubbleProps {
|
|
|
42
45
|
showTimestamp?: boolean;
|
|
43
46
|
showActions?: boolean;
|
|
44
47
|
isCompact?: boolean;
|
|
48
|
+
/** Spaciousness of the bubble — `full` scales padding, text, avatar up
|
|
49
|
+
* for full-page chat. `compact` (default) keeps the current geometry. */
|
|
50
|
+
appearance?: ComposerAppearance;
|
|
45
51
|
className?: string;
|
|
46
52
|
beforeContent?: ReactNode;
|
|
47
53
|
afterContent?: ReactNode;
|
|
@@ -52,6 +58,11 @@ export interface MessageBubbleProps {
|
|
|
52
58
|
attachmentsRenderer?: (atts: ChatAttachment[]) => ReactNode;
|
|
53
59
|
/** Per-type attachment renderers forwarded to default `<Attachments>`. */
|
|
54
60
|
attachmentRenderers?: AttachmentRendererMap;
|
|
61
|
+
/**
|
|
62
|
+
* Registry of `kind` → renderer for `message.blocks`. Prop beats
|
|
63
|
+
* context; both fall back to `BUILTIN_BLOCK_REGISTRY`.
|
|
64
|
+
*/
|
|
65
|
+
blockRegistry?: BlockRegistry;
|
|
55
66
|
/** Click handler for attachment tiles (e.g. open lightbox). */
|
|
56
67
|
onAttachmentOpen?: (a: ChatAttachment) => void;
|
|
57
68
|
onCopy?: () => void;
|
|
@@ -96,6 +107,28 @@ export interface MessageBubbleProps {
|
|
|
96
107
|
renderAfterMessage?: (m: ChatMessage) => ReactNode;
|
|
97
108
|
}
|
|
98
109
|
|
|
110
|
+
/** Extra spaciousness layered on top of the default bubble geometry when
|
|
111
|
+
* `appearance="full"`. Empty strings for `compact` keep every pixel of the
|
|
112
|
+
* current geometry untouched (backward-compat). */
|
|
113
|
+
const APPEARANCE_CLASSES: Record<ComposerAppearance, {
|
|
114
|
+
row: string;
|
|
115
|
+
avatar: string;
|
|
116
|
+
avatarFallback: string;
|
|
117
|
+
bubble: string;
|
|
118
|
+
meta: string;
|
|
119
|
+
}> = {
|
|
120
|
+
compact: { row: '', avatar: '', avatarFallback: '', bubble: '', meta: '' },
|
|
121
|
+
full: {
|
|
122
|
+
row: 'gap-4',
|
|
123
|
+
avatar: 'size-10',
|
|
124
|
+
avatarFallback: 'text-sm',
|
|
125
|
+
// Roomy ChatGPT-style bubble: larger text with generous line-height
|
|
126
|
+
// and padding so a full-page chat reads spacious, not just bigger.
|
|
127
|
+
bubble: 'rounded-3xl px-5 py-3.5 text-base leading-relaxed',
|
|
128
|
+
meta: 'text-xs',
|
|
129
|
+
},
|
|
130
|
+
};
|
|
131
|
+
|
|
99
132
|
const MessageBubbleInner = ({
|
|
100
133
|
message,
|
|
101
134
|
isUser: isUserProp,
|
|
@@ -107,6 +140,7 @@ const MessageBubbleInner = ({
|
|
|
107
140
|
showTimestamp = false,
|
|
108
141
|
showActions = true,
|
|
109
142
|
isCompact = false,
|
|
143
|
+
appearance = 'compact',
|
|
110
144
|
className,
|
|
111
145
|
beforeContent,
|
|
112
146
|
afterContent,
|
|
@@ -115,6 +149,7 @@ const MessageBubbleInner = ({
|
|
|
115
149
|
sourcesRenderer,
|
|
116
150
|
attachmentsRenderer,
|
|
117
151
|
attachmentRenderers,
|
|
152
|
+
blockRegistry,
|
|
118
153
|
onAttachmentOpen,
|
|
119
154
|
onCopy,
|
|
120
155
|
onRegenerate,
|
|
@@ -133,6 +168,9 @@ const MessageBubbleInner = ({
|
|
|
133
168
|
);
|
|
134
169
|
|
|
135
170
|
const ctx = useChatContextOptional();
|
|
171
|
+
// Prop beats context; `<MessageBlocks>` falls back to the built-in
|
|
172
|
+
// registry when both are absent.
|
|
173
|
+
const resolvedBlockRegistry = blockRegistry ?? ctx?.blockRegistry;
|
|
136
174
|
const persona = resolvePersona(
|
|
137
175
|
message,
|
|
138
176
|
user ?? ctx?.config.user,
|
|
@@ -140,6 +178,9 @@ const MessageBubbleInner = ({
|
|
|
140
178
|
);
|
|
141
179
|
const initials = deriveInitials(persona, message.role);
|
|
142
180
|
const personaName = persona.name ?? (isUser ? 'You' : 'Assistant');
|
|
181
|
+
// `appearance` scales the whole bubble (padding, text, avatar) so a
|
|
182
|
+
// full-page chat reads like ChatGPT/Gemini. `compact` = no changes.
|
|
183
|
+
const ap = APPEARANCE_CLASSES[appearance];
|
|
143
184
|
|
|
144
185
|
return (
|
|
145
186
|
<div
|
|
@@ -149,19 +190,20 @@ const MessageBubbleInner = ({
|
|
|
149
190
|
data-role={message.role}
|
|
150
191
|
className={cn(
|
|
151
192
|
'group/msg flex gap-2.5 px-2.5 py-2',
|
|
193
|
+
ap.row,
|
|
152
194
|
isUser ? 'flex-row-reverse' : 'flex-row',
|
|
153
195
|
className,
|
|
154
196
|
)}
|
|
155
197
|
>
|
|
156
198
|
{showAvatar ? (
|
|
157
199
|
<Avatar
|
|
158
|
-
className=
|
|
200
|
+
className={cn('size-7 shrink-0', ap.avatar)}
|
|
159
201
|
title={persona.description ?? personaName}
|
|
160
202
|
>
|
|
161
203
|
{avatarSrc || persona.avatarUrl ? (
|
|
162
204
|
<AvatarImage src={avatarSrc ?? persona.avatarUrl} alt={personaName} />
|
|
163
205
|
) : null}
|
|
164
|
-
<AvatarFallback className=
|
|
206
|
+
<AvatarFallback className={cn('text-[10px]', ap.avatarFallback)}>
|
|
165
207
|
{avatarFallback ?? initials}
|
|
166
208
|
</AvatarFallback>
|
|
167
209
|
</Avatar>
|
|
@@ -195,6 +237,7 @@ const MessageBubbleInner = ({
|
|
|
195
237
|
<div
|
|
196
238
|
className={cn(
|
|
197
239
|
'inline-block max-w-full rounded-2xl px-3.5 py-2 text-sm',
|
|
240
|
+
ap.bubble,
|
|
198
241
|
bubbleSurface,
|
|
199
242
|
)}
|
|
200
243
|
>
|
|
@@ -210,7 +253,7 @@ const MessageBubbleInner = ({
|
|
|
210
253
|
<MarkdownMessage
|
|
211
254
|
content={message.content || (isErr ? '*Failed to generate a response.*' : '')}
|
|
212
255
|
isUser={isUser}
|
|
213
|
-
|
|
256
|
+
size={appearance === 'full' ? 'base' : isCompact ? 'xs' : 'sm'}
|
|
214
257
|
plainText={isStreaming}
|
|
215
258
|
/>
|
|
216
259
|
) : (
|
|
@@ -218,6 +261,15 @@ const MessageBubbleInner = ({
|
|
|
218
261
|
)}
|
|
219
262
|
</div>
|
|
220
263
|
|
|
264
|
+
{message.blocks?.length ? (
|
|
265
|
+
<MessageBlocks
|
|
266
|
+
blocks={message.blocks}
|
|
267
|
+
registry={resolvedBlockRegistry}
|
|
268
|
+
appearance={appearance}
|
|
269
|
+
isUser={isUser}
|
|
270
|
+
/>
|
|
271
|
+
) : null}
|
|
272
|
+
|
|
221
273
|
{message.toolCalls?.length
|
|
222
274
|
? toolCallsRenderer
|
|
223
275
|
? toolCallsRenderer(message.toolCalls)
|
|
@@ -246,7 +298,7 @@ const MessageBubbleInner = ({
|
|
|
246
298
|
) : null}
|
|
247
299
|
|
|
248
300
|
{showTimestamp ? (
|
|
249
|
-
<div className=
|
|
301
|
+
<div className={cn('mt-1 text-[10px] text-muted-foreground', ap.meta)}>
|
|
250
302
|
{new Date(message.createdAt).toLocaleTimeString()}
|
|
251
303
|
</div>
|
|
252
304
|
) : null}
|
|
@@ -269,7 +321,8 @@ export const MessageBubble = memo(MessageBubbleInner, (prev, next) => {
|
|
|
269
321
|
a.toolActivity === b.toolActivity &&
|
|
270
322
|
a.toolCalls === b.toolCalls &&
|
|
271
323
|
a.sources === b.sources &&
|
|
272
|
-
a.attachments === b.attachments
|
|
324
|
+
a.attachments === b.attachments &&
|
|
325
|
+
a.blocks === b.blocks
|
|
273
326
|
);
|
|
274
327
|
});
|
|
275
328
|
MessageBubble.displayName = 'MessageBubble';
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
type ReactNode,
|
|
5
|
-
type RefObject,
|
|
6
5
|
forwardRef,
|
|
7
6
|
useCallback,
|
|
8
7
|
useEffect,
|
|
@@ -20,6 +19,7 @@ import { useCopy } from '@djangocfg/ui-core/hooks';
|
|
|
20
19
|
import type { ChatMessage } from '../types';
|
|
21
20
|
import { useChatContextOptional } from '../context';
|
|
22
21
|
import { MessageBubble } from './MessageBubble';
|
|
22
|
+
import type { ComposerAppearance } from '../composer/types';
|
|
23
23
|
|
|
24
24
|
export interface MessageListProps {
|
|
25
25
|
messages?: ChatMessage[];
|
|
@@ -34,18 +34,6 @@ export interface MessageListProps {
|
|
|
34
34
|
* `startReached` until `data` length grows).
|
|
35
35
|
*/
|
|
36
36
|
onStartReached?: () => void;
|
|
37
|
-
/**
|
|
38
|
-
* @deprecated Kept as a no-op for backwards compatibility — wire
|
|
39
|
-
* `onStartReached` instead. Virtuoso owns the scroll viewport now,
|
|
40
|
-
* external sentinels never see scroll events.
|
|
41
|
-
*/
|
|
42
|
-
topSentinelRef?: RefObject<HTMLDivElement | null>;
|
|
43
|
-
/**
|
|
44
|
-
* @deprecated Kept as a no-op for backwards compatibility — Virtuoso
|
|
45
|
-
* exposes `scrollToIndex` via the imperative handle instead. See
|
|
46
|
-
* `useChatScroll` for the chat-friendly wrapper.
|
|
47
|
-
*/
|
|
48
|
-
bottomRef?: RefObject<HTMLDivElement | null>;
|
|
49
37
|
className?: string;
|
|
50
38
|
itemClassName?: string;
|
|
51
39
|
/**
|
|
@@ -55,15 +43,6 @@ export interface MessageListProps {
|
|
|
55
43
|
* always. Plan64.
|
|
56
44
|
*/
|
|
57
45
|
noVirtualize?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* @deprecated No-op as of 2.1.373. We intentionally let Virtuoso run
|
|
60
|
-
* its first-item probe pass: cmdop bubbles vary from 40px (one-line
|
|
61
|
-
* user message) to 800px (markdown with code blocks), so any single
|
|
62
|
-
* estimate fed here forces a measure/reshape loop on every render.
|
|
63
|
-
* The kept prop avoids a breaking-change bump for hosts that still
|
|
64
|
-
* pass it explicitly.
|
|
65
|
-
*/
|
|
66
|
-
defaultItemHeight?: number;
|
|
67
46
|
/**
|
|
68
47
|
* Fires when the viewport sticky state changes — `true` when the
|
|
69
48
|
* user is pinned to the bottom (streaming token deltas keep them
|
|
@@ -86,6 +65,10 @@ export interface MessageListProps {
|
|
|
86
65
|
* reply, even if they were scrolled up. Plan11.
|
|
87
66
|
*/
|
|
88
67
|
scrollAnchorId?: string | number | null;
|
|
68
|
+
/** Spaciousness of the default `<MessageBubble>`s — `full` scales the
|
|
69
|
+
* whole bubble up for full-page chat. Default `compact` (no change).
|
|
70
|
+
* Ignored when `renderItem` is set (the host owns bubble rendering). */
|
|
71
|
+
appearance?: ComposerAppearance;
|
|
89
72
|
}
|
|
90
73
|
|
|
91
74
|
export interface MessageListHandle {
|
|
@@ -103,14 +86,13 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
103
86
|
className,
|
|
104
87
|
itemClassName,
|
|
105
88
|
noVirtualize = false,
|
|
106
|
-
defaultItemHeight: _deprecatedDefaultItemHeight,
|
|
107
89
|
onAtBottomChange,
|
|
108
90
|
atBottomThreshold = 120,
|
|
109
91
|
scrollAnchorId,
|
|
92
|
+
appearance = 'compact',
|
|
110
93
|
},
|
|
111
94
|
ref,
|
|
112
95
|
) {
|
|
113
|
-
void _deprecatedDefaultItemHeight;
|
|
114
96
|
const ctx = useChatContextOptional();
|
|
115
97
|
const messages = messagesProp ?? ctx?.messages ?? [];
|
|
116
98
|
const isLoadingMore = isLoadingMoreProp ?? ctx?.isLoadingMore ?? false;
|
|
@@ -167,13 +149,14 @@ export const MessageList = forwardRef<MessageListHandle, MessageListProps>(funct
|
|
|
167
149
|
<div className={itemClassName}>
|
|
168
150
|
<MessageBubble
|
|
169
151
|
message={m}
|
|
152
|
+
appearance={appearance}
|
|
170
153
|
onCopy={() => void copyToClipboard(m.content)}
|
|
171
154
|
onRegenerate={ctx ? () => void ctx.regenerate(m.id) : undefined}
|
|
172
155
|
onDelete={ctx ? () => ctx.deleteMessage(m.id) : undefined}
|
|
173
156
|
/>
|
|
174
157
|
</div>
|
|
175
158
|
),
|
|
176
|
-
[itemClassName, ctx, copyToClipboard],
|
|
159
|
+
[itemClassName, ctx, copyToClipboard, appearance],
|
|
177
160
|
);
|
|
178
161
|
|
|
179
162
|
const itemRenderer = renderItem ?? defaultRenderItem;
|