@djangocfg/ui-tools 2.1.369 → 2.1.371
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ChatRoot-DYMCNGOB.mjs +5 -0
- package/dist/{ChatRoot-DENECC2Q.mjs.map → ChatRoot-DYMCNGOB.mjs.map} +1 -1
- package/dist/ChatRoot-HOQ37WRE.cjs +14 -0
- package/dist/{ChatRoot-PW6U3QVF.cjs.map → ChatRoot-HOQ37WRE.cjs.map} +1 -1
- package/dist/{chunk-OD3P64QD.cjs → chunk-2SKR4U5S.cjs} +15 -16
- package/dist/chunk-2SKR4U5S.cjs.map +1 -0
- package/dist/{chunk-YLIYXSUO.mjs → chunk-MVAT6OPZ.mjs} +16 -17
- package/dist/chunk-MVAT6OPZ.mjs.map +1 -0
- package/dist/index.cjs +47 -47
- package/dist/index.mjs +3 -3
- package/package.json +6 -6
- package/src/tools/Chat/components/MessageList.tsx +24 -10
- package/dist/ChatRoot-DENECC2Q.mjs +0 -5
- package/dist/ChatRoot-PW6U3QVF.cjs +0 -14
- package/dist/chunk-OD3P64QD.cjs.map +0 -1
- package/dist/chunk-YLIYXSUO.mjs.map +0 -1
|
@@ -3,7 +3,7 @@ import { __name } from './chunk-N2XQF2OL.mjs';
|
|
|
3
3
|
import { createContext, forwardRef, memo, useRef, useImperativeHandle, useCallback, useMemo, useReducer, useEffect, useState, useSyncExternalStore, useContext } from 'react';
|
|
4
4
|
import { cn, isDev } from '@djangocfg/ui-core/lib';
|
|
5
5
|
import { consola } from 'consola';
|
|
6
|
-
import { useLocalStorage, useMediaQuery } from '@djangocfg/ui-core/hooks';
|
|
6
|
+
import { useCopy, useLocalStorage, useMediaQuery } from '@djangocfg/ui-core/hooks';
|
|
7
7
|
import { create } from 'zustand';
|
|
8
8
|
import { persist, createJSONStorage } from 'zustand/middleware';
|
|
9
9
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
@@ -2154,6 +2154,7 @@ var MessageList = forwardRef(/* @__PURE__ */ __name(function MessageList2({
|
|
|
2154
2154
|
const ctx = useChatContextOptional();
|
|
2155
2155
|
const messages = messagesProp ?? ctx?.messages ?? [];
|
|
2156
2156
|
const isLoadingMore = isLoadingMoreProp ?? ctx?.isLoadingMore ?? false;
|
|
2157
|
+
const { copyToClipboard } = useCopy();
|
|
2157
2158
|
const virtuosoRef = useRef(null);
|
|
2158
2159
|
useImperativeHandle(
|
|
2159
2160
|
ref,
|
|
@@ -2179,15 +2180,18 @@ var MessageList = forwardRef(/* @__PURE__ */ __name(function MessageList2({
|
|
|
2179
2180
|
MessageBubble,
|
|
2180
2181
|
{
|
|
2181
2182
|
message: m,
|
|
2182
|
-
onCopy: () =>
|
|
2183
|
+
onCopy: () => void copyToClipboard(m.content),
|
|
2183
2184
|
onRegenerate: ctx ? () => void ctx.regenerate(m.id) : void 0,
|
|
2184
2185
|
onDelete: ctx ? () => ctx.deleteMessage(m.id) : void 0
|
|
2185
2186
|
}
|
|
2186
2187
|
) }),
|
|
2187
|
-
[itemClassName, ctx]
|
|
2188
|
+
[itemClassName, ctx, copyToClipboard]
|
|
2188
2189
|
);
|
|
2189
2190
|
const itemRenderer = renderItem ?? defaultRenderItem;
|
|
2190
|
-
const computeItemKey = useCallback(
|
|
2191
|
+
const computeItemKey = useCallback(
|
|
2192
|
+
(index, m) => m?.id ?? index,
|
|
2193
|
+
[]
|
|
2194
|
+
);
|
|
2191
2195
|
const startReachedHandler = useMemo(() => {
|
|
2192
2196
|
if (!onStartReached) return void 0;
|
|
2193
2197
|
let inFlight = false;
|
|
@@ -2240,7 +2244,7 @@ var MessageList = forwardRef(/* @__PURE__ */ __name(function MessageList2({
|
|
|
2240
2244
|
className: cn("flex-1", className),
|
|
2241
2245
|
data: messages,
|
|
2242
2246
|
computeItemKey,
|
|
2243
|
-
itemContent: (index, m) => itemRenderer(m, index),
|
|
2247
|
+
itemContent: (index, m) => m ? itemRenderer(m, index) : null,
|
|
2244
2248
|
defaultItemHeight,
|
|
2245
2249
|
followOutput: (isAtBottom) => isAtBottom ? "auto" : false,
|
|
2246
2250
|
atBottomStateChange: onAtBottomChange,
|
|
@@ -2248,17 +2252,12 @@ var MessageList = forwardRef(/* @__PURE__ */ __name(function MessageList2({
|
|
|
2248
2252
|
startReached: startReachedHandler,
|
|
2249
2253
|
components: isLoadingMore ? {
|
|
2250
2254
|
Header: /* @__PURE__ */ __name(() => /* @__PURE__ */ jsx("div", { className: "flex justify-center py-2", children: /* @__PURE__ */ jsx(Spinner, { className: "size-4 text-muted-foreground" }) }), "Header")
|
|
2251
|
-
} :
|
|
2255
|
+
} : EMPTY_COMPONENTS,
|
|
2252
2256
|
increaseViewportBy: { top: 200, bottom: 400 }
|
|
2253
2257
|
}
|
|
2254
2258
|
);
|
|
2255
2259
|
}, "MessageList"));
|
|
2256
|
-
|
|
2257
|
-
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
2258
|
-
void navigator.clipboard.writeText(text);
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
__name(copy, "copy");
|
|
2260
|
+
var EMPTY_COMPONENTS = {};
|
|
2262
2261
|
function ChatRoot(props) {
|
|
2263
2262
|
const { transport, config, initialSessionId, autoCreateSession, streaming, audio, debug, className, listClassName, ...slots } = props;
|
|
2264
2263
|
return /* @__PURE__ */ jsx(
|
|
@@ -2308,7 +2307,7 @@ function ChatRootShell({ className, listClassName, slots }) {
|
|
|
2308
2307
|
toolCallsProps: slots.toolCallsProps,
|
|
2309
2308
|
attachmentRenderers: slots.attachmentRenderers,
|
|
2310
2309
|
onAttachmentOpen: slots.onAttachmentOpen,
|
|
2311
|
-
onCopy: () =>
|
|
2310
|
+
onCopy: () => copy(m.content),
|
|
2312
2311
|
onRegenerate: () => void chat.regenerate(m.id),
|
|
2313
2312
|
onDelete: () => chat.deleteMessage(m.id)
|
|
2314
2313
|
},
|
|
@@ -2362,13 +2361,13 @@ function ChatRootShell({ className, listClassName, slots }) {
|
|
|
2362
2361
|
] });
|
|
2363
2362
|
}
|
|
2364
2363
|
__name(ChatRootShell, "ChatRootShell");
|
|
2365
|
-
function
|
|
2364
|
+
function copy(text) {
|
|
2366
2365
|
if (typeof navigator !== "undefined" && navigator.clipboard) {
|
|
2367
2366
|
void navigator.clipboard.writeText(text);
|
|
2368
2367
|
}
|
|
2369
2368
|
}
|
|
2370
|
-
__name(
|
|
2369
|
+
__name(copy, "copy");
|
|
2371
2370
|
|
|
2372
2371
|
export { Attachments, AttachmentsGrid, AttachmentsList, CHAT_EVENT_NAME, CSS_VARS, ChatProvider, ChatRoot, Composer, DEFAULT_LABELS, DEFAULT_SIDEBAR, DEFAULT_Z_INDEX, EmptyState, ErrorBanner, HOTKEYS, JumpToLatest, LIMITS, MessageActions, MessageBubble, MessageList, STORAGE_KEYS, Sources, StreamingIndicator, ToolCalls, createId, createTokenBuffer, deriveInitials, getChatLogger, initialState, reducer, resolvePersona, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatLayout };
|
|
2373
|
-
//# sourceMappingURL=chunk-
|
|
2374
|
-
//# sourceMappingURL=chunk-
|
|
2372
|
+
//# sourceMappingURL=chunk-MVAT6OPZ.mjs.map
|
|
2373
|
+
//# sourceMappingURL=chunk-MVAT6OPZ.mjs.map
|