quikchat 1.0.4 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"quikchat.esm.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n /**\n * \n * @param string or DOM element parentElement \n * @param {*} meta \n */\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { }, \n trackHistory: true,\n titleArea: {title: \"Title Area\", show: false, align: \"center\"}\n }) \n {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\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.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show == true) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\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 this.msgid = 0;\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 // set the onSend function callback.\n setCallbackOnSend(callback) {\n this._onSend = callback;\n }\n // set a callback for everytime a message is added (listener)\n setCallbackonMessageAdded(callback) {\n this._onMessageAdded = callback;\n }\n\n // Public methods\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 titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\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 messageAddFull(input = {content: \"\", userString: \"user\", align : \"right\", role : \"user\", userID : -1}) {\n const msgid = this.msgid;\n const messageDiv = document.createElement('div');\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n const userIdClass = 'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\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 = input.userString;\n userDiv.style = `width: 100%; text-align: ${input.align}; font-size: 1em; font-weight:700;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${input.align};`;\n contentDiv.innerHTML = input.content;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n //this._messagesArea.lastChild.scrollIntoView();\n this._messagesArea.lastElementChild.scrollIntoView()\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n const timestamp = new Date().toISOString();\n const updatedtime = timestamp;\n if (this.trackHistory) {\n this._history.push({ msgid, ...input, timestamp, updatedtime, messageDiv});\n if (this._history.length > this._historyLimit) {\n this._history.shift();\n }\n }\n if (this._onMessageAdded) {\n this._onMessageAdded(this, msgid);\n };\n return msgid;\n }\n messageAddNew(content=\"\", userString=\"user\", align = \"right\", role = \"user\") {\n return this.messageAddFull( \n {content: content, userString: userString, align: align, role: role}\n );\n }\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n if (sucess) {\n // slow way to remove from history\n //this._history = this._history.filter((item) => item.msgid !== n); // todo make this more efficient\n\n // better way to delete this from history\n this._history.splice(this._history.findIndex((item) => item.msgid === n), 1);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n // get from history..\n content = this._history.filter((item) => item.msgid === n)[0].content;\n //content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content += content;\n item.updatedtime = new Date().toISOString();\n sucess = true;\n //this._messagesArea.lastChild.scrollIntoView();\n this._messagesArea.lastElementChild.scrollIntoView()\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n // update history\n this._history.filter((item) => item.msgid === n)[0].content = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n // history functions\n /**\n * \n * @param {*} n \n * @param {*} m \n * @returns array of history messages\n */\n historyGet(n,m) {\n\n if (n == undefined) {\n n = 0;\n m= this._history.length;\n }\n if (m === undefined) {\n m = n < 0 ? m: n + 1;\n }\n // remember that entries could be deleted. TODO: So we need to return the actual history entries\n // so now we need to find the array index that correspondes to messageIds n (start) and m (end)\n \n return this._history.slice(n,m);\n }\n\n historyClear() {\n this.msgid = 0;\n this._history = [];\n } \n\n historyGetLength() {\n return this._history.length;\n } \n\n historyGetMessage(n) {\n if ( n>=0 && n < this._history.length) {\n this._history[n];\n }\n return {};\n\n } \n\n historyGetMessageContent(n) {\n return this._history[n].message;\n }\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 get theme() {\n return this._theme;\n }\n\n static version() {\n return {\"version\" : \"1.0.4\", \"license\" : \"BSD-2\", \"url\" :\"https://github/deftio/quikchat\"};\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","titleArea","title","show","align","_classCallCheck","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleAreaSetContents","titleAreaShow","titleAreaHide","_attachEventListeners","_historyLimit","_history","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","callback","_onMessageAdded","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","input","content","userString","role","userID","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastElementChild","scrollIntoView","timestamp","Date","toISOString","updatedtime","push","_objectSpread","shift","messageAddFull","n","sucess","removeChild","error","console","log","splice","findIndex","item","msg","lastChild","m","slice","message","newTheme","remove","get","version","license","url"],"mappings":"02DACMA,EAAQ,WAkCT,SA5BD,SAAAA,EAAYC,GAOR,IANIC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CACHG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CACA,OAAOJ,CACX,GAEA,CAAA1E,IAAA,aAAAC,MAMA,SAAWwE,EAAEW,GAYT,OAVS1G,MAAL+F,IACAA,EAAI,EACJW,EAAG/F,KAAKU,SAAStB,aAEXC,IAAN0G,IACAA,EAAIX,EAAI,EAAIW,EAAGX,EAAI,GAKhBpF,KAAKU,SAASsF,MAAMZ,EAAEW,EACjC,GAAC,CAAApF,IAAA,eAAAC,MAED,WACIZ,KAAKsB,MAAQ,EACbtB,KAAKU,SAAW,EACpB,GAAC,CAAAC,IAAA,mBAAAC,MAED,WACI,OAAOZ,KAAKU,SAAStB,MACzB,GAAC,CAAAuB,IAAA,oBAAAC,MAED,SAAkBwE,GAId,OAHKA,GAAG,GAAKA,EAAIpF,KAAKU,SAAStB,QAC3BY,KAAKU,SAAS0E,GAEX,EAEX,GAAC,CAAAzE,IAAA,2BAAAC,MAED,SAAyBwE,GACrB,OAAOpF,KAAKU,SAAS0E,GAAGa,OAC5B,GAAC,CAAAtF,IAAA,cAAAC,MAGD,SAAYsF,GACRlG,KAAKgB,YAAYsB,UAAU6D,OAAOnG,KAAKE,QACvCF,KAAKgB,YAAYsB,UAAUgC,IAAI4B,GAC/BlG,KAAKE,OAASgG,CAClB,GAAC,CAAAvF,IAAA,QAAAyF,IAED,WACI,OAAOpG,KAAKE,MAChB,MAAC,CAAA,CAAAS,IAAA,UAAAC,MAED,WACI,MAAO,CAACyF,QAAY,QAASC,QAAY,QAASC,IAAO,iCAC7D,gGAAC,CAtUS"}
1
+ {"version":3,"file":"quikchat.esm.min.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n /**\n * \n * @param string or DOM element parentElement \n * @param {*} meta \n */\n constructor(parentElement, onSend = () => { }, options = {}) {\n const defaultOpts = {\n theme: 'quikchat-theme-light',\n trackHistory: true,\n titleArea: { title: \"Chat\", show: false, align: \"center\" },\n messagesArea: { alternating: true },\n };\n const meta = { ...defaultOpts, ...options }; // merge options with defaults\n\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n //console.log(parentElement, meta);\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = onSend ? onSend : () => { }; // call back function for onSend\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show === true) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n // messages area\n if (meta.messagesArea) {\n this.messagesAreaAlternateColors(meta.messagesArea.alternating);\n }\n // plumbing\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\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 this.msgid = 0;\n }\n\n /**\n * Attach event listeners to the widget\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 this._messagesArea.addEventListener('scroll', () => {\n const { scrollTop, scrollHeight, clientHeight } = this._messagesArea;\n this.userScrolledUp = scrollTop + clientHeight < scrollHeight;\n });\n }\n \n // set the onSend function callback.\n setCallbackOnSend(callback) {\n this._onSend = callback;\n }\n // set a callback for everytime a message is added (listener)\n setCallbackonMessageAdded(callback) {\n this._onMessageAdded = callback;\n }\n\n // Public methods\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 titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\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 //messagesArea functions\n messagesAreaAlternateColors(alt = true) {\n if (alt) {\n this._messagesArea.classList.add('quikchat-messages-area-alt');\n }\n else {\n this._messagesArea.classList.remove('quikchat-messages-area-alt');\n }\n return alt === true;\n }\n messagesAreaAlternateColorsToggle() {\n this._messagesArea.classList.toggle('quikchat-messages-area-alt');\n }\n messagesAreaAlternateColorsGet() {\n return this._messagesArea.classList.contains('quikchat-messages-area-alt');\n }\n // message functions\n messageAddFull(input = { content: \"\", userString: \"user\", align: \"right\", role: \"user\", userID: -1 }) {\n const msgid = this.msgid;\n const messageDiv = document.createElement('div');\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n const userIdClass = 'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\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 = input.userString;\n userDiv.style = `width: 100%; text-align: ${input.align}; font-size: 1em; font-weight:700;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${input.align};`;\n contentDiv.innerHTML = input.content;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n\n // Scroll to the last message only if the user is not actively scrolling up\n if (!this.userScrolledUp) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n const timestamp = new Date().toISOString();\n const updatedtime = timestamp;\n\n if (this.trackHistory) {\n this._history.push({ msgid, ...input, timestamp, updatedtime, messageDiv });\n if (this._history.length > this._historyLimit) {\n this._history.shift();\n }\n }\n\n if (this._onMessageAdded) {\n this._onMessageAdded(this, msgid);\n }\n\n return msgid;\n }\n\n \n messageAddNew(content = \"\", userString = \"user\", align = \"right\", role = \"user\") {\n return this.messageAddFull(\n { content: content, userString: userString, align: align, role: role }\n );\n }\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n if (sucess) {\n // slow way to remove from history\n //this._history = this._history.filter((item) => item.msgid !== n); // todo make this more efficient\n\n // better way to delete this from history\n this._history.splice(this._history.findIndex((item) => item.msgid === n), 1);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg;\n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n // get from history..\n content = this._history.filter((item) => item.msgid === n)[0].content;\n //content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content;\n }\n\n /* append message to the message content\n */\n\n messageAppendContent(n, content) {\n let success = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content += content;\n item.updatedtime = new Date().toISOString();\n success = true;\n\n // Scroll to the last message only if the user is not actively scrolling up\n if (!this.userScrolledUp) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n } catch (error) {\n console.log(`${String(n)} : Message ID not found`);\n }\n return success;\n }\n \n /* replace message content\n */\n messageReplaceContent(n, content) {\n let success = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content = content;\n item.updatedtime = new Date().toISOString();\n success = true;\n\n // Scroll to the last message only if the user is not actively scrolling up\n if (!this.userScrolledUp) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n } catch (error) {\n console.log(`${String(n)} : Message ID not found`);\n }\n return success;\n }\n \n // history functions\n /**\n * \n * @param {*} n \n * @param {*} m \n * @returns array of history messages\n */\n historyGet(n, m) {\n\n if (n == undefined) {\n n = 0;\n m = this._history.length;\n }\n if (m === undefined) {\n m = n < 0 ? m : n + 1;\n }\n // remember that entries could be deleted. TODO: So we need to return the actual history entries\n // so now we need to find the array index that correspondes to messageIds n (start) and m (end)\n\n return this._history.slice(n, m);\n }\n\n historyClear() {\n this.msgid = 0;\n this._history = [];\n }\n\n historyGetLength() {\n return this._history.length;\n }\n\n historyGetMessage(n) {\n if (n >= 0 && n < this._history.length) {\n this._history[n];\n }\n return {};\n\n }\n\n historyGetMessageContent(n) {\n return this._history[n].message;\n }\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 get theme() {\n return this._theme;\n }\n\n static version() {\n return { \"version\": \"1.1.2\", \"license\": \"BSD-2\", \"url\": \"https://github/deftio/quikchat\" };\n }\n\n /**\n * quikchat.loremIpsum() - Generate a simple string of Lorem Ipsum text (sample typographer's text) of numChars in length.\n * borrowed from github.com/deftio/bitwrench.js\n * @param {number} numChars - The number of characters to generate (random btw 25 and 150 if undefined). \n * @param {number} [startSpot=0] - The starting index in the Lorem Ipsum text. If undefined, a random startSpot will be generated.\n * @param {boolean} [startWithCapitalLetter=true] - If true, capitalize the first character or inject a capital letter if the first character isn't a capital letter.\n * \n * @returns {string} A string of Lorem Ipsum text.\n * \n * @example \n * // Returns 200 characters of Lorem Ipsum starting from index 50\n * loremIpsum(200, 50);\n * \n * @example \n * //Returns a 200 Lorem Ipsum characters starting from a random index\n * loremIpsum(200);\n */\n\n static loremIpsum(numChars, startSpot = undefined, startWithCapitalLetter = true) {\n const loremText = \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \";\n\n if (typeof numChars !== \"number\") {\n numChars = Math.floor(Math.random() * (150)) + 25;\n }\n\n if (startSpot === undefined) {\n startSpot = Math.floor(Math.random() * loremText.length);\n }\n\n startSpot = startSpot % loremText.length;\n\n // Move startSpot to the next non-whitespace and non-punctuation character\n while (loremText[startSpot] === ' ' || /[.,:;!?]/.test(loremText[startSpot])) {\n startSpot = (startSpot + 1) % loremText.length;\n }\n\n let l = loremText.substring(startSpot) + loremText.substring(0, startSpot);\n\n if (typeof numChars !== \"number\") {\n numChars = l.length;\n }\n\n let s = \"\";\n while (numChars > 0) {\n s += numChars < l.length ? l.substring(0, numChars) : l;\n numChars -= l.length;\n }\n\n if (s[s.length - 1] === \" \") {\n s = s.substring(0, s.length - 1) + \".\"; // always end on non-whitespace. \".\" was chosen arbitrarily.\n }\n\n if (startWithCapitalLetter) {\n let c = s[0].toUpperCase();\n c = /[A-Z]/.test(c) ? c : \"M\";\n s = c + s.substring(1);\n }\n\n return s;\n };\n\n\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","onSend","arguments","length","undefined","options","_classCallCheck","meta","_objectSpread","defaultOpts","theme","trackHistory","titleArea","title","show","align","messagesArea","alternating","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleAreaSetContents","titleAreaShow","titleAreaHide","messagesAreaAlternateColors","_attachEventListeners","_historyLimit","_history","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","_this$_messagesArea","scrollTop","scrollHeight","clientHeight","userScrolledUp","callback","_onMessageAdded","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","inputAreaShow","inputAreaHide","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","alt","add","remove","input","content","userString","role","userID","messageDiv","createElement","msgidClass","String","padStart","userDiv","contentDiv","appendChild","lastElementChild","scrollIntoView","timestamp","Date","toISOString","updatedtime","push","shift","messageAddFull","n","sucess","removeChild","error","console","log","splice","findIndex","item","msg","success","lastChild","m","slice","message","newTheme","get","version","license","url","numChars","startSpot","startWithCapitalLetter","loremText","Math","floor","random","test","l","substring","s","c","toUpperCase"],"mappings":"02DACMA,EAAQ,WAyCT,SAnCD,SAAAA,EAAYC,GAAiD,IAAlCC,EAAMC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,WAAM,EAAKG,EAAOH,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,+FAAEI,MAAAP,GACvD,IAMMQ,EAAIC,EAAAA,EAAQC,CAAAA,EANE,CAChBC,MAAO,uBACPC,cAAc,EACdC,UAAW,CAAEC,MAAO,OAAQC,MAAM,EAAOC,MAAO,UAChDC,aAAc,CAAEC,aAAa,KAECZ,GAEL,iBAAlBL,IACPA,EAAgBkB,SAASC,cAAcnB,IAG3CoB,KAAKC,eAAiBrB,EACtBoB,KAAKE,OAASf,EAAKG,MACnBU,KAAKG,QAAUtB,GAAkB,WAAM,EACvCmB,KAAKI,gBAEDjB,EAAKK,YACLQ,KAAKK,qBAAqBlB,EAAKK,UAAUC,MAAON,EAAKK,UAAUG,QACnC,IAAxBR,EAAKK,UAAUE,KACfM,KAAKM,gBAELN,KAAKO,iBAITpB,EAAKS,cACLI,KAAKQ,4BAA4BrB,EAAKS,aAAaC,aAGvDG,KAAKS,wBACLT,KAAKT,aAAeJ,EAAKI,eAAgB,EACzCS,KAAKU,cAAgB,IACrBV,KAAKW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C5D,GAEA,CAAAlG,IAAA,aAAAC,MAkBA,SAAkBkG,GAAgE,IAAtDC,EAASlI,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,QAAGE,EAAWiI,IAAsBnI,UAAAC,OAAA,QAAAC,IAAAF,UAAA,KAAAA,UAAA,GAC/DoI,EAAY,icAalB,IAXwB,iBAAbH,IACPA,EAAWI,KAAKC,MAAuB,IAAjBD,KAAKE,UAAoB,SAGjCrI,IAAdgI,IACAA,EAAYG,KAAKC,MAAsBF,IAAhBC,KAAKE,WAGhCL,GAAwBE,IAGQ,MAAzBA,EAAUF,IAAsB,WAAWM,KAAKJ,EAAUF,KAC7DA,GAAaA,EAAY,GAAKE,IAGlC,IAAIK,EAAIL,EAAUM,UAAUR,GAAaE,EAAUM,UAAU,EAAGR,GAExC,iBAAbD,IACPA,EAAWQ,EAAExI,QAIjB,IADA,IAAI0I,EAAI,GACDV,EAAW,GACdU,GAAKV,EAAWQ,EAAExI,OAASwI,EAAEC,UAAU,EAAGT,GAAYQ,EACtDR,GAAYQ,EAAExI,OAOlB,GAJwB,MAApB0I,EAAEA,EAAE1I,OAAS,KACb0I,EAAIA,EAAED,UAAU,EAAGC,EAAE1I,OAAS,GAAK,KAGnCkI,EAAwB,CACxB,IAAIS,EAAID,EAAE,GAAGE,cAEbF,GADAC,EAAI,QAAQJ,KAAKI,GAAKA,EAAI,KAClBD,EAAED,UAAU,EACxB,CAEA,OAAOC,CACX,gGAAC,CApbS"}
@@ -0,0 +1,63 @@
1
+ (function (React, quikchat) {
2
+ const { useEffect, useRef, forwardRef, useImperativeHandle } = React;
3
+
4
+ const QuikChat = forwardRef(function QuikChat({ onSend, options }, ref) {
5
+ const chatContainerRef = useRef(null);
6
+ const quikChatInstanceRef = useRef(null);
7
+
8
+ useEffect(function() {
9
+ if (chatContainerRef.current && !quikChatInstanceRef.current) {
10
+ quikChatInstanceRef.current = new quikchat(
11
+ chatContainerRef.current,
12
+ function(chat, msg) {
13
+ if (onSend) {
14
+ onSend(chat, msg);
15
+ }
16
+ },
17
+ options
18
+ );
19
+ }
20
+
21
+ return function() {
22
+ // Clean up if necessary
23
+ };
24
+ }, [onSend, options]);
25
+
26
+ useImperativeHandle(ref, function() {
27
+ return {
28
+ titleAreaToggle: function() { return quikChatInstanceRef.current.titleAreaToggle(); },
29
+ titleAreaShow: function() { return quikChatInstanceRef.current.titleAreaShow(); },
30
+ titleAreaHide: function() { return quikChatInstanceRef.current.titleAreaHide(); },
31
+ titleAreaSetContents: function() { return quikChatInstanceRef.current.titleAreaSetContents.apply(quikChatInstanceRef.current, arguments); },
32
+ titleAreaGetContents: function() { return quikChatInstanceRef.current.titleAreaGetContents(); },
33
+ inputAreaToggle: function() { return quikChatInstanceRef.current.inputAreaToggle(); },
34
+ inputAreaShow: function() { return quikChatInstanceRef.current.inputAreaShow(); },
35
+ inputAreaHide: function() { return quikChatInstanceRef.current.inputAreaHide(); },
36
+ messagesAreaAlternateColors: function() { return quikChatInstanceRef.current.messagesAreaAlternateColors.apply(quikChatInstanceRef.current, arguments); },
37
+ messagesAreaAlternateColorsToggle: function() { return quikChatInstanceRef.current.messagesAreaAlternateColorsToggle(); },
38
+ messagesAreaAlternateColorsGet: function() { return quikChatInstanceRef.current.messagesAreaAlternateColorsGet(); },
39
+ messageAddFull: function() { return quikChatInstanceRef.current.messageAddFull.apply(quikChatInstanceRef.current, arguments); },
40
+ messageAddNew: function() { return quikChatInstanceRef.current.messageAddNew.apply(quikChatInstanceRef.current, arguments); },
41
+ messageRemove: function() { return quikChatInstanceRef.current.messageRemove.apply(quikChatInstanceRef.current, arguments); },
42
+ messageGetDOMObject: function() { return quikChatInstanceRef.current.messageGetDOMObject.apply(quikChatInstanceRef.current, arguments); },
43
+ messageGetContent: function() { return quikChatInstanceRef.current.messageGetContent.apply(quikChatInstanceRef.current, arguments); },
44
+ messageAppendContent: function() { return quikChatInstanceRef.current.messageAppendContent.apply(quikChatInstanceRef.current, arguments); },
45
+ messageReplaceContent: function() { return quikChatInstanceRef.current.messageReplaceContent.apply(quikChatInstanceRef.current, arguments); },
46
+ historyGet: function() { return quikChatInstanceRef.current.historyGet.apply(quikChatInstanceRef.current, arguments); },
47
+ historyClear: function() { return quikChatInstanceRef.current.historyClear(); },
48
+ historyGetLength: function() { return quikChatInstanceRef.current.historyGetLength(); },
49
+ historyGetMessage: function() { return quikChatInstanceRef.current.historyGetMessage.apply(quikChatInstanceRef.current, arguments); },
50
+ historyGetMessageContent: function() { return quikChatInstanceRef.current.historyGetMessageContent.apply(quikChatInstanceRef.current, arguments); },
51
+ changeTheme: function() { return quikChatInstanceRef.current.changeTheme.apply(quikChatInstanceRef.current, arguments); }
52
+ };
53
+ });
54
+
55
+ return React.createElement('div', {
56
+ ref: chatContainerRef,
57
+ style: { height: '100%', width: '100%' }
58
+ });
59
+ });
60
+
61
+ // Export for use in browser
62
+ window.QuikChatReact = { QuikChat: QuikChat };
63
+ })(React, quikchat);
@@ -93,33 +93,45 @@
93
93
  * @param {*} meta
