@yext/chat-ui-react 0.7.2 → 0.8.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.
Files changed (45) hide show
  1. package/README.md +10 -2
  2. package/lib/bundle.css +1 -1
  3. package/lib/commonjs/package.json.js +1 -1
  4. package/lib/commonjs/src/components/ChatPanel.d.ts.map +1 -1
  5. package/lib/commonjs/src/components/ChatPanel.js +3 -14
  6. package/lib/commonjs/src/components/ChatPanel.js.map +1 -1
  7. package/lib/commonjs/src/components/ChatPopUp.d.ts +31 -4
  8. package/lib/commonjs/src/components/ChatPopUp.d.ts.map +1 -1
  9. package/lib/commonjs/src/components/ChatPopUp.js +58 -10
  10. package/lib/commonjs/src/components/ChatPopUp.js.map +1 -1
  11. package/lib/commonjs/src/components/InitialMessagePopUp.d.ts +33 -0
  12. package/lib/commonjs/src/components/InitialMessagePopUp.d.ts.map +1 -0
  13. package/lib/commonjs/src/components/InitialMessagePopUp.js +44 -0
  14. package/lib/commonjs/src/components/InitialMessagePopUp.js.map +1 -0
  15. package/lib/commonjs/src/components/index.d.ts +2 -1
  16. package/lib/commonjs/src/components/index.d.ts.map +1 -1
  17. package/lib/commonjs/src/hooks/useFetchInitialMessage.d.ts +13 -0
  18. package/lib/commonjs/src/hooks/useFetchInitialMessage.d.ts.map +1 -0
  19. package/lib/commonjs/src/hooks/useFetchInitialMessage.js +53 -0
  20. package/lib/commonjs/src/hooks/useFetchInitialMessage.js.map +1 -0
  21. package/lib/esm/index.d.ts +42 -4
  22. package/lib/esm/package.json.mjs +1 -1
  23. package/lib/esm/src/components/ChatPanel.d.ts.map +1 -1
  24. package/lib/esm/src/components/ChatPanel.mjs +4 -15
  25. package/lib/esm/src/components/ChatPanel.mjs.map +1 -1
  26. package/lib/esm/src/components/ChatPopUp.d.ts +31 -4
  27. package/lib/esm/src/components/ChatPopUp.d.ts.map +1 -1
  28. package/lib/esm/src/components/ChatPopUp.mjs +58 -10
  29. package/lib/esm/src/components/ChatPopUp.mjs.map +1 -1
  30. package/lib/esm/src/components/InitialMessagePopUp.d.ts +33 -0
  31. package/lib/esm/src/components/InitialMessagePopUp.d.ts.map +1 -0
  32. package/lib/esm/src/components/InitialMessagePopUp.mjs +38 -0
  33. package/lib/esm/src/components/InitialMessagePopUp.mjs.map +1 -0
  34. package/lib/esm/src/components/index.d.ts +2 -1
  35. package/lib/esm/src/components/index.d.ts.map +1 -1
  36. package/lib/esm/src/hooks/useFetchInitialMessage.d.ts +13 -0
  37. package/lib/esm/src/hooks/useFetchInitialMessage.d.ts.map +1 -0
  38. package/lib/esm/src/hooks/useFetchInitialMessage.mjs +51 -0
  39. package/lib/esm/src/hooks/useFetchInitialMessage.mjs.map +1 -0
  40. package/package.json +2 -2
  41. package/src/components/ChatPanel.tsx +5 -22
  42. package/src/components/ChatPopUp.tsx +159 -33
  43. package/src/components/InitialMessagePopUp.tsx +76 -0
  44. package/src/components/index.ts +3 -2
  45. package/src/hooks/useFetchInitialMessage.ts +58 -0
package/README.md CHANGED
@@ -41,8 +41,16 @@ export default App;
41
41
 
42
42
  ### default styling
43
43
 
