@djangocfg/ui-tools 2.1.375 → 2.1.377
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-AWNBBBH7.cjs +14 -0
- package/dist/{ChatRoot-F5XXERXU.cjs.map → ChatRoot-AWNBBBH7.cjs.map} +1 -1
- package/dist/ChatRoot-VJKOAVPQ.mjs +5 -0
- package/dist/{ChatRoot-T7D7QRCH.mjs.map → ChatRoot-VJKOAVPQ.mjs.map} +1 -1
- package/dist/{chunk-JXBEKSNT.mjs → chunk-BDWVCSM5.mjs} +29 -13
- package/dist/chunk-BDWVCSM5.mjs.map +1 -0
- package/dist/{chunk-UVIFD3TH.cjs → chunk-TUZZROQU.cjs} +30 -12
- package/dist/chunk-TUZZROQU.cjs.map +1 -0
- package/dist/index.cjs +102 -51
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +83 -2
- package/dist/index.d.ts +83 -2
- package/dist/index.mjs +48 -5
- package/dist/index.mjs.map +1 -1
- package/package.json +6 -6
- package/src/tools/Chat/README.md +51 -0
- package/src/tools/Chat/hooks/useChatComposer.ts +41 -9
- package/src/tools/Chat/index.ts +5 -0
- package/src/tools/Chat/utils/sanitizeDraft.ts +72 -0
- package/src/tools/MarkdownEditor/MarkdownEditor.tsx +40 -0
- package/src/tools/MarkdownEditor/README.md +34 -0
- package/src/tools/MarkdownEditor/submitOnEnter.ts +67 -0
- package/dist/ChatRoot-F5XXERXU.cjs +0 -14
- package/dist/ChatRoot-T7D7QRCH.mjs +0 -5
- package/dist/chunk-JXBEKSNT.mjs.map +0 -1
- package/dist/chunk-UVIFD3TH.cjs.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkTUZZROQU_cjs = require('./chunk-TUZZROQU.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 chunkTUZZROQU_cjs.ChatRoot; }
|
|
12
|
+
});
|
|
13
|
+
//# sourceMappingURL=ChatRoot-AWNBBBH7.cjs.map
|
|
14
|
+
//# sourceMappingURL=ChatRoot-AWNBBBH7.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-AWNBBBH7.cjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"ChatRoot-VJKOAVPQ.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
|
|
1343
|
-
if (!
|
|
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 &&
|
|
1363
|
+
if (history.enabled !== false && cleaned) {
|
|
1347
1364
|
const buf = historyRef.current.items;
|
|
1348
|
-
if (buf[buf.length - 1] !==
|
|
1349
|
-
buf.push(
|
|
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(
|
|
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,
|
|
@@ -2391,6 +2407,6 @@ function copy(text) {
|
|
|
2391
2407
|
}
|
|
2392
2408
|
__name(copy, "copy");
|
|
2393
2409
|
|
|
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-
|
|
2396
|
-
//# sourceMappingURL=chunk-
|
|
2410
|
+
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 };
|
|
2411
|
+
//# sourceMappingURL=chunk-BDWVCSM5.mjs.map
|
|
2412
|
+
//# sourceMappingURL=chunk-BDWVCSM5.mjs.map
|