diff --git a/README.md b/README.md
index 8f21205..73486d6 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,8 @@ quikchat is a simple vanilla (no dependancies) JavaScript chat control that can
## Features
* Callback function for message events.
* Responsive design for various screen sizes.
-* Themeable
+* Themeable with css
+* Hideable/Showable Title and Text Entry areas allows flexibility of usage
## Demo
[Example Code and Demo](https://deftio.github.io/quikchat/example.html)
@@ -19,7 +20,7 @@ html
```html
-
+
```
Create a container element in your HTML where you want the chat interface to appear:
@@ -36,7 +37,64 @@ const chat = new quikchat('#chat-container', messageCallback);
chat.addMessage('Hello!', 'User', 'left'); // user should appear left or right justified
```
+## Theming
+QuikChat also allows theming using CSS of all the messages, and user area, and overal widget.
+Below is the prebuilt 'light' theme. To change the theme, make a new set of classes with different values but the same css selector naming (e.g. change "quikchat-theme-light" to "my-theme") and save as a style. Then pass the "my-theme" to the constructor.
+
+Themes can be changed at anytime by calling
+myChatWidget.changeTheme(newTheme) where myChatWidget is the instance of your widget.
+
+If several widgets are on the same page, each can have a separate theme.
+
+```css
+
+.quikchat-theme-light {
+ border: 1px solid #cccccc;
+ border-radius: 10px;
+ padding: 5px;
+ background-color: #f9f9f9;
+ }
+
+.quikchat-theme-light .quikchat-title-area {
+color: #333;
+}
+
+.quikchat-theme-light .quikchat-messages-area {
+background-color: #ffffffe2;
+color: #333;
+}
+
+.quikchat-theme-light .quikchat-message-1 {
+background-color: #fffffff0;
+color: #005662;
+}
+
+.quikchat-theme-light .quikchat-message-2 {
+background-color: #eeeeeee9;
+color: #353535;
+}
+
+.quikchat-theme-light .quikchat-input-area {
+background-color: #f0f0f0;
+}
+
+.quikchat-theme-light .quikchat-input-textbox {
+background-color: #ffffff;
+border: 1px solid #ccc;
+border-radius: 4px;
+font-size: 14px;
+color: #333;
+}
+
+.quikchat-theme-light .quikchat-input-send-btn {
+background-color: #4caf50;
+color: white;
+border: none;
+border-radius: 4px;
+}
+
+```
## Building from Source
Make sure to run npm install. Then run npm run build.
diff --git a/dist/quikchat.cjs.js b/dist/quikchat.cjs.js
index 5bc611a..b0ab1aa 100644
--- a/dist/quikchat.cjs.js
+++ b/dist/quikchat.cjs.js
@@ -193,11 +193,11 @@ var quikchat = /*#__PURE__*/function () {
messageDiv.classList.add('quikchat-message');
messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');
var userDiv = document.createElement('div');
- userDiv.textContent = user;
+ userDiv.innerHTML = user;
userDiv.style = "width: 100%; text-align: ".concat(align, "; font-size: 1em; font-weight:700; color: #444;");
var contentDiv = document.createElement('div');
contentDiv.style = "width: 100%; text-align: ".concat(align, ";");
- contentDiv.textContent = message;
+ contentDiv.innerHTML = message;
messageDiv.appendChild(userDiv);
messageDiv.appendChild(contentDiv);
this.messagesArea.appendChild(messageDiv);
diff --git a/dist/quikchat.cjs.js.map b/dist/quikchat.cjs.js.map
index a1164f8..aed25c1 100644
--- a/dist/quikchat.cjs.js.map
+++ b/dist/quikchat.cjs.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.cjs.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n
\n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.textContent = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.textContent = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","adjustMessagesAreaHeight","textContent","textAlign","titleAreaGet","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","fontSize","parseFloat","getComputedStyle","minWidth","addMessage","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","removeMesssage","n","removeChild","getMessage","appendMessage","updateMessage","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,IAEMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;IAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;AAAEG,MAAAA,KAAK,EAAE,sBAAsB;AAAEC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAE;KAAG,CAAA;AAAAC,IAAAA,eAAA,OAAAR,QAAA,CAAA,CAAA;IAClF,IAAI,CAACC,aAAa,GAAGA,aAAa,CAAA;AAClC,IAAA,IAAI,CAACK,KAAK,GAAGJ,IAAI,CAACI,KAAK,CAAA;AACvB,IAAA,IAAI,CAACC,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAG,YAAM,EAAG,CAAA;IACnD,IAAI,CAACE,YAAY,EAAE,CAAA;AACnB;IACA,IAAIP,IAAI,CAACQ,SAAS,EAAE;AAChB,MAAA,IAAI,CAACC,YAAY,CAACT,IAAI,CAACQ,SAAS,CAACE,KAAK,EAAEV,IAAI,CAACQ,SAAS,CAACG,KAAK,CAAC,CAAA;AAC7D,MAAA,IAAIX,IAAI,CAACQ,SAAS,CAACI,IAAI,EAAE;QACrB,IAAI,CAACC,aAAa,EAAE,CAAA;AACxB,OAAC,MAAM;QACH,IAAI,CAACC,aAAa,EAAE,CAAA;AACxB,OAAA;AACJ,KAAA;IACA,IAAI,CAACC,oBAAoB,EAAE,CAAA;AAC/B,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AACH,SAAS,CAACtC,WAAW,IAAI6B,OAAO,CAAA;AAClE,KAAA;AAAC,GAAA,EAAA;IAAArD,GAAA,EAAA,eAAA;AAAAC,IAAAA,KAAA,EAED,SAAAoE,aAAAA,CAAcJ,CAAC,EAAEZ,OAAO,EAAE;AACtB,MAAA,IAAI,CAAC9C,YAAY,CAAC2B,QAAQ,CAAC+B,CAAC,CAAC,CAACH,SAAS,CAACtC,WAAW,GAAG6B,OAAO,CAAA;AACjE,KAAA;AAAC,GAAA,EAAA;IAAArD,GAAA,EAAA,aAAA;AAAAC,IAAAA,KAAA,EAED,SAAAqE,WAAYC,CAAAA,QAAQ,EAAE;MAClB,IAAI,CAAClE,UAAU,CAACuB,SAAS,CAAC4C,MAAM,CAAC,IAAI,CAACrF,KAAK,CAAC,CAAA;MAC5C,IAAI,CAACkB,UAAU,CAACuB,SAAS,CAAC8B,GAAG,CAACa,QAAQ,CAAC,CAAA;MACvC,IAAI,CAACpF,KAAK,GAAGoF,QAAQ,CAAA;AACzB,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
+{"version":3,"file":"quikchat.cjs.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","adjustMessagesAreaHeight","textContent","textAlign","titleAreaGet","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","fontSize","parseFloat","getComputedStyle","minWidth","addMessage","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","removeMesssage","n","removeChild","getMessage","appendMessage","updateMessage","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,IAEMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;IAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;AAAEG,MAAAA,KAAK,EAAE,sBAAsB;AAAEC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAE;KAAG,CAAA;AAAAC,IAAAA,eAAA,OAAAR,QAAA,CAAA,CAAA;IAClF,IAAI,CAACC,aAAa,GAAGA,aAAa,CAAA;AAClC,IAAA,IAAI,CAACK,KAAK,GAAGJ,IAAI,CAACI,KAAK,CAAA;AACvB,IAAA,IAAI,CAACC,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAG,YAAM,EAAG,CAAA;IACnD,IAAI,CAACE,YAAY,EAAE,CAAA;AACnB;IACA,IAAIP,IAAI,CAACQ,SAAS,EAAE;AAChB,MAAA,IAAI,CAACC,YAAY,CAACT,IAAI,CAACQ,SAAS,CAACE,KAAK,EAAEV,IAAI,CAACQ,SAAS,CAACG,KAAK,CAAC,CAAA;AAC7D,MAAA,IAAIX,IAAI,CAACQ,SAAS,CAACI,IAAI,EAAE;QACrB,IAAI,CAACC,aAAa,EAAE,CAAA;AACxB,OAAC,MAAM;QACH,IAAI,CAACC,aAAa,EAAE,CAAA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ACtB,MAAA,IAAI,CAAC9C,YAAY,CAAC2B,QAAQ,CAAC+B,CAAC,CAAC,CAACH,SAAS,CAACtC,WAAW,IAAI6B,OAAO,CAAA;AAClE,KAAA;AAAC,GAAA,EAAA;IAAArD,GAAA,EAAA,eAAA;AAAAC,IAAAA,KAAA,EAED,SAAAoE,aAAAA,CAAcJ,CAAC,EAAEZ,OAAO,EAAE;AACtB,MAAA,IAAI,CAAC9C,YAAY,CAAC2B,QAAQ,CAAC+B,CAAC,CAAC,CAACH,SAAS,CAACtC,WAAW,GAAG6B,OAAO,CAAA;AACjE,KAAA;AAAC,GAAA,EAAA;IAAArD,GAAA,EAAA,aAAA;AAAAC,IAAAA,KAAA,EAED,SAAAqE,WAAYC,CAAAA,QAAQ,EAAE;MAClB,IAAI,CAAClE,UAAU,CAACuB,SAAS,CAAC4C,MAAM,CAAC,IAAI,CAACrF,KAAK,CAAC,CAAA;MAC5C,IAAI,CAACkB,UAAU,CAACuB,SAAS,CAAC8B,GAAG,CAACa,QAAQ,CAAC,CAAA;MACvC,IAAI,CAACpF,KAAK,GAAGoF,QAAQ,CAAA;AACzB,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
diff --git a/dist/quikchat.cjs.min.js b/dist/quikchat.cjs.min.js
index 4328d3a..40acdd5 100644
--- a/dist/quikchat.cjs.min.js
+++ b/dist/quikchat.cjs.min.js
@@ -1,2 +1,2 @@
-"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=t,this.theme=i.theme,this.onSend=i.onSend?i.onSend:function(){},this.createWidget(),i.titleArea&&(this.titleAreaSet(i.titleArea.title,i.titleArea.align),i.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this.attachEventListeners()}),[{key:"createWidget",value:function(){var e='\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n ');this.parentElement.innerHTML=e,this.chatWidget=this.parentElement.querySelector(".quikchat-base"),this.titleArea=this.chatWidget.querySelector(".quikchat-title-area"),this.messagesArea=this.chatWidget.querySelector(".quikchat-messages-area"),this.inputArea=this.chatWidget.querySelector(".quikchat-input-area"),this.textEntry=this.inputArea.querySelector(".quikchat-input-textbox"),this.sendButton=this.inputArea.querySelector(".quikchat-input-send-btn")}},{key:"attachEventListeners",value:function(){var e=this;this.sendButton.addEventListener("click",(function(){return e.onSend(e,e.textEntry.value.trim())})),window.addEventListener("resize",(function(){return e.handleContainerResize()})),this.chatWidget.addEventListener("resize",(function(){return e.handleContainerResize()})),this.textEntry.addEventListener("keydown",(function(t){t.shiftKey&&13===t.keyCode&&(t.preventDefault(),e.onSend(e,e.textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this.titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this.titleArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this.titleArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"titleAreaSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this.titleArea.textContent=e,this.titleArea.style.textAlign=t}},{key:"titleAreaGet",value:function(){return this.titleArea.textContent}},{key:"inputAreaToggle",value:function(){this.inputArea.classList.toggle("hidden"),"none"===this.inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this.inputArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this.inputArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"adjustMessagesAreaHeight",value:function(){var e=i(this.chatWidget.children).filter((function(e){return e.classList.contains("hidden")})).reduce((function(e,t){return e+t.offsetHeight}),0),t=this.chatWidget.offsetHeight;this.messagesArea.style.height="calc(100% - ".concat(t-e,"px)")}},{key:"handleContainerResize",value:function(){this.adjustMessagesAreaHeight(),this.adjustSendButtonWidth(),console.log("Container resized")}},{key:"adjustSendButtonWidth",value:function(){var e=this.sendButton.textContent.trim(),t=parseFloat(getComputedStyle(this.sendButton).fontSize)*e.length+16;this.sendButton.style.minWidth="".concat(t,"px")}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",n=document.createElement("div");n.classList.add("quikchat-message"),n.classList.add(this.messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var a=document.createElement("div");a.textContent=t,a.style="width: 100%; text-align: ".concat(i,"; font-size: 1em; font-weight:700; color: #444;");var s=document.createElement("div");s.style="width: 100%; text-align: ".concat(i,";"),s.textContent=e,n.appendChild(a),n.appendChild(s),this.messagesArea.appendChild(n),this.messagesArea.lastChild.scrollIntoView(),this.textEntry.value="",this.adjustMessagesAreaHeight()}},{key:"removeMesssage",value:function(e){this.messagesArea.removeChild(this.messagesArea.children[e])}},{key:"getMessage",value:function(e){return this.messagesArea.children[e].lastChild.textContent}},{key:"appendMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent+=t}},{key:"updateMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent=t}},{key:"changeTheme",value:function(e){this.chatWidget.classList.remove(this.theme),this.chatWidget.classList.add(e),this.theme=e}}])}();module.exports=a;
+"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=t,this.theme=i.theme,this.onSend=i.onSend?i.onSend:function(){},this.createWidget(),i.titleArea&&(this.titleAreaSet(i.titleArea.title,i.titleArea.align),i.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this.attachEventListeners()}),[{key:"createWidget",value:function(){var e='\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n ');this.parentElement.innerHTML=e,this.chatWidget=this.parentElement.querySelector(".quikchat-base"),this.titleArea=this.chatWidget.querySelector(".quikchat-title-area"),this.messagesArea=this.chatWidget.querySelector(".quikchat-messages-area"),this.inputArea=this.chatWidget.querySelector(".quikchat-input-area"),this.textEntry=this.inputArea.querySelector(".quikchat-input-textbox"),this.sendButton=this.inputArea.querySelector(".quikchat-input-send-btn")}},{key:"attachEventListeners",value:function(){var e=this;this.sendButton.addEventListener("click",(function(){return e.onSend(e,e.textEntry.value.trim())})),window.addEventListener("resize",(function(){return e.handleContainerResize()})),this.chatWidget.addEventListener("resize",(function(){return e.handleContainerResize()})),this.textEntry.addEventListener("keydown",(function(t){t.shiftKey&&13===t.keyCode&&(t.preventDefault(),e.onSend(e,e.textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this.titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this.titleArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this.titleArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"titleAreaSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this.titleArea.textContent=e,this.titleArea.style.textAlign=t}},{key:"titleAreaGet",value:function(){return this.titleArea.textContent}},{key:"inputAreaToggle",value:function(){this.inputArea.classList.toggle("hidden"),"none"===this.inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this.inputArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this.inputArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"adjustMessagesAreaHeight",value:function(){var e=i(this.chatWidget.children).filter((function(e){return e.classList.contains("hidden")})).reduce((function(e,t){return e+t.offsetHeight}),0),t=this.chatWidget.offsetHeight;this.messagesArea.style.height="calc(100% - ".concat(t-e,"px)")}},{key:"handleContainerResize",value:function(){this.adjustMessagesAreaHeight(),this.adjustSendButtonWidth(),console.log("Container resized")}},{key:"adjustSendButtonWidth",value:function(){var e=this.sendButton.textContent.trim(),t=parseFloat(getComputedStyle(this.sendButton).fontSize)*e.length+16;this.sendButton.style.minWidth="".concat(t,"px")}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",n=document.createElement("div");n.classList.add("quikchat-message"),n.classList.add(this.messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var a=document.createElement("div");a.innerHTML=t,a.style="width: 100%; text-align: ".concat(i,"; font-size: 1em; font-weight:700; color: #444;");var s=document.createElement("div");s.style="width: 100%; text-align: ".concat(i,";"),s.innerHTML=e,n.appendChild(a),n.appendChild(s),this.messagesArea.appendChild(n),this.messagesArea.lastChild.scrollIntoView(),this.textEntry.value="",this.adjustMessagesAreaHeight()}},{key:"removeMesssage",value:function(e){this.messagesArea.removeChild(this.messagesArea.children[e])}},{key:"getMessage",value:function(e){return this.messagesArea.children[e].lastChild.textContent}},{key:"appendMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent+=t}},{key:"updateMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent=t}},{key:"changeTheme",value:function(e){this.chatWidget.classList.remove(this.theme),this.chatWidget.classList.add(e),this.theme=e}}])}();module.exports=a;
//# sourceMappingURL=quikchat.cjs.min.js.map
diff --git a/dist/quikchat.cjs.min.js.map b/dist/quikchat.cjs.min.js.map
index 832e439..d1cfdc8 100644
--- a/dist/quikchat.cjs.min.js.map
+++ b/dist/quikchat.cjs.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.cjs.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.textContent = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.textContent = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","adjustMessagesAreaHeight","textContent","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","removeChild","newTheme","remove"],"mappings":"sxCAAA,IAEMA,EAAQ,WAgBT,OAAAC,GAfD,SAAAD,EAAYE,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAT,GAClFU,KAAKR,cAAgBA,EACrBQ,KAAKH,MAAQJ,EAAKI,MAClBG,KAAKF,OAASL,EAAKK,OAASL,EAAKK,OAAS,aAC1CE,KAAKC,eAEDR,EAAKS,YACLF,KAAKG,aAAaV,EAAKS,UAAUE,MAAOX,EAAKS,UAAUG,OACnDZ,EAAKS,UAAUI,KACfN,KAAKO,gBAELP,KAAKQ,iBAGbR,KAAKS,sBACT,GAAC,CAAA,CAAAC,IAAA,eAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBb,KAAKH,MAUhC,weAELG,KAAKR,cAAcsB,UAAYF,EAC/BZ,KAAKe,WAAaf,KAAKR,cAAcwB,cAAc,kBACnDhB,KAAKE,UAAYF,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKiB,aAAejB,KAAKe,WAAWC,cAAc,2BAClDhB,KAAKkB,UAAYlB,KAAKe,WA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K,4BAAAjB,OAA+BR,EAAsD,mDAElG,IAAM4D,EAAaJ,SAASC,cAAc,OAC1CG,EAAWnC,MAAK,4BAAAjB,OAA+BR,EAAQ,KACvD4D,EAAWhC,YAAcyB,EAEzBE,EAAWM,YAAYF,GACvBJ,EAAWM,YAAYD,GACvBjE,KAAKiB,aAAaiD,YAAYN,GAC9B5D,KAAKiB,aAAakD,UAAUC,iBAE5BpE,KAAKmB,UAAUR,MAAQ,GACvBX,KAAKgC,0BACT,GAAC,CAAAtB,IAAA,iBAAAC,MAED,SAAe0D,GACXrE,KAAKiB,aAAaqD,YAAYtE,KAAKiB,aAAawB,SAAS4B,GAC7D,GAAC,CAAA3D,IAAA,aAAAC,MAED,SAAW0D,GACP,OAAOrE,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,WACnD,GAAC,CAAAvB,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,aAAeyB,CAC3D,GAAC,CAAAhD,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,YAAcyB,CAC1D,GAAC,CAAAhD,IAAA,cAAAC,MAED,SAAY4D,GACRvE,KAAKe,WAAWoB,UAAUqC,OAAOxE,KAAKH,OACtCG,KAAKe,WAAWoB,UAAU4B,IAAIQ,GAC9BvE,KAAKH,MAAQ0E,CACjB,IAAC,CA5JS"}
\ No newline at end of file
+{"version":3,"file":"quikchat.cjs.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","adjustMessagesAreaHeight","textContent","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","removeChild","newTheme","remove"],"mappings":"sxCAAA,IAEMA,EAAQ,WAgBT,OAAAC,GAfD,SAAAD,EAAYE,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAT,GAClFU,KAAKR,cAAgBA,EACrBQ,KAAKH,MAAQJ,EAAKI,MAClBG,KAAKF,OAASL,EAAKK,OAASL,EAAKK,OAAS,aAC1CE,KAAKC,eAEDR,EAAKS,YACLF,KAAKG,aAAaV,EAAKS,UAAUE,MAAOX,EAAKS,UAAUG,OACnDZ,EAAKS,UAAUI,KACfN,KAAKO,gBAELP,KAAKQ,iBAGbR,KAAKS,sBACT,GAAC,CAAA,CAAAC,IAAA,eAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBb,KAAKH,MAUhC,weAELG,KAAKR,cAAcsB,UAAYF,EAC/BZ,KAAKe,WAAaf,KAAKR,cAAcwB,cAAc,kBACnDhB,KAAKE,UAAYF,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKiB,aAAejB,KAAKe,WAAWC,cAAc,2BAClDhB,KAAKkB,UAAYlB,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKmB,UAAYnB,KAAKkB,UAAUF,cAAc,2BAC9ChB,KAAKoB,WAAapB,KAAKkB,UAAUF,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,EAAQ,KACvD4D,EAAWnD,UAAY4C,EAEvBE,EAAWM,YAAYF,GACvBJ,EAAWM,YAAYD,GACvBjE,KAAKiB,aAAaiD,YAAYN,GAC9B5D,KAAKiB,aAAakD,UAAUC,iBAE5BpE,KAAKmB,UAAUR,MAAQ,GACvBX,KAAKgC,0BACT,GAAC,CAAAtB,IAAA,iBAAAC,MAED,SAAe0D,GACXrE,KAAKiB,aAAaqD,YAAYtE,KAAKiB,aAAawB,SAAS4B,GAC7D,GAAC,CAAA3D,IAAA,aAAAC,MAED,SAAW0D,GACP,OAAOrE,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,WACnD,GAAC,CAAAvB,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,aAAeyB,CAC3D,GAAC,CAAAhD,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,YAAcyB,CAC1D,GAAC,CAAAhD,IAAA,cAAAC,MAED,SAAY4D,GACRvE,KAAKe,WAAWoB,UAAUqC,OAAOxE,KAAKH,OACtCG,KAAKe,WAAWoB,UAAU4B,IAAIQ,GAC9BvE,KAAKH,MAAQ0E,CACjB,IAAC,CA5JS"}
\ No newline at end of file
diff --git a/dist/quikchat.css b/dist/quikchat.css
index 8df0711..b10be44 100644
--- a/dist/quikchat.css
+++ b/dist/quikchat.css
@@ -9,11 +9,10 @@
}
.quikchat-title-area {
- width: 100%;
- padding-left: 2px;
- padding-right:2px;
margin-left: 8px;
- margin-right: 28px;
+ margin-right: 8px;
+ padding-left : 2px;
+ padding-right : 2px;
font-weight: 600;
font-size: 1.3em;
}
@@ -67,6 +66,7 @@
color: #333;
font-size: 1.1em;
font-weight: 700;
+ margin-right: 10px;
}
.quikchat-theme-debug .quikchat-messages-area {
diff --git a/dist/quikchat.esm.js b/dist/quikchat.esm.js
index ee449d4..5e57bd0 100644
--- a/dist/quikchat.esm.js
+++ b/dist/quikchat.esm.js
@@ -191,11 +191,11 @@ var quikchat = /*#__PURE__*/function () {
messageDiv.classList.add('quikchat-message');
messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');
var userDiv = document.createElement('div');
- userDiv.textContent = user;
+ userDiv.innerHTML = user;
userDiv.style = "width: 100%; text-align: ".concat(align, "; font-size: 1em; font-weight:700; color: #444;");
var contentDiv = document.createElement('div');
contentDiv.style = "width: 100%; text-align: ".concat(align, ";");
- contentDiv.textContent = message;
+ contentDiv.innerHTML = message;
messageDiv.appendChild(userDiv);
messageDiv.appendChild(contentDiv);
this.messagesArea.appendChild(messageDiv);
diff --git a/dist/quikchat.esm.js.map b/dist/quikchat.esm.js.map
index 16a2b9b..ab624d0 100644
--- a/dist/quikchat.esm.js.map
+++ b/dist/quikchat.esm.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.esm.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.textContent = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.textContent = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","adjustMessagesAreaHeight","textContent","textAlign","titleAreaGet","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","fontSize","parseFloat","getComputedStyle","minWidth","addMessage","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","removeMesssage","n","removeChild","getMessage","appendMessage","updateMessage","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,IAEMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;IAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;AAAEG,MAAAA,KAAK,EAAE,sBAAsB;AAAEC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAE;KAAG,CAAA;AAAAC,IAAAA,eAAA,OAAAR,QAAA,CAAA,CAAA;IAClF,IAAI,CAACC,aAAa,GAAGA,aAAa,CAAA;AAClC,IAAA,IAAI,CAACK,KAAK,GAAGJ,IAAI,CAACI,KAAK,CAAA;AACvB,IAAA,IAAI,CAACC,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAG,YAAM,EAAG,CAAA;IACnD,IAAI,CAACE,YAAY,EAAE,CAAA;AACnB;IACA,IAAIP,IAAI,CAACQ,SAAS,EAAE;AAChB,MAAA,IAAI,CAACC,YAAY,CAACT,IAAI,CAACQ,SAAS,CAACE,KAAK,EAAEV,IAAI,CAACQ,SAAS,CAACG,KAAK,CAAC,CAAA;AAC7D,MAAA,IAAIX,IAAI,CAACQ,SAAS,CAACI,IAAI,EAAE;QACrB,IAAI,CAACC,aAAa,EAAE,CAAA;AACxB,OAAC,MAAM;QACH,IAAI,CAACC,aAAa,EAAE,CAAA;AACxB,OAAA;AACJ,KAAA;IACA,IAAI,CAACC,oBAAoB,EAAE,CAAA;AAC/B,GAAA;EAAC,OAAAC,YAAA,CAAAlB,QAAA,EAAA,CAAA;IAAAmB,GAAA,EAAA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AA;IAAArD,GAAA,EAAA,eAAA;AAAAC,IAAAA,KAAA,EAED,SAAAoE,aAAAA,CAAcJ,CAAC,EAAEZ,OAAO,EAAE;AACtB,MAAA,IAAI,CAAC9C,YAAY,CAAC2B,QAAQ,CAAC+B,CAAC,CAAC,CAACH,SAAS,CAACtC,WAAW,GAAG6B,OAAO,CAAA;AACjE,KAAA;AAAC,GAAA,EAAA;IAAArD,GAAA,EAAA,aAAA;AAAAC,IAAAA,KAAA,EAED,SAAAqE,WAAYC,CAAAA,QAAQ,EAAE;MAClB,IAAI,CAAClE,UAAU,CAACuB,SAAS,CAAC4C,MAAM,CAAC,IAAI,CAACrF,KAAK,CAAC,CAAA;MAC5C,IAAI,CAACkB,UAAU,CAACuB,SAAS,CAAC8B,GAAG,CAACa,QAAQ,CAAC,CAAA;MACvC,IAAI,CAACpF,KAAK,GAAGoF,QAAQ,CAAA;AACzB,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
+{"version":3,"file":"quikchat.esm.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","adjustMessagesAreaHeight","textContent","textAlign","titleAreaGet","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","fontSize","parseFloat","getComputedStyle","minWidth","addMessage","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","removeMesssage","n","removeChild","getMessage","appendMessage","updateMessage","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,IAEMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;IAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;AAAEG,MAAAA,KAAK,EAAE,sBAAsB;AAAEC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAE;KAAG,CAAA;AAAAC,IAAAA,eAAA,OAAAR,QAAA,CAAA,CAAA;IAClF,IAAI,CAACC,aAAa,GAAGA,aAAa,CAAA;AAClC,IAAA,IAAI,CAACK,KAAK,GAAGJ,IAAI,CAACI,KAAK,CAAA;AACvB,IAAA,IAAI,CAACC,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAG,YAAM,EAAG,CAAA;IACnD,IAAI,CAACE,YAAY,EAAE,CAAA;AACnB;IACA,IAAIP,IAAI,CAACQ,SAAS,EAAE;AAChB,MAAA,IAAI,CAACC,YAAY,CAACT,IAAI,CAACQ,SAAS,CAACE,KAAK,EAAEV,IAAI,CAACQ,SAAS,CAACG,KAAK,CAAC,CAAA;AAC7D,MAAA,IAAIX,IAAI,CAACQ,SAAS,CAACI,IAAI,EAAE;QACrB,IAAI,CAACC,aAAa,EAAE,CAAA;AACxB,OAAC,MAAM;QACH,IAAI,CAACC,aAAa,EAAE,CAAA;AACxB,OAAA;AACJ,KAAA;IACA,IAAI,CAACC,oBAAoB,EAAE,CAAA;AAC/B,GAAA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AAS,CAACtC,WAAW,IAAI6B,OAAO,CAAA;AAClE,KAAA;AAAC,GAAA,EAAA;IAAArD,GAAA,EAAA,eAAA;AAAAC,IAAAA,KAAA,EAED,SAAAoE,aAAAA,CAAcJ,CAAC,EAAEZ,OAAO,EAAE;AACtB,MAAA,IAAI,CAAC9C,YAAY,CAAC2B,QAAQ,CAAC+B,CAAC,CAAC,CAACH,SAAS,CAACtC,WAAW,GAAG6B,OAAO,CAAA;AACjE,KAAA;AAAC,GAAA,EAAA;IAAArD,GAAA,EAAA,aAAA;AAAAC,IAAAA,KAAA,EAED,SAAAqE,WAAYC,CAAAA,QAAQ,EAAE;MAClB,IAAI,CAAClE,UAAU,CAACuB,SAAS,CAAC4C,MAAM,CAAC,IAAI,CAACrF,KAAK,CAAC,CAAA;MAC5C,IAAI,CAACkB,UAAU,CAACuB,SAAS,CAAC8B,GAAG,CAACa,QAAQ,CAAC,CAAA;MACvC,IAAI,CAACpF,KAAK,GAAGoF,QAAQ,CAAA;AACzB,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
\ No newline at end of file
diff --git a/dist/quikchat.esm.min.js b/dist/quikchat.esm.min.js
index be6fd2d..f806bf6 100644
--- a/dist/quikchat.esm.min.js
+++ b/dist/quikchat.esm.min.js
@@ -1,2 +1,2 @@
-function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=t,this.theme=i.theme,this.onSend=i.onSend?i.onSend:function(){},this.createWidget(),i.titleArea&&(this.titleAreaSet(i.titleArea.title,i.titleArea.align),i.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this.attachEventListeners()}),[{key:"createWidget",value:function(){var e='\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n ');this.parentElement.innerHTML=e,this.chatWidget=this.parentElement.querySelector(".quikchat-base"),this.titleArea=this.chatWidget.querySelector(".quikchat-title-area"),this.messagesArea=this.chatWidget.querySelector(".quikchat-messages-area"),this.inputArea=this.chatWidget.querySelector(".quikchat-input-area"),this.textEntry=this.inputArea.querySelector(".quikchat-input-textbox"),this.sendButton=this.inputArea.querySelector(".quikchat-input-send-btn")}},{key:"attachEventListeners",value:function(){var e=this;this.sendButton.addEventListener("click",(function(){return e.onSend(e,e.textEntry.value.trim())})),window.addEventListener("resize",(function(){return e.handleContainerResize()})),this.chatWidget.addEventListener("resize",(function(){return e.handleContainerResize()})),this.textEntry.addEventListener("keydown",(function(t){t.shiftKey&&13===t.keyCode&&(t.preventDefault(),e.onSend(e,e.textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this.titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this.titleArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this.titleArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"titleAreaSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this.titleArea.textContent=e,this.titleArea.style.textAlign=t}},{key:"titleAreaGet",value:function(){return this.titleArea.textContent}},{key:"inputAreaToggle",value:function(){this.inputArea.classList.toggle("hidden"),"none"===this.inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this.inputArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this.inputArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"adjustMessagesAreaHeight",value:function(){var e=i(this.chatWidget.children).filter((function(e){return e.classList.contains("hidden")})).reduce((function(e,t){return e+t.offsetHeight}),0),t=this.chatWidget.offsetHeight;this.messagesArea.style.height="calc(100% - ".concat(t-e,"px)")}},{key:"handleContainerResize",value:function(){this.adjustMessagesAreaHeight(),this.adjustSendButtonWidth(),console.log("Container resized")}},{key:"adjustSendButtonWidth",value:function(){var e=this.sendButton.textContent.trim(),t=parseFloat(getComputedStyle(this.sendButton).fontSize)*e.length+16;this.sendButton.style.minWidth="".concat(t,"px")}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",n=document.createElement("div");n.classList.add("quikchat-message"),n.classList.add(this.messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var a=document.createElement("div");a.textContent=t,a.style="width: 100%; text-align: ".concat(i,"; font-size: 1em; font-weight:700; color: #444;");var s=document.createElement("div");s.style="width: 100%; text-align: ".concat(i,";"),s.textContent=e,n.appendChild(a),n.appendChild(s),this.messagesArea.appendChild(n),this.messagesArea.lastChild.scrollIntoView(),this.textEntry.value="",this.adjustMessagesAreaHeight()}},{key:"removeMesssage",value:function(e){this.messagesArea.removeChild(this.messagesArea.children[e])}},{key:"getMessage",value:function(e){return this.messagesArea.children[e].lastChild.textContent}},{key:"appendMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent+=t}},{key:"updateMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent=t}},{key:"changeTheme",value:function(e){this.chatWidget.classList.remove(this.theme),this.chatWidget.classList.add(e),this.theme=e}}])}();export{a as default};
+function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=t,this.theme=i.theme,this.onSend=i.onSend?i.onSend:function(){},this.createWidget(),i.titleArea&&(this.titleAreaSet(i.titleArea.title,i.titleArea.align),i.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this.attachEventListeners()}),[{key:"createWidget",value:function(){var e='\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n ');this.parentElement.innerHTML=e,this.chatWidget=this.parentElement.querySelector(".quikchat-base"),this.titleArea=this.chatWidget.querySelector(".quikchat-title-area"),this.messagesArea=this.chatWidget.querySelector(".quikchat-messages-area"),this.inputArea=this.chatWidget.querySelector(".quikchat-input-area"),this.textEntry=this.inputArea.querySelector(".quikchat-input-textbox"),this.sendButton=this.inputArea.querySelector(".quikchat-input-send-btn")}},{key:"attachEventListeners",value:function(){var e=this;this.sendButton.addEventListener("click",(function(){return e.onSend(e,e.textEntry.value.trim())})),window.addEventListener("resize",(function(){return e.handleContainerResize()})),this.chatWidget.addEventListener("resize",(function(){return e.handleContainerResize()})),this.textEntry.addEventListener("keydown",(function(t){t.shiftKey&&13===t.keyCode&&(t.preventDefault(),e.onSend(e,e.textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this.titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this.titleArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this.titleArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"titleAreaSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this.titleArea.textContent=e,this.titleArea.style.textAlign=t}},{key:"titleAreaGet",value:function(){return this.titleArea.textContent}},{key:"inputAreaToggle",value:function(){this.inputArea.classList.toggle("hidden"),"none"===this.inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this.inputArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this.inputArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"adjustMessagesAreaHeight",value:function(){var e=i(this.chatWidget.children).filter((function(e){return e.classList.contains("hidden")})).reduce((function(e,t){return e+t.offsetHeight}),0),t=this.chatWidget.offsetHeight;this.messagesArea.style.height="calc(100% - ".concat(t-e,"px)")}},{key:"handleContainerResize",value:function(){this.adjustMessagesAreaHeight(),this.adjustSendButtonWidth(),console.log("Container resized")}},{key:"adjustSendButtonWidth",value:function(){var e=this.sendButton.textContent.trim(),t=parseFloat(getComputedStyle(this.sendButton).fontSize)*e.length+16;this.sendButton.style.minWidth="".concat(t,"px")}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",n=document.createElement("div");n.classList.add("quikchat-message"),n.classList.add(this.messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var a=document.createElement("div");a.innerHTML=t,a.style="width: 100%; text-align: ".concat(i,"; font-size: 1em; font-weight:700; color: #444;");var s=document.createElement("div");s.style="width: 100%; text-align: ".concat(i,";"),s.innerHTML=e,n.appendChild(a),n.appendChild(s),this.messagesArea.appendChild(n),this.messagesArea.lastChild.scrollIntoView(),this.textEntry.value="",this.adjustMessagesAreaHeight()}},{key:"removeMesssage",value:function(e){this.messagesArea.removeChild(this.messagesArea.children[e])}},{key:"getMessage",value:function(e){return this.messagesArea.children[e].lastChild.textContent}},{key:"appendMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent+=t}},{key:"updateMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent=t}},{key:"changeTheme",value:function(e){this.chatWidget.classList.remove(this.theme),this.chatWidget.classList.add(e),this.theme=e}}])}();export{a as default};
//# sourceMappingURL=quikchat.esm.min.js.map
diff --git a/dist/quikchat.esm.min.js.map b/dist/quikchat.esm.min.js.map
index 83678bb..26c7f02 100644
--- a/dist/quikchat.esm.min.js.map
+++ b/dist/quikchat.esm.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.esm.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.textContent = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.textContent = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","adjustMessagesAreaHeight","textContent","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","removeChild","newTheme","remove"],"mappings":"ywCAAA,IAEMA,EAAQ,WAgBT,OAAAC,GAfD,SAAAD,EAAYE,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAT,GAClFU,KAAKR,cAAgBA,EACrBQ,KAAKH,MAAQJ,EAAKI,MAClBG,KAAKF,OAASL,EAAKK,OAASL,EAAKK,OAAS,aAC1CE,KAAKC,eAEDR,EAAKS,YACLF,KAAKG,aAAaV,EAAKS,UAAUE,MAAOX,EAAKS,UAAUG,OACnDZ,EAAKS,UAAUI,KACfN,KAAKO,gBAELP,KAAKQ,iBAGbR,KAAKS,sBACT,GAAC,CAAA,CAAAC,IAAA,eAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBb,KAAKH,MAUhC,weAELG,KAAKR,cAAcsB,UAAYF,EAC/BZ,KAAKe,WAAaf,KAAKR,cAAcwB,cAAc,kBACnDhB,KAAKE,UAAYF,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKiB,aAAejB,KAAKe,WAAWC,cAAc,2BAClDhB,KAAKkB,UAAYlB,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKmB,UAAYnB,KAAKkB,UAAUF,cAAc,2BAC9ChB,KAAKoB,WAAapB,KAAKkB,UAAUF,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R,EAAQ,KACvD4D,EAAWhC,YAAcyB,EAEzBE,EAAWM,YAAYF,GACvBJ,EAAWM,YAAYD,GACvBjE,KAAKiB,aAAaiD,YAAYN,GAC9B5D,KAAKiB,aAAakD,UAAUC,iBAE5BpE,KAAKmB,UAAUR,MAAQ,GACvBX,KAAKgC,0BACT,GAAC,CAAAtB,IAAA,iBAAAC,MAED,SAAe0D,GACXrE,KAAKiB,aAAaqD,YAAYtE,KAAKiB,aAAawB,SAAS4B,GAC7D,GAAC,CAAA3D,IAAA,aAAAC,MAED,SAAW0D,GACP,OAAOrE,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,WACnD,GAAC,CAAAvB,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,aAAeyB,CAC3D,GAAC,CAAAhD,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,YAAcyB,CAC1D,GAAC,CAAAhD,IAAA,cAAAC,MAED,SAAY4D,GACRvE,KAAKe,WAAWoB,UAAUqC,OAAOxE,KAAKH,OACtCG,KAAKe,WAAWoB,UAAU4B,IAAIQ,GAC9BvE,KAAKH,MAAQ0E,CACjB,IAAC,CA5JS"}
\ No newline at end of file
+{"version":3,"file":"quikchat.esm.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","adjustMessagesAreaHeight","textContent","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","removeChild","newTheme","remove"],"mappings":"ywCAAA,IAEMA,EAAQ,WAgBT,OAAAC,GAfD,SAAAD,EAAYE,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAT,GAClFU,KAAKR,cAAgBA,EACrBQ,KAAKH,MAAQJ,EAAKI,MAClBG,KAAKF,OAASL,EAAKK,OAASL,EAAKK,OAAS,aAC1CE,KAAKC,eAEDR,EAAKS,YACLF,KAAKG,aAAaV,EAAKS,UAAUE,MAAOX,EAAKS,UAAUG,OACnDZ,EAAKS,UAAUI,KACfN,KAAKO,gBAELP,KAAKQ,iBAGbR,KAAKS,sBACT,GAAC,CAAA,CAAAC,IAAA,eAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBb,KAAKH,MAUhC,weAELG,KAAKR,cAAcsB,UAAYF,EAC/BZ,KAAKe,WAAaf,KAAKR,cAAcwB,cAAc,kBACnDhB,KAAKE,UAAYF,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKiB,aAAejB,KAAKe,WAAWC,cAAc,2BAClDhB,KAAKkB,UAAYlB,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKmB,UAAYnB,KAAKkB,UAAUF,cAAc,2BAC9ChB,KAAKoB,WAAapB,KAAKkB,UAAUF,cAAc,2BACnD,GAAC,CAAAN,IAAA,uBAAAC,MAED,WAAuB,IAAAU,EAAArB,KACnBA,KAAKoB,WAAWE,iBAAiB,SAAS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,YAAYN,GAC9B5D,KAAKiB,aAAakD,UAAUC,iBAE5BpE,KAAKmB,UAAUR,MAAQ,GACvBX,KAAKgC,0BACT,GAAC,CAAAtB,IAAA,iBAAAC,MAED,SAAe0D,GACXrE,KAAKiB,aAAaqD,YAAYtE,KAAKiB,aAAawB,SAAS4B,GAC7D,GAAC,CAAA3D,IAAA,aAAAC,MAED,SAAW0D,GACP,OAAOrE,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,WACnD,GAAC,CAAAvB,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,aAAeyB,CAC3D,GAAC,CAAAhD,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,YAAcyB,CAC1D,GAAC,CAAAhD,IAAA,cAAAC,MAED,SAAY4D,GACRvE,KAAKe,WAAWoB,UAAUqC,OAAOxE,KAAKH,OACtCG,KAAKe,WAAWoB,UAAU4B,IAAIQ,GAC9BvE,KAAKH,MAAQ0E,CACjB,IAAC,CA5JS"}
\ No newline at end of file
diff --git a/dist/quikchat.umd.js b/dist/quikchat.umd.js
index ce4e42f..6e222bb 100644
--- a/dist/quikchat.umd.js
+++ b/dist/quikchat.umd.js
@@ -197,11 +197,11 @@
messageDiv.classList.add('quikchat-message');
messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');
var userDiv = document.createElement('div');
- userDiv.textContent = user;
+ userDiv.innerHTML = user;
userDiv.style = "width: 100%; text-align: ".concat(align, "; font-size: 1em; font-weight:700; color: #444;");
var contentDiv = document.createElement('div');
contentDiv.style = "width: 100%; text-align: ".concat(align, ";");
- contentDiv.textContent = message;
+ contentDiv.innerHTML = message;
messageDiv.appendChild(userDiv);
messageDiv.appendChild(contentDiv);
this.messagesArea.appendChild(messageDiv);
diff --git a/dist/quikchat.umd.js.map b/dist/quikchat.umd.js.map
index 9eb4c9b..57e9d1b 100644
--- a/dist/quikchat.umd.js.map
+++ b/dist/quikchat.umd.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.umd.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.textContent = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.textContent = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","adjustMessagesAreaHeight","textContent","textAlign","titleAreaGet","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","fontSize","parseFloat","getComputedStyle","minWidth","addMessage","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","removeMesssage","n","removeChild","getMessage","appendMessage","updateMessage","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;AAAA,MAEMA,QAAQ,gBAAA,YAAA;IACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;MAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;EAAEG,MAAAA,KAAK,EAAE,sBAAsB;EAAEC,MAAAA,MAAM,EAAE,SAAAA,M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S,CAAC8B,GAAG,CAACa,QAAQ,CAAC,CAAA;QACvC,IAAI,CAACpF,KAAK,GAAGoF,QAAQ,CAAA;EACzB,KAAA;EAAC,GAAA,CAAA,CAAA,CAAA;EAAA,CAAA;;;;;;;;"}
\ No newline at end of file
+{"version":3,"file":"quikchat.umd.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","titleAreaToggle","style","display","adjustMessagesAreaHeight","textContent","textAlign","titleAreaGet","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","fontSize","parseFloat","getComputedStyle","minWidth","addMessage","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","removeMesssage","n","removeChild","getMessage","appendMessage","updateMessage","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAAA;AAAA,MAEMA,QAAQ,gBAAA,YAAA;IACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;MAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAA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M,CAAC,IAAI,CAACrF,KAAK,CAAC,CAAA;QAC5C,IAAI,CAACkB,UAAU,CAACuB,SAAS,CAAC8B,GAAG,CAACa,QAAQ,CAAC,CAAA;QACvC,IAAI,CAACpF,KAAK,GAAGoF,QAAQ,CAAA;EACzB,KAAA;EAAC,GAAA,CAAA,CAAA,CAAA;EAAA,CAAA;;;;;;;;"}
\ No newline at end of file
diff --git a/dist/quikchat.umd.min.js b/dist/quikchat.umd.min.js
index 09c0a1a..ca03058 100644
--- a/dist/quikchat.umd.min.js
+++ b/dist/quikchat.umd.min.js
@@ -1,2 +1,2 @@
-!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikchat=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=t,this.theme=i.theme,this.onSend=i.onSend?i.onSend:function(){},this.createWidget(),i.titleArea&&(this.titleAreaSet(i.titleArea.title,i.titleArea.align),i.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this.attachEventListeners()}),[{key:"createWidget",value:function(){var e='\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n ');this.parentElement.innerHTML=e,this.chatWidget=this.parentElement.querySelector(".quikchat-base"),this.titleArea=this.chatWidget.querySelector(".quikchat-title-area"),this.messagesArea=this.chatWidget.querySelector(".quikchat-messages-area"),this.inputArea=this.chatWidget.querySelector(".quikchat-input-area"),this.textEntry=this.inputArea.querySelector(".quikchat-input-textbox"),this.sendButton=this.inputArea.querySelector(".quikchat-input-send-btn")}},{key:"attachEventListeners",value:function(){var e=this;this.sendButton.addEventListener("click",(function(){return e.onSend(e,e.textEntry.value.trim())})),window.addEventListener("resize",(function(){return e.handleContainerResize()})),this.chatWidget.addEventListener("resize",(function(){return e.handleContainerResize()})),this.textEntry.addEventListener("keydown",(function(t){t.shiftKey&&13===t.keyCode&&(t.preventDefault(),e.onSend(e,e.textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this.titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this.titleArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this.titleArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"titleAreaSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this.titleArea.textContent=e,this.titleArea.style.textAlign=t}},{key:"titleAreaGet",value:function(){return this.titleArea.textContent}},{key:"inputAreaToggle",value:function(){this.inputArea.classList.toggle("hidden"),"none"===this.inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this.inputArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this.inputArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"adjustMessagesAreaHeight",value:function(){var e=i(this.chatWidget.children).filter((function(e){return e.classList.contains("hidden")})).reduce((function(e,t){return e+t.offsetHeight}),0),t=this.chatWidget.offsetHeight;this.messagesArea.style.height="calc(100% - ".concat(t-e,"px)")}},{key:"handleContainerResize",value:function(){this.adjustMessagesAreaHeight(),this.adjustSendButtonWidth(),console.log("Container resized")}},{key:"adjustSendButtonWidth",value:function(){var e=this.sendButton.textContent.trim(),t=parseFloat(getComputedStyle(this.sendButton).fontSize)*e.length+16;this.sendButton.style.minWidth="".concat(t,"px")}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",n=document.createElement("div");n.classList.add("quikchat-message"),n.classList.add(this.messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var a=document.createElement("div");a.textContent=t,a.style="width: 100%; text-align: ".concat(i,"; font-size: 1em; font-weight:700; color: #444;");var s=document.createElement("div");s.style="width: 100%; text-align: ".concat(i,";"),s.textContent=e,n.appendChild(a),n.appendChild(s),this.messagesArea.appendChild(n),this.messagesArea.lastChild.scrollIntoView(),this.textEntry.value="",this.adjustMessagesAreaHeight()}},{key:"removeMesssage",value:function(e){this.messagesArea.removeChild(this.messagesArea.children[e])}},{key:"getMessage",value:function(e){return this.messagesArea.children[e].lastChild.textContent}},{key:"appendMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent+=t}},{key:"updateMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent=t}},{key:"changeTheme",value:function(e){this.chatWidget.classList.remove(this.theme),this.chatWidget.classList.add(e),this.theme=e}}])}();return a}));
+!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).quikchat=t()}(this,(function(){"use strict";function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.parentElement=t,this.theme=i.theme,this.onSend=i.onSend?i.onSend:function(){},this.createWidget(),i.titleArea&&(this.titleAreaSet(i.titleArea.title,i.titleArea.align),i.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this.attachEventListeners()}),[{key:"createWidget",value:function(){var e='\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n ');this.parentElement.innerHTML=e,this.chatWidget=this.parentElement.querySelector(".quikchat-base"),this.titleArea=this.chatWidget.querySelector(".quikchat-title-area"),this.messagesArea=this.chatWidget.querySelector(".quikchat-messages-area"),this.inputArea=this.chatWidget.querySelector(".quikchat-input-area"),this.textEntry=this.inputArea.querySelector(".quikchat-input-textbox"),this.sendButton=this.inputArea.querySelector(".quikchat-input-send-btn")}},{key:"attachEventListeners",value:function(){var e=this;this.sendButton.addEventListener("click",(function(){return e.onSend(e,e.textEntry.value.trim())})),window.addEventListener("resize",(function(){return e.handleContainerResize()})),this.chatWidget.addEventListener("resize",(function(){return e.handleContainerResize()})),this.textEntry.addEventListener("keydown",(function(t){t.shiftKey&&13===t.keyCode&&(t.preventDefault(),e.onSend(e,e.textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this.titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this.titleArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this.titleArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"titleAreaSet",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this.titleArea.textContent=e,this.titleArea.style.textAlign=t}},{key:"titleAreaGet",value:function(){return this.titleArea.textContent}},{key:"inputAreaToggle",value:function(){this.inputArea.classList.toggle("hidden"),"none"===this.inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this.inputArea.style.display="",this.adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this.inputArea.style.display="none",this.adjustMessagesAreaHeight()}},{key:"adjustMessagesAreaHeight",value:function(){var e=i(this.chatWidget.children).filter((function(e){return e.classList.contains("hidden")})).reduce((function(e,t){return e+t.offsetHeight}),0),t=this.chatWidget.offsetHeight;this.messagesArea.style.height="calc(100% - ".concat(t-e,"px)")}},{key:"handleContainerResize",value:function(){this.adjustMessagesAreaHeight(),this.adjustSendButtonWidth(),console.log("Container resized")}},{key:"adjustSendButtonWidth",value:function(){var e=this.sendButton.textContent.trim(),t=parseFloat(getComputedStyle(this.sendButton).fontSize)*e.length+16;this.sendButton.style.minWidth="".concat(t,"px")}},{key:"addMessage",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",n=document.createElement("div");n.classList.add("quikchat-message"),n.classList.add(this.messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var a=document.createElement("div");a.innerHTML=t,a.style="width: 100%; text-align: ".concat(i,"; font-size: 1em; font-weight:700; color: #444;");var s=document.createElement("div");s.style="width: 100%; text-align: ".concat(i,";"),s.innerHTML=e,n.appendChild(a),n.appendChild(s),this.messagesArea.appendChild(n),this.messagesArea.lastChild.scrollIntoView(),this.textEntry.value="",this.adjustMessagesAreaHeight()}},{key:"removeMesssage",value:function(e){this.messagesArea.removeChild(this.messagesArea.children[e])}},{key:"getMessage",value:function(e){return this.messagesArea.children[e].lastChild.textContent}},{key:"appendMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent+=t}},{key:"updateMessage",value:function(e,t){this.messagesArea.children[e].lastChild.textContent=t}},{key:"changeTheme",value:function(e){this.chatWidget.classList.remove(this.theme),this.chatWidget.classList.add(e),this.theme=e}}])}();return a}));
//# sourceMappingURL=quikchat.umd.min.js.map
diff --git a/dist/quikchat.umd.min.js.map b/dist/quikchat.umd.min.js.map
index a646030..05b5466 100644
--- a/dist/quikchat.umd.min.js.map
+++ b/dist/quikchat.umd.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"quikchat.umd.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.textContent = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.textContent = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","adjustMessagesAreaHeight","textContent","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","removeChild","newTheme","remove"],"mappings":"k/CAEMA,IAAAA,EAAQ,WAgBT,OAAAC,GAfD,SAAAD,EAAYE,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAT,GAClFU,KAAKR,cAAgBA,EACrBQ,KAAKH,MAAQJ,EAAKI,MAClBG,KAAKF,OAASL,EAAKK,OAASL,EAAKK,OAAS,aAC1CE,KAAKC,eAEDR,EAAKS,YACLF,KAAKG,aAAaV,EAAKS,UAAUE,MAAOX,EAAKS,UAAUG,OACnDZ,EAAKS,UAAUI,KACfN,KAAKO,gBAELP,KAAKQ,iBAGbR,KAAKS,sBACT,GAAC,CAAA,CAAAC,IAAA,eAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBb,KAAKH,MAUhC,weAELG,KAAKR,cAAcsB,UAAYF,EAC/BZ,KAAKe,WAAaf,KAAKR,cAAcwB,cAAc,kBACnDhB,KAAKE,UAAYF,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKiB,aAAejB,KAAKe,WAAWC,cAAc,2BAClDhB,KAAKkB,UAAYlB,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKmB,UAAYnB,KAAKkB,UAAUF,cAAc,2BAC9ChB,KAAKoB,WAAapB,KAAKkB,UAAUF,cAAc,2BACnD,GAAC,CAAAN,IAAA,uBAAAC,MAED,WAAuB,IAAAU,EAAArB,KACnBA,KAAKoB,WAAWE,iBAAiB,SAAS,WAAA,OAAMD,EAAKvB,OAAOuB,EAAMA,EAAKF,UAAUR,MAAMY,WACvFC,OAAOF,iBAAiB,UAAU,WAAA,OAAMD,EA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AAAtB,IAAA,iBAAAC,MAED,SAAe0D,GACXrE,KAAKiB,aAAaqD,YAAYtE,KAAKiB,aAAawB,SAAS4B,GAC7D,GAAC,CAAA3D,IAAA,aAAAC,MAED,SAAW0D,GACP,OAAOrE,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,WACnD,GAAC,CAAAvB,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,aAAeyB,CAC3D,GAAC,CAAAhD,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,YAAcyB,CAC1D,GAAC,CAAAhD,IAAA,cAAAC,MAED,SAAY4D,GACRvE,KAAKe,WAAWoB,UAAUqC,OAAOxE,KAAKH,OACtCG,KAAKe,WAAWoB,UAAU4B,IAAIQ,GAC9BvE,KAAKH,MAAQ0E,CACjB,IAAC,CA5JS"}
\ No newline at end of file
+{"version":3,"file":"quikchat.umd.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this.parentElement = parentElement;\n this.theme = meta.theme;\n this.onSend = meta.onSend ? meta.onSend : () => { };\n this.createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSet(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this.attachEventListeners();\n }\n\n createWidget() {\n const widgetHTML =\n `\n \n
\n Title Area \n
\n
\n
\n \n Send \n
\n
\n `;\n\n this.parentElement.innerHTML = widgetHTML;\n this.chatWidget = this.parentElement.querySelector('.quikchat-base');\n this.titleArea = this.chatWidget.querySelector('.quikchat-title-area');\n this.messagesArea = this.chatWidget.querySelector('.quikchat-messages-area');\n this.inputArea = this.chatWidget.querySelector('.quikchat-input-area');\n this.textEntry = this.inputArea.querySelector('.quikchat-input-textbox');\n this.sendButton = this.inputArea.querySelector('.quikchat-input-send-btn');\n }\n\n attachEventListeners() {\n this.sendButton.addEventListener('click', () => this.onSend(this, this.textEntry.value.trim()));\n window.addEventListener('resize', () => this.handleContainerResize());\n this.chatWidget.addEventListener('resize', () => this.handleContainerResize());\n this.textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this.onSend(this, this.textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this.titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this.titleArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this.titleArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n titleAreaSet(title, align = 'center') {\n this.titleArea.textContent = title;\n this.titleArea.style.textAlign = align;\n }\n\n titleAreaGet() {\n return this.titleArea.textContent;\n }\n\n inputAreaToggle() {\n this.inputArea.classList.toggle('hidden');\n this.inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();\n }\n\n inputAreaShow() {\n this.inputArea.style.display = '';\n this.adjustMessagesAreaHeight();\n }\n\n inputAreaHide() {\n this.inputArea.style.display = 'none';\n this.adjustMessagesAreaHeight();\n }\n\n adjustMessagesAreaHeight() {\n const hiddenElements = [...this.chatWidget.children].filter(child => child.classList.contains('hidden'));\n const totalHiddenHeight = hiddenElements.reduce((sum, child) => sum + child.offsetHeight, 0);\n const containerHeight = this.chatWidget.offsetHeight;\n this.messagesArea.style.height = `calc(100% - ${containerHeight - totalHiddenHeight}px)`;\n }\n\n handleContainerResize() {\n this.adjustMessagesAreaHeight();\n this.adjustSendButtonWidth();\n console.log('Container resized');\n }\n\n adjustSendButtonWidth() {\n const sendButtonText = this.sendButton.textContent.trim();\n const fontSize = parseFloat(getComputedStyle(this.sendButton).fontSize);\n const minWidth = fontSize * sendButtonText.length + 16;\n this.sendButton.style.minWidth = `${minWidth}px`;\n }\n\n addMessage(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n messageDiv.classList.add('quikchat-message');\n messageDiv.classList.add(this.messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this.messagesArea.appendChild(messageDiv);\n this.messagesArea.lastChild.scrollIntoView();\n\n this.textEntry.value = '';\n this.adjustMessagesAreaHeight();\n }\n\n removeMesssage(n) {\n this.messagesArea.removeChild(this.messagesArea.children[n]);\n }\n\n getMessage(n) {\n return this.messagesArea.children[n].lastChild.textContent;\n }\n\n appendMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent += message;\n }\n\n updateMessage(n, message) {\n this.messagesArea.children[n].lastChild.textContent = message;\n }\n\n changeTheme(newTheme) {\n this.chatWidget.classList.remove(this.theme);\n this.chatWidget.classList.add(newTheme);\n this.theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","createWidget","titleArea","titleAreaSet","title","align","show","titleAreaShow","titleAreaHide","attachEventListeners","key","value","widgetHTML","concat","innerHTML","chatWidget","querySelector","messagesArea","inputArea","textEntry","sendButton","_this","addEventListener","trim","window","handleContainerResize","event","shiftKey","keyCode","preventDefault","style","display","adjustMessagesAreaHeight","textContent","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","adjustSendButtonWidth","console","log","sendButtonText","minWidth","parseFloat","getComputedStyle","fontSize","message","user","messageDiv","document","createElement","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","removeChild","newTheme","remove"],"mappings":"k/CAEMA,IAAAA,EAAQ,WAgBT,OAAAC,GAfD,SAAAD,EAAYE,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAT,GAClFU,KAAKR,cAAgBA,EACrBQ,KAAKH,MAAQJ,EAAKI,MAClBG,KAAKF,OAASL,EAAKK,OAASL,EAAKK,OAAS,aAC1CE,KAAKC,eAEDR,EAAKS,YACLF,KAAKG,aAAaV,EAAKS,UAAUE,MAAOX,EAAKS,UAAUG,OACnDZ,EAAKS,UAAUI,KACfN,KAAKO,gBAELP,KAAKQ,iBAGbR,KAAKS,sBACT,GAAC,CAAA,CAAAC,IAAA,eAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBb,KAAKH,MAUhC,weAELG,KAAKR,cAAcsB,UAAYF,EAC/BZ,KAAKe,WAAaf,KAAKR,cAAcwB,cAAc,kBACnDhB,KAAKE,UAAYF,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKiB,aAAejB,KAAKe,WAAWC,cAAc,2BAClDhB,KAAKkB,UAAYlB,KAAKe,WAAWC,cAAc,wBAC/ChB,KAAKmB,UAAYnB,KAAKkB,UAAUF,cAAc,2BAC9ChB,KAAKoB,WAAapB,KAAKkB,UAAUF,cAAc,2BACnD,GAAC,CAAAN,IAAA,uBAAAC,MAED,WAAuB,IAAAU,EAAArB,KACnBA,KAAKoB,WAAWE,iBAAiB,SAAS,WAAA,OAAMD,EAAKvB,OAAOuB,EAAMA,EAAKF,UAAUR,MAAMY,WACvFC,OAAOF,iBAAiB,UAAU,WAAA,OAAMD,EAAKI,2BAC7CzB,KAAKe,WAAWO,iBAAiB,UAAU,WAAA,OAAMD,EAAKI,2BACtDzB,KAAKmB,UAAUG,iBAAiB,WAA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,CAAA3D,IAAA,aAAAC,MAED,SAAW0D,GACP,OAAOrE,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,WACnD,GAAC,CAAAvB,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,aAAeyB,CAC3D,GAAC,CAAAhD,IAAA,gBAAAC,MAED,SAAc0D,EAAGX,GACb1D,KAAKiB,aAAawB,SAAS4B,GAAGF,UAAUlC,YAAcyB,CAC1D,GAAC,CAAAhD,IAAA,cAAAC,MAED,SAAY4D,GACRvE,KAAKe,WAAWoB,UAAUqC,OAAOxE,KAAKH,OACtCG,KAAKe,WAAWoB,UAAU4B,IAAIQ,GAC9BvE,KAAKH,MAAQ0E,CACjB,IAAC,CA5JS"}
\ No newline at end of file
diff --git a/example.html b/example.html
index 2519838..5c589d3 100644
--- a/example.html
+++ b/example.html
@@ -59,14 +59,18 @@ Component Styles and Resize Checks
theme: 'quikchat-theme-light',
titleArea: { title: 'QuikChatJS', align: 'left', show: true },
onSend: (chat, msg) => {
+
chat.addMessage(msg, 'me', 'right'); // echo the message to the chat area
+
// do something with the message
-
+ chat.addMessage(bw.loremIpsum(bw.random(0,50),bw.random(33,100)), 'bot', 'left');
}
});
chatBox.addMessage('Hello, how are you?', 'bot', 'left');
chatBox.addMessage('I am fine, thank you.', 'user', 'right');
chatBox.addMessage('How can I help you today?', 'bot', 'left');
+ chatBox.changeTheme("quikchat-theme-debug");
+
});