@informedai/react 0.2.0 → 0.2.1

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.d.mts CHANGED
@@ -14,11 +14,12 @@ interface Session {
14
14
  }
15
15
  interface WidgetMessage {
16
16
  id: string;
17
- role: 'user' | 'assistant' | 'system';
17
+ role: 'user' | 'assistant' | 'agent' | 'system';
18
18
  content: string;
19
- type: 'text' | 'quick_actions' | 'task_intro' | 'pending_preview';
19
+ type: 'text' | 'quick_actions' | 'task_intro' | 'pending_preview' | 'scripted' | 'ai_response' | 'user_input' | 'quick_action';
20
20
  quickActions?: QuickAction[];
21
21
  timestamp: string;
22
+ taskContext?: string;
22
23
  }
23
24
  interface QuickAction {
24
25
  id: string;
package/dist/index.d.ts CHANGED
@@ -14,11 +14,12 @@ interface Session {
14
14
  }
15
15
  interface WidgetMessage {
16
16
  id: string;
17
- role: 'user' | 'assistant' | 'system';
17
+ role: 'user' | 'assistant' | 'agent' | 'system';
18
18
  content: string;
19
- type: 'text' | 'quick_actions' | 'task_intro' | 'pending_preview';
19
+ type: 'text' | 'quick_actions' | 'task_intro' | 'pending_preview' | 'scripted' | 'ai_response' | 'user_input' | 'quick_action';
20
20
  quickActions?: QuickAction[];
21
21
  timestamp: string;
22
+ taskContext?: string;
22
23
  }
23
24
  interface QuickAction {
24
25
  id: string;
package/dist/index.js CHANGED
@@ -706,7 +706,8 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
706
706
  }
707
707
  function MessageBubble({ message, theme, onQuickAction }) {
708
708
  const isUser = message.role === "user";
709
- if (message.type === "quick_actions" && message.quickActions) {
709
+ const hasQuickActions = message.quickActions && message.quickActions.length > 0;
710
+ if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
710
711
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: message.quickActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
711
712
  "button",
712
713
  {
@@ -734,31 +735,61 @@ function MessageBubble({ message, theme, onQuickAction }) {
734
735
  action.id
735
736
  )) });
736
737
  }
737
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
738
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
738
739
  "div",
739
740
  {
740
741
  style: {
741
742
  display: "flex",
742
- justifyContent: isUser ? "flex-end" : "flex-start"
743
+ flexDirection: "column",
744
+ alignItems: isUser ? "flex-end" : "flex-start",
745
+ gap: "8px"
743
746
  },
744
- children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
745
- "div",
746
- {
747
- style: {
748
- maxWidth: "85%",
749
- padding: "12px 16px",
750
- backgroundColor: isUser ? theme.primaryColor : "#f5f5f5",
751
- color: isUser ? "#fff" : theme.textColor,
752
- borderRadius: "12px",
753
- borderBottomRightRadius: isUser ? "4px" : "12px",
754
- borderBottomLeftRadius: isUser ? "12px" : "4px",
755
- fontSize: "14px",
756
- lineHeight: 1.5,
757
- whiteSpace: "pre-wrap"
747
+ children: [
748
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
749
+ "div",
750
+ {
751
+ style: {
752
+ maxWidth: "85%",
753
+ padding: "12px 16px",
754
+ backgroundColor: isUser ? theme.primaryColor : "#f5f5f5",
755
+ color: isUser ? "#fff" : theme.textColor,
756
+ borderRadius: "12px",
757
+ borderBottomRightRadius: isUser ? "4px" : "12px",
758
+ borderBottomLeftRadius: isUser ? "12px" : "4px",
759
+ fontSize: "14px",
760
+ lineHeight: 1.5,
761
+ whiteSpace: "pre-wrap"
762
+ },
763
+ children: message.content
764
+ }
765
+ ),
766
+ hasQuickActions && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px", maxWidth: "85%" }, children: message.quickActions.map((action) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
767
+ "button",
768
+ {
769
+ onClick: () => onQuickAction(action),
770
+ style: {
771
+ padding: "8px 14px",
772
+ backgroundColor: "#f5f5f5",
773
+ border: "1px solid #e5e5e5",
774
+ borderRadius: "20px",
775
+ fontSize: "13px",
776
+ cursor: "pointer",
777
+ color: theme.textColor,
778
+ transition: "all 0.15s"
779
+ },
780
+ onMouseOver: (e) => {
781
+ e.currentTarget.style.backgroundColor = `${theme.primaryColor}15`;
782
+ e.currentTarget.style.borderColor = theme.primaryColor;
783
+ },
784
+ onMouseOut: (e) => {
785
+ e.currentTarget.style.backgroundColor = "#f5f5f5";
786
+ e.currentTarget.style.borderColor = "#e5e5e5";
787
+ },
788
+ children: action.label
758
789
  },
759
- children: message.content
760
- }
761
- )
790
+ action.id
791
+ )) })
792
+ ]
762
793
  }
