@vantageos/mosaic-blocks 0.5.18-alpha → 0.5.20-alpha
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +56 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +32 -3
- package/dist/index.d.ts +32 -3
- package/dist/index.js +56 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -46,7 +46,7 @@ function _interopNamespace(e) {
|
|
|
46
46
|
var React28__namespace = /*#__PURE__*/_interopNamespace(React28);
|
|
47
47
|
|
|
48
48
|
// src/version.ts
|
|
49
|
-
var version = "0.5.
|
|
49
|
+
var version = "0.5.20-alpha";
|
|
50
50
|
function Placeholder({ label = "mosaic-blocks placeholder" }) {
|
|
51
51
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { "data-mosaic-block": "placeholder", children: label });
|
|
52
52
|
}
|
|
@@ -11483,7 +11483,8 @@ var chatThreadRootVariants = classVarianceAuthority.cva([
|
|
|
11483
11483
|
"relative flex min-h-0 flex-1 flex-col overflow-y-auto"
|
|
11484
11484
|
]);
|
|
11485
11485
|
var chatThreadContentVariants = classVarianceAuthority.cva([
|
|
11486
|
-
"mx-auto flex w-full max-w-2xl flex-col gap-4 px-4 py-6 sm:px-6"
|
|
11486
|
+
"mx-auto flex w-full max-w-2xl flex-col gap-4 px-4 py-6 sm:px-6",
|
|
11487
|
+
"[&>*]:[content-visibility:auto] [&>*]:[contain-intrinsic-size:auto_4rem]"
|
|
11487
11488
|
]);
|
|
11488
11489
|
var chatThreadScrollButtonVariants = classVarianceAuthority.cva([
|
|
11489
11490
|
"absolute bottom-4 left-1/2 -translate-x-1/2 inline-flex size-9",
|
|
@@ -11497,6 +11498,7 @@ var BOTTOM_THRESHOLD_PX = 24;
|
|
|
11497
11498
|
function isNearBottom(element) {
|
|
11498
11499
|
return element.scrollHeight - element.scrollTop - element.clientHeight <= BOTTOM_THRESHOLD_PX;
|
|
11499
11500
|
}
|
|
11501
|
+
var NAVIGATION_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "PageUp", "PageDown", "Home", "End"]);
|
|
11500
11502
|
function MosaicChatThread({
|
|
11501
11503
|
children,
|
|
11502
11504
|
scrollToBottomLabel,
|
|
@@ -11528,6 +11530,37 @@ function MosaicChatThread({
|
|
|
11528
11530
|
isAtBottomRef.current = true;
|
|
11529
11531
|
setIsAtBottom(true);
|
|
11530
11532
|
}
|
|
11533
|
+
function disengageBottomAnchor() {
|
|
11534
|
+
isAtBottomRef.current = false;
|
|
11535
|
+
setIsAtBottom(false);
|
|
11536
|
+
}
|
|
11537
|
+
function handleKeyDown(event) {
|
|
11538
|
+
if (NAVIGATION_KEYS.has(event.key)) {
|
|
11539
|
+
disengageBottomAnchor();
|
|
11540
|
+
}
|
|
11541
|
+
}
|
|
11542
|
+
React28.useEffect(() => {
|
|
11543
|
+
function handleSelectionChange() {
|
|
11544
|
+
const container = containerRef.current;
|
|
11545
|
+
if (!container) {
|
|
11546
|
+
return;
|
|
11547
|
+
}
|
|
11548
|
+
const selection = document.getSelection();
|
|
11549
|
+
if (!selection || selection.isCollapsed || selection.rangeCount === 0) {
|
|
11550
|
+
return;
|
|
11551
|
+
}
|
|
11552
|
+
const { anchorNode, focusNode } = selection;
|
|
11553
|
+
const touchesThread = anchorNode !== null && container.contains(anchorNode) || focusNode !== null && container.contains(focusNode);
|
|
11554
|
+
if (touchesThread) {
|
|
11555
|
+
isAtBottomRef.current = false;
|
|
11556
|
+
setIsAtBottom(false);
|
|
11557
|
+
}
|
|
11558
|
+
}
|
|
11559
|
+
document.addEventListener("selectionchange", handleSelectionChange);
|
|
11560
|
+
return () => {
|
|
11561
|
+
document.removeEventListener("selectionchange", handleSelectionChange);
|
|
11562
|
+
};
|
|
11563
|
+
}, []);
|
|
11531
11564
|
React28.useLayoutEffect(() => {
|
|
11532
11565
|
const element = containerRef.current;
|
|
11533
11566
|
if (element && isAtBottomRef.current) {
|
|
@@ -11541,6 +11574,7 @@ function MosaicChatThread({
|
|
|
11541
11574
|
"data-slot": "chat-thread",
|
|
11542
11575
|
role: "log",
|
|
11543
11576
|
onScroll: handleScroll,
|
|
11577
|
+
onKeyDown: handleKeyDown,
|
|
11544
11578
|
className: cn73(chatThreadRootVariants(), className),
|
|
11545
11579
|
children: [
|
|
11546
11580
|
/* @__PURE__ */ jsxRuntime.jsx("div", { "data-slot": "chat-thread-content", className: chatThreadContentVariants(), children }),
|
|
@@ -12030,7 +12064,9 @@ function cn76(...classes) {
|
|
|
12030
12064
|
return classes.filter(Boolean).join(" ");
|
|
12031
12065
|
}
|
|
12032
12066
|
function partKey(part, index) {
|
|
12033
|
-
|
|
12067
|
+
if (part.type === "tool") return part.toolCallId;
|
|
12068
|
+
if (part.type === "attachment") return part.attachmentId;
|
|
12069
|
+
return `${part.type}:${index}`;
|
|
12034
12070
|
}
|
|
12035
12071
|
function toolStatusOf(part) {
|
|
12036
12072
|
switch (part.state) {
|
|
@@ -12132,6 +12168,21 @@ function ChatMessageToolPartView({
|
|
|
12132
12168
|
)
|
|
12133
12169
|
] });
|
|
12134
12170
|
}
|
|
12171
|
+
function ChatMessageAttachmentPartView({ part }) {
|
|
12172
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
12173
|
+
"div",
|
|
12174
|
+
{
|
|
12175
|
+
"data-slot": "chat-message-attachment",
|
|
12176
|
+
"data-attachment-id": part.attachmentId,
|
|
12177
|
+
"data-attachment-filename": part.fileName,
|
|
12178
|
+
"data-attachment-mimetype": part.mimeType,
|
|
12179
|
+
"data-attachment-size": part.sizeBytes,
|
|
12180
|
+
"data-attachment-url": part.url,
|
|
12181
|
+
className: "my-2",
|
|
12182
|
+
children: part.renderAttachment(part)
|
|
12183
|
+
}
|
|
12184
|
+
);
|
|
12185
|
+
}
|
|
12135
12186
|
function ChatMessagePartView({
|
|
12136
12187
|
part,
|
|
12137
12188
|
renderText,
|
|
@@ -12154,6 +12205,8 @@ function ChatMessagePartView({
|
|
|
12154
12205
|
);
|
|
12155
12206
|
case "tool":
|
|
12156
12207
|
return /* @__PURE__ */ jsxRuntime.jsx(ChatMessageToolPartView, { part, toolStatusLabels });
|
|
12208
|
+
case "attachment":
|
|
12209
|
+
return /* @__PURE__ */ jsxRuntime.jsx(ChatMessageAttachmentPartView, { part });
|
|
12157
12210
|
}
|
|
12158
12211
|
}
|
|
12159
12212
|
function MosaicChatMessage({
|