@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.
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 chunkUVIFD3TH_cjs = require('./chunk-UVIFD3TH.cjs');
10
+ var chunkSI5RD2GD_cjs = require('./chunk-SI5RD2GD.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');
@@ -28,6 +28,7 @@ var Placeholder = require('@tiptap/extension-placeholder');
28
28
  var Mention = require('@tiptap/extension-mention');
29
29
  var markdown = require('@tiptap/markdown');
30
30
  var dom = require('@floating-ui/dom');
31
+ var core = require('@tiptap/core');
31
32
 
32
33
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
33
34
 
@@ -373,7 +374,7 @@ var LazyTree = createLazyComponent(
373
374
  }
374
375
  );
375
376
  var LazyChat = createLazyComponent(
376
- () => import('./ChatRoot-F5XXERXU.cjs').then((m) => ({ default: m.ChatRoot })),
377
+ () => import('./ChatRoot-EJC5Y2YM.cjs').then((m) => ({ default: m.ChatRoot })),
377
378
  {
378
379
  displayName: "LazyChat",
379
380
  fallback: /* @__PURE__ */ jsxRuntime.jsx(LoadingFallback, { minHeight: 320, text: "Loading chat\u2026" })
@@ -410,7 +411,7 @@ async function* parseSSE(response, options = {}) {
410
411
  throw new Error("SSE response has no body");
411
412
  }
412
413
  const map = options.map ?? DEFAULT_MAP;
413
- const idleMs = options.idleTimeoutMs ?? chunkUVIFD3TH_cjs.LIMITS.sseIdleMs;
414
+ const idleMs = options.idleTimeoutMs ?? chunkSI5RD2GD_cjs.LIMITS.sseIdleMs;
414
415
  const reader = response.body.getReader();
415
416
  const decoder = new TextDecoder();
416
417
  let buffer = "";
@@ -613,7 +614,7 @@ function createMockTransport(opts = {}) {
613
614
  async createSession(_opts) {
614
615
  await sleep(latency);
615
616
  return {
616
- sessionId: chunkUVIFD3TH_cjs.createId("s"),
617
+ sessionId: chunkSI5RD2GD_cjs.createId("s"),
617
618
  messages: history.length ? [...history] : void 0,
618
619
  hasMore: false,
619
620
  cursor: null,
@@ -630,12 +631,12 @@ function createMockTransport(opts = {}) {
630
631
  throw new Error("mock transport scripted failure");
631
632
  }
632
633
  history.push({
633
- id: chunkUVIFD3TH_cjs.createId("u"),
634
+ id: chunkSI5RD2GD_cjs.createId("u"),
634
635
  role: "user",
635
636
  content,
636
637
  createdAt: Date.now()
637
638
  });
638
- const messageId = chunkUVIFD3TH_cjs.createId("a");
639
+ const messageId = chunkSI5RD2GD_cjs.createId("a");
639
640
  yield { type: "message_start", messageId, sessionId: _sid };
640
641
  const reply = replies[turn % replies.length];
641
642
  turn += 1;
@@ -664,7 +665,7 @@ function createMockTransport(opts = {}) {
664
665
  turn += 1;
665
666
  const text = typeof reply === "string" ? reply : reply.filter((e) => e.type === "chunk").map((e) => e.delta).join("");
666
667
  return {
667
- id: chunkUVIFD3TH_cjs.createId("a"),
668
+ id: chunkSI5RD2GD_cjs.createId("a"),
668
669
  role: "assistant",
669
670
  content: text || DEFAULT_REPLY,
670
671
  createdAt: Date.now()
@@ -820,7 +821,7 @@ function useChatLightbox() {
820
821
  chunkOLISEQHS_cjs.__name(useChatLightbox, "useChatLightbox");
821
822
  function useAutoFocusOnStreamEnd(options = {}) {
822
823
  const { isStreaming: isStreamingProp, targetRef, enabled = true, delayMs = 0 } = options;
823
- const ctx = chunkUVIFD3TH_cjs.useChatContextOptional();
824
+ const ctx = chunkSI5RD2GD_cjs.useChatContextOptional();
824
825
  const isStreaming = isStreamingProp ?? ctx?.isStreaming ?? false;
825
826
  const composerHandleRef = React.useRef(null);
826
827
  composerHandleRef.current = ctx?.composer ?? null;
@@ -845,7 +846,7 @@ function useAutoFocusOnStreamEnd(options = {}) {
845
846
  }
846
847
  chunkOLISEQHS_cjs.__name(useAutoFocusOnStreamEnd, "useAutoFocusOnStreamEnd");
847
848
  function useRegisterComposer(focus) {
848
- const ctx = chunkUVIFD3TH_cjs.useChatContextOptional();
849
+ const ctx = chunkSI5RD2GD_cjs.useChatContextOptional();
849
850
  const register = ctx?.registerComposer;
850
851
  React.useEffect(() => {
851
852
  if (!register) return;
@@ -900,9 +901,9 @@ function AudioToggle({
900
901
  alwaysShow = false,
901
902
  className
902
903
  }) {
903
- const muted = chunkUVIFD3TH_cjs.useChatAudioPrefs((s) => s.muted);
904
- const setMuted = chunkUVIFD3TH_cjs.useChatAudioPrefs((s) => s.setMuted);
905
- const ctx = chunkUVIFD3TH_cjs.useChatContextOptional();
904
+ const muted = chunkSI5RD2GD_cjs.useChatAudioPrefs((s) => s.muted);
905
+ const setMuted = chunkSI5RD2GD_cjs.useChatAudioPrefs((s) => s.setMuted);
906
+ const ctx = chunkSI5RD2GD_cjs.useChatContextOptional();
906
907
  if (ctx && !ctx.hasAudio && !alwaysShow) return null;
907
908
  const Icon = muted ? lucideReact.VolumeX : lucideReact.Volume2;
908
909
  const label = muted ? "Unmute chat sounds" : "Mute chat sounds";
@@ -1830,6 +1831,33 @@ var mentionPresets = {
1830
1831
  /** Inline HTML span — for products that consume markdown with raw HTML allowed. */
1831
1832
  htmlSpan: /* @__PURE__ */ chunkOLISEQHS_cjs.__name((className = "mention") => ({ label, id }) => `<span class="${className}" data-mention-id="${encodeURIComponent(id)}">@${escapeMd(label || id)}</span>`, "htmlSpan")
1832
1833
  };
1834
+ var SubmitOnEnter = core.Extension.create({
1835
+ name: "submitOnEnter",
1836
+ addOptions() {
1837
+ return {
1838
+ // Default no-op — explicit consumer must override. We never
1839
+ // intercept Enter unless an onSubmit is wired, so leaving the
1840
+ // extension installed with no handler is safe.
1841
+ onSubmit: /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => false, "onSubmit")
1842
+ };
1843
+ },
1844
+ addKeyboardShortcuts() {
1845
+ return {
1846
+ Enter: /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => {
1847
+ if (typeof document !== "undefined" && document.querySelector(".markdown-mention-list")) {
1848
+ return false;
1849
+ }
1850
+ const result = this.options.onSubmit();
1851
+ return result !== false;
1852
+ }, "Enter"),
1853
+ // Shift+Enter — always insert a newline. Tiptap's StarterKit
1854
+ // already binds this to HardBreak; we re-bind to `false` (not
1855
+ // handled) so the chain falls through cleanly even if other
1856
+ // extensions try to grab Shift+Enter.
1857
+ "Shift-Enter": /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => false, "Shift-Enter")
1858
+ };
1859
+ }
1860
+ });
1833
1861
  function getMarkdown(editor) {
1834
1862
  const storage = editor.storage.markdown;
1835
1863
  if (!storage?.manager) return editor.getText();
@@ -1855,8 +1883,11 @@ function MarkdownEditor({
1855
1883
  disabled = false,
1856
1884
  showToolbar = true,
1857
1885
  mentions,
1858
- onMentionIdsChange
1886
+ onMentionIdsChange,
1887
+ onSubmit
1859
1888
  }) {
1889
+ const onSubmitRef = React.useRef(onSubmit);
1890
+ onSubmitRef.current = onSubmit;
1860
1891
  const isExternalUpdate = React.useRef(false);
1861
1892
  const initialMentionsDefinedRef = React.useRef(mentions !== void 0);
1862
1893
  const warnedRef = React.useRef(false);
@@ -1870,7 +1901,19 @@ function MarkdownEditor({
1870
1901
  const exts = [
1871
1902
  StarterKit__default.default.configure({ heading: { levels: [1, 2, 3] } }),
1872
1903
  Placeholder__default.default.configure({ placeholder }),
1873
- markdown.Markdown
1904
+ markdown.Markdown,
1905
+ // SubmitOnEnter — when the consumer wired an onSubmit, intercept
1906
+ // Enter at the keymap level (before StarterKit's HardBreak).
1907
+ // The extension calls through `onSubmitRef.current` so handler
1908
+ // identity changes don't require an editor rebuild. See
1909
+ // submitOnEnter.ts for the keymap-vs-wrapper-handler rationale.
1910
+ SubmitOnEnter.configure({
1911
+ onSubmit: /* @__PURE__ */ chunkOLISEQHS_cjs.__name(() => {
1912
+ const h = onSubmitRef.current;
1913
+ if (!h) return false;
1914
+ return h();
1915
+ }, "onSubmit")
1916
+ })
1874
1917
  ];
1875
1918
  if (mentions) {
1876
1919
  const renderMarkdown = mentions.renderMarkdown ?? mentionPresets.plainAt;
@@ -2216,151 +2259,159 @@ Object.defineProperty(exports, "useCronWeekDays", {
2216
2259
  });
2217
2260
  Object.defineProperty(exports, "Attachments", {
2218
2261
  enumerable: true,
2219
- get: function () { return chunkUVIFD3TH_cjs.Attachments; }
2262
+ get: function () { return chunkSI5RD2GD_cjs.Attachments; }
2220
2263
  });
2221
2264
  Object.defineProperty(exports, "AttachmentsGrid", {
2222
2265
  enumerable: true,
2223
- get: function () { return chunkUVIFD3TH_cjs.AttachmentsGrid; }
2266
+ get: function () { return chunkSI5RD2GD_cjs.AttachmentsGrid; }
2224
2267
  });
2225
2268
  Object.defineProperty(exports, "AttachmentsList", {
2226
2269
  enumerable: true,
2227
- get: function () { return chunkUVIFD3TH_cjs.AttachmentsList; }
2270
+ get: function () { return chunkSI5RD2GD_cjs.AttachmentsList; }
2228
2271
  });
2229
2272
  Object.defineProperty(exports, "CHAT_EVENT_NAME", {
2230
2273
  enumerable: true,
2231
- get: function () { return chunkUVIFD3TH_cjs.CHAT_EVENT_NAME; }
2274
+ get: function () { return chunkSI5RD2GD_cjs.CHAT_EVENT_NAME; }
2232
2275
  });
2233
2276
  Object.defineProperty(exports, "CSS_VARS", {
2234
2277
  enumerable: true,
2235
- get: function () { return chunkUVIFD3TH_cjs.CSS_VARS; }
2278
+ get: function () { return chunkSI5RD2GD_cjs.CSS_VARS; }
2236
2279
  });
2237
2280
  Object.defineProperty(exports, "ChatProvider", {
2238
2281
  enumerable: true,
2239
- get: function () { return chunkUVIFD3TH_cjs.ChatProvider; }
2282
+ get: function () { return chunkSI5RD2GD_cjs.ChatProvider; }
2240
2283
  });
2241
2284
  Object.defineProperty(exports, "ChatRoot", {
2242
2285
  enumerable: true,
2243
- get: function () { return chunkUVIFD3TH_cjs.ChatRoot; }
2286
+ get: function () { return chunkSI5RD2GD_cjs.ChatRoot; }
2244
2287
  });
2245
2288
  Object.defineProperty(exports, "Composer", {
2246
2289
  enumerable: true,
2247
- get: function () { return chunkUVIFD3TH_cjs.Composer; }
2290
+ get: function () { return chunkSI5RD2GD_cjs.Composer; }
2248
2291
  });
2249
2292
  Object.defineProperty(exports, "DEFAULT_LABELS", {
2250
2293
  enumerable: true,
2251
- get: function () { return chunkUVIFD3TH_cjs.DEFAULT_LABELS; }
2294
+ get: function () { return chunkSI5RD2GD_cjs.DEFAULT_LABELS; }
2252
2295
  });
2253
2296
  Object.defineProperty(exports, "DEFAULT_SIDEBAR", {
2254
2297
  enumerable: true,
2255
- get: function () { return chunkUVIFD3TH_cjs.DEFAULT_SIDEBAR; }
2298
+ get: function () { return chunkSI5RD2GD_cjs.DEFAULT_SIDEBAR; }
2256
2299
  });
2257
2300
  Object.defineProperty(exports, "DEFAULT_Z_INDEX", {
2258
2301
  enumerable: true,
2259
- get: function () { return chunkUVIFD3TH_cjs.DEFAULT_Z_INDEX; }
2302
+ get: function () { return chunkSI5RD2GD_cjs.DEFAULT_Z_INDEX; }
2260
2303
  });
2261
2304
  Object.defineProperty(exports, "EmptyState", {
2262
2305
  enumerable: true,
2263
- get: function () { return chunkUVIFD3TH_cjs.EmptyState; }
2306
+ get: function () { return chunkSI5RD2GD_cjs.EmptyState; }
2264
2307
  });
2265
2308
  Object.defineProperty(exports, "ErrorBanner", {
2266
2309
  enumerable: true,
2267
- get: function () { return chunkUVIFD3TH_cjs.ErrorBanner; }
2310
+ get: function () { return chunkSI5RD2GD_cjs.ErrorBanner; }
2268
2311
  });
2269
2312
  Object.defineProperty(exports, "HOTKEYS", {
2270
2313
  enumerable: true,
2271
- get: function () { return chunkUVIFD3TH_cjs.HOTKEYS; }
2314
+ get: function () { return chunkSI5RD2GD_cjs.HOTKEYS; }
2272
2315
  });
2273
2316
  Object.defineProperty(exports, "JumpToLatest", {
2274
2317
  enumerable: true,
2275
- get: function () { return chunkUVIFD3TH_cjs.JumpToLatest; }
2318
+ get: function () { return chunkSI5RD2GD_cjs.JumpToLatest; }
2276
2319
  });
2277
2320
  Object.defineProperty(exports, "LIMITS", {
2278
2321
  enumerable: true,
2279
- get: function () { return chunkUVIFD3TH_cjs.LIMITS; }
2322
+ get: function () { return chunkSI5RD2GD_cjs.LIMITS; }
2280
2323
  });
2281
2324
  Object.defineProperty(exports, "MessageActions", {
2282
2325
  enumerable: true,
2283
- get: function () { return chunkUVIFD3TH_cjs.MessageActions; }
2326
+ get: function () { return chunkSI5RD2GD_cjs.MessageActions; }
2284
2327
  });
2285
2328
  Object.defineProperty(exports, "MessageBubble", {
2286
2329
  enumerable: true,
2287
- get: function () { return chunkUVIFD3TH_cjs.MessageBubble; }
2330
+ get: function () { return chunkSI5RD2GD_cjs.MessageBubble; }
2288
2331
  });
2289
2332
  Object.defineProperty(exports, "MessageList", {
2290
2333
  enumerable: true,
2291
- get: function () { return chunkUVIFD3TH_cjs.MessageList; }
2334
+ get: function () { return chunkSI5RD2GD_cjs.MessageList; }
2292
2335
  });
2293
2336
  Object.defineProperty(exports, "STORAGE_KEYS", {
2294
2337
  enumerable: true,
2295
- get: function () { return chunkUVIFD3TH_cjs.STORAGE_KEYS; }
2338
+ get: function () { return chunkSI5RD2GD_cjs.STORAGE_KEYS; }
2296
2339
  });
2297
2340
  Object.defineProperty(exports, "Sources", {
2298
2341
  enumerable: true,
2299
- get: function () { return chunkUVIFD3TH_cjs.Sources; }
2342
+ get: function () { return chunkSI5RD2GD_cjs.Sources; }
2300
2343
  });
2301
2344
  Object.defineProperty(exports, "StreamingIndicator", {
2302
2345
  enumerable: true,
2303
- get: function () { return chunkUVIFD3TH_cjs.StreamingIndicator; }
2346
+ get: function () { return chunkSI5RD2GD_cjs.StreamingIndicator; }
2304
2347
  });
2305
2348
  Object.defineProperty(exports, "ToolCalls", {
2306
2349
  enumerable: true,
2307
- get: function () { return chunkUVIFD3TH_cjs.ToolCalls; }
2350
+ get: function () { return chunkSI5RD2GD_cjs.ToolCalls; }
2308
2351
  });
2309
2352
  Object.defineProperty(exports, "createId", {
2310
2353
  enumerable: true,
2311
- get: function () { return chunkUVIFD3TH_cjs.createId; }
2354
+ get: function () { return chunkSI5RD2GD_cjs.createId; }
2312
2355
  });
2313
2356
  Object.defineProperty(exports, "createTokenBuffer", {
2314
2357
  enumerable: true,
2315
- get: function () { return chunkUVIFD3TH_cjs.createTokenBuffer; }
2358
+ get: function () { return chunkSI5RD2GD_cjs.createTokenBuffer; }
2316
2359
  });
2317
2360
  Object.defineProperty(exports, "deriveInitials", {
2318
2361
  enumerable: true,
2319
- get: function () { return chunkUVIFD3TH_cjs.deriveInitials; }
2362
+ get: function () { return chunkSI5RD2GD_cjs.deriveInitials; }
2320
2363
  });
2321
2364
  Object.defineProperty(exports, "getChatLogger", {
2322
2365
  enumerable: true,
2323
- get: function () { return chunkUVIFD3TH_cjs.getChatLogger; }
2366
+ get: function () { return chunkSI5RD2GD_cjs.getChatLogger; }
2324
2367
  });
2325
2368
  Object.defineProperty(exports, "initialState", {
2326
2369
  enumerable: true,
2327
- get: function () { return chunkUVIFD3TH_cjs.initialState; }
2370
+ get: function () { return chunkSI5RD2GD_cjs.initialState; }
2371
+ });
2372
+ Object.defineProperty(exports, "isSubmittableDraft", {
2373
+ enumerable: true,
2374
+ get: function () { return chunkSI5RD2GD_cjs.isSubmittableDraft; }
2328
2375
  });
2329
2376
  Object.defineProperty(exports, "reducer", {
2330
2377
  enumerable: true,
2331
- get: function () { return chunkUVIFD3TH_cjs.reducer; }
2378
+ get: function () { return chunkSI5RD2GD_cjs.reducer; }
2332
2379
  });
2333
2380
  Object.defineProperty(exports, "resolvePersona", {
2334
2381
  enumerable: true,
2335
- get: function () { return chunkUVIFD3TH_cjs.resolvePersona; }
2382
+ get: function () { return chunkSI5RD2GD_cjs.resolvePersona; }
2383
+ });
2384
+ Object.defineProperty(exports, "sanitizeDraft", {
2385
+ enumerable: true,
2386
+ get: function () { return chunkSI5RD2GD_cjs.sanitizeDraft; }
2336
2387
  });
2337
2388
  Object.defineProperty(exports, "useChat", {
2338
2389
  enumerable: true,
2339
- get: function () { return chunkUVIFD3TH_cjs.useChat; }
2390
+ get: function () { return chunkSI5RD2GD_cjs.useChat; }
2340
2391
  });
2341
2392
  Object.defineProperty(exports, "useChatAudio", {
2342
2393
  enumerable: true,
2343
- get: function () { return chunkUVIFD3TH_cjs.useChatAudio; }
2394
+ get: function () { return chunkSI5RD2GD_cjs.useChatAudio; }
2344
2395
  });
2345
2396
  Object.defineProperty(exports, "useChatAudioPrefs", {
2346
2397
  enumerable: true,
2347
- get: function () { return chunkUVIFD3TH_cjs.useChatAudioPrefs; }
2398
+ get: function () { return chunkSI5RD2GD_cjs.useChatAudioPrefs; }
2348
2399
  });
2349
2400
  Object.defineProperty(exports, "useChatComposer", {
2350
2401
  enumerable: true,
2351
- get: function () { return chunkUVIFD3TH_cjs.useChatComposer; }
2402
+ get: function () { return chunkSI5RD2GD_cjs.useChatComposer; }
2352
2403
  });
2353
2404
  Object.defineProperty(exports, "useChatContext", {
2354
2405
  enumerable: true,
2355
- get: function () { return chunkUVIFD3TH_cjs.useChatContext; }
2406
+ get: function () { return chunkSI5RD2GD_cjs.useChatContext; }
2356
2407
  });
2357
2408
  Object.defineProperty(exports, "useChatContextOptional", {
2358
2409
  enumerable: true,
2359
- get: function () { return chunkUVIFD3TH_cjs.useChatContextOptional; }
2410
+ get: function () { return chunkSI5RD2GD_cjs.useChatContextOptional; }
2360
2411
  });
2361
2412
  Object.defineProperty(exports, "useChatLayout", {
2362
2413
  enumerable: true,
2363
- get: function () { return chunkUVIFD3TH_cjs.useChatLayout; }
2414
+ get: function () { return chunkSI5RD2GD_cjs.useChatLayout; }
2364
2415
  });
2365
2416
  Object.defineProperty(exports, "TreeError", {
2366
2417
  enumerable: true,