quikchat 1.1.13 → 1.1.14

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":["class 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 inputArea: { show: true },\n sendOnEnter: true,\n sendOnShiftEnter: false\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\n // input area\n if (meta.inputArea) {\n if (meta.inputArea.show === true)\n this.inputAreaShow();\n else\n this.inputAreaHide();\n }\n // plumbing\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n\n // send on enter / shift enter\n this.sendOnEnter = meta.sendOnEnter;\n this.sendOnShiftEnter = meta.sendOnShiftEnter;\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', (event) => { event.preventDefault(); 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\n // Check if Shift + Enter is pressed then we just do carraige\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n if (this.sendOnShiftEnter) {\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim());\n }\n } else if (event.keyCode === 13) {// Enter but not Shift + Enter\n if (this.sendOnEnter) {\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim());\n }\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 return true;\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 return true;\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, timestamp: false, updatedtime: false, scrollIntoView: true, visible: true }) {\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, 'quikchat-structure');\n this.msgid++;\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = input.userString;\n userDiv.classList.add('quikchat-user-label');\n userDiv.style.textAlign = input.align;\n \n const contentDiv = document.createElement('div');\n contentDiv.classList.add('quikchat-message-content');\n \n // Determine text alignment for right-aligned messages\n if (input.align === \"right\") {\n const isMultiLine = input.content.includes(\"\\n\");\n const isLong = input.content.length > 50; // Adjust length threshold\n \n if (isMultiLine || isLong) {\n contentDiv.classList.add(\"quikchat-right-multiline\");\n } else {\n contentDiv.classList.add(\"quikchat-right-singleline\");\n }\n }\n \n contentDiv.innerHTML = input.content;\n \n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n \n const visible = input.visible === undefined ? true : input.visible;\n if (!visible) {\n messageDiv.style.display = 'none';\n }\n \n // Scroll to the last message only if the user is not actively scrolling up\n if ((!this.userScrolledUp) || input.scrollIntoView) {\n this.messageScrollToBottom();\n }\n \n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n this._handleShortLongMessageCSS(messageDiv, input.align); // Handle CSS for short/long messages\n this._updateMessageStyles();\n \n // Add timestamp now, unless it is passed in \n const timestamp = input.timestamp ? input.timestamp : new Date().toISOString();\n const updatedtime = input.updatedtime ? input.updatedtime : timestamp;\n \n if (this.trackHistory) {\n this._history.push({ msgid, ...input, visible, 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\n messageAddNew(content = \"\", userString = \"user\", align = \"right\", role = \"user\", scrollIntoView = true, visible = true) {\n let retvalue = this.messageAddFull(\n { content: content, userString: userString, align: align, role: role, scrollIntoView: scrollIntoView, visible: visible }\n );\n // this.messageScrollToBottom();\n return retvalue;\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 /* returns the DOM Content element of a given message\n */\n messageGetContentDOMElement(n) {\n let contentElement = null;\n // now use css selector to get the message\n try {\n //contentElement = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild;\n contentElement = this._history.filter((item) => item.msgid === n)[0].messageDiv.lastChild;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return contentElement;\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 /**\n * Scrolls the messages area to the bottom.\n */\n messageScrollToBottom() {\n if (this._messagesArea.lastElementChild) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n }\n\n /**\n * Removes the last message from the messages area.\n */\n messageRemoveLast() {\n // find the last message by id:\n if (this._history.length >= 0) {\n let lastMsgId = this._history[this._history.length - 1].msgid;\n return this.messageRemove(lastMsgId);\n }\n return false;\n }\n\n messageSetVisibility(msgid, isVisible) {\n const message = this._history.find(item => item.msgid === msgid);\n if (message && message.messageDiv) {\n message.messageDiv.style.display = isVisible ? '' : 'none';\n message.visible = isVisible;\n this._updateMessageStyles();\n return true;\n }\n return false;\n }\n\n messageGetVisibility(msgid) {\n const message = this._history.find(item => item.msgid === msgid);\n if (message && message.messageDiv) {\n return message.messageDiv.style.display !== 'none';\n }\n return false; // Return false if not found or no messageDiv\n }\n\n _updateMessageStyles() {\n const visibleMessages = [...this._messagesArea.children].filter(\n child => child.style.display !== 'none'\n );\n\n visibleMessages.forEach((messageDiv, index) => {\n messageDiv.classList.remove('quikchat-message-1', 'quikchat-message-2');\n messageDiv.classList.add(index % 2 === 0 ? 'quikchat-message-1' : 'quikchat-message-2');\n });\n }\n\n /**\n * For right sided or centered messages, we need to handle the CSS for short and long messages.\n * for short messages we use simple justifying, for long messages we need to wrap and perform multiline\n * formatting. \n * \n * @param {*} messageElement \n * @returns nothing\n */\n _handleShortLongMessageCSS(messageElement, align) {\n // console.log(messageElement);\n // Reset classes\n messageElement.classList.remove(\n 'left-singleline', 'left-multiline',\n 'center-singleline', 'center-multiline',\n 'right-singleline', 'right-multiline');\n let contentDiv = messageElement.lastChild;\n window.lastDiv = contentDiv; // for debugging \n // Determine if the message is short or long\n\n const computedStyle = window.getComputedStyle(contentDiv);\n\n // Get the element's height\n const elementHeight = contentDiv.offsetHeight;\n\n // Calculate or estimate line height\n let lineHeight;\n if (computedStyle.lineHeight === \"normal\") {\n const fontSize = parseFloat(computedStyle.fontSize);\n lineHeight = fontSize * 1.2; // approximate \"normal\" as 1.2 times font-size\n } else {\n lineHeight = parseFloat(computedStyle.lineHeight);\n }\n\n // Check if the element height is more than one line-height\n const isMultiLine = elementHeight > lineHeight;\n\n // Using scrollHeight and clientHeight to check for overflow (multi-line)\n switch (align) {\n case 'center':\n if (isMultiLine) {\n messageElement.classList.add('center-multiline');\n }\n else {\n messageElement.classList.add('center-singleline');\n }\n break;\n case 'right':\n if (isMultiLine) {\n messageElement.classList.add('right-multiline');\n }\n else {\n messageElement.classList.add('right-singleline');\n }\n break;\n case 'left':\n default:\n if (isMultiLine) {\n messageElement.classList.add('left-multiline');\n }\n else {\n messageElement.classList.add('left-singleline');\n }\n break;\n }\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 historyGetAllCopy() {\n return this._history.slice();\n }\n\n historyClear() {\n this.msgid = 0;\n this._messagesArea.innerHTML = \"\";\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 return this._history[n];\n }\n return {};\n\n }\n\n historyGetMessageContent(n) {\n if (n >= 0 && n < this._history.length)\n return this._history[n].content;\n else\n return \"\";\n }\n\n // expects an array of messages to be in the format of the history object\n historyRestoreAll(messageList) {\n // clear all messages and history\n this.historyClear();\n\n // clear the messages div \n this._messagesArea.innerHTML = \"\";\n\n // add all messages\n messageList.forEach((message) => {\n this.messageAddFull(message);\n });\n }\n /**\n * \n * @param {string} newTheme \n */\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n /**\n * Get the current theme\n * @returns {string} - The current theme\n */\n get theme() {\n return this._theme;\n }\n\n /**\n * \n * @returns {object} - Returns the version and license information for the library.\n */\n static version() {\n return { \"version\": \"1.1.13\", \"license\": \"BSD-2\", \"url\": \"https://github/deftio/quikchat\", \"fun\": true };\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 static tempMessageGenerator (domElement, content, interval, cb = null) {\n interval = Math.max(interval, 100); // Ensure at least 100ms interval\n \n let count = 0;\n\n let defaultCB = (msg, count) => {msg += \".\"; return msg; };\n\n if (cb && typeof cb !== 'function') {\n cb = null;\n }\n\n cb = cb || defaultCB;\n \n // if its a string, then get the element (css sel) or its an DOM element already \n let el = domElement;\n if (typeof el === 'string') {\n el = document.querySelector(el);\n } \n\n const element = el;\n\n \n // Ensure the element exists\n if (!element) return;\n \n element.innerHTML = content;\n let currentMsg = content;\n \n const intervalId = setInterval(() => {\n if (element.innerHTML !== currentMsg) {\n clearInterval(intervalId); // Stop updating if content is changed externally\n return;\n }\n \n currentMsg = String( cb(currentMsg, count)) ;// Use callback return value if provided\n \n count++;\n element.innerHTML = currentMsg;\n }, interval);\n }\n\n static createTempMessageDOMStr(initialContent, updateInterval = 1000, callback = null, options = {}) {\n // Make sure the interval is at least 100ms\n updateInterval = Math.max(updateInterval, 100);\n \n // Validate callback; if not a function, ignore it.\n if (callback && typeof callback !== 'function') {\n callback = null;\n }\n // Default callback simply appends a dot.\n callback = callback || function(msg, count) {\n return msg + \".\";\n };\n \n // Allow an optional CSS class for the container element\n const containerClass = options.containerClass ? options.containerClass : '';\n \n // Generate a unique id so that the inline script can reliably find the container.\n const uniqueId = \"tempMsg_\" + Date.now() + \"_\" + Math.floor(Math.random() * 1000000);\n \n // Build and return the HTML string.\n // Note the use of <\\/script> (with a backslash) so that the inline script is not terminated early.\n return `\n <span id=\"${uniqueId}\" ${containerClass ? `class=\"${containerClass}\"` : ''}>\n ${initialContent}\n </span>\n <script>\n (function(){\n // Get our container element by its unique id.\n var container = document.getElementById(\"${uniqueId}\");\n if (!container) return;\n var count = 0;\n var currentMsg = container.innerHTML;\n var interval = ${updateInterval};\n // Convert the callback function into its string representation.\n var cb = ${callback.toString()};\n var intervalId = setInterval(function(){\n // If the content has been replaced, stop updating.\n if(container.innerHTML !== currentMsg){\n clearInterval(intervalId);\n return;\n }\n // Use the callback to generate the new message.\n currentMsg = String(cb(currentMsg, count));\n count++;\n container.innerHTML = currentMsg;\n }, interval);\n })();\n <\\/script>\n `;\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","inputArea","sendOnEnter","sendOnShiftEnter","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","titleAreaSetContents","titleAreaShow","titleAreaHide","messagesAreaAlternateColors","inputAreaShow","inputAreaHide","_attachEventListeners","_historyLimit","_history","key","value","widgetHTML","concat","innerHTML","_chatWidget","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","event","preventDefault","trim","window","_handleContainerResize","shiftKey","keyCode","_this$_messagesArea","scrollTop","scrollHeight","clientHeight","userScrolledUp","callback","_onMessageAdded","style","display","_adjustMessagesAreaHeight","textAlign","classList","toggle","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","timestamp","updatedtime","scrollIntoView","visible","messageDiv","createElement","msgidClass","String","padStart","userDiv","contentDiv","isMultiLine","includes","isLong","appendChild","messageScrollToBottom","_handleShortLongMessageCSS","_updateMessageStyles","Date","toISOString","push","shift","messageAddFull","n","sucess","removeChild","error","console","log","splice","findIndex","item","msg","contentElement","lastChild","success","lastElementChild","lastMsgId","messageRemove","isVisible","message","find","forEach","index","messageElement","lastDiv","lineHeight","computedStyle","elementHeight","m","slice","messageList","_this2","historyClear","newTheme","get","version","license","url","fun","numChars","startSpot","startWithCapitalLetter","loremText","Math","floor","random","test","l","substring","s","c","toUpperCase","domElement","interval","cb","max","count","el","element","currentMsg","intervalId","setInterval","clearInterval","initialContent","updateInterval","containerClass","uniqueId","now","toString"],"mappings":"02DAAMA,EAAQ,WAwDT,SAlDD,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,IASMQ,EAAIC,EAAAA,EAAQC,CAAAA,EATE,CAChBC,MAAO,uBACPC,cAAc,EACdC,UAAW,CAAEC,MAAO,OAAQC,MAAM,EAAOC,MAAO,UAChDC,aAAc,CAAEC,aAAa,GAC7BC,UAAW,CAAEJ,MAAM,GACnBK,aAAa,EACbC,kBAAkB,IAEYf,GAEL,iBAAlBL,IACPA,EAAgBqB,SAASC,cAActB,IAG3CuB,KAAKC,eAAiBxB,EACtBuB,KAAKE,OAASlB,EAAKG,MACnBa,KAAKG,QAAUzB,GAAkB,WAAM,EACvCsB,KAAKI,gBAEDpB,EAAKK,YACLW,KAAKK,qBAAqBrB,EAAKK,UAAUC,MAAON,EAAKK,UAAUG,QACnC,IAAxBR,EAAKK,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,GAAAA,UAAA,GAAG,IAAM6D,EAAQ7D,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,KAAMG,EAAOH,UAAAC,OAAA,QAAAC,IAAAF,UAAA,GAAAA,UAAA,GAAG,CAAA,EAE7FoL,EAAiBrB,KAAKY,IAAIS,EAAgB,KAGtCvH,GAAgC,mBAAbA,IACrBA,EAAW,MAGbA,EAAWA,GAAY,SAASkE,EAAK6C,GACnC,OAAO7C,EAAM,KAIf,IAAMsD,EAAiBlL,EAAQkL,eAAiBlL,EAAQkL,eAAiB,GAGnEC,EAAW,WAAarE,KAAKsE,MAAQ,IAAMxB,KAAKC,MAAsB,IAAhBD,KAAKE,UAIjE,MAAA,yBAAA3H,OACcgJ,EAAQ,MAAAhJ,OAAK+I,EAAc/I,UAAAA,OAAa+I,EAAoB,KAAA,sBAAE/I,OACtE6I,EAAc,4LAAA7I,OAK6BgJ,EAAQ,gKAAAhJ,OAIlC8I,EAAc9I,8GAAAA,OAEpBuB,EAAS2H,WAAU,kjBAetC,gGAAC,CAtuBO"}
1
+ {"version":3,"file":"quikchat.esm.min.js","sources":["../src/quikchat.js"],"sourcesContent":["class 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 inputArea: { show: true },\n sendOnEnter: true,\n sendOnShiftEnter: false,\n instanceClass: ''\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\n if (meta.instanceClass) {\n this._chatWidget.classList.add(meta.instanceClass);\n }\n\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\n // input area\n if (meta.inputArea) {\n if (meta.inputArea.show === true)\n this.inputAreaShow();\n else\n this.inputAreaHide();\n }\n // plumbing\n this._attachEventListeners();\n this.trackHistory = meta.trackHistory || true;\n this._historyLimit = 10000000;\n this._history = [];\n this._activeTags = new Set();\n\n // send on enter / shift enter\n this.sendOnEnter = meta.sendOnEnter;\n this.sendOnShiftEnter = meta.sendOnShiftEnter;\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', (event) => { event.preventDefault(); 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\n // Check if Shift + Enter is pressed then we just do carraige\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n if (this.sendOnShiftEnter) {\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim());\n }\n } else if (event.keyCode === 13) {// Enter but not Shift + Enter\n if (this.sendOnEnter) {\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim());\n }\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 return true;\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 return true;\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, timestamp: false, updatedtime: false, scrollIntoView: true, visible: true, tags: [] }) {\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, 'quikchat-structure');\n\n if (Array.isArray(input.tags)) {\n input.tags.forEach(tag => {\n if (typeof tag === 'string' && /^[a-zA-Z0-9-]+$/.test(tag)) {\n messageDiv.classList.add(`quikchat-tag-${tag}`);\n this._activeTags.add(tag);\n }\n });\n }\n\n this.msgid++;\n\n const userDiv = document.createElement('div');\n userDiv.innerHTML = input.userString;\n userDiv.classList.add('quikchat-user-label');\n userDiv.style.textAlign = input.align;\n \n const contentDiv = document.createElement('div');\n contentDiv.classList.add('quikchat-message-content');\n \n // Determine text alignment for right-aligned messages\n if (input.align === \"right\") {\n const isMultiLine = input.content.includes(\"\\n\");\n const isLong = input.content.length > 50; // Adjust length threshold\n \n if (isMultiLine || isLong) {\n contentDiv.classList.add(\"quikchat-right-multiline\");\n } else {\n contentDiv.classList.add(\"quikchat-right-singleline\");\n }\n }\n \n contentDiv.innerHTML = input.content;\n \n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n \n const visible = input.visible === undefined ? true : input.visible;\n if (!visible) {\n messageDiv.style.display = 'none';\n }\n \n // Scroll to the last message only if the user is not actively scrolling up\n if ((!this.userScrolledUp) || input.scrollIntoView) {\n this.messageScrollToBottom();\n }\n \n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n this._handleShortLongMessageCSS(messageDiv, input.align); // Handle CSS for short/long messages\n this._updateMessageStyles();\n \n // Add timestamp now, unless it is passed in \n const timestamp = input.timestamp ? input.timestamp : new Date().toISOString();\n const updatedtime = input.updatedtime ? input.updatedtime : timestamp;\n \n if (this.trackHistory) {\n this._history.push({ msgid, ...input, visible, 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\n messageAddNew(content = \"\", userString = \"user\", align = \"right\", role = \"user\", scrollIntoView = true, visible = true, tags = []) {\n let retvalue = this.messageAddFull(\n { content: content, userString: userString, align: align, role: role, scrollIntoView: scrollIntoView, visible: visible, tags: tags }\n );\n // this.messageScrollToBottom();\n return retvalue;\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 /* returns the DOM Content element of a given message\n */\n messageGetContentDOMElement(n) {\n let contentElement = null;\n // now use css selector to get the message\n try {\n //contentElement = this._messagesArea.querySelector(`.quikchat-msgid-${String(n).padStart(10, '0')}`).lastChild;\n contentElement = this._history.filter((item) => item.msgid === n)[0].messageDiv.lastChild;\n }\n catch (error) {\n console.log(`{String(n)} : Message ID not found`);\n }\n return contentElement;\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 /**\n * Scrolls the messages area to the bottom.\n */\n messageScrollToBottom() {\n if (this._messagesArea.lastElementChild) {\n this._messagesArea.lastElementChild.scrollIntoView();\n }\n }\n\n /**\n * Removes the last message from the messages area.\n */\n messageRemoveLast() {\n // find the last message by id:\n if (this._history.length >= 0) {\n let lastMsgId = this._history[this._history.length - 1].msgid;\n return this.messageRemove(lastMsgId);\n }\n return false;\n }\n\n messageSetVisibility(msgid, isVisible) {\n const message = this._history.find(item => item.msgid === msgid);\n if (message && message.messageDiv) {\n message.messageDiv.style.display = isVisible ? '' : 'none';\n message.visible = isVisible;\n this._updateMessageStyles();\n return true;\n }\n return false;\n }\n\n messageGetVisibility(msgid) {\n const message = this._history.find(item => item.msgid === msgid);\n if (message && message.messageDiv) {\n return message.messageDiv.style.display !== 'none';\n }\n return false; // Return false if not found or no messageDiv\n }\n\n _updateMessageStyles() {\n const visibleMessages = [...this._messagesArea.children].filter(\n child => child.style.display !== 'none'\n );\n\n visibleMessages.forEach((messageDiv, index) => {\n messageDiv.classList.remove('quikchat-message-1', 'quikchat-message-2');\n messageDiv.classList.add(index % 2 === 0 ? 'quikchat-message-1' : 'quikchat-message-2');\n });\n }\n\n /**\n * For right sided or centered messages, we need to handle the CSS for short and long messages.\n * for short messages we use simple justifying, for long messages we need to wrap and perform multiline\n * formatting. \n * \n * @param {*} messageElement \n * @returns nothing\n */\n _handleShortLongMessageCSS(messageElement, align) {\n // console.log(messageElement);\n // Reset classes\n messageElement.classList.remove(\n 'left-singleline', 'left-multiline',\n 'center-singleline', 'center-multiline',\n 'right-singleline', 'right-multiline');\n let contentDiv = messageElement.lastChild;\n window.lastDiv = contentDiv; // for debugging \n // Determine if the message is short or long\n\n const computedStyle = window.getComputedStyle(contentDiv);\n\n // Get the element's height\n const elementHeight = contentDiv.offsetHeight;\n\n // Calculate or estimate line height\n let lineHeight;\n if (computedStyle.lineHeight === \"normal\") {\n const fontSize = parseFloat(computedStyle.fontSize);\n lineHeight = fontSize * 1.2; // approximate \"normal\" as 1.2 times font-size\n } else {\n lineHeight = parseFloat(computedStyle.lineHeight);\n }\n\n // Check if the element height is more than one line-height\n const isMultiLine = elementHeight > lineHeight;\n\n // Using scrollHeight and clientHeight to check for overflow (multi-line)\n switch (align) {\n case 'center':\n if (isMultiLine) {\n messageElement.classList.add('center-multiline');\n }\n else {\n messageElement.classList.add('center-singleline');\n }\n break;\n case 'right':\n if (isMultiLine) {\n messageElement.classList.add('right-multiline');\n }\n else {\n messageElement.classList.add('right-singleline');\n }\n break;\n case 'left':\n default:\n if (isMultiLine) {\n messageElement.classList.add('left-multiline');\n }\n else {\n messageElement.classList.add('left-singleline');\n }\n break;\n }\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 historyGetAllCopy() {\n return this._history.slice();\n }\n\n historyClear() {\n this.msgid = 0;\n this._messagesArea.innerHTML = \"\";\n this._history = [];\n this._activeTags.clear();\n }\n\n historyGetLength() {\n return this._history.length;\n }\n\n historyGetMessage(n) {\n if (n >= 0 && n < this._history.length) {\n return this._history[n];\n }\n return {};\n\n }\n\n historyGetMessageContent(n) {\n if (n >= 0 && n < this._history.length)\n return this._history[n].content;\n else\n return \"\";\n }\n\n // expects an array of messages to be in the format of the history object\n historyRestoreAll(messageList) {\n // clear all messages and history\n this.historyClear();\n\n // clear the messages div \n this._messagesArea.innerHTML = \"\";\n\n // add all messages\n messageList.forEach((message) => {\n this.messageAddFull(message);\n });\n }\n /**\n * \n * @param {string} newTheme \n */\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n\n /**\n * Get the current theme\n * @returns {string} - The current theme\n */\n get theme() {\n return this._theme;\n }\n\n /**\n * \n * @returns {object} - Returns the version and license information for the library.\n */\n static version() {\n return { \"version\": \"1.1.14\", \"license\": \"BSD-2\", \"url\": \"https://github/deftio/quikchat\", \"fun\": true };\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 static tempMessageGenerator (domElement, content, interval, cb = null) {\n interval = Math.max(interval, 100); // Ensure at least 100ms interval\n \n let count = 0;\n\n let defaultCB = (msg, count) => {msg += \".\"; return msg; };\n\n if (cb && typeof cb !== 'function') {\n cb = null;\n }\n\n cb = cb || defaultCB;\n \n // if its a string, then get the element (css sel) or its an DOM element already \n let el = domElement;\n if (typeof el === 'string') {\n el = document.querySelector(el);\n } \n\n const element = el;\n\n \n // Ensure the element exists\n if (!element) return;\n \n element.innerHTML = content;\n let currentMsg = content;\n \n const intervalId = setInterval(() => {\n if (element.innerHTML !== currentMsg) {\n clearInterval(intervalId); // Stop updating if content is changed externally\n return;\n }\n \n currentMsg = String( cb(currentMsg, count)) ;// Use callback return value if provided\n \n count++;\n element.innerHTML = currentMsg;\n }, interval);\n }\n\n static createTempMessageDOMStr(initialContent, updateInterval = 1000, callback = null, options = {}) {\n // Make sure the interval is at least 100ms\n updateInterval = Math.max(updateInterval, 100);\n \n // Validate callback; if not a function, ignore it.\n if (callback && typeof callback !== 'function') {\n callback = null;\n }\n // Default callback simply appends a dot.\n callback = callback || function(msg, count) {\n return msg + \".\";\n };\n \n // Allow an optional CSS class for the container element\n const containerClass = options.containerClass ? options.containerClass : '';\n \n // Generate a unique id so that the inline script can reliably find the container.\n const uniqueId = \"tempMsg_\" + Date.now() + \"_\" + Math.floor(Math.random() * 1000000);\n \n // Build and return the HTML string.\n // Note the use of <\\/script> (with a backslash) so that the inline script is not terminated early.\n return `\n <span id=\"${uniqueId}\" ${containerClass ? `class=\"${containerClass}\"` : ''}>\n ${initialContent}\n </span>\n <script>\n (function(){\n // Get our container element by its unique id.\n var container = document.getElementById(\"${uniqueId}\");\n if (!container) return;\n var count = 0;\n var currentMsg = container.innerHTML;\n var interval = ${updateInterval};\n // Convert the callback function into its string representation.\n var cb = ${callback.toString()};\n var intervalId = setInterval(function(){\n // If the content has been replaced, stop updating.\n if(container.innerHTML !== currentMsg){\n clearInterval(intervalId);\n return;\n }\n // Use the callback to generate the new message.\n currentMsg = String(cb(currentMsg, count));\n count++;\n container.innerHTML = currentMsg;\n }, interval);\n })();\n <\\/script>\n `;\n }\n \n setTagVisibility(tagName, isVisible) {\n if (typeof tagName !== 'string' || !/^[a-zA-Z0-9-]+$/.test(tagName)) {\n return false;\n }\n const className = `quikchat-show-tag-${tagName}`;\n if (isVisible) {\n this._chatWidget.classList.add(className);\n } else {\n this._chatWidget.classList.remove(className);\n }\n this._updateMessageStyles();\n return true;\n }\n\n getTagVisibility(tagName) {\n if (typeof tagName !== 'string' || !/^[a-zA-Z0-9-]+$/.test(tagName)) {\n return false;\n }\n return this._chatWidget.classList.contains(`quikchat-show-tag-${tagName}`);\n }\n\n getActiveTags() {\n return Array.from(this._activeTags);\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","inputArea","sendOnEnter","sendOnShiftEnter","instanceClass","document","querySelector","this","_parentElement","_theme","_onSend","_createWidget","_chatWidget","classList","add","titleAreaSetContents","titleAreaShow","titleAreaHide","messagesAreaAlternateColors","inputAreaShow","inputAreaHide","_attachEventListeners","_historyLimit","_history","_activeTags","Set","key","value","widgetHTML","concat","innerHTML","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","event","preventDefault","trim","window","_handleContainerResize","shiftKey","keyCode","_this$_messagesArea","scrollTop","scrollHeight","clientHeight","userScrolledUp","callback","_onMessageAdded","style","display","_adjustMessagesAreaHeight","textAlign","toggle","totalHiddenHeight","_toConsumableArray","children","filter","child","contains","reduce","sum","offsetHeight","containerHeight","height","_adjustSendButtonWidth","sendButtonText","textContent","minWidth","parseFloat","getComputedStyle","fontSize","alt","remove","_this2","input","content","userString","role","userID","timestamp","updatedtime","scrollIntoView","visible","tags","messageDiv","createElement","msgidClass","String","padStart","Array","isArray","forEach","tag","test","userDiv","contentDiv","isMultiLine","includes","isLong","appendChild","messageScrollToBottom","_handleShortLongMessageCSS","_updateMessageStyles","Date","toISOString","push","shift","messageAddFull","n","sucess","removeChild","error","console","log","splice","findIndex","item","msg","contentElement","lastChild","success","lastElementChild","lastMsgId","messageRemove","isVisible","message","find","index","messageElement","lastDiv","lineHeight","computedStyle","elementHeight","m","slice","clear","messageList","_this3","historyClear","newTheme","get","tagName","className","from","version","license","url","fun","numChars","startSpot","startWithCapitalLetter","loremText","Math","floor","random","l","substring","s","c","toUpperCase","domElement","interval","cb","max","count","el","element","currentMsg","intervalId","setInterval","clearInterval","initialContent","updateInterval","containerClass","uniqueId","now","toString"],"mappings":"02DAAMA,EAAQ,WA+DT,SAzDD,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,IAUMQ,EAAIC,EAAAA,EAAQC,CAAAA,EAVE,CAChBC,MAAO,uBACPC,cAAc,EACdC,UAAW,CAAEC,MAAO,OAAQC,MAAM,EAAOC,MAAO,UAChDC,aAAc,CAAEC,aAAa,GAC7BC,UAAW,CAAEJ,MAAM,GACnBK,aAAa,EACbC,kBAAkB,EAClBC,cAAe,KAEehB,GAEL,iBAAlBL,IACPA,EAAgBsB,SAASC,cAAcvB,IAG3CwB,KAAKC,eAAiBzB,EACtBwB,KAAKE,OAASnB,EAAKG,MACnBc,KAAKG,QAAU1B,GAAkB,WAAM,EACvCuB,KAAKI,gBAEDrB,EAAKc,eACLG,KAAKK,YAAYC,UAAUC,IAAIxB,EAAKc,eAIpCd,E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,EAAW,MAGbA,EAAWA,GAAY,SAASuE,EAAK+C,GACnC,OAAO/C,EAAM,KAIf,IAAMwD,EAAiB9L,EAAQ8L,eAAiB9L,EAAQ8L,eAAiB,GAGnEC,EAAW,WAAavE,KAAKwE,MAAQ,IAAMvB,KAAKC,MAAsB,IAAhBD,KAAKE,UAIjE,MAAA,yBAAAlI,OACcsJ,EAAQ,MAAAtJ,OAAKqJ,EAAcrJ,UAAAA,OAAaqJ,EAAoB,KAAA,sBAAErJ,OACtEmJ,EAAc,4LAAAnJ,OAK6BsJ,EAAQ,gKAAAtJ,OAIlCoJ,EAAcpJ,8GAAAA,OAEpBsB,EAASkI,WAAU,kjBAetC,gGAAC,CAxvBO"}
@@ -111,7 +111,8 @@
111
111
  show: true
