@duskmoon-dev/components 0.6.0 → 0.6.1
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/README.md +27 -3
- package/dist/{chunk-b1jnq16e.js → chunk-rd10x4gc.js} +6 -0
- package/dist/components/chat/Chat.types.d.ts +7 -0
- package/dist/components/chat/ChatSessionComposer.types.d.ts +4 -0
- package/dist/components/chat/ComposerProvider.types.d.ts +4 -0
- package/dist/components/chat/composer/CompletionList.d.ts +6 -1
- package/dist/components/chat/composer/ComposerShell.d.ts +4 -0
- package/dist/components/chat/composer/DraftLifecycle.d.ts +3 -1
- package/dist/components/chat/index.js +826 -659
- package/dist/components/chat/rich/index.js +644 -603
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.js +1939 -1540
- package/dist/infrastructure.js +1 -1
- package/dist/styles.css +180 -2
- package/package.json +3 -3
|
@@ -38,25 +38,25 @@ var __chunks = (base, ids, nodes, entry) => {
|
|
|
38
38
|
__chunkSeen ||= {};
|
|
39
39
|
__preload(ids[entry], 1);
|
|
40
40
|
};
|
|
41
|
-
__chunks(import.meta.url,["
|
|
41
|
+
__chunks(import.meta.url,["75afjaj1","rd10x4gc","kg46s2vk"],[["./index.js",2],["../../../chunk-rd10x4gc.js",2],["../../../chunk-kg46s2vk.js"]],0);
|
|
42
42
|
|
|
43
43
|
// src/components/chat/rich/RichChatComposer.tsx
|
|
44
|
-
import { Component, Suspense, forwardRef as
|
|
44
|
+
import { Component, Suspense, forwardRef as forwardRef5, lazy } from "react";
|
|
45
45
|
|
|
46
46
|
// src/components/chat/composer/SemanticComposer.tsx
|
|
47
47
|
import {
|
|
48
|
-
forwardRef as
|
|
48
|
+
forwardRef as forwardRef4,
|
|
49
49
|
useId as useId4,
|
|
50
50
|
useCallback as useCallback2,
|
|
51
|
-
useImperativeHandle as
|
|
52
|
-
useLayoutEffect as
|
|
51
|
+
useImperativeHandle as useImperativeHandle3,
|
|
52
|
+
useLayoutEffect as useLayoutEffect8,
|
|
53
53
|
useRef as useRef5,
|
|
54
54
|
useState as useState6,
|
|
55
55
|
useSyncExternalStore as useSyncExternalStore5
|
|
56
56
|
} from "react";
|
|
57
57
|
|
|
58
58
|
// src/components/chat/composer/ComposerShell.tsx
|
|
59
|
-
import { forwardRef, useEffect, useRef } from "react";
|
|
59
|
+
import { forwardRef, useEffect, useRef as useRef2, useState } from "react";
|
|
60
60
|
|
|
61
61
|
// src/components/button/Button.tsx
|
|
62
62
|
import React from "react";
|
|
@@ -411,8 +411,8 @@ function Button({
|
|
|
411
411
|
});
|
|
412
412
|
}
|
|
413
413
|
// src/components/chat/composer/CompletionList.tsx
|
|
414
|
-
import React2 from "react";
|
|
415
|
-
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
414
|
+
import React2, { useLayoutEffect, useRef } from "react";
|
|
415
|
+
import { jsx as jsx2, jsxs as jsxs2, Fragment as Fragment2 } from "react/jsx-runtime";
|
|
416
416
|
function completionOptionId(composerId, candidateId) {
|
|
417
417
|
return `${composerId}-option-${encodeURIComponent(candidateId)}`;
|
|
418
418
|
}
|
|
@@ -421,13 +421,37 @@ function CompletionList({
|
|
|
421
421
|
label,
|
|
422
422
|
candidates,
|
|
423
423
|
activeId,
|
|
424
|
-
onSelect
|
|
424
|
+
onSelect,
|
|
425
|
+
compact = false,
|
|
426
|
+
anchorName,
|
|
427
|
+
header,
|
|
428
|
+
status,
|
|
429
|
+
onDismiss
|
|
425
430
|
}) {
|
|
426
|
-
|
|
431
|
+
const surface = useRef(null);
|
|
432
|
+
useLayoutEffect(() => {
|
|
433
|
+
if (compact)
|
|
434
|
+
surface.current?.showPopover?.();
|
|
435
|
+
}, [compact]);
|
|
436
|
+
useLayoutEffect(() => {
|
|
437
|
+
const tray = surface.current;
|
|
438
|
+
const option = tray?.querySelector('[aria-selected="true"]');
|
|
439
|
+
if (!compact || !tray || !option)
|
|
440
|
+
return;
|
|
441
|
+
const bounds = tray.getBoundingClientRect();
|
|
442
|
+
const selected = option.getBoundingClientRect();
|
|
443
|
+
const top = bounds.top + tray.clientTop;
|
|
444
|
+
const bottom = top + tray.clientHeight;
|
|
445
|
+
if (selected.top < top)
|
|
446
|
+
tray.scrollTop += selected.top - top;
|
|
447
|
+
else if (selected.bottom > bottom)
|
|
448
|
+
tray.scrollTop += selected.bottom - bottom;
|
|
449
|
+
}, [compact, activeId, candidates]);
|
|
450
|
+
const list = candidates.length ? /* @__PURE__ */ jsx2("ul", {
|
|
427
451
|
id: `${composerId}-completions`,
|
|
428
452
|
role: "listbox",
|
|
429
453
|
"aria-label": label,
|
|
430
|
-
className: "chat-composer-completions",
|
|
454
|
+
className: compact ? "chat-composer-completion-list" : "chat-composer-completions",
|
|
431
455
|
children: candidates.map((item, index) => /* @__PURE__ */ jsxs2(React2.Fragment, {
|
|
432
456
|
children: [
|
|
433
457
|
item.group && candidates[index - 1]?.group !== item.group ? /* @__PURE__ */ jsx2("li", {
|
|
@@ -438,7 +462,7 @@ function CompletionList({
|
|
|
438
462
|
}) : null,
|
|
439
463
|
/* @__PURE__ */ jsxs2("li", {
|
|
440
464
|
id: completionOptionId(composerId, item.id),
|
|
441
|
-
className: "chat-composer-option",
|
|
465
|
+
className: compact ? "chat-composer-option chat-composer-option-compact" : "chat-composer-option",
|
|
442
466
|
role: "option",
|
|
443
467
|
"aria-label": item.group ? `${item.group}: ${item.label}` : undefined,
|
|
444
468
|
"aria-selected": item.id === activeId,
|
|
@@ -455,24 +479,57 @@ function CompletionList({
|
|
|
455
479
|
}
|
|
456
480
|
},
|
|
457
481
|
children: [
|
|
482
|
+
compact && item.icon ? /* @__PURE__ */ jsx2("span", {
|
|
483
|
+
className: "chat-composer-option-icon",
|
|
484
|
+
"aria-hidden": "true",
|
|
485
|
+
children: item.icon
|
|
486
|
+
}) : null,
|
|
458
487
|
/* @__PURE__ */ jsx2("span", {
|
|
488
|
+
className: compact ? "chat-composer-label" : undefined,
|
|
489
|
+
title: item.label,
|
|
459
490
|
children: item.label
|
|
460
491
|
}),
|
|
461
492
|
item.description ? /* @__PURE__ */ jsx2("span", {
|
|
462
|
-
className: "chat-composer-description",
|
|
493
|
+
className: compact ? "chat-composer-description chat-composer-option-description" : "chat-composer-description",
|
|
494
|
+
title: typeof item.description === "string" ? item.description : undefined,
|
|
463
495
|
children: item.description
|
|
496
|
+
}) : null,
|
|
497
|
+
compact && item.sourceLabel ? /* @__PURE__ */ jsx2("span", {
|
|
498
|
+
className: "chat-composer-description chat-composer-option-source",
|
|
499
|
+
children: item.sourceLabel
|
|
464
500
|
}) : null
|
|
465
501
|
]
|
|
466
502
|
})
|
|
467
503
|
]
|
|
468
504
|
}, item.id))
|
|
505
|
+
}) : null;
|
|
506
|
+
return compact ? /* @__PURE__ */ jsxs2("div", {
|
|
507
|
+
ref: surface,
|
|
508
|
+
popover: "auto",
|
|
509
|
+
className: "chat-composer-completions chat-composer-completions-compact",
|
|
510
|
+
style: { positionAnchor: anchorName },
|
|
511
|
+
onToggle: (event) => {
|
|
512
|
+
if (event.newState === "closed")
|
|
513
|
+
onDismiss?.();
|
|
514
|
+
},
|
|
515
|
+
children: [
|
|
516
|
+
header,
|
|
517
|
+
list,
|
|
518
|
+
status
|
|
519
|
+
]
|
|
520
|
+
}) : /* @__PURE__ */ jsxs2(Fragment2, {
|
|
521
|
+
children: [
|
|
522
|
+
header,
|
|
523
|
+
status,
|
|
524
|
+
list
|
|
525
|
+
]
|
|
469
526
|
});
|
|
470
527
|
}
|
|
471
528
|
|
|
472
529
|
// src/components/chat/composer/ComposerShell.tsx
|
|
473
|
-
import { jsx as jsx3, jsxs as jsxs3, Fragment as
|
|
530
|
+
import { jsx as jsx3, jsxs as jsxs3, Fragment as Fragment3 } from "react/jsx-runtime";
|
|
474
531
|
function AttachmentPreview({ file }) {
|
|
475
|
-
const imageRef =
|
|
532
|
+
const imageRef = useRef2(null);
|
|
476
533
|
useEffect(() => {
|
|
477
534
|
const image = imageRef.current;
|
|
478
535
|
if (!image || !file.type.startsWith("image/") || !URL.createObjectURL)
|
|
@@ -488,10 +545,44 @@ function AttachmentPreview({ file }) {
|
|
|
488
545
|
}, [file]);
|
|
489
546
|
return file.type.startsWith("image/") ? /* @__PURE__ */ jsx3("img", {
|
|
490
547
|
ref: imageRef,
|
|
548
|
+
className: "chat-composer-preview",
|
|
491
549
|
alt: file.name,
|
|
492
550
|
hidden: true
|
|
493
551
|
}) : null;
|
|
494
552
|
}
|
|
553
|
+
function ComposerIcon({
|
|
554
|
+
action
|
|
555
|
+
}) {
|
|
556
|
+
return /* @__PURE__ */ jsx3("svg", {
|
|
557
|
+
width: "18",
|
|
558
|
+
height: "18",
|
|
559
|
+
viewBox: "0 0 24 24",
|
|
560
|
+
fill: "none",
|
|
561
|
+
stroke: "currentColor",
|
|
562
|
+
strokeWidth: "2",
|
|
563
|
+
strokeLinecap: "round",
|
|
564
|
+
strokeLinejoin: "round",
|
|
565
|
+
"aria-hidden": "true",
|
|
566
|
+
focusable: "false",
|
|
567
|
+
children: action === "attach" ? /* @__PURE__ */ jsx3("path", {
|
|
568
|
+
d: "M12 5v14M5 12h14"
|
|
569
|
+
}) : action === "send" ? /* @__PURE__ */ jsx3("path", {
|
|
570
|
+
d: "m5 12 7-7 7 7M12 5v14"
|
|
571
|
+
}) : action === "stop" ? /* @__PURE__ */ jsx3("rect", {
|
|
572
|
+
x: "6",
|
|
573
|
+
y: "6",
|
|
574
|
+
width: "12",
|
|
575
|
+
height: "12",
|
|
576
|
+
rx: "1",
|
|
577
|
+
fill: "currentColor",
|
|
578
|
+
stroke: "none"
|
|
579
|
+
}) : action === "retry" ? /* @__PURE__ */ jsx3("path", {
|
|
580
|
+
d: "M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7"
|
|
581
|
+
}) : /* @__PURE__ */ jsx3("path", {
|
|
582
|
+
d: "m6 6 12 12M6 18 18 6"
|
|
583
|
+
})
|
|
584
|
+
});
|
|
585
|
+
}
|
|
495
586
|
function AttachmentContent({
|
|
496
587
|
file,
|
|
497
588
|
renderAttachment,
|
|
@@ -508,6 +599,8 @@ function ExtraActions({
|
|
|
508
599
|
var ComposerShell = forwardRef(({
|
|
509
600
|
editor,
|
|
510
601
|
composerId,
|
|
602
|
+
compact = false,
|
|
603
|
+
addMenu,
|
|
511
604
|
entries,
|
|
512
605
|
renderAttachment,
|
|
513
606
|
removeAttachment,
|
|
@@ -526,12 +619,14 @@ var ComposerShell = forwardRef(({
|
|
|
526
619
|
active,
|
|
527
620
|
showCompletion,
|
|
528
621
|
selectCompletion,
|
|
622
|
+
dismissCompletion,
|
|
529
623
|
visibleError,
|
|
530
624
|
hasError,
|
|
531
625
|
intakeEvents = true,
|
|
532
626
|
completionHeader,
|
|
533
627
|
completionStatus,
|
|
534
628
|
statusContent,
|
|
629
|
+
renderFooter,
|
|
535
630
|
attachLabel,
|
|
536
631
|
sendLabel,
|
|
537
632
|
stopLabel,
|
|
@@ -541,206 +636,345 @@ var ComposerShell = forwardRef(({
|
|
|
541
636
|
children,
|
|
542
637
|
className,
|
|
543
638
|
...props
|
|
544
|
-
}, ref) =>
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
previewUrl,
|
|
581
|
-
state,
|
|
582
|
-
status,
|
|
583
|
-
progress,
|
|
584
|
-
retry,
|
|
585
|
-
cancel
|
|
586
|
-
}) => {
|
|
587
|
-
const name = file?.name ?? entryName ?? "Attachment";
|
|
588
|
-
return /* @__PURE__ */ jsx3("li", {
|
|
589
|
-
className: "chat-composer-attachment",
|
|
590
|
-
"data-state": state,
|
|
591
|
-
children: renderAttachment && file ? /* @__PURE__ */ jsx3(AttachmentContent, {
|
|
592
|
-
file,
|
|
593
|
-
renderAttachment,
|
|
594
|
-
context: {
|
|
595
|
-
remove: () => removeAttachment(id),
|
|
596
|
-
disabled: disabled || !onAttachmentsChange
|
|
597
|
-
}
|
|
598
|
-
}) : /* @__PURE__ */ jsxs3(Fragment2, {
|
|
599
|
-
children: [
|
|
600
|
-
previewUrl ? /* @__PURE__ */ jsx3("img", {
|
|
601
|
-
src: previewUrl,
|
|
602
|
-
alt: name
|
|
603
|
-
}) : file ? /* @__PURE__ */ jsx3(AttachmentPreview, {
|
|
604
|
-
file
|
|
605
|
-
}) : null,
|
|
606
|
-
/* @__PURE__ */ jsxs3("div", {
|
|
607
|
-
className: "chat-composer-attachment-info",
|
|
608
|
-
children: [
|
|
609
|
-
/* @__PURE__ */ jsx3("span", {
|
|
610
|
-
className: "chat-composer-filename",
|
|
611
|
-
title: name,
|
|
612
|
-
children: name
|
|
613
|
-
}),
|
|
614
|
-
status ? /* @__PURE__ */ jsx3("span", {
|
|
615
|
-
className: "chat-composer-description",
|
|
616
|
-
children: status
|
|
617
|
-
}) : null,
|
|
618
|
-
progress !== undefined ? /* @__PURE__ */ jsx3("progress", {
|
|
619
|
-
value: progress,
|
|
620
|
-
max: 1,
|
|
621
|
-
"aria-label": `Preparing ${name}`
|
|
622
|
-
}) : null
|
|
623
|
-
]
|
|
624
|
-
}),
|
|
625
|
-
retry ? /* @__PURE__ */ jsx3(Button, {
|
|
626
|
-
type: "button",
|
|
627
|
-
size: "sm",
|
|
628
|
-
disabled,
|
|
629
|
-
onClick: retry,
|
|
630
|
-
"aria-label": `Retry ${name}`,
|
|
631
|
-
children: "Retry"
|
|
632
|
-
}) : null,
|
|
633
|
-
cancel ? /* @__PURE__ */ jsx3(Button, {
|
|
634
|
-
type: "button",
|
|
635
|
-
size: "sm",
|
|
636
|
-
disabled,
|
|
637
|
-
onClick: cancel,
|
|
638
|
-
"aria-label": `Cancel ${name}`,
|
|
639
|
-
children: "Cancel"
|
|
640
|
-
}) : null,
|
|
641
|
-
onAttachmentsChange ? /* @__PURE__ */ jsx3(Button, {
|
|
642
|
-
type: "button",
|
|
643
|
-
size: "sm",
|
|
644
|
-
color: "base",
|
|
645
|
-
appearance: "ghost",
|
|
646
|
-
disabled,
|
|
647
|
-
"aria-label": `Remove ${name}`,
|
|
648
|
-
onClick: () => removeAttachment(id),
|
|
649
|
-
children: "Remove"
|
|
650
|
-
}) : null
|
|
651
|
-
]
|
|
652
|
-
})
|
|
653
|
-
}, id);
|
|
639
|
+
}, ref) => {
|
|
640
|
+
const [addOpen, setAddOpen] = useState(false);
|
|
641
|
+
const addId = `${composerId}-add`;
|
|
642
|
+
const addAnchor = `--composer-add-${composerId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
643
|
+
const completionAnchor = `--composer-completions-${composerId.replace(/[^a-zA-Z0-9_-]/g, "")}`;
|
|
644
|
+
const thumbnails = compact && entries.length > 0 && !renderAttachment && entries.every(({ file, previewUrl, state, status, progress, retry, cancel }) => (previewUrl || file?.type.startsWith("image/") && typeof URL.createObjectURL === "function") && (!state || state === "ready") && !status && progress === undefined && !retry && !cancel);
|
|
645
|
+
const attachmentAction = onAttachmentsChange ? /* @__PURE__ */ jsxs3(Fragment3, {
|
|
646
|
+
children: [
|
|
647
|
+
/* @__PURE__ */ jsx3("input", {
|
|
648
|
+
ref: pickerRef,
|
|
649
|
+
type: "file",
|
|
650
|
+
accept,
|
|
651
|
+
multiple,
|
|
652
|
+
disabled,
|
|
653
|
+
hidden: true,
|
|
654
|
+
"aria-label": attachLabel,
|
|
655
|
+
onChange: (event) => {
|
|
656
|
+
const files = Array.from(event.currentTarget.files ?? []);
|
|
657
|
+
event.currentTarget.value = "";
|
|
658
|
+
if (files.length > 0)
|
|
659
|
+
addAttachments(files, "picker");
|
|
660
|
+
}
|
|
661
|
+
}),
|
|
662
|
+
/* @__PURE__ */ jsx3(Button, {
|
|
663
|
+
type: "button",
|
|
664
|
+
color: "base",
|
|
665
|
+
appearance: "ghost",
|
|
666
|
+
size: "sm",
|
|
667
|
+
shape: "circle",
|
|
668
|
+
"aria-label": attachLabel,
|
|
669
|
+
title: attachLabel,
|
|
670
|
+
disabled,
|
|
671
|
+
onClick: openAttachments,
|
|
672
|
+
children: /* @__PURE__ */ jsx3(ComposerIcon, {
|
|
673
|
+
action: "attach"
|
|
674
|
+
})
|
|
654
675
|
})
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
+
]
|
|
677
|
+
}) : null;
|
|
678
|
+
const actionContent = /* @__PURE__ */ jsxs3(Fragment3, {
|
|
679
|
+
children: [
|
|
680
|
+
/* @__PURE__ */ jsx3(ExtraActions, {
|
|
681
|
+
context: {
|
|
682
|
+
submit: () => {
|
|
683
|
+
submit();
|
|
684
|
+
},
|
|
685
|
+
submitting,
|
|
686
|
+
canSubmit: eligible,
|
|
687
|
+
disabled,
|
|
688
|
+
generating,
|
|
689
|
+
openAttachments
|
|
690
|
+
},
|
|
691
|
+
children
|
|
692
|
+
}),
|
|
693
|
+
generating && onStop && (!compact || !eligible) ? /* @__PURE__ */ jsx3(Button, {
|
|
694
|
+
type: "button",
|
|
695
|
+
color: compact ? "primary" : undefined,
|
|
696
|
+
size: "sm",
|
|
697
|
+
shape: "circle",
|
|
698
|
+
"aria-label": stopLabel,
|
|
699
|
+
title: stopLabel,
|
|
700
|
+
disabled,
|
|
701
|
+
onClick: onStop,
|
|
702
|
+
children: /* @__PURE__ */ jsx3(ComposerIcon, {
|
|
703
|
+
action: "stop"
|
|
704
|
+
})
|
|
705
|
+
}) : null,
|
|
706
|
+
!compact || !generating || !onStop || eligible ? /* @__PURE__ */ jsx3(Button, {
|
|
707
|
+
type: "button",
|
|
708
|
+
color: "primary",
|
|
709
|
+
size: "sm",
|
|
710
|
+
shape: "circle",
|
|
711
|
+
"aria-label": sendLabel,
|
|
712
|
+
title: sendLabel,
|
|
713
|
+
disabled: !eligible,
|
|
714
|
+
"aria-busy": busy || submitting || undefined,
|
|
715
|
+
onClick: () => {
|
|
716
|
+
submit();
|
|
717
|
+
},
|
|
718
|
+
children: /* @__PURE__ */ jsx3(ComposerIcon, {
|
|
719
|
+
action: "send"
|
|
720
|
+
})
|
|
721
|
+
}) : null
|
|
722
|
+
]
|
|
723
|
+
});
|
|
724
|
+
function renderToolbar(menuContent) {
|
|
725
|
+
return compact ? /* @__PURE__ */ jsxs3("div", {
|
|
726
|
+
className: "chat-composer-toolbar chat-composer-toolbar-compact",
|
|
676
727
|
children: [
|
|
677
|
-
onAttachmentsChange ? /* @__PURE__ */ jsxs3(
|
|
728
|
+
onAttachmentsChange || addMenu || menuContent ? /* @__PURE__ */ jsxs3(Fragment3, {
|
|
678
729
|
children: [
|
|
679
|
-
/* @__PURE__ */ jsx3("input", {
|
|
680
|
-
ref: pickerRef,
|
|
681
|
-
type: "file",
|
|
682
|
-
accept,
|
|
683
|
-
multiple,
|
|
684
|
-
disabled,
|
|
685
|
-
hidden: true,
|
|
686
|
-
"aria-label": attachLabel,
|
|
687
|
-
onChange: (event) => {
|
|
688
|
-
const files = Array.from(event.currentTarget.files ?? []);
|
|
689
|
-
event.currentTarget.value = "";
|
|
690
|
-
if (files.length > 0)
|
|
691
|
-
addAttachments(files, "picker");
|
|
692
|
-
}
|
|
693
|
-
}),
|
|
694
730
|
/* @__PURE__ */ jsx3(Button, {
|
|
695
731
|
type: "button",
|
|
696
732
|
color: "base",
|
|
697
733
|
appearance: "ghost",
|
|
734
|
+
size: "sm",
|
|
735
|
+
shape: "circle",
|
|
736
|
+
"aria-label": attachLabel,
|
|
737
|
+
title: attachLabel,
|
|
698
738
|
disabled,
|
|
699
|
-
|
|
700
|
-
|
|
739
|
+
popoverTarget: addId,
|
|
740
|
+
"aria-controls": addId,
|
|
741
|
+
"aria-expanded": addOpen,
|
|
742
|
+
style: { anchorName: addAnchor },
|
|
743
|
+
children: /* @__PURE__ */ jsx3(ComposerIcon, {
|
|
744
|
+
action: "attach"
|
|
745
|
+
})
|
|
746
|
+
}),
|
|
747
|
+
/* @__PURE__ */ jsxs3("div", {
|
|
748
|
+
id: addId,
|
|
749
|
+
popover: "auto",
|
|
750
|
+
role: "group",
|
|
751
|
+
"aria-label": "Add files and more",
|
|
752
|
+
className: "popover popover-menu chat-composer-menu",
|
|
753
|
+
style: { positionAnchor: addAnchor },
|
|
754
|
+
onToggle: (event) => setAddOpen(event.currentTarget.matches(":popover-open")),
|
|
755
|
+
children: [
|
|
756
|
+
/* @__PURE__ */ jsx3("div", {
|
|
757
|
+
className: "chat-composer-group",
|
|
758
|
+
children: "Add"
|
|
759
|
+
}),
|
|
760
|
+
onAttachmentsChange ? /* @__PURE__ */ jsxs3(Fragment3, {
|
|
761
|
+
children: [
|
|
762
|
+
/* @__PURE__ */ jsx3("input", {
|
|
763
|
+
ref: pickerRef,
|
|
764
|
+
type: "file",
|
|
765
|
+
accept,
|
|
766
|
+
multiple,
|
|
767
|
+
disabled,
|
|
768
|
+
hidden: true,
|
|
769
|
+
"aria-label": attachLabel,
|
|
770
|
+
onChange: (event) => {
|
|
771
|
+
const files = Array.from(event.currentTarget.files ?? []);
|
|
772
|
+
event.currentTarget.value = "";
|
|
773
|
+
if (files.length)
|
|
774
|
+
addAttachments(files, "picker");
|
|
775
|
+
}
|
|
776
|
+
}),
|
|
777
|
+
/* @__PURE__ */ jsxs3("button", {
|
|
778
|
+
type: "button",
|
|
779
|
+
className: "popover-menu-item",
|
|
780
|
+
disabled,
|
|
781
|
+
onClick: (event) => {
|
|
782
|
+
event.currentTarget.closest("[popover]")?.hidePopover?.();
|
|
783
|
+
openAttachments();
|
|
784
|
+
},
|
|
785
|
+
children: [
|
|
786
|
+
/* @__PURE__ */ jsx3(ComposerIcon, {
|
|
787
|
+
action: "attach"
|
|
788
|
+
}),
|
|
789
|
+
/* @__PURE__ */ jsx3("span", {
|
|
790
|
+
children: "Files"
|
|
791
|
+
})
|
|
792
|
+
]
|
|
793
|
+
})
|
|
794
|
+
]
|
|
795
|
+
}) : null,
|
|
796
|
+
menuContent,
|
|
797
|
+
addMenu
|
|
798
|
+
]
|
|
701
799
|
})
|
|
702
800
|
]
|
|
703
801
|
}) : null,
|
|
704
|
-
/* @__PURE__ */ jsx3(
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
submit();
|
|
708
|
-
},
|
|
709
|
-
submitting,
|
|
710
|
-
canSubmit: eligible,
|
|
711
|
-
disabled,
|
|
712
|
-
generating,
|
|
713
|
-
openAttachments
|
|
714
|
-
},
|
|
715
|
-
children
|
|
716
|
-
}),
|
|
717
|
-
generating && onStop ? /* @__PURE__ */ jsx3(Button, {
|
|
718
|
-
type: "button",
|
|
719
|
-
disabled,
|
|
720
|
-
onClick: onStop,
|
|
721
|
-
children: stopLabel
|
|
722
|
-
}) : null,
|
|
723
|
-
/* @__PURE__ */ jsx3(Button, {
|
|
724
|
-
type: "button",
|
|
725
|
-
color: "primary",
|
|
726
|
-
disabled: !eligible,
|
|
727
|
-
"aria-busy": busy || submitting || undefined,
|
|
728
|
-
onClick: () => {
|
|
729
|
-
submit();
|
|
730
|
-
},
|
|
731
|
-
children: sendLabel
|
|
802
|
+
/* @__PURE__ */ jsx3("div", {
|
|
803
|
+
className: "chat-composer-actions",
|
|
804
|
+
children: actionContent
|
|
732
805
|
})
|
|
733
806
|
]
|
|
734
|
-
})
|
|
735
|
-
|
|
736
|
-
|
|
807
|
+
}) : /* @__PURE__ */ jsxs3("div", {
|
|
808
|
+
className: "chat-composer-actions",
|
|
809
|
+
children: [
|
|
810
|
+
attachmentAction,
|
|
811
|
+
actionContent
|
|
812
|
+
]
|
|
813
|
+
});
|
|
814
|
+
}
|
|
815
|
+
return /* @__PURE__ */ jsxs3("div", {
|
|
816
|
+
...props,
|
|
817
|
+
ref,
|
|
818
|
+
className: cn("chat-composer", className),
|
|
819
|
+
style: compact ? {
|
|
820
|
+
...props.style,
|
|
821
|
+
anchorName: props.style?.anchorName && props.style.anchorName !== "none" ? `${props.style.anchorName}, ${completionAnchor}` : completionAnchor
|
|
822
|
+
} : props.style,
|
|
823
|
+
onPaste: (event) => {
|
|
824
|
+
props.onPaste?.(event);
|
|
825
|
+
if (!intakeEvents || event.defaultPrevented || disabled || !onAttachmentsChange)
|
|
826
|
+
return;
|
|
827
|
+
const files = Array.from(event.clipboardData.files ?? []);
|
|
828
|
+
if (files.length)
|
|
829
|
+
addAttachments(files, "paste");
|
|
830
|
+
},
|
|
831
|
+
onDragOver: (event) => {
|
|
832
|
+
props.onDragOver?.(event);
|
|
833
|
+
if (intakeEvents && !event.defaultPrevented && !disabled && onAttachmentsChange && Array.from(event.dataTransfer.types).includes("Files"))
|
|
834
|
+
event.preventDefault();
|
|
835
|
+
},
|
|
836
|
+
onDrop: (event) => {
|
|
837
|
+
props.onDrop?.(event);
|
|
838
|
+
if (!intakeEvents || event.defaultPrevented || disabled || !onAttachmentsChange)
|
|
839
|
+
return;
|
|
840
|
+
const files = Array.from(event.dataTransfer.files ?? []);
|
|
841
|
+
if (files.length) {
|
|
842
|
+
event.preventDefault();
|
|
843
|
+
addAttachments(files, "drop");
|
|
844
|
+
}
|
|
845
|
+
},
|
|
846
|
+
children: [
|
|
847
|
+
entries.length > 0 ? /* @__PURE__ */ jsx3("ul", {
|
|
848
|
+
role: "list",
|
|
849
|
+
className: cn("chat-composer-attachments", thumbnails && "chat-composer-thumbnails"),
|
|
850
|
+
"aria-label": "Attachments",
|
|
851
|
+
children: entries.map(({
|
|
852
|
+
file,
|
|
853
|
+
id,
|
|
854
|
+
name: entryName,
|
|
855
|
+
previewUrl,
|
|
856
|
+
state,
|
|
857
|
+
status,
|
|
858
|
+
progress,
|
|
859
|
+
retry,
|
|
860
|
+
cancel
|
|
861
|
+
}) => {
|
|
862
|
+
const name = file?.name ?? entryName ?? "Attachment";
|
|
863
|
+
return /* @__PURE__ */ jsx3("li", {
|
|
864
|
+
className: cn("chat-composer-attachment", thumbnails && "chat-composer-attachment-tile"),
|
|
865
|
+
"data-state": state,
|
|
866
|
+
children: renderAttachment && file ? /* @__PURE__ */ jsx3(AttachmentContent, {
|
|
867
|
+
file,
|
|
868
|
+
renderAttachment,
|
|
869
|
+
context: {
|
|
870
|
+
remove: () => removeAttachment(id),
|
|
871
|
+
disabled: disabled || !onAttachmentsChange
|
|
872
|
+
}
|
|
873
|
+
}) : /* @__PURE__ */ jsxs3(Fragment3, {
|
|
874
|
+
children: [
|
|
875
|
+
previewUrl ? /* @__PURE__ */ jsx3("img", {
|
|
876
|
+
className: "chat-composer-preview",
|
|
877
|
+
src: previewUrl,
|
|
878
|
+
alt: name
|
|
879
|
+
}) : file ? /* @__PURE__ */ jsx3(AttachmentPreview, {
|
|
880
|
+
file
|
|
881
|
+
}) : null,
|
|
882
|
+
!thumbnails ? /* @__PURE__ */ jsxs3("div", {
|
|
883
|
+
className: "chat-composer-attachment-info",
|
|
884
|
+
children: [
|
|
885
|
+
/* @__PURE__ */ jsx3("span", {
|
|
886
|
+
className: "chat-composer-filename",
|
|
887
|
+
title: name,
|
|
888
|
+
children: name
|
|
889
|
+
}),
|
|
890
|
+
status ? /* @__PURE__ */ jsx3("span", {
|
|
891
|
+
className: "chat-composer-description",
|
|
892
|
+
children: status
|
|
893
|
+
}) : null,
|
|
894
|
+
progress !== undefined ? /* @__PURE__ */ jsx3("progress", {
|
|
895
|
+
className: "progress",
|
|
896
|
+
value: progress,
|
|
897
|
+
max: 1,
|
|
898
|
+
"aria-label": `Preparing ${name}`
|
|
899
|
+
}) : null
|
|
900
|
+
]
|
|
901
|
+
}) : null,
|
|
902
|
+
retry ? /* @__PURE__ */ jsx3(Button, {
|
|
903
|
+
type: "button",
|
|
904
|
+
size: "sm",
|
|
905
|
+
shape: "circle",
|
|
906
|
+
disabled,
|
|
907
|
+
onClick: retry,
|
|
908
|
+
"aria-label": `Retry ${name}`,
|
|
909
|
+
title: `Retry ${name}`,
|
|
910
|
+
children: /* @__PURE__ */ jsx3(ComposerIcon, {
|
|
911
|
+
action: "retry"
|
|
912
|
+
})
|
|
913
|
+
}) : null,
|
|
914
|
+
cancel ? /* @__PURE__ */ jsx3(Button, {
|
|
915
|
+
type: "button",
|
|
916
|
+
size: "sm",
|
|
917
|
+
shape: "circle",
|
|
918
|
+
disabled,
|
|
919
|
+
onClick: cancel,
|
|
920
|
+
"aria-label": `Cancel ${name}`,
|
|
921
|
+
title: `Cancel ${name}`,
|
|
922
|
+
children: /* @__PURE__ */ jsx3(ComposerIcon, {
|
|
923
|
+
action: "remove"
|
|
924
|
+
})
|
|
925
|
+
}) : null,
|
|
926
|
+
onAttachmentsChange ? /* @__PURE__ */ jsx3(Button, {
|
|
927
|
+
type: "button",
|
|
928
|
+
size: thumbnails ? "xs" : "sm",
|
|
929
|
+
shape: "circle",
|
|
930
|
+
className: thumbnails ? "chat-composer-attachment-remove" : undefined,
|
|
931
|
+
color: "base",
|
|
932
|
+
appearance: "ghost",
|
|
933
|
+
disabled,
|
|
934
|
+
"aria-label": `Remove ${name}`,
|
|
935
|
+
title: `Remove ${name}`,
|
|
936
|
+
onClick: () => removeAttachment(id),
|
|
937
|
+
children: /* @__PURE__ */ jsx3(ComposerIcon, {
|
|
938
|
+
action: "remove"
|
|
939
|
+
})
|
|
940
|
+
}) : null
|
|
941
|
+
]
|
|
942
|
+
})
|
|
943
|
+
}, id);
|
|
944
|
+
})
|
|
945
|
+
}) : null,
|
|
946
|
+
editor,
|
|
947
|
+
showCompletion || completionHeader || completionStatus ? /* @__PURE__ */ jsx3(CompletionList, {
|
|
948
|
+
composerId,
|
|
949
|
+
label: completion?.label ?? "Suggestions",
|
|
950
|
+
candidates: showCompletion ? candidates : [],
|
|
951
|
+
activeId: active?.id,
|
|
952
|
+
onSelect: selectCompletion,
|
|
953
|
+
compact,
|
|
954
|
+
anchorName: completionAnchor,
|
|
955
|
+
header: completionHeader,
|
|
956
|
+
status: completionStatus,
|
|
957
|
+
onDismiss: dismissCompletion
|
|
958
|
+
}) : null,
|
|
959
|
+
statusContent,
|
|
960
|
+
hasError ? /* @__PURE__ */ jsx3("div", {
|
|
961
|
+
id: `${composerId}-error`,
|
|
962
|
+
role: "alert",
|
|
963
|
+
className: "chat-composer-error chat-composer-status",
|
|
964
|
+
"data-state": "error",
|
|
965
|
+
children: visibleError
|
|
966
|
+
}) : null,
|
|
967
|
+
renderFooter ? renderFooter(renderToolbar) : renderToolbar()
|
|
968
|
+
]
|
|
969
|
+
});
|
|
970
|
+
});
|
|
737
971
|
ComposerShell.displayName = "ComposerShell";
|
|
738
972
|
|
|
739
973
|
// src/components/chat/composer/useComposerAttachments.ts
|
|
740
974
|
import {
|
|
741
975
|
useEffect as useEffect2,
|
|
742
|
-
useLayoutEffect,
|
|
743
|
-
useState,
|
|
976
|
+
useLayoutEffect as useLayoutEffect2,
|
|
977
|
+
useState as useState2,
|
|
744
978
|
useSyncExternalStore
|
|
745
979
|
} from "react";
|
|
746
980
|
|
|
@@ -1100,9 +1334,9 @@ function createComposerAttachmentController(options) {
|
|
|
1100
1334
|
|
|
1101
1335
|
// src/components/chat/composer/useComposerAttachments.ts
|
|
1102
1336
|
function useComposerAttachments(options) {
|
|
1103
|
-
const [controller] =
|
|
1337
|
+
const [controller] = useState2(() => createComposerAttachmentController(options));
|
|
1104
1338
|
const snapshot = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
1105
|
-
|
|
1339
|
+
useLayoutEffect2(() => {
|
|
1106
1340
|
controller.configure(options);
|
|
1107
1341
|
});
|
|
1108
1342
|
useEffect2(() => () => {
|
|
@@ -1112,7 +1346,7 @@ function useComposerAttachments(options) {
|
|
|
1112
1346
|
}
|
|
1113
1347
|
|
|
1114
1348
|
// src/components/chat/composer/useComposerProviders.ts
|
|
1115
|
-
import { useLayoutEffect as
|
|
1349
|
+
import { useLayoutEffect as useLayoutEffect3, useState as useState3, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
1116
1350
|
|
|
1117
1351
|
// src/components/chat/composer/providers.ts
|
|
1118
1352
|
var nextController = 0;
|
|
@@ -1484,20 +1718,20 @@ class ComposerProviderController {
|
|
|
1484
1718
|
|
|
1485
1719
|
// src/components/chat/composer/useComposerProviders.ts
|
|
1486
1720
|
function useComposerProviders(context) {
|
|
1487
|
-
const [controller] =
|
|
1721
|
+
const [controller] = useState3(() => new ComposerProviderController);
|
|
1488
1722
|
const snapshot = useSyncExternalStore2(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
1489
|
-
|
|
1723
|
+
useLayoutEffect3(() => {
|
|
1490
1724
|
controller.activate();
|
|
1491
1725
|
return () => controller.dispose();
|
|
1492
1726
|
}, [controller]);
|
|
1493
|
-
|
|
1727
|
+
useLayoutEffect3(() => {
|
|
1494
1728
|
controller.update(context);
|
|
1495
1729
|
});
|
|
1496
1730
|
return { controller, snapshot };
|
|
1497
1731
|
}
|
|
1498
1732
|
|
|
1499
1733
|
// src/components/chat/composer/useComposerSession.ts
|
|
1500
|
-
import { useId, useLayoutEffect as
|
|
1734
|
+
import { useId, useLayoutEffect as useLayoutEffect4, useState as useState4, useSyncExternalStore as useSyncExternalStore3 } from "react";
|
|
1501
1735
|
|
|
1502
1736
|
// src/components/chat/composer/session.ts
|
|
1503
1737
|
function sameComposerScope(a, b) {
|
|
@@ -1832,13 +2066,13 @@ function createComposerSessionController(initial, identity) {
|
|
|
1832
2066
|
// src/components/chat/composer/useComposerSession.ts
|
|
1833
2067
|
function useComposerSession(context) {
|
|
1834
2068
|
const instanceId = useId();
|
|
1835
|
-
const [controller] =
|
|
2069
|
+
const [controller] = useState4(() => createComposerSessionController(context, { instanceId }));
|
|
1836
2070
|
const snapshot = useSyncExternalStore3(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
1837
|
-
|
|
2071
|
+
useLayoutEffect4(() => {
|
|
1838
2072
|
controller.activate();
|
|
1839
2073
|
return () => controller.dispose();
|
|
1840
2074
|
}, [controller]);
|
|
1841
|
-
|
|
2075
|
+
useLayoutEffect4(() => {
|
|
1842
2076
|
controller.update(context);
|
|
1843
2077
|
});
|
|
1844
2078
|
return { controller, snapshot };
|
|
@@ -1846,343 +2080,33 @@ function useComposerSession(context) {
|
|
|
1846
2080
|
|
|
1847
2081
|
// src/components/chat/composer/PlainSemanticEditor.tsx
|
|
1848
2082
|
import {
|
|
1849
|
-
forwardRef as
|
|
2083
|
+
forwardRef as forwardRef3,
|
|
1850
2084
|
useId as useId2,
|
|
1851
|
-
useImperativeHandle as
|
|
2085
|
+
useImperativeHandle as useImperativeHandle2,
|
|
1852
2086
|
useCallback,
|
|
1853
|
-
useLayoutEffect as
|
|
2087
|
+
useLayoutEffect as useLayoutEffect6,
|
|
1854
2088
|
useRef as useRef4
|
|
1855
2089
|
} from "react";
|
|
1856
2090
|
|
|
1857
2091
|
// src/components/chat/composer/PlainEditor.tsx
|
|
1858
|
-
import {
|
|
1859
|
-
forwardRef as forwardRef3,
|
|
1860
|
-
useImperativeHandle as useImperativeHandle2,
|
|
1861
|
-
useLayoutEffect as useLayoutEffect4,
|
|
1862
|
-
useRef as useRef3
|
|
1863
|
-
} from "react";
|
|
1864
|
-
|
|
1865
|
-
// src/components/input/Input.tsx
|
|
1866
2092
|
import {
|
|
1867
2093
|
forwardRef as forwardRef2,
|
|
1868
2094
|
useImperativeHandle,
|
|
1869
|
-
|
|
1870
|
-
|
|
2095
|
+
useLayoutEffect as useLayoutEffect5,
|
|
2096
|
+
useRef as useRef3
|
|
1871
2097
|
} from "react";
|
|
1872
2098
|
|
|
1873
2099
|
// src/classes/input.ts
|
|
1874
|
-
var inputBaseClass = "input";
|
|
1875
|
-
var inputWrapperClass = "input-wrapper";
|
|
1876
|
-
var inputAffixWrapperClass = "input-affix-wrapper";
|
|
1877
|
-
var inputPrefixClass = "input-prefix";
|
|
1878
|
-
var inputSuffixClass = "input-suffix";
|
|
1879
|
-
var inputClearClass = "input-clear";
|
|
1880
|
-
var inputSearchClass = "input-search";
|
|
1881
|
-
var inputSearchButtonClass = "input-search-button";
|
|
1882
|
-
var inputPasswordClass = "input-password";
|
|
1883
|
-
var inputPasswordToggleClass = "input-password-toggle";
|
|
1884
|
-
var inputGroupClass = "input-group";
|
|
1885
|
-
var textAreaBaseClass = "textarea";
|
|
1886
2100
|
var textAreaWrapperClass = "textarea-wrapper";
|
|
1887
2101
|
var textAreaCountClass = "textarea-counter";
|
|
1888
2102
|
var textAreaCountExceededClass = "textarea-counter-exceeded";
|
|
1889
|
-
var textAreaAutoSizeClass = "textarea-auto-resize";
|
|
1890
|
-
var inputVariantClasses = {
|
|
1891
|
-
filled: "input-filled",
|
|
1892
|
-
outlined: "input-outlined"
|
|
1893
|
-
};
|
|
1894
|
-
var inputSizeClasses = {
|
|
1895
|
-
sm: "input-sm",
|
|
1896
|
-
md: "input-md",
|
|
1897
|
-
lg: "input-lg"
|
|
1898
|
-
};
|
|
1899
|
-
var inputStatusClasses = {
|
|
1900
|
-
error: "input-error",
|
|
1901
|
-
success: "input-success"
|
|
1902
|
-
};
|
|
1903
|
-
var textAreaVariantClasses = {
|
|
1904
|
-
filled: "textarea-filled",
|
|
1905
|
-
outlined: "textarea-outlined"
|
|
1906
|
-
};
|
|
1907
|
-
var textAreaSizeClasses = {
|
|
1908
|
-
sm: "textarea-sm",
|
|
1909
|
-
md: "",
|
|
1910
|
-
lg: "textarea-lg"
|
|
1911
|
-
};
|
|
1912
|
-
var textAreaStatusClasses = {
|
|
1913
|
-
error: "textarea-error",
|
|
1914
|
-
success: "textarea-success"
|
|
1915
|
-
};
|
|
1916
|
-
var textAreaResizeClasses = {
|
|
1917
|
-
none: "textarea-resize-none",
|
|
1918
|
-
both: "textarea-resize-both",
|
|
1919
|
-
horizontal: "textarea-resize-horizontal",
|
|
1920
|
-
vertical: "textarea-resize-vertical"
|
|
1921
|
-
};
|
|
1922
|
-
function getInputClasses({
|
|
1923
|
-
size = "md",
|
|
1924
|
-
status,
|
|
1925
|
-
variant = "outlined",
|
|
1926
|
-
className
|
|
1927
|
-
}) {
|
|
1928
|
-
return cn(inputBaseClass, inputVariantClasses[variant], inputSizeClasses[size], status && inputStatusClasses[status], className);
|
|
1929
|
-
}
|
|
1930
|
-
function getInputWrapperClasses({
|
|
1931
|
-
affixed,
|
|
1932
|
-
className
|
|
1933
|
-
}) {
|
|
1934
|
-
return cn(inputWrapperClass, affixed && inputAffixWrapperClass, className);
|
|
1935
|
-
}
|
|
1936
|
-
function getSearchWrapperClasses({ className }) {
|
|
1937
|
-
return cn(inputSearchClass, className);
|
|
1938
|
-
}
|
|
1939
|
-
function getPasswordWrapperClasses({
|
|
1940
|
-
className
|
|
1941
|
-
}) {
|
|
1942
|
-
return cn(inputPasswordClass, className);
|
|
1943
|
-
}
|
|
1944
|
-
function getTextAreaClasses({
|
|
1945
|
-
size = "md",
|
|
1946
|
-
status,
|
|
1947
|
-
variant = "outlined",
|
|
1948
|
-
resize = "vertical",
|
|
1949
|
-
autoSize,
|
|
1950
|
-
className
|
|
1951
|
-
}) {
|
|
1952
|
-
return cn(textAreaBaseClass, textAreaVariantClasses[variant], textAreaSizeClasses[size], status && textAreaStatusClasses[status], textAreaResizeClasses[resize], autoSize && textAreaAutoSizeClass, className);
|
|
1953
|
-
}
|
|
1954
2103
|
function getTextAreaCountClasses({ exceeded }) {
|
|
1955
2104
|
return cn(textAreaCountClass, exceeded && textAreaCountExceededClass);
|
|
1956
2105
|
}
|
|
1957
2106
|
|
|
1958
|
-
// src/components/input/Input.tsx
|
|
1959
|
-
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1960
|
-
function toTextValue(value) {
|
|
1961
|
-
if (Array.isArray(value)) {
|
|
1962
|
-
return value.join(",");
|
|
1963
|
-
}
|
|
1964
|
-
return value == null ? "" : String(value);
|
|
1965
|
-
}
|
|
1966
|
-
var InputRoot = forwardRef2(({
|
|
1967
|
-
allowClear,
|
|
1968
|
-
className,
|
|
1969
|
-
defaultValue,
|
|
1970
|
-
disabled,
|
|
1971
|
-
onChange,
|
|
1972
|
-
prefix,
|
|
1973
|
-
size = "md",
|
|
1974
|
-
status,
|
|
1975
|
-
suffix,
|
|
1976
|
-
type = "text",
|
|
1977
|
-
value,
|
|
1978
|
-
variant = "outlined",
|
|
1979
|
-
...props
|
|
1980
|
-
}, ref) => {
|
|
1981
|
-
const inputRef = useRef2(null);
|
|
1982
|
-
const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
|
|
1983
|
-
const isControlled = value !== undefined;
|
|
1984
|
-
const currentValue = isControlled ? toTextValue(value) : internalValue;
|
|
1985
|
-
const hasAffix = prefix != null || suffix != null || allowClear;
|
|
1986
|
-
useImperativeHandle(ref, () => inputRef.current);
|
|
1987
|
-
function handleChange(event) {
|
|
1988
|
-
if (!isControlled) {
|
|
1989
|
-
setInternalValue(event.currentTarget.value);
|
|
1990
|
-
}
|
|
1991
|
-
onChange?.(event);
|
|
1992
|
-
}
|
|
1993
|
-
function handleClear() {
|
|
1994
|
-
const input = inputRef.current;
|
|
1995
|
-
if (!input || disabled) {
|
|
1996
|
-
return;
|
|
1997
|
-
}
|
|
1998
|
-
input.value = "";
|
|
1999
|
-
if (!isControlled) {
|
|
2000
|
-
setInternalValue("");
|
|
2001
|
-
}
|
|
2002
|
-
onChange?.({
|
|
2003
|
-
currentTarget: input,
|
|
2004
|
-
target: input,
|
|
2005
|
-
type: "change"
|
|
2006
|
-
});
|
|
2007
|
-
input.focus();
|
|
2008
|
-
}
|
|
2009
|
-
const control = /* @__PURE__ */ jsx4("input", {
|
|
2010
|
-
...props,
|
|
2011
|
-
ref: inputRef,
|
|
2012
|
-
type,
|
|
2013
|
-
className: getInputClasses({ size, status, variant, className }),
|
|
2014
|
-
disabled,
|
|
2015
|
-
value: currentValue,
|
|
2016
|
-
onChange: handleChange
|
|
2017
|
-
});
|
|
2018
|
-
if (!hasAffix) {
|
|
2019
|
-
return control;
|
|
2020
|
-
}
|
|
2021
|
-
const showClear = allowClear && !disabled && currentValue.length > 0;
|
|
2022
|
-
return /* @__PURE__ */ jsxs4("span", {
|
|
2023
|
-
className: getInputWrapperClasses({ affixed: hasAffix }),
|
|
2024
|
-
children: [
|
|
2025
|
-
prefix != null ? /* @__PURE__ */ jsx4("span", {
|
|
2026
|
-
className: inputPrefixClass,
|
|
2027
|
-
children: prefix
|
|
2028
|
-
}) : null,
|
|
2029
|
-
control,
|
|
2030
|
-
showClear ? /* @__PURE__ */ jsx4("button", {
|
|
2031
|
-
type: "button",
|
|
2032
|
-
className: inputClearClass,
|
|
2033
|
-
"aria-label": "Clear input",
|
|
2034
|
-
onClick: handleClear,
|
|
2035
|
-
children: "x"
|
|
2036
|
-
}) : null,
|
|
2037
|
-
suffix != null ? /* @__PURE__ */ jsx4("span", {
|
|
2038
|
-
className: inputSuffixClass,
|
|
2039
|
-
children: suffix
|
|
2040
|
-
}) : null
|
|
2041
|
-
]
|
|
2042
|
-
});
|
|
2043
|
-
});
|
|
2044
|
-
InputRoot.displayName = "Input";
|
|
2045
|
-
var Search = forwardRef2(({
|
|
2046
|
-
className,
|
|
2047
|
-
disabled,
|
|
2048
|
-
enterButton,
|
|
2049
|
-
loading,
|
|
2050
|
-
onKeyDown,
|
|
2051
|
-
onSearch,
|
|
2052
|
-
...props
|
|
2053
|
-
}, ref) => {
|
|
2054
|
-
const inputRef = useRef2(null);
|
|
2055
|
-
useImperativeHandle(ref, () => inputRef.current);
|
|
2056
|
-
function emitSearch(event) {
|
|
2057
|
-
onSearch?.(inputRef.current?.value ?? "", event);
|
|
2058
|
-
}
|
|
2059
|
-
function handleKeyDown(event) {
|
|
2060
|
-
onKeyDown?.(event);
|
|
2061
|
-
if (!event.defaultPrevented && event.key === "Enter") {
|
|
2062
|
-
emitSearch(event);
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
const buttonContent = enterButton === true ? "Search" : enterButton ?? "Search";
|
|
2066
|
-
return /* @__PURE__ */ jsxs4("span", {
|
|
2067
|
-
className: getSearchWrapperClasses({ className }),
|
|
2068
|
-
children: [
|
|
2069
|
-
/* @__PURE__ */ jsx4(InputRoot, {
|
|
2070
|
-
...props,
|
|
2071
|
-
ref: inputRef,
|
|
2072
|
-
disabled,
|
|
2073
|
-
onKeyDown: handleKeyDown
|
|
2074
|
-
}),
|
|
2075
|
-
enterButton || loading ? /* @__PURE__ */ jsx4("button", {
|
|
2076
|
-
type: "button",
|
|
2077
|
-
className: inputSearchButtonClass,
|
|
2078
|
-
disabled: disabled || loading,
|
|
2079
|
-
"aria-busy": loading || undefined,
|
|
2080
|
-
onClick: emitSearch,
|
|
2081
|
-
children: loading ? "Loading" : buttonContent
|
|
2082
|
-
}) : null
|
|
2083
|
-
]
|
|
2084
|
-
});
|
|
2085
|
-
});
|
|
2086
|
-
Search.displayName = "Input.Search";
|
|
2087
|
-
var Password = forwardRef2(({ className, disabled, visibilityToggle = true, ...props }, ref) => {
|
|
2088
|
-
const [visible, setVisible] = useState4(false);
|
|
2089
|
-
const type = visible ? "text" : "password";
|
|
2090
|
-
const toggle = visibilityToggle ? /* @__PURE__ */ jsx4("button", {
|
|
2091
|
-
type: "button",
|
|
2092
|
-
className: inputPasswordToggleClass,
|
|
2093
|
-
disabled,
|
|
2094
|
-
"aria-label": visible ? "Hide password" : "Show password",
|
|
2095
|
-
onClick: () => {
|
|
2096
|
-
setVisible((current) => !current);
|
|
2097
|
-
},
|
|
2098
|
-
children: visible ? "Hide" : "Show"
|
|
2099
|
-
}) : undefined;
|
|
2100
|
-
return /* @__PURE__ */ jsx4("span", {
|
|
2101
|
-
className: getPasswordWrapperClasses({ className }),
|
|
2102
|
-
children: /* @__PURE__ */ jsx4(InputRoot, {
|
|
2103
|
-
...props,
|
|
2104
|
-
ref,
|
|
2105
|
-
disabled,
|
|
2106
|
-
type,
|
|
2107
|
-
suffix: toggle
|
|
2108
|
-
})
|
|
2109
|
-
});
|
|
2110
|
-
});
|
|
2111
|
-
Password.displayName = "Input.Password";
|
|
2112
|
-
var TextArea = forwardRef2(({
|
|
2113
|
-
autoSize,
|
|
2114
|
-
className,
|
|
2115
|
-
defaultValue,
|
|
2116
|
-
maxLength,
|
|
2117
|
-
onChange,
|
|
2118
|
-
resize = "vertical",
|
|
2119
|
-
showCount,
|
|
2120
|
-
size = "md",
|
|
2121
|
-
status,
|
|
2122
|
-
value,
|
|
2123
|
-
variant = "outlined",
|
|
2124
|
-
...props
|
|
2125
|
-
}, ref) => {
|
|
2126
|
-
const [internalValue, setInternalValue] = useState4(() => toTextValue(defaultValue));
|
|
2127
|
-
const isControlled = value !== undefined;
|
|
2128
|
-
const currentValue = isControlled ? toTextValue(value) : internalValue;
|
|
2129
|
-
const count = currentValue.length;
|
|
2130
|
-
const exceeded = maxLength !== undefined && count > maxLength;
|
|
2131
|
-
function handleChange(event) {
|
|
2132
|
-
if (!isControlled) {
|
|
2133
|
-
setInternalValue(event.currentTarget.value);
|
|
2134
|
-
}
|
|
2135
|
-
onChange?.(event);
|
|
2136
|
-
}
|
|
2137
|
-
const control = /* @__PURE__ */ jsx4("textarea", {
|
|
2138
|
-
...props,
|
|
2139
|
-
ref,
|
|
2140
|
-
className: getTextAreaClasses({
|
|
2141
|
-
size,
|
|
2142
|
-
status,
|
|
2143
|
-
variant,
|
|
2144
|
-
resize,
|
|
2145
|
-
autoSize: Boolean(autoSize),
|
|
2146
|
-
className
|
|
2147
|
-
}),
|
|
2148
|
-
maxLength,
|
|
2149
|
-
value: currentValue,
|
|
2150
|
-
onChange: handleChange
|
|
2151
|
-
});
|
|
2152
|
-
if (!showCount) {
|
|
2153
|
-
return control;
|
|
2154
|
-
}
|
|
2155
|
-
return /* @__PURE__ */ jsxs4("span", {
|
|
2156
|
-
className: textAreaWrapperClass,
|
|
2157
|
-
children: [
|
|
2158
|
-
control,
|
|
2159
|
-
/* @__PURE__ */ jsxs4("span", {
|
|
2160
|
-
className: getTextAreaCountClasses({ exceeded }),
|
|
2161
|
-
children: [
|
|
2162
|
-
count,
|
|
2163
|
-
maxLength !== undefined ? ` / ${maxLength}` : null
|
|
2164
|
-
]
|
|
2165
|
-
})
|
|
2166
|
-
]
|
|
2167
|
-
});
|
|
2168
|
-
});
|
|
2169
|
-
TextArea.displayName = "Input.TextArea";
|
|
2170
|
-
var Group = forwardRef2(({ className, children, ...props }, ref) => /* @__PURE__ */ jsx4("div", {
|
|
2171
|
-
...props,
|
|
2172
|
-
ref,
|
|
2173
|
-
className: cn(inputGroupClass, className),
|
|
2174
|
-
children
|
|
2175
|
-
}));
|
|
2176
|
-
Group.displayName = "Input.Group";
|
|
2177
|
-
var Input = Object.assign(InputRoot, {
|
|
2178
|
-
Search,
|
|
2179
|
-
Password,
|
|
2180
|
-
TextArea,
|
|
2181
|
-
Group
|
|
2182
|
-
});
|
|
2183
2107
|
// src/components/chat/composer/PlainEditor.tsx
|
|
2184
|
-
import { jsx as
|
|
2185
|
-
var PlainEditor =
|
|
2108
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2109
|
+
var PlainEditor = forwardRef2(({
|
|
2186
2110
|
value,
|
|
2187
2111
|
disabled,
|
|
2188
2112
|
minRows,
|
|
@@ -2202,7 +2126,12 @@ var PlainEditor = forwardRef3(({
|
|
|
2202
2126
|
const composingRef = useRef3(false);
|
|
2203
2127
|
const minimumRows = Math.max(1, Math.floor(minRows));
|
|
2204
2128
|
const maximumRows = Math.max(minimumRows, Math.floor(maxRows));
|
|
2205
|
-
|
|
2129
|
+
const { showCount, ...nativeProps } = textareaProps ?? {};
|
|
2130
|
+
delete nativeProps.size;
|
|
2131
|
+
delete nativeProps.status;
|
|
2132
|
+
delete nativeProps.variant;
|
|
2133
|
+
delete nativeProps.resize;
|
|
2134
|
+
useImperativeHandle(ref, () => ({
|
|
2206
2135
|
focus: () => editorRef.current?.focus(),
|
|
2207
2136
|
select: (start, end) => editorRef.current?.setSelectionRange(start, end),
|
|
2208
2137
|
selection: (currentValue) => ({
|
|
@@ -2211,10 +2140,10 @@ var PlainEditor = forwardRef3(({
|
|
|
2211
2140
|
selectionEnd: editorRef.current?.selectionEnd ?? currentValue.length
|
|
2212
2141
|
})
|
|
2213
2142
|
}), []);
|
|
2214
|
-
|
|
2143
|
+
useLayoutEffect5(() => {
|
|
2215
2144
|
composingRef.current = false;
|
|
2216
2145
|
}, [generation]);
|
|
2217
|
-
|
|
2146
|
+
useLayoutEffect5(() => {
|
|
2218
2147
|
const editor = editorRef.current;
|
|
2219
2148
|
if (!editor)
|
|
2220
2149
|
return;
|
|
@@ -2242,17 +2171,16 @@ var PlainEditor = forwardRef3(({
|
|
|
2242
2171
|
window.removeEventListener("resize", measure);
|
|
2243
2172
|
};
|
|
2244
2173
|
}, [value, minimumRows, maximumRows, textareaProps?.style]);
|
|
2245
|
-
|
|
2246
|
-
...
|
|
2174
|
+
const control = /* @__PURE__ */ jsx4("textarea", {
|
|
2175
|
+
...nativeProps,
|
|
2247
2176
|
ref: editorRef,
|
|
2248
2177
|
className: cn("chat-composer-editor", textareaProps?.className),
|
|
2249
2178
|
value,
|
|
2250
2179
|
disabled,
|
|
2251
2180
|
rows: minimumRows,
|
|
2252
|
-
resize: "none",
|
|
2253
2181
|
"aria-label": textareaProps?.["aria-label"] ?? (textareaProps?.["aria-labelledby"] ? undefined : "Message"),
|
|
2254
2182
|
"aria-describedby": cn(textareaProps?.["aria-describedby"], hasError && `${composerId}-error`) || undefined,
|
|
2255
|
-
"aria-invalid": hasError ? true : textareaProps?.["aria-invalid"],
|
|
2183
|
+
"aria-invalid": hasError || textareaProps?.status === "error" ? true : textareaProps?.["aria-invalid"],
|
|
2256
2184
|
"aria-controls": showCompletion ? `${composerId}-completions` : undefined,
|
|
2257
2185
|
"aria-autocomplete": hasCompletion ? "list" : undefined,
|
|
2258
2186
|
"aria-haspopup": hasCompletion ? "listbox" : undefined,
|
|
@@ -2273,22 +2201,37 @@ var PlainEditor = forwardRef3(({
|
|
|
2273
2201
|
onKeyDown(event);
|
|
2274
2202
|
}
|
|
2275
2203
|
});
|
|
2204
|
+
return showCount ? /* @__PURE__ */ jsxs4("span", {
|
|
2205
|
+
className: textAreaWrapperClass,
|
|
2206
|
+
children: [
|
|
2207
|
+
control,
|
|
2208
|
+
/* @__PURE__ */ jsxs4("span", {
|
|
2209
|
+
className: getTextAreaCountClasses({
|
|
2210
|
+
exceeded: textareaProps?.maxLength !== undefined && value.length > textareaProps.maxLength
|
|
2211
|
+
}),
|
|
2212
|
+
children: [
|
|
2213
|
+
value.length,
|
|
2214
|
+
textareaProps?.maxLength !== undefined ? ` / ${textareaProps.maxLength}` : null
|
|
2215
|
+
]
|
|
2216
|
+
})
|
|
2217
|
+
]
|
|
2218
|
+
}) : control;
|
|
2276
2219
|
});
|
|
2277
2220
|
PlainEditor.displayName = "PlainEditor";
|
|
2278
2221
|
|
|
2279
2222
|
// src/components/chat/composer/PlainSemanticEditor.tsx
|
|
2280
|
-
import { jsx as
|
|
2223
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2281
2224
|
function isPlainComposerDocument(document2) {
|
|
2282
2225
|
return !document2.command && document2.content.every((node) => node.type === "text");
|
|
2283
2226
|
}
|
|
2284
|
-
var PlainSemanticEditor =
|
|
2227
|
+
var PlainSemanticEditor = forwardRef3((props, ref) => {
|
|
2285
2228
|
const editor = useRef4(null);
|
|
2286
2229
|
const originId = useId2();
|
|
2287
2230
|
const latest = useRef4(props);
|
|
2288
2231
|
const revision = useRef4(props.value.revision);
|
|
2289
2232
|
const pendingCaret = useRef4(undefined);
|
|
2290
2233
|
const text = props.value.document.content.map((node) => node.type === "text" ? node.text : "").join("");
|
|
2291
|
-
|
|
2234
|
+
useLayoutEffect6(() => {
|
|
2292
2235
|
latest.current = props;
|
|
2293
2236
|
revision.current = Math.max(revision.current, props.value.revision);
|
|
2294
2237
|
const caret = pendingCaret.current;
|
|
@@ -2299,7 +2242,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2299
2242
|
pendingCaret.current = undefined;
|
|
2300
2243
|
}
|
|
2301
2244
|
});
|
|
2302
|
-
|
|
2245
|
+
useLayoutEffect6(() => {
|
|
2303
2246
|
latest.current.onReady?.(true);
|
|
2304
2247
|
return () => latest.current.onReady?.(false);
|
|
2305
2248
|
}, []);
|
|
@@ -2339,7 +2282,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2339
2282
|
}
|
|
2340
2283
|
return latest.current.value.document.content.length ? null : { nodeIndex: 0, start: 0, end: 0 };
|
|
2341
2284
|
}
|
|
2342
|
-
|
|
2285
|
+
useImperativeHandle2(ref, () => ({
|
|
2343
2286
|
focus: () => editor.current?.focus(),
|
|
2344
2287
|
selection,
|
|
2345
2288
|
insertText: (value) => {
|
|
@@ -2379,7 +2322,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2379
2322
|
return true;
|
|
2380
2323
|
}
|
|
2381
2324
|
}), [change]);
|
|
2382
|
-
return /* @__PURE__ */
|
|
2325
|
+
return /* @__PURE__ */ jsx5(PlainEditor, {
|
|
2383
2326
|
ref: editor,
|
|
2384
2327
|
value: text,
|
|
2385
2328
|
disabled: !!props.disabled,
|
|
@@ -2417,7 +2360,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2417
2360
|
PlainSemanticEditor.displayName = "PlainSemanticEditor";
|
|
2418
2361
|
|
|
2419
2362
|
// src/components/chat/composer/PreservedDraft.tsx
|
|
2420
|
-
import { jsx as
|
|
2363
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2421
2364
|
function PreservedDraft({
|
|
2422
2365
|
input,
|
|
2423
2366
|
reason,
|
|
@@ -2443,10 +2386,10 @@ function PreservedDraft({
|
|
|
2443
2386
|
" Your draft is preserved."
|
|
2444
2387
|
]
|
|
2445
2388
|
}),
|
|
2446
|
-
/* @__PURE__ */
|
|
2389
|
+
/* @__PURE__ */ jsx6("pre", {
|
|
2447
2390
|
children: document2.status === "compatible" ? exportComposerText(document2.value) : json ?? "The application retains the original incompatible input."
|
|
2448
2391
|
}),
|
|
2449
|
-
json ? /* @__PURE__ */
|
|
2392
|
+
json ? /* @__PURE__ */ jsx6("a", {
|
|
2450
2393
|
download: "composer-draft.json",
|
|
2451
2394
|
href: `data:application/json;charset=utf-8,${encodeURIComponent(json)}`,
|
|
2452
2395
|
children: "Export preserved draft"
|
|
@@ -2466,7 +2409,7 @@ function PreservedDraft({
|
|
|
2466
2409
|
import { useId as useId3 } from "react";
|
|
2467
2410
|
|
|
2468
2411
|
// src/components/chat/composer/useComposerDraft.ts
|
|
2469
|
-
import { useLayoutEffect as
|
|
2412
|
+
import { useLayoutEffect as useLayoutEffect7, useState as useState5, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
2470
2413
|
|
|
2471
2414
|
// src/components/chat/composer/drafts.ts
|
|
2472
2415
|
function error2(cause, code) {
|
|
@@ -2832,18 +2775,18 @@ function createComposerDraftController(context) {
|
|
|
2832
2775
|
function useComposerDraft(context) {
|
|
2833
2776
|
const [controller] = useState5(() => createComposerDraftController(context));
|
|
2834
2777
|
const snapshot = useSyncExternalStore4(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
2835
|
-
|
|
2778
|
+
useLayoutEffect7(() => {
|
|
2836
2779
|
controller.activate();
|
|
2837
2780
|
return () => controller.dispose();
|
|
2838
2781
|
}, [controller]);
|
|
2839
|
-
|
|
2782
|
+
useLayoutEffect7(() => {
|
|
2840
2783
|
controller.update(context);
|
|
2841
2784
|
});
|
|
2842
2785
|
return { controller, snapshot };
|
|
2843
2786
|
}
|
|
2844
2787
|
|
|
2845
2788
|
// src/components/chat/composer/DraftLifecycle.tsx
|
|
2846
|
-
import { jsx as
|
|
2789
|
+
import { jsx as jsx7, jsxs as jsxs6, Fragment as Fragment4 } from "react/jsx-runtime";
|
|
2847
2790
|
function DraftLifecycle({
|
|
2848
2791
|
adapter,
|
|
2849
2792
|
scope,
|
|
@@ -2852,7 +2795,9 @@ function DraftLifecycle({
|
|
|
2852
2795
|
value,
|
|
2853
2796
|
attachments,
|
|
2854
2797
|
onDocumentChange,
|
|
2855
|
-
disabled
|
|
2798
|
+
disabled,
|
|
2799
|
+
compact = false,
|
|
2800
|
+
children
|
|
2856
2801
|
}) {
|
|
2857
2802
|
const originId = `${useId3()}-draft`;
|
|
2858
2803
|
function restore(draft) {
|
|
@@ -2876,25 +2821,25 @@ function DraftLifecycle({
|
|
|
2876
2821
|
onRestore: restore
|
|
2877
2822
|
});
|
|
2878
2823
|
const blocked = disabled || snapshot.saving || snapshot.status === "idle" || snapshot.status === "loading" || snapshot.restorePending || snapshot.status === "incompatible" && !snapshot.overwriteAllowed || snapshot.status === "error" && snapshot.errorOperation !== "save";
|
|
2879
|
-
|
|
2880
|
-
|
|
2881
|
-
"aria-label": "Draft storage",
|
|
2824
|
+
const status = snapshot.status === "loading" ? "Loading stored draft…" : snapshot.saving ? "Saving draft…" : snapshot.lastSavedRevision === value.revision ? "Draft saved by host storage." : snapshot.loaded?.applied ? "Stored draft restored." : "Draft storage is provided by the host.";
|
|
2825
|
+
const feedback = /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2882
2826
|
children: [
|
|
2883
|
-
/* @__PURE__ */
|
|
2827
|
+
/* @__PURE__ */ jsx7("div", {
|
|
2884
2828
|
role: "status",
|
|
2885
|
-
|
|
2829
|
+
className: compact ? "sr-only" : undefined,
|
|
2830
|
+
children: status
|
|
2886
2831
|
}),
|
|
2887
|
-
snapshot.error ? /* @__PURE__ */
|
|
2832
|
+
snapshot.error ? /* @__PURE__ */ jsx7("p", {
|
|
2888
2833
|
role: "alert",
|
|
2889
2834
|
children: snapshot.error.message
|
|
2890
2835
|
}) : null,
|
|
2891
|
-
snapshot.incompatible ? /* @__PURE__ */ jsxs6(
|
|
2836
|
+
snapshot.incompatible ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2892
2837
|
children: [
|
|
2893
|
-
/* @__PURE__ */
|
|
2838
|
+
/* @__PURE__ */ jsx7(PreservedDraft, {
|
|
2894
2839
|
input: snapshot.incompatible.input,
|
|
2895
2840
|
reason: snapshot.incompatible.reason
|
|
2896
2841
|
}),
|
|
2897
|
-
!snapshot.overwriteAllowed ? /* @__PURE__ */
|
|
2842
|
+
!snapshot.overwriteAllowed ? /* @__PURE__ */ jsx7("button", {
|
|
2898
2843
|
type: "button",
|
|
2899
2844
|
disabled,
|
|
2900
2845
|
onClick: () => {
|
|
@@ -2905,14 +2850,14 @@ function DraftLifecycle({
|
|
|
2905
2850
|
}) : null
|
|
2906
2851
|
]
|
|
2907
2852
|
}) : null,
|
|
2908
|
-
snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs6(
|
|
2853
|
+
snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2909
2854
|
children: [
|
|
2910
|
-
/* @__PURE__ */
|
|
2855
|
+
/* @__PURE__ */ jsx7(PreservedDraft, {
|
|
2911
2856
|
input: snapshot.loaded.draft,
|
|
2912
2857
|
reason: "A stored draft arrived after editing. Your current draft is preserved.",
|
|
2913
2858
|
state: "pending"
|
|
2914
2859
|
}),
|
|
2915
|
-
/* @__PURE__ */
|
|
2860
|
+
/* @__PURE__ */ jsx7("button", {
|
|
2916
2861
|
type: "button",
|
|
2917
2862
|
disabled,
|
|
2918
2863
|
onClick: () => {
|
|
@@ -2922,14 +2867,81 @@ function DraftLifecycle({
|
|
|
2922
2867
|
children: "Restore stored draft"
|
|
2923
2868
|
})
|
|
2924
2869
|
]
|
|
2925
|
-
}) : null
|
|
2926
|
-
|
|
2870
|
+
}) : null
|
|
2871
|
+
]
|
|
2872
|
+
});
|
|
2873
|
+
const actions = compact ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2874
|
+
children: [
|
|
2875
|
+
/* @__PURE__ */ jsxs6("button", {
|
|
2876
|
+
type: "button",
|
|
2877
|
+
className: "popover-menu-item",
|
|
2878
|
+
title: status,
|
|
2879
|
+
disabled: blocked,
|
|
2880
|
+
onClick: (event) => {
|
|
2881
|
+
controller.save();
|
|
2882
|
+
event.currentTarget.closest("[popover]")?.hidePopover?.();
|
|
2883
|
+
},
|
|
2884
|
+
children: [
|
|
2885
|
+
/* @__PURE__ */ jsx7("svg", {
|
|
2886
|
+
width: "18",
|
|
2887
|
+
height: "18",
|
|
2888
|
+
viewBox: "0 0 24 24",
|
|
2889
|
+
fill: "none",
|
|
2890
|
+
stroke: "currentColor",
|
|
2891
|
+
strokeWidth: "2",
|
|
2892
|
+
strokeLinecap: "round",
|
|
2893
|
+
strokeLinejoin: "round",
|
|
2894
|
+
"aria-hidden": "true",
|
|
2895
|
+
focusable: "false",
|
|
2896
|
+
children: /* @__PURE__ */ jsx7("path", {
|
|
2897
|
+
d: "M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h12l4 4v12a2 2 0 0 1-2 2ZM7 3v6h10V3M7 21v-8h10v8"
|
|
2898
|
+
})
|
|
2899
|
+
}),
|
|
2900
|
+
/* @__PURE__ */ jsx7("span", {
|
|
2901
|
+
children: "Save draft"
|
|
2902
|
+
})
|
|
2903
|
+
]
|
|
2904
|
+
}),
|
|
2905
|
+
/* @__PURE__ */ jsxs6("button", {
|
|
2906
|
+
type: "button",
|
|
2907
|
+
className: "popover-menu-item",
|
|
2908
|
+
title: "Reload stored draft",
|
|
2909
|
+
disabled: disabled || snapshot.status === "loading" || snapshot.saving,
|
|
2910
|
+
onClick: (event) => {
|
|
2911
|
+
controller.reload();
|
|
2912
|
+
event.currentTarget.closest("[popover]")?.hidePopover?.();
|
|
2913
|
+
},
|
|
2914
|
+
children: [
|
|
2915
|
+
/* @__PURE__ */ jsx7("svg", {
|
|
2916
|
+
width: "18",
|
|
2917
|
+
height: "18",
|
|
2918
|
+
viewBox: "0 0 24 24",
|
|
2919
|
+
fill: "none",
|
|
2920
|
+
stroke: "currentColor",
|
|
2921
|
+
strokeWidth: "2",
|
|
2922
|
+
strokeLinecap: "round",
|
|
2923
|
+
strokeLinejoin: "round",
|
|
2924
|
+
"aria-hidden": "true",
|
|
2925
|
+
focusable: "false",
|
|
2926
|
+
children: /* @__PURE__ */ jsx7("path", {
|
|
2927
|
+
d: "M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7"
|
|
2928
|
+
})
|
|
2929
|
+
}),
|
|
2930
|
+
/* @__PURE__ */ jsx7("span", {
|
|
2931
|
+
children: "Reload stored draft"
|
|
2932
|
+
})
|
|
2933
|
+
]
|
|
2934
|
+
})
|
|
2935
|
+
]
|
|
2936
|
+
}) : /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2937
|
+
children: [
|
|
2938
|
+
/* @__PURE__ */ jsx7("button", {
|
|
2927
2939
|
type: "button",
|
|
2928
2940
|
disabled: blocked,
|
|
2929
2941
|
onClick: () => void controller.save(),
|
|
2930
2942
|
children: "Save draft"
|
|
2931
2943
|
}),
|
|
2932
|
-
/* @__PURE__ */
|
|
2944
|
+
/* @__PURE__ */ jsx7("button", {
|
|
2933
2945
|
type: "button",
|
|
2934
2946
|
disabled: disabled || snapshot.status === "loading" || snapshot.saving,
|
|
2935
2947
|
onClick: () => void controller.reload(),
|
|
@@ -2937,11 +2949,19 @@ function DraftLifecycle({
|
|
|
2937
2949
|
})
|
|
2938
2950
|
]
|
|
2939
2951
|
});
|
|
2952
|
+
return compact ? children(feedback, actions) : children(/* @__PURE__ */ jsxs6("div", {
|
|
2953
|
+
className: "chat-composer-status",
|
|
2954
|
+
"aria-label": "Draft storage",
|
|
2955
|
+
children: [
|
|
2956
|
+
feedback,
|
|
2957
|
+
actions
|
|
2958
|
+
]
|
|
2959
|
+
}));
|
|
2940
2960
|
}
|
|
2941
2961
|
|
|
2942
2962
|
// src/components/chat/composer/SemanticComposer.tsx
|
|
2943
|
-
import { jsx as
|
|
2944
|
-
var SemanticComposer =
|
|
2963
|
+
import { jsx as jsx8, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-runtime";
|
|
2964
|
+
var SemanticComposer = forwardRef4(({
|
|
2945
2965
|
Editor,
|
|
2946
2966
|
structured,
|
|
2947
2967
|
value,
|
|
@@ -2960,6 +2980,8 @@ var SemanticComposer = forwardRef5(({
|
|
|
2960
2980
|
busy = false,
|
|
2961
2981
|
canSubmit = true,
|
|
2962
2982
|
allowAttachmentOnly = false,
|
|
2983
|
+
compact = false,
|
|
2984
|
+
addMenu,
|
|
2963
2985
|
onStop,
|
|
2964
2986
|
label = "Message",
|
|
2965
2987
|
attachLabel = "Attach files",
|
|
@@ -2988,13 +3010,13 @@ var SemanticComposer = forwardRef5(({
|
|
|
2988
3010
|
const changedScope = !sameComposerScope(observed.current.scope, scope) || observed.current.draftKey !== draftKey;
|
|
2989
3011
|
const generation = observed.current.generation + (changedScope ? 1 : 0);
|
|
2990
3012
|
const alive = useRef5(false);
|
|
2991
|
-
|
|
3013
|
+
useLayoutEffect8(() => {
|
|
2992
3014
|
alive.current = true;
|
|
2993
3015
|
return () => {
|
|
2994
3016
|
alive.current = false;
|
|
2995
3017
|
};
|
|
2996
3018
|
}, []);
|
|
2997
|
-
|
|
3019
|
+
useLayoutEffect8(() => {
|
|
2998
3020
|
if (changedScope)
|
|
2999
3021
|
observed.current = { scope: { ...scope }, draftKey, generation };
|
|
3000
3022
|
}, [
|
|
@@ -3079,10 +3101,13 @@ var SemanticComposer = forwardRef5(({
|
|
|
3079
3101
|
const completion = useComposerProviders(providerContext);
|
|
3080
3102
|
const popup = completion.snapshot.status !== "idle";
|
|
3081
3103
|
const candidates = completion.snapshot.items.map((item) => {
|
|
3104
|
+
const provider = providers.find((entry) => entry.providerId === item.providerId);
|
|
3082
3105
|
const reason = item.candidate.disabledReason ?? candidateDisabledReason(item.candidate);
|
|
3083
3106
|
return {
|
|
3084
3107
|
id: item.id,
|
|
3085
3108
|
label: item.candidate.label,
|
|
3109
|
+
icon: provider?.icon,
|
|
3110
|
+
sourceLabel: provider?.sourceLabel,
|
|
3086
3111
|
description: reason ?? item.candidate.description,
|
|
3087
3112
|
disabled: reason !== undefined,
|
|
3088
3113
|
group: item.candidate.group ?? completion.snapshot.groups.find((group) => group.providerId === item.providerId)?.label
|
|
@@ -3092,7 +3117,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3092
3117
|
const showCompletion = popup && candidates.length > 0;
|
|
3093
3118
|
const visibleError = error ?? localError ?? session.snapshot.error?.message;
|
|
3094
3119
|
const hasError = visibleError !== undefined && visibleError !== null && visibleError !== false;
|
|
3095
|
-
|
|
3120
|
+
useImperativeHandle3(forwardedRef, () => ({
|
|
3096
3121
|
focus: () => editor.current?.focus(),
|
|
3097
3122
|
selection: () => editor.current?.selection() ?? null,
|
|
3098
3123
|
insertReference: (node) => {
|
|
@@ -3148,16 +3173,19 @@ var SemanticComposer = forwardRef5(({
|
|
|
3148
3173
|
}
|
|
3149
3174
|
editor.current?.focus();
|
|
3150
3175
|
}
|
|
3151
|
-
|
|
3176
|
+
const compactImages = compact && attachmentsCurrent && attachments.entries.length > 0 && attachments.entries.every((entry) => entry.state.status === "ready" && entry.metadata.mediaType.startsWith("image/") && !!attachments.controller.previewUrl(entry.entryId));
|
|
3177
|
+
return /* @__PURE__ */ jsx8(ComposerShell, {
|
|
3152
3178
|
...rootProps,
|
|
3153
3179
|
className,
|
|
3154
3180
|
composerId: id,
|
|
3181
|
+
compact,
|
|
3182
|
+
addMenu,
|
|
3155
3183
|
entries: (attachmentsCurrent ? attachments.entries : []).map((entry) => ({
|
|
3156
3184
|
id: entry.entryId,
|
|
3157
3185
|
name: entry.metadata.name,
|
|
3158
3186
|
previewUrl: attachments.controller.previewUrl(entry.entryId),
|
|
3159
3187
|
state: entry.state.status === "preparing" ? "validating" : entry.state.status,
|
|
3160
|
-
status: entry.state.status === "error" ? entry.state.error.message : entry.state.status === "reattach" ? "Select this file again to restore it" : entry.state.status === "ready" ? "Ready" : entry.state.status,
|
|
3188
|
+
status: entry.state.status === "error" ? entry.state.error.message : entry.state.status === "reattach" ? "Select this file again to restore it" : entry.state.status === "ready" ? compactImages ? undefined : "Ready" : entry.state.status,
|
|
3161
3189
|
...entry.state.status === "preparing" || entry.state.status === "uploading" ? {
|
|
3162
3190
|
progress: entry.state.progress,
|
|
3163
3191
|
cancel: () => attachments.controller.cancel(entry.entryId)
|
|
@@ -3207,23 +3235,24 @@ var SemanticComposer = forwardRef5(({
|
|
|
3207
3235
|
active,
|
|
3208
3236
|
showCompletion,
|
|
3209
3237
|
selectCompletion: selectCandidate,
|
|
3238
|
+
dismissCompletion: () => completion.controller.dismiss(),
|
|
3210
3239
|
completionHeader: completion.snapshot.breadcrumbs.length ? /* @__PURE__ */ jsxs7("nav", {
|
|
3211
3240
|
"aria-label": "Suggestion folders",
|
|
3212
3241
|
className: "chat-composer-breadcrumb",
|
|
3213
3242
|
children: [
|
|
3214
|
-
/* @__PURE__ */
|
|
3243
|
+
/* @__PURE__ */ jsx8("button", {
|
|
3215
3244
|
type: "button",
|
|
3216
3245
|
onMouseDown: (event) => event.preventDefault(),
|
|
3217
3246
|
onClick: () => completion.controller.back(0),
|
|
3218
3247
|
children: "All results"
|
|
3219
3248
|
}),
|
|
3220
|
-
completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */
|
|
3249
|
+
completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsx8("button", {
|
|
3221
3250
|
type: "button",
|
|
3222
3251
|
onMouseDown: (event) => event.preventDefault(),
|
|
3223
3252
|
onClick: () => completion.controller.back(index + 1),
|
|
3224
3253
|
children: crumb.label
|
|
3225
3254
|
}, crumb.refId)),
|
|
3226
|
-
/* @__PURE__ */
|
|
3255
|
+
/* @__PURE__ */ jsx8("span", {
|
|
3227
3256
|
className: "chat-composer-hint",
|
|
3228
3257
|
children: "Alt+Left returns to the parent folder."
|
|
3229
3258
|
})
|
|
@@ -3234,7 +3263,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3234
3263
|
className: "chat-composer-status",
|
|
3235
3264
|
children: [
|
|
3236
3265
|
completion.snapshot.status === "loading" ? "Loading suggestions…" : completion.snapshot.status === "empty" ? "No suggestions" : completion.snapshot.error?.message ?? "Some suggestions could not be loaded",
|
|
3237
|
-
completion.snapshot.status === "error" ? /* @__PURE__ */
|
|
3266
|
+
completion.snapshot.status === "error" ? /* @__PURE__ */ jsx8("button", {
|
|
3238
3267
|
type: "button",
|
|
3239
3268
|
onClick: () => completion.controller.retry(),
|
|
3240
3269
|
children: "Retry suggestions"
|
|
@@ -3243,18 +3272,8 @@ var SemanticComposer = forwardRef5(({
|
|
|
3243
3272
|
}) : null,
|
|
3244
3273
|
visibleError,
|
|
3245
3274
|
hasError,
|
|
3246
|
-
statusContent: /* @__PURE__ */ jsxs7(
|
|
3275
|
+
statusContent: /* @__PURE__ */ jsxs7(Fragment5, {
|
|
3247
3276
|
children: [
|
|
3248
|
-
draftAdapter && attachmentsCurrent && read.status === "compatible" ? /* @__PURE__ */ jsx9(DraftLifecycle, {
|
|
3249
|
-
adapter: draftAdapter,
|
|
3250
|
-
scope,
|
|
3251
|
-
draftKey,
|
|
3252
|
-
generation,
|
|
3253
|
-
value,
|
|
3254
|
-
attachments: attachments.controller,
|
|
3255
|
-
onDocumentChange,
|
|
3256
|
-
disabled: disabled || runtime.status === "read_only"
|
|
3257
|
-
}, generation) : null,
|
|
3258
3277
|
attachmentsCurrent && attachments.rejections.length ? /* @__PURE__ */ jsxs7("div", {
|
|
3259
3278
|
role: "alert",
|
|
3260
3279
|
className: "chat-composer-status",
|
|
@@ -3267,58 +3286,80 @@ var SemanticComposer = forwardRef5(({
|
|
|
3267
3286
|
item.error.message
|
|
3268
3287
|
]
|
|
3269
3288
|
}, `${index}-${item.metadata.name}`)),
|
|
3270
|
-
/* @__PURE__ */
|
|
3289
|
+
/* @__PURE__ */ jsx8("button", {
|
|
3271
3290
|
type: "button",
|
|
3272
3291
|
onClick: () => attachments.controller.clearRejections(),
|
|
3273
3292
|
children: "Dismiss attachment errors"
|
|
3274
3293
|
})
|
|
3275
3294
|
]
|
|
3276
3295
|
}) : null,
|
|
3277
|
-
recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => /* @__PURE__ */
|
|
3296
|
+
recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => compact && attempt.status === "pending" ? /* @__PURE__ */ jsx8("p", {
|
|
3297
|
+
role: "status",
|
|
3298
|
+
className: "sr-only",
|
|
3299
|
+
"data-state": "pending",
|
|
3300
|
+
children: "Awaiting admission"
|
|
3301
|
+
}, attempt.snapshot.clientSubmissionId) : /* @__PURE__ */ jsxs7("details", {
|
|
3278
3302
|
className: "chat-composer-status",
|
|
3279
3303
|
"data-state": attempt.status,
|
|
3280
3304
|
children: [
|
|
3281
|
-
/* @__PURE__ */
|
|
3305
|
+
/* @__PURE__ */ jsx8("summary", {
|
|
3282
3306
|
children: attempt.status === "unknown" ? "Submission outcome unknown — draft retained" : "Awaiting admission"
|
|
3283
3307
|
}),
|
|
3284
|
-
/* @__PURE__ */
|
|
3308
|
+
/* @__PURE__ */ jsx8("p", {
|
|
3285
3309
|
children: attempt.snapshot.clientSubmissionId
|
|
3286
3310
|
}),
|
|
3287
|
-
attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */
|
|
3311
|
+
attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */ jsx8("p", {
|
|
3288
3312
|
children: attempt.receipt.error.message
|
|
3289
3313
|
}) : null,
|
|
3290
|
-
host.reconcile ? /* @__PURE__ */
|
|
3314
|
+
host.reconcile ? /* @__PURE__ */ jsx8("button", {
|
|
3291
3315
|
type: "button",
|
|
3292
3316
|
onClick: () => {
|
|
3293
3317
|
session.controller.reconcile(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
|
|
3294
3318
|
},
|
|
3295
3319
|
children: "Check submission status"
|
|
3296
3320
|
}) : null,
|
|
3297
|
-
attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */
|
|
3321
|
+
attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */ jsx8("button", {
|
|
3298
3322
|
type: "button",
|
|
3299
3323
|
onClick: () => {
|
|
3300
3324
|
session.controller.retry(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
|
|
3301
3325
|
},
|
|
3302
3326
|
children: "Request authorized retry"
|
|
3303
3327
|
}) : null,
|
|
3304
|
-
/* @__PURE__ */
|
|
3328
|
+
/* @__PURE__ */ jsx8(PreservedDraft, {
|
|
3305
3329
|
input: attempt.snapshot.document,
|
|
3306
3330
|
reason: "Submitted snapshot",
|
|
3307
3331
|
state: attempt.status === "unknown" ? "unknown" : "pending"
|
|
3308
3332
|
})
|
|
3309
3333
|
]
|
|
3310
3334
|
}, attempt.snapshot.clientSubmissionId)),
|
|
3311
|
-
session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */
|
|
3335
|
+
session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */ jsx8(PreservedDraft, {
|
|
3312
3336
|
input: attempt,
|
|
3313
3337
|
reason: "The host could not retain this submission. Export its recovery record before leaving."
|
|
3314
3338
|
}, attempt.snapshot.clientSubmissionId)),
|
|
3315
|
-
session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */
|
|
3339
|
+
session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */ jsx8("div", {
|
|
3316
3340
|
role: "status",
|
|
3317
|
-
className: "chat-composer-status",
|
|
3341
|
+
className: compact ? "sr-only" : "chat-composer-status",
|
|
3318
3342
|
children: session.snapshot.lastReceipt.operation === "command" ? "Command completed" : `Admitted: ${session.snapshot.lastReceipt.delivery} (${session.snapshot.lastReceipt.persistence})`
|
|
3319
3343
|
}) : null
|
|
3320
3344
|
]
|
|
3321
3345
|
}),
|
|
3346
|
+
renderFooter: (renderToolbar) => draftAdapter && attachmentsCurrent && read.status === "compatible" ? /* @__PURE__ */ jsx8(DraftLifecycle, {
|
|
3347
|
+
compact,
|
|
3348
|
+
adapter: draftAdapter,
|
|
3349
|
+
scope,
|
|
3350
|
+
draftKey,
|
|
3351
|
+
generation,
|
|
3352
|
+
value,
|
|
3353
|
+
attachments: attachments.controller,
|
|
3354
|
+
onDocumentChange,
|
|
3355
|
+
disabled: disabled || runtime.status === "read_only",
|
|
3356
|
+
children: (feedback, actions) => /* @__PURE__ */ jsxs7(Fragment5, {
|
|
3357
|
+
children: [
|
|
3358
|
+
feedback,
|
|
3359
|
+
renderToolbar(actions)
|
|
3360
|
+
]
|
|
3361
|
+
})
|
|
3362
|
+
}, `draft-${generation}`) : renderToolbar(),
|
|
3322
3363
|
attachLabel,
|
|
3323
3364
|
sendLabel: action.label,
|
|
3324
3365
|
stopLabel,
|
|
@@ -3328,7 +3369,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3328
3369
|
},
|
|
3329
3370
|
submit,
|
|
3330
3371
|
onStop,
|
|
3331
|
-
editor: editAvailable ? /* @__PURE__ */
|
|
3372
|
+
editor: editAvailable ? /* @__PURE__ */ jsx8(Editor, {
|
|
3332
3373
|
ref: editor,
|
|
3333
3374
|
value,
|
|
3334
3375
|
instanceGeneration: generation,
|
|
@@ -3381,7 +3422,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3381
3422
|
submit();
|
|
3382
3423
|
}
|
|
3383
3424
|
}
|
|
3384
|
-
}, generation) : /* @__PURE__ */
|
|
3425
|
+
}, generation) : /* @__PURE__ */ jsx8(PreservedDraft, {
|
|
3385
3426
|
input: value.document,
|
|
3386
3427
|
reason: editorError?.message ?? (read.status === "incompatible" ? read.reason : "This draft requires the optional rich editor.")
|
|
3387
3428
|
}),
|
|
@@ -3391,8 +3432,8 @@ var SemanticComposer = forwardRef5(({
|
|
|
3391
3432
|
SemanticComposer.displayName = "SemanticComposer";
|
|
3392
3433
|
|
|
3393
3434
|
// src/components/chat/rich/RichChatComposer.tsx
|
|
3394
|
-
import { jsx as
|
|
3395
|
-
var LazyLexicalEditor = lazy(() => (__preload("
|
|
3435
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
3436
|
+
var LazyLexicalEditor = lazy(() => (__preload("rd10x4gc"), import("../../../chunk-rd10x4gc.js")));
|
|
3396
3437
|
|
|
3397
3438
|
class EditorBoundary extends Component {
|
|
3398
3439
|
state = {};
|
|
@@ -3403,29 +3444,29 @@ class EditorBoundary extends Component {
|
|
|
3403
3444
|
this.props.onError?.(error);
|
|
3404
3445
|
}
|
|
3405
3446
|
render() {
|
|
3406
|
-
return this.state.error ? /* @__PURE__ */
|
|
3447
|
+
return this.state.error ? /* @__PURE__ */ jsx9(PreservedDraft, {
|
|
3407
3448
|
input: this.props.input,
|
|
3408
3449
|
reason: this.state.error.message
|
|
3409
3450
|
}) : this.props.children;
|
|
3410
3451
|
}
|
|
3411
3452
|
}
|
|
3412
|
-
var OptionalEditor =
|
|
3453
|
+
var OptionalEditor = forwardRef5((props, ref) => /* @__PURE__ */ jsx9(EditorBoundary, {
|
|
3413
3454
|
input: props.value.document,
|
|
3414
3455
|
onError: props.onError,
|
|
3415
|
-
children: /* @__PURE__ */
|
|
3416
|
-
fallback: /* @__PURE__ */
|
|
3456
|
+
children: /* @__PURE__ */ jsx9(Suspense, {
|
|
3457
|
+
fallback: /* @__PURE__ */ jsx9(PreservedDraft, {
|
|
3417
3458
|
input: props.value.document,
|
|
3418
3459
|
reason: "Loading rich editor.",
|
|
3419
3460
|
state: "pending"
|
|
3420
3461
|
}),
|
|
3421
|
-
children: /* @__PURE__ */
|
|
3462
|
+
children: /* @__PURE__ */ jsx9(LazyLexicalEditor, {
|
|
3422
3463
|
...props,
|
|
3423
3464
|
ref
|
|
3424
3465
|
})
|
|
3425
3466
|
})
|
|
3426
3467
|
}));
|
|
3427
3468
|
OptionalEditor.displayName = "OptionalComposerEditor";
|
|
3428
|
-
var RichChatComposer =
|
|
3469
|
+
var RichChatComposer = forwardRef5((props, ref) => /* @__PURE__ */ jsx9(SemanticComposer, {
|
|
3429
3470
|
...props,
|
|
3430
3471
|
ref,
|
|
3431
3472
|
Editor: OptionalEditor,
|