94
94
  */
95
95
  function quikchat(parentElement) {
96
- var meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
96
+ var onSend = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
97
+ var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
98
+ _classCallCheck(this, quikchat);
99
+ var defaultOpts = {
97
100
  theme: 'quikchat-theme-light',
98
- onSend: function onSend() {},
99
101
  trackHistory: true,
100
102
  titleArea: {
101
- title: "Title Area",
103
+ title: "Chat",
102
104
  show: false,
103
105
  align: "center"
106
+ },
107
+ messagesArea: {
108
+ alternating: true
104
109
  }
105
110
  };
106
- _classCallCheck(this, quikchat);
111
+ var meta = _objectSpread2(_objectSpread2({}, defaultOpts), options); // merge options with defaults
112
+
107
113
  if (typeof parentElement === 'string') {
108
114
  parentElement = document.querySelector(parentElement);
109
115
  }
116
+ //console.log(parentElement, meta);
110
117
  this._parentElement = parentElement;
111
118
  this._theme = meta.theme;
112
- this._onSend = meta.onSend ? meta.onSend : function () {};
119
+ this._onSend = onSend ? onSend : function () {}; // call back function for onSend
113
120
  this._createWidget();
114
121
  // title area
115
122
  if (meta.titleArea) {
116
123
  this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);
117
- if (meta.titleArea.show == true) {
124
+ if (meta.titleArea.show === true) {
118
125
  this.titleAreaShow();
119
126
  } else {
120
127
  this.titleAreaHide();
121
128
  }
122
129
  }
130
+ // messages area
131
+ if (meta.messagesArea) {
132
+ this.messagesAreaAlternateColors(meta.messagesArea.alternating);
133
+ }
134
+ // plumbing
123
135
  this._attachEventListeners();
124
136
  this.trackHistory = meta.trackHistory || true;
125
137
  this._historyLimit = 10000000;
@@ -138,6 +150,10 @@
138
150
  this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');
139
151
  this.msgid = 0;
140
152
  }
