@informedai/react 0.2.4 → 0.2.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.d.mts CHANGED
@@ -78,6 +78,8 @@ interface InformedAssistantConfig {
78
78
  apiUrl?: string;
79
79
  /** Optional: Existing session ID to resume */
80
80
  sessionId?: string;
81
+ /** Callback when widget is ready with document type schema */
82
+ onReady?: (context: WidgetReadyContext) => void;
81
83
  /** Callback when a field value is applied */
82
84
  onFieldApply?: (fieldName: string, value: unknown) => void;
83
85
  /** Callback when session state changes */
@@ -91,6 +93,11 @@ interface InformedAssistantConfig {
91
93
  /** Initial collapsed state */
92
94
  defaultCollapsed?: boolean;
93
95
  }
96
+ interface WidgetReadyContext {
97
+ session: Session;
98
+ document: Document;
99
+ documentType: DocumentType;
100
+ }
94
101
  interface WidgetTheme {
95
102
  /** Primary accent color */
96
103
  primaryColor: string;
@@ -234,4 +241,4 @@ declare class InformedAIClient {
234
241
  private processSSEStream;
235
242
  }
236
243
 
237
- export { type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseSessionReturn, type WidgetMessage, type WidgetTheme, useInformedAI, useSession };
244
+ export { type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseSessionReturn, type WidgetMessage, type WidgetReadyContext, type WidgetTheme, useInformedAI, useSession };
package/dist/index.d.ts CHANGED
@@ -78,6 +78,8 @@ interface InformedAssistantConfig {
78
78
  apiUrl?: string;
79
79
  /** Optional: Existing session ID to resume */
80
80
  sessionId?: string;
81
+ /** Callback when widget is ready with document type schema */
82
+ onReady?: (context: WidgetReadyContext) => void;
81
83
  /** Callback when a field value is applied */
82
84
  onFieldApply?: (fieldName: string, value: unknown) => void;
83
85
  /** Callback when session state changes */
@@ -91,6 +93,11 @@ interface InformedAssistantConfig {
91
93
  /** Initial collapsed state */
92
94
  defaultCollapsed?: boolean;
93
95
  }
96
+ interface WidgetReadyContext {
97
+ session: Session;
98
+ document: Document;
99
+ documentType: DocumentType;
100
+ }
94
101
  interface WidgetTheme {
95
102
  /** Primary accent color */
96
103
  primaryColor: string;
@@ -234,4 +241,4 @@ declare class InformedAIClient {
234
241
  private processSSEStream;
235
242
  }
236
243
 
237
- export { type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseSessionReturn, type WidgetMessage, type WidgetTheme, useInformedAI, useSession };
244
+ export { type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseSessionReturn, type WidgetMessage, type WidgetReadyContext, type WidgetTheme, useInformedAI, useSession };
package/dist/index.js CHANGED
@@ -236,6 +236,9 @@ function InformedAIProvider({ config, children }) {
236
236
  if (doc) setDocument(doc);
237
237
  if (dt) setDocumentType(dt);
238
238
  config.onSessionChange?.(sess);
239
+ if (doc && dt) {
240
+ config.onReady?.({ session: sess, document: doc, documentType: dt });
241
+ }
239
242
  } catch (err) {
240
243
  const error2 = err instanceof Error ? err : new Error("Initialization failed");
241
244
  setError(error2);
@@ -746,21 +749,33 @@ function MessageBubble({ message, theme, onQuickAction }) {
746
749
  const isUser = message.role === "user";
747
750
  const hasQuickActions = message.quickActions && message.quickActions.length > 0;
748
751
  if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
749
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
752
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: {
750
753
  display: "flex",
751
- flexWrap: "wrap",
752
- justifyContent: "center",
754
+ flexDirection: "column",
755
+ alignItems: "center",
753
756
  gap: "8px",
754
- padding: "8px 0"
755
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
756
- QuickActionButton,
757
- {
758
- action,
759
- theme,
760
- onClick: () => onQuickAction(action)
761
- },
762
- action.id || action.action || index
763
- )) });
757
+ padding: "12px 0"
758
+ }, children: [
759
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: {
760
+ fontSize: "11px",
761
+ color: "#a3a3a3",
762
+ fontWeight: 500
763
+ }, children: "Quick actions:" }),
764
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
765
+ display: "flex",
766
+ flexWrap: "wrap",
767
+ justifyContent: "center",
768
+ gap: "8px"
769
+ }, children: message.quickActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
770
+ QuickActionButton,
771
+ {
772
+ action,
773
+ theme,
774
+ onClick: () => onQuickAction(action)
775
+ },
776
+ action.id || action.action || index
777
+ )) })
778
+ ] });
764
779
  }
765
780
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
766
781
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
@@ -790,21 +805,33 @@ function MessageBubble({ message, theme, onQuickAction }) {
790
805
  )
791
806
  }
792
807
  ),
