@apteva/apteva-kit 0.1.65 → 0.1.66

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.mjs CHANGED
@@ -1455,6 +1455,43 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1455
1455
  }
1456
1456
  return elements.length > 0 ? elements : null;
1457
1457
  };
1458
+ const attachments = message.metadata?.attachments || [];
1459
+ const hasAttachments = attachments.length > 0;
1460
+ const renderAttachments = () => {
1461
+ if (!hasAttachments) return null;
1462
+ return /* @__PURE__ */ jsx12("div", { className: "apteva-message-attachments flex flex-wrap gap-2 mb-2 justify-end", children: attachments.map((att, index) => {
1463
+ const isImage = att.type.startsWith("image/");
1464
+ const isPdf = att.type === "application/pdf";
1465
+ if (isImage && att.preview) {
1466
+ return /* @__PURE__ */ jsx12("div", { className: "apteva-attachment-image relative rounded-lg overflow-hidden shadow-sm", children: /* @__PURE__ */ jsx12(
1467
+ "img",
1468
+ {
1469
+ src: att.preview,
1470
+ alt: att.name,
1471
+ className: "max-w-[150px] max-h-[150px] object-cover"
1472
+ }
1473
+ ) }, index);
1474
+ }
1475
+ return /* @__PURE__ */ jsxs9(
1476
+ "div",
1477
+ {
1478
+ className: "apteva-attachment-doc flex items-center gap-3 px-4 py-3 bg-neutral-100 dark:bg-neutral-800 border border-neutral-200 dark:border-neutral-700 rounded-xl shadow-sm",
1479
+ children: [
1480
+ /* @__PURE__ */ jsx12("div", { className: "w-10 h-10 flex items-center justify-center bg-red-100 dark:bg-red-900/30 rounded-lg text-red-600 dark:text-red-400", children: isPdf ? /* @__PURE__ */ jsx12("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx12("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M7 21h10a2 2 0 002-2V9.414a1 1 0 00-.293-.707l-5.414-5.414A1 1 0 0012.586 3H7a2 2 0 00-2 2v14a2 2 0 002 2z" }) }) : /* @__PURE__ */ jsx12("svg", { className: "w-5 h-5", fill: "none", stroke: "currentColor", viewBox: "0 0 24 24", children: /* @__PURE__ */ jsx12("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z" }) }) }),
1481
+ /* @__PURE__ */ jsxs9("div", { className: "flex flex-col min-w-0", children: [
1482
+ /* @__PURE__ */ jsx12("span", { className: "text-sm font-medium text-neutral-800 dark:text-neutral-200 truncate max-w-[180px]", children: att.name }),
1483
+ /* @__PURE__ */ jsxs9("span", { className: "text-xs text-neutral-500 dark:text-neutral-400", children: [
1484
+ isPdf ? "PDF" : "Document",
1485
+ " \xB7 ",
1486
+ formatFileSize(att.size)
1487
+ ] })
1488
+ ] })
1489
+ ]
1490
+ },
1491
+ index
1492
+ );
1493
+ }) });
1494
+ };
1458
1495
  const renderContent = () => {
1459
1496
  if (isUser) {
1460
1497
  return /* @__PURE__ */ jsx12("div", { className: "apteva-message-text", children: message.content });
@@ -1552,6 +1589,13 @@ function Message({ message, onAction, enableWidgets, onWidgetRender }) {
1552
1589
  /* @__PURE__ */ jsx12("div", { className: "apteva-message-timestamp apteva-message-timestamp-assistant", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
1553
1590
  ] });
1554
1591
  }
1592
+ if (isUser && hasAttachments) {
1593
+ return /* @__PURE__ */ jsxs9("div", { className: "apteva-message-segmented apteva-message-user-with-attachments flex flex-col items-end", children: [
1594
+ renderAttachments(),
1595
+ message.content && /* @__PURE__ */ jsx12("div", { className: "apteva-message-bubble apteva-message-user", children: /* @__PURE__ */ jsx12("div", { className: "apteva-message-content-user", children: /* @__PURE__ */ jsx12("div", { className: "apteva-message-text", children: message.content }) }) }),
1596
+ /* @__PURE__ */ jsx12("div", { className: "apteva-message-timestamp apteva-message-timestamp-user", suppressHydrationWarning: true, children: message.timestamp.toLocaleTimeString([], { hour: "2-digit", minute: "2-digit" }) })
1597
+ ] });
1598
+ }
1555
1599
  return /* @__PURE__ */ jsxs9(
1556
1600
  "div",
1557
1601
  {
@@ -2600,15 +2644,19 @@ ${widgetContext}` : widgetContext;
2600
2644
  const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
2601
2645
  const handleSendMessage = async (text, files, isSystem) => {
2602
2646
  const hasFiles = files && files.length > 0;
2603
- const fileNames = hasFiles ? files.map((f) => f.name) : [];
2604
- const displayContent = hasFiles ? `${text}${text ? "\n" : ""}[Attached: ${fileNames.join(", ")}]` : text;
2647
+ const attachments = hasFiles ? files.map((f) => ({
2648
+ name: f.name,
2649
+ type: f.type,
2650
+ size: f.size,
2651
+ preview: f.type.startsWith("image/") ? URL.createObjectURL(f) : void 0
2652
+ })) : [];
2605
2653
  if (!isSystem) {
2606
2654
  const userMessage = {
2607
2655
  id: `msg-${Date.now()}`,
2608
2656
  role: "user",
2609
- content: displayContent,
2657
+ content: text,
2610
2658
  timestamp: /* @__PURE__ */ new Date(),
2611
- metadata: hasFiles ? { attachments: fileNames } : void 0
2659
+ metadata: hasFiles ? { attachments } : void 0
2612
2660
  };
2613
2661
  setMessages((prev) => [...prev, userMessage]);
2614
2662
  onMessageSent?.(userMessage);