open-chat-studio-widget 0.3.1 → 0.4.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.
Files changed (39) hide show
  1. package/README.md +14 -7
  2. package/dist/cjs/{index-d39b7c53.js → index-b700441a.js} +83 -4
  3. package/dist/cjs/index-b700441a.js.map +1 -0
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/cjs/open-chat-studio-widget.cjs.entry.js +4895 -61
  6. package/dist/cjs/open-chat-studio-widget.cjs.entry.js.map +1 -1
  7. package/dist/cjs/open-chat-studio-widget.cjs.js +2 -2
  8. package/dist/collection/components/ocs-chat/heroicons.js +10 -16
  9. package/dist/collection/components/ocs-chat/heroicons.js.map +1 -1
  10. package/dist/collection/components/ocs-chat/ocs-chat.css +1121 -74
  11. package/dist/collection/components/ocs-chat/ocs-chat.js +802 -50
  12. package/dist/collection/components/ocs-chat/ocs-chat.js.map +1 -1
  13. package/dist/collection/utils/markdown.js +64 -0
  14. package/dist/collection/utils/markdown.js.map +1 -0
  15. package/dist/components/open-chat-studio-widget.js +4921 -64
  16. package/dist/components/open-chat-studio-widget.js.map +1 -1
  17. package/dist/esm/{index-b73ebc69.js → index-b188b488.js} +83 -4
  18. package/dist/esm/index-b188b488.js.map +1 -0
  19. package/dist/esm/loader.js +3 -3
  20. package/dist/esm/open-chat-studio-widget.entry.js +4895 -61
  21. package/dist/esm/open-chat-studio-widget.entry.js.map +1 -1
  22. package/dist/esm/open-chat-studio-widget.js +3 -3
  23. package/dist/open-chat-studio-widget/open-chat-studio-widget.esm.js +1 -1
  24. package/dist/open-chat-studio-widget/open-chat-studio-widget.esm.js.map +1 -1
  25. package/dist/open-chat-studio-widget/p-a0fbe1b4.js +3 -0
  26. package/dist/open-chat-studio-widget/p-a0fbe1b4.js.map +1 -0
  27. package/dist/open-chat-studio-widget/p-eb89e6d7.entry.js +3 -0
  28. package/dist/open-chat-studio-widget/p-eb89e6d7.entry.js.map +1 -0
  29. package/dist/types/components/ocs-chat/heroicons.d.ts +4 -6
  30. package/dist/types/components/ocs-chat/ocs-chat.d.ts +142 -7
  31. package/dist/types/components.d.ts +65 -9
  32. package/dist/types/utils/markdown.d.ts +6 -0
  33. package/package.json +4 -3
  34. package/dist/cjs/index-d39b7c53.js.map +0 -1
  35. package/dist/esm/index-b73ebc69.js.map +0 -1
  36. package/dist/open-chat-studio-widget/p-4cdc34c1.js +0 -3
  37. package/dist/open-chat-studio-widget/p-4cdc34c1.js.map +0 -1
  38. package/dist/open-chat-studio-widget/p-c4c7c404.entry.js +0 -2
  39. package/dist/open-chat-studio-widget/p-c4c7c404.entry.js.map +0 -1