793
- hasQuickActions && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
808
+ hasQuickActions && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: {
794
809
  display: "flex",
795
- flexWrap: "wrap",
796
- justifyContent: "center",
810
+ flexDirection: "column",
811
+ alignItems: "center",
797
812
  gap: "8px",
798
- padding: "8px 0"
799
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
800
- QuickActionButton,
801
- {
802
- action,
803
- theme,
804
- onClick: () => onQuickAction(action)
805
- },
806
- action.id || action.action || index
807
- )) })
813
+ padding: "12px 0"
814
+ }, children: [
815
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: {
816
+ fontSize: "11px",
817
+ color: "#a3a3a3",
818
+ fontWeight: 500
819
+ }, children: "Quick actions:" }),
820
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
821
+ display: "flex",
822
+ flexWrap: "wrap",
823
+ justifyContent: "center",
824
+ gap: "8px"
825
+ }, children: message.quickActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
826
+ QuickActionButton,
827
+ {
828
+ action,
829
+ theme,
830
+ onClick: () => onQuickAction(action)
831
+ },
832
+ action.id || action.action || index
833
+ )) })
834
+ ] })
808
835
  ] });
809
836
  }
810
837
  function SparklesIcon({ color = "currentColor" }) {
package/dist/index.mjs CHANGED
@@ -206,6 +206,9 @@ function InformedAIProvider({ config, children }) {
206
206
  if (doc) setDocument(doc);
207
207
  if (dt) setDocumentType(dt);
208
208
  config.onSessionChange?.(sess);
209
+ if (doc && dt) {
210
+ config.onReady?.({ session: sess, document: doc, documentType: dt });
211
+ }
209
212
  } catch (err) {
210
213
  const error2 = err instanceof Error ? err : new Error("Initialization failed");
211
214
  setError(error2);
@@ -716,21 +719,33 @@ function MessageBubble({ message, theme, onQuickAction }) {
716
719
  const isUser = message.role === "user";
717
720
  const hasQuickActions = message.quickActions && message.quickActions.length > 0;
718
721
  if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
719
- return /* @__PURE__ */ jsx2("div", { style: {
722
+ return /* @__PURE__ */ jsxs("div", { style: {
720
723
  display: "flex",
721
- flexWrap: "wrap",
722
- justifyContent: "center",
724
+ flexDirection: "column",
725
+ alignItems: "center",
723
726
  gap: "8px",
724
- padding: "8px 0"
725
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ jsx2(
726
- QuickActionButton,
727
- {
728
- action,
729
- theme,
730
- onClick: () => onQuickAction(action)
731
- },
732
- action.id || action.action || index
733
- )) });
727
+ padding: "12px 0"
728
+ }, children: [
729
+ /* @__PURE__ */ jsx2("span", { style: {
730
+ fontSize: "11px",
731
+ color: "#a3a3a3",
732
+ fontWeight: 500
733
+ }, children: "Quick actions:" }),
734
+ /* @__PURE__ */ jsx2("div", { style: {
735
+ display: "flex",
736
+ flexWrap: "wrap",
737
+ justifyContent: "center",
738
+ gap: "8px"
739
+ }, children: message.quickActions.map((action, index) => /* @__PURE__ */ jsx2(
740
+ QuickActionButton,
741
+ {
742
+ action,
743
+ theme,
744
+ onClick: () => onQuickAction(action)
745
+ },
746
+ action.id || action.action || index
747
+ )) })
748
+ ] });
734
749
  }
735
750
  return /* @__PURE__ */ jsxs(Fragment, { children: [
736
751
  /* @__PURE__ */ jsx2(
@@ -760,21 +775,33 @@ function MessageBubble({ message, theme, onQuickAction }) {
760
775
  )
761
776
  }
762
777
  ),
763
- hasQuickActions && /* @__PURE__ */ jsx2("div", { style: {
778
+ hasQuickActions && /* @__PURE__ */ jsxs("div", { style: {
764
779
  display: "flex",
765
- flexWrap: "wrap",
766
- justifyContent: "center",
780
+ flexDirection: "column",
781
+ alignItems: "center",
767
782
  gap: "8px",
768
- padding: "8px 0"
769
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ jsx2(
770
- QuickActionButton,
771
- {
772
- action,
773
- theme,
774
- onClick: () => onQuickAction(action)
775
- },
776
- action.id || action.action || index
777
- )) })
783
+ padding: "12px 0"
784
+ }, children: [
785
+ /* @__PURE__ */ jsx2("span", { style: {
786
+ fontSize: "11px",
787
+ color: "#a3a3a3",
788
+ fontWeight: 500
789
+ }, children: "Quick actions:" }),
790
+ /* @__PURE__ */ jsx2("div", { style: {
791
+ display: "flex",
792
+ flexWrap: "wrap",
793
+ justifyContent: "center",
794
+ gap: "8px"
795
+ }, children: message.quickActions.map((action, index) => /* @__PURE__ */ jsx2(
796
+ QuickActionButton,
797
+ {
798
+ action,
799
+ theme,
800
+ onClick: () => onQuickAction(action)
801
+ },
802
+ action.id || action.action || index
803
+ )) })
804
+ ] })
778
805
  ] });
779
806
  }
780
807
  function SparklesIcon({ color = "currentColor" }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.2.4",
3
+ "version": "0.2.6",
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",