@superatomai/application-react 0.0.4 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -70398,8 +70398,9 @@ function useSuperAtom({
70398
70398
  removed.add(msg.id);
70399
70399
  }
70400
70400
  setMessages((prev) => prev.filter((m) => !removed.has(m.id)));
70401
+ refreshThreads();
70401
70402
  return { success: true };
70402
- }, [resolvedUserId]);
70403
+ }, [resolvedUserId, refreshThreads]);
70403
70404
  React6.useEffect(() => {
70404
70405
  setMessageActions({ deleteMessage });
70405
70406
  return () => setMessageActions({});
@@ -70562,15 +70563,35 @@ function ChatInput({
70562
70563
  window.addEventListener("keydown", onKeyDown);
70563
70564
  return () => window.removeEventListener("keydown", onKeyDown);
70564
70565
  }, [showStop, onStop]);
70565
- React6.useEffect(() => {
70566
+ const resize = React6.useCallback(() => {
70566
70567
  const textarea = textareaRef.current;
70567
70568
  if (!textarea) return;
70568
70569
  textarea.style.height = "auto";
70569
70570
  const newHeight = Math.min(textarea.scrollHeight, 200);
70570
70571
  textarea.style.height = `${newHeight}px`;
70571
- const shouldBeMultiline = newHeight > 60;
70572
- if (shouldBeMultiline !== isMultiline) setIsMultiline(shouldBeMultiline);
70573
- }, [input, isMultiline]);
70572
+ setIsMultiline(newHeight > 60);
70573
+ }, []);
70574
+ React6.useEffect(resize, [input, resize]);
70575
+ React6.useEffect(() => {
70576
+ const frame = requestAnimationFrame(resize);
70577
+ document.fonts?.ready.then(resize).catch(() => {
70578
+ });
70579
+ const textarea = textareaRef.current;
70580
+ if (!textarea || typeof ResizeObserver === "undefined") {
70581
+ return () => cancelAnimationFrame(frame);
70582
+ }
70583
+ let width = textarea.clientWidth;
70584
+ const observer = new ResizeObserver(() => {
70585
+ if (textarea.clientWidth === width) return;
70586
+ width = textarea.clientWidth;
70587
+ resize();
70588
+ });
70589
+ observer.observe(textarea);
70590
+ return () => {
70591
+ cancelAnimationFrame(frame);
70592
+ observer.disconnect();
70593
+ };
70594
+ }, [resize]);
70574
70595
  const setCursorToEnd = (textarea) => {
70575
70596
  setTimeout(() => {
70576
70597
  textarea.setSelectionRange(textarea.value.length, textarea.value.length);
@@ -70814,7 +70835,7 @@ function MessageBubble({ message, onStop }) {
70814
70835
  setConfirmOpen(false);
70815
70836
  if (!res.success) console.error("[SuperAtom] Could not delete the message:", res.error);
70816
70837
  };
70817
- const deleteButton = deleteMessage && responseComplete && !isAborted ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-end mt-2", children: /* @__PURE__ */ jsxRuntime.jsx(
70838
+ const deleteButton = deleteMessage && responseComplete && !isAborted ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "absolute bottom-2 right-2 opacity-0 group-hover:opacity-100 focus-within:opacity-100 transition-opacity duration-200", children: /* @__PURE__ */ jsxRuntime.jsx(
70818
70839
  "button",
70819
70840
  {
70820
70841
  onClick: () => setConfirmOpen(true),
@@ -70910,12 +70931,12 @@ function MessageBubble({ message, onStop }) {
70910
70931
  /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-base-content/70", children: "Generating component..." })
70911
70932
  ] })
70912
70933
  ] }) }),
70913
- hasComponent && /* @__PURE__ */ jsxRuntime.jsxs("div", { id: `box-${message.id}`, className: "w-full px-4 lg:px-16 xl:px-24 2xl:px-32", children: [
70934
+ hasComponent && /* @__PURE__ */ jsxRuntime.jsx("div", { id: `box-${message.id}`, className: "w-full px-4 lg:px-16 xl:px-24 2xl:px-32", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "group relative", children: [
70914
70935
  /* @__PURE__ */ jsxRuntime.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__ */ jsxRuntime.jsx(DSLRenderer, { dsl: message.schema.ui, data: message.schema.data ?? {} }) }),
70915
70936
  deleteButton
70916
- ] }),
70917
- !isStreaming && !hasComponent && hasText && isTextOnly && !isAborted && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center w-full px-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full md:w-[60vw]", children: [
70918
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 p-4 text-base-content", children: /* @__PURE__ */ jsxRuntime.jsx(Markdown_default, { content: fullText, isStreaming: false }) }),
70937
+ ] }) }),
70938
+ !isStreaming && !hasComponent && hasText && isTextOnly && !isAborted && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center w-full px-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "w-full md:w-[60vw] group relative", children: [
70939
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl shadow-sm bg-base-100 border-2 border-base-300 p-4 pb-10 text-base-content", children: /* @__PURE__ */ jsxRuntime.jsx(Markdown_default, { content: fullText, isStreaming: false }) }),
70919
70940
  deleteButton
70920
70941
  ] }) }),
70921
70942
  /* @__PURE__ */ jsxRuntime.jsx(