@superatomai/application-react 0.0.4 → 0.0.6
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 +40 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +36 -11
- package/dist/index.js.map +1 -1
- package/package.json +5 -3
package/dist/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React6, { Component, useState, useEffect, forwardRef, memo, useMemo, useRef, useCallback, createElement, lazy as lazy$1, Suspense
|
|
1
|
+
import React6, { Component, useState, useEffect, forwardRef, memo, useMemo, useRef, useCallback, createElement, lazy as lazy$1, Suspense } from 'react';
|
|
2
2
|
import { jsx, Fragment, jsxs } from 'react/jsx-runtime';
|
|
3
|
+
import { useSyncExternalStore } from 'use-sync-external-store/shim';
|
|
3
4
|
import { createPortal } from 'react-dom';
|
|
4
5
|
|
|
5
6
|
var __create = Object.create;
|
|
@@ -70392,8 +70393,9 @@ function useSuperAtom({
|
|
|
70392
70393
|
removed.add(msg.id);
|
|
70393
70394
|
}
|
|
70394
70395
|
setMessages((prev) => prev.filter((m) => !removed.has(m.id)));
|
|
70396
|
+
refreshThreads();
|
|
70395
70397
|
return { success: true };
|
|
70396
|
-
}, [resolvedUserId]);
|
|
70398
|
+
}, [resolvedUserId, refreshThreads]);
|
|
70397
70399
|
useEffect(() => {
|
|
70398
70400
|
setMessageActions({ deleteMessage });
|
|
70399
70401
|
return () => setMessageActions({});
|
|
@@ -70556,15 +70558,38 @@ function ChatInput({
|
|
|
70556
70558
|
window.addEventListener("keydown", onKeyDown);
|
|
70557
70559
|
return () => window.removeEventListener("keydown", onKeyDown);
|
|
70558
70560
|
}, [showStop, onStop]);
|
|
70559
|
-
|
|
70561
|
+
const resize = useCallback(() => {
|
|
70560
70562
|
const textarea = textareaRef.current;
|
|
70561
70563
|
if (!textarea) return;
|
|
70562
70564
|
textarea.style.height = "auto";
|
|
70563
70565
|
const newHeight = Math.min(textarea.scrollHeight, 200);
|
|
70564
70566
|
textarea.style.height = `${newHeight}px`;
|
|
70565
|
-
|
|
70566
|
-
|
|
70567
|
-
|
|
70567
|
+
setIsMultiline(newHeight > 60);
|
|
70568
|
+
}, []);
|
|
70569
|
+
useEffect(resize, [input, resize]);
|
|
70570
|
+
useEffect(() => {
|
|
70571
|
+
const frame = requestAnimationFrame(resize);
|
|
70572
|
+
document.fonts?.ready.then(resize).catch(() => {
|
|
70573
|
+
});
|
|
70574
|
+
const textarea = textareaRef.current;
|
|
70575
|
+
if (!textarea || typeof ResizeObserver === "undefined") {
|
|
70576
|
+
return () => cancelAnimationFrame(frame);
|
|
70577
|
+
}
|
|
70578
|
+
let width = textarea.clientWidth;
|
|
70579
|
+
let pending = 0;
|
|
70580
|
+
const observer = new ResizeObserver(() => {
|
|
70581
|
+
if (textarea.clientWidth === width) return;
|
|
70582
|
+
width = textarea.clientWidth;
|
|
70583
|
+
cancelAnimationFrame(pending);
|
|
70584
|
+
pending = requestAnimationFrame(resize);
|
|
70585
|
+
});
|
|
70586
|
+
observer.observe(textarea);
|
|
70587
|
+
return () => {
|
|
70588
|
+
cancelAnimationFrame(frame);
|
|
70589
|
+
cancelAnimationFrame(pending);
|
|
70590
|
+
observer.disconnect();
|
|
70591
|
+
};
|
|
70592
|
+
}, [resize]);
|
|
70568
70593
|
const setCursorToEnd = (textarea) => {
|
|
70569
70594
|
setTimeout(() => {
|
|
70570
70595
|
textarea.setSelectionRange(textarea.value.length, textarea.value.length);
|
|
@@ -70808,7 +70833,7 @@ function MessageBubble({ message, onStop }) {
|
|
|
70808
70833
|
setConfirmOpen(false);
|
|
70809
70834
|
if (!res.success) console.error("[SuperAtom] Could not delete the message:", res.error);
|
|
70810
70835
|
};
|
|
70811
|
-
const deleteButton = deleteMessage && responseComplete && !isAborted ? /* @__PURE__ */ jsx("div", { className: "
|
|
70836
|
+
const deleteButton = deleteMessage && responseComplete && !isAborted ? /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity duration-200", children: /* @__PURE__ */ jsx(
|
|
70812
70837
|
"button",
|
|
70813
70838
|
{
|
|
70814
70839
|
onClick: () => setConfirmOpen(true),
|
|
@@ -70904,12 +70929,12 @@ function MessageBubble({ message, onStop }) {
|
|
|
70904
70929
|
/* @__PURE__ */ jsx("span", { className: "text-sm text-base-content/70", children: "Generating component..." })
|
|
70905
70930
|
] })
|
|
70906
70931
|
] }) }),
|
|
70907
|
-
hasComponent && /* @__PURE__ */
|
|
70932
|
+
hasComponent && /* @__PURE__ */ jsx("div", { id: `box-${message.id}`, className: "w-full px-4 lg:px-16 xl:px-24 2xl:px-32", children: /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
70908
70933
|
/* @__PURE__ */ jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 min-h-[85vh] overflow-auto flex items-center justify-center p-5", children: /* @__PURE__ */ jsx(DSLRenderer, { dsl: message.schema.ui, data: message.schema.data ?? {} }) }),
|
|
70909
70934
|
deleteButton
|
|
70910
|
-
] }),
|
|
70911
|
-
!isStreaming && !hasComponent && hasText && isTextOnly && !isAborted && /* @__PURE__ */ jsx("div", { className: "flex justify-center w-full px-4", children: /* @__PURE__ */ jsxs("div", { className: "w-full md:w-[60vw]", children: [
|
|
70912
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 p-4 text-base-content", children: /* @__PURE__ */ jsx(Markdown_default, { content: fullText, isStreaming: false }) }),
|
|
70935
|
+
] }) }),
|
|
70936
|
+
!isStreaming && !hasComponent && hasText && isTextOnly && !isAborted && /* @__PURE__ */ jsx("div", { className: "flex justify-center w-full px-4", children: /* @__PURE__ */ jsxs("div", { className: "w-full md:w-[60vw] group relative", children: [
|
|
70937
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 p-4 pb-10 text-base-content", children: /* @__PURE__ */ jsx(Markdown_default, { content: fullText, isStreaming: false }) }),
|
|
70913
70938
|
deleteButton
|
|
70914
70939
|
] }) }),
|
|
70915
70940
|
/* @__PURE__ */ jsx(
|