763
794
  );
764
795
  }
package/dist/index.mjs CHANGED
@@ -676,7 +676,8 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
676
676
  }
677
677
  function MessageBubble({ message, theme, onQuickAction }) {
678
678
  const isUser = message.role === "user";
679
- if (message.type === "quick_actions" && message.quickActions) {
679
+ const hasQuickActions = message.quickActions && message.quickActions.length > 0;
680
+ if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
680
681
  return /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px" }, children: message.quickActions.map((action) => /* @__PURE__ */ jsx2(
681
682
  "button",
682
683
  {
@@ -704,31 +705,61 @@ function MessageBubble({ message, theme, onQuickAction }) {
704
705
  action.id
705
706
  )) });
706
707
  }
707
- return /* @__PURE__ */ jsx2(
708
+ return /* @__PURE__ */ jsxs(
708
709
  "div",
709
710
  {
710
711
  style: {
711
712
  display: "flex",
712
- justifyContent: isUser ? "flex-end" : "flex-start"
713
+ flexDirection: "column",
714
+ alignItems: isUser ? "flex-end" : "flex-start",
715
+ gap: "8px"
713
716
  },
714
- children: /* @__PURE__ */ jsx2(
715
- "div",
716
- {
717
- style: {
718
- maxWidth: "85%",
719
- padding: "12px 16px",
720
- backgroundColor: isUser ? theme.primaryColor : "#f5f5f5",
721
- color: isUser ? "#fff" : theme.textColor,
722
- borderRadius: "12px",
723
- borderBottomRightRadius: isUser ? "4px" : "12px",
724
- borderBottomLeftRadius: isUser ? "12px" : "4px",
725
- fontSize: "14px",
726
- lineHeight: 1.5,
727
- whiteSpace: "pre-wrap"
717
+ children: [
718
+ /* @__PURE__ */ jsx2(
719
+ "div",
720
+ {
721
+ style: {
722
+ maxWidth: "85%",
723
+ padding: "12px 16px",
724
+ backgroundColor: isUser ? theme.primaryColor : "#f5f5f5",
725
+ color: isUser ? "#fff" : theme.textColor,
726
+ borderRadius: "12px",
727
+ borderBottomRightRadius: isUser ? "4px" : "12px",
728
+ borderBottomLeftRadius: isUser ? "12px" : "4px",
729
+ fontSize: "14px",
730
+ lineHeight: 1.5,
731
+ whiteSpace: "pre-wrap"
732
+ },
733
+ children: message.content
734
+ }
735
+ ),
736
+ hasQuickActions && /* @__PURE__ */ jsx2("div", { style: { display: "flex", flexWrap: "wrap", gap: "8px", maxWidth: "85%" }, children: message.quickActions.map((action) => /* @__PURE__ */ jsx2(
737
+ "button",
738
+ {
739
+ onClick: () => onQuickAction(action),
740
+ style: {
741
+ padding: "8px 14px",
742
+ backgroundColor: "#f5f5f5",
743
+ border: "1px solid #e5e5e5",
744
+ borderRadius: "20px",
745
+ fontSize: "13px",
746
+ cursor: "pointer",
747
+ color: theme.textColor,
748
+ transition: "all 0.15s"
749
+ },
750
+ onMouseOver: (e) => {
751
+ e.currentTarget.style.backgroundColor = `${theme.primaryColor}15`;
752
+ e.currentTarget.style.borderColor = theme.primaryColor;
753
+ },
754
+ onMouseOut: (e) => {
755
+ e.currentTarget.style.backgroundColor = "#f5f5f5";
756
+ e.currentTarget.style.borderColor = "#e5e5e5";
757
+ },
758
+ children: action.label
728
759
  },
729
- children: message.content
730
- }
731
- )
760
+ action.id
761
+ )) })
762
+ ]
732
763
  }
733
764
  );
734
765
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "description": "React SDK for InformedAI Assistant - AI-powered content creation widget",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",