package/README.md CHANGED
@@ -9,13 +9,20 @@ For more information, see the [Open Chat Studio documentation](https://docs.open
9
9
 
10
10
  ## Properties
11
11
 
12
- | Property | Attribute | Description | Type | Default |
13
- | --------------------- | ------------- | ------------------------------------------------------ | ------------------------------- | ----------- |
14
- | `botUrl` _(required)_ | `bot-url` | The URL of the bot to connect to. | `string` | `undefined` |
15
- | `buttonText` | `button-text` | The text to display on the button. | `string` | `"Chat"` |
16
- | `expanded` | `expanded` | Whether the chat widget is initially expanded. | `boolean` | `false` |
17
- | `position` | `position` | The initial position of the chat widget on the screen. | `"center" \| "left" \| "right"` | `'right'` |
18
- | `visible` | `visible` | Whether the chat widget is visible on load. | `boolean` | `false` |
12
+ | Property | Attribute | Description | Type | Default |
13
+ | ------------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------- | ------------------------------- |
14
+ | `allowFullScreen` | `allow-full-screen` | Allow the user to make the chat window full screen. | `boolean` | `true` |
15
+ | `apiBaseUrl` | `api-base-url` | The base URL for the API (defaults to current origin). | `string` | `"https://chatbots.dimagi.com"` |
16
+ | `buttonShape` | `button-shape` | The shape of the chat button. 'round' makes it circular, 'square' keeps it rectangular. | `"round" \| "square"` | `'square'` |
17
+ | `buttonText` | `button-text` | The text to display on the button. | `string` | `undefined` |
18
+ | `chatbotId` _(required)_ | `chatbot-id` | The ID of the chatbot to connect to. | `string` | `undefined` |
19
+ | `iconUrl` | `icon-url` | URL of the icon to display on the button. If not provided, uses the default OCS logo. | `string` | `undefined` |
20
+ | `persistentSession` | `persistent-session` | Whether to persist session data to local storage to allow resuming previous conversations after page reload. | `boolean` | `true` |
21
+ | `persistentSessionExpire` | `persistent-session-expire` | Minutes since the most recent message after which the session data in local storage will expire. Set this to `0` to never expire. | `number` | `60 * 24` |
22
+ | `position` | `position` | The initial position of the chat widget on the screen. | `"center" \| "left" \| "right"` | `'right'` |
23
+ | `starterQuestions` | `starter-questions` | Array of starter questions that users can click to send (JSON array of strings) | `string` | `undefined` |
24
+ | `visible` | `visible` | Whether the chat widget is visible on load. | `boolean` | `false` |
25
+ | `welcomeMessages` | `welcome-messages` | Welcome messages to display above starter questions (JSON array of strings) | `string` | `undefined` |
19
26
 
20
27
 
21
28
  ## CSS Custom Properties
@@ -21,7 +21,7 @@ function _interopNamespace(e) {
21
21
  }
22
22
 
23
23
  const NAMESPACE = 'open-chat-studio-widget';
24
- const BUILD = /* open-chat-studio-widget */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: false, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: false, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, modernPropertyDecls: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: false, propString: true, reflect: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: false, slotChildNodesFix: false, slotRelocation: false, state: true, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: false, vdomListener: true, vdomPropOrAttr: true, vdomRef: false, vdomRender: true, vdomStyle: false, vdomText: true, vdomXlink: false, watchCallback: false };
24
+ const BUILD = /* open-chat-studio-widget */ { allRenderFn: true, appendChildSlotFix: false, asyncLoading: true, asyncQueue: false, attachStyles: true, cloneNodeFix: false, cmpDidLoad: true, cmpDidRender: false, cmpDidUnload: false, cmpDidUpdate: false, cmpShouldUpdate: false, cmpWillLoad: true, cmpWillRender: false, cmpWillUpdate: false, connectedCallback: false, constructableCSS: true, cssAnnotations: true, devTools: false, disconnectedCallback: true, element: false, event: false, experimentalScopedSlotChanges: false, experimentalSlotFixes: false, formAssociated: false, hasRenderFn: true, hostListener: false, hostListenerTarget: false, hostListenerTargetBody: false, hostListenerTargetDocument: false, hostListenerTargetParent: false, hostListenerTargetWindow: false, hotModuleReplacement: false, hydrateClientSide: false, hydrateServerSide: false, hydratedAttribute: false, hydratedClass: true, hydratedSelectorName: "hydrated", initializeNextTick: false, invisiblePrehydration: true, isDebug: false, isDev: false, isTesting: false, lazyLoad: true, lifecycle: true, lifecycleDOMEvents: false, member: true, method: false, mode: false, modernPropertyDecls: false, observeAttribute: true, profile: false, prop: true, propBoolean: true, propMutable: true, propNumber: true, propString: true, reflect: false, scoped: false, scopedSlotTextContentFix: false, scriptDataOpts: false, shadowDelegatesFocus: false, shadowDom: true, slot: false, slotChildNodesFix: false, slotRelocation: false, state: true, style: true, svg: true, taskQueue: true, transformTagName: false, updatable: true, vdomAttribute: true, vdomClass: true, vdomFunctional: true, vdomKey: true, vdomListener: true, vdomPropOrAttr: true, vdomRef: true, vdomRender: true, vdomStyle: true, vdomText: true, vdomXlink: false, watchCallback: false };
25
25
 
