@duskmoon-dev/components 0.6.0 → 0.6.2
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 +837 -660
- package/dist/components/chat/rich/index.js +655 -604
- package/dist/generated/version.d.ts +1 -1
- package/dist/index.js +1950 -1541
- package/dist/infrastructure.js +1 -1
- package/dist/styles.css +184 -5
- 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,["actqdgcw","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) {
|
|
@@ -1618,6 +1852,16 @@ function snapshotComposerReceipt(input, submission) {
|
|
|
1618
1852
|
throw new TypeError("Unsupported receipt fields");
|
|
1619
1853
|
return value;
|
|
1620
1854
|
}
|
|
1855
|
+
function createSubmissionId() {
|
|
1856
|
+
const webCrypto = globalThis.crypto;
|
|
1857
|
+
if (typeof webCrypto.randomUUID === "function")
|
|
1858
|
+
return webCrypto.randomUUID();
|
|
1859
|
+
const bytes = webCrypto.getRandomValues(new Uint8Array(16));
|
|
1860
|
+
bytes[6] = bytes[6] & 15 | 64;
|
|
1861
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
1862
|
+
const hex = Array.from(bytes, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
1863
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
1864
|
+
}
|
|
1621
1865
|
function createComposerSessionController(initial, identity) {
|
|
1622
1866
|
let context = initial;
|
|
1623
1867
|
let disposed = false;
|
|
@@ -1740,7 +1984,7 @@ function createComposerSessionController(initial, identity) {
|
|
|
1740
1984
|
const action = composerActionEligibility(context, intent);
|
|
1741
1985
|
if (disposed || state.submitting || !action.allowed)
|
|
1742
1986
|
return;
|
|
1743
|
-
const clientSubmissionId = identity.nextSubmissionId?.() ??
|
|
1987
|
+
const clientSubmissionId = identity.nextSubmissionId?.() ?? createSubmissionId();
|
|
1744
1988
|
const common = {
|
|
1745
1989
|
protocolVersion: 1,
|
|
1746
1990
|
clientSubmissionId,
|
|
@@ -1832,13 +2076,13 @@ function createComposerSessionController(initial, identity) {
|
|
|
1832
2076
|
// src/components/chat/composer/useComposerSession.ts
|
|
1833
2077
|
function useComposerSession(context) {
|
|
1834
2078
|
const instanceId = useId();
|
|
1835
|
-
const [controller] =
|
|
2079
|
+
const [controller] = useState4(() => createComposerSessionController(context, { instanceId }));
|
|
1836
2080
|
const snapshot = useSyncExternalStore3(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
1837
|
-
|
|
2081
|
+
useLayoutEffect4(() => {
|
|
1838
2082
|
controller.activate();
|
|
1839
2083
|
return () => controller.dispose();
|
|
1840
2084
|
}, [controller]);
|
|
1841
|
-
|
|
2085
|
+
useLayoutEffect4(() => {
|
|
1842
2086
|
controller.update(context);
|
|
1843
2087
|
});
|
|
1844
2088
|
return { controller, snapshot };
|
|
@@ -1846,343 +2090,33 @@ function useComposerSession(context) {
|
|
|
1846
2090
|
|
|
1847
2091
|
// src/components/chat/composer/PlainSemanticEditor.tsx
|
|
1848
2092
|
import {
|
|
1849
|
-
forwardRef as
|
|
2093
|
+
forwardRef as forwardRef3,
|
|
1850
2094
|
useId as useId2,
|
|
1851
|
-
useImperativeHandle as
|
|
2095
|
+
useImperativeHandle as useImperativeHandle2,
|
|
1852
2096
|
useCallback,
|
|
1853
|
-
useLayoutEffect as
|
|
2097
|
+
useLayoutEffect as useLayoutEffect6,
|
|
1854
2098
|
useRef as useRef4
|
|
1855
2099
|
} from "react";
|
|
1856
2100
|
|
|
1857
2101
|
// 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
2102
|
import {
|
|
1867
2103
|
forwardRef as forwardRef2,
|
|
1868
2104
|
useImperativeHandle,
|
|
1869
|
-
|
|
1870
|
-
|
|
2105
|
+
useLayoutEffect as useLayoutEffect5,
|
|
2106
|
+
useRef as useRef3
|
|
1871
2107
|
} from "react";
|
|
1872
2108
|
|
|
1873
2109
|
// 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
2110
|
var textAreaWrapperClass = "textarea-wrapper";
|
|
1887
2111
|
var textAreaCountClass = "textarea-counter";
|
|
1888
2112
|
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
2113
|
function getTextAreaCountClasses({ exceeded }) {
|
|
1955
2114
|
return cn(textAreaCountClass, exceeded && textAreaCountExceededClass);
|
|
1956
2115
|
}
|
|
1957
2116
|
|
|
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
2117
|
// src/components/chat/composer/PlainEditor.tsx
|
|
2184
|
-
import { jsx as
|
|
2185
|
-
var PlainEditor =
|
|
2118
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2119
|
+
var PlainEditor = forwardRef2(({
|
|
2186
2120
|
value,
|
|
2187
2121
|
disabled,
|
|
2188
2122
|
minRows,
|
|
@@ -2202,7 +2136,12 @@ var PlainEditor = forwardRef3(({
|
|
|
2202
2136
|
const composingRef = useRef3(false);
|
|
2203
2137
|
const minimumRows = Math.max(1, Math.floor(minRows));
|
|
2204
2138
|
const maximumRows = Math.max(minimumRows, Math.floor(maxRows));
|
|
2205
|
-
|
|
2139
|
+
const { showCount, ...nativeProps } = textareaProps ?? {};
|
|
2140
|
+
delete nativeProps.size;
|
|
2141
|
+
delete nativeProps.status;
|
|
2142
|
+
delete nativeProps.variant;
|
|
2143
|
+
delete nativeProps.resize;
|
|
2144
|
+
useImperativeHandle(ref, () => ({
|
|
2206
2145
|
focus: () => editorRef.current?.focus(),
|
|
2207
2146
|
select: (start, end) => editorRef.current?.setSelectionRange(start, end),
|
|
2208
2147
|
selection: (currentValue) => ({
|
|
@@ -2211,10 +2150,10 @@ var PlainEditor = forwardRef3(({
|
|
|
2211
2150
|
selectionEnd: editorRef.current?.selectionEnd ?? currentValue.length
|
|
2212
2151
|
})
|
|
2213
2152
|
}), []);
|
|
2214
|
-
|
|
2153
|
+
useLayoutEffect5(() => {
|
|
2215
2154
|
composingRef.current = false;
|
|
2216
2155
|
}, [generation]);
|
|
2217
|
-
|
|
2156
|
+
useLayoutEffect5(() => {
|
|
2218
2157
|
const editor = editorRef.current;
|
|
2219
2158
|
if (!editor)
|
|
2220
2159
|
return;
|
|
@@ -2242,17 +2181,16 @@ var PlainEditor = forwardRef3(({
|
|
|
2242
2181
|
window.removeEventListener("resize", measure);
|
|
2243
2182
|
};
|
|
2244
2183
|
}, [value, minimumRows, maximumRows, textareaProps?.style]);
|
|
2245
|
-
|
|
2246
|
-
...
|
|
2184
|
+
const control = /* @__PURE__ */ jsx4("textarea", {
|
|
2185
|
+
...nativeProps,
|
|
2247
2186
|
ref: editorRef,
|
|
2248
2187
|
className: cn("chat-composer-editor", textareaProps?.className),
|
|
2249
2188
|
value,
|
|
2250
2189
|
disabled,
|
|
2251
2190
|
rows: minimumRows,
|
|
2252
|
-
resize: "none",
|
|
2253
2191
|
"aria-label": textareaProps?.["aria-label"] ?? (textareaProps?.["aria-labelledby"] ? undefined : "Message"),
|
|
2254
2192
|
"aria-describedby": cn(textareaProps?.["aria-describedby"], hasError && `${composerId}-error`) || undefined,
|
|
2255
|
-
"aria-invalid": hasError ? true : textareaProps?.["aria-invalid"],
|
|
2193
|
+
"aria-invalid": hasError || textareaProps?.status === "error" ? true : textareaProps?.["aria-invalid"],
|
|
2256
2194
|
"aria-controls": showCompletion ? `${composerId}-completions` : undefined,
|
|
2257
2195
|
"aria-autocomplete": hasCompletion ? "list" : undefined,
|
|
2258
2196
|
"aria-haspopup": hasCompletion ? "listbox" : undefined,
|
|
@@ -2273,22 +2211,37 @@ var PlainEditor = forwardRef3(({
|
|
|
2273
2211
|
onKeyDown(event);
|
|
2274
2212
|
}
|
|
2275
2213
|
});
|
|
2214
|
+
return showCount ? /* @__PURE__ */ jsxs4("span", {
|
|
2215
|
+
className: textAreaWrapperClass,
|
|
2216
|
+
children: [
|
|
2217
|
+
control,
|
|
2218
|
+
/* @__PURE__ */ jsxs4("span", {
|
|
2219
|
+
className: getTextAreaCountClasses({
|
|
2220
|
+
exceeded: textareaProps?.maxLength !== undefined && value.length > textareaProps.maxLength
|
|
2221
|
+
}),
|
|
2222
|
+
children: [
|
|
2223
|
+
value.length,
|
|
2224
|
+
textareaProps?.maxLength !== undefined ? ` / ${textareaProps.maxLength}` : null
|
|
2225
|
+
]
|
|
2226
|
+
})
|
|
2227
|
+
]
|
|
2228
|
+
}) : control;
|
|
2276
2229
|
});
|
|
2277
2230
|
PlainEditor.displayName = "PlainEditor";
|
|
2278
2231
|
|
|
2279
2232
|
// src/components/chat/composer/PlainSemanticEditor.tsx
|
|
2280
|
-
import { jsx as
|
|
2233
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
2281
2234
|
function isPlainComposerDocument(document2) {
|
|
2282
2235
|
return !document2.command && document2.content.every((node) => node.type === "text");
|
|
2283
2236
|
}
|
|
2284
|
-
var PlainSemanticEditor =
|
|
2237
|
+
var PlainSemanticEditor = forwardRef3((props, ref) => {
|
|
2285
2238
|
const editor = useRef4(null);
|
|
2286
2239
|
const originId = useId2();
|
|
2287
2240
|
const latest = useRef4(props);
|
|
2288
2241
|
const revision = useRef4(props.value.revision);
|
|
2289
2242
|
const pendingCaret = useRef4(undefined);
|
|
2290
2243
|
const text = props.value.document.content.map((node) => node.type === "text" ? node.text : "").join("");
|
|
2291
|
-
|
|
2244
|
+
useLayoutEffect6(() => {
|
|
2292
2245
|
latest.current = props;
|
|
2293
2246
|
revision.current = Math.max(revision.current, props.value.revision);
|
|
2294
2247
|
const caret = pendingCaret.current;
|
|
@@ -2299,7 +2252,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2299
2252
|
pendingCaret.current = undefined;
|
|
2300
2253
|
}
|
|
2301
2254
|
});
|
|
2302
|
-
|
|
2255
|
+
useLayoutEffect6(() => {
|
|
2303
2256
|
latest.current.onReady?.(true);
|
|
2304
2257
|
return () => latest.current.onReady?.(false);
|
|
2305
2258
|
}, []);
|
|
@@ -2339,7 +2292,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2339
2292
|
}
|
|
2340
2293
|
return latest.current.value.document.content.length ? null : { nodeIndex: 0, start: 0, end: 0 };
|
|
2341
2294
|
}
|
|
2342
|
-
|
|
2295
|
+
useImperativeHandle2(ref, () => ({
|
|
2343
2296
|
focus: () => editor.current?.focus(),
|
|
2344
2297
|
selection,
|
|
2345
2298
|
insertText: (value) => {
|
|
@@ -2379,7 +2332,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2379
2332
|
return true;
|
|
2380
2333
|
}
|
|
2381
2334
|
}), [change]);
|
|
2382
|
-
return /* @__PURE__ */
|
|
2335
|
+
return /* @__PURE__ */ jsx5(PlainEditor, {
|
|
2383
2336
|
ref: editor,
|
|
2384
2337
|
value: text,
|
|
2385
2338
|
disabled: !!props.disabled,
|
|
@@ -2417,7 +2370,7 @@ var PlainSemanticEditor = forwardRef4((props, ref) => {
|
|
|
2417
2370
|
PlainSemanticEditor.displayName = "PlainSemanticEditor";
|
|
2418
2371
|
|
|
2419
2372
|
// src/components/chat/composer/PreservedDraft.tsx
|
|
2420
|
-
import { jsx as
|
|
2373
|
+
import { jsx as jsx6, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
2421
2374
|
function PreservedDraft({
|
|
2422
2375
|
input,
|
|
2423
2376
|
reason,
|
|
@@ -2443,10 +2396,10 @@ function PreservedDraft({
|
|
|
2443
2396
|
" Your draft is preserved."
|
|
2444
2397
|
]
|
|
2445
2398
|
}),
|
|
2446
|
-
/* @__PURE__ */
|
|
2399
|
+
/* @__PURE__ */ jsx6("pre", {
|
|
2447
2400
|
children: document2.status === "compatible" ? exportComposerText(document2.value) : json ?? "The application retains the original incompatible input."
|
|
2448
2401
|
}),
|
|
2449
|
-
json ? /* @__PURE__ */
|
|
2402
|
+
json ? /* @__PURE__ */ jsx6("a", {
|
|
2450
2403
|
download: "composer-draft.json",
|
|
2451
2404
|
href: `data:application/json;charset=utf-8,${encodeURIComponent(json)}`,
|
|
2452
2405
|
children: "Export preserved draft"
|
|
@@ -2466,7 +2419,7 @@ function PreservedDraft({
|
|
|
2466
2419
|
import { useId as useId3 } from "react";
|
|
2467
2420
|
|
|
2468
2421
|
// src/components/chat/composer/useComposerDraft.ts
|
|
2469
|
-
import { useLayoutEffect as
|
|
2422
|
+
import { useLayoutEffect as useLayoutEffect7, useState as useState5, useSyncExternalStore as useSyncExternalStore4 } from "react";
|
|
2470
2423
|
|
|
2471
2424
|
// src/components/chat/composer/drafts.ts
|
|
2472
2425
|
function error2(cause, code) {
|
|
@@ -2832,18 +2785,18 @@ function createComposerDraftController(context) {
|
|
|
2832
2785
|
function useComposerDraft(context) {
|
|
2833
2786
|
const [controller] = useState5(() => createComposerDraftController(context));
|
|
2834
2787
|
const snapshot = useSyncExternalStore4(controller.subscribe, controller.getSnapshot, controller.getSnapshot);
|
|
2835
|
-
|
|
2788
|
+
useLayoutEffect7(() => {
|
|
2836
2789
|
controller.activate();
|
|
2837
2790
|
return () => controller.dispose();
|
|
2838
2791
|
}, [controller]);
|
|
2839
|
-
|
|
2792
|
+
useLayoutEffect7(() => {
|
|
2840
2793
|
controller.update(context);
|
|
2841
2794
|
});
|
|
2842
2795
|
return { controller, snapshot };
|
|
2843
2796
|
}
|
|
2844
2797
|
|
|
2845
2798
|
// src/components/chat/composer/DraftLifecycle.tsx
|
|
2846
|
-
import { jsx as
|
|
2799
|
+
import { jsx as jsx7, jsxs as jsxs6, Fragment as Fragment4 } from "react/jsx-runtime";
|
|
2847
2800
|
function DraftLifecycle({
|
|
2848
2801
|
adapter,
|
|
2849
2802
|
scope,
|
|
@@ -2852,7 +2805,9 @@ function DraftLifecycle({
|
|
|
2852
2805
|
value,
|
|
2853
2806
|
attachments,
|
|
2854
2807
|
onDocumentChange,
|
|
2855
|
-
disabled
|
|
2808
|
+
disabled,
|
|
2809
|
+
compact = false,
|
|
2810
|
+
children
|
|
2856
2811
|
}) {
|
|
2857
2812
|
const originId = `${useId3()}-draft`;
|
|
2858
2813
|
function restore(draft) {
|
|
@@ -2876,25 +2831,25 @@ function DraftLifecycle({
|
|
|
2876
2831
|
onRestore: restore
|
|
2877
2832
|
});
|
|
2878
2833
|
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",
|
|
2834
|
+
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.";
|
|
2835
|
+
const feedback = /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2882
2836
|
children: [
|
|
2883
|
-
/* @__PURE__ */
|
|
2837
|
+
/* @__PURE__ */ jsx7("div", {
|
|
2884
2838
|
role: "status",
|
|
2885
|
-
|
|
2839
|
+
className: compact ? "sr-only" : undefined,
|
|
2840
|
+
children: status
|
|
2886
2841
|
}),
|
|
2887
|
-
snapshot.error ? /* @__PURE__ */
|
|
2842
|
+
snapshot.error ? /* @__PURE__ */ jsx7("p", {
|
|
2888
2843
|
role: "alert",
|
|
2889
2844
|
children: snapshot.error.message
|
|
2890
2845
|
}) : null,
|
|
2891
|
-
snapshot.incompatible ? /* @__PURE__ */ jsxs6(
|
|
2846
|
+
snapshot.incompatible ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2892
2847
|
children: [
|
|
2893
|
-
/* @__PURE__ */
|
|
2848
|
+
/* @__PURE__ */ jsx7(PreservedDraft, {
|
|
2894
2849
|
input: snapshot.incompatible.input,
|
|
2895
2850
|
reason: snapshot.incompatible.reason
|
|
2896
2851
|
}),
|
|
2897
|
-
!snapshot.overwriteAllowed ? /* @__PURE__ */
|
|
2852
|
+
!snapshot.overwriteAllowed ? /* @__PURE__ */ jsx7("button", {
|
|
2898
2853
|
type: "button",
|
|
2899
2854
|
disabled,
|
|
2900
2855
|
onClick: () => {
|
|
@@ -2905,14 +2860,14 @@ function DraftLifecycle({
|
|
|
2905
2860
|
}) : null
|
|
2906
2861
|
]
|
|
2907
2862
|
}) : null,
|
|
2908
|
-
snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs6(
|
|
2863
|
+
snapshot.loaded && !snapshot.loaded.applied ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2909
2864
|
children: [
|
|
2910
|
-
/* @__PURE__ */
|
|
2865
|
+
/* @__PURE__ */ jsx7(PreservedDraft, {
|
|
2911
2866
|
input: snapshot.loaded.draft,
|
|
2912
2867
|
reason: "A stored draft arrived after editing. Your current draft is preserved.",
|
|
2913
2868
|
state: "pending"
|
|
2914
2869
|
}),
|
|
2915
|
-
/* @__PURE__ */
|
|
2870
|
+
/* @__PURE__ */ jsx7("button", {
|
|
2916
2871
|
type: "button",
|
|
2917
2872
|
disabled,
|
|
2918
2873
|
onClick: () => {
|
|
@@ -2922,14 +2877,81 @@ function DraftLifecycle({
|
|
|
2922
2877
|
children: "Restore stored draft"
|
|
2923
2878
|
})
|
|
2924
2879
|
]
|
|
2925
|
-
}) : null
|
|
2926
|
-
|
|
2880
|
+
}) : null
|
|
2881
|
+
]
|
|
2882
|
+
});
|
|
2883
|
+
const actions = compact ? /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2884
|
+
children: [
|
|
2885
|
+
/* @__PURE__ */ jsxs6("button", {
|
|
2886
|
+
type: "button",
|
|
2887
|
+
className: "popover-menu-item",
|
|
2888
|
+
title: status,
|
|
2889
|
+
disabled: blocked,
|
|
2890
|
+
onClick: (event) => {
|
|
2891
|
+
controller.save();
|
|
2892
|
+
event.currentTarget.closest("[popover]")?.hidePopover?.();
|
|
2893
|
+
},
|
|
2894
|
+
children: [
|
|
2895
|
+
/* @__PURE__ */ jsx7("svg", {
|
|
2896
|
+
width: "18",
|
|
2897
|
+
height: "18",
|
|
2898
|
+
viewBox: "0 0 24 24",
|
|
2899
|
+
fill: "none",
|
|
2900
|
+
stroke: "currentColor",
|
|
2901
|
+
strokeWidth: "2",
|
|
2902
|
+
strokeLinecap: "round",
|
|
2903
|
+
strokeLinejoin: "round",
|
|
2904
|
+
"aria-hidden": "true",
|
|
2905
|
+
focusable: "false",
|
|
2906
|
+
children: /* @__PURE__ */ jsx7("path", {
|
|
2907
|
+
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"
|
|
2908
|
+
})
|
|
2909
|
+
}),
|
|
2910
|
+
/* @__PURE__ */ jsx7("span", {
|
|
2911
|
+
children: "Save draft"
|
|
2912
|
+
})
|
|
2913
|
+
]
|
|
2914
|
+
}),
|
|
2915
|
+
/* @__PURE__ */ jsxs6("button", {
|
|
2916
|
+
type: "button",
|
|
2917
|
+
className: "popover-menu-item",
|
|
2918
|
+
title: "Reload stored draft",
|
|
2919
|
+
disabled: disabled || snapshot.status === "loading" || snapshot.saving,
|
|
2920
|
+
onClick: (event) => {
|
|
2921
|
+
controller.reload();
|
|
2922
|
+
event.currentTarget.closest("[popover]")?.hidePopover?.();
|
|
2923
|
+
},
|
|
2924
|
+
children: [
|
|
2925
|
+
/* @__PURE__ */ jsx7("svg", {
|
|
2926
|
+
width: "18",
|
|
2927
|
+
height: "18",
|
|
2928
|
+
viewBox: "0 0 24 24",
|
|
2929
|
+
fill: "none",
|
|
2930
|
+
stroke: "currentColor",
|
|
2931
|
+
strokeWidth: "2",
|
|
2932
|
+
strokeLinecap: "round",
|
|
2933
|
+
strokeLinejoin: "round",
|
|
2934
|
+
"aria-hidden": "true",
|
|
2935
|
+
focusable: "false",
|
|
2936
|
+
children: /* @__PURE__ */ jsx7("path", {
|
|
2937
|
+
d: "M3 11a9 9 0 1 1 2.6 7.4M3 4v7h7"
|
|
2938
|
+
})
|
|
2939
|
+
}),
|
|
2940
|
+
/* @__PURE__ */ jsx7("span", {
|
|
2941
|
+
children: "Reload stored draft"
|
|
2942
|
+
})
|
|
2943
|
+
]
|
|
2944
|
+
})
|
|
2945
|
+
]
|
|
2946
|
+
}) : /* @__PURE__ */ jsxs6(Fragment4, {
|
|
2947
|
+
children: [
|
|
2948
|
+
/* @__PURE__ */ jsx7("button", {
|
|
2927
2949
|
type: "button",
|
|
2928
2950
|
disabled: blocked,
|
|
2929
2951
|
onClick: () => void controller.save(),
|
|
2930
2952
|
children: "Save draft"
|
|
2931
2953
|
}),
|
|
2932
|
-
/* @__PURE__ */
|
|
2954
|
+
/* @__PURE__ */ jsx7("button", {
|
|
2933
2955
|
type: "button",
|
|
2934
2956
|
disabled: disabled || snapshot.status === "loading" || snapshot.saving,
|
|
2935
2957
|
onClick: () => void controller.reload(),
|
|
@@ -2937,11 +2959,19 @@ function DraftLifecycle({
|
|
|
2937
2959
|
})
|
|
2938
2960
|
]
|
|
2939
2961
|
});
|
|
2962
|
+
return compact ? children(feedback, actions) : children(/* @__PURE__ */ jsxs6("div", {
|
|
2963
|
+
className: "chat-composer-status",
|
|
2964
|
+
"aria-label": "Draft storage",
|
|
2965
|
+
children: [
|
|
2966
|
+
feedback,
|
|
2967
|
+
actions
|
|
2968
|
+
]
|
|
2969
|
+
}));
|
|
2940
2970
|
}
|
|
2941
2971
|
|
|
2942
2972
|
// src/components/chat/composer/SemanticComposer.tsx
|
|
2943
|
-
import { jsx as
|
|
2944
|
-
var SemanticComposer =
|
|
2973
|
+
import { jsx as jsx8, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-runtime";
|
|
2974
|
+
var SemanticComposer = forwardRef4(({
|
|
2945
2975
|
Editor,
|
|
2946
2976
|
structured,
|
|
2947
2977
|
value,
|
|
@@ -2960,6 +2990,8 @@ var SemanticComposer = forwardRef5(({
|
|
|
2960
2990
|
busy = false,
|
|
2961
2991
|
canSubmit = true,
|
|
2962
2992
|
allowAttachmentOnly = false,
|
|
2993
|
+
compact = false,
|
|
2994
|
+
addMenu,
|
|
2963
2995
|
onStop,
|
|
2964
2996
|
label = "Message",
|
|
2965
2997
|
attachLabel = "Attach files",
|
|
@@ -2988,13 +3020,13 @@ var SemanticComposer = forwardRef5(({
|
|
|
2988
3020
|
const changedScope = !sameComposerScope(observed.current.scope, scope) || observed.current.draftKey !== draftKey;
|
|
2989
3021
|
const generation = observed.current.generation + (changedScope ? 1 : 0);
|
|
2990
3022
|
const alive = useRef5(false);
|
|
2991
|
-
|
|
3023
|
+
useLayoutEffect8(() => {
|
|
2992
3024
|
alive.current = true;
|
|
2993
3025
|
return () => {
|
|
2994
3026
|
alive.current = false;
|
|
2995
3027
|
};
|
|
2996
3028
|
}, []);
|
|
2997
|
-
|
|
3029
|
+
useLayoutEffect8(() => {
|
|
2998
3030
|
if (changedScope)
|
|
2999
3031
|
observed.current = { scope: { ...scope }, draftKey, generation };
|
|
3000
3032
|
}, [
|
|
@@ -3079,10 +3111,13 @@ var SemanticComposer = forwardRef5(({
|
|
|
3079
3111
|
const completion = useComposerProviders(providerContext);
|
|
3080
3112
|
const popup = completion.snapshot.status !== "idle";
|
|
3081
3113
|
const candidates = completion.snapshot.items.map((item) => {
|
|
3114
|
+
const provider = providers.find((entry) => entry.providerId === item.providerId);
|
|
3082
3115
|
const reason = item.candidate.disabledReason ?? candidateDisabledReason(item.candidate);
|
|
3083
3116
|
return {
|
|
3084
3117
|
id: item.id,
|
|
3085
3118
|
label: item.candidate.label,
|
|
3119
|
+
icon: provider?.icon,
|
|
3120
|
+
sourceLabel: provider?.sourceLabel,
|
|
3086
3121
|
description: reason ?? item.candidate.description,
|
|
3087
3122
|
disabled: reason !== undefined,
|
|
3088
3123
|
group: item.candidate.group ?? completion.snapshot.groups.find((group) => group.providerId === item.providerId)?.label
|
|
@@ -3092,7 +3127,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3092
3127
|
const showCompletion = popup && candidates.length > 0;
|
|
3093
3128
|
const visibleError = error ?? localError ?? session.snapshot.error?.message;
|
|
3094
3129
|
const hasError = visibleError !== undefined && visibleError !== null && visibleError !== false;
|
|
3095
|
-
|
|
3130
|
+
useImperativeHandle3(forwardedRef, () => ({
|
|
3096
3131
|
focus: () => editor.current?.focus(),
|
|
3097
3132
|
selection: () => editor.current?.selection() ?? null,
|
|
3098
3133
|
insertReference: (node) => {
|
|
@@ -3148,16 +3183,19 @@ var SemanticComposer = forwardRef5(({
|
|
|
3148
3183
|
}
|
|
3149
3184
|
editor.current?.focus();
|
|
3150
3185
|
}
|
|
3151
|
-
|
|
3186
|
+
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));
|
|
3187
|
+
return /* @__PURE__ */ jsx8(ComposerShell, {
|
|
3152
3188
|
...rootProps,
|
|
3153
3189
|
className,
|
|
3154
3190
|
composerId: id,
|
|
3191
|
+
compact,
|
|
3192
|
+
addMenu,
|
|
3155
3193
|
entries: (attachmentsCurrent ? attachments.entries : []).map((entry) => ({
|
|
3156
3194
|
id: entry.entryId,
|
|
3157
3195
|
name: entry.metadata.name,
|
|
3158
3196
|
previewUrl: attachments.controller.previewUrl(entry.entryId),
|
|
3159
3197
|
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,
|
|
3198
|
+
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
3199
|
...entry.state.status === "preparing" || entry.state.status === "uploading" ? {
|
|
3162
3200
|
progress: entry.state.progress,
|
|
3163
3201
|
cancel: () => attachments.controller.cancel(entry.entryId)
|
|
@@ -3207,23 +3245,24 @@ var SemanticComposer = forwardRef5(({
|
|
|
3207
3245
|
active,
|
|
3208
3246
|
showCompletion,
|
|
3209
3247
|
selectCompletion: selectCandidate,
|
|
3248
|
+
dismissCompletion: () => completion.controller.dismiss(),
|
|
3210
3249
|
completionHeader: completion.snapshot.breadcrumbs.length ? /* @__PURE__ */ jsxs7("nav", {
|
|
3211
3250
|
"aria-label": "Suggestion folders",
|
|
3212
3251
|
className: "chat-composer-breadcrumb",
|
|
3213
3252
|
children: [
|
|
3214
|
-
/* @__PURE__ */
|
|
3253
|
+
/* @__PURE__ */ jsx8("button", {
|
|
3215
3254
|
type: "button",
|
|
3216
3255
|
onMouseDown: (event) => event.preventDefault(),
|
|
3217
3256
|
onClick: () => completion.controller.back(0),
|
|
3218
3257
|
children: "All results"
|
|
3219
3258
|
}),
|
|
3220
|
-
completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */
|
|
3259
|
+
completion.snapshot.breadcrumbs.map((crumb, index) => /* @__PURE__ */ jsx8("button", {
|
|
3221
3260
|
type: "button",
|
|
3222
3261
|
onMouseDown: (event) => event.preventDefault(),
|
|
3223
3262
|
onClick: () => completion.controller.back(index + 1),
|
|
3224
3263
|
children: crumb.label
|
|
3225
3264
|
}, crumb.refId)),
|
|
3226
|
-
/* @__PURE__ */
|
|
3265
|
+
/* @__PURE__ */ jsx8("span", {
|
|
3227
3266
|
className: "chat-composer-hint",
|
|
3228
3267
|
children: "Alt+Left returns to the parent folder."
|
|
3229
3268
|
})
|
|
@@ -3234,7 +3273,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3234
3273
|
className: "chat-composer-status",
|
|
3235
3274
|
children: [
|
|
3236
3275
|
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__ */
|
|
3276
|
+
completion.snapshot.status === "error" ? /* @__PURE__ */ jsx8("button", {
|
|
3238
3277
|
type: "button",
|
|
3239
3278
|
onClick: () => completion.controller.retry(),
|
|
3240
3279
|
children: "Retry suggestions"
|
|
@@ -3243,18 +3282,8 @@ var SemanticComposer = forwardRef5(({
|
|
|
3243
3282
|
}) : null,
|
|
3244
3283
|
visibleError,
|
|
3245
3284
|
hasError,
|
|
3246
|
-
statusContent: /* @__PURE__ */ jsxs7(
|
|
3285
|
+
statusContent: /* @__PURE__ */ jsxs7(Fragment5, {
|
|
3247
3286
|
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
3287
|
attachmentsCurrent && attachments.rejections.length ? /* @__PURE__ */ jsxs7("div", {
|
|
3259
3288
|
role: "alert",
|
|
3260
3289
|
className: "chat-composer-status",
|
|
@@ -3267,58 +3296,80 @@ var SemanticComposer = forwardRef5(({
|
|
|
3267
3296
|
item.error.message
|
|
3268
3297
|
]
|
|
3269
3298
|
}, `${index}-${item.metadata.name}`)),
|
|
3270
|
-
/* @__PURE__ */
|
|
3299
|
+
/* @__PURE__ */ jsx8("button", {
|
|
3271
3300
|
type: "button",
|
|
3272
3301
|
onClick: () => attachments.controller.clearRejections(),
|
|
3273
3302
|
children: "Dismiss attachment errors"
|
|
3274
3303
|
})
|
|
3275
3304
|
]
|
|
3276
3305
|
}) : null,
|
|
3277
|
-
recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => /* @__PURE__ */
|
|
3306
|
+
recovery.filter((attempt) => sameComposerScope(attempt.snapshot.scope, scope) && (attempt.status === "unknown" || attempt.status === "pending")).map((attempt) => compact && attempt.status === "pending" ? /* @__PURE__ */ jsx8("p", {
|
|
3307
|
+
role: "status",
|
|
3308
|
+
className: "sr-only",
|
|
3309
|
+
"data-state": "pending",
|
|
3310
|
+
children: "Awaiting admission"
|
|
3311
|
+
}, attempt.snapshot.clientSubmissionId) : /* @__PURE__ */ jsxs7("details", {
|
|
3278
3312
|
className: "chat-composer-status",
|
|
3279
3313
|
"data-state": attempt.status,
|
|
3280
3314
|
children: [
|
|
3281
|
-
/* @__PURE__ */
|
|
3315
|
+
/* @__PURE__ */ jsx8("summary", {
|
|
3282
3316
|
children: attempt.status === "unknown" ? "Submission outcome unknown — draft retained" : "Awaiting admission"
|
|
3283
3317
|
}),
|
|
3284
|
-
/* @__PURE__ */
|
|
3318
|
+
/* @__PURE__ */ jsx8("p", {
|
|
3285
3319
|
children: attempt.snapshot.clientSubmissionId
|
|
3286
3320
|
}),
|
|
3287
|
-
attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */
|
|
3321
|
+
attempt.receipt?.outcome === "unknown" ? /* @__PURE__ */ jsx8("p", {
|
|
3288
3322
|
children: attempt.receipt.error.message
|
|
3289
3323
|
}) : null,
|
|
3290
|
-
host.reconcile ? /* @__PURE__ */
|
|
3324
|
+
host.reconcile ? /* @__PURE__ */ jsx8("button", {
|
|
3291
3325
|
type: "button",
|
|
3292
3326
|
onClick: () => {
|
|
3293
3327
|
session.controller.reconcile(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
|
|
3294
3328
|
},
|
|
3295
3329
|
children: "Check submission status"
|
|
3296
3330
|
}) : null,
|
|
3297
|
-
attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */
|
|
3331
|
+
attempt.status === "unknown" && host.authorizeRetry ? /* @__PURE__ */ jsx8("button", {
|
|
3298
3332
|
type: "button",
|
|
3299
3333
|
onClick: () => {
|
|
3300
3334
|
session.controller.retry(attempt.snapshot.clientSubmissionId).catch((cause) => setLocalError(String(cause), generation));
|
|
3301
3335
|
},
|
|
3302
3336
|
children: "Request authorized retry"
|
|
3303
3337
|
}) : null,
|
|
3304
|
-
/* @__PURE__ */
|
|
3338
|
+
/* @__PURE__ */ jsx8(PreservedDraft, {
|
|
3305
3339
|
input: attempt.snapshot.document,
|
|
3306
3340
|
reason: "Submitted snapshot",
|
|
3307
3341
|
state: attempt.status === "unknown" ? "unknown" : "pending"
|
|
3308
3342
|
})
|
|
3309
3343
|
]
|
|
3310
3344
|
}, attempt.snapshot.clientSubmissionId)),
|
|
3311
|
-
session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */
|
|
3345
|
+
session.snapshot.recoveryFailures?.map((attempt) => /* @__PURE__ */ jsx8(PreservedDraft, {
|
|
3312
3346
|
input: attempt,
|
|
3313
3347
|
reason: "The host could not retain this submission. Export its recovery record before leaving."
|
|
3314
3348
|
}, attempt.snapshot.clientSubmissionId)),
|
|
3315
|
-
session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */
|
|
3349
|
+
session.snapshot.lastReceipt?.outcome === "accepted" ? /* @__PURE__ */ jsx8("div", {
|
|
3316
3350
|
role: "status",
|
|
3317
|
-
className: "chat-composer-status",
|
|
3351
|
+
className: compact ? "sr-only" : "chat-composer-status",
|
|
3318
3352
|
children: session.snapshot.lastReceipt.operation === "command" ? "Command completed" : `Admitted: ${session.snapshot.lastReceipt.delivery} (${session.snapshot.lastReceipt.persistence})`
|
|
3319
3353
|
}) : null
|
|
3320
3354
|
]
|
|
3321
3355
|
}),
|
|
3356
|
+
renderFooter: (renderToolbar) => draftAdapter && attachmentsCurrent && read.status === "compatible" ? /* @__PURE__ */ jsx8(DraftLifecycle, {
|
|
3357
|
+
compact,
|
|
3358
|
+
adapter: draftAdapter,
|
|
3359
|
+
scope,
|
|
3360
|
+
draftKey,
|
|
3361
|
+
generation,
|
|
3362
|
+
value,
|
|
3363
|
+
attachments: attachments.controller,
|
|
3364
|
+
onDocumentChange,
|
|
3365
|
+
disabled: disabled || runtime.status === "read_only",
|
|
3366
|
+
children: (feedback, actions) => /* @__PURE__ */ jsxs7(Fragment5, {
|
|
3367
|
+
children: [
|
|
3368
|
+
feedback,
|
|
3369
|
+
renderToolbar(actions)
|
|
3370
|
+
]
|
|
3371
|
+
})
|
|
3372
|
+
}, `draft-${generation}`) : renderToolbar(),
|
|
3322
3373
|
attachLabel,
|
|
3323
3374
|
sendLabel: action.label,
|
|
3324
3375
|
stopLabel,
|
|
@@ -3328,7 +3379,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3328
3379
|
},
|
|
3329
3380
|
submit,
|
|
3330
3381
|
onStop,
|
|
3331
|
-
editor: editAvailable ? /* @__PURE__ */
|
|
3382
|
+
editor: editAvailable ? /* @__PURE__ */ jsx8(Editor, {
|
|
3332
3383
|
ref: editor,
|
|
3333
3384
|
value,
|
|
3334
3385
|
instanceGeneration: generation,
|
|
@@ -3381,7 +3432,7 @@ var SemanticComposer = forwardRef5(({
|
|
|
3381
3432
|
submit();
|
|
3382
3433
|
}
|
|
3383
3434
|
}
|
|
3384
|
-
}, generation) : /* @__PURE__ */
|
|
3435
|
+
}, generation) : /* @__PURE__ */ jsx8(PreservedDraft, {
|
|
3385
3436
|
input: value.document,
|
|
3386
3437
|
reason: editorError?.message ?? (read.status === "incompatible" ? read.reason : "This draft requires the optional rich editor.")
|
|
3387
3438
|
}),
|
|
@@ -3391,8 +3442,8 @@ var SemanticComposer = forwardRef5(({
|
|
|
3391
3442
|
SemanticComposer.displayName = "SemanticComposer";
|
|
3392
3443
|
|
|
3393
3444
|
// src/components/chat/rich/RichChatComposer.tsx
|
|
3394
|
-
import { jsx as
|
|
3395
|
-
var LazyLexicalEditor = lazy(() => (__preload("
|
|
3445
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
3446
|
+
var LazyLexicalEditor = lazy(() => (__preload("rd10x4gc"), import("../../../chunk-rd10x4gc.js")));
|
|
3396
3447
|
|
|
3397
3448
|
class EditorBoundary extends Component {
|
|
3398
3449
|
state = {};
|
|
@@ -3403,29 +3454,29 @@ class EditorBoundary extends Component {
|
|
|
3403
3454
|
this.props.onError?.(error);
|
|
3404
3455
|
}
|
|
3405
3456
|
render() {
|
|
3406
|
-
return this.state.error ? /* @__PURE__ */
|
|
3457
|
+
return this.state.error ? /* @__PURE__ */ jsx9(PreservedDraft, {
|
|
3407
3458
|
input: this.props.input,
|
|
3408
3459
|
reason: this.state.error.message
|
|
3409
3460
|
}) : this.props.children;
|
|
3410
3461
|
}
|
|
3411
3462
|
}
|
|
3412
|
-
var OptionalEditor =
|
|
3463
|
+
var OptionalEditor = forwardRef5((props, ref) => /* @__PURE__ */ jsx9(EditorBoundary, {
|
|
3413
3464
|
input: props.value.document,
|
|
3414
3465
|
onError: props.onError,
|
|
3415
|
-
children: /* @__PURE__ */
|
|
3416
|
-
fallback: /* @__PURE__ */
|
|
3466
|
+
children: /* @__PURE__ */ jsx9(Suspense, {
|
|
3467
|
+
fallback: /* @__PURE__ */ jsx9(PreservedDraft, {
|
|
3417
3468
|
input: props.value.document,
|
|
3418
3469
|
reason: "Loading rich editor.",
|
|
3419
3470
|
state: "pending"
|
|
3420
3471
|
}),
|
|
3421
|
-
children: /* @__PURE__ */
|
|
3472
|
+
children: /* @__PURE__ */ jsx9(LazyLexicalEditor, {
|
|
3422
3473
|
...props,
|
|
3423
3474
|
ref
|
|
3424
3475
|
})
|
|
3425
3476
|
})
|
|
3426
3477
|
}));
|
|
3427
3478
|
OptionalEditor.displayName = "OptionalComposerEditor";
|
|
3428
|
-
var RichChatComposer =
|
|
3479
|
+
var RichChatComposer = forwardRef5((props, ref) => /* @__PURE__ */ jsx9(SemanticComposer, {
|
|
3429
3480
|
...props,
|
|
3430
3481
|
ref,
|
|
3431
3482
|
Editor: OptionalEditor,
|