@djangocfg/ui-tools 2.1.369 → 2.1.372

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.
@@ -0,0 +1,5 @@
1
+ export { ChatRoot } from './chunk-KSBMKHYY.mjs';
2
+ import './chunk-NWUT327A.mjs';
3
+ import './chunk-N2XQF2OL.mjs';
4
+ //# sourceMappingURL=ChatRoot-2WNYE2V5.mjs.map
5
+ //# sourceMappingURL=ChatRoot-2WNYE2V5.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-DENECC2Q.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-2WNYE2V5.mjs"}
@@ -0,0 +1,14 @@
1
+ 'use strict';
2
+
3
+ var chunkA6DDYQQV_cjs = require('./chunk-A6DDYQQV.cjs');
4
+ require('./chunk-XACCHZH2.cjs');
5
+ require('./chunk-OLISEQHS.cjs');
6
+
7
+
8
+
9
+ Object.defineProperty(exports, "ChatRoot", {
10
+ enumerable: true,
11
+ get: function () { return chunkA6DDYQQV_cjs.ChatRoot; }
12
+ });
13
+ //# sourceMappingURL=ChatRoot-AD2JIUIU.cjs.map
14
+ //# sourceMappingURL=ChatRoot-AD2JIUIU.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-PW6U3QVF.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-AD2JIUIU.cjs"}
@@ -2156,7 +2156,9 @@ var MessageList = react.forwardRef(/* @__PURE__ */ chunkOLISEQHS_cjs.__name(func
2156
2156
  const ctx = useChatContextOptional();
2157
2157
  const messages = messagesProp ?? ctx?.messages ?? [];
2158
2158
  const isLoadingMore = isLoadingMoreProp ?? ctx?.isLoadingMore ?? false;
2159
+ const { copyToClipboard } = hooks.useCopy();
2159
2160
  const virtuosoRef = react.useRef(null);
2161
+ const didInitialScrollRef = react.useRef(false);
2160
2162
  react.useImperativeHandle(
2161
2163
  ref,
2162
2164
  () => ({
@@ -2181,15 +2183,31 @@ var MessageList = react.forwardRef(/* @__PURE__ */ chunkOLISEQHS_cjs.__name(func
2181
2183
  MessageBubble,
2182
2184
  {
2183
2185
  message: m,
2184
- onCopy: () => copy(m.content),
2186
+ onCopy: () => void copyToClipboard(m.content),
2185
2187
  onRegenerate: ctx ? () => void ctx.regenerate(m.id) : void 0,
2186
2188
  onDelete: ctx ? () => ctx.deleteMessage(m.id) : void 0
2187
2189
  }
2188
2190
  ) }),
2189
- [itemClassName, ctx]
2191
+ [itemClassName, ctx, copyToClipboard]
2190
2192
  );
2191
2193
  const itemRenderer = renderItem ?? defaultRenderItem;
2192
- const computeItemKey = react.useCallback((index, m) => m.id ?? index, []);
2194
+ react.useEffect(() => {
2195
+ if (didInitialScrollRef.current) return;
2196
+ if (messages.length === 0) return;
2197
+ didInitialScrollRef.current = true;
2198
+ const id = requestAnimationFrame(() => {
2199
+ virtuosoRef.current?.scrollToIndex({
2200
+ index: "LAST",
2201
+ align: "end",
2202
+ behavior: "auto"
2203
+ });
2204
+ });
2205
+ return () => cancelAnimationFrame(id);
2206
+ }, [messages.length]);
2207
+ const computeItemKey = react.useCallback(
2208
+ (index, m) => m?.id ?? index,
2209
+ []
2210
+ );
2193
2211
  const startReachedHandler = react.useMemo(() => {
2194
2212
  if (!onStartReached) return void 0;
2195
2213
  let inFlight = false;
@@ -2242,25 +2260,21 @@ var MessageList = react.forwardRef(/* @__PURE__ */ chunkOLISEQHS_cjs.__name(func
2242
2260
  className: lib.cn("flex-1", className),
2243
2261
  data: messages,
2244
2262
  computeItemKey,
2245
- itemContent: (index, m) => itemRenderer(m, index),
2263
+ itemContent: (index, m) => m ? itemRenderer(m, index) : null,
2246
2264
  defaultItemHeight,
2265
+ initialTopMostItemIndex: messages.length > 0 ? messages.length - 1 : 0,
2247
2266
  followOutput: (isAtBottom) => isAtBottom ? "auto" : false,
2248
2267
  atBottomStateChange: onAtBottomChange,
2249
2268
  alignToBottom: true,
2250
2269
  startReached: startReachedHandler,
2251
2270
  components: isLoadingMore ? {
2252
2271
  Header: /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-2", children: /* @__PURE__ */ jsxRuntime.jsx(components.Spinner, { className: "size-4 text-muted-foreground" }) }), "Header")
2253
- } : void 0,
2272
+ } : EMPTY_COMPONENTS,
2254
2273
  increaseViewportBy: { top: 200, bottom: 400 }
2255
2274
  }
2256
2275
  );
2257
2276
  }, "MessageList"));
2258
- function copy(text) {
2259
- if (typeof navigator !== "undefined" && navigator.clipboard) {
2260
- void navigator.clipboard.writeText(text);
2261
- }
2262
- }
2263
- chunkOLISEQHS_cjs.__name(copy, "copy");
2277
+ var EMPTY_COMPONENTS = {};
2264
2278
  function ChatRoot(props) {
2265
2279
  const { transport, config, initialSessionId, autoCreateSession, streaming, audio, debug, className, listClassName, ...slots } = props;
2266
2280
  return /* @__PURE__ */ jsxRuntime.jsx(
@@ -2310,7 +2324,7 @@ function ChatRootShell({ className, listClassName, slots }) {
2310
2324
  toolCallsProps: slots.toolCallsProps,
2311
2325
  attachmentRenderers: slots.attachmentRenderers,
2312
2326
  onAttachmentOpen: slots.onAttachmentOpen,
2313
- onCopy: () => copy2(m.content),
2327
+ onCopy: () => copy(m.content),
2314
2328
  onRegenerate: () => void chat.regenerate(m.id),
2315
2329
  onDelete: () => chat.deleteMessage(m.id)
2316
2330
  },
@@ -2364,12 +2378,12 @@ function ChatRootShell({ className, listClassName, slots }) {
2364
2378
  ] });
2365
2379
  }