44
- By default, the component library uses Tailwind styling. However, for projects that
45
- do not use Tailwind, a css bundle is exported as part of this package. To use it, you can import
44
+ #### Tailwind
45
+
46
+ The component library utilizes Tailwind styling by default. Please make sure that your application's tailwind configuration includes the following:
47
+
48
+ - The `content` field should contain the path to the location of the `@yext/chat-ui-react` library (e.g., `node_modules/@yext/chat-ui-react/lib/**/*.{js,jsx}`)
49
+ - The default theme should be extended with the custom styling used by the components specified [here](https://github.com/yext/chat-ui-react/blob/main/tailwind.config.js).
50
+
51
+ #### CSS bundle
52
+
53
+ For projects that do not use Tailwind, a css bundle is exported as part of this package. To use it, you can import
46
54
  the file `@yext/chat-ui-react/bundle.css` into your normal CSS flow.
47
55
 
48
56
  Example for Yext Pages:
package/lib/bundle.css CHANGED
@@ -1 +1 @@
1
- .yext-chat { width: 100%; height: 100%; } /*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/.yext-chat *,.yext-chat :after,.yext-chat :before{box-sizing:border-box;border:0 solid #e5e7eb}.yext-chat :after,.yext-chat :before{--tw-content:""}.yext-chat {line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}.yext-chat {margin:0;line-height:inherit}.yext-chat hr{height:0;color:inherit;border-top-width:1px}.yext-chat abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.yext-chat h1,.yext-chat h2,.yext-chat h3,.yext-chat h4,.yext-chat h5,.yext-chat h6{font-size:inherit;font-weight:inherit}.yext-chat a{color:inherit;text-decoration:inherit}.yext-chat b,.yext-chat strong{font-weight:bolder}.yext-chat code,.yext-chat kbd,.yext-chat pre,.yext-chat samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.yext-chat small{font-size:80%}.yext-chat sub,.yext-chat sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}.yext-chat sub{bottom:-.25em}.yext-chat sup{top:-.5em}.yext-chat table{text-indent:0;border-color:inherit;border-collapse:collapse}.yext-chat button,.yext-chat input,.yext-chat optgroup,.yext-chat select,.yext-chat textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.yext-chat button,.yext-chat select{text-transform:none}.yext-chat [type=button],.yext-chat [type=reset],.yext-chat [type=submit],.yext-chat button{-webkit-appearance:button;background-color:initial;background-image:none}.yext-chat :-moz-focusring{outline:auto}.yext-chat :-moz-ui-invalid{box-shadow:none}.yext-chat progress{vertical-align:initial}.yext-chat ::-webkit-inner-spin-button,.yext-chat ::-webkit-outer-spin-button{height:auto}.yext-chat [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.yext-chat ::-webkit-search-decoration{-webkit-appearance:none}.yext-chat ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.yext-chat summary{display:list-item}.yext-chat blockquote,.yext-chat dd,.yext-chat dl,.yext-chat figure,.yext-chat h1,.yext-chat h2,.yext-chat h3,.yext-chat h4,.yext-chat h5,.yext-chat h6,.yext-chat hr,.yext-chat p,.yext-chat pre{margin:0}.yext-chat fieldset{margin:0}.yext-chat fieldset,.yext-chat legend{padding:0}.yext-chat menu,.yext-chat ol,.yext-chat ul{list-style:none;margin:0;padding:0}.yext-chat textarea{resize:vertical}.yext-chat input::-moz-placeholder,.yext-chat textarea::-moz-placeholder{opacity:1;color:#9ca3af}.yext-chat input::placeholder,.yext-chat textarea::placeholder{opacity:1;color:#9ca3af}.yext-chat [role=button],.yext-chat button{cursor:pointer}.yext-chat :disabled{cursor:default}.yext-chat audio,.yext-chat canvas,.yext-chat embed,.yext-chat iframe,.yext-chat img,.yext-chat object,.yext-chat svg,.yext-chat video{display:block;vertical-align:middle}.yext-chat img,.yext-chat video{max-width:100%;height:auto}.yext-chat [hidden]{display:none}.yext-chat *,.yext-chat ::backdrop,.yext-chat :after,.yext-chat :before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.yext-chat .container{width:100%}@media (min-width:640px){.yext-chat .container{max-width:640px}}@media (min-width:768px){.yext-chat .container{max-width:768px}}@media (min-width:1024px){.yext-chat .container{max-width:1024px}}@media (min-width:1280px){.yext-chat .container{max-width:1280px}}@media (min-width:1536px){.yext-chat .container{max-width:1536px}}.yext-chat .prose{color:var(--tw-prose-body);max-width:65ch}.yext-chat .prose :where(p):not(:where([class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.yext-chat .prose :where([class~=lead]):not(:where([class~=not-prose] *)){color:var(--tw-prose-lead);font-size:1.25em;line-height:1.6;margin-top:1.2em;margin-bottom:1.2em}.yext-chat .prose :where(a):not(:where([class~=not-prose] *)){color:var(--tw-prose-links);text-decoration:underline;font-weight:500}.yext-chat .prose :where(strong):not(:where([class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.yext-chat .prose :where(a strong):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(blockquote strong):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(thead th strong):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(ol):not(:where([class~=not-prose] *)){list-style-type:decimal;margin-top:1.25em;margin-bottom:1.25em;padding-left:1.625em}.yext-chat .prose :where(ol[type=A]):not(:where([class~=not-prose] *)){list-style-type:upper-alpha}.yext-chat .prose :where(ol[type=a]):not(:where([class~=not-prose] *)){list-style-type:lower-alpha}.yext-chat .prose :where(ol[type=A s]):not(:where([class~=not-prose] *)){list-style-type:upper-alpha}.yext-chat .prose :where(ol[type=a s]):not(:where([class~=not-prose] *)){list-style-type:lower-alpha}.yext-chat .prose :where(ol[type=I]):not(:where([class~=not-prose] *)){list-style-type:upper-roman}.yext-chat .prose :where(ol[type=i]):not(:where([class~=not-prose] *)){list-style-type:lower-roman}.yext-chat .prose :where(ol[type=I s]):not(:where([class~=not-prose] *)){list-style-type:upper-roman}.yext-chat .prose :where(ol[type=i s]):not(:where([class~=not-prose] *)){list-style-type:lower-roman}.yext-chat .prose :where(ol[type="1"]):not(:where([class~=not-prose] *)){list-style-type:decimal}.yext-chat .prose :where(ul):not(:where([class~=not-prose] *)){list-style-type:disc;margin-top:1.25em;margin-bottom:1.25em;padding-left:1.625em}.yext-chat .prose :where(ol>li):not(:where([class~=not-prose] *))::marker{font-weight:400;color:var(--tw-prose-counters)}.yext-chat .prose :where(ul>li):not(:where([class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.yext-chat .prose :where(hr):not(:where([class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.yext-chat .prose :where(blockquote):not(:where([class~=not-prose] *)){font-weight:500;font-style:italic;color:var(--tw-prose-quotes);border-left-width:.25rem;border-left-color:var(--tw-prose-quote-borders);quotes:"\201C""\201D""\2018""\2019";margin-top:1.6em;margin-bottom:1.6em;padding-left:1em}.yext-chat .prose :where(blockquote p:first-of-type):not(:where([class~=not-prose] *)):before{content:open-quote}.yext-chat .prose :where(blockquote p:last-of-type):not(:where([class~=not-prose] *)):after{content:close-quote}.yext-chat .prose :where(h1):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:800;font-size:2.25em;margin-top:0;margin-bottom:.8888889em;line-height:1.1111111}.yext-chat .prose :where(h1 strong):not(:where([class~=not-prose] *)){font-weight:900;color:inherit}.yext-chat .prose :where(h2):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:700;font-size:1.5em;margin-top:2em;margin-bottom:1em;line-height:1.3333333}.yext-chat .prose :where(h2 strong):not(:where([class~=not-prose] *)){font-weight:800;color:inherit}.yext-chat .prose :where(h3):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;font-size:1.25em;margin-top:1.6em;margin-bottom:.6em;line-height:1.6}.yext-chat .prose :where(h3 strong):not(:where([class~=not-prose] *)){font-weight:700;color:inherit}.yext-chat .prose :where(h4):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.5em;margin-bottom:.5em;line-height:1.5}.yext-chat .prose :where(h4 strong):not(:where([class~=not-prose] *)){font-weight:700;color:inherit}.yext-chat .prose :where(img):not(:where([class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.yext-chat .prose :where(figure>*):not(:where([class~=not-prose] *)){margin-top:0;margin-bottom:0}.yext-chat .prose :where(figcaption):not(:where([class~=not-prose] *)){color:var(--tw-prose-captions);font-size:.875em;line-height:1.4285714;margin-top:.8571429em}.yext-chat .prose :where(code):not(:where([class~=not-prose] *)){color:var(--tw-prose-code);font-weight:600;font-size:.875em}.yext-chat .prose :where(code):not(:where([class~=not-prose] *)):before{content:"`"}.yext-chat .prose :where(code):not(:where([class~=not-prose] *)):after{content:"`"}.yext-chat .prose :where(a code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(h1 code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(h2 code):not(:where([class~=not-prose] *)){color:inherit;font-size:.875em}.yext-chat .prose :where(h3 code):not(:where([class~=not-prose] *)){color:inherit;font-size:.9em}.yext-chat .prose :where(h4 code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(blockquote code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(thead th code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(pre):not(:where([class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);overflow-x:auto;font-weight:400;font-size:.875em;line-height:1.7142857;margin-top:1.7142857em;margin-bottom:1.7142857em;border-radius:.375rem;padding:.8571429em 1.1428571em}.yext-chat .prose :where(pre code):not(:where([class~=not-prose] *)){background-color:initial;border-width:0;border-radius:0;padding:0;font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}.yext-chat .prose :where(pre code):not(:where([class~=not-prose] *)):before{content:none}.yext-chat .prose :where(pre code):not(:where([class~=not-prose] *)):after{content:none}.yext-chat .prose :where(table):not(:where([class~=not-prose] *)){width:100%;table-layout:auto;text-align:left;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.7142857}.yext-chat .prose :where(thead):not(:where([class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.yext-chat .prose :where(thead th):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;vertical-align:bottom;padding-right:.5714286em;padding-bottom:.5714286em;padding-left:.5714286em}.yext-chat .prose :where(tbody tr):not(:where([class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.yext-chat .prose :where(tbody tr:last-child):not(:where([class~=not-prose] *)){border-bottom-width:0}.yext-chat .prose :where(tbody td):not(:where([class~=not-prose] *)){vertical-align:initial}.yext-chat .prose :where(tfoot):not(:where([class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.yext-chat .prose :where(tfoot td):not(:where([class~=not-prose] *)){vertical-align:top}.yext-chat .prose{--tw-prose-body:#374151;--tw-prose-headings:#111827;--tw-prose-lead:#4b5563;--tw-prose-links:#111827;--tw-prose-bold:#111827;--tw-prose-counters:#6b7280;--tw-prose-bullets:#d1d5db;--tw-prose-hr:#e5e7eb;--tw-prose-quotes:#111827;--tw-prose-quote-borders:#e5e7eb;--tw-prose-captions:#6b7280;--tw-prose-code:#111827;--tw-prose-pre-code:#e5e7eb;--tw-prose-pre-bg:#1f2937;--tw-prose-th-borders:#d1d5db;--tw-prose-td-borders:#e5e7eb;--tw-prose-invert-body:#d1d5db;--tw-prose-invert-headings:#fff;--tw-prose-invert-lead:#9ca3af;--tw-prose-invert-links:#fff;--tw-prose-invert-bold:#fff;--tw-prose-invert-counters:#9ca3af;--tw-prose-invert-bullets:#4b5563;--tw-prose-invert-hr:#374151;--tw-prose-invert-quotes:#f3f4f6;--tw-prose-invert-quote-borders:#374151;--tw-prose-invert-captions:#9ca3af;--tw-prose-invert-code:#fff;--tw-prose-invert-pre-code:#d1d5db;--tw-prose-invert-pre-bg:#00000080;--tw-prose-invert-th-borders:#4b5563;--tw-prose-invert-td-borders:#374151;font-size:1rem;line-height:1.75}.yext-chat .prose :where(video):not(:where([class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.yext-chat .prose :where(figure):not(:where([class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.yext-chat .prose :where(li):not(:where([class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.yext-chat .prose :where(ol>li):not(:where([class~=not-prose] *)){padding-left:.375em}.yext-chat .prose :where(ul>li):not(:where([class~=not-prose] *)){padding-left:.375em}.yext-chat .prose :where(.prose>ul>li p):not(:where([class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.yext-chat .prose :where(.prose>ul>li>:first-child):not(:where([class~=not-prose] *)){margin-top:1.25em}.yext-chat .prose :where(.prose>ul>li>:last-child):not(:where([class~=not-prose] *)){margin-bottom:1.25em}.yext-chat .prose :where(.prose>ol>li>:first-child):not(:where([class~=not-prose] *)){margin-top:1.25em}.yext-chat .prose :where(.prose>ol>li>:last-child):not(:where([class~=not-prose] *)){margin-bottom:1.25em}.yext-chat .prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.yext-chat .prose :where(hr+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(h2+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(h3+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(h4+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(thead th:first-child):not(:where([class~=not-prose] *)){padding-left:0}.yext-chat .prose :where(thead th:last-child):not(:where([class~=not-prose] *)){padding-right:0}.yext-chat .prose :where(tbody td,tfoot td):not(:where([class~=not-prose] *)){padding:.5714286em}.yext-chat .prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose] *)){padding-left:0}.yext-chat .prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose] *)){padding-right:0}.yext-chat .prose :where(.prose>:first-child):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(.prose>:last-child):not(:where([class~=not-prose] *)){margin-bottom:0}.yext-chat .invisible{visibility:hidden}.yext-chat .fixed{position:fixed}.yext-chat .absolute{position:absolute}.yext-chat .relative{position:relative}.yext-chat .-right-1{right:-.25rem}.yext-chat .-top-3{top:-.75rem}.yext-chat .bottom-2{bottom:.5rem}.yext-chat .bottom-2\.5{bottom:.625rem}.yext-chat .bottom-6{bottom:1.5rem}.yext-chat .right-4{right:1rem}.yext-chat .z-50{z-index:50}.yext-chat .my-0{margin-top:0;margin-bottom:0}.yext-chat .my-0\.5{margin-top:.125rem;margin-bottom:.125rem}.yext-chat .mb-3{margin-bottom:.75rem}.yext-chat .ml-4{margin-left:1rem}.yext-chat .ml-auto{margin-left:auto}.yext-chat .mt-auto{margin-top:auto}.yext-chat .flex{display:flex}.yext-chat .h-12{height:3rem}.yext-chat .h-2{height:.5rem}.yext-chat .h-6{height:1.5rem}.yext-chat .h-8{height:2rem}.yext-chat .h-\[22px\]{height:22px}.yext-chat .h-\[26px\]{height:26px}.yext-chat .h-\[28px\]{height:28px}.yext-chat .h-\[75vh\]{height:75vh}.yext-chat .h-fit{height:-moz-fit-content;height:fit-content}.yext-chat .h-full{height:100%}.yext-chat .w-12{width:3rem}.yext-chat .w-2{width:.5rem}.yext-chat .w-6{width:1.5rem}.yext-chat .w-8{width:2rem}.yext-chat .w-80{width:20rem}.yext-chat .w-\[22px\]{width:22px}.yext-chat .w-\[26px\]{width:26px}.yext-chat .w-\[28px\]{width:28px}.yext-chat .w-fit{width:-moz-fit-content;width:fit-content}.yext-chat .w-full{width:100%}.yext-chat .max-w-\[80\%\]{max-width:80%}.yext-chat .shrink-0{flex-shrink:0}.yext-chat .translate-y-0{--tw-translate-y:0px}.yext-chat .translate-y-0,.yext-chat .translate-y-\[20\%\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .translate-y-\[20\%\]{--tw-translate-y:20%}.yext-chat .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .animate-\[bounce_1s_infinite\]{animation:bounce 1s infinite}.yext-chat .animate-\[bounce_1s_infinite_0\.3s\]{animation:bounce 1s .3s infinite}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.yext-chat .animate-\[bounce_1s_infinite_0\.6s\]{animation:bounce 1s .6s infinite}@keyframes spin{to{transform:rotate(1turn)}}.yext-chat .animate-\[spin_0\.3s_linear\]{animation:spin .3s linear}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.yext-chat .animate-fade-in{animation:fade-in .4s}.yext-chat .cursor-pointer{cursor:pointer}.yext-chat .resize-none{resize:none}.yext-chat .flex-row{flex-direction:row}.yext-chat .flex-col{flex-direction:column}.yext-chat .items-center{align-items:center}.yext-chat .justify-center{justify-content:center}.yext-chat .justify-between{justify-content:space-between}.yext-chat .gap-1{gap:.25rem}.yext-chat .gap-x-1{-moz-column-gap:.25rem;column-gap:.25rem}.yext-chat .gap-y-1{row-gap:.25rem}.yext-chat .overflow-auto{overflow:auto}.yext-chat .overflow-hidden{overflow:hidden}.yext-chat .overflow-x-auto{overflow-x:auto}.yext-chat .truncate{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.yext-chat .whitespace-pre-wrap{white-space:pre-wrap}.yext-chat .break-words{overflow-wrap:break-word}.yext-chat .rounded-2xl{border-radius:1rem}.yext-chat .rounded-3xl{border-radius:1.5rem}.yext-chat .rounded-full{border-radius:9999px}.yext-chat .rounded-md{border-radius:.375rem}.yext-chat .rounded-b-3xl{border-bottom-right-radius:1.5rem;border-bottom-left-radius:1.5rem}.yext-chat .rounded-t-3xl{border-top-left-radius:1.5rem;border-top-right-radius:1.5rem}.yext-chat .border{border-width:1px}.yext-chat .border-slate-300{--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}.yext-chat .bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.yext-chat .bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.yext-chat .bg-slate-500{--tw-bg-opacity:1;background-color:rgb(100 116 139/var(--tw-bg-opacity))}.yext-chat .bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.yext-chat .bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.yext-chat .bg-gradient-to-tr{background-image:linear-gradient(to top right,var(--tw-gradient-stops))}.yext-chat .from-blue-600{--tw-gradient-from:#2563eb var(--tw-gradient-from-position);--tw-gradient-to:#2563eb00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.yext-chat .from-slate-50{--tw-gradient-from:#f8fafc var(--tw-gradient-from-position);--tw-gradient-to:#f8fafc00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.yext-chat .to-blue-700{--tw-gradient-to:#1d4ed8 var(--tw-gradient-to-position)}.yext-chat .to-blue-800{--tw-gradient-to:#1e40af var(--tw-gradient-to-position)}.yext-chat .to-slate-100{--tw-gradient-to:#f1f5f9 var(--tw-gradient-to-position)}.yext-chat .stroke-2{stroke-width:2}.yext-chat .stroke-\[0\.2\]{stroke-width:.2}.yext-chat .p-1{padding:.25rem}.yext-chat .p-1\.5{padding:.375rem}.yext-chat .p-2{padding:.5rem}.yext-chat .p-4{padding:1rem}.yext-chat .px-4{padding-left:1rem;padding-right:1rem}.yext-chat .py-3{padding-top:.75rem;padding-bottom:.75rem}.yext-chat .pl-4{padding-left:1rem}.yext-chat .pr-1{padding-right:.25rem}.yext-chat .pr-12{padding-right:3rem}.yext-chat .pr-3{padding-right:.75rem}.yext-chat .text-\[10px\]{font-size:10px}.yext-chat .text-\[13px\]{font-size:13px}.yext-chat .text-xl{font-size:1.25rem;line-height:1.75rem}.yext-chat .font-medium{font-weight:500}.yext-chat .text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity))}.yext-chat .text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.yext-chat .text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}.yext-chat .text-slate-700{--tw-text-opacity:1;color:rgb(51 65 85/var(--tw-text-opacity))}.yext-chat .text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity))}.yext-chat .text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.yext-chat .opacity-0{opacity:0}.yext-chat .shadow-2xl{--tw-shadow:0 25px 50px -12px #00000040;--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color)}.yext-chat .shadow-2xl,.yext-chat .shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.yext-chat .shadow-xl{--tw-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a;--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color)}.yext-chat .transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.yext-chat .duration-150,.yext-chat .transition-all{transition-duration:.15s}.yext-chat .duration-200{transition-duration:.2s}.yext-chat .duration-300{transition-duration:.3s}.yext-chat .\@container{container-type:inline-size}.yext-chat .placeholder\:text-\[13px\]::-moz-placeholder{font-size:13px}.yext-chat .placeholder\:text-\[13px\]::placeholder{font-size:13px}.yext-chat .first\:mt-4:first-child{margin-top:1rem}.yext-chat .hover\:-translate-y-2:hover{--tw-translate-y:-0.5rem}.yext-chat .hover\:-translate-y-2:hover,.yext-chat .hover\:scale-110:hover{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .hover\:scale-110:hover{--tw-scale-x:1.1;--tw-scale-y:1.1}.yext-chat .hover\:bg-blue-800:hover{--tw-bg-opacity:1;background-color:rgb(30 64 175/var(--tw-bg-opacity))}.yext-chat .active\:scale-90:active{--tw-scale-x:.9;--tw-scale-y:.9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .disabled\:bg-slate-200:disabled{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity))}.yext-chat .group:hover .group-hover\:opacity-100,.yext-chat .peer:hover~.peer-hover\:opacity-100{opacity:1}@container (min-width: 32rem){.yext-chat .\@lg\:m-1{margin:.25rem}.yext-chat .\@lg\:ml-0{margin-left:0}.yext-chat .\@lg\:flex-row{flex-direction:row}.yext-chat .\@lg\:flex-row-reverse{flex-direction:row-reverse}.yext-chat .\@lg\:items-center{align-items:center}.yext-chat .\@lg\:gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}}@container (min-width: 480px){.yext-chat .\@\[480px\]\:bottom-3\.5{bottom:.875rem}.yext-chat .\@\[480px\]\:text-\[13px\]{font-size:13px}.yext-chat .\@\[480px\]\:text-base{font-size:1rem;line-height:1.5rem}.yext-chat .placeholder\:\@\[480px\]\:text-base::-moz-placeholder{font-size:1rem;line-height:1.5rem}.yext-chat .placeholder\:\@\[480px\]\:text-base::placeholder{font-size:1rem;line-height:1.5rem}}@media (max-width:480px){.yext-chat .max-\[480px\]\:bottom-0{bottom:0}.yext-chat .max-\[480px\]\:right-0{right:0}.yext-chat .max-\[480px\]\:h-full{height:100%}.yext-chat .max-\[480px\]\:w-full{width:100%}.yext-chat .max-\[480px\]\:rounded-none{border-radius:0}}@media (min-width:1024px){.yext-chat .lg\:bottom-14{bottom:3.5rem}.yext-chat .lg\:right-10{right:2.5rem}.yext-chat .lg\:h-16{height:4rem}.yext-chat .lg\:h-\[40px\]{height:40px}.yext-chat .lg\:w-16{width:4rem}.yext-chat .lg\:w-96{width:24rem}.yext-chat .lg\:w-\[40px\]{width:40px}}
1
+ .yext-chat { width: 100%; height: 100%; } /*! tailwindcss v3.3.2 | MIT License | https://tailwindcss.com*/.yext-chat *,.yext-chat :after,.yext-chat :before{box-sizing:border-box;border:0 solid #e5e7eb}.yext-chat :after,.yext-chat :before{--tw-content:""}.yext-chat {line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;-o-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;font-feature-settings:normal;font-variation-settings:normal}.yext-chat {margin:0;line-height:inherit}.yext-chat hr{height:0;color:inherit;border-top-width:1px}.yext-chat abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}.yext-chat h1,.yext-chat h2,.yext-chat h3,.yext-chat h4,.yext-chat h5,.yext-chat h6{font-size:inherit;font-weight:inherit}.yext-chat a{color:inherit;text-decoration:inherit}.yext-chat b,.yext-chat strong{font-weight:bolder}.yext-chat code,.yext-chat kbd,.yext-chat pre,.yext-chat samp{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-size:1em}.yext-chat small{font-size:80%}.yext-chat sub,.yext-chat sup{font-size:75%;line-height:0;position:relative;vertical-align:initial}.yext-chat sub{bottom:-.25em}.yext-chat sup{top:-.5em}.yext-chat table{text-indent:0;border-color:inherit;border-collapse:collapse}.yext-chat button,.yext-chat input,.yext-chat optgroup,.yext-chat select,.yext-chat textarea{font-family:inherit;font-size:100%;font-weight:inherit;line-height:inherit;color:inherit;margin:0;padding:0}.yext-chat button,.yext-chat select{text-transform:none}.yext-chat [type=button],.yext-chat [type=reset],.yext-chat [type=submit],.yext-chat button{-webkit-appearance:button;background-color:initial;background-image:none}.yext-chat :-moz-focusring{outline:auto}.yext-chat :-moz-ui-invalid{box-shadow:none}.yext-chat progress{vertical-align:initial}.yext-chat ::-webkit-inner-spin-button,.yext-chat ::-webkit-outer-spin-button{height:auto}.yext-chat [type=search]{-webkit-appearance:textfield;outline-offset:-2px}.yext-chat ::-webkit-search-decoration{-webkit-appearance:none}.yext-chat ::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}.yext-chat summary{display:list-item}.yext-chat blockquote,.yext-chat dd,.yext-chat dl,.yext-chat figure,.yext-chat h1,.yext-chat h2,.yext-chat h3,.yext-chat h4,.yext-chat h5,.yext-chat h6,.yext-chat hr,.yext-chat p,.yext-chat pre{margin:0}.yext-chat fieldset{margin:0}.yext-chat fieldset,.yext-chat legend{padding:0}.yext-chat menu,.yext-chat ol,.yext-chat ul{list-style:none;margin:0;padding:0}.yext-chat textarea{resize:vertical}.yext-chat input::-moz-placeholder,.yext-chat textarea::-moz-placeholder{opacity:1;color:#9ca3af}.yext-chat input::placeholder,.yext-chat textarea::placeholder{opacity:1;color:#9ca3af}.yext-chat [role=button],.yext-chat button{cursor:pointer}.yext-chat :disabled{cursor:default}.yext-chat audio,.yext-chat canvas,.yext-chat embed,.yext-chat iframe,.yext-chat img,.yext-chat object,.yext-chat svg,.yext-chat video{display:block;vertical-align:middle}.yext-chat img,.yext-chat video{max-width:100%;height:auto}.yext-chat [hidden]{display:none}.yext-chat *,.yext-chat ::backdrop,.yext-chat :after,.yext-chat :before{--tw-border-spacing-x:0;--tw-border-spacing-y:0;--tw-translate-x:0;--tw-translate-y:0;--tw-rotate:0;--tw-skew-x:0;--tw-skew-y:0;--tw-scale-x:1;--tw-scale-y:1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness:proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-color:#3b82f680;--tw-ring-offset-shadow:0 0 #0000;--tw-ring-shadow:0 0 #0000;--tw-shadow:0 0 #0000;--tw-shadow-colored:0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: }.yext-chat .container{width:100%}@media (min-width:640px){.yext-chat .container{max-width:640px}}@media (min-width:768px){.yext-chat .container{max-width:768px}}@media (min-width:1024px){.yext-chat .container{max-width:1024px}}@media (min-width:1280px){.yext-chat .container{max-width:1280px}}@media (min-width:1536px){.yext-chat .container{max-width:1536px}}.yext-chat .prose{color:var(--tw-prose-body);max-width:65ch}.yext-chat .prose :where(p):not(:where([class~=not-prose] *)){margin-top:1.25em;margin-bottom:1.25em}.yext-chat .prose :where([class~=lead]):not(:where([class~=not-prose] *)){color:var(--tw-prose-lead);font-size:1.25em;line-height:1.6;margin-top:1.2em;margin-bottom:1.2em}.yext-chat .prose :where(a):not(:where([class~=not-prose] *)){color:var(--tw-prose-links);text-decoration:underline;font-weight:500}.yext-chat .prose :where(strong):not(:where([class~=not-prose] *)){color:var(--tw-prose-bold);font-weight:600}.yext-chat .prose :where(a strong):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(blockquote strong):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(thead th strong):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(ol):not(:where([class~=not-prose] *)){list-style-type:decimal;margin-top:1.25em;margin-bottom:1.25em;padding-left:1.625em}.yext-chat .prose :where(ol[type=A]):not(:where([class~=not-prose] *)){list-style-type:upper-alpha}.yext-chat .prose :where(ol[type=a]):not(:where([class~=not-prose] *)){list-style-type:lower-alpha}.yext-chat .prose :where(ol[type=A s]):not(:where([class~=not-prose] *)){list-style-type:upper-alpha}.yext-chat .prose :where(ol[type=a s]):not(:where([class~=not-prose] *)){list-style-type:lower-alpha}.yext-chat .prose :where(ol[type=I]):not(:where([class~=not-prose] *)){list-style-type:upper-roman}.yext-chat .prose :where(ol[type=i]):not(:where([class~=not-prose] *)){list-style-type:lower-roman}.yext-chat .prose :where(ol[type=I s]):not(:where([class~=not-prose] *)){list-style-type:upper-roman}.yext-chat .prose :where(ol[type=i s]):not(:where([class~=not-prose] *)){list-style-type:lower-roman}.yext-chat .prose :where(ol[type="1"]):not(:where([class~=not-prose] *)){list-style-type:decimal}.yext-chat .prose :where(ul):not(:where([class~=not-prose] *)){list-style-type:disc;margin-top:1.25em;margin-bottom:1.25em;padding-left:1.625em}.yext-chat .prose :where(ol>li):not(:where([class~=not-prose] *))::marker{font-weight:400;color:var(--tw-prose-counters)}.yext-chat .prose :where(ul>li):not(:where([class~=not-prose] *))::marker{color:var(--tw-prose-bullets)}.yext-chat .prose :where(hr):not(:where([class~=not-prose] *)){border-color:var(--tw-prose-hr);border-top-width:1px;margin-top:3em;margin-bottom:3em}.yext-chat .prose :where(blockquote):not(:where([class~=not-prose] *)){font-weight:500;font-style:italic;color:var(--tw-prose-quotes);border-left-width:.25rem;border-left-color:var(--tw-prose-quote-borders);quotes:"\201C""\201D""\2018""\2019";margin-top:1.6em;margin-bottom:1.6em;padding-left:1em}.yext-chat .prose :where(blockquote p:first-of-type):not(:where([class~=not-prose] *)):before{content:open-quote}.yext-chat .prose :where(blockquote p:last-of-type):not(:where([class~=not-prose] *)):after{content:close-quote}.yext-chat .prose :where(h1):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:800;font-size:2.25em;margin-top:0;margin-bottom:.8888889em;line-height:1.1111111}.yext-chat .prose :where(h1 strong):not(:where([class~=not-prose] *)){font-weight:900;color:inherit}.yext-chat .prose :where(h2):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:700;font-size:1.5em;margin-top:2em;margin-bottom:1em;line-height:1.3333333}.yext-chat .prose :where(h2 strong):not(:where([class~=not-prose] *)){font-weight:800;color:inherit}.yext-chat .prose :where(h3):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;font-size:1.25em;margin-top:1.6em;margin-bottom:.6em;line-height:1.6}.yext-chat .prose :where(h3 strong):not(:where([class~=not-prose] *)){font-weight:700;color:inherit}.yext-chat .prose :where(h4):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;margin-top:1.5em;margin-bottom:.5em;line-height:1.5}.yext-chat .prose :where(h4 strong):not(:where([class~=not-prose] *)){font-weight:700;color:inherit}.yext-chat .prose :where(img):not(:where([class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.yext-chat .prose :where(figure>*):not(:where([class~=not-prose] *)){margin-top:0;margin-bottom:0}.yext-chat .prose :where(figcaption):not(:where([class~=not-prose] *)){color:var(--tw-prose-captions);font-size:.875em;line-height:1.4285714;margin-top:.8571429em}.yext-chat .prose :where(code):not(:where([class~=not-prose] *)){color:var(--tw-prose-code);font-weight:600;font-size:.875em}.yext-chat .prose :where(code):not(:where([class~=not-prose] *)):before{content:"`"}.yext-chat .prose :where(code):not(:where([class~=not-prose] *)):after{content:"`"}.yext-chat .prose :where(a code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(h1 code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(h2 code):not(:where([class~=not-prose] *)){color:inherit;font-size:.875em}.yext-chat .prose :where(h3 code):not(:where([class~=not-prose] *)){color:inherit;font-size:.9em}.yext-chat .prose :where(h4 code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(blockquote code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(thead th code):not(:where([class~=not-prose] *)){color:inherit}.yext-chat .prose :where(pre):not(:where([class~=not-prose] *)){color:var(--tw-prose-pre-code);background-color:var(--tw-prose-pre-bg);overflow-x:auto;font-weight:400;font-size:.875em;line-height:1.7142857;margin-top:1.7142857em;margin-bottom:1.7142857em;border-radius:.375rem;padding:.8571429em 1.1428571em}.yext-chat .prose :where(pre code):not(:where([class~=not-prose] *)){background-color:initial;border-width:0;border-radius:0;padding:0;font-weight:inherit;color:inherit;font-size:inherit;font-family:inherit;line-height:inherit}.yext-chat .prose :where(pre code):not(:where([class~=not-prose] *)):before{content:none}.yext-chat .prose :where(pre code):not(:where([class~=not-prose] *)):after{content:none}.yext-chat .prose :where(table):not(:where([class~=not-prose] *)){width:100%;table-layout:auto;text-align:left;margin-top:2em;margin-bottom:2em;font-size:.875em;line-height:1.7142857}.yext-chat .prose :where(thead):not(:where([class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-th-borders)}.yext-chat .prose :where(thead th):not(:where([class~=not-prose] *)){color:var(--tw-prose-headings);font-weight:600;vertical-align:bottom;padding-right:.5714286em;padding-bottom:.5714286em;padding-left:.5714286em}.yext-chat .prose :where(tbody tr):not(:where([class~=not-prose] *)){border-bottom-width:1px;border-bottom-color:var(--tw-prose-td-borders)}.yext-chat .prose :where(tbody tr:last-child):not(:where([class~=not-prose] *)){border-bottom-width:0}.yext-chat .prose :where(tbody td):not(:where([class~=not-prose] *)){vertical-align:initial}.yext-chat .prose :where(tfoot):not(:where([class~=not-prose] *)){border-top-width:1px;border-top-color:var(--tw-prose-th-borders)}.yext-chat .prose :where(tfoot td):not(:where([class~=not-prose] *)){vertical-align:top}.yext-chat .prose{--tw-prose-body:#374151;--tw-prose-headings:#111827;--tw-prose-lead:#4b5563;--tw-prose-links:#111827;--tw-prose-bold:#111827;--tw-prose-counters:#6b7280;--tw-prose-bullets:#d1d5db;--tw-prose-hr:#e5e7eb;--tw-prose-quotes:#111827;--tw-prose-quote-borders:#e5e7eb;--tw-prose-captions:#6b7280;--tw-prose-code:#111827;--tw-prose-pre-code:#e5e7eb;--tw-prose-pre-bg:#1f2937;--tw-prose-th-borders:#d1d5db;--tw-prose-td-borders:#e5e7eb;--tw-prose-invert-body:#d1d5db;--tw-prose-invert-headings:#fff;--tw-prose-invert-lead:#9ca3af;--tw-prose-invert-links:#fff;--tw-prose-invert-bold:#fff;--tw-prose-invert-counters:#9ca3af;--tw-prose-invert-bullets:#4b5563;--tw-prose-invert-hr:#374151;--tw-prose-invert-quotes:#f3f4f6;--tw-prose-invert-quote-borders:#374151;--tw-prose-invert-captions:#9ca3af;--tw-prose-invert-code:#fff;--tw-prose-invert-pre-code:#d1d5db;--tw-prose-invert-pre-bg:#00000080;--tw-prose-invert-th-borders:#4b5563;--tw-prose-invert-td-borders:#374151;font-size:1rem;line-height:1.75}.yext-chat .prose :where(video):not(:where([class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.yext-chat .prose :where(figure):not(:where([class~=not-prose] *)){margin-top:2em;margin-bottom:2em}.yext-chat .prose :where(li):not(:where([class~=not-prose] *)){margin-top:.5em;margin-bottom:.5em}.yext-chat .prose :where(ol>li):not(:where([class~=not-prose] *)){padding-left:.375em}.yext-chat .prose :where(ul>li):not(:where([class~=not-prose] *)){padding-left:.375em}.yext-chat .prose :where(.prose>ul>li p):not(:where([class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.yext-chat .prose :where(.prose>ul>li>:first-child):not(:where([class~=not-prose] *)){margin-top:1.25em}.yext-chat .prose :where(.prose>ul>li>:last-child):not(:where([class~=not-prose] *)){margin-bottom:1.25em}.yext-chat .prose :where(.prose>ol>li>:first-child):not(:where([class~=not-prose] *)){margin-top:1.25em}.yext-chat .prose :where(.prose>ol>li>:last-child):not(:where([class~=not-prose] *)){margin-bottom:1.25em}.yext-chat .prose :where(ul ul,ul ol,ol ul,ol ol):not(:where([class~=not-prose] *)){margin-top:.75em;margin-bottom:.75em}.yext-chat .prose :where(hr+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(h2+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(h3+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(h4+*):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(thead th:first-child):not(:where([class~=not-prose] *)){padding-left:0}.yext-chat .prose :where(thead th:last-child):not(:where([class~=not-prose] *)){padding-right:0}.yext-chat .prose :where(tbody td,tfoot td):not(:where([class~=not-prose] *)){padding:.5714286em}.yext-chat .prose :where(tbody td:first-child,tfoot td:first-child):not(:where([class~=not-prose] *)){padding-left:0}.yext-chat .prose :where(tbody td:last-child,tfoot td:last-child):not(:where([class~=not-prose] *)){padding-right:0}.yext-chat .prose :where(.prose>:first-child):not(:where([class~=not-prose] *)){margin-top:0}.yext-chat .prose :where(.prose>:last-child):not(:where([class~=not-prose] *)){margin-bottom:0}.yext-chat .invisible{visibility:hidden}.yext-chat .fixed{position:fixed}.yext-chat .absolute{position:absolute}.yext-chat .relative{position:relative}.yext-chat .-right-1{right:-.25rem}.yext-chat .-top-3{top:-.75rem}.yext-chat .bottom-2{bottom:.5rem}.yext-chat .bottom-2\.5{bottom:.625rem}.yext-chat .bottom-6{bottom:1.5rem}.yext-chat .right-4{right:1rem}.yext-chat .top-0{top:0}.yext-chat .z-50{z-index:50}.yext-chat .my-0{margin-top:0;margin-bottom:0}.yext-chat .my-0\.5{margin-top:.125rem;margin-bottom:.125rem}.yext-chat .-mr-8{margin-right:-2rem}.yext-chat .mb-3{margin-bottom:.75rem}.yext-chat .ml-4{margin-left:1rem}.yext-chat .ml-auto{margin-left:auto}.yext-chat .mt-auto{margin-top:auto}.yext-chat .line-clamp-1{-webkit-line-clamp:1}.yext-chat .line-clamp-1,.yext-chat .line-clamp-2{overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical}.yext-chat .line-clamp-2{-webkit-line-clamp:2}.yext-chat .flex{display:flex}.yext-chat .hidden{display:none}.yext-chat .h-10{height:2.5rem}.yext-chat .h-12{height:3rem}.yext-chat .h-2{height:.5rem}.yext-chat .h-4{height:1rem}.yext-chat .h-5{height:1.25rem}.yext-chat .h-6{height:1.5rem}.yext-chat .h-8{height:2rem}.yext-chat .h-\[22px\]{height:22px}.yext-chat .h-\[26px\]{height:26px}.yext-chat .h-\[28px\]{height:28px}.yext-chat .h-\[75vh\]{height:75vh}.yext-chat .h-fit{height:-moz-fit-content;height:fit-content}.yext-chat .h-full{height:100%}.yext-chat .w-12{width:3rem}.yext-chat .w-2{width:.5rem}.yext-chat .w-4{width:1rem}.yext-chat .w-5{width:1.25rem}.yext-chat .w-6{width:1.5rem}.yext-chat .w-60{width:15rem}.yext-chat .w-8{width:2rem}.yext-chat .w-80{width:20rem}.yext-chat .w-\[22px\]{width:22px}.yext-chat .w-\[26px\]{width:26px}.yext-chat .w-\[28px\]{width:28px}.yext-chat .w-fit{width:-moz-fit-content;width:fit-content}.yext-chat .w-full{width:100%}.yext-chat .max-w-\[80\%\]{max-width:80%}.yext-chat .shrink-0{flex-shrink:0}.yext-chat .translate-y-0{--tw-translate-y:0px}.yext-chat .translate-y-0,.yext-chat .translate-y-\[20\%\]{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .translate-y-\[20\%\]{--tw-translate-y:20%}.yext-chat .transform{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .animate-\[bounce_1s_infinite\]{animation:bounce 1s infinite}.yext-chat .animate-\[bounce_1s_infinite_0\.3s\]{animation:bounce 1s .3s infinite}@keyframes bounce{0%,to{transform:translateY(-25%);animation-timing-function:cubic-bezier(.8,0,1,1)}50%{transform:none;animation-timing-function:cubic-bezier(0,0,.2,1)}}.yext-chat .animate-\[bounce_1s_infinite_0\.6s\]{animation:bounce 1s .6s infinite}@keyframes spin{to{transform:rotate(1turn)}}.yext-chat .animate-\[spin_0\.3s_linear\]{animation:spin .3s linear}@keyframes expand-left{0%{margin-left:100%}to{margin-left:0}}.yext-chat .animate-expand-left{animation:expand-left .5s}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.yext-chat .animate-fade-in{animation:fade-in .4s}@keyframes heartbeat{0%{transform:scale(1)}80%{transform:scale(1)}90%{transform:scale(1.1)}to{transform:scale(1)}}.yext-chat .animate-heartbeat{animation:heartbeat 2s ease-out infinite}.yext-chat .cursor-pointer{cursor:pointer}.yext-chat .resize-none{resize:none}.yext-chat .flex-row{flex-direction:row}.yext-chat .flex-col{flex-direction:column}.yext-chat .items-center{align-items:center}.yext-chat .justify-center{justify-content:center}.yext-chat .justify-between{justify-content:space-between}.yext-chat .gap-1{gap:.25rem}.yext-chat .gap-x-1{-moz-column-gap:.25rem;column-gap:.25rem}.yext-chat .gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}.yext-chat .gap-x-2\.5{-moz-column-gap:.625rem;column-gap:.625rem}.yext-chat .gap-y-1{row-gap:.25rem}.yext-chat .overflow-auto{overflow:auto}.yext-chat .overflow-hidden{overflow:hidden}.yext-chat .overflow-x-auto{overflow-x:auto}.yext-chat .truncate{overflow:hidden;text-overflow:ellipsis}.yext-chat .truncate,.yext-chat .whitespace-nowrap{white-space:nowrap}.yext-chat .whitespace-pre-wrap{white-space:pre-wrap}.yext-chat .break-words{overflow-wrap:break-word}.yext-chat .rounded-2xl{border-radius:1rem}.yext-chat .rounded-3xl{border-radius:1.5rem}.yext-chat .rounded-full{border-radius:9999px}.yext-chat .rounded-md{border-radius:.375rem}.yext-chat .rounded-xl{border-radius:.75rem}.yext-chat .rounded-b-3xl{border-bottom-right-radius:1.5rem;border-bottom-left-radius:1.5rem}.yext-chat .rounded-l-full{border-top-left-radius:9999px;border-bottom-left-radius:9999px}.yext-chat .rounded-t-3xl{border-top-left-radius:1.5rem;border-top-right-radius:1.5rem}.yext-chat .border{border-width:1px}.yext-chat .border-slate-300{--tw-border-opacity:1;border-color:rgb(203 213 225/var(--tw-border-opacity))}.yext-chat .bg-blue-600{--tw-bg-opacity:1;background-color:rgb(37 99 235/var(--tw-bg-opacity))}.yext-chat .bg-gray-700{--tw-bg-opacity:1;background-color:rgb(55 65 81/var(--tw-bg-opacity))}.yext-chat .bg-red-700{--tw-bg-opacity:1;background-color:rgb(185 28 28/var(--tw-bg-opacity))}.yext-chat .bg-slate-500{--tw-bg-opacity:1;background-color:rgb(100 116 139/var(--tw-bg-opacity))}.yext-chat .bg-white{--tw-bg-opacity:1;background-color:rgb(255 255 255/var(--tw-bg-opacity))}.yext-chat .bg-gradient-to-br{background-image:linear-gradient(to bottom right,var(--tw-gradient-stops))}.yext-chat .bg-gradient-to-tr{background-image:linear-gradient(to top right,var(--tw-gradient-stops))}.yext-chat .from-blue-600{--tw-gradient-from:#2563eb var(--tw-gradient-from-position);--tw-gradient-to:#2563eb00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.yext-chat .from-slate-50{--tw-gradient-from:#f8fafc var(--tw-gradient-from-position);--tw-gradient-to:#f8fafc00 var(--tw-gradient-to-position);--tw-gradient-stops:var(--tw-gradient-from),var(--tw-gradient-to)}.yext-chat .to-blue-700{--tw-gradient-to:#1d4ed8 var(--tw-gradient-to-position)}.yext-chat .to-blue-800{--tw-gradient-to:#1e40af var(--tw-gradient-to-position)}.yext-chat .to-slate-100{--tw-gradient-to:#f1f5f9 var(--tw-gradient-to-position)}.yext-chat .stroke-2{stroke-width:2}.yext-chat .stroke-\[0\.2\]{stroke-width:.2}.yext-chat .p-1{padding:.25rem}.yext-chat .p-1\.5{padding:.375rem}.yext-chat .p-2{padding:.5rem}.yext-chat .p-2\.5{padding:.625rem}.yext-chat .p-3{padding:.75rem}.yext-chat .p-4{padding:1rem}.yext-chat .px-4{padding-left:1rem;padding-right:1rem}.yext-chat .py-3{padding-top:.75rem;padding-bottom:.75rem}.yext-chat .pl-4{padding-left:1rem}.yext-chat .pr-1{padding-right:.25rem}.yext-chat .pr-12{padding-right:3rem}.yext-chat .pr-3{padding-right:.75rem}.yext-chat .pr-8{padding-right:2rem}.yext-chat .text-\[10px\]{font-size:10px}.yext-chat .text-\[13px\]{font-size:13px}.yext-chat .text-sm{font-size:.875rem;line-height:1.25rem}.yext-chat .text-xl{font-size:1.25rem;line-height:1.75rem}.yext-chat .font-bold{font-weight:700}.yext-chat .font-medium{font-weight:500}.yext-chat .text-blue-600{--tw-text-opacity:1;color:rgb(37 99 235/var(--tw-text-opacity))}.yext-chat .text-blue-700{--tw-text-opacity:1;color:rgb(29 78 216/var(--tw-text-opacity))}.yext-chat .text-red-200{--tw-text-opacity:1;color:rgb(254 202 202/var(--tw-text-opacity))}.yext-chat .text-slate-400{--tw-text-opacity:1;color:rgb(148 163 184/var(--tw-text-opacity))}.yext-chat .text-slate-700{--tw-text-opacity:1;color:rgb(51 65 85/var(--tw-text-opacity))}.yext-chat .text-slate-900{--tw-text-opacity:1;color:rgb(15 23 42/var(--tw-text-opacity))}.yext-chat .text-white{--tw-text-opacity:1;color:rgb(255 255 255/var(--tw-text-opacity))}.yext-chat .opacity-0{opacity:0}.yext-chat .shadow-2xl{--tw-shadow:0 25px 50px -12px #00000040;--tw-shadow-colored:0 25px 50px -12px var(--tw-shadow-color)}.yext-chat .shadow-2xl,.yext-chat .shadow-xl{box-shadow:var(--tw-ring-offset-shadow,0 0 #0000),var(--tw-ring-shadow,0 0 #0000),var(--tw-shadow)}.yext-chat .shadow-xl{--tw-shadow:0 20px 25px -5px #0000001a,0 8px 10px -6px #0000001a;--tw-shadow-colored:0 20px 25px -5px var(--tw-shadow-color),0 8px 10px -6px var(--tw-shadow-color)}.yext-chat .transition-all{transition-property:all;transition-timing-function:cubic-bezier(.4,0,.2,1)}.yext-chat .duration-150,.yext-chat .transition-all{transition-duration:.15s}.yext-chat .duration-200{transition-duration:.2s}.yext-chat .duration-300{transition-duration:.3s}.yext-chat .\@container{container-type:inline-size}.yext-chat .placeholder\:text-\[13px\]::-moz-placeholder{font-size:13px}.yext-chat .placeholder\:text-\[13px\]::placeholder{font-size:13px}.yext-chat .first\:mt-4:first-child{margin-top:1rem}.yext-chat .hover\:-translate-y-2:hover{--tw-translate-y:-0.5rem}.yext-chat .hover\:-translate-y-2:hover,.yext-chat .hover\:scale-110:hover{transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .hover\:scale-110:hover{--tw-scale-x:1.1;--tw-scale-y:1.1}.yext-chat .hover\:bg-blue-800:hover{--tw-bg-opacity:1;background-color:rgb(30 64 175/var(--tw-bg-opacity))}.yext-chat .active\:scale-90:active{--tw-scale-x:.9;--tw-scale-y:.9;transform:translate(var(--tw-translate-x),var(--tw-translate-y)) rotate(var(--tw-rotate)) skewX(var(--tw-skew-x)) skewY(var(--tw-skew-y)) scaleX(var(--tw-scale-x)) scaleY(var(--tw-scale-y))}.yext-chat .disabled\:bg-slate-200:disabled{--tw-bg-opacity:1;background-color:rgb(226 232 240/var(--tw-bg-opacity))}.yext-chat .group:hover .group-hover\:opacity-100,.yext-chat .peer:hover~.peer-hover\:opacity-100{opacity:1}@container (min-width: 32rem){.yext-chat .\@lg\:m-1{margin:.25rem}.yext-chat .\@lg\:ml-0{margin-left:0}.yext-chat .\@lg\:flex-row{flex-direction:row}.yext-chat .\@lg\:flex-row-reverse{flex-direction:row-reverse}.yext-chat .\@lg\:items-center{align-items:center}.yext-chat .\@lg\:gap-x-2{-moz-column-gap:.5rem;column-gap:.5rem}}@container (min-width: 480px){.yext-chat .\@\[480px\]\:bottom-3\.5{bottom:.875rem}.yext-chat .\@\[480px\]\:text-\[13px\]{font-size:13px}.yext-chat .\@\[480px\]\:text-base{font-size:1rem;line-height:1.5rem}.yext-chat .placeholder\:\@\[480px\]\:text-base::-moz-placeholder{font-size:1rem;line-height:1.5rem}.yext-chat .placeholder\:\@\[480px\]\:text-base::placeholder{font-size:1rem;line-height:1.5rem}}@media (max-width:480px){.yext-chat .max-\[480px\]\:bottom-0{bottom:0}.yext-chat .max-\[480px\]\:right-0{right:0}.yext-chat .max-\[480px\]\:h-full{height:100%}.yext-chat .max-\[480px\]\:w-full{width:100%}.yext-chat .max-\[480px\]\:rounded-none{border-radius:0}}@media (min-width:1024px){.yext-chat .lg\:bottom-14{bottom:3.5rem}.yext-chat .lg\:right-10{right:2.5rem}.yext-chat .lg\:h-14{height:3.5rem}.yext-chat .lg\:h-16{height:4rem}.yext-chat .lg\:h-6{height:1.5rem}.yext-chat .lg\:h-\[40px\]{height:40px}.yext-chat .lg\:w-16{width:4rem}.yext-chat .lg\:w-6{width:1.5rem}.yext-chat .lg\:w-96{width:24rem}.yext-chat .lg\:w-\[40px\]{width:40px}.yext-chat .lg\:text-base{font-size:1rem;line-height:1.5rem}}
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- var version = "0.7.2";
3
+ var version = "0.8.0";
4
4
 
5
5
  exports.version = version;
6
6
  //# sourceMappingURL=package.json.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ChatPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/ChatPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAEL,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAa,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAO7E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAeD;;;;GAIG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,CAAC,EAC9D,IAAI,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAC1C,kDAAkD;IAClD,MAAM,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qBAmF9C"}
1
+ {"version":3,"file":"ChatPanel.d.ts","sourceRoot":"","sources":["../../../../src/components/ChatPanel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAyC,MAAM,OAAO,CAAC;AAE9D,OAAO,EAEL,uBAAuB,EACvB,kBAAkB,EACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAa,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAO7E;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,uBAAuB,CAAC,EAAE,uBAAuB,CAAC;CACnD;AAeD;;;;GAIG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,SAAS,CAAC,EAC9D,IAAI,CAAC,cAAc,EAAE,kBAAkB,CAAC;IAC1C,kDAAkD;IAClD,MAAM,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IACrB;;OAEG;IACH,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;CACxC;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qBAkE9C"}
@@ -6,9 +6,9 @@ var MessageBubble = require('./MessageBubble.js');
6
6
  var ChatInput = require('./ChatInput.js');
7
7
  var LoadingDots = require('./LoadingDots.js');
8
8
  var useComposedCssClasses = require('../hooks/useComposedCssClasses.js');
9
- var useDefaultHandleApiError = require('../hooks/useDefaultHandleApiError.js');
10
9
  var withStylelessCssClasses = require('../utils/withStylelessCssClasses.js');
11
10
  var useReportAnalyticsEvent = require('../hooks/useReportAnalyticsEvent.js');
11
+ var useFetchInitialMessage = require('../hooks/useFetchInitialMessage.js');
12
12
 
13
13
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
14
14
 
@@ -33,28 +33,17 @@ const builtInCssClasses = withStylelessCssClasses.withStylelessCssClasses("Panel
33
33
  * @param props - {@link ChatPanelProps}
34
34
  */
35
35
  function ChatPanel(props) {
36
- const { header, customCssClasses } = props;
37
- const chat = chatHeadlessReact.useChatActions();
36
+ const { header, customCssClasses, stream, handleError } = props;
38
37
  const messages = chatHeadlessReact.useChatState((state) => state.conversation.messages);
39
38
  const loading = chatHeadlessReact.useChatState((state) => state.conversation.isLoading);
40
- const canSendMessage = chatHeadlessReact.useChatState((state) => state.conversation.canSendMessage);
41
39
  const cssClasses = useComposedCssClasses.useComposedCssClasses(builtInCssClasses, customCssClasses);
42
- const defaultHandleApiError = useDefaultHandleApiError.useDefaultHandleApiError();
43
40
  const reportAnalyticsEvent = useReportAnalyticsEvent.useReportAnalyticsEvent();
41
+ useFetchInitialMessage.useFetchInitialMessage(handleError, stream);
44
42
  React.useEffect(() => {
45
43
  reportAnalyticsEvent({
46
44
  action: "CHAT_IMPRESSION",
47
45
  });
48
46
  }, [reportAnalyticsEvent]);
49
- // Fetch the first message on load, if there are no existing messages or a request being processed
50
- React.useEffect(() => {
51
- if (messages.length !== 0 || !canSendMessage) {
52
- return;
53
- }
54
- const { stream = false, handleError } = props;
55
- const res = stream ? chat.streamNextMessage() : chat.getNextMessage();
56
- res.catch((e) => (handleError ? handleError(e) : defaultHandleApiError(e)));
57
- }, [chat, props, messages, defaultHandleApiError, canSendMessage]);
58
47
  const messagesRef = React.useRef([]);
59
48
  const messagesContainer = React.useRef(null);
60
49
  // Handle scrolling when messages change
@@ -1 +1 @@
1
- {"version":3,"file":"ChatPanel.js","sources":["../../../../src/components/ChatPanel.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useRef } from \"react\";\nimport { useChatState, useChatActions } from \"@yext/chat-headless-react\";\nimport {\n MessageBubble,\n MessageBubbleCssClasses,\n MessageBubbleProps,\n} from \"./MessageBubble\";\nimport { ChatInput, ChatInputCssClasses, ChatInputProps } from \"./ChatInput\";\nimport { LoadingDots } from \"./LoadingDots\";\nimport { useComposedCssClasses } from \"../hooks\";\nimport { useDefaultHandleApiError } from \"../hooks/useDefaultHandleApiError\";\nimport { withStylelessCssClasses } from \"../utils/withStylelessCssClasses\";\nimport { useReportAnalyticsEvent } from \"../hooks/useReportAnalyticsEvent\";\n\n/**\n * The CSS class interface for the {@link ChatPanel} component.\n *\n * @public\n */\nexport interface ChatPanelCssClasses {\n container?: string;\n messagesContainer?: string;\n messagesScrollContainer?: string;\n inputContainer?: string;\n inputCssClasses?: ChatInputCssClasses;\n messageBubbleCssClasses?: MessageBubbleCssClasses;\n}\n\nconst builtInCssClasses: ChatPanelCssClasses = withStylelessCssClasses(\n \"Panel\",\n {\n container: \"h-full w-full flex flex-col relative shadow-2xl bg-white\",\n messagesScrollContainer: \"flex flex-col mt-auto overflow-hidden\",\n messagesContainer: \"flex flex-col gap-y-1 px-4 overflow-auto\",\n inputContainer: \"w-full p-4\",\n messageBubbleCssClasses: {\n topContainer: \"first:mt-4\",\n },\n }\n);\n\n/**\n * The props for the {@link ChatPanel} component.\n *\n * @public\n */\nexport interface ChatPanelProps\n extends Omit<MessageBubbleProps, \"customCssClasses\" | \"message\">,\n Omit<ChatInputProps, \"customCssClasses\"> {\n /** A header to render at the top of the panel. */\n header?: JSX.Element;\n /**\n * CSS classes for customizing the component styling.\n */\n customCssClasses?: ChatPanelCssClasses;\n}\n\n/**\n * A component that renders a full panel for chat bot interactions. This includes\n * the message bubbles for the conversation, input box with send button, and header\n * (if provided).\n *\n * @public\n *\n * @param props - {@link ChatPanelProps}\n */\nexport function ChatPanel(props: ChatPanelProps) {\n const { header, customCssClasses } = props;\n const chat = useChatActions();\n const messages = useChatState((state) => state.conversation.messages);\n const loading = useChatState((state) => state.conversation.isLoading);\n const canSendMessage = useChatState(\n (state) => state.conversation.canSendMessage\n );\n const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);\n const defaultHandleApiError = useDefaultHandleApiError();\n const reportAnalyticsEvent = useReportAnalyticsEvent();\n\n useEffect(() => {\n reportAnalyticsEvent({\n action: \"CHAT_IMPRESSION\",\n });\n }, [reportAnalyticsEvent]);\n\n // Fetch the first message on load, if there are no existing messages or a request being processed\n useEffect(() => {\n if (messages.length !== 0 || !canSendMessage) {\n return;\n }\n const { stream = false, handleError } = props;\n const res = stream ? chat.streamNextMessage() : chat.getNextMessage();\n res.catch((e) => (handleError ? handleError(e) : defaultHandleApiError(e)));\n }, [chat, props, messages, defaultHandleApiError, canSendMessage]);\n\n const messagesRef = useRef<Array<HTMLDivElement | null>>([]);\n const messagesContainer = useRef<HTMLDivElement>(null);\n\n // Handle scrolling when messages change\n useEffect(() => {\n let scrollTop = 0;\n messagesRef.current = messagesRef.current.slice(0, messages.length);\n\n // Sums up scroll heights of all messages except the last one\n if (messagesRef?.current.length > 1) {\n scrollTop = messagesRef.current\n .slice(0, -1)\n .map((elem, _) => elem?.scrollHeight ?? 0)\n .reduce((total, height) => total + height);\n }\n\n // Scroll to the top of the last message\n messagesContainer.current?.scroll({\n top: scrollTop,\n behavior: \"smooth\",\n });\n }, [messages]);\n\n const setMessagesRef = useCallback((index) => {\n if (!messagesRef?.current) return null;\n return (message) => (messagesRef.current[index] = message);\n }, []);\n\n return (\n <div className=\"yext-chat w-full h-full\">\n <div className={cssClasses.container}>\n {header}\n <div className={cssClasses.messagesScrollContainer}>\n <div\n ref={messagesContainer}\n className={cssClasses.messagesContainer}\n >\n {messages.map((message, index) => (\n <div key={index} ref={setMessagesRef(index)}>\n <MessageBubble\n {...props}\n customCssClasses={cssClasses.messageBubbleCssClasses}\n message={message}\n />\n </div>\n ))}\n {loading && <LoadingDots />}\n </div>\n </div>\n <div className={cssClasses.inputContainer}>\n <ChatInput {...props} customCssClasses={cssClasses.inputCssClasses} />\n </div>\n </div>\n </div>\n );\n}\n"],"names":["withStylelessCssClasses","useChatActions","useChatState","useComposedCssClasses","useDefaultHandleApiError","useReportAnalyticsEvent","useEffect","useRef","useCallback","React","MessageBubble","LoadingDots","ChatInput"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAM,iBAAiB,GAAwBA,+CAAuB,CACpE,OAAO,EACP;AACE,IAAA,SAAS,EAAE,0DAA0D;AACrE,IAAA,uBAAuB,EAAE,uCAAuC;AAChE,IAAA,iBAAiB,EAAE,0CAA0C;AAC7D,IAAA,cAAc,EAAE,YAAY;AAC5B,IAAA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useCallback, useEffect, useRef } from \"react\";\nimport { useChatState } from \"@yext/chat-headless-react\";\nimport {\n MessageBubble,\n MessageBubbleCssClasses,\n MessageBubbleProps,\n} from \"./MessageBubble\";\nimport { ChatInput, ChatInputCssClasses, ChatInputProps } from \"./ChatInput\";\nimport { LoadingDots } from \"./LoadingDots\";\nimport { useComposedCssClasses } from \"../hooks\";\nimport { withStylelessCssClasses } from \"../utils/withStylelessCssClasses\";\nimport { useReportAnalyticsEvent } from \"../hooks/useReportAnalyticsEvent\";\nimport { useFetchInitialMessage } from \"../hooks/useFetchInitialMessage\";\n\n/**\n * The CSS class interface for the {@link ChatPanel} component.\n *\n * @public\n */\nexport interface ChatPanelCssClasses {\n container?: string;\n messagesContainer?: string;\n messagesScrollContainer?: string;\n inputContainer?: string;\n inputCssClasses?: ChatInputCssClasses;\n messageBubbleCssClasses?: MessageBubbleCssClasses;\n}\n\nconst builtInCssClasses: ChatPanelCssClasses = withStylelessCssClasses(\n \"Panel\",\n {\n container: \"h-full w-full flex flex-col relative shadow-2xl bg-white\",\n messagesScrollContainer: \"flex flex-col mt-auto overflow-hidden\",\n messagesContainer: \"flex flex-col gap-y-1 px-4 overflow-auto\",\n inputContainer: \"w-full p-4\",\n messageBubbleCssClasses: {\n topContainer: \"first:mt-4\",\n },\n }\n);\n\n/**\n * The props for the {@link ChatPanel} component.\n *\n * @public\n */\nexport interface ChatPanelProps\n extends Omit<MessageBubbleProps, \"customCssClasses\" | \"message\">,\n Omit<ChatInputProps, \"customCssClasses\"> {\n /** A header to render at the top of the panel. */\n header?: JSX.Element;\n /**\n * CSS classes for customizing the component styling.\n */\n customCssClasses?: ChatPanelCssClasses;\n}\n\n/**\n * A component that renders a full panel for chat bot interactions. This includes\n * the message bubbles for the conversation, input box with send button, and header\n * (if provided).\n *\n * @public\n *\n * @param props - {@link ChatPanelProps}\n */\nexport function ChatPanel(props: ChatPanelProps) {\n const { header, customCssClasses, stream, handleError } = props;\n const messages = useChatState((state) => state.conversation.messages);\n const loading = useChatState((state) => state.conversation.isLoading);\n const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);\n const reportAnalyticsEvent = useReportAnalyticsEvent();\n useFetchInitialMessage(handleError, stream);\n\n useEffect(() => {\n reportAnalyticsEvent({\n action: \"CHAT_IMPRESSION\",\n });\n }, [reportAnalyticsEvent]);\n\n const messagesRef = useRef<Array<HTMLDivElement | null>>([]);\n const messagesContainer = useRef<HTMLDivElement>(null);\n\n // Handle scrolling when messages change\n useEffect(() => {\n let scrollTop = 0;\n messagesRef.current = messagesRef.current.slice(0, messages.length);\n\n // Sums up scroll heights of all messages except the last one\n if (messagesRef?.current.length > 1) {\n scrollTop = messagesRef.current\n .slice(0, -1)\n .map((elem, _) => elem?.scrollHeight ?? 0)\n .reduce((total, height) => total + height);\n }\n\n // Scroll to the top of the last message\n messagesContainer.current?.scroll({\n top: scrollTop,\n behavior: \"smooth\",\n });\n }, [messages]);\n\n const setMessagesRef = useCallback((index) => {\n if (!messagesRef?.current) return null;\n return (message) => (messagesRef.current[index] = message);\n }, []);\n\n return (\n <div className=\"yext-chat w-full h-full\">\n <div className={cssClasses.container}>\n {header}\n <div className={cssClasses.messagesScrollContainer}>\n <div ref={messagesContainer} className={cssClasses.messagesContainer}>\n {messages.map((message, index) => (\n <div key={index} ref={setMessagesRef(index)}>\n <MessageBubble\n {...props}\n customCssClasses={cssClasses.messageBubbleCssClasses}\n message={message}\n />\n </div>\n ))}\n {loading && <LoadingDots />}\n </div>\n </div>\n <div className={cssClasses.inputContainer}>\n <ChatInput {...props} customCssClasses={cssClasses.inputCssClasses} />\n </div>\n </div>\n </div>\n );\n}\n"],"names":["withStylelessCssClasses","useChatState","useComposedCssClasses","useReportAnalyticsEvent","useFetchInitialMessage","useEffect","useRef","useCallback","React","MessageBubble","LoadingDots","ChatInput"],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAM,iBAAiB,GAAwBA,+CAAuB,CACpE,OAAO,EACP;AACE,IAAA,SAAS,EAAE,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AK,MAC3BA,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,cAAc,CAAC,KAAK,CAAC,EAAA;AACzC,wBAAAA,sBAAA,CAAA,aAAA,CAACC,2BAAa,EACR,EAAA,GAAA,KAAK,EACT,gBAAgB,EAAE,UAAU,CAAC,uBAAuB,EACpD,OAAO,EAAE,OAAO,EAChB,CAAA,CACE,CACP,CAAC;AACD,oBAAA,OAAO,IAAID,sBAAA,CAAA,aAAA,CAACE,uBAAW,EAAA,IAAA,CAAG,CACvB,CACF;AACN,YAAAF,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,cAAc,EAAA;AACvC,gBAAAA,sBAAA,CAAA,aAAA,CAACG,mBAAS,EAAA,EAAA,GAAK,KAAK,EAAE,gBAAgB,EAAE,UAAU,CAAC,eAAe,EAAI,CAAA,CAClE,CACF,CACF,EACN;AACJ;;;;"}
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
2
  import { ChatPanelCssClasses, ChatPanelProps } from "./ChatPanel";
3
3
  import { ChatHeaderCssClasses, ChatHeaderProps } from "./ChatHeader";
4
+ import { InitialMessagePopUpCssClasses } from "./InitialMessagePopUp";
4
5
  /**
5
6
  * The CSS class interface for the {@link ChatPopUp} component.
6
7
  *
@@ -12,11 +13,16 @@ export interface ChatPopUpCssClasses {
12
13
  panel__display?: string;
13
14
  panel__hidden?: string;
14
15
  button?: string;
15
- button__display?: string;
16
- button__hidden?: string;
17
16
  buttonIcon?: string;
17
+ ctaLabelContainer?: string;
18
+ ctaLabel?: string;
19
+ notification?: string;
20
+ closedPopupContainer?: string;
21
+ closedPopupContainer__display?: string;
22
+ closedPopupContainer__hidden?: string;
18
23
  headerCssClasses?: ChatHeaderCssClasses;
19
24
  panelCssClasses?: ChatPanelCssClasses;
25
+ initialMessagePopUpCssClasses?: InitialMessagePopUpCssClasses;
20
26
  }
21
27
  /**
22
28
  * The props for the {@link ChatPopUp} component.
@@ -26,10 +32,31 @@ export interface ChatPopUpCssClasses {
26
32
  export interface ChatPopUpProps extends Omit<ChatHeaderProps, "showCloseButton" | "customCssClasses">, Omit<ChatPanelProps, "header" | "customCssClasses"> {
27
33
  /** Custom icon for the popup button to open the panel. */
28
34
  openPanelButtonIcon?: JSX.Element;
35
+ /** CSS classes for customizing the component styling. */
36
+ customCssClasses?: ChatPopUpCssClasses;
37
+ /** Whether to show the panel on load. Defaults to false. */
38
+ openOnLoad?: boolean;
29
39
  /**
30
- * CSS classes for customizing the component styling.
40
+ * Whether to show the initial message popup when the panel is hidden on load.
41
+ * Defaults to false.
31
42
  */
32
- customCssClasses?: ChatPopUpCssClasses;
43
+ showInitialMessagePopUp?: boolean;
44
+ /**
45
+ * Whether to show a heartbeat animation on the popup button when the panel is hidden.
46
+ * Defaults to false.
47
+ */
48
+ showHeartBeatAnimation?: boolean;
49
+ /**
50
+ * Whether to show notification showing number of unread messages.
51
+ * Defaults to false.
52
+ */
53
+ showUnreadNotification?: boolean;
54
+ /**
55
+ * The "Call to Action" label to be displayed next to the popup button.
56
+ * By default, the CTA is not shown.
57
+ * This prop will override the "showInitialMessagePopUp" prop, if specified.
58
+ */
59
+ ctaLabel?: string;
33
60
  }
34
61
  /**
35
62
  * A component that renders a popup button that displays and hides
@@ -1 +1 @@
1
- {"version":3,"file":"ChatPopUp.d.ts","sourceRoot":"","sources":["../../../../src/components/ChatPopUp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAEhE,OAAO,EAAa,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7E,OAAO,EAEL,oBAAoB,EACpB,eAAe,EAChB,MAAM,cAAc,CAAC;AAMtB;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAA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IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,4BAA4B,CAAC,EAAE,MAAM,CAAC;IACtC,gBAAgB,CAAC,EAAE,oBAAoB,CAAC;IACxC,eAAe,CAAC,EAAE,mBAAmB,CAAC;IACtC,6BAA6B,CAAC,EAAE,6BAA6B,CAAC;CAC/D;AAqCD;;;;GAIG;AACH,MAAM,WAAW,cACf,SAAQ,IAAI,CAAC,eAAe,EAAE,iBAAiB,GAAG,kBAAkB,CAAC,EACnE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,kBAAkB,CAAC;IACrD,0DAA0D;IAC1D,mBAAmB,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC;IAClC,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,mBAAmB,CAAC;IACvC,4DAA4D;IAC5D,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;OAGG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;OAGG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;GAOG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qBAyJ9C"}
@@ -8,6 +8,9 @@ var tailwindMerge = require('tailwind-merge');
8
8
  var useComposedCssClasses = require('../hooks/useComposedCssClasses.js');
9
9
  var withStylelessCssClasses = require('../utils/withStylelessCssClasses.js');
10
10
  var useReportAnalyticsEvent = require('../hooks/useReportAnalyticsEvent.js');
11
+ var InitialMessagePopUp = require('./InitialMessagePopUp.js');
12
+ var chatHeadlessReact = require('@yext/chat-headless-react');
13
+ var useFetchInitialMessage = require('../hooks/useFetchInitialMessage.js');
11
14
 
12
15
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
16
 
@@ -20,11 +23,15 @@ const builtInCssClasses = withStylelessCssClasses.withStylelessCssClasses("PopUp
20
23
  "w-80 max-[480px]:right-0 max-[480px]:bottom-0 max-[480px]:w-full max-[480px]:h-full lg:w-96 h-[75vh]",
21
24
  panel__display: "duration-300 translate-y-0",
22
25
  panel__hidden: "duration-300 translate-y-[20%] opacity-0 invisible",
23
- button: fixedPosition +
24
- "p-2 w-12 h-12 lg:w-16 lg:h-16 flex justify-center items-center text-white shadow-xl rounded-full bg-gradient-to-br from-blue-600 to-blue-700 hover:-translate-y-2 duration-150",
25
- button__display: "duration-300 transform translate-y-0",
26
- button__hidden: "duration-300 transform translate-y-[20%] opacity-0 invisible",
26
+ closedPopupContainer: fixedPosition +
27
+ "flex gap-x-2.5 items-center hover:-translate-y-2 duration-150",
28
+ closedPopupContainer__display: "duration-300 transform translate-y-0",
29
+ closedPopupContainer__hidden: "duration-300 transform translate-y-[20%] opacity-0 invisible",
30
+ button: "p-2 w-12 h-12 lg:w-16 lg:h-16 flex justify-center items-center text-white shadow-xl rounded-full bg-gradient-to-br from-blue-600 to-blue-700",
27
31
  buttonIcon: "text-blue-600 w-[28px] h-[28px] lg:w-[40px] lg:h-[40px]",
32
+ ctaLabelContainer: "max-w-60 -mr-8 line-clamp-1",
33
+ ctaLabel: "p-3 pr-8 flex items-center whitespace-nowrap animate-expand-left font-bold rounded-l-full bg-white text-blue-700 h-10 lg:h-14 text-sm lg:text-base",
34
+ notification: "fixed animate-fade-in bg-red-700 -right-1 top-0 rounded-full w-5 lg:w-6 h-5 lg:h-6 items-center flex justify-center text-sm lg:text-base text-white",
28
35
  headerCssClasses: {
29
36
  container: "max-[480px]:rounded-none rounded-t-3xl",
30
37
  },
@@ -43,29 +50,70 @@ const builtInCssClasses = withStylelessCssClasses.withStylelessCssClasses("PopUp
43
50
  * @param props - {@link ChatPanelProps}
44
51
  */
45
52
  function ChatPopUp(props) {
46
- const { openPanelButtonIcon, customCssClasses, showRestartButton = true, onClose: customOnClose, title, } = props;
53
+ const { openPanelButtonIcon, customCssClasses, showRestartButton = true, onClose: customOnClose, handleError, openOnLoad = false, showInitialMessagePopUp = false, showHeartBeatAnimation = false, showUnreadNotification = false, ctaLabel, title, } = props;
47
54
  const reportAnalyticsEvent = useReportAnalyticsEvent.useReportAnalyticsEvent();
48
55
  React.useEffect(() => {
49
56
  reportAnalyticsEvent({
50
57
  action: "CHAT_IMPRESSION",
51
58
  });
52
59
  }, [reportAnalyticsEvent]);
60
+ const messages = chatHeadlessReact.useChatState((s) => s.conversation.messages);
61
+ const [numReadMessages, setNumReadMessagesLength] = React.useState(0);
62
+ const [numUnreadMessages, setNumUnreadMessagesLength] = React.useState(0);
63
+ useFetchInitialMessage.useFetchInitialMessage(showInitialMessagePopUp ? console.error : handleError, false, showUnreadNotification || showInitialMessagePopUp);
64
+ const [showInitialMessage, setshowInitialMessage] = React.useState(
65
+ //only show initial message popup (if specified) when CTA label is not provided
66
+ !ctaLabel && showInitialMessagePopUp);
67
+ const onCloseInitialMessage = React.useCallback(() => {
68
+ setshowInitialMessage(false);
69
+ }, []);
70
+ // control CSS behavior on open/close state of the panel
53
71
  const [showChat, setShowChat] = React.useState(false);
72
+ // control the actual DOM rendering of the panel. Start rendering on first open state
73
+ // to avoid message requests immediately on load while the popup is still "hidden"
74
+ const [renderChat, setRenderChat] = React.useState(false);
75
+ // update in useEffect, instead of having openOnLoad as initial state for show/renderChat,
76
+ // in order to maintain the fade-in CSS animation when opening the panel on load
77
+ React.useEffect(() => {
78
+ if (openOnLoad) {
79
+ setShowChat(true);
80
+ setRenderChat(true);
81
+ setshowInitialMessage(false);
82
+ }
83
+ }, [openOnLoad]);
54
84
  const onClick = React.useCallback(() => {
55
85
  setShowChat(!showChat);
86
+ setRenderChat(true);
87
+ setshowInitialMessage(false);
56
88
  }, [showChat]);
57
89
  const onClose = React.useCallback(() => {
58
90
  setShowChat(false);
59
91
  customOnClose?.();
60
- }, [customOnClose]);
92
+ // consider all the messages are read while the panel was open
93
+ setNumReadMessagesLength(messages.length);
94
+ }, [customOnClose, messages]);
95
+ React.useEffect(() => {
96
+ //update number of unread messages if there are new messages added while the panel is closed
97
+ setNumUnreadMessagesLength(messages.length - numReadMessages);
98
+ }, [messages, numReadMessages]);
61
99
  const cssClasses = useComposedCssClasses.useComposedCssClasses(builtInCssClasses, customCssClasses);
62
100
  const panelCssClasses = tailwindMerge.twMerge(cssClasses.panel, showChat ? cssClasses.panel__display : cssClasses.panel__hidden);
63
- const buttonCssClasses = tailwindMerge.twMerge(cssClasses.button, showChat ? cssClasses.button__hidden : cssClasses.button__display);
101
+ const closedPopupContainerCssClasses = tailwindMerge.twMerge(cssClasses.closedPopupContainer, showChat
102
+ ? cssClasses.closedPopupContainer__hidden
103
+ : cssClasses.closedPopupContainer__display);
64
104
  return (React__default.default.createElement("div", { className: "yext-chat w-full h-full" },
65
105
  React__default.default.createElement("div", { className: cssClasses.container },
66
- React__default.default.createElement("div", { className: panelCssClasses, "aria-label": "Chat Popup Panel" },
67
- React__default.default.createElement(ChatPanel.ChatPanel, { ...props, customCssClasses: cssClasses.panelCssClasses, header: React__default.default.createElement(ChatHeader.ChatHeader, { title: title, showRestartButton: showRestartButton, showCloseButton: true, onClose: onClose, customCssClasses: cssClasses.headerCssClasses }) })),
68
- React__default.default.createElement("button", { "aria-label": "Chat Popup Button", onClick: onClick, className: buttonCssClasses }, openPanelButtonIcon ?? (React__default.default.createElement(Chat.ChatIcon, { className: cssClasses.buttonIcon }))))));
106
+ React__default.default.createElement("div", { className: panelCssClasses, "aria-label": "Chat Popup Panel" }, renderChat && (React__default.default.createElement(ChatPanel.ChatPanel, { ...props, customCssClasses: cssClasses.panelCssClasses, header: React__default.default.createElement(ChatHeader.ChatHeader, { title: title, showRestartButton: showRestartButton, showCloseButton: true, onClose: onClose, customCssClasses: cssClasses.headerCssClasses }) }))),
107
+ React__default.default.createElement("div", { className: closedPopupContainerCssClasses, "aria-label": "Chat Closed Popup Container" },
108
+ showInitialMessage && (React__default.default.createElement(InitialMessagePopUp.InitialMessagePopUp, { onClose: onCloseInitialMessage, customCssClasses: cssClasses.initialMessagePopUpCssClasses })),
109
+ ctaLabel && (
110
+ // the div container is needed to islate the expand CSS animation
111
+ React__default.default.createElement("div", { className: cssClasses.ctaLabelContainer },
112
+ React__default.default.createElement("button", { onClick: onClick, "aria-label": "CTA Label", className: cssClasses.ctaLabel }, ctaLabel))),
113
+ React__default.default.createElement("button", { "aria-label": "Chat Popup Button", onClick: onClick, className: cssClasses.button +
114
+ (showHeartBeatAnimation ? " animate-heartbeat" : "") },
115
+ openPanelButtonIcon ?? (React__default.default.createElement(Chat.ChatIcon, { className: cssClasses.buttonIcon })),
116
+ showUnreadNotification && !!numUnreadMessages && (React__default.default.createElement("div", { "aria-label": "Unread Messages Notification", className: cssClasses.notification }, numUnreadMessages)))))));
69
117
  }