26
26
  /*
27
27
  Stencil Client Platform v4.26.0 | MIT Licensed | https://stenciljs.com
@@ -227,6 +227,7 @@ var uniqueTime = (key, measureText) => {
227
227
  };
228
228
  var h = (nodeName, vnodeData, ...children) => {
229
229
  let child = null;
230
+ let key = null;
230
231
  let simple = false;
231
232
  let lastSimple = false;
232
233
  const vNodeChildren = [];
@@ -250,6 +251,9 @@ var h = (nodeName, vnodeData, ...children) => {
250
251
  };
251
252
  walk(children);
252
253
  if (vnodeData) {
254
+ if (vnodeData.key) {
255
+ key = vnodeData.key;
256
+ }
253
257
  {
254
258
  const classData = vnodeData.className || vnodeData.class;
255
259
  if (classData) {
@@ -269,6 +273,9 @@ var h = (nodeName, vnodeData, ...children) => {
269
273
  if (vNodeChildren.length > 0) {
270
274
  vnode.$children$ = vNodeChildren;
271
275
  }
276
+ {
277
+ vnode.$key$ = key;
278
+ }
272
279
  return vnode;
273
280
  };
274
281
  var newVNode = (tag, text) => {
@@ -282,6 +289,9 @@ var newVNode = (tag, text) => {
282
289
  {
283
290
  vnode.$attrs$ = null;
284
291
  }
292
+ {
293
+ vnode.$key$ = null;
294
+ }
285
295
  return vnode;
286
296
  };
287
297
  var Host = {};
@@ -321,6 +331,9 @@ var parsePropertyValue = (propValue, propType) => {
321
331
  if (propType & 4 /* Boolean */) {
322
332
  return propValue === "false" ? false : propValue === "" || !!propValue;
323
333
  }
334
+ if (propType & 2 /* Number */) {
335
+ return parseFloat(propValue);
336
+ }
324
337
  if (propType & 1 /* String */) {
325
338
  return String(propValue);
326
339
  }
@@ -438,6 +451,31 @@ var setAccessor = (elm, memberName, oldValue, newValue, isSvg, flags, initialRen
438
451
  classList.remove(...oldClasses.filter((c) => c && !newClasses.includes(c)));
439
452
  classList.add(...newClasses.filter((c) => c && !oldClasses.includes(c)));
440
453
  }
