@deepfrog/pangents-widget 2.1.5 → 2.2.0

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/Widget.d.ts CHANGED
@@ -6,6 +6,7 @@ interface WidgetProps extends Partial<WidgetConfig> {
6
6
  pangentsApiKey?: string;
7
7
  tenantId?: string;
8
8
  email?: string;
9
+ zIndex?: number;
9
10
  }
10
- export declare function Widget({ theme, className, position, margin, pangentsApiKey, tenantId, email }: WidgetProps): import("react/jsx-runtime").JSX.Element;
11
+ export declare function Widget({ theme, className, position, margin, pangentsApiKey, tenantId, email, zIndex }: WidgetProps): import("react/jsx-runtime").JSX.Element;
11
12
  export default Widget;
@@ -1,6 +1,7 @@
1
1
  interface WidgetBubbleProps {
2
2
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
3
3
  margin?: string;
4
+ zIndex?: number;
4
5
  }
5
- export declare function WidgetBubble({ position, margin }: WidgetBubbleProps): import("react/jsx-runtime").JSX.Element;
6
+ export declare function WidgetBubble({ position, margin, zIndex }: WidgetBubbleProps): import("react/jsx-runtime").JSX.Element;
6
7
  export {};
@@ -1,5 +1,6 @@
1
1
  interface WidgetPopupProps {
2
2
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
3
+ zIndex?: number;
3
4
  }
4
- export declare function WidgetPopup({ position }: WidgetPopupProps): import("react/jsx-runtime").JSX.Element;
5
+ export declare function WidgetPopup({ position, zIndex }: WidgetPopupProps): import("react/jsx-runtime").JSX.Element;
5
6
  export {};
package/dist/index.cjs.js CHANGED
@@ -6,5 +6,5 @@
6
6
  }
7
7
  } catch (error) {}
8
8
  })();