112
112
  },
113
113
  sendOnEnter: true,
114
- sendOnShiftEnter: false
114
+ sendOnShiftEnter: false,
115
+ instanceClass: ''
115
116
  };
116
117
  var meta = _objectSpread2(_objectSpread2({}, defaultOpts), options); // merge options with defaults
117
118
 
@@ -123,6 +124,10 @@
123
124
  this._theme = meta.theme;
124
125
  this._onSend = onSend ? onSend : function () {}; // call back function for onSend
125
126
  this._createWidget();
127
+ if (meta.instanceClass) {
128
+ this._chatWidget.classList.add(meta.instanceClass);
129
+ }
130
+
126
131
  // title area
127
132
  if (meta.titleArea) {
128
133
  this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);
@@ -146,6 +151,7 @@
146
151
  this.trackHistory = meta.trackHistory || true;
147
152
  this._historyLimit = 10000000;
148
153
  this._history = [];
154
+ this._activeTags = new Set();
149
155
 
150
156
  // send on enter / shift enter
151
157
  this.sendOnEnter = meta.sendOnEnter;
@@ -323,6 +329,7 @@
323
329
  }, {
324
330
  key: "messageAddFull",
325
331
  value: function messageAddFull() {
332
+ var _this2 = this;
326
333
  var input = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
327
334
  content: "",
328
335
  userString: "user",
@@ -332,13 +339,22 @@
332
339
  timestamp: false,
333
340
  updatedtime: false,
334
341
  scrollIntoView: true,
335
- visible: true
342
+ visible: true,
343
+ tags: []
336
344
  };
337
345
  var msgid = this.msgid;
338
346
  var messageDiv = document.createElement('div');
339
347
  var msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');
340
348
  'quikchat-userid-' + String(input.userString).padStart(10, '0'); // hash this..
341
349
  messageDiv.classList.add('quikchat-message', msgidClass, 'quikchat-structure');
350
+ if (Array.isArray(input.tags)) {
351
+ input.tags.forEach(function (tag) {
352
+ if (typeof tag === 'string' && /^[a-zA-Z0-9-]+$/.test(tag)) {
353
+ messageDiv.classList.add("quikchat-tag-".concat(tag));
354
+ _this2._activeTags.add(tag);
355
+ }
356
+ });
357
+ }
342
358
  this.msgid++;
343
359
  var userDiv = document.createElement('div');
344
360
  userDiv.innerHTML = input.userString;
@@ -406,13 +422,15 @@
406
422
  var role = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : "user";
407
423
  var scrollIntoView = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;
408
424
  var visible = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : true;
425
+ var tags = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : [];
409
426
  var retvalue = this.messageAddFull({
410
427
  content: content,
411
428
  userString: userString,
412
429
  align: align,
413
430
  role: role,
414
431
  scrollIntoView: scrollIntoView,
415
- visible: visible
432
+ visible: visible,
433
+ tags: tags
416
434
  });
417
435
  // this.messageScrollToBottom();
418
436
  return retvalue;
@@ -697,6 +715,7 @@
697
715
  this.msgid = 0;
698
716
  this._messagesArea.innerHTML = "";
699
717
  this._history = [];
718
+ this._activeTags.clear();
700
719
  }