2366
2380
  chunkOLISEQHS_cjs.__name(ChatRootShell, "ChatRootShell");
2367
- function copy2(text) {
2381
+ function copy(text) {
2368
2382
  if (typeof navigator !== "undefined" && navigator.clipboard) {
2369
2383
  void navigator.clipboard.writeText(text);
2370
2384
  }
2371
2385
  }
2372
- chunkOLISEQHS_cjs.__name(copy2, "copy");
2386
+ chunkOLISEQHS_cjs.__name(copy, "copy");
2373
2387
 
2374
2388
  exports.Attachments = Attachments;
2375
2389
  exports.AttachmentsGrid = AttachmentsGrid;
@@ -2408,5 +2422,5 @@ exports.useChatComposer = useChatComposer;
2408
2422
  exports.useChatContext = useChatContext;
2409
2423
  exports.useChatContextOptional = useChatContextOptional;
2410
2424
  exports.useChatLayout = useChatLayout;
2411
- //# sourceMappingURL=chunk-OD3P64QD.cjs.map
2412
- //# sourceMappingURL=chunk-OD3P64QD.cjs.map
2425
+ //# sourceMappingURL=chunk-A6DDYQQV.cjs.map
2426
+ //# sourceMappingURL=chunk-A6DDYQQV.cjs.map