9
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./widget-embed-9DdEqVMP.cjs.js"),t=require("react/jsx-runtime"),r=require("react"),o=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));exports.Chatbot=e.Chatbot,exports.Widget=e.Widget,exports.ChatbotWidget=({pangentsApiKey:e,email:n,tenantId:i,theme:s,position:a="bottom-right",zIndex:c=9999,onInit:d,onDestroy:u})=>{const l=r.useRef(null),g=r.useRef(null);return r.useEffect(()=>((async()=>{try{const{default:t}=await Promise.resolve().then(()=>o(require("./widget-embed.cjs.js"))),r={pangentsApiKey:e,email:n,tenantId:i,theme:s,position:a,zIndex:c};l.current=t,t.init(r),d&&d()}catch(t){console.error("Failed to initialize chatbot widget:",t)}})(),()=>{if(l.current)try{l.current.destroy(),u&&u()}catch(e){console.error("Error destroying chatbot widget:",e)}}),[e,n,i,s,a,c,d,u]),r.useEffect(()=>{if(l.current){const r={pangentsApiKey:e,email:n,tenantId:i,theme:s,position:a,zIndex:c};try{l.current.updateConfig(r)}catch(t){console.error("Error updating chatbot widget config:",t)}}},[e,n,i,s,a,c]),t.jsx("div",{ref:g,style:{display:"none"}})};
9
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./widget-embed-BPoilyw_.cjs.js"),t=require("react/jsx-runtime"),n=require("react"),o=e=>Object.freeze(Object.defineProperty({__proto__:null,default:e},Symbol.toStringTag,{value:"Module"}));if("undefined"!=typeof window)try{const e=window.__PANGENTS_WIDGET_CSS;if(e&&!document.getElementById("pangents-widget-styles")){const t=document.createElement("style");t.id="pangents-widget-styles",t.textContent=e,document.head.appendChild(t)}}catch{}exports.Chatbot=e.Chatbot,exports.Widget=e.Widget,exports.ChatbotWidget=({pangentsApiKey:e,email:r,tenantId:i,theme:s,position:d="bottom-right",zIndex:c=9999,onInit:a,onDestroy:l})=>{const u=n.useRef(null),g=n.useRef(null);return n.useEffect(()=>((async()=>{try{const{default:t}=await Promise.resolve().then(()=>o(require("./widget-embed.cjs.js"))),n={pangentsApiKey:e,email:r,tenantId:i,theme:s,position:d,zIndex:c};u.current=t,t.init(n),a&&a()}catch(t){console.error("Failed to initialize chatbot widget:",t)}})(),()=>{if(u.current)try{u.current.destroy(),l&&l()}catch(e){console.error("Error destroying chatbot widget:",e)}}),[e,r,i,s,d,c,a,l]),n.useEffect(()=>{if(u.current){const n={pangentsApiKey:e,email:r,tenantId:i,theme:s,position:d,zIndex:c};try{u.current.updateConfig(n)}catch(t){console.error("Error updating chatbot widget config:",t)}}},[e,r,i,s,d,c]),t.jsx("div",{ref:g,style:{display:"none"}})};
10
10
  //# sourceMappingURL=index.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs.js","sources":["../src/components/ChatbotWidget.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\r\n\r\nexport interface ChatbotWidgetProps {\r\n pangentsApiKey?: string;\r\n email?: string;\r\n tenantId?: string;\r\n theme?: {\r\n primaryColor?: string;\r\n userBubble?: string;\r\n botBubble?: string;\r\n backgroundColor?: string;\r\n textColor?: string;\r\n };\r\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\r\n zIndex?: number;\r\n onInit?: () => void;\r\n onDestroy?: () => void;\r\n}\r\n\r\nexport const ChatbotWidget: React.FC<ChatbotWidgetProps> = ({\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position = 'bottom-right',\r\n zIndex = 9999,\r\n onInit,\r\n onDestroy,\r\n}) => {\r\n const widgetRef = useRef<any>(null);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n // Import the widget dynamically to avoid SSR issues\r\n const initializeWidget = async () => {\r\n try {\r\n // Import the widget module\r\n const { default: Chatbot } = await import('../widget-embed');\r\n \r\n // Initialize the widget with configuration\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n\r\n // Store reference to the widget instance\r\n widgetRef.current = Chatbot;\r\n \r\n // Initialize the widget\r\n Chatbot.init(config);\r\n \r\n // Call onInit callback if provided\r\n if (onInit) {\r\n onInit();\r\n }\r\n } catch (error) {\r\n console.error('Failed to initialize chatbot widget:', error);\r\n }\r\n };\r\n\r\n initializeWidget();\r\n\r\n // Cleanup function\r\n return () => {\r\n if (widgetRef.current) {\r\n try {\r\n widgetRef.current.destroy();\r\n if (onDestroy) {\r\n onDestroy();\r\n }\r\n } catch (error) {\r\n console.error('Error destroying chatbot widget:', error);\r\n }\r\n }\r\n };\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex, onInit, onDestroy]);\r\n\r\n // Update widget configuration when props change\r\n useEffect(() => {\r\n if (widgetRef.current) {\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n \r\n try {\r\n widgetRef.current.updateConfig(config);\r\n } catch (error) {\r\n console.error('Error updating chatbot widget config:', error);\r\n }\r\n }\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex]);\r\n\r\n // This component doesn't render anything visible as the widget creates its own DOM elements\r\n return <div ref={containerRef} style={{ display: 'none' }} />;\r\n};\r\n\r\nexport default ChatbotWidget;"],"names":["pangentsApiKey","email","tenantId","theme","position","zIndex","onInit","onDestroy","widgetRef","useRef","containerRef","useEffect","async","default","Chatbot","Promise","resolve","then","_interopNamespaceDefaultOnly","require","config","current","init","error","console","initializeWidget","destroy","updateConfig","jsx","ref","style","display"],"mappings":"sWAmB2D,EACzDA,iBACAC,QACAC,WACAC,QACAC,WAAW,eACXC,SAAS,KACTC,SACAC,gBAEA,MAAMC,EAAYC,EAAAA,OAAY,MACxBC,EAAeD,EAAAA,OAAuB,MAwE5C,OAtEAE,EAAAA,UAAU,KAEiBC,WACvB,IAEE,MAAQC,QAASC,SAAkBC,QAAAC,UAAAC,KAAA,IAAAC,EAAAC,QAAO,2BAGpCC,EAAS,CACbpB,iBACAC,QACAC,WACAC,QACAC,WACAC,UAIFG,EAAUa,QAAUP,EAGpBA,EAAQQ,KAAKF,GAGTd,GACFA,GAEJ,OAASiB,GACPC,QAAQD,MAAM,uCAAwCA,EACxD,GAGFE,GAGO,KACL,GAAIjB,EAAUa,QACZ,IACEb,EAAUa,QAAQK,UACdnB,GACFA,GAEJ,OAASgB,GACPC,QAAQD,MAAM,mCAAoCA,EACpD,IAGH,CAACvB,EAAgBC,EAAOC,EAAUC,EAAOC,EAAUC,EAAQC,EAAQC,IAGtEI,EAAAA,UAAU,KACR,GAAIH,EAAUa,QAAS,CACrB,MAAMD,EAAS,CACbpB,iBACAC,QACAC,WACAC,QACAC,WACAC,UAGF,IACEG,EAAUa,QAAQM,aAAaP,EACjC,OAASG,GACPC,QAAQD,MAAM,wCAAyCA,EACzD,CACF,GACC,CAACvB,EAAgBC,EAAOC,EAAUC,EAAOC,EAAUC,IAG/CuB,EAAAA,IAAC,OAAIC,IAAKnB,EAAcoB,MAAO,CAAEC,QAAS"}