153
+
154
+ /**
155
+ * Attach event listeners to the widget
156
+ */
141
157
  }, {
142
158
  key: "_attachEventListeners",
143
159
  value: function _attachEventListeners() {
@@ -159,7 +175,15 @@
159
175
  _this._onSend(_this, _this._textEntry.value.trim());
160
176
  }
161
177
  });
178
+ this._messagesArea.addEventListener('scroll', function () {
179
+ var _this$_messagesArea = _this._messagesArea,
180
+ scrollTop = _this$_messagesArea.scrollTop,
181
+ scrollHeight = _this$_messagesArea.scrollHeight,
182
+ clientHeight = _this$_messagesArea.clientHeight;
183
+ _this.userScrolledUp = scrollTop + clientHeight < scrollHeight;
184
+ });
162
185
  }
186
+
163
187
  // set the onSend function callback.
164
188
  }, {
165
189
  key: "setCallbackOnSend",
@@ -248,6 +272,30 @@
248
272
  var minWidth = fontSize * sendButtonText.length + 16;
249
273
  this._sendButton.style.minWidth = "".concat(minWidth, "px");
250
274
  }
275
+
276
+ //messagesArea functions
277
+ }, {
278
+ key: "messagesAreaAlternateColors",
279
+ value: function messagesAreaAlternateColors() {
280
+ var alt = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : true;
281
+ if (alt) {
282
+ this._messagesArea.classList.add('quikchat-messages-area-alt');
283
+ } else {
284
+ this._messagesArea.classList.remove('quikchat-messages-area-alt');
285
+ }
286
+ return alt === true;
287
+ }
288
+ }, {
289
+ key: "messagesAreaAlternateColorsToggle",
290
+ value: function messagesAreaAlternateColorsToggle() {
291
+ this._messagesArea.classList.toggle('quikchat-messages-area-alt');
292
+ }
293
+ }, {
294
+ key: "messagesAreaAlternateColorsGet",
295
+ value: function messagesAreaAlternateColorsGet() {
296
+ return this._messagesArea.classList.contains('quikchat-messages-area-alt');
297
+ }
298
+ // message functions
251
299
  }, {
252
300
  key: "messageAddFull",
253
301
  value: function messageAddFull() {
@@ -274,8 +322,11 @@
274
322
  messageDiv.appendChild(userDiv);
275
323
  messageDiv.appendChild(contentDiv);
276
324
  this._messagesArea.appendChild(messageDiv);
277
- //this._messagesArea.lastChild.scrollIntoView();
278
- this._messagesArea.lastElementChild.scrollIntoView();
325
+
326
+ // Scroll to the last message only if the user is not actively scrolling up
327
+ if (!this.userScrolledUp) {
328
+ this._messagesArea.lastElementChild.scrollIntoView();
329
+ }
279
330
  this._textEntry.value = '';
280
331
  this._adjustMessagesAreaHeight();
281
332
  var timestamp = new Date().toISOString();
@@ -371,7 +422,7 @@
371
422
  }, {
372
423
  key: "messageAppendContent",
373
424
  value: function messageAppendContent(n, content) {
374
- var sucess = false;
425
+ var success = false;
375
426
  try {
376
427
  this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))).lastChild.innerHTML += content;
377
428
  // update history
@@ -380,31 +431,44 @@
380
431
  })[0];
