@informedai/react 0.4.18 → 0.4.20

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
@@ -31,6 +31,7 @@ interface QuickAction {
31
31
  id: string;
32
32
  label: string;
33
33
  action: string;
34
+ group?: string;
34
35
  payload?: Record<string, unknown>;
35
36
  }
36
37
  interface TaskState {
@@ -46,8 +47,18 @@ interface FieldDefinition {
46
47
  label: string;
47
48
  description?: string;
48
49
  }
50
+ interface QuickActionGroup {
51
+ id: string;
52
+ label: string;
53
+ fieldNames: string[];
54
+ }
49
55
  interface DocumentTypeSchema {
50
56
  fields: Record<string, FieldDefinition>;
57
+ orchestratorConfig?: {
58
+ greeting?: string;
59
+ quickActions?: QuickAction[];
60
+ quickActionGroups?: QuickActionGroup[];
61
+ };
51
62
  }
52
63
  interface DocumentType {
53
64
  id: string;
@@ -419,4 +430,4 @@ declare class InformedAIClient {
419
430
  private processSSEStream;
420
431
  }
421
432
 
422
- export { AdminChatbot, type AdminChatbotConfig, type AdminChatbotTheme, 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, WebsiteChatbot, type WebsiteChatbotConfig, type WebsiteChatbotTheme, type WidgetMessage, type WidgetReadyContext, type WidgetTheme, useInformedAI, useSession };
433
+ export { AdminChatbot, type AdminChatbotConfig, type AdminChatbotTheme, type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type QuickActionGroup, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseSessionReturn, WebsiteChatbot, type WebsiteChatbotConfig, type WebsiteChatbotTheme, type WidgetMessage, type WidgetReadyContext, type WidgetTheme, useInformedAI, useSession };
package/dist/index.d.ts CHANGED
@@ -31,6 +31,7 @@ interface QuickAction {
31
31
  id: string;
32
32
  label: string;
33
33
  action: string;
34
+ group?: string;
34
35
  payload?: Record<string, unknown>;
35
36
  }
36
37
  interface TaskState {
@@ -46,8 +47,18 @@ interface FieldDefinition {
46
47
  label: string;
47
48
  description?: string;
48
49
  }
50
+ interface QuickActionGroup {
51
+ id: string;
52
+ label: string;
53
+ fieldNames: string[];
54
+ }
49
55
  interface DocumentTypeSchema {
50
56
  fields: Record<string, FieldDefinition>;
57
+ orchestratorConfig?: {
58
+ greeting?: string;
59
+ quickActions?: QuickAction[];
60
+ quickActionGroups?: QuickActionGroup[];
61
+ };
51
62
  }
52
63
  interface DocumentType {
53
64
  id: string;
@@ -419,4 +430,4 @@ declare class InformedAIClient {
419
430
  private processSSEStream;
420
431
  }
421
432
 
422
- export { AdminChatbot, type AdminChatbotConfig, type AdminChatbotTheme, 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, WebsiteChatbot, type WebsiteChatbotConfig, type WebsiteChatbotTheme, type WidgetMessage, type WidgetReadyContext, type WidgetTheme, useInformedAI, useSession };
433
+ export { AdminChatbot, type AdminChatbotConfig, type AdminChatbotTheme, type ChatMessage, type Document, type DocumentType, type DocumentTypeSchema, type FieldDefinition, InformedAIClient, InformedAIProvider, InformedAssistant, type InformedAssistantConfig, type QuickAction, type QuickActionGroup, type SSEEvent, type Session, type TaskConfig, type TaskState, type UseSessionReturn, WebsiteChatbot, type WebsiteChatbotConfig, type WebsiteChatbotTheme, type WidgetMessage, type WidgetReadyContext, type WidgetTheme, useInformedAI, useSession };
package/dist/index.js CHANGED
@@ -964,7 +964,8 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
964
964
  message: msg,
965
965
  theme,
966
966
  onQuickAction: handleQuickAction,
967
- isLatest: index === session.widgetMessages.length - 1
967
+ isLatest: index === session.widgetMessages.length - 1,
968
+ quickActionGroups: documentType?.schema?.orchestratorConfig?.quickActionGroups
968
969
  },
969
970
  msg.id
970
971
  )),
@@ -1144,38 +1145,20 @@ function QuickActionButton({
1144
1145
  }
1145
1146
  );
1146
1147
  }