1
+ {"version":3,"file":"index.cjs.js","sources":["../src/index.ts","../src/components/ChatbotWidget.tsx"],"sourcesContent":["if (typeof window !== 'undefined') {\n try {\n const css = (window as any).__PANGENTS_WIDGET_CSS;\n if (css && !document.getElementById('pangents-widget-styles')) {\n const style = document.createElement('style');\n style.id = 'pangents-widget-styles';\n style.textContent = css;\n document.head.appendChild(style);\n }\n } catch { void 0; }\n}\n\n// Main exports for the package\nexport { default as Widget } from './Widget';\nexport { ChatbotWidget } from './components/ChatbotWidget';\nexport type { ChatbotWidgetProps } from './components/ChatbotWidget';\nexport type { WidgetConfig } from './types';\n\n// Export the widget embed for direct usage\nexport { default as Chatbot } from './widget-embed';\n\n// Re-export everything from components\nexport * from './components/ChatbotWidget';\n","import React, { useEffect, useRef } from 'react';\r\n\r\nexport interface ChatbotWidgetProps {\r\n pangentsApiKey?: string;\r\n email?: string;\r\n tenantId?: string;\r\n theme?: {\r\n primaryColor?: string;\r\n userBubble?: string;\r\n botBubble?: string;\r\n backgroundColor?: string;\r\n textColor?: string;\r\n };\r\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\r\n zIndex?: number;\r\n onInit?: () => void;\r\n onDestroy?: () => void;\r\n}\r\n\r\nexport const ChatbotWidget: React.FC<ChatbotWidgetProps> = ({\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position = 'bottom-right',\r\n zIndex = 9999,\r\n onInit,\r\n onDestroy,\r\n}) => {\r\n const widgetRef = useRef<any>(null);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n // Import the widget dynamically to avoid SSR issues\r\n const initializeWidget = async () => {\r\n try {\r\n // Import the widget module\r\n const { default: Chatbot } = await import('../widget-embed');\r\n \r\n // Initialize the widget with configuration\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n\r\n // Store reference to the widget instance\r\n widgetRef.current = Chatbot;\r\n \r\n // Initialize the widget\r\n Chatbot.init(config);\r\n \r\n // Call onInit callback if provided\r\n if (onInit) {\r\n onInit();\r\n }\r\n } catch (error) {\r\n console.error('Failed to initialize chatbot widget:', error);\r\n }\r\n };\r\n\r\n initializeWidget();\r\n\r\n // Cleanup function\r\n return () => {\r\n if (widgetRef.current) {\r\n try {\r\n widgetRef.current.destroy();\r\n if (onDestroy) {\r\n onDestroy();\r\n }\r\n } catch (error) {\r\n console.error('Error destroying chatbot widget:', error);\r\n }\r\n }\r\n };\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex, onInit, onDestroy]);\r\n\r\n // Update widget configuration when props change\r\n useEffect(() => {\r\n if (widgetRef.current) {\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n \r\n try {\r\n widgetRef.current.updateConfig(config);\r\n } catch (error) {\r\n console.error('Error updating chatbot widget config:', error);\r\n }\r\n }\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex]);\r\n\r\n // This component doesn't render anything visible as the widget creates its own DOM elements\r\n return <div ref={containerRef} style={{ display: 'none' }} />;\r\n};\r\n\r\nexport default ChatbotWidget;"],"names":["window","css","__PANGENTS_WIDGET_CSS","document","getElementById","style","createElement","id","textContent","head","appendChild","pangentsApiKey","email","tenantId","theme","position","zIndex","onInit","onDestroy","widgetRef","useRef","containerRef","useEffect","async","default","Chatbot","Promise","resolve","then","_interopNamespaceDefaultOnly","require","config","current","init","error","console","initializeWidget","destroy","updateConfig","jsx","ref","display"],"mappings":"8RAAA,GAAsB,oBAAXA,OACT,IACE,MAAMC,EAAOD,OAAeE,sBAC5B,GAAID,IAAQE,SAASC,eAAe,0BAA2B,CAC7D,MAAMC,EAAQF,SAASG,cAAc,SACrCD,EAAME,GAAK,yBACXF,EAAMG,YAAcP,EACpBE,SAASM,KAAKC,YAAYL,EAC5B,CACF,CAAA,MAAkB,yECUuC,EACzDM,iBACAC,QACAC,WACAC,QACAC,WAAW,eACXC,SAAS,KACTC,SACAC,gBAEA,MAAMC,EAAYC,EAAAA,OAAY,MACxBC,EAAeD,EAAAA,OAAuB,MAwE5C,OAtEAE,EAAAA,UAAU,KAEiBC,WACvB,IAEE,MAAQC,QAASC,SAAkBC,QAAAC,UAAAC,KAAA,IAAAC,EAAAC,QAAO,2BAGpCC,EAAS,CACbpB,iBACAC,QACAC,WACAC,QACAC,WACAC,UAIFG,EAAUa,QAAUP,EAGpBA,EAAQQ,KAAKF,GAGTd,GACFA,GAEJ,OAASiB,GACPC,QAAQD,MAAM,uCAAwCA,EACxD,GAGFE,GAGO,KACL,GAAIjB,EAAUa,QACZ,IACEb,EAAUa,QAAQK,UACdnB,GACFA,GAEJ,OAASgB,GACPC,QAAQD,MAAM,mCAAoCA,EACpD,IAGH,CAACvB,EAAgBC,EAAOC,EAAUC,EAAOC,EAAUC,EAAQC,EAAQC,IAGtEI,EAAAA,UAAU,KACR,GAAIH,EAAUa,QAAS,CACrB,MAAMD,EAAS,CACbpB,iBACAC,QACAC,WACAC,QACAC,WACAC,UAGF,IACEG,EAAUa,QAAQM,aAAaP,EACjC,OAASG,GACPC,QAAQD,MAAM,wCAAyCA,EACzD,CACF,GACC,CAACvB,EAAgBC,EAAOC,EAAUC,EAAOC,EAAUC,IAG/CuB,EAAAA,IAAC,OAAIC,IAAKnB,EAAchB,MAAO,CAAEoC,QAAS"}
package/dist/index.es.js CHANGED
@@ -6,7 +6,7 @@
6
6
  }