381
432
  item.content += content;
382
433
  item.updatedtime = new Date().toISOString();
383
- sucess = true;
384
- //this._messagesArea.lastChild.scrollIntoView();
385
- this._messagesArea.lastElementChild.scrollIntoView();
434
+ success = true;
435
+
436
+ // Scroll to the last message only if the user is not actively scrolling up
437
+ if (!this.userScrolledUp) {
438
+ this._messagesArea.lastElementChild.scrollIntoView();
439
+ }
386
440
  } catch (error) {
387
- console.log("{String(n)} : Message ID not found");
441
+ console.log("".concat(String(n), " : Message ID not found"));
388
442
  }
443
+ return success;
389
444
  }
445
+
390
446
  /* replace message content
391
447
  */
392
448
  }, {
393
449
  key: "messageReplaceContent",
394
450
  value: function messageReplaceContent(n, content) {
395
- var sucess = false;
451
+ var success = false;
396
452
  try {
397
453
  this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))).lastChild.innerHTML = content;
398
454
  // update history
399
- this._history.filter(function (item) {
455
+ var item = this._history.filter(function (item) {
400
456
  return item.msgid === n;
401
- })[0].content = content;
402
- sucess = true;
457
+ })[0];
458
+ item.content = content;
459
+ item.updatedtime = new Date().toISOString();
460
+ success = true;
461
+
462
+ // Scroll to the last message only if the user is not actively scrolling up
463
+ if (!this.userScrolledUp) {
464
+ this._messagesArea.lastElementChild.scrollIntoView();
465
+ }
403
466
  } catch (error) {
404
- console.log("{String(n)} : Message ID not found");
467
+ console.log("".concat(String(n), " : Message ID not found"));
405
468
  }