1147
- function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1148
+ function MessageBubble({ message, theme, onQuickAction, isLatest = false, quickActionGroups }) {
1148
1149
  const isUser = message.role === "user";
1149
1150
  const hasQuickActions = isLatest && message.quickActions && message.quickActions.length > 0;
1150
1151
  const hasKbSearch = message.kbSearch != null;
1151
1152
  if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
1152
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: {
1153
- display: "flex",
1154
- flexDirection: "column",
1155
- alignItems: "center",
1156
- gap: "8px",
1157
- padding: "12px 0"
1158
- }, children: [
1159
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { style: {
1160
- fontSize: "11px",
1161
- color: "#a3a3a3",
1162
- fontWeight: 500
1163
- }, children: "Quick actions:" }),
1164
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
1165
- display: "flex",
1166
- flexWrap: "wrap",
1167
- justifyContent: "center",
1168
- gap: "8px"
1169
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1170
- QuickActionButton,
1171
- {
1172
- action,
1173
- theme,
1174
- onClick: () => onQuickAction(action)
1175
- },
1176
- action.id || action.action || index
1177
- )) })
1178
- ] });
1153
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1154
+ GroupedQuickActions,
1155
+ {
1156
+ actions: message.quickActions,
1157
+ groups: quickActionGroups,
1158
+ theme,
1159
+ onQuickAction
1160
+ }
1161
+ );
1179
1162
  }
1180
1163
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
1181
1164
  hasKbSearch && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
@@ -1231,7 +1214,21 @@ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1231
1214
  )
1232
1215
  }
1233
1216
  ),
1234
- hasQuickActions && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: {
1217
+ hasQuickActions && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1218
+ GroupedQuickActions,
1219
+ {
1220
+ actions: message.quickActions,
1221
+ groups: quickActionGroups,
1222
+ theme,
1223
+ onQuickAction
1224
+ }
1225
+ )
1226
+ ] });
1227
+ }
1228
+ function GroupedQuickActions({ actions, groups, theme, onQuickAction }) {
1229
+ const hasGroupedActions = actions.some((a) => a.group);
1230
+ if (!hasGroupedActions) {
1231
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: {
1235
1232
  display: "flex",
1236
1233
  flexDirection: "column",
1237
1234
  alignItems: "center",
@@ -1248,7 +1245,7 @@ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1248
1245
  flexWrap: "wrap",
1249
1246
  justifyContent: "center",
1250
1247
  gap: "8px"
1251
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1248
+ }, children: actions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1252
1249
  QuickActionButton,
1253
1250
  {
1254
1251
  action,
@@ -1257,8 +1254,73 @@ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1257
1254
  },
1258
1255
  action.id || action.action || index
1259
1256
  )) })
1260
- ] })
1261
- ] });
1257
+ ] });
1258
+ }
1259
+ const groupLabelMap = /* @__PURE__ */ new Map();
1260
+ if (groups) {
1261
+ for (const g of groups) {
1262
+ groupLabelMap.set(g.id, g.label);
1263
+ }
1264
+ }
1265
+ const grouped = {};
1266
+ const groupOrder = [];
1267
+ for (const action of actions) {
1268
+ const groupKey = action.group || "_default";
1269
+ if (!grouped[groupKey]) {
1270
+ grouped[groupKey] = [];
1271
+ groupOrder.push(groupKey);
1272
+ }
1273
+ grouped[groupKey].push(action);
1274
+ }
1275
+ if (groups) {
1276
+ groupOrder.sort((a, b) => {
1277
+ if (a === "_default") return 1;
1278
+ if (b === "_default") return -1;
1279
+ const aIdx = groups.findIndex((g) => g.id === a);
1280
+ const bIdx = groups.findIndex((g) => g.id === b);
1281
+ return (aIdx === -1 ? 999 : aIdx) - (bIdx === -1 ? 999 : bIdx);
1282
+ });
1283
+ }
1284
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
1285
+ display: "flex",
1286
+ flexDirection: "column",
1287
+ alignItems: "center",
1288
+ gap: "12px",
1289
+ padding: "12px 0"
1290
+ }, children: groupOrder.map((groupKey) => {
1291
+ const groupActions = grouped[groupKey];
1292
+ const label = groupKey === "_default" ? "Quick actions" : groupLabelMap.get(groupKey) || groupKey;
1293
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { style: {
1294
+ display: "flex",
1295
+ flexDirection: "column",
1296
+ alignItems: "center",
1297
+ gap: "8px",
1298
+ width: "100%"
1299
+ }, children: [
1300
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { style: {
1301
+ fontSize: "11px",
1302
+ color: "#a3a3a3",
1303
+ fontWeight: 500
1304
+ }, children: [
1305
+ label,
1306
+ ":"
1307
+ ] }),
1308
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { style: {
1309
+ display: "flex",
1310
+ flexWrap: "wrap",
1311
+ justifyContent: "center",
1312
+ gap: "8px"
1313
+ }, children: groupActions.map((action, index) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
1314
+ QuickActionButton,
1315
+ {
1316
+ action,
1317
+ theme,
1318
+ onClick: () => onQuickAction(action)
1319
+ },
1320
+ action.id || action.action || index
1321
+ )) })
1322
+ ] }, groupKey);
1323
+ }) });
1262
1324
  }