701
720
  }, {
702
721
  key: "historyGetLength",
@@ -721,7 +740,7 @@
721
740
  }, {
722
741
  key: "historyRestoreAll",
723
742
  value: function historyRestoreAll(messageList) {
724
- var _this2 = this;
743
+ var _this3 = this;
725
744
  // clear all messages and history
726
745
  this.historyClear();
727
746
 
@@ -730,7 +749,7 @@
730
749
 
731
750
  // add all messages
732
751
  messageList.forEach(function (message) {
733
- _this2.messageAddFull(message);
752
+ _this3.messageAddFull(message);
734
753
  });
735
754
  }
736
755
  /**
@@ -759,11 +778,39 @@
759
778
  *
760
779
  * @returns {object} - Returns the version and license information for the library.
761
780
  */
781
+ }, {
782
+ key: "setTagVisibility",
783
+ value: function setTagVisibility(tagName, isVisible) {
784
+ if (typeof tagName !== 'string' || !/^[a-zA-Z0-9-]+$/.test(tagName)) {
785
+ return false;
786
+ }
787
+ var className = "quikchat-show-tag-".concat(tagName);
788
+ if (isVisible) {
789
+ this._chatWidget.classList.add(className);
790
+ } else {
791
+ this._chatWidget.classList.remove(className);
792
+ }
793
+ this._updateMessageStyles();
794
+ return true;
795
+ }
796
+ }, {
797
+ key: "getTagVisibility",
798
+ value: function getTagVisibility(tagName) {
799
+ if (typeof tagName !== 'string' || !/^[a-zA-Z0-9-]+$/.test(tagName)) {
800
+ return false;
801
+ }
802
+ return this._chatWidget.classList.contains("quikchat-show-tag-".concat(tagName));
803
+ }
804
+ }, {
805
+ key: "getActiveTags",
806
+ value: function getActiveTags() {
807
+ return Array.from(this._activeTags);
808
+ }
762
809
  }], [{
763
810
  key: "version",
764
811
  value: function version() {
765
812
  return {
766
- "version": "1.1.13",
813
+ "version": "1.1.14",
767
814
  "license": "BSD-2",
768
815
  "url": "https://github/deftio/quikchat",
769
816
  "fun": true