406
- return sucess;
469
+ return success;
407
470
  }
471
+
408
472
  // history functions
409
473
  /**
410
474
  *
@@ -467,11 +531,66 @@
467
531
  key: "version",
468
532
  value: function version() {
469
533
  return {
470
- "version": "1.0.4",
534
+ "version": "1.1.2",
471
535
  "license": "BSD-2",
472
536
  "url": "https://github/deftio/quikchat"
473
537
  };
474
538
  }
539
+
540
+ /**
541
+ * quikchat.loremIpsum() - Generate a simple string of Lorem Ipsum text (sample typographer's text) of numChars in length.
542
+ * borrowed from github.com/deftio/bitwrench.js
543
+ * @param {number} numChars - The number of characters to generate (random btw 25 and 150 if undefined).
544
+ * @param {number} [startSpot=0] - The starting index in the Lorem Ipsum text. If undefined, a random startSpot will be generated.
545
+ * @param {boolean} [startWithCapitalLetter=true] - If true, capitalize the first character or inject a capital letter if the first character isn't a capital letter.
546
+ *
547
+ * @returns {string} A string of Lorem Ipsum text.
548
+ *
549
+ * @example
550
+ * // Returns 200 characters of Lorem Ipsum starting from index 50
551
+ * loremIpsum(200, 50);
552
+ *
553
+ * @example
554
+ * //Returns a 200 Lorem Ipsum characters starting from a random index
555
+ * loremIpsum(200);
556
+ */
557
+ }, {
558
+ key: "loremIpsum",
559
+ value: function loremIpsum(numChars) {
560
+ var startSpot = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
561
+ var startWithCapitalLetter = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
562
+ var loremText = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. ";
563
+ if (typeof numChars !== "number") {
564
+ numChars = Math.floor(Math.random() * 150) + 25;
565
+ }
566
+ if (startSpot === undefined) {
567
+ startSpot = Math.floor(Math.random() * loremText.length);
568
+ }
569
+ startSpot = startSpot % loremText.length;
570
+
571
+ // Move startSpot to the next non-whitespace and non-punctuation character
572
+ while (loremText[startSpot] === ' ' || /[.,:;!?]/.test(loremText[startSpot])) {
573
+ startSpot = (startSpot + 1) % loremText.length;
574
+ }
575
+ var l = loremText.substring(startSpot) + loremText.substring(0, startSpot);
576
+ if (typeof numChars !== "number") {
577
+ numChars = l.length;
578
+ }
579
+ var s = "";
580
+ while (numChars > 0) {
581
+ s += numChars < l.length ? l.substring(0, numChars) : l;
582
+ numChars -= l.length;
583
+ }
584
+ if (s[s.length - 1] === " ") {
585
+ s = s.substring(0, s.length - 1) + "."; // always end on non-whitespace. "." was chosen arbitrarily.
586
+ }
587
+ if (startWithCapitalLetter) {
588
+ var c = s[0].toUpperCase();
589
+ c = /[A-Z]/.test(c) ? c : "M";
590
+ s = c + s.substring(1);
591
+ }
592
+ return s;
593
+ }
475
594
  }]);
