@djangocfg/ui-tools 2.1.374 → 2.1.375
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-F5XXERXU.cjs +14 -0
- package/dist/{ChatRoot-3LA3DSNY.cjs.map → ChatRoot-F5XXERXU.cjs.map} +1 -1
- package/dist/ChatRoot-T7D7QRCH.mjs +5 -0
- package/dist/{ChatRoot-RIETBE55.mjs.map → ChatRoot-T7D7QRCH.mjs.map} +1 -1
- package/dist/{chunk-PSM3DUTC.mjs → chunk-JXBEKSNT.mjs} +16 -5
- package/dist/chunk-JXBEKSNT.mjs.map +1 -0
- package/dist/{chunk-TAEHNX4W.cjs → chunk-UVIFD3TH.cjs} +15 -4
- package/dist/chunk-UVIFD3TH.cjs.map +1 -0
- package/dist/index.cjs +85 -47
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +86 -1
- package/dist/index.d.ts +86 -1
- package/dist/index.mjs +40 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/tools/Chat/Chat.story.tsx +73 -0
- package/src/tools/Chat/README.md +57 -2
- package/src/tools/Chat/components/Composer.tsx +13 -1
- package/src/tools/Chat/context/ChatProvider.tsx +27 -2
- package/src/tools/Chat/context/index.ts +1 -0
- package/src/tools/Chat/hooks/index.ts +6 -0
- package/src/tools/Chat/hooks/useAutoFocusOnStreamEnd.ts +128 -0
- package/src/tools/Chat/index.ts +4 -0
- package/dist/ChatRoot-3LA3DSNY.cjs +0 -14
- package/dist/ChatRoot-RIETBE55.mjs +0 -5
- package/dist/chunk-PSM3DUTC.mjs.map +0 -1
- package/dist/chunk-TAEHNX4W.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -7,7 +7,7 @@ var chunkKNDLV4PI_cjs = require('./chunk-KNDLV4PI.cjs');
|
|
|
7
7
|
var chunk5I5QNGUG_cjs = require('./chunk-5I5QNGUG.cjs');
|
|
8
8
|
var chunkYW5IVWHQ_cjs = require('./chunk-YW5IVWHQ.cjs');
|
|
9
9
|
var chunk76NNDZH6_cjs = require('./chunk-76NNDZH6.cjs');
|
|
10
|
-
var
|
|
10
|
+
var chunkUVIFD3TH_cjs = require('./chunk-UVIFD3TH.cjs');
|
|
11
11
|
var chunkYXZ6GU7H_cjs = require('./chunk-YXZ6GU7H.cjs');
|
|
12
12
|
var chunkFVVF7VCD_cjs = require('./chunk-FVVF7VCD.cjs');
|
|
13
13
|
var chunk7EYHNP3E_cjs = require('./chunk-7EYHNP3E.cjs');
|
|
@@ -373,7 +373,7 @@ var LazyTree = createLazyComponent(
|
|
|
373
373
|
}
|
|
374
374
|
);
|
|
375
375
|
var LazyChat = createLazyComponent(
|
|
376
|
-
() => import('./ChatRoot-
|
|
376
|
+
() => import('./ChatRoot-F5XXERXU.cjs').then((m) => ({ default: m.ChatRoot })),
|
|
377
377
|
{
|
|
378
378
|
displayName: "LazyChat",
|
|
379
379
|
fallback: /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
|
|
@@ -410,7 +410,7 @@ async function* parseSSE(response, options = {}) {
|
|
|
410
410
|
throw new Error("SSE response has no body");
|
|
411
411
|
}
|
|
412
412
|
const map = options.map ?? DEFAULT_MAP;
|
|
413
|
-
const idleMs = options.idleTimeoutMs ??
|
|
413
|
+
const idleMs = options.idleTimeoutMs ?? chunkUVIFD3TH_cjs.LIMITS.sseIdleMs;
|
|
414
414
|
const reader = response.body.getReader();
|
|
415
415
|
const decoder = new TextDecoder();
|
|
416
416
|
let buffer = "";
|
|
@@ -613,7 +613,7 @@ function createMockTransport(opts = {}) {
|
|
|
613
613
|
async createSession(_opts) {
|
|
614
614
|
await sleep(latency);
|
|
615
615
|
return {
|
|
616
|
-
sessionId:
|
|
616
|
+
sessionId: chunkUVIFD3TH_cjs.createId("s"),
|
|
617
617
|
messages: history.length ? [...history] : void 0,
|
|
618
618
|
hasMore: false,
|
|
619
619
|
cursor: null,
|
|
@@ -630,12 +630,12 @@ function createMockTransport(opts = {}) {
|
|
|
630
630
|
throw new Error("mock transport scripted failure");
|
|
631
631
|
}
|
|
632
632
|
history.push({
|
|
633
|
-
id:
|
|
633
|
+
id: chunkUVIFD3TH_cjs.createId("u"),
|
|
634
634
|
role: "user",
|
|
635
635
|
content,
|
|
636
636
|
createdAt: Date.now()
|
|
637
637
|
});
|
|
638
|
-
const messageId =
|
|
638
|
+
const messageId = chunkUVIFD3TH_cjs.createId("a");
|
|
639
639
|
yield { type: "message_start", messageId, sessionId: _sid };
|
|
640
640
|
const reply = replies[turn % replies.length];
|
|
641
641
|
turn += 1;
|
|
@@ -664,7 +664,7 @@ function createMockTransport(opts = {}) {
|
|
|
664
664
|
turn += 1;
|
|
665
665
|
const text = typeof reply === "string" ? reply : reply.filter((e) => e.type === "chunk").map((e) => e.delta).join("");
|
|
666
666
|
return {
|
|
667
|
-
id:
|
|
667
|
+
id: chunkUVIFD3TH_cjs.createId("a"),
|
|
668
668
|
role: "assistant",
|
|
669
669
|
content: text || DEFAULT_REPLY,
|
|
670
670
|
createdAt: Date.now()
|
|
@@ -818,6 +818,42 @@ function useChatLightbox() {
|
|
|
818
818
|
return { state, open, close };
|
|
819
819
|
}
|
|
820
820
|
chunkOLISEQHS_cjs.__name(useChatLightbox, "useChatLightbox");
|
|
821
|
+
function useAutoFocusOnStreamEnd(options = {}) {
|
|
822
|
+
const { isStreaming: isStreamingProp, targetRef, enabled = true, delayMs = 0 } = options;
|
|
823
|
+
const ctx = chunkUVIFD3TH_cjs.useChatContextOptional();
|
|
824
|
+
const isStreaming = isStreamingProp ?? ctx?.isStreaming ?? false;
|
|
825
|
+
const composerHandleRef = React.useRef(null);
|
|
826
|
+
composerHandleRef.current = ctx?.composer ?? null;
|
|
827
|
+
const prevStreamingRef = React.useRef(isStreaming);
|
|
828
|
+
React.useEffect(() => {
|
|
829
|
+
const wasStreaming = prevStreamingRef.current;
|
|
830
|
+
prevStreamingRef.current = isStreaming;
|
|
831
|
+
if (!enabled) return;
|
|
832
|
+
if (!(wasStreaming && !isStreaming)) return;
|
|
833
|
+
const focusNow = /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => {
|
|
834
|
+
const explicit = targetRef?.current;
|
|
835
|
+
const target = explicit ?? composerHandleRef.current;
|
|
836
|
+
target?.focus();
|
|
837
|
+
}, "focusNow");
|
|
838
|
+
if (delayMs > 0) {
|
|
839
|
+
const id = window.setTimeout(focusNow, delayMs);
|
|
840
|
+
return () => window.clearTimeout(id);
|
|
841
|
+
}
|
|
842
|
+
const raf = requestAnimationFrame(focusNow);
|
|
843
|
+
return () => cancelAnimationFrame(raf);
|
|
844
|
+
}, [isStreaming, enabled, delayMs, targetRef]);
|
|
845
|
+
}
|
|
846
|
+
chunkOLISEQHS_cjs.__name(useAutoFocusOnStreamEnd, "useAutoFocusOnStreamEnd");
|
|
847
|
+
function useRegisterComposer(focus) {
|
|
848
|
+
const ctx = chunkUVIFD3TH_cjs.useChatContextOptional();
|
|
849
|
+
const register = ctx?.registerComposer;
|
|
850
|
+
React.useEffect(() => {
|
|
851
|
+
if (!register) return;
|
|
852
|
+
register({ focus });
|
|
853
|
+
return () => register(null);
|
|
854
|
+
}, [register, focus]);
|
|
855
|
+
}
|
|
856
|
+
chunkOLISEQHS_cjs.__name(useRegisterComposer, "useRegisterComposer");
|
|
821
857
|
|
|
822
858
|
// src/tools/Chat/core/payload-dispatch.ts
|
|
823
859
|
function dispatchToolPayload(matchers, fallback) {
|
|
@@ -864,9 +900,9 @@ function AudioToggle({
|
|
|
864
900
|
alwaysShow = false,
|
|
865
901
|
className
|
|
866
902
|
}) {
|
|
867
|
-
const muted =
|
|
868
|
-
const setMuted =
|
|
869
|
-
const ctx =
|
|
903
|
+
const muted = chunkUVIFD3TH_cjs.useChatAudioPrefs((s) => s.muted);
|
|
904
|
+
const setMuted = chunkUVIFD3TH_cjs.useChatAudioPrefs((s) => s.setMuted);
|
|
905
|
+
const ctx = chunkUVIFD3TH_cjs.useChatContextOptional();
|
|
870
906
|
if (ctx && !ctx.hasAudio && !alwaysShow) return null;
|
|
871
907
|
const Icon = muted ? lucideReact.VolumeX : lucideReact.Volume2;
|
|
872
908
|
const label = muted ? "Unmute chat sounds" : "Mute chat sounds";
|
|
@@ -2180,151 +2216,151 @@ Object.defineProperty(exports, "useCronWeekDays", {
|
|
|
2180
2216
|
});
|
|
2181
2217
|
Object.defineProperty(exports, "Attachments", {
|
|
2182
2218
|
enumerable: true,
|
|
2183
|
-
get: function () { return
|
|
2219
|
+
get: function () { return chunkUVIFD3TH_cjs.Attachments; }
|
|
2184
2220
|
});
|
|
2185
2221
|
Object.defineProperty(exports, "AttachmentsGrid", {
|
|
2186
2222
|
enumerable: true,
|
|
2187
|
-
get: function () { return
|
|
2223
|
+
get: function () { return chunkUVIFD3TH_cjs.AttachmentsGrid; }
|
|
2188
2224
|
});
|
|
2189
2225
|
Object.defineProperty(exports, "AttachmentsList", {
|
|
2190
2226
|
enumerable: true,
|
|
2191
|
-
get: function () { return
|
|
2227
|
+
get: function () { return chunkUVIFD3TH_cjs.AttachmentsList; }
|
|
2192
2228
|
});
|
|
2193
2229
|
Object.defineProperty(exports, "CHAT_EVENT_NAME", {
|
|
2194
2230
|
enumerable: true,
|
|
2195
|
-
get: function () { return
|
|
2231
|
+
get: function () { return chunkUVIFD3TH_cjs.CHAT_EVENT_NAME; }
|
|
2196
2232
|
});
|
|
2197
2233
|
Object.defineProperty(exports, "CSS_VARS", {
|
|
2198
2234
|
enumerable: true,
|
|
2199
|
-
get: function () { return
|
|
2235
|
+
get: function () { return chunkUVIFD3TH_cjs.CSS_VARS; }
|
|
2200
2236
|
});
|
|
2201
2237
|
Object.defineProperty(exports, "ChatProvider", {
|
|
2202
2238
|
enumerable: true,
|
|
2203
|
-
get: function () { return
|
|
2239
|
+
get: function () { return chunkUVIFD3TH_cjs.ChatProvider; }
|
|
2204
2240
|
});
|
|
2205
2241
|
Object.defineProperty(exports, "ChatRoot", {
|
|
2206
2242
|
enumerable: true,
|
|
2207
|
-
get: function () { return
|
|
2243
|
+
get: function () { return chunkUVIFD3TH_cjs.ChatRoot; }
|
|
2208
2244
|
});
|
|
2209
2245
|
Object.defineProperty(exports, "Composer", {
|
|
2210
2246
|
enumerable: true,
|
|
2211
|
-
get: function () { return
|
|
2247
|
+
get: function () { return chunkUVIFD3TH_cjs.Composer; }
|
|
2212
2248
|
});
|
|
2213
2249
|
Object.defineProperty(exports, "DEFAULT_LABELS", {
|
|
2214
2250
|
enumerable: true,
|
|
2215
|
-
get: function () { return
|
|
2251
|
+
get: function () { return chunkUVIFD3TH_cjs.DEFAULT_LABELS; }
|
|
2216
2252
|
});
|
|
2217
2253
|
Object.defineProperty(exports, "DEFAULT_SIDEBAR", {
|
|
2218
2254
|
enumerable: true,
|
|
2219
|
-
get: function () { return
|
|
2255
|
+
get: function () { return chunkUVIFD3TH_cjs.DEFAULT_SIDEBAR; }
|
|
2220
2256
|
});
|
|
2221
2257
|
Object.defineProperty(exports, "DEFAULT_Z_INDEX", {
|
|
2222
2258
|
enumerable: true,
|
|
2223
|
-
get: function () { return
|
|
2259
|
+
get: function () { return chunkUVIFD3TH_cjs.DEFAULT_Z_INDEX; }
|
|
2224
2260
|
});
|
|
2225
2261
|
Object.defineProperty(exports, "EmptyState", {
|
|
2226
2262
|
enumerable: true,
|
|
2227
|
-
get: function () { return
|
|
2263
|
+
get: function () { return chunkUVIFD3TH_cjs.EmptyState; }
|
|
2228
2264
|
});
|
|
2229
2265
|
Object.defineProperty(exports, "ErrorBanner", {
|
|
2230
2266
|
enumerable: true,
|
|
2231
|
-
get: function () { return
|
|
2267
|
+
get: function () { return chunkUVIFD3TH_cjs.ErrorBanner; }
|
|
2232
2268
|
});
|
|
2233
2269
|
Object.defineProperty(exports, "HOTKEYS", {
|
|
2234
2270
|
enumerable: true,
|
|
2235
|
-
get: function () { return
|
|
2271
|
+
get: function () { return chunkUVIFD3TH_cjs.HOTKEYS; }
|
|
2236
2272
|
});
|
|
2237
2273
|
Object.defineProperty(exports, "JumpToLatest", {
|
|
2238
2274
|
enumerable: true,
|
|
2239
|
-
get: function () { return
|
|
2275
|
+
get: function () { return chunkUVIFD3TH_cjs.JumpToLatest; }
|
|
2240
2276
|
});
|
|
2241
2277
|
Object.defineProperty(exports, "LIMITS", {
|
|
2242
2278
|
enumerable: true,
|
|
2243
|
-
get: function () { return
|
|
2279
|
+
get: function () { return chunkUVIFD3TH_cjs.LIMITS; }
|
|
2244
2280
|
});
|
|
2245
2281
|
Object.defineProperty(exports, "MessageActions", {
|
|
2246
2282
|
enumerable: true,
|
|
2247
|
-
get: function () { return
|
|
2283
|
+
get: function () { return chunkUVIFD3TH_cjs.MessageActions; }
|
|
2248
2284
|
});
|
|
2249
2285
|
Object.defineProperty(exports, "MessageBubble", {
|
|
2250
2286
|
enumerable: true,
|
|
2251
|
-
get: function () { return
|
|
2287
|
+
get: function () { return chunkUVIFD3TH_cjs.MessageBubble; }
|
|
2252
2288
|
});
|
|
2253
2289
|
Object.defineProperty(exports, "MessageList", {
|
|
2254
2290
|
enumerable: true,
|
|
2255
|
-
get: function () { return
|
|
2291
|
+
get: function () { return chunkUVIFD3TH_cjs.MessageList; }
|
|
2256
2292
|
});
|
|
2257
2293
|
Object.defineProperty(exports, "STORAGE_KEYS", {
|
|
2258
2294
|
enumerable: true,
|
|
2259
|
-
get: function () { return
|
|
2295
|
+
get: function () { return chunkUVIFD3TH_cjs.STORAGE_KEYS; }
|
|
2260
2296
|
});
|
|
2261
2297
|
Object.defineProperty(exports, "Sources", {
|
|
2262
2298
|
enumerable: true,
|
|
2263
|
-
get: function () { return
|
|
2299
|
+
get: function () { return chunkUVIFD3TH_cjs.Sources; }
|
|
2264
2300
|
});
|
|
2265
2301
|
Object.defineProperty(exports, "StreamingIndicator", {
|
|
2266
2302
|
enumerable: true,
|
|
2267
|
-
get: function () { return
|
|
2303
|
+
get: function () { return chunkUVIFD3TH_cjs.StreamingIndicator; }
|
|
2268
2304
|
});
|
|
2269
2305
|
Object.defineProperty(exports, "ToolCalls", {
|
|
2270
2306
|
enumerable: true,
|
|
2271
|
-
get: function () { return
|
|
2307
|
+
get: function () { return chunkUVIFD3TH_cjs.ToolCalls; }
|
|
2272
2308
|
});
|
|
2273
2309
|
Object.defineProperty(exports, "createId", {
|
|
2274
2310
|
enumerable: true,
|
|
2275
|
-
get: function () { return
|
|
2311
|
+
get: function () { return chunkUVIFD3TH_cjs.createId; }
|
|
2276
2312
|
});
|
|
2277
2313
|
Object.defineProperty(exports, "createTokenBuffer", {
|
|
2278
2314
|
enumerable: true,
|
|
2279
|
-
get: function () { return
|
|
2315
|
+
get: function () { return chunkUVIFD3TH_cjs.createTokenBuffer; }
|
|
2280
2316
|
});
|
|
2281
2317
|
Object.defineProperty(exports, "deriveInitials", {
|
|
2282
2318
|
enumerable: true,
|
|
2283
|
-
get: function () { return
|
|
2319
|
+
get: function () { return chunkUVIFD3TH_cjs.deriveInitials; }
|
|
2284
2320
|
});
|
|
2285
2321
|
Object.defineProperty(exports, "getChatLogger", {
|
|
2286
2322
|
enumerable: true,
|
|
2287
|
-
get: function () { return
|
|
2323
|
+
get: function () { return chunkUVIFD3TH_cjs.getChatLogger; }
|
|
2288
2324
|
});
|
|
2289
2325
|
Object.defineProperty(exports, "initialState", {
|
|
2290
2326
|
enumerable: true,
|
|
2291
|
-
get: function () { return
|
|
2327
|
+
get: function () { return chunkUVIFD3TH_cjs.initialState; }
|
|
2292
2328
|
});
|
|
2293
2329
|
Object.defineProperty(exports, "reducer", {
|
|
2294
2330
|
enumerable: true,
|
|
2295
|
-
get: function () { return
|
|
2331
|
+
get: function () { return chunkUVIFD3TH_cjs.reducer; }
|
|
2296
2332
|
});
|
|
2297
2333
|
Object.defineProperty(exports, "resolvePersona", {
|
|
2298
2334
|
enumerable: true,
|
|
2299
|
-
get: function () { return
|
|
2335
|
+
get: function () { return chunkUVIFD3TH_cjs.resolvePersona; }
|
|
2300
2336
|
});
|
|
2301
2337
|
Object.defineProperty(exports, "useChat", {
|
|
2302
2338
|
enumerable: true,
|
|
2303
|
-
get: function () { return
|
|
2339
|
+
get: function () { return chunkUVIFD3TH_cjs.useChat; }
|
|
2304
2340
|
});
|
|
2305
2341
|
Object.defineProperty(exports, "useChatAudio", {
|
|
2306
2342
|
enumerable: true,
|
|
2307
|
-
get: function () { return
|
|
2343
|
+
get: function () { return chunkUVIFD3TH_cjs.useChatAudio; }
|
|
2308
2344
|
});
|
|
2309
2345
|
Object.defineProperty(exports, "useChatAudioPrefs", {
|
|
2310
2346
|
enumerable: true,
|
|
2311
|
-
get: function () { return
|
|
2347
|
+
get: function () { return chunkUVIFD3TH_cjs.useChatAudioPrefs; }
|
|
2312
2348
|
});
|
|
2313
2349
|
Object.defineProperty(exports, "useChatComposer", {
|
|
2314
2350
|
enumerable: true,
|
|
2315
|
-
get: function () { return
|
|
2351
|
+
get: function () { return chunkUVIFD3TH_cjs.useChatComposer; }
|
|
2316
2352
|
});
|
|
2317
2353
|
Object.defineProperty(exports, "useChatContext", {
|
|
2318
2354
|
enumerable: true,
|
|
2319
|
-
get: function () { return
|
|
2355
|
+
get: function () { return chunkUVIFD3TH_cjs.useChatContext; }
|
|
2320
2356
|
});
|
|
2321
2357
|
Object.defineProperty(exports, "useChatContextOptional", {
|
|
2322
2358
|
enumerable: true,
|
|
2323
|
-
get: function () { return
|
|
2359
|
+
get: function () { return chunkUVIFD3TH_cjs.useChatContextOptional; }
|
|
2324
2360
|
});
|
|
2325
2361
|
Object.defineProperty(exports, "useChatLayout", {
|
|
2326
2362
|
enumerable: true,
|
|
2327
|
-
get: function () { return
|
|
2363
|
+
get: function () { return chunkUVIFD3TH_cjs.useChatLayout; }
|
|
2328
2364
|
});
|
|
2329
2365
|
Object.defineProperty(exports, "TreeError", {
|
|
2330
2366
|
enumerable: true,
|
|
@@ -2525,6 +2561,7 @@ exports.isPlainObject = isPlainObject;
|
|
|
2525
2561
|
exports.isStringValue = isStringValue;
|
|
2526
2562
|
exports.mentionPresets = mentionPresets;
|
|
2527
2563
|
exports.parseSSE = parseSSE;
|
|
2564
|
+
exports.useAutoFocusOnStreamEnd = useAutoFocusOnStreamEnd;
|
|
2528
2565
|
exports.useChatHistory = useChatHistory;
|
|
2529
2566
|
exports.useChatLightbox = useChatLightbox;
|
|
2530
2567
|
exports.useChatScroll = useChatScroll;
|
|
@@ -2532,5 +2569,6 @@ exports.useEditor = useEditor;
|
|
|
2532
2569
|
exports.useEditorContext = useEditorContext;
|
|
2533
2570
|
exports.useLanguage = useLanguage;
|
|
2534
2571
|
exports.useMonaco = useMonaco;
|
|
2572
|
+
exports.useRegisterComposer = useRegisterComposer;
|
|
2535
2573
|
//# sourceMappingURL=index.cjs.map
|
|
2536
2574
|
//# sourceMappingURL=index.cjs.map
|