@eka-care/medassist-widget-embed 0.2.11 → 0.2.13

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/iframe-helper.ts CHANGED
@@ -48,7 +48,7 @@ const getIframeBaseUrl = (customUrl?: string): string => {
48
48
  };
49
49
 
50
50
  export const openMedAssistIframe = (options: OpenIframeOptions): void => {
51
- const { agentId, title, iconUrl, environment, iframeBaseUrl ,context} = options;
51
+ const { agentId, title, iconUrl, environment, iframeBaseUrl, context } = options;
52
52
 
53
53
  if (!agentId) {
54
54
  console.error("Agent ID is required");
@@ -82,7 +82,7 @@ export const openMedAssistIframe = (options: OpenIframeOptions): void => {
82
82
  iframe.id = "medassist-iframe";
83
83
  iframe.src = iframeUrl.toString();
84
84
  iframe.setAttribute("allow", "microphone; camera");
85
-
85
+
86
86
  // Apply fullscreen styles automatically
87
87
  iframe.style.cssText = `
88
88
  width: 100vw;
package/iframe.ts CHANGED
@@ -32,6 +32,7 @@
32
32
  /** Theme from agent-config API (has mode; textColor derived: dark → black, light → white) */
33
33
  type AgentConfig = {
34
34
  name?: string;
35
+ allowed?: ("text" | "file" | "audio")[];
35
36
  theme?: {
36
37
  background?: string;
37
38
  background_img?: string;
@@ -106,7 +107,7 @@
106
107
  });
107
108
  if (!res.ok) return undefined;
108
109
  const json = await res.json();
109
- if (json?.success && json?.data?.theme) return json.data as AgentConfig;
110
+ if (json?.success && json?.data) return json.data as AgentConfig;
110
111
  return undefined;
111
112
  } catch {
112
113
  return undefined;
@@ -259,12 +260,14 @@
259
260
  }
260
261
 
261
262
  let apiTheme: WidgetTheme | undefined;
263
+ let allowed: ("text" | "file" | "audio")[] | undefined;
262
264
  if (agentConfig) {
263
265
  title = agentConfig?.name ?? title;
264
266
  iconUrl = agentConfig?.theme?.icon_img ?? iconUrl;
265
267
  apiTheme = mapAgentConfigThemeToWidgetTheme(
266
268
  agentConfig?.theme ?? undefined
267
269
  );
270
+ allowed = agentConfig?.allowed;
268
271
  }
269
272
 
270
273
  const config = {
@@ -279,6 +282,8 @@
279
282
  context: context ? JSON.parse(context) : undefined,
280
283
  baseUrl,
281
284
  displayMode: "full" as "full" | "widget",
285
+ allowed,
286
+ showCloseButton: false,
282
287
  theme: {
283
288
  ...(apiTheme ?? {}),
284
289
  ...(attributeTheme ?? {}),
package/index.ts CHANGED
@@ -59,7 +59,6 @@ type MedAssistInitConfig = {
59
59
  title?: string;
60
60
  iconUrl?: string;
61
61
  baseUrl?: string;
62
- allowed?: ("text" | "file" | "audio")[];
63
62
  theme?: {
64
63
  background?: string;
65
64
  backgroundImage?: string;
@@ -499,7 +498,7 @@ class MedAssistWidgetLoader extends HTMLElement {
499
498
  const widgetConfig = {
500
499
  title: (initConfig.title as string) || title,
501
500
  iconUrl: (initConfig.iconUrl as string) || iconUrl,
502
- allowed: (initConfig.allowed as ("text" | "file" | "audio")[] | undefined) || allowed,
501
+ allowed,
503
502
  environment,
504
503
  onClose: () => {
505
504
  if (customOnClose && typeof customOnClose === "function") {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eka-care/medassist-widget-embed",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "Embeddable MedAssist widget loader built with Web Components.",
5
5
  "author": "Geethanjali S",
6
6
  "license": "MIT",
@@ -895,10 +895,6 @@ body {
895
895
  display: grid;
896
896
  }
897
897
 
898
- .\!hidden {
899
- display: none !important;
900
- }
901
-
902
898
  .hidden {
903
899
  display: none;
904
900
  }
@@ -1424,11 +1420,6 @@ body {
1424
1420
  border-color: rgb(247 181 0 / var(--tw-border-opacity));
1425
1421
  }
1426
1422
 
1427
- .border-\[\#FEE39B\] {
1428
- --tw-border-opacity: 1;
1429
- border-color: rgb(254 227 155 / var(--tw-border-opacity));
1430
- }
1431
-
1432
1423
  .border-\[var\(--color-primary\)\] {
1433
1424
  border-color: var(--color-primary);
1434
1425
  }
@@ -1512,11 +1503,6 @@ body {
1512
1503
  background-color: rgb(247 181 0 / var(--tw-bg-opacity));
1513
1504
  }
1514
1505
 
1515
- .bg-\[\#FFFBEB\] {
1516
- --tw-bg-opacity: 1;
1517
- background-color: rgb(255 251 235 / var(--tw-bg-opacity));
1518
- }
1519
-
1520
1506
  .bg-\[opposite\] {
1521
1507
  background-color: opposite;
1522
1508
  }
@@ -2169,10 +2155,6 @@ body {
2169
2155
  --tw-ring-color: rgb(232 228 255 / var(--tw-ring-opacity));
2170
2156
  }
2171
2157
 
2172
- .ring-primary {
2173
- --tw-ring-color: hsl(var(--primary));
2174
- }
2175
-
2176
2158
  .ring-primary\/10 {
2177
2159
  --tw-ring-color: hsl(var(--primary) / var(--opacity-10));
2178
2160
  }
@@ -2181,10 +2163,6 @@ body {
2181
2163
  --tw-ring-color: hsl(var(--primary) / 0.2);
2182
2164
  }
2183
2165
 
2184
- .ring-offset-2 {
2185
- --tw-ring-offset-width: 2px;
2186
- }
2187
-
2188
2166
  .blur {
2189
2167
  --tw-blur: blur(8px);
2190
2168
  filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
@@ -29871,6 +29871,7 @@ var MedAssistWidget = (function(exports) {
29871
29871
  );
29872
29872
  function ProfileHeader({
29873
29873
  onClose,
29874
+ showCloseButton = true,
29874
29875
  title,
29875
29876
  titleImg,
29876
29877
  iconUrl,
@@ -29952,7 +29953,7 @@ var MedAssistWidget = (function(exports) {
29952
29953
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(MessageSquarePlus, { className: "w-8 h-8" })
29953
29954
  }
29954
29955
  ),
29955
- /* @__PURE__ */ jsxRuntimeExports.jsx(
29956
+ showCloseButton && /* @__PURE__ */ jsxRuntimeExports.jsx(
29956
29957
  Button,
29957
29958
  {
29958
29959
  onClick: onClose,
@@ -30383,6 +30384,7 @@ var MedAssistWidget = (function(exports) {
30383
30384
  function WidgetContainer({
30384
30385
  isOpen,
30385
30386
  onClose,
30387
+ showCloseButton = true,
30386
30388
  iconUrl,
30387
30389
  onStartNewSession,
30388
30390
  children,
@@ -30647,6 +30649,7 @@ var MedAssistWidget = (function(exports) {
30647
30649
  ProfileHeader,
30648
30650
  {
30649
30651
  onClose,
30652
+ showCloseButton,
30650
30653
  title,
30651
30654
  titleImg,
30652
30655
  iconUrl,
@@ -31343,41 +31346,39 @@ var MedAssistWidget = (function(exports) {
31343
31346
  } : {}
31344
31347
  });
31345
31348
  if (message || files && files.length > 0) {
31346
- const shouldUpdateToolResponse = isResponseFromTool && lastMessage?.toolEscalationData && (toolCalled === true || !hidden);
31347
- if (!hidden || shouldUpdateToolResponse) {
31348
- setMessages((prev) => {
31349
- const previousMessage = [...prev];
31350
- const prevLastIndex = previousMessage.length - 1;
31351
- if (isResponseFromTool && prevLastIndex >= 0 && previousMessage[prevLastIndex].toolEscalationData) {
31352
- previousMessage[prevLastIndex] = {
31353
- ...previousMessage[prevLastIndex],
31354
- toolEscalationData: {
31355
- ...previousMessage[prevLastIndex].toolEscalationData,
31356
- tool_id: null,
31357
- isResponded: true,
31358
- ...toolCalled && message != null && message.trim() !== "" && { selectedCtaAction: message.trim() }
31359
- }
31360
- };
31361
- updateMessageInSession(
31362
- sessionId,
31363
- previousMessage[prevLastIndex].id || Date.now().toString(),
31364
- previousMessage[prevLastIndex]
31365
- );
31366
- }
31367
- if (hidden) return previousMessage;
31368
- return [
31369
- ...previousMessage,
31370
- {
31371
- id: messageId || Date.now().toString(),
31372
- content: message || "",
31373
- files: files || [],
31374
- role: MessageSender.USER,
31375
- timestamp: formatMessageTimestamp(Date.now()),
31376
- isStored: true
31349
+ setMessages((prev) => {
31350
+ const previousMessage = [...prev];
31351
+ const prevLastIndex = previousMessage.length - 1;
31352
+ if (isResponseFromTool && prevLastIndex >= 0 && previousMessage[prevLastIndex].toolEscalationData) {
31353
+ previousMessage[prevLastIndex] = {
31354
+ ...previousMessage[prevLastIndex],
31355
+ toolEscalationData: {
31356
+ ...previousMessage[prevLastIndex].toolEscalationData,
31357
+ tool_id: null,
31358
+ isResponded: true
31377
31359
  }
31378
- ];
31379
- });
31380
- }
31360
+ };
31361
+ updateMessageInSession(
31362
+ sessionId,
31363
+ previousMessage[lastIndex].id || Date.now().toString(),
31364
+ previousMessage[lastIndex]
31365
+ );
31366
+ }
31367
+ if (hidden) {
31368
+ return previousMessage;
31369
+ }
31370
+ return [
31371
+ ...previousMessage,
31372
+ {
31373
+ id: messageId || Date.now().toString(),
31374
+ content: message || "",
31375
+ files: files || [],
31376
+ role: MessageSender.USER,
31377
+ timestamp: formatMessageTimestamp(Date.now()),
31378
+ isStored: true
31379
+ }
31380
+ ];
31381
+ });
31381
31382
  setIsWaitingForResponse(true);
31382
31383
  }
31383
31384
  };
@@ -31735,6 +31736,7 @@ var MedAssistWidget = (function(exports) {
31735
31736
  {
31736
31737
  isOpen,
31737
31738
  onClose: config.onClose,
31739
+ showCloseButton: config.showCloseButton,
31738
31740
  title: config.title,
31739
31741
  titleImg: config.theme?.titleImg,
31740
31742
  iconUrl: config.iconUrl,
@@ -43128,8 +43130,7 @@ var MedAssistWidget = (function(exports) {
43128
43130
  function GenericCard({
43129
43131
  card,
43130
43132
  onSendMessage,
43131
- disabled = false,
43132
- selectedCtaAction
43133
+ disabled = false
43133
43134
  }) {
43134
43135
  const {
43135
43136
  title,
@@ -43145,16 +43146,12 @@ var MedAssistWidget = (function(exports) {
43145
43146
  if (cta.link) {
43146
43147
  window.open(cta.link, "_blank", "noopener,noreferrer");
43147
43148
  }
43148
- const action = cta.action?.trim();
43149
- if (action) {
43150
- onSendMessage?.(action);
43149
+ if (cta.text) {
43150
+ onSendMessage?.(cta.text, cta.action === "hidden_text" ? true : false);
43151
43151
  }
43152
43152
  };
43153
43153
  const bannerTheme = banner?.theme ?? "success";
43154
43154
  const bannerClass = BANNER_THEME_CLASSES[bannerTheme];
43155
- const displayCtas = selectedCtaAction != null && selectedCtaAction.trim() !== "" ? ctas?.filter(
43156
- (cta) => cta.action?.trim() === selectedCtaAction.trim()
43157
- ) ?? [] : ctas ?? [];
43158
43155
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(Card, { className: "overflow-hidden rounded-xl border border-border bg-card text-card-foreground shadow-sm", children: [
43159
43156
  /* @__PURE__ */ jsxRuntimeExports.jsxs(CardHeader, { className: "flex flex-row items-start justify-between gap-3 pb-2", children: [
43160
43157
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "min-w-0 flex-1", children: [
@@ -43194,25 +43191,21 @@ var MedAssistWidget = (function(exports) {
43194
43191
  i
43195
43192
  )) }) : null
43196
43193
  ] }),
43197
- displayCtas.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex justify-center flex-wrap gap-2 pt-0", children: displayCtas.map((cta, i) => {
43194
+ ctas?.length ? /* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex justify-center flex-wrap gap-2 pt-0", children: ctas.map((cta, i) => {
43198
43195
  const variant = cta.theme ? CTA_VARIANT[cta.theme] : "default";
43199
43196
  const isOutline = i > 0 || cta.link && !cta.action;
43200
- const isSelected = disabled && selectedCtaAction != null && cta.action?.trim() === selectedCtaAction.trim();
43201
43197
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
43202
43198
  Button,
43203
43199
  {
43204
43200
  type: "button",
43205
- variant: isOutline && !isSelected ? "outline" : variant,
43201
+ variant: isOutline ? "outline" : variant,
43206
43202
  size: "sm",
43207
- className: cn(
43208
- "gap-1.5",
43209
- isSelected && "ring-2 ring-primary ring-offset-2"
43210
- ),
43203
+ className: "gap-1.5",
43211
43204
  disabled,
43212
43205
  onClick: () => handleCtaClick(cta),
43213
43206
  children: [
43214
43207
  cta.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx(CardIcon, { name: cta.icon, size: 14, className: "shrink-0" }) : null,
43215
- isSelected ? "Selected" : cta.title
43208
+ cta.title
43216
43209
  ]
43217
43210
  },
43218
43211
  i
@@ -43224,27 +43217,17 @@ var MedAssistWidget = (function(exports) {
43224
43217
  cards,
43225
43218
  onSendMessage,
43226
43219
  disabled = false,
43227
- selectedCtaAction,
43228
43220
  className
43229
43221
  }) {
43230
43222
  if (!cards?.length) {
43231
43223
  return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-2", children: "No options available." });
43232
43224
  }
43233
- const displayCards = selectedCtaAction != null && selectedCtaAction.trim() !== "" ? cards.filter(
43234
- (card) => card.ctas?.some(
43235
- (cta) => cta.action?.trim() === selectedCtaAction.trim()
43236
- )
43237
- ) : cards;
43238
- if (!displayCards.length) {
43239
- return /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-sm text-muted-foreground py-2", children: "No options available." });
43240
- }
43241
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: className ?? "flex flex-col gap-3 mt-3", children: displayCards.map((card, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
43225
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: className ?? "flex flex-col gap-3 mt-3", children: cards.map((card, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
43242
43226
  GenericCard,
43243
43227
  {
43244
43228
  card,
43245
43229
  onSendMessage,
43246
- disabled,
43247
- selectedCtaAction
43230
+ disabled
43248
43231
  },
43249
43232
  index2
43250
43233
  )) });
@@ -43335,8 +43318,9 @@ var MedAssistWidget = (function(exports) {
43335
43318
  });
43336
43319
  }
43337
43320
  };
43321
+ const hasContentInCard = !!(content2?.trim() || files && files.length > 0 || toolCallStatus || progressMessage);
43338
43322
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
43339
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("flex", isUser ? "justify-end" : "justify-start"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
43323
+ hasContentInCard && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("flex", isUser ? "justify-end" : "justify-start"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(
43340
43324
  "div",
43341
43325
  {
43342
43326
  className: cn(
@@ -43364,7 +43348,7 @@ var MedAssistWidget = (function(exports) {
43364
43348
  ]
43365
43349
  }
43366
43350
  ),
43367
- !isUser && !isStreaming && isLastMessage && userFeedback === distExports.USER_FEEDBACK.NONE && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 self-start mt-1", children: [
43351
+ !isUser && !isStreaming && isLastMessage && content2 && userFeedback === distExports.USER_FEEDBACK.NONE && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-1 self-start mt-1", children: [
43368
43352
  /* @__PURE__ */ jsxRuntimeExports.jsx(
43369
43353
  Button,
43370
43354
  {
@@ -43409,7 +43393,7 @@ var MedAssistWidget = (function(exports) {
43409
43393
  ] })
43410
43394
  }
43411
43395
  ) }),
43412
- !toolEscalationData?.isResponded && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-end", children: [
43396
+ toolEscalationData?.details?.component && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex justify-end", children: [
43413
43397
  toolEscalationData?.details?.component === distExports.SYNAPSE_COMPONENTS.PILL && toolEscalationData?.details?.input?.options && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-wrap gap-2 mt-3", children: toolEscalationData.details?.input?.options.map(
43414
43398
  (choice, index2) => /* @__PURE__ */ jsxRuntimeExports.jsx(
43415
43399
  Pills,
@@ -43464,16 +43448,15 @@ var MedAssistWidget = (function(exports) {
43464
43448
  CardList,
43465
43449
  {
43466
43450
  cards: toolEscalationData.details.input.cards,
43467
- onSendMessage: async (message) => {
43451
+ onSendMessage: async (message, hidden) => {
43468
43452
  const messageId = Date.now().toString();
43469
43453
  await onSendMessage({
43470
43454
  message,
43471
43455
  messageId,
43472
43456
  toolCalled: true,
43473
- hidden: true
43457
+ hidden
43474
43458
  });
43475
43459
  },
43476
- selectedCtaAction: toolEscalationData?.selectedCtaAction,
43477
43460
  disabled: toolEscalationData?.isResponded
43478
43461
  }
43479
43462
  )
@@ -43565,7 +43548,7 @@ var MedAssistWidget = (function(exports) {
43565
43548
  "div",
43566
43549
  {
43567
43550
  className: cn(
43568
- "mx-4 mb-3 px-2 py-1 bg-[#FFFBEB] border border-[#FEE39B] rounded-lg",
43551
+ "mx-4 mb-3 px-2 py-1 bg-surface border border-[#F7B500] rounded-lg",
43569
43552
  className
43570
43553
  ),
43571
43554
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-3", children: [