476
595
  }();
477
596
 
@@ -1 +1 @@
1
- {"version":3,"file":"quikchat.umd.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n /**\n * \n * @param string or DOM element parentElement \n * @param {*} meta \n */\n constructor(parentElement, \n meta = { \n theme: 'quikchat-theme-light', \n onSend: () => { }, \n trackHistory: true,\n titleArea: {title: \"Title Area\", show: false, align: \"center\"}\n }) \n {\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\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.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show == true) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\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 this.msgid = 0;\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 // set the onSend function callback.\n setCallbackOnSend(callback) {\n this._onSend = callback;\n }\n // set a callback for everytime a message is added (listener)\n setCallbackonMessageAdded(callback) {\n this._onMessageAdded = callback;\n }\n\n // Public methods\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 titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\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 messageAddFull(input = {content: \"\", userString: \"user\", align : \"right\", role : \"user\", userID : -1}) {\n const msgid = this.msgid;\n const messageDiv = document.createElement('div');\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n const userIdClass = 'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\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 = input.userString;\n userDiv.style = `width: 100%; text-align: ${input.align}; font-size: 1em; font-weight:700;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${input.align};`;\n contentDiv.innerHTML = input.content;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n //this._messagesArea.lastChild.scrollIntoView();\n this._messagesArea.lastElementChild.scrollIntoView()\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n const timestamp = new Date().toISOString();\n const updatedtime = timestamp;\n if (this.trackHistory) {\n this._history.push({ msgid, ...input, timestamp, updatedtime, messageDiv});\n if (this._history.length > this._historyLimit) {\n this._history.shift();\n }\n }\n if (this._onMessageAdded) {\n this._onMessageAdded(this, msgid);\n };\n return msgid;\n }\n messageAddNew(content=\"\", userString=\"user\", align = \"right\", role = \"user\") {\n return this.messageAddFull( \n {content: content, userString: userString, align: align, role: role}\n );\n }\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n if (sucess) {\n // slow way to remove from history\n //this._history = this._history.filter((item) => item.msgid !== n); // todo make this more efficient\n\n // better way to delete this from history\n this._history.splice(this._history.findIndex((item) => item.msgid === n), 1);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg; \n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n // get from history..\n content = this._history.filter((item) => item.msgid === n)[0].content;\n //content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content; \n }\n\n /* append message to the message content\n */\n messageAppendContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content += content;\n item.updatedtime = new Date().toISOString();\n sucess = true;\n //this._messagesArea.lastChild.scrollIntoView();\n this._messagesArea.lastElementChild.scrollIntoView()\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n } \n }\n /* replace message content\n */\n messageReplaceContent(n, content) {\n let sucess = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n // update history\n this._history.filter((item) => item.msgid === n)[0].content = content;\n sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n // history functions\n /**\n * \n * @param {*} n \n * @param {*} m \n * @returns array of history messages\n */\n historyGet(n,m) {\n\n if (n == undefined) {\n n = 0;\n m= this._history.length;\n }\n if (m === undefined) {\n m = n < 0 ? m: n + 1;\n }\n // remember that entries could be deleted. TODO: So we need to return the actual history entries\n // so now we need to find the array index that correspondes to messageIds n (start) and m (end)\n \n return this._history.slice(n,m);\n }\n\n historyClear() {\n this.msgid = 0;\n this._history = [];\n } \n\n historyGetLength() {\n return this._history.length;\n } \n\n historyGetMessage(n) {\n if ( n>=0 && n < this._history.length) {\n this._history[n];\n }\n return {};\n\n } \n\n historyGetMessageContent(n) {\n return this._history[n].message;\n }\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 get theme() {\n return this._theme;\n }\n\n static version() {\n return {\"version\" : \"1.0.4\", \"license\" : \"BSD-2\", \"url\" :\"https://github/deftio/quikchat\"};\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","trackHistory","titleArea","title","show","align","_classCallCheck","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleAreaSetContents","titleAreaShow","titleAreaHide","_attachEventListeners","_historyLimit","_history","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","setCallbackOnSend","callback","setCallbackonMessageAdded","_onMessageAdded","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","messageAddFull","input","content","userString","role","userID","messageDiv","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastElementChild","scrollIntoView","timestamp","Date","toISOString","updatedtime","push","_objectSpread","shift","messageAddNew","messageRemove","n","sucess","removeChild","error","console","log","splice","findIndex","item","messageGetDOMObject","msg","messageGetContent","messageAppendContent","lastChild","messageReplaceContent","historyGet","m","slice","historyClear","historyGetLength","historyGetMessage","historyGetMessageContent","message","changeTheme","newTheme","remove","get","version"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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A,EAED,SAAAA,GAAAA,GAAY;QACR,OAAO,IAAI,CAACrH,MAAM,CAAA;EACtB,KAAA;EAAC,GAAA,CAAA,EAAA,CAAA;MAAAU,GAAA,EAAA,SAAA;MAAAC,KAAA,EAED,SAAA2G,OAAAA,GAAiB;QACb,OAAO;EAAC,QAAA,SAAS,EAAG,OAAO;EAAE,QAAA,SAAS,EAAG,OAAO;EAAE,QAAA,KAAK,EAAE,gCAAA;SAAiC,CAAA;EAC9F,KAAA;EAAC,GAAA,CAAA,CAAA,CAAA;EAAA,CAAA;;;;;;;;"}
1
+ {"version":3,"file":"quikchat.umd.js","sources":["../src/quikchat.js"],"sourcesContent":["\nclass quikchat {\n /**\n * \n * @param string or DOM element parentElement \n * @param {*} meta \n */\n constructor(parentElement, onSend = () => { }, options = {}) {\n const defaultOpts = {\n theme: 'quikchat-theme-light',\n trackHistory: true,\n titleArea: { title: \"Chat\", show: false, align: \"center\" },\n messagesArea: { alternating: true },\n };\n const meta = { ...defaultOpts, ...options }; // merge options with defaults\n\n if (typeof parentElement === 'string') {\n parentElement = document.querySelector(parentElement);\n }\n //console.log(parentElement, meta);\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = onSend ? onSend : () => { }; // call back function for onSend\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show === true) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n // messages area\n if (meta.messagesArea) {\n this.messagesAreaAlternateColors(meta.messagesArea.alternating);\n }\n // plumbing\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <div class=\"quikchat-base ${this.theme}\">\n <div class=\"quikchat-title-area\">\n <span style=\"font-size: 1.5em; font-weight: 600;\">Title Area</span>\n </div>\n <div class=\"quikchat-messages-area\"></div>\n <div class=\"quikchat-input-area\">\n <textarea class=\"quikchat-input-textbox\"></textarea>\n <button class=\"quikchat-input-send-btn\">Send</button>\n </div>\n </div>\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 this.msgid = 0;\n }\n\n /**\n * Attach event listeners to the widget\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 this._messagesArea.addEventListener('scroll', () => {\n const { scrollTop, scrollHeight, clientHeight } = this._messagesArea;\n this.userScrolledUp = scrollTop + clientHeight < scrollHeight;\n });\n }\n \n // set the onSend function callback.\n setCallbackOnSend(callback) {\n this._onSend = callback;\n }\n // set a callback for everytime a message is added (listener)\n setCallbackonMessageAdded(callback) {\n this._onMessageAdded = callback;\n }\n\n // Public methods\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 titleAreaSetContents(title, align = 'center') {\n this._titleArea.innerHTML = title;\n this._titleArea.style.textAlign = align;\n }\n\n titleAreaGetContents() {\n return this._titleArea.innerHTML;\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 //messagesArea functions\n messagesAreaAlternateColors(alt = true) {\n if (alt) {\n this._messagesArea.classList.add('quikchat-messages-area-alt');\n }\n else {\n this._messagesArea.classList.remove('quikchat-messages-area-alt');\n }\n return alt === true;\n }\n messagesAreaAlternateColorsToggle() {\n this._messagesArea.classList.toggle('quikchat-messages-area-alt');\n }\n messagesAreaAlternateColorsGet() {\n return this._messagesArea.classList.contains('quikchat-messages-area-alt');\n }\n // message functions\n messageAddFull(input = { content: \"\", userString: \"user\", align: \"right\", role: \"user\", userID: -1 }) {\n const msgid = this.msgid;\n const messageDiv = document.createElement('div');\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\n const userIdClass = 'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..\n messageDiv.classList.add('quikchat-message', msgidClass);\n this.msgid++;\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 = input.userString;\n userDiv.style = `width: 100%; text-align: ${input.align}; font-size: 1em; font-weight:700;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${input.align};`;\n contentDiv.innerHTML = input.content;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n\n // Scroll to the last message only if the user is not actively scrolling up\n if (!this.userScrolledUp) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n const timestamp = new Date().toISOString();\n const updatedtime = timestamp;\n\n if (this.trackHistory) {\n this._history.push({ msgid, ...input, timestamp, updatedtime, messageDiv });\n if (this._history.length > this._historyLimit) {\n this._history.shift();\n }\n }\n\n if (this._onMessageAdded) {\n this._onMessageAdded(this, msgid);\n }\n\n return msgid;\n }\n\n \n messageAddNew(content = \"\", userString = \"user\", align = \"right\", role = \"user\") {\n return this.messageAddFull(\n { content: content, userString: userString, align: align, role: role }\n );\n }\n messageRemove(n) {\n // use css selector to remove the message\n let sucess = false;\n try {\n this._messagesArea.removeChild(this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`));\n sucess = true;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n if (sucess) {\n // slow way to remove from history\n //this._history = this._history.filter((item) => item.msgid !== n); // todo make this more efficient\n\n // better way to delete this from history\n this._history.splice(this._history.findIndex((item) => item.msgid === n), 1);\n }\n return sucess;\n }\n /* returns the message html object from the DOM\n */\n messageGetDOMObject(n) {\n let msg = null;\n // now use css selector to get the message \n try {\n msg = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`);\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return msg;\n }\n /* returns the message content only\n */\n messageGetContent(n) {\n let content = \"\"\n // now use css selector to get the message \n try {\n // get from history..\n content = this._history.filter((item) => item.msgid === n)[0].content;\n //content = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.textContent;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return content;\n }\n\n /* append message to the message content\n */\n\n messageAppendContent(n, content) {\n let success = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML += content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content += content;\n item.updatedtime = new Date().toISOString();\n success = true;\n\n // Scroll to the last message only if the user is not actively scrolling up\n if (!this.userScrolledUp) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n } catch (error) {\n console.log(`${String(n)} : Message ID not found`);\n }\n return success;\n }\n \n /* replace message content\n */\n messageReplaceContent(n, content) {\n let success = false;\n try {\n this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild.innerHTML = content;\n // update history\n let item = this._history.filter((item) => item.msgid === n)[0];\n item.content = content;\n item.updatedtime = new Date().toISOString();\n success = true;\n\n // Scroll to the last message only if the user is not actively scrolling up\n if (!this.userScrolledUp) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n } catch (error) {\n console.log(`${String(n)} : Message ID not found`);\n }\n return success;\n }\n \n // history functions\n /**\n * \n * @param {*} n \n * @param {*} m \n * @returns array of history messages\n */\n historyGet(n, m) {\n\n if (n == undefined) {\n n = 0;\n m = this._history.length;\n }\n if (m === undefined) {\n m = n < 0 ? m : n + 1;\n }\n // remember that entries could be deleted. TODO: So we need to return the actual history entries\n // so now we need to find the array index that correspondes to messageIds n (start) and m (end)\n\n return this._history.slice(n, m);\n }\n\n historyClear() {\n this.msgid = 0;\n this._history = [];\n }\n\n historyGetLength() {\n return this._history.length;\n }\n\n historyGetMessage(n) {\n if (n >= 0 && n < this._history.length) {\n this._history[n];\n }\n return {};\n\n }\n\n historyGetMessageContent(n) {\n return this._history[n].message;\n }\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 get theme() {\n return this._theme;\n }\n\n static version() {\n return { \"version\": \"1.1.2\", \"license\": \"BSD-2\", \"url\": \"https://github/deftio/quikchat\" };\n }\n\n /**\n * quikchat.loremIpsum() - Generate a simple string of Lorem Ipsum text (sample typographer's text) of numChars in length.\n * borrowed from github.com/deftio/bitwrench.js\n * @param {number} numChars - The number of characters to generate (random btw 25 and 150 if undefined). \n * @param {number} [startSpot=0] - The starting index in the Lorem Ipsum text. If undefined, a random startSpot will be generated.\n * @param {boolean} [startWithCapitalLetter=true] - If true, capitalize the first character or inject a capital letter if the first character isn't a capital letter.\n * \n * @returns {string} A string of Lorem Ipsum text.\n * \n * @example \n * // Returns 200 characters of Lorem Ipsum starting from index 50\n * loremIpsum(200, 50);\n * \n * @example \n * //Returns a 200 Lorem Ipsum characters starting from a random index\n * loremIpsum(200);\n */\n\n static loremIpsum(numChars, startSpot = undefined, startWithCapitalLetter = true) {\n const loremText = \"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \";\n\n if (typeof numChars !== \"number\") {\n numChars = Math.floor(Math.random() * (150)) + 25;\n }\n\n if (startSpot === undefined) {\n startSpot = Math.floor(Math.random() * loremText.length);\n }\n\n startSpot = startSpot % loremText.length;\n\n // Move startSpot to the next non-whitespace and non-punctuation character\n while (loremText[startSpot] === ' ' || /[.,:;!?]/.test(loremText[startSpot])) {\n startSpot = (startSpot + 1) % loremText.length;\n }\n\n let l = loremText.substring(startSpot) + loremText.substring(0, startSpot);\n\n if (typeof numChars !== \"number\") {\n numChars = l.length;\n }\n\n let s = \"\";\n while (numChars > 0) {\n s += numChars < l.length ? l.substring(0, numChars) : l;\n numChars -= l.length;\n }\n\n if (s[s.length - 1] === \" \") {\n s = s.substring(0, s.length - 1) + \".\"; // always end on non-whitespace. \".\" was chosen arbitrarily.\n }\n\n if (startWithCapitalLetter) {\n let c = s[0].toUpperCase();\n c = /[A-Z]/.test(c) ? c : \"M\";\n s = c + s.substring(1);\n }\n\n return s;\n };\n\n\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","onSend","arguments","length","undefined","options","_classCallCheck","defaultOpts","theme","trackHistory","titleArea","title","show","align","messagesArea","alternating","meta","_objectSpread","document","querySelector","_parentElement","_theme","_onSend","_createWidget","titleAreaSetContents","titleAreaShow","titleAreaHide","messagesAreaAlternateColors","_attachEventListeners","_historyLimit","_history","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","_this$_messagesArea","scrollTop","scrollHeight","clientHeight","userScrolledUp","setCallbackOnSend","callback","setCallbackonMessageAdded","_onMessageAdded","titleAreaToggle","style","display","_adjustMessagesAreaHeight","textAlign","titleAreaGetContents","inputAreaToggle","classList","toggle","inputAreaShow","inputAreaHide","hiddenElements","_toConsumableArray","children","filter","child","contains","totalHiddenHeight","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","fontSize","parseFloat","getComputedStyle","minWidth","alt","add","remove","messagesAreaAlternateColorsToggle","messagesAreaAlternateColorsGet","messageAddFull","input","content","userString","role","userID","messageDiv","createElement","msgidClass","String","padStart","userDiv","contentDiv","appendChild","lastElementChild","scrollIntoView","timestamp","Date","toISOString","updatedtime","push","shift","messageAddNew","messageRemove","n","sucess","removeChild","error","console","log","splice","findIndex","item","messageGetDOMObject","msg","messageGetContent","messageAppendContent","success","lastChild","messageReplaceContent","historyGet","m","slice","historyClear","historyGetLength","historyGetMessage","historyGetMessageContent","message","changeTheme","newTheme","get","version","lorem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