7
7
  } catch (error) {}
8
8
  })();
9
- import { C, W } from "./widget-embed-LzSoeVtX.es.js";
9
+ import { C, W } from "./widget-embed-CtD27t5y.es.js";
10
10
  import { jsx } from "react/jsx-runtime";
11
11
  import { useRef, useEffect } from "react";
12
12
  const ChatbotWidget = ({
@@ -75,6 +75,18 @@ const ChatbotWidget = ({
75
75
  }, [pangentsApiKey, email, tenantId, theme, position, zIndex]);
76
76
  return /* @__PURE__ */ jsx("div", { ref: containerRef, style: { display: "none" } });
77
77
  };
78
+ if (typeof window !== "undefined") {
79
+ try {
80
+ const css = window.__PANGENTS_WIDGET_CSS;
81
+ if (css && !document.getElementById("pangents-widget-styles")) {
82
+ const style = document.createElement("style");
83
+ style.id = "pangents-widget-styles";
84
+ style.textContent = css;
85
+ document.head.appendChild(style);
86
+ }
87
+ } catch {
88
+ }
89
+ }
78
90
  export {
79
91
  C as Chatbot,
80
92
  ChatbotWidget,
@@ -1 +1 @@
1
- {"version":3,"file":"index.es.js","sources":["../src/components/ChatbotWidget.tsx"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\r\n\r\nexport interface ChatbotWidgetProps {\r\n pangentsApiKey?: string;\r\n email?: string;\r\n tenantId?: string;\r\n theme?: {\r\n primaryColor?: string;\r\n userBubble?: string;\r\n botBubble?: string;\r\n backgroundColor?: string;\r\n textColor?: string;\r\n };\r\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\r\n zIndex?: number;\r\n onInit?: () => void;\r\n onDestroy?: () => void;\r\n}\r\n\r\nexport const ChatbotWidget: React.FC<ChatbotWidgetProps> = ({\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position = 'bottom-right',\r\n zIndex = 9999,\r\n onInit,\r\n onDestroy,\r\n}) => {\r\n const widgetRef = useRef<any>(null);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n // Import the widget dynamically to avoid SSR issues\r\n const initializeWidget = async () => {\r\n try {\r\n // Import the widget module\r\n const { default: Chatbot } = await import('../widget-embed');\r\n \r\n // Initialize the widget with configuration\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n\r\n // Store reference to the widget instance\r\n widgetRef.current = Chatbot;\r\n \r\n // Initialize the widget\r\n Chatbot.init(config);\r\n \r\n // Call onInit callback if provided\r\n if (onInit) {\r\n onInit();\r\n }\r\n } catch (error) {\r\n console.error('Failed to initialize chatbot widget:', error);\r\n }\r\n };\r\n\r\n initializeWidget();\r\n\r\n // Cleanup function\r\n return () => {\r\n if (widgetRef.current) {\r\n try {\r\n widgetRef.current.destroy();\r\n if (onDestroy) {\r\n onDestroy();\r\n }\r\n } catch (error) {\r\n console.error('Error destroying chatbot widget:', error);\r\n }\r\n }\r\n };\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex, onInit, onDestroy]);\r\n\r\n // Update widget configuration when props change\r\n useEffect(() => {\r\n if (widgetRef.current) {\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n \r\n try {\r\n widgetRef.current.updateConfig(config);\r\n } catch (error) {\r\n console.error('Error updating chatbot widget config:', error);\r\n }\r\n }\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex]);\r\n\r\n // This component doesn't render anything visible as the widget creates its own DOM elements\r\n return <div ref={containerRef} style={{ display: 'none' }} />;\r\n};\r\n\r\nexport default ChatbotWidget;"],"names":[],"mappings":";;;AAmBO,MAAM,gBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,YAAY,OAAY,IAAI;AAClC,QAAM,eAAe,OAAuB,IAAI;AAEhD,YAAU,MAAM;AAEd,UAAM,mBAAmB,YAAY;AACnC,UAAI;AAEF,cAAM,EAAE,SAAS,YAAY,MAAM,OAAO,sBAAiB;AAG3D,cAAM,SAAS;AAAA,UACb;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAIF,kBAAU,UAAU;AAGpB,gBAAQ,KAAK,MAAM;AAGnB,YAAI,QAAQ;AACV,iBAAA;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAM,wCAAwC,KAAK;AAAA,MAC7D;AAAA,IACF;AAEA,qBAAA;AAGA,WAAO,MAAM;AACX,UAAI,UAAU,SAAS;AACrB,YAAI;AACF,oBAAU,QAAQ,QAAA;AAClB,cAAI,WAAW;AACb,sBAAA;AAAA,UACF;AAAA,QACF,SAAS,OAAO;AACd,kBAAQ,MAAM,oCAAoC,KAAK;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,gBAAgB,OAAO,UAAU,OAAO,UAAU,QAAQ,QAAQ,SAAS,CAAC;AAGhF,YAAU,MAAM;AACd,QAAI,UAAU,SAAS;AACrB,YAAM,SAAS;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAGF,UAAI;AACF,kBAAU,QAAQ,aAAa,MAAM;AAAA,MACvC,SAAS,OAAO;AACd,gBAAQ,MAAM,yCAAyC,KAAK;AAAA,MAC9D;AAAA,IACF;AAAA,EACF,GAAG,CAAC,gBAAgB,OAAO,UAAU,OAAO,UAAU,MAAM,CAAC;AAG7D,SAAO,oBAAC,SAAI,KAAK,cAAc,OAAO,EAAE,SAAS,UAAU;AAC7D;"}
1
+ {"version":3,"file":"index.es.js","sources":["../src/components/ChatbotWidget.tsx","../src/index.ts"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\r\n\r\nexport interface ChatbotWidgetProps {\r\n pangentsApiKey?: string;\r\n email?: string;\r\n tenantId?: string;\r\n theme?: {\r\n primaryColor?: string;\r\n userBubble?: string;\r\n botBubble?: string;\r\n backgroundColor?: string;\r\n textColor?: string;\r\n };\r\n position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';\r\n zIndex?: number;\r\n onInit?: () => void;\r\n onDestroy?: () => void;\r\n}\r\n\r\nexport const ChatbotWidget: React.FC<ChatbotWidgetProps> = ({\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position = 'bottom-right',\r\n zIndex = 9999,\r\n onInit,\r\n onDestroy,\r\n}) => {\r\n const widgetRef = useRef<any>(null);\r\n const containerRef = useRef<HTMLDivElement>(null);\r\n\r\n useEffect(() => {\r\n // Import the widget dynamically to avoid SSR issues\r\n const initializeWidget = async () => {\r\n try {\r\n // Import the widget module\r\n const { default: Chatbot } = await import('../widget-embed');\r\n \r\n // Initialize the widget with configuration\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n\r\n // Store reference to the widget instance\r\n widgetRef.current = Chatbot;\r\n \r\n // Initialize the widget\r\n Chatbot.init(config);\r\n \r\n // Call onInit callback if provided\r\n if (onInit) {\r\n onInit();\r\n }\r\n } catch (error) {\r\n console.error('Failed to initialize chatbot widget:', error);\r\n }\r\n };\r\n\r\n initializeWidget();\r\n\r\n // Cleanup function\r\n return () => {\r\n if (widgetRef.current) {\r\n try {\r\n widgetRef.current.destroy();\r\n if (onDestroy) {\r\n onDestroy();\r\n }\r\n } catch (error) {\r\n console.error('Error destroying chatbot widget:', error);\r\n }\r\n }\r\n };\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex, onInit, onDestroy]);\r\n\r\n // Update widget configuration when props change\r\n useEffect(() => {\r\n if (widgetRef.current) {\r\n const config = {\r\n pangentsApiKey,\r\n email,\r\n tenantId,\r\n theme,\r\n position,\r\n zIndex,\r\n };\r\n \r\n try {\r\n widgetRef.current.updateConfig(config);\r\n } catch (error) {\r\n console.error('Error updating chatbot widget config:', error);\r\n }\r\n }\r\n }, [pangentsApiKey, email, tenantId, theme, position, zIndex]);\r\n\r\n // This component doesn't render anything visible as the widget creates its own DOM elements\r\n return <div ref={containerRef} style={{ display: 'none' }} />;\r\n};\r\n\r\nexport default ChatbotWidget;","if (typeof window !== 'undefined') {\n try {\n const css = (window as any).__PANGENTS_WIDGET_CSS;\n if (css && !document.getElementById('pangents-widget-styles')) {\n const style = document.createElement('style');\n style.id = 'pangents-widget-styles';\n style.textContent = css;\n document.head.appendChild(style);\n }\n } catch { void 0; }\n}\n\n// Main exports for the package\nexport { default as Widget } from './Widget';\nexport { ChatbotWidget } from './components/ChatbotWidget';\nexport type { ChatbotWidgetProps } from './components/ChatbotWidget';\nexport type { WidgetConfig } from './types';\n\n// Export the widget embed for direct usage\nexport { default as Chatbot } from './widget-embed';\n\n// Re-export everything from components\nexport * from './components/ChatbotWidget';\n"],"names":[],"mappings":";;;AAmBO,MAAM,gBAA8C,CAAC;AAAA,EAC1D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX,SAAS;AAAA,EACT;AAAA,EACA;AACF,MAAM;AACJ,QAAM,YAAY,OAAY,IAAI;AAClC,QAAM,eAAe,OAAuB,IAAI;AAEhD,YAAU,MAAM;AAEd,UAAM,mBAAmB,YAAY;AACnC,UAAI;AAEF,cAAM,EAAE,SAAS,YAAY,MAAM,OAAO,sBAAiB;AAG3D,cAAM,SAAS;AAAA,UACb;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,UACA;AAAA,QAAA;AAIF,kBAAU,UAAU;AAGpB,gBAAQ,KAAK,MAAM;AAGnB,YAAI,QAAQ;AACV,iBAAA;AAAA,QACF;AAAA,MACF,SAAS,OAAO;AACd,gBAAQ,MAAM,wCAAwC,KAAK;AAAA,MAC7D;AAAA,IACF;AAEA,qBAAA;AAGA,WAAO,MAAM;AACX,UAAI,UAAU,SAAS;AACrB,YAAI;AACF,oBAAU,QAAQ,QAAA;AAClB,cAAI,WAAW;AACb,sBAAA;AAAA,UACF;AAAA,QACF,SAAS,OAAO;AACd,kBAAQ,MAAM,oCAAoC,KAAK;AAAA,QACzD;AAAA,MACF;AAAA,IACF;AAAA,EACF,GAAG,CAAC,gBAAgB,OAAO,UAAU,OAAO,UAAU,QAAQ,QAAQ,SAAS,CAAC;AAGhF,YAAU,MAAM;AACd,QAAI,UAAU,SAAS;AACrB,YAAM,SAAS;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MAAA;AAGF,UAAI;AACF,kBAAU,QAAQ,aAAa,MAAM;AAAA,MACvC,SAAS,OAAO;AACd,gBAAQ,MAAM,yCAAyC,KAAK;AAAA,MAC9D;AAAA,IACF;AAAA,EACF,GAAG,CAAC,gBAAgB,OAAO,UAAU,OAAO,UAAU,MAAM,CAAC;AAG7D,SAAO,oBAAC,SAAI,KAAK,cAAc,OAAO,EAAE,SAAS,UAAU;AAC7D;ACvGA,IAAI,OAAO,WAAW,aAAa;AACjC,MAAI;AACF,UAAM,MAAO,OAAe;AAC5B,QAAI,OAAO,CAAC,SAAS,eAAe,wBAAwB,GAAG;AAC7D,YAAM,QAAQ,SAAS,cAAc,OAAO;AAC5C,YAAM,KAAK;AACX,YAAM,cAAc;AACpB,eAAS,KAAK,YAAY,KAAK;AAAA,IACjC;AAAA,EACF,QAAQ;AAAA,EAAU;AACpB;"}
@@ -26,6 +26,7 @@ export interface WidgetConfig {
26
26
  pangentsApiKey: string;
27
27
  tenantId?: string;
28
28
  theme?: WidgetTheme;
29
+ zIndex?: number;
29
30
  }
30
31
  export interface ChatState {
31
32
  isOpen: boolean;