@djangocfg/ui-tools 2.1.376 → 2.1.378

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,14 @@
1
+ 'use strict';
2
+
3
+ var chunkSI5RD2GD_cjs = require('./chunk-SI5RD2GD.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 chunkSI5RD2GD_cjs.ChatRoot; }
12
+ });
13
+ //# sourceMappingURL=ChatRoot-EJC5Y2YM.cjs.map
14
+ //# sourceMappingURL=ChatRoot-EJC5Y2YM.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-F5XXERXU.cjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-EJC5Y2YM.cjs"}
@@ -0,0 +1,5 @@
1
+ export { ChatRoot } from './chunk-QLMKCSR6.mjs';
2
+ import './chunk-NWUT327A.mjs';
3
+ import './chunk-N2XQF2OL.mjs';
4
+ //# sourceMappingURL=ChatRoot-QOSKJPM6.mjs.map
5
+ //# sourceMappingURL=ChatRoot-QOSKJPM6.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-T7D7QRCH.mjs"}
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-QOSKJPM6.mjs"}
@@ -1282,6 +1282,22 @@ function useChatContextOptional() {
1282
1282
  return useContext(Ctx);
1283
1283
  }
1284
1284
  __name(useChatContextOptional, "useChatContextOptional");
1285
+
1286
+ // src/tools/Chat/utils/sanitizeDraft.ts
1287
+ function sanitizeDraft(input) {
1288
+ if (!input) return "";
1289
+ let s = input.replace(/[​‌‍]/g, "");
1290
+ s = s.replace(/\r\n?/g, "\n");
1291
+ s = s.trim();
1292
+ return s;
1293
+ }
1294
+ __name(sanitizeDraft, "sanitizeDraft");
1295
+ function isSubmittableDraft(input) {
1296
+ return sanitizeDraft(input).length > 0;
1297
+ }
1298
+ __name(isSubmittableDraft, "isSubmittableDraft");
1299
+
1300
+ // src/tools/Chat/hooks/useChatComposer.ts
1285
1301
  var MAX_TEXTAREA_HEIGHT = 240;
1286
1302
  function useChatComposer(options) {
1287
1303
  const {
@@ -1293,7 +1309,8 @@ function useChatComposer(options) {
1293
1309
  submitOn = "enter",
1294
1310
  history = { enabled: true, size: LIMITS.composerHistorySize },
1295
1311
  onPasteFiles,
1296
- persistKey
1312
+ persistKey,
1313
+ preserveExactValue = false
1297
1314
  } = options;
1298
1315
  const initialFromStorage = (() => {
1299
1316
  if (!persistKey || typeof window === "undefined") return initialValue;
@@ -1339,26 +1356,25 @@ function useChatComposer(options) {
1339
1356
  requestAnimationFrame(() => textareaRef.current?.focus());
1340
1357
  }, []);
1341
1358
  const submit = useCallback(async () => {
1342
- const trimmed = value.trim();
1343
- if (!trimmed && attachments.length === 0 || isSubmitting || disabled) return;
1359
+ const cleaned = preserveExactValue ? value : sanitizeDraft(value);
1360
+ if (!cleaned && attachments.length === 0 || isSubmitting || disabled) return;
1344
1361
  setIsSubmitting(true);
1345
1362
  try {
1346
- if (history.enabled !== false && trimmed) {
1363
+ if (history.enabled !== false && cleaned) {
1347
1364
  const buf = historyRef.current.items;
1348
- if (buf[buf.length - 1] !== trimmed) {
1349
- buf.push(trimmed);
1365
+ if (buf[buf.length - 1] !== cleaned) {
1366
+ buf.push(cleaned);
1350
1367
  if (buf.length > (history.size ?? LIMITS.composerHistorySize)) buf.shift();
1351
1368
  }
1352
1369
  historyRef.current.index = -1;
1353
1370
  }
1354
1371
  const snapshot = [...attachments];
1355
- const text = value;
1356
1372
  reset();
1357
- await onSubmit(text, snapshot);
1373
+ await onSubmit(cleaned, snapshot);
1358
1374
  } finally {
1359
1375
  setIsSubmitting(false);
1360
1376
  }
1361
- }, [value, attachments, isSubmitting, disabled, history, onSubmit, reset]);
1377
+ }, [value, attachments, isSubmitting, disabled, history, onSubmit, reset, preserveExactValue]);
1362
1378
  const addAttachment = useCallback(
1363
1379
  (a) => {
1364
1380
  setAttachments((prev) => {
@@ -1432,7 +1448,7 @@ function useChatComposer(options) {
1432
1448
  },
1433
1449
  [onPasteFiles]
1434
1450
  );
1435
- const canSubmit = !disabled && !isSubmitting && (value.trim().length > 0 || attachments.length > 0);
1451
+ const canSubmit = !disabled && !isSubmitting && ((preserveExactValue ? value.trim().length : sanitizeDraft(value).length) > 0 || attachments.length > 0);
1436
1452
  return {
1437
1453
  value,
1438
1454
  setValue,
@@ -1872,22 +1888,30 @@ function ToolCalls({
1872
1888
  renderOutput,
1873
1889
  renderStreaming,
1874
1890
  renderPayload,
1891
+ renderAfterCalls,
1892
+ renderToolCall,
1893
+ hideToolCalls = false,
1875
1894
  className
1876
1895
  }) {
1877
1896
  if (!calls?.length) return null;
1878
- return /* @__PURE__ */ jsx("div", { className: cn("mt-2 space-y-1.5", className), children: calls.map((call) => /* @__PURE__ */ jsx(
1879
- ToolCallItem,
1880
- {
1881
- call,
1882
- defaultExpanded,
1883
- expandWhileStreaming,
1884
- renderInput,
1885
- renderOutput,
1886
- renderStreaming,
1887
- renderPayload
1888
- },
1889
- call.id
1890
- )) });
1897
+ return /* @__PURE__ */ jsxs("div", { className: cn("mt-2 space-y-1.5", className), children: [
1898
+ !hideToolCalls && calls.map(
1899
+ (call) => renderToolCall ? /* @__PURE__ */ jsx("div", { children: renderToolCall(call) }, call.id) : /* @__PURE__ */ jsx(
1900
+ ToolCallItem,
1901
+ {
1902
+ call,
1903
+ defaultExpanded,
1904
+ expandWhileStreaming,
1905
+ renderInput,
1906
+ renderOutput,
1907
+ renderStreaming,
1908
+ renderPayload
1909
+ },
1910
+ call.id
1911
+ )
1912
+ ),
1913
+ renderAfterCalls ? renderAfterCalls(calls) : null
1914
+ ] });
1891
1915
  }
1892
1916
  __name(ToolCalls, "ToolCalls");
1893
1917
  function ToolCallItem({
@@ -2391,6 +2415,6 @@ function copy(text) {
2391
2415
  }
2392
2416
  __name(copy, "copy");
2393
2417
 
2394
- 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 };
2395
- //# sourceMappingURL=chunk-JXBEKSNT.mjs.map
2396
- //# sourceMappingURL=chunk-JXBEKSNT.mjs.map
2418
+ 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, isSubmittableDraft, reducer, resolvePersona, sanitizeDraft, useChat, useChatAudio, useChatAudioPrefs, useChatComposer, useChatContext, useChatContextOptional, useChatLayout };
2419
+ //# sourceMappingURL=chunk-QLMKCSR6.mjs.map
2420
+ //# sourceMappingURL=chunk-QLMKCSR6.mjs.map