70
118
 
71
119
  exports.ChatPopUp = ChatPopUp;
@@ -1 +1 @@
1
- {"version":3,"file":"ChatPopUp.js","sources":["../../../../src/components/ChatPopUp.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport { ChatIcon } from \"../icons/Chat\";\nimport { ChatPanel, ChatPanelCssClasses, ChatPanelProps } from \"./ChatPanel\";\nimport {\n ChatHeader,\n ChatHeaderCssClasses,\n ChatHeaderProps,\n} from \"./ChatHeader\";\nimport { twMerge } from \"tailwind-merge\";\nimport { useComposedCssClasses } from \"../hooks\";\nimport { withStylelessCssClasses } from \"../utils/withStylelessCssClasses\";\nimport { useReportAnalyticsEvent } from \"../hooks/useReportAnalyticsEvent\";\n\n/**\n * The CSS class interface for the {@link ChatPopUp} component.\n *\n * @public\n */\nexport interface ChatPopUpCssClasses {\n container?: string;\n panel?: string;\n panel__display?: string;\n panel__hidden?: string;\n button?: string;\n button__display?: string;\n button__hidden?: string;\n buttonIcon?: string;\n headerCssClasses?: ChatHeaderCssClasses;\n panelCssClasses?: ChatPanelCssClasses;\n}\n\nconst fixedPosition = \"fixed bottom-6 right-4 lg:bottom-14 lg:right-10 z-50 \";\nconst builtInCssClasses: ChatPopUpCssClasses = withStylelessCssClasses(\n \"PopUp\",\n {\n container: \"transition-all\",\n panel:\n fixedPosition +\n \"w-80 max-[480px]:right-0 max-[480px]:bottom-0 max-[480px]:w-full max-[480px]:h-full lg:w-96 h-[75vh]\",\n panel__display: \"duration-300 translate-y-0\",\n panel__hidden: \"duration-300 translate-y-[20%] opacity-0 invisible\",\n button:\n fixedPosition +\n \"p-2 w-12 h-12 lg:w-16 lg:h-16 flex justify-center items-center text-white shadow-xl rounded-full bg-gradient-to-br from-blue-600 to-blue-700 hover:-translate-y-2 duration-150\",\n button__display: \"duration-300 transform translate-y-0\",\n button__hidden:\n \"duration-300 transform translate-y-[20%] opacity-0 invisible\",\n buttonIcon: \"text-blue-600 w-[28px] h-[28px] lg:w-[40px] lg:h-[40px]\",\n headerCssClasses: {\n container: \"max-[480px]:rounded-none rounded-t-3xl\",\n },\n panelCssClasses: {\n container: \"max-[480px]:rounded-none rounded-3xl\",\n inputContainer: \"max-[480px]:rounded-none rounded-b-3xl\",\n messagesScrollContainer: \"rounded-b-3xl\",\n },\n }\n);\n\n/**\n * The props for the {@link ChatPopUp} component.\n *\n * @public\n */\nexport interface ChatPopUpProps\n extends Omit<ChatHeaderProps, \"showCloseButton\" | \"customCssClasses\">,\n Omit<ChatPanelProps, \"header\" | \"customCssClasses\"> {\n /** Custom icon for the popup button to open the panel. */\n openPanelButtonIcon?: JSX.Element;\n /**\n * CSS classes for customizing the component styling.\n */\n customCssClasses?: ChatPopUpCssClasses;\n}\n\n/**\n * A component that renders a popup button that displays and hides\n * a panel for chat bot interactions.\n *\n * @public\n *\n * @param props - {@link ChatPanelProps}\n */\nexport function ChatPopUp(props: ChatPopUpProps) {\n const {\n openPanelButtonIcon,\n customCssClasses,\n showRestartButton = true,\n onClose: customOnClose,\n title,\n } = props;\n const reportAnalyticsEvent = useReportAnalyticsEvent();\n\n useEffect(() => {\n reportAnalyticsEvent({\n action: \"CHAT_IMPRESSION\",\n });\n }, [reportAnalyticsEvent]);\n\n const [showChat, setShowChat] = useState(false);\n const onClick = useCallback(() => {\n setShowChat(!showChat);\n }, [showChat]);\n\n const onClose = useCallback(() => {\n setShowChat(false);\n customOnClose?.();\n }, [customOnClose]);\n\n const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);\n const panelCssClasses = twMerge(\n cssClasses.panel,\n showChat ? cssClasses.panel__display : cssClasses.panel__hidden\n );\n const buttonCssClasses = twMerge(\n cssClasses.button,\n showChat ? cssClasses.button__hidden : cssClasses.button__display\n );\n\n return (\n <div className=\"yext-chat w-full h-full\">\n <div className={cssClasses.container}>\n <div className={panelCssClasses} aria-label=\"Chat Popup Panel\">\n <ChatPanel\n {...props}\n customCssClasses={cssClasses.panelCssClasses}\n header={\n <ChatHeader\n title={title}\n showRestartButton={showRestartButton}\n showCloseButton={true}\n onClose={onClose}\n customCssClasses={cssClasses.headerCssClasses}\n />\n }\n />\n </div>\n <button\n aria-label=\"Chat Popup Button\"\n onClick={onClick}\n className={buttonCssClasses}\n >\n {openPanelButtonIcon ?? (\n <ChatIcon className={cssClasses.buttonIcon} />\n )}\n </button>\n </div>\n </div>\n );\n}\n"],"names":["withStylelessCssClasses","useReportAnalyticsEvent","useEffect","useState","useCallback","useComposedCssClasses","twMerge","React","ChatPanel","ChatHeader","ChatIcon"],"mappings":";;;;;;;;;;;;;;;AA+BA,MAAM,aAAa,GAAG,uDAAuD,CAAC;AAC9E,MAAM,iBAAiB,GAAwBA,+CAAuB,CACpE,OAAO,EACP;AACE,IAAA,SAAS,EAAE,gBAAgB;AAC3B,IAAA,KAAK,EACH,aAAa;QACb,sGAAsG;AACxG,IAAA,cAAc,EAAE,4BAA4B;AAC5C,IAAA,aAAa,EAAE,oDAAoD;AACnE,IAAA,MAAM,EACJ,aAAa;QACb,gLAAgL;AAClL,IAAA,eAAe,E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EAChB,QAAQ,GAAG,UAAU,CAAC,cAAc,GAAG,UAAU,CAAC,aAAa,CAChE,CAAC;IACF,MAAM,gBAAgB,GAAGA,qBAAO,CAC9B,UAAU,CAAC,MAAM,EACjB,QAAQ,GAAG,UAAU,CAAC,cAAc,GAAG,UAAU,CAAC,eAAe,CAClE,CAAC;AAEF,IAAA,QACEC,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,yBAAyB,EAAA;AACtC,QAAAA,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,UAAU,CAAC,SAAS,EAAA;AAClC,YAAAA,sBAAA,CAAA,aAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAE,eAAe,EAAA,YAAA,EAAa,kBAAkB,EAAA;AAC5D,gBAAAA,sBAAA,CAAA,aAAA,CAACC,mBAAS,EACJ,EAAA,GAAA,KAAK,EACT,gBAAgB,EAAE,UAAU,CAAC,eAAe,EAC5C,MAAM,EACJD,sBAAA,CAAA,aAAA,CAACE,qBAAU,EACT,EAAA,KAAK,EAAE,KAAK,EACZ,iBAAiB,EAAE,iBAAiB,EACpC,eAAe,EAAE,IAAI,EACrB,OAAO,EAAE,OAAO,EAChB,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAAA,CAC7C,GAEJ,CACE;YACNF,sBACa,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,YAAA,EAAA,mBAAmB,EAC9B,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,gBAAgB,EAE1B,EAAA,mBAAmB,KAClBA,sBAAC,CAAA,aAAA,CAAAG,aAAQ,EAAC,EAAA,SAAS,EAAE,UAAU,CAAC,UAAU,EAAI,CAAA,CAC/C,CACM,CACL,CACF,EACN;AACJ;;;;"}
1
+ {"version":3,"file":"ChatPopUp.js","sources":["../../../../src/components/ChatPopUp.tsx"],"sourcesContent":["import React, { useCallback, useEffect, useState } from \"react\";\nimport { ChatIcon } from \"../icons/Chat\";\nimport { ChatPanel, ChatPanelCssClasses, ChatPanelProps } from \"./ChatPanel\";\nimport {\n ChatHeader,\n ChatHeaderCssClasses,\n ChatHeaderProps,\n} from \"./ChatHeader\";\nimport { twMerge } from \"tailwind-merge\";\nimport { useComposedCssClasses } from \"../hooks\";\nimport { withStylelessCssClasses } from \"../utils/withStylelessCssClasses\";\nimport { useReportAnalyticsEvent } from \"../hooks/useReportAnalyticsEvent\";\nimport {\n InitialMessagePopUp,\n InitialMessagePopUpCssClasses,\n} from \"./InitialMessagePopUp\";\nimport { useChatState } from \"@yext/chat-headless-react\";\nimport { useFetchInitialMessage } from \"../hooks/useFetchInitialMessage\";\n\n/**\n * The CSS class interface for the {@link ChatPopUp} component.\n *\n * @public\n */\nexport interface ChatPopUpCssClasses {\n container?: string;\n panel?: string;\n panel__display?: string;\n panel__hidden?: string;\n button?: string;\n buttonIcon?: string;\n ctaLabelContainer?: string;\n ctaLabel?: string;\n notification?: string;\n closedPopupContainer?: string;\n closedPopupContainer__display?: string;\n closedPopupContainer__hidden?: string;\n headerCssClasses?: ChatHeaderCssClasses;\n panelCssClasses?: ChatPanelCssClasses;\n initialMessagePopUpCssClasses?: InitialMessagePopUpCssClasses;\n}\n\nconst fixedPosition = \"fixed bottom-6 right-4 lg:bottom-14 lg:right-10 z-50 \";\nconst builtInCssClasses: ChatPopUpCssClasses = withStylelessCssClasses(\n \"PopUp\",\n {\n container: \"transition-all\",\n panel:\n fixedPosition +\n \"w-80 max-[480px]:right-0 max-[480px]:bottom-0 max-[480px]:w-full max-[480px]:h-full lg:w-96 h-[75vh]\",\n panel__display: \"duration-300 translate-y-0\",\n panel__hidden: \"duration-300 translate-y-[20%] opacity-0 invisible\",\n closedPopupContainer:\n fixedPosition +\n \"flex gap-x-2.5 items-center hover:-translate-y-2 duration-150\",\n closedPopupContainer__display: \"duration-300 transform translate-y-0\",\n closedPopupContainer__hidden:\n \"duration-300 transform translate-y-[20%] opacity-0 invisible\",\n button:\n \"p-2 w-12 h-12 lg:w-16 lg:h-16 flex justify-center items-center text-white shadow-xl rounded-full bg-gradient-to-br from-blue-600 to-blue-700\",\n buttonIcon: \"text-blue-600 w-[28px] h-[28px] lg:w-[40px] lg:h-[40px]\",\n ctaLabelContainer: \"max-w-60 -mr-8 line-clamp-1\",\n ctaLabel:\n \"p-3 pr-8 flex items-center whitespace-nowrap animate-expand-left font-bold rounded-l-full bg-white text-blue-700 h-10 lg:h-14 text-sm lg:text-base\",\n notification:\n \"fixed animate-fade-in bg-red-700 -right-1 top-0 rounded-full w-5 lg:w-6 h-5 lg:h-6 items-center flex justify-center text-sm lg:text-base text-white\",\n headerCssClasses: {\n container: \"max-[480px]:rounded-none rounded-t-3xl\",\n },\n panelCssClasses: {\n container: \"max-[480px]:rounded-none rounded-3xl\",\n inputContainer: \"max-[480px]:rounded-none rounded-b-3xl\",\n messagesScrollContainer: \"rounded-b-3xl\",\n },\n }\n);\n\n/**\n * The props for the {@link ChatPopUp} component.\n *\n * @public\n */\nexport interface ChatPopUpProps\n extends Omit<ChatHeaderProps, \"showCloseButton\" | \"customCssClasses\">,\n Omit<ChatPanelProps, \"header\" | \"customCssClasses\"> {\n /** Custom icon for the popup button to open the panel. */\n openPanelButtonIcon?: JSX.Element;\n /** CSS classes for customizing the component styling. */\n customCssClasses?: ChatPopUpCssClasses;\n /** Whether to show the panel on load. Defaults to false. */\n openOnLoad?: boolean;\n /**\n * Whether to show the initial message popup when the panel is hidden on load.\n * Defaults to false.\n */\n showInitialMessagePopUp?: boolean;\n /**\n * Whether to show a heartbeat animation on the popup button when the panel is hidden.\n * Defaults to false.\n */\n showHeartBeatAnimation?: boolean;\n /**\n * Whether to show notification showing number of unread messages.\n * Defaults to false.\n */\n showUnreadNotification?: boolean;\n /**\n * The \"Call to Action\" label to be displayed next to the popup button.\n * By default, the CTA is not shown.\n * This prop will override the \"showInitialMessagePopUp\" prop, if specified.\n */\n ctaLabel?: string;\n}\n\n/**\n * A component that renders a popup button that displays and hides\n * a panel for chat bot interactions.\n *\n * @public\n *\n * @param props - {@link ChatPanelProps}\n */\nexport function ChatPopUp(props: ChatPopUpProps) {\n const {\n openPanelButtonIcon,\n customCssClasses,\n showRestartButton = true,\n onClose: customOnClose,\n handleError,\n openOnLoad = false,\n showInitialMessagePopUp = false,\n showHeartBeatAnimation = false,\n showUnreadNotification = false,\n ctaLabel,\n title,\n } = props;\n\n const reportAnalyticsEvent = useReportAnalyticsEvent();\n useEffect(() => {\n reportAnalyticsEvent({\n action: \"CHAT_IMPRESSION\",\n });\n }, [reportAnalyticsEvent]);\n\n const messages = useChatState((s) => s.conversation.messages);\n const [numReadMessages, setNumReadMessagesLength] = useState<number>(0);\n const [numUnreadMessages, setNumUnreadMessagesLength] = useState<number>(0);\n\n useFetchInitialMessage(\n showInitialMessagePopUp ? console.error : handleError,\n false,\n showUnreadNotification || showInitialMessagePopUp\n );\n\n const [showInitialMessage, setshowInitialMessage] = useState(\n //only show initial message popup (if specified) when CTA label is not provided\n !ctaLabel && showInitialMessagePopUp\n );\n const onCloseInitialMessage = useCallback(() => {\n setshowInitialMessage(false);\n }, []);\n\n // control CSS behavior on open/close state of the panel\n const [showChat, setShowChat] = useState(false);\n\n // control the actual DOM rendering of the panel. Start rendering on first open state\n // to avoid message requests immediately on load while the popup is still \"hidden\"\n const [renderChat, setRenderChat] = useState(false);\n\n // update in useEffect, instead of having openOnLoad as initial state for show/renderChat,\n // in order to maintain the fade-in CSS animation when opening the panel on load\n useEffect(() => {\n if (openOnLoad) {\n setShowChat(true);\n setRenderChat(true);\n setshowInitialMessage(false);\n }\n }, [openOnLoad]);\n\n const onClick = useCallback(() => {\n setShowChat(!showChat);\n setRenderChat(true);\n setshowInitialMessage(false);\n }, [showChat]);\n\n const onClose = useCallback(() => {\n setShowChat(false);\n customOnClose?.();\n // consider all the messages are read while the panel was open\n setNumReadMessagesLength(messages.length);\n }, [customOnClose, messages]);\n\n useEffect(() => {\n //update number of unread messages if there are new messages added while the panel is closed\n setNumUnreadMessagesLength(messages.length - numReadMessages);\n }, [messages, numReadMessages]);\n\n const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);\n const panelCssClasses = twMerge(\n cssClasses.panel,\n showChat ? cssClasses.panel__display : cssClasses.panel__hidden\n );\n const closedPopupContainerCssClasses = twMerge(\n cssClasses.closedPopupContainer,\n showChat\n ? cssClasses.closedPopupContainer__hidden\n : cssClasses.closedPopupContainer__display\n );\n\n return (\n <div className=\"yext-chat w-full h-full\">\n <div className={cssClasses.container}>\n <div className={panelCssClasses} aria-label=\"Chat Popup Panel\">\n {renderChat && (\n <ChatPanel\n {...props}\n customCssClasses={cssClasses.panelCssClasses}\n header={\n <ChatHeader\n title={title}\n showRestartButton={showRestartButton}\n showCloseButton={true}\n onClose={onClose}\n customCssClasses={cssClasses.headerCssClasses}\n />\n }\n />\n )}\n </div>\n <div\n className={closedPopupContainerCssClasses}\n aria-label=\"Chat Closed Popup Container\"\n >\n {showInitialMessage && (\n <InitialMessagePopUp\n onClose={onCloseInitialMessage}\n customCssClasses={cssClasses.initialMessagePopUpCssClasses}\n />\n )}\n {ctaLabel && (\n // the div container is needed to islate the expand CSS animation\n <div className={cssClasses.ctaLabelContainer}>\n <button\n onClick={onClick}\n aria-label=\"CTA Label\"\n className={cssClasses.ctaLabel}\n >\n {ctaLabel}\n </button>\n </div>\n )}\n <button\n aria-label=\"Chat Popup Button\"\n onClick={onClick}\n className={\n cssClasses.button +\n (showHeartBeatAnimation ? \" animate-heartbeat\" : \"\")\n }\n >\n {openPanelButtonIcon ?? (\n <ChatIcon className={cssClasses.buttonIcon} />\n )}\n {showUnreadNotification && !!numUnreadMessages && (\n <div\n aria-label=\"Unread Messages Notification\"\n className={cssClasses.notification}\n >\n {numUnreadMessages}\n </div>\n )}\n </button>\n </div>\n </div>\n </div>\n );\n}\n"],"names":["withStylelessCssClasses","useReportAnalyticsEvent","useEffect","useChatState","useState","useFetchInitialMessage","useCallback","useComposedCssClasses","twMerge","React","ChatPanel","ChatHeader","InitialM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E,UAAU,CAAC,YAAY,EAEjC,EAAA,iBAAiB,CACd,CACP,CACM,CACL,CACF,CACF,EACN;AACJ;;;;"}
@@ -0,0 +1,33 @@
1
+ import React from "react";
2
+ /**
3
+ * The CSS class interface for the InitialMessagePopUp component.
4
+ *
5
+ * @public
6
+ */
7
+ export interface InitialMessagePopUpCssClasses {
8
+ container?: string;
9
+ closeButton?: string;
10
+ closeButtonIcon?: string;
11
+ message?: string;
12
+ }
13
+ /**
14
+ * The props for the {@link InitialMessagePopUp} component.
15
+ *
16
+ * @internal
17
+ */
18
+ interface InitialMessagePopUpProps {
19
+ /** CSS classes for customizing the component styling. */
20
+ customCssClasses?: InitialMessagePopUpCssClasses;
21
+ /** Function to call when user click on the close button */
22
+ onClose: () => void;
23
+ }
24
+ /**
25
+ * A component that renders a popup bubble displaying the initial message from chat bot.
26
+ *
27
+ * @internal
28
+ *
29
+ * @param props - {@link InitialMessagePopUpProps}
30
+ */
31
+ export declare function InitialMessagePopUp({ onClose, customCssClasses, }: InitialMessagePopUpProps): React.JSX.Element;
32
+ export {};
33
+ //# sourceMappingURL=InitialMessagePopUp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitialMessagePopUp.d.ts","sourceRoot":"","sources":["../../../../src/components/InitialMessagePopUp.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAkB,MAAM,OAAO,CAAC;AAMvC;;;;GAIG;AACH,MAAM,WAAW,6BAA6B;IAC5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,UAAU,wBAAwB;IAChC,yDAAyD;IACzD,gBAAgB,CAAC,EAAE,6BAA6B,CAAC;IACjD,2DAA2D;IAC3D,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAWD;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,EAClC,OAAO,EACP,gBAAgB,GACjB,EAAE,wBAAwB,qBA0B1B"}
@@ -0,0 +1,44 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var Cross = require('../icons/Cross.js');
5
+ var useComposedCssClasses = require('../hooks/useComposedCssClasses.js');
6
+ var withStylelessCssClasses = require('../utils/withStylelessCssClasses.js');
7
+ var chatHeadlessReact = require('@yext/chat-headless-react');
8
+
9
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
10
+
11
+ var React__default = /*#__PURE__*/_interopDefault(React);
12
+
13
+ const builtInCssClasses = withStylelessCssClasses.withStylelessCssClasses("InitialMessagePopUp", {
14
+ container: "flex gap-x-1 animate-fade-in",
15
+ closeButton: "bg-white w-4 h-4 rounded-full border border-slate-300",
16
+ closeButtonIcon: "",
17
+ message: "line-clamp-2 w-60 p-2.5 bg-white rounded-xl shadow-xl text-sm lg:text-base",
18
+ });
19
+ /**
20
+ * A component that renders a popup bubble displaying the initial message from chat bot.
21
+ *
22
+ * @internal
23
+ *
24
+ * @param props - {@link InitialMessagePopUpProps}
25
+ */
26
+ function InitialMessagePopUp({ onClose, customCssClasses, }) {
27
+ const messages = chatHeadlessReact.useChatState((s) => s.conversation.messages);
28
+ const cssClasses = useComposedCssClasses.useComposedCssClasses(builtInCssClasses, customCssClasses);
29
+ const firstBotMessage = React.useMemo(() => {
30
+ return messages.length !== 0 && messages[0].source === chatHeadlessReact.MessageSource.BOT
31
+ ? messages[0].text
32
+ : "";
33
+ }, [messages]);
34
+ if (firstBotMessage.length === 0) {
35
+ return React__default.default.createElement(React__default.default.Fragment, null);
36
+ }
37
+ return (React__default.default.createElement("div", { className: cssClasses.container },
38
+ React__default.default.createElement("button", { "aria-label": "Close Initial Message", onClick: onClose, className: cssClasses.closeButton },
39
+ React__default.default.createElement(Cross.CrossIcon, { className: cssClasses.closeButtonIcon })),
40
+ React__default.default.createElement("div", { className: cssClasses.message }, firstBotMessage)));
41
+ }
42
+
43
+ exports.InitialMessagePopUp = InitialMessagePopUp;
44
+ //# sourceMappingURL=InitialMessagePopUp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InitialMessagePopUp.js","sources":["../../../../src/components/InitialMessagePopUp.tsx"],"sourcesContent":["import React, { useMemo } from \"react\";\nimport { CrossIcon } from \"../icons/Cross\";\nimport { useComposedCssClasses } from \"../hooks\";\nimport { withStylelessCssClasses } from \"../utils/withStylelessCssClasses\";\nimport { MessageSource, useChatState } from \"@yext/chat-headless-react\";\n\n/**\n * The CSS class interface for the InitialMessagePopUp component.\n *\n * @public\n */\nexport interface InitialMessagePopUpCssClasses {\n container?: string;\n closeButton?: string;\n closeButtonIcon?: string;\n message?: string;\n}\n\n/**\n * The props for the {@link InitialMessagePopUp} component.\n *\n * @internal\n */\ninterface InitialMessagePopUpProps {\n /** CSS classes for customizing the component styling. */\n customCssClasses?: InitialMessagePopUpCssClasses;\n /** Function to call when user click on the close button */\n onClose: () => void;\n}\n\nconst builtInCssClasses: InitialMessagePopUpCssClasses =\n withStylelessCssClasses(\"InitialMessagePopUp\", {\n container: \"flex gap-x-1 animate-fade-in\",\n closeButton: \"bg-white w-4 h-4 rounded-full border border-slate-300\",\n closeButtonIcon: \"\",\n message:\n \"line-clamp-2 w-60 p-2.5 bg-white rounded-xl shadow-xl text-sm lg:text-base\",\n });\n\n/**\n * A component that renders a popup bubble displaying the initial message from chat bot.\n *\n * @internal\n *\n * @param props - {@link InitialMessagePopUpProps}\n */\nexport function InitialMessagePopUp({\n onClose,\n customCssClasses,\n}: InitialMessagePopUpProps) {\n const messages = useChatState((s) => s.conversation.messages);\n const cssClasses = useComposedCssClasses(builtInCssClasses, customCssClasses);\n\n const firstBotMessage: string = useMemo(() => {\n return messages.length !== 0 && messages[0].source === MessageSource.BOT\n ? messages[0].text\n : \"\";\n }, [messages]);\n\n if (firstBotMessage.length === 0) {\n return <></>;\n }\n\n return (\n <div className={cssClasses.container}>\n <button\n aria-label=\"Close Initial Message\"\n onClick={onClose}\n className={cssClasses.closeButton}\n >\n <CrossIcon className={cssClasses.closeButtonIcon} />\n </button>\n <div className={cssClasses.message}>{firstBotMessage}</div>\n </div>\n );\n}\n"],"names":["withStylelessCssClasses","useChatState","useComposedCssClasses","useMemo","MessageSource","React","CrossIcon"],"mappings":";;;;;;;;;;;;AA8BA,MAAM,iBAAiB,GACrBA,+CAAuB,CAAC,qBAAqB,EAAE;AAC7C,IAAA,SAAS,EAAE,8BAA8B;AACzC,IAAA,WAAW,EAAE,uDAAuD;AACpE,IAAA,eAAe,EAAE,EAAE;AACnB,IAAA,OAAO,EACL,4EAA4E;AAC/E,CAAA,CAAC,CAAC;AAEL;;;;;;AAMG;SACa,mBAAmB,CAAC,EAClC,OAAO,EACP,gBAAgB,GACS,EAAA;AACzB,IAAA,MAAM,QAAQ,GAAGC,8BAAY,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC9D,MAAM,UAAU,GAAGC,2CAAqB,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAC;AAE9E,IAAA,MAAM,eAAe,GAAWC,aAAO,CAAC,MAAK;AAC3C,QAAA,OAAO,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,KAAKC,+BAAa,CAAC,GAAG;AACtE,cAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI;cAChB,EAAE,CAAC;AACT,KAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEf,IAAA,IAAI,eAAe,CAAC,MAAM,KAAK,CAAC,EAAE;AAChC,QAAA,OAAOC,2EAAK,CAAC;AACd,KAAA;AAED,IAAA,QACEA,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,SAAS,EAAA;QAClCA,sBACa,CAAA,aAAA,CAAA,QAAA,EAAA,EAAA,YAAA,EAAA,uBAAuB,EAClC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,UAAU,CAAC,WAAW,EAAA;YAEjCA,sBAAC,CAAA,aAAA,CAAAC,eAAS,IAAC,SAAS,EAAE,UAAU,CAAC,eAAe,GAAI,CAC7C;QACTD,sBAAK,CAAA,aAAA,CAAA,KAAA,EAAA,EAAA,SAAS,EAAE,UAAU,CAAC,OAAO,IAAG,eAAe,CAAO,CACvD,EACN;AACJ;;;;"}
@@ -4,9 +4,10 @@ export { ChatHeader } from "./ChatHeader";
4
4
  export type { ChatHeaderCssClasses, ChatHeaderProps } from "./ChatHeader";
5
5
  export { MessageBubble } from "./MessageBubble";
6
6
  export type { MessageBubbleCssClasses, MessageBubbleProps, } from "./MessageBubble";
7
- export type { FeedbackButtonsCssClasses } from "./FeedbackButtons";
8
7
  export { ChatPanel } from "./ChatPanel";
9
8
  export type { ChatPanelCssClasses, ChatPanelProps } from "./ChatPanel";
10
9
  export { ChatPopUp } from "./ChatPopUp";
11
10
  export type { ChatPopUpCssClasses, ChatPopUpProps } from "./ChatPopUp";
11
+ export type { FeedbackButtonsCssClasses } from "./FeedbackButtons";
12
+ export type { InitialMessagePopUpCssClasses } from "./InitialMessagePopUp";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,YAAY,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,YAAY,EACV,uBAAuB,EACvB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEvE,YAAY,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AACnE,YAAY,EAAE,6BAA6B,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Sends a request to Chat API to fetch the initial message when the
3
+ * conversation first start or when the message history is reset.
4
+ *
5
+ * @internal
6
+ *
7
+ * @param handleError - A function which is called when an error occurs while fetching for initial message.
8
+ * By default, the error is logged to the console and an error message is added to state.
9
+ * @param stream - Enable streaming behavior by making a request to Chat Streaming API. Defaults to false.
10
+ * @param customCondition - additional condition for when to fetch initial message
11
+ */
12
+ export declare function useFetchInitialMessage(handleError?: (e: unknown) => void, stream?: boolean, customCondition?: boolean): void;
13
+ //# sourceMappingURL=useFetchInitialMessage.d.ts.map