1263
1325
  function SparklesIcon({ color = "currentColor" }) {
1264
1326
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: "2", children: [
@@ -2089,8 +2151,8 @@ function WebsiteChatbot({ className, ...config }) {
2089
2151
  style: {
2090
2152
  ...cssVars,
2091
2153
  ...positionStyles,
2092
- width: config.position === "inline" ? "100%" : "400px",
2093
- maxHeight: config.position === "inline" ? "600px" : "80vh",
2154
+ width: config.position === "inline" ? "100%" : "380px",
2155
+ maxHeight: config.position === "inline" ? "600px" : "500px",
2094
2156
  backgroundColor: "var(--wc-bg)",
2095
2157
  borderRadius: "var(--wc-radius)",
2096
2158
  border: "1px solid #e5e5e5",
package/dist/index.mjs CHANGED
@@ -932,7 +932,8 @@ function AssistantWidget({ className, theme, position = "inline", defaultCollaps
932
932
  message: msg,
933
933
  theme,
934
934
  onQuickAction: handleQuickAction,
935
- isLatest: index === session.widgetMessages.length - 1
935
+ isLatest: index === session.widgetMessages.length - 1,
936
+ quickActionGroups: documentType?.schema?.orchestratorConfig?.quickActionGroups
936
937
  },
937
938
  msg.id
938
939
  )),
@@ -1112,38 +1113,20 @@ function QuickActionButton({
1112
1113
  }
1113
1114
  );
1114
1115
  }
1115
- function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1116
+ function MessageBubble({ message, theme, onQuickAction, isLatest = false, quickActionGroups }) {
1116
1117
  const isUser = message.role === "user";
1117
1118
  const hasQuickActions = isLatest && message.quickActions && message.quickActions.length > 0;
1118
1119
  const hasKbSearch = message.kbSearch != null;
1119
1120
  if ((message.type === "quick_actions" || !message.content) && hasQuickActions) {
1120
- return /* @__PURE__ */ jsxs("div", { style: {
1121
- display: "flex",
1122
- flexDirection: "column",
1123
- alignItems: "center",
1124
- gap: "8px",
1125
- padding: "12px 0"
1126
- }, children: [
1127
- /* @__PURE__ */ jsx2("span", { style: {
1128
- fontSize: "11px",
1129
- color: "#a3a3a3",
1130
- fontWeight: 500
1131
- }, children: "Quick actions:" }),
1132
- /* @__PURE__ */ jsx2("div", { style: {
1133
- display: "flex",
1134
- flexWrap: "wrap",
1135
- justifyContent: "center",
1136
- gap: "8px"
1137
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ jsx2(
1138
- QuickActionButton,
1139
- {
1140
- action,
1141
- theme,
1142
- onClick: () => onQuickAction(action)
1143
- },
1144
- action.id || action.action || index
1145
- )) })
1146
- ] });
1121
+ return /* @__PURE__ */ jsx2(
1122
+ GroupedQuickActions,
1123
+ {
1124
+ actions: message.quickActions,
1125
+ groups: quickActionGroups,
1126
+ theme,
1127
+ onQuickAction
1128
+ }
1129
+ );
1147
1130
  }
1148
1131
  return /* @__PURE__ */ jsxs(Fragment, { children: [
1149
1132
  hasKbSearch && /* @__PURE__ */ jsxs(
@@ -1199,7 +1182,21 @@ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1199
1182
  )
1200
1183
  }
1201
1184
  ),
1202
- hasQuickActions && /* @__PURE__ */ jsxs("div", { style: {
1185
+ hasQuickActions && /* @__PURE__ */ jsx2(
1186
+ GroupedQuickActions,
1187
+ {
1188
+ actions: message.quickActions,
1189
+ groups: quickActionGroups,
1190
+ theme,
1191
+ onQuickAction
1192
+ }
1193
+ )
1194
+ ] });
1195
+ }
1196
+ function GroupedQuickActions({ actions, groups, theme, onQuickAction }) {
1197
+ const hasGroupedActions = actions.some((a) => a.group);
1198
+ if (!hasGroupedActions) {
1199
+ return /* @__PURE__ */ jsxs("div", { style: {
1203
1200
  display: "flex",
1204
1201
  flexDirection: "column",
1205
1202
  alignItems: "center",
@@ -1216,7 +1213,7 @@ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1216
1213
  flexWrap: "wrap",
1217
1214
  justifyContent: "center",
1218
1215
  gap: "8px"
1219
- }, children: message.quickActions.map((action, index) => /* @__PURE__ */ jsx2(
1216
+ }, children: actions.map((action, index) => /* @__PURE__ */ jsx2(
1220
1217
  QuickActionButton,
1221
1218
  {
1222
1219
  action,
@@ -1225,8 +1222,73 @@ function MessageBubble({ message, theme, onQuickAction, isLatest = false }) {
1225
1222
  },
1226
1223
  action.id || action.action || index
1227
1224
  )) })
1228
- ] })
1229
- ] });
1225
+ ] });
1226
+ }
1227
+ const groupLabelMap = /* @__PURE__ */ new Map();
1228
+ if (groups) {
1229
+ for (const g of groups) {
1230
+ groupLabelMap.set(g.id, g.label);
1231
+ }
1232
+ }
1233
+ const grouped = {};
1234
+ const groupOrder = [];
1235
+ for (const action of actions) {
1236
+ const groupKey = action.group || "_default";
1237
+ if (!grouped[groupKey]) {
1238
+ grouped[groupKey] = [];
1239
+ groupOrder.push(groupKey);
1240
+ }
1241
+ grouped[groupKey].push(action);
1242
+ }
1243
+ if (groups) {
1244
+ groupOrder.sort((a, b) => {
1245
+ if (a === "_default") return 1;
1246
+ if (b === "_default") return -1;
1247
+ const aIdx = groups.findIndex((g) => g.id === a);
1248
+ const bIdx = groups.findIndex((g) => g.id === b);
1249
+ return (aIdx === -1 ? 999 : aIdx) - (bIdx === -1 ? 999 : bIdx);
1250
+ });
1251
+ }
1252
+ return /* @__PURE__ */ jsx2("div", { style: {
1253
+ display: "flex",
1254
+ flexDirection: "column",
1255
+ alignItems: "center",
1256
+ gap: "12px",
1257
+ padding: "12px 0"
1258
+ }, children: groupOrder.map((groupKey) => {
1259
+ const groupActions = grouped[groupKey];
1260
+ const label = groupKey === "_default" ? "Quick actions" : groupLabelMap.get(groupKey) || groupKey;
1261
+ return /* @__PURE__ */ jsxs("div", { style: {
1262
+ display: "flex",
1263
+ flexDirection: "column",
1264
+ alignItems: "center",
1265
+ gap: "8px",
1266
+ width: "100%"
1267
+ }, children: [
1268
+ /* @__PURE__ */ jsxs("span", { style: {
1269
+ fontSize: "11px",
1270
+ color: "#a3a3a3",
1271
+ fontWeight: 500
1272
+ }, children: [
1273
+ label,
1274
+ ":"
1275
+ ] }),
1276
+ /* @__PURE__ */ jsx2("div", { style: {
1277
+ display: "flex",
1278
+ flexWrap: "wrap",
1279
+ justifyContent: "center",
1280
+ gap: "8px"
1281
+ }, children: groupActions.map((action, index) => /* @__PURE__ */ jsx2(
1282
+ QuickActionButton,
1283
+ {
1284
+ action,
1285
+ theme,
1286
+ onClick: () => onQuickAction(action)
1287
+ },
1288
+ action.id || action.action || index
1289
+ )) })
1290
+ ] }, groupKey);
1291
+ }) });
1230
1292
  }
1231
1293
  function SparklesIcon({ color = "currentColor" }) {
1232
1294
  return /* @__PURE__ */ jsxs("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: color, strokeWidth: "2", children: [
@@ -2057,8 +2119,8 @@ function WebsiteChatbot({ className, ...config }) {
2057
2119
  style: {
2058
2120
  ...cssVars,
2059
2121
  ...positionStyles,
2060
- width: config.position === "inline" ? "100%" : "400px",
2061
- maxHeight: config.position === "inline" ? "600px" : "80vh",
2122
+ width: config.position === "inline" ? "100%" : "380px",
2123
+ maxHeight: config.position === "inline" ? "600px" : "500px",
2062
2124
  backgroundColor: "var(--wc-bg)",
2063
2125
  borderRadius: "var(--wc-radius)",
2064
2126
  border: "1px solid #e5e5e5",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@informedai/react",
3
- "version": "0.4.18",
3
+ "version": "0.4.20",
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",