454
+ } else if (memberName === "style") {
455
+ {
456
+ for (const prop in oldValue) {
457
+ if (!newValue || newValue[prop] == null) {
458
+ if (prop.includes("-")) {
459
+ elm.style.removeProperty(prop);
460
+ } else {
461
+ elm.style[prop] = "";
462
+ }
463
+ }
464
+ }
465
+ }
466
+ for (const prop in newValue) {
467
+ if (!oldValue || newValue[prop] !== oldValue[prop]) {
468
+ if (prop.includes("-")) {
469
+ elm.style.setProperty(prop, newValue[prop]);
470
+ } else {
471
+ elm.style[prop] = newValue[prop];
472
+ }
473
+ }
474
+ }
475
+ } else if (memberName === "key") ; else if (memberName === "ref") {
476
+ if (newValue) {
477
+ newValue(elm);
478
+ }
441
479
  } else if ((!isProp ) && memberName[0] === "o" && memberName[1] === "n") {
442
480
  if (memberName[2] === "-") {
443
481
  memberName = memberName.slice(3);
@@ -606,6 +644,7 @@ var removeVnodes = (vnodes, startIdx, endIdx) => {
606
644
  const vnode = vnodes[index];
607
645
  if (vnode) {
608
646
  const elm = vnode.$elm$;
647
+ nullifyVNodeRefs(vnode);
609
648
  if (elm) {
610
649
  elm.remove();
611
650
  }
@@ -615,6 +654,8 @@ var removeVnodes = (vnodes, startIdx, endIdx) => {
615
654
  var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = false) => {
616
655
  let oldStartIdx = 0;
617
656
  let newStartIdx = 0;
657
+ let idxInOld = 0;
658
+ let i2 = 0;
618
659
  let oldEndIdx = oldCh.length - 1;
619
660
  let oldStartVnode = oldCh[0];
620
661
  let oldEndVnode = oldCh[oldEndIdx];
@@ -622,6 +663,7 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
622
663
  let newStartVnode = newCh[0];
623
664
  let newEndVnode = newCh[newEndIdx];
624
665
  let node;
666
+ let elmToMove;
625
667
  while (oldStartIdx <= oldEndIdx && newStartIdx <= newEndIdx) {
626
668
  if (oldStartVnode == null) {
627
669
  oldStartVnode = oldCh[++oldStartIdx];
@@ -650,7 +692,26 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
650
692
  oldEndVnode = oldCh[--oldEndIdx];
651
693
  newStartVnode = newCh[++newStartIdx];
652
694
  } else {
695
+ idxInOld = -1;
653
696
  {
697
+ for (i2 = oldStartIdx; i2 <= oldEndIdx; ++i2) {
698
+ if (oldCh[i2] && oldCh[i2].$key$ !== null && oldCh[i2].$key$ === newStartVnode.$key$) {
699
+ idxInOld = i2;
700
+ break;
701
+ }
702
+ }
703
+ }
704
+ if (idxInOld >= 0) {
705
+ elmToMove = oldCh[idxInOld];
706
+ if (elmToMove.$tag$ !== newStartVnode.$tag$) {
707
+ node = createElm(oldCh && oldCh[newStartIdx], newVNode2, idxInOld);
708
+ } else {
709
+ patch(elmToMove, newStartVnode, isInitialRender);
710
+ oldCh[idxInOld] = void 0;
711
+ node = elmToMove.$elm$;
712
+ }
713
+ newStartVnode = newCh[++newStartIdx];
714
+ } else {
654
715
  node = createElm(oldCh && oldCh[newStartIdx], newVNode2, newStartIdx);
655
716
  newStartVnode = newCh[++newStartIdx];
656
717
  }
@@ -676,6 +737,9 @@ var updateChildren = (parentElm, oldCh, newVNode2, newCh, isInitialRender = fals
676
737
  };
677
738
  var isSameVnode = (leftVNode, rightVNode, isInitialRender = false) => {
678
739
  if (leftVNode.$tag$ === rightVNode.$tag$) {
740
+ if (!isInitialRender) {
741
+ return leftVNode.$key$ === rightVNode.$key$;
742
+ }
679
743
  if (isInitialRender && !leftVNode.$key$ && rightVNode.$key$) {
680
744
  leftVNode.$key$ = rightVNode.$key$;
681
745
  }
@@ -718,6 +782,12 @@ var patch = (oldVNode, newVNode2, isInitialRender = false) => {
718
782
  elm.data = text;
719
783
  }
720
784
  };
785
+ var nullifyVNodeRefs = (vNode) => {
786
+ {
787
+ vNode.$attrs$ && vNode.$attrs$.ref && vNode.$attrs$.ref(null);
788
+ vNode.$children$ && vNode.$children$.map(nullifyVNodeRefs);
789
+ }
790
+ };
721
791
  var insertBefore = (parent, newNode, reference) => {
722
792
  {
723
793
  return parent == null ? void 0 : parent.insertBefore(newNode, reference);
@@ -847,12 +917,16 @@ var postUpdateComponent = (hostRef) => {
847
917
  const tagName = hostRef.$cmpMeta$.$tagName$;
848
918
  const elm = hostRef.$hostElement$;
849
919
  const endPostUpdate = createTime("postUpdate", tagName);
920
+ const instance = hostRef.$lazyInstance$ ;
850
921
  const ancestorComponent = hostRef.$ancestorComponent$;
851
922
  if (!(hostRef.$flags$ & 64 /* hasLoadedComponent */)) {
852
923
  hostRef.$flags$ |= 64 /* hasLoadedComponent */;
853
924
  {
854
925
  addHydratedFlag(elm);
855
926
  }
927
+ {
928
+ safeCall(instance, "componentDidLoad", void 0, elm);
929
+ }
856
930
  endPostUpdate();
857
931
  {
858
932
  hostRef.$onReadyResolve$(elm);
@@ -1140,12 +1214,17 @@ var connectedCallback = (elm) => {
1140
1214
  }
1141
1215
  };
1142
1216
  var disconnectInstance = (instance, elm) => {
1217
+ {
1218
+ safeCall(instance, "disconnectedCallback", void 0, elm || instance);
1219
+ }
1143
1220
  };
1144
1221
  var disconnectedCallback = async (elm) => {
1145
1222
  if ((plt.$flags$ & 1 /* isTmpDisconnected */) === 0) {
1146
1223
  const hostRef = getHostRef(elm);
1147
- if (hostRef == null ? void 0 : hostRef.$lazyInstance$) ; else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
1148
- hostRef.$onReadyPromise$.then(() => disconnectInstance());
1224
+ if (hostRef == null ? void 0 : hostRef.$lazyInstance$) {
1225
+ disconnectInstance(hostRef.$lazyInstance$, elm);
1226
+ } else if (hostRef == null ? void 0 : hostRef.$onReadyPromise$) {
1227
+ hostRef.$onReadyPromise$.then(() => disconnectInstance(hostRef.$lazyInstance$, elm));
1149
1228
  }
1150
1229
  }
1151
1230
  if (rootAppliedStyles.has(elm)) {
@@ -1290,4 +1369,4 @@ exports.promiseResolve = promiseResolve;
1290
1369
  exports.registerInstance = registerInstance;
1291
1370
  exports.setNonce = setNonce;
1292
1371
 
1293
- //# sourceMappingURL=index-d39b7c53.js.map
1372
+ //# sourceMappingURL=index-b700441a.js.map