@apteva/apteva-kit 0.1.107 → 0.1.109

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
@@ -612,7 +612,7 @@ function parseWidgetsFromText(text) {
612
612
  let hasPendingWidget = false;
613
613
  let currentIndex = 0;
614
614
  let pendingWidgetType = null;
615
- let processText = text;
615
+ let processText = text.replace(/<\/?ui\s*\/?>/gi, "");
616
616
  const lastWidgetStart = text.lastIndexOf("@ui:");
617
617
  if (lastWidgetStart !== -1) {
618
618
  const afterStart = text.slice(lastWidgetStart);
@@ -1561,14 +1561,14 @@ function Form({ widget, onAction }) {
1561
1561
  {
1562
1562
  type: "button",
1563
1563
  onClick: () => fileInputRefs.current[field.name]?.click(),
1564
- className: "w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-800 !text-neutral-500 dark:!text-neutral-400 hover:border-blue-400 hover:!text-blue-500 !text-sm",
1564
+ className: "apteva-file-drop w-full px-3 py-3 rounded-lg border-2 border-dashed transition-colors cursor-pointer border-neutral-300 dark:border-neutral-600 bg-neutral-50 dark:bg-neutral-800 !text-neutral-500 dark:!text-neutral-400 hover:border-blue-400 hover:!text-blue-500 !text-sm",
1565
1565
  children: field.placeholder || "Click to add files"
1566
1566
  }
1567
1567
  ),
1568
1568
  files.length > 0 && /* @__PURE__ */ jsx6("ul", { className: "space-y-1", children: files.map((file, idx) => /* @__PURE__ */ jsxs4(
1569
1569
  "li",
1570
1570
  {
1571
- className: "flex items-center justify-between px-2 py-1.5 rounded-lg bg-neutral-50 dark:bg-neutral-800 !text-sm",
1571
+ className: "apteva-file-item-row flex items-center justify-between px-2 py-1.5 rounded-lg bg-neutral-50 dark:bg-neutral-800 !text-sm",
1572
1572
  children: [
1573
1573
  /* @__PURE__ */ jsxs4("span", { className: "!text-neutral-700 dark:!text-neutral-300 truncate mr-2", children: [
1574
1574
  file.name,
@@ -1583,7 +1583,7 @@ function Form({ widget, onAction }) {
1583
1583
  {
1584
1584
  type: "button",
1585
1585
  onClick: () => handleChange(field.name, files.filter((_, i) => i !== idx)),
1586
- className: "!text-neutral-400 hover:!text-red-500 transition-colors flex-shrink-0",
1586
+ className: "apteva-file-remove-btn !text-neutral-400 hover:!text-red-500 transition-colors flex-shrink-0",
1587
1587
  children: "\u2715"
1588
1588
  }
1589
1589
  )
@@ -1860,7 +1860,7 @@ function Kpi({ widget, onAction }) {
1860
1860
  title && /* @__PURE__ */ jsx9("h3", { className: "!text-base font-semibold !text-neutral-900 dark:!text-white mb-3", children: title }),
1861
1861
  /* @__PURE__ */ jsx9("div", { className: "!text-sm font-medium !text-neutral-500 dark:!text-neutral-400 mb-1", children: label }),
1862
1862
  /* @__PURE__ */ jsxs7("div", { className: "flex items-end gap-2", children: [
1863
- /* @__PURE__ */ jsx9("div", { className: "!text-2xl font-bold !text-neutral-900 dark:!text-white", children: value }),
1863
+ /* @__PURE__ */ jsx9("div", { className: "apteva-kpi-value !text-2xl font-bold !text-neutral-900 dark:!text-white", children: value }),
1864
1864
  change && trendInfo && /* @__PURE__ */ jsxs7("div", { className: `flex items-center gap-0.5 !text-sm font-medium ${trendInfo.color} mb-0.5`, children: [
1865
1865
  /* @__PURE__ */ jsx9("span", { children: trendInfo.symbol }),
1866
1866
  /* @__PURE__ */ jsx9("span", { children: change })
@@ -2421,7 +2421,8 @@ function parseMarkdown(content) {
2421
2421
  return result;
2422
2422
  }
2423
2423
  function MarkdownContent({ content, className = "" }) {
2424
- return /* @__PURE__ */ jsx16("div", { className: `apteva-md ${className}`, children: parseMarkdown(content) });
2424
+ const cleaned = content.replace(/<\/?ui\s*\/?>/gi, "");
2425
+ return /* @__PURE__ */ jsx16("div", { className: `apteva-md ${className}`, children: parseMarkdown(cleaned) });
2425
2426
  }
2426
2427
 
2427
2428
  // src/components/Chat/ToolCall.tsx
@@ -3972,6 +3973,30 @@ ${widgetContext}` : widgetContext;
3972
3973
  }
3973
3974
  };
3974
3975
  const defaultPlaceholder = mode === "chat" ? "Type a message..." : "Enter your command...";
3976
+ const handleWidgetAction = useCallback2((action) => {
3977
+ onAction?.(action);
3978
+ if (action.type === "submit" && action.payload?.formData) {
3979
+ const formData = action.payload.formData;
3980
+ const lines = [];
3981
+ for (const [key, value] of Object.entries(formData)) {
3982
+ if (Array.isArray(value) && value.length > 0 && value[0] instanceof File) {
3983
+ const fileNames = value.map((f) => f.name).join(", ");
3984
+ lines.push(`${key}: ${fileNames}`);
3985
+ } else if (value !== "" && value !== false && value != null) {
3986
+ lines.push(`${key}: ${value}`);
3987
+ }
3988
+ }
3989
+ if (lines.length > 0 && handleSendMessageRef.current) {
3990
+ const files = [];
3991
+ for (const value of Object.values(formData)) {
3992
+ if (Array.isArray(value) && value.length > 0 && value[0] instanceof File) {
3993
+ files.push(...value);
3994
+ }
3995
+ }
3996
+ handleSendMessageRef.current(lines.join("\n"), files.length > 0 ? files : void 0);
3997
+ }
3998
+ }
3999
+ }, [onAction]);
3975
4000
  const handleSendMessage = async (text, files, isSystem) => {
3976
4001
  const hasFiles = files && files.length > 0;
3977
4002
  const attachments = hasFiles ? files.map((f) => ({
@@ -4474,12 +4499,12 @@ ${planToExecute}`;
4474
4499
  ] })
4475
4500
  ] }) }),
4476
4501
  mode === "chat" && /* @__PURE__ */ jsxs20(Fragment6, { children: [
4477
- persistentWidgetList.length > 0 && /* @__PURE__ */ jsx26(PersistentWidgetPanel, { widgets: persistentWidgetList, onAction }),
4502
+ persistentWidgetList.length > 0 && /* @__PURE__ */ jsx26(PersistentWidgetPanel, { widgets: persistentWidgetList, onAction: handleWidgetAction }),
4478
4503
  /* @__PURE__ */ jsx26(
4479
4504
  MessageList,
4480
4505
  {
4481
4506
  messages,
4482
- onAction,
4507
+ onAction: handleWidgetAction,
4483
4508
  welcomeTitle,
4484
4509
  welcomeSubtitle,
4485
4510
  welcomeIcon,