quikchat 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +23 -0
- package/README.md +107 -0
- package/dist/quikchat.cjs.js +298 -0
- package/dist/quikchat.cjs.js.map +1 -0
- package/dist/quikchat.cjs.min.js +2 -0
- package/dist/quikchat.cjs.min.js.map +1 -0
- package/dist/quikchat.css +219 -0
- package/dist/quikchat.esm.js +296 -0
- package/dist/quikchat.esm.js.map +1 -0
- package/dist/quikchat.esm.min.js +2 -0
- package/dist/quikchat.esm.min.js.map +1 -0
- package/dist/quikchat.umd.js +304 -0
- package/dist/quikchat.umd.js.map +1 -0
- package/dist/quikchat.umd.min.js +2 -0
- package/dist/quikchat.umd.min.js.map +1 -0
- package/package.json +33 -0
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
quikchat is Copyright (c) 2023-, M. A. Chatterjee <manu at deftio dot com>
|
|
2
|
+
All rights reserved.
|
|
3
|
+
|
|
4
|
+
Redistribution and use in source and binary forms, with or without
|
|
5
|
+
modification, are permitted provided that the following conditions are met:
|
|
6
|
+
|
|
7
|
+
* Redistributions of source code must retain the above copyright notice, this
|
|
8
|
+
list of conditions and the following disclaimer.
|
|
9
|
+
|
|
10
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
|
11
|
+
this list of conditions and the following disclaimer in the documentation
|
|
12
|
+
and/or other materials provided with the distribution.
|
|
13
|
+
|
|
14
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
15
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
16
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
17
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
18
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
19
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
20
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
21
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
22
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
23
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
# quikchat.js
|
|
2
|
+
quikchat is a simple vanilla (no dependancies) JavaScript chat control that can be easily integrated into web applications. It provides a customizable chat interface with support for hiding and showing a title area and the input area.
|
|
3
|
+
|
|
4
|
+
## Features
|
|
5
|
+
* Callback function for message events.
|
|
6
|
+
* Responsive design for various screen sizes.
|
|
7
|
+
* Themeable with css
|
|
8
|
+
* Hideable/Showable Title and Text Entry areas allows flexibility of usage
|
|
9
|
+
|
|
10
|
+
## Demo
|
|
11
|
+
[Example Code and Demo](https://deftio.github.io/quikchat/example.html)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
To use quikchat in your project, follow these steps:
|
|
16
|
+
|
|
17
|
+
Include the quikchat.js JavaScript file in your project.
|
|
18
|
+
Link the quikchat.css stylesheet to style the chat interface.
|
|
19
|
+
html
|
|
20
|
+
|
|
21
|
+
```html
|
|
22
|
+
<script src="./path/to/quikchat.umd.min.js"></script>
|
|
23
|
+
<link rel="stylesheet" href="./path/to/quikchat.css">
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Create a container element in your HTML where you want the chat interface to appear:
|
|
27
|
+
```html
|
|
28
|
+
<div id="chat-container"></div>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Initialize quikchat in your JavaScript code by providing the container element and a callback function for message events:
|
|
32
|
+
```javascript
|
|
33
|
+
const chat = new quikchat('#chat-container', messageCallback);
|
|
34
|
+
//Use the provided methods to interact with the chat control:
|
|
35
|
+
|
|
36
|
+
// Add a message
|
|
37
|
+
chat.addMessage('Hello!', 'User', 'left'); // user should appear left or right justified
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
## Theming
|
|
41
|
+
QuikChat also allows theming using CSS of all the messages, and user area, and overal widget.
|
|
42
|
+
|
|
43
|
+
Below is the prebuilt 'light' theme. To change the theme, make a new set of classes with different values but the same css selector naming (e.g. change "quikchat-theme-light" to "my-theme") and save as a style. Then pass the "my-theme" to the constructor.
|
|
44
|
+
|
|
45
|
+
Themes can be changed at anytime by calling
|
|
46
|
+
myChatWidget.changeTheme(newTheme) where myChatWidget is the instance of your widget.
|
|
47
|
+
|
|
48
|
+
If several widgets are on the same page, each can have a separate theme.
|
|
49
|
+
|
|
50
|
+
```css
|
|
51
|
+
|
|
52
|
+
.quikchat-theme-light {
|
|
53
|
+
border: 1px solid #cccccc;
|
|
54
|
+
border-radius: 10px;
|
|
55
|
+
padding: 5px;
|
|
56
|
+
background-color: #f9f9f9;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.quikchat-theme-light .quikchat-title-area {
|
|
60
|
+
color: #333;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
.quikchat-theme-light .quikchat-messages-area {
|
|
64
|
+
background-color: #ffffffe2;
|
|
65
|
+
color: #333;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.quikchat-theme-light .quikchat-message-1 {
|
|
69
|
+
background-color: #fffffff0;
|
|
70
|
+
color: #005662;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.quikchat-theme-light .quikchat-message-2 {
|
|
74
|
+
background-color: #eeeeeee9;
|
|
75
|
+
color: #353535;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.quikchat-theme-light .quikchat-input-area {
|
|
79
|
+
background-color: #f0f0f0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.quikchat-theme-light .quikchat-input-textbox {
|
|
83
|
+
background-color: #ffffff;
|
|
84
|
+
border: 1px solid #ccc;
|
|
85
|
+
border-radius: 4px;
|
|
86
|
+
font-size: 14px;
|
|
87
|
+
color: #333;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.quikchat-theme-light .quikchat-input-send-btn {
|
|
91
|
+
background-color: #4caf50;
|
|
92
|
+
color: white;
|
|
93
|
+
border: none;
|
|
94
|
+
border-radius: 4px;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## Building from Source
|
|
100
|
+
Make sure to run npm install. Then run npm run build.
|
|
101
|
+
Note that at run time quikchat has no dependancies, but at build time several tools are used for packing and minifying code.
|
|
102
|
+
|
|
103
|
+
## Contributors
|
|
104
|
+
|
|
105
|
+
## License
|
|
106
|
+
quikchat is licensed under the BSD-2 License.
|
|
107
|
+
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function _arrayLikeToArray(r, a) {
|
|
4
|
+
(null == a || a > r.length) && (a = r.length);
|
|
5
|
+
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
6
|
+
return n;
|
|
7
|
+
}
|
|
8
|
+
function _arrayWithoutHoles(r) {
|
|
9
|
+
if (Array.isArray(r)) return _arrayLikeToArray(r);
|
|
10
|
+
}
|
|
11
|
+
function _classCallCheck(a, n) {
|
|
12
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
13
|
+
}
|
|
14
|
+
function _defineProperties(e, r) {
|
|
15
|
+
for (var t = 0; t < r.length; t++) {
|
|
16
|
+
var o = r[t];
|
|
17
|
+
o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function _createClass(e, r, t) {
|
|
21
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
22
|
+
writable: !1
|
|
23
|
+
}), e;
|
|
24
|
+
}
|
|
25
|
+
function _iterableToArray(r) {
|
|
26
|
+
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
27
|
+
}
|
|
28
|
+
function _nonIterableSpread() {
|
|
29
|
+
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
30
|
+
}
|
|
31
|
+
function _toConsumableArray(r) {
|
|
32
|
+
return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
|
|
33
|
+
}
|
|
34
|
+
function _toPrimitive(t, r) {
|
|
35
|
+
if ("object" != typeof t || !t) return t;
|
|
36
|
+
var e = t[Symbol.toPrimitive];
|
|
37
|
+
if (void 0 !== e) {
|
|
38
|
+
var i = e.call(t, r );
|
|
39
|
+
if ("object" != typeof i) return i;
|
|
40
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
41
|
+
}
|
|
42
|
+
return (String )(t);
|
|
43
|
+
}
|
|
44
|
+
function _toPropertyKey(t) {
|
|
45
|
+
var i = _toPrimitive(t, "string");
|
|
46
|
+
return "symbol" == typeof i ? i : i + "";
|
|
47
|
+
}
|
|
48
|
+
function _unsupportedIterableToArray(r, a) {
|
|
49
|
+
if (r) {
|
|
50
|
+
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
51
|
+
var t = {}.toString.call(r).slice(8, -1);
|
|
52
|
+
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
// quikchat.js
|
|
57
|
+
var quikchat = /*#__PURE__*/function () {
|
|
58
|
+
function quikchat(parentElement) {
|
|
59
|
+
var meta = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
|
60
|
+
theme: 'quikchat-theme-light',
|
|
61
|
+
onSend: function onSend() {}
|
|
62
|
+
};
|
|
63
|
+
_classCallCheck(this, quikchat);
|
|
64
|
+
this._parentElement = parentElement;
|
|
65
|
+
this._theme = meta.theme;
|
|
66
|
+
this._onSend = meta.onSend ? meta.onSend : function () {};
|
|
67
|
+
this._createWidget();
|
|
68
|
+
// title area
|
|
69
|
+
if (meta.titleArea) {
|
|
70
|
+
this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);
|
|
71
|
+
if (meta.titleArea.show) {
|
|
72
|
+
this.titleAreaShow();
|
|
73
|
+
} else {
|
|
74
|
+
this.titleAreaHide();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
this._attachEventListeners();
|
|
78
|
+
}
|
|
79
|
+
return _createClass(quikchat, [{
|
|
80
|
+
key: "_createWidget",
|
|
81
|
+
value: function _createWidget() {
|
|
82
|
+
var widgetHTML = "\n <div class=\"quikchat-base ".concat(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 ");
|
|
83
|
+
this._parentElement.innerHTML = widgetHTML;
|
|
84
|
+
this._chatWidget = this._parentElement.querySelector('.quikchat-base');
|
|
85
|
+
this._titleArea = this._chatWidget.querySelector('.quikchat-title-area');
|
|
86
|
+
this._messagesArea = this._chatWidget.querySelector('.quikchat-messages-area');
|
|
87
|
+
this._inputArea = this._chatWidget.querySelector('.quikchat-input-area');
|
|
88
|
+
this._textEntry = this._inputArea.querySelector('.quikchat-input-textbox');
|
|
89
|
+
this._sendButton = this._inputArea.querySelector('.quikchat-input-send-btn');
|
|
90
|
+
this.msgid = 0;
|
|
91
|
+
}
|
|
92
|
+
}, {
|
|
93
|
+
key: "$",
|
|
94
|
+
value: function $() {}
|
|
95
|
+
}, {
|
|
96
|
+
key: "_attachEventListeners",
|
|
97
|
+
value: function _attachEventListeners() {
|
|
98
|
+
var _this = this;
|
|
99
|
+
this._sendButton.addEventListener('click', function () {
|
|
100
|
+
return _this._onSend(_this, _this._textEntry.value.trim());
|
|
101
|
+
});
|
|
102
|
+
window.addEventListener('resize', function () {
|
|
103
|
+
return _this._handleContainerResize();
|
|
104
|
+
});
|
|
105
|
+
this._chatWidget.addEventListener('resize', function () {
|
|
106
|
+
return _this._handleContainerResize();
|
|
107
|
+
});
|
|
108
|
+
this._textEntry.addEventListener('keydown', function (event) {
|
|
109
|
+
// Check if Shift + Enter is pressed
|
|
110
|
+
if (event.shiftKey && event.keyCode === 13) {
|
|
111
|
+
// Prevent default behavior (adding new line)
|
|
112
|
+
event.preventDefault();
|
|
113
|
+
_this._onSend(_this, _this._textEntry.value.trim());
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
}, {
|
|
118
|
+
key: "titleAreaToggle",
|
|
119
|
+
value: function titleAreaToggle() {
|
|
120
|
+
this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();
|
|
121
|
+
}
|
|
122
|
+
}, {
|
|
123
|
+
key: "titleAreaShow",
|
|
124
|
+
value: function titleAreaShow() {
|
|
125
|
+
this._titleArea.style.display = '';
|
|
126
|
+
this._adjustMessagesAreaHeight();
|
|
127
|
+
}
|
|
128
|
+
}, {
|
|
129
|
+
key: "titleAreaHide",
|
|
130
|
+
value: function titleAreaHide() {
|
|
131
|
+
this._titleArea.style.display = 'none';
|
|
132
|
+
this._adjustMessagesAreaHeight();
|
|
133
|
+
}
|
|
134
|
+
}, {
|
|
135
|
+
key: "titleAreaSetContents",
|
|
136
|
+
value: function titleAreaSetContents(title) {
|
|
137
|
+
var align = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'center';
|
|
138
|
+
this._titleArea.innerHTML = title;
|
|
139
|
+
this._titleArea.style.textAlign = align;
|
|
140
|
+
}
|
|
141
|
+
}, {
|
|
142
|
+
key: "titleAreaGetContents",
|
|
143
|
+
value: function titleAreaGetContents() {
|
|
144
|
+
return this._titleArea.innerHTML;
|
|
145
|
+
}
|
|
146
|
+
}, {
|
|
147
|
+
key: "inputAreaToggle",
|
|
148
|
+
value: function inputAreaToggle() {
|
|
149
|
+
this._inputArea.classList.toggle('hidden');
|
|
150
|
+
this._inputArea.style.display === 'none' ? this.inputAreaShow() : this.inputAreaHide();
|
|
151
|
+
}
|
|
152
|
+
}, {
|
|
153
|
+
key: "inputAreaShow",
|
|
154
|
+
value: function inputAreaShow() {
|
|
155
|
+
this._inputArea.style.display = '';
|
|
156
|
+
this._adjustMessagesAreaHeight();
|
|
157
|
+
}
|
|
158
|
+
}, {
|
|
159
|
+
key: "inputAreaHide",
|
|
160
|
+
value: function inputAreaHide() {
|
|
161
|
+
this._inputArea.style.display = 'none';
|
|
162
|
+
this._adjustMessagesAreaHeight();
|
|
163
|
+
}
|
|
164
|
+
}, {
|
|
165
|
+
key: "_adjustMessagesAreaHeight",
|
|
166
|
+
value: function _adjustMessagesAreaHeight() {
|
|
167
|
+
var hiddenElements = _toConsumableArray(this._chatWidget.children).filter(function (child) {
|
|
168
|
+
return child.classList.contains('hidden');
|
|
169
|
+
});
|
|
170
|
+
var totalHiddenHeight = hiddenElements.reduce(function (sum, child) {
|
|
171
|
+
return sum + child.offsetHeight;
|
|
172
|
+
}, 0);
|
|
173
|
+
var containerHeight = this._chatWidget.offsetHeight;
|
|
174
|
+
this._messagesArea.style.height = "calc(100% - ".concat(containerHeight - totalHiddenHeight, "px)");
|
|
175
|
+
}
|
|
176
|
+
}, {
|
|
177
|
+
key: "_handleContainerResize",
|
|
178
|
+
value: function _handleContainerResize() {
|
|
179
|
+
this._adjustMessagesAreaHeight();
|
|
180
|
+
this._adjustSendButtonWidth();
|
|
181
|
+
//console.log('Container resized');
|
|
182
|
+
}
|
|
183
|
+
}, {
|
|
184
|
+
key: "_adjustSendButtonWidth",
|
|
185
|
+
value: function _adjustSendButtonWidth() {
|
|
186
|
+
var sendButtonText = this._sendButton.textContent.trim();
|
|
187
|
+
var fontSize = parseFloat(getComputedStyle(this._sendButton).fontSize);
|
|
188
|
+
var minWidth = fontSize * sendButtonText.length + 16;
|
|
189
|
+
this._sendButton.style.minWidth = "".concat(minWidth, "px");
|
|
190
|
+
}
|
|
191
|
+
}, {
|
|
192
|
+
key: "messageAddNew",
|
|
193
|
+
value: function messageAddNew(message) {
|
|
194
|
+
var user = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "foo";
|
|
195
|
+
var align = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 'left';
|
|
196
|
+
var messageDiv = document.createElement('div');
|
|
197
|
+
var msgid = this.msgid;
|
|
198
|
+
var msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');
|
|
199
|
+
messageDiv.classList.add('quikchat-message', msgidClass);
|
|
200
|
+
this.msgid++;
|
|
201
|
+
messageDiv.classList.add(this._messagesArea.children.length % 2 === 1 ? 'quikchat-message-1' : 'quikchat-message-2');
|
|
202
|
+
var userDiv = document.createElement('div');
|
|
203
|
+
userDiv.innerHTML = user;
|
|
204
|
+
userDiv.style = "width: 100%; text-align: ".concat(align, "; font-size: 1em; font-weight:700; color: #444;");
|
|
205
|
+
var contentDiv = document.createElement('div');
|
|
206
|
+
contentDiv.style = "width: 100%; text-align: ".concat(align, ";");
|
|
207
|
+
contentDiv.innerHTML = message;
|
|
208
|
+
messageDiv.appendChild(userDiv);
|
|
209
|
+
messageDiv.appendChild(contentDiv);
|
|
210
|
+
this._messagesArea.appendChild(messageDiv);
|
|
211
|
+
this._messagesArea.lastChild.scrollIntoView();
|
|
212
|
+
this._textEntry.value = '';
|
|
213
|
+
this._adjustMessagesAreaHeight();
|
|
214
|
+
return {
|
|
215
|
+
msgid: msgid
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
}, {
|
|
219
|
+
key: "messageRemove",
|
|
220
|
+
value: function messageRemove(n) {
|
|
221
|
+
// use css selector to remove the message
|
|
222
|
+
var sucess = false;
|
|
223
|
+
try {
|
|
224
|
+
this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))));
|
|
225
|
+
sucess = true;
|
|
226
|
+
} catch (error) {
|
|
227
|
+
console.log("{String(n)} : Message ID not found");
|
|
228
|
+
}
|
|
229
|
+
return sucess;
|
|
230
|
+
}
|
|
231
|
+
/* returns the message html object from the DOM
|
|
232
|
+
*/
|
|
233
|
+
}, {
|
|
234
|
+
key: "messageGetDOMObject",
|
|
235
|
+
value: function messageGetDOMObject(n) {
|
|
236
|
+
var msg = null;
|
|
237
|
+
// now use css selector to get the message
|
|
238
|
+
try {
|
|
239
|
+
msg = this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0')));
|
|
240
|
+
} catch (error) {
|
|
241
|
+
console.log("{String(n)} : Message ID not found");
|
|
242
|
+
}
|
|
243
|
+
return msg;
|
|
244
|
+
}
|
|
245
|
+
/* returns the message content only
|
|
246
|
+
*/
|
|
247
|
+
}, {
|
|
248
|
+
key: "messageGetContent",
|
|
249
|
+
value: function messageGetContent(n) {
|
|
250
|
+
var content = "";
|
|
251
|
+
// now use css selector to get the message
|
|
252
|
+
try {
|
|
253
|
+
content = this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))).lastChild.textContent;
|
|
254
|
+
} catch (error) {
|
|
255
|
+
console.log("{String(n)} : Message ID not found");
|
|
256
|
+
}
|
|
257
|
+
return content;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/* append message to the message content
|
|
261
|
+
*/
|
|
262
|
+
}, {
|
|
263
|
+
key: "messageAppendContent",
|
|
264
|
+
value: function messageAppendContent(n, content) {
|
|
265
|
+
var sucess = false;
|
|
266
|
+
try {
|
|
267
|
+
this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))).lastChild.innerHTML += content;
|
|
268
|
+
sucess = true;
|
|
269
|
+
} catch (error) {
|
|
270
|
+
console.log("{String(n)} : Message ID not found");
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
/* replace message content
|
|
274
|
+
*/
|
|
275
|
+
}, {
|
|
276
|
+
key: "messageReplaceContent",
|
|
277
|
+
value: function messageReplaceContent(n, content) {
|
|
278
|
+
var sucess = false;
|
|
279
|
+
try {
|
|
280
|
+
this._messagesArea.querySelector(".quikchat-msgid-".concat(String(n).padStart(10, '0'))).lastChild.innerHTML = content;
|
|
281
|
+
sucess = true;
|
|
282
|
+
} catch (error) {
|
|
283
|
+
console.log("{String(n)} : Message ID not found");
|
|
284
|
+
}
|
|
285
|
+
return sucess;
|
|
286
|
+
}
|
|
287
|
+
}, {
|
|
288
|
+
key: "changeTheme",
|
|
289
|
+
value: function changeTheme(newTheme) {
|
|
290
|
+
this._chatWidget.classList.remove(this._theme);
|
|
291
|
+
this._chatWidget.classList.add(newTheme);
|
|
292
|
+
this._theme = newTheme;
|
|
293
|
+
}
|
|
294
|
+
}]);
|
|
295
|
+
}();
|
|
296
|
+
|
|
297
|
+
module.exports = quikchat;
|
|
298
|
+
//# sourceMappingURL=quikchat.cjs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quikchat.cjs.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <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 _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n 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 messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\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 = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\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 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 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 sucess = true;\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 sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","_createClass","key","value","widgetHTML","concat","innerHTML","_chatWidget","querySelector","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","$","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","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","messageAddNew","message","user","messageDiv","document","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","messageRemove","n","sucess","removeChild","error","console","log","messageGetDOMObject","msg","messageGetContent","content","messageAppendContent","messageReplaceContent","changeTheme","newTheme","remove"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,IAEMA,QAAQ,gBAAA,YAAA;EACV,SAAAA,QAAAA,CAAYC,aAAa,EAA+D;IAAA,IAA7DC,IAAI,GAAAC,SAAA,CAAAC,MAAA,GAAAD,CAAAA,IAAAA,SAAA,CAAAE,CAAAA,CAAAA,KAAAA,SAAA,GAAAF,SAAA,CAAG,CAAA,CAAA,GAAA;AAAEG,MAAAA,KAAK,EAAE,sBAAsB;AAAEC,MAAAA,MAAM,EAAE,SAAAA,MAAA,GAAM,EAAE;KAAG,CAAA;AAAAC,IAAAA,eAAA,OAAAR,QAAA,CAAA,CAAA;IAClF,IAAI,CAACS,cAAc,GAAGR,aAAa,CAAA;AACnC,IAAA,IAAI,CAACS,MAAM,GAAGR,IAAI,CAACI,KAAK,CAAA;AACxB,IAAA,IAAI,CAACK,OAAO,GAAGT,IAAI,CAACK,MAAM,GAAGL,IAAI,CAACK,MAAM,GAAG,YAAM,EAAG,CAAA;IACpD,IAAI,CAACK,aAAa,EAAE,CAAA;AACpB;IACA,IAAIV,IAAI,CAACW,SAAS,EAAE;AAChB,MAAA,IAAI,CAACC,oBAAoB,CAACZ,IAAI,CAACW,SAAS,CAACE,KAAK,EAAEb,IAAI,CAACW,SAAS,CAACG,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OAAO,CAACC,GAAG,CAAA,oCAAqC,CAAC,CAAA;AACrD,OAAA;AACA,MAAA,OAAOJ,MAAM,CAAA;AACjB,KAAA;AAAC,GAAA,EAAA;IAAAtE,GAAA,EAAA,aAAA;AAAAC,IAAAA,KAAA,EAED,SAAAgF,WAAYC,CAAAA,QAAQ,EAAE;MAClB,IAAI,CAAC7E,WAAW,CAACyB,SAAS,CAACqD,MAAM,CAAC,IAAI,CAAC/F,MAAM,CAAC,CAAA;MAC9C,IAAI,CAACiB,WAAW,CAACyB,SAAS,CAACgC,GAAG,CAACoB,QAAQ,CAAC,CAAA;MACxC,IAAI,CAAC9F,MAAM,GAAG8F,QAAQ,CAAA;AAC1B,KAAA;AAAC,GAAA,CAAA,CAAA,CAAA;AAAA,CAAA;;;;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n<e;n++)i[n]=t[n];return i}function e(t,e,n){return e&&function(t,e){for(var n=0;n<e.length;n++){var a=e[n];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,i(a.key),a)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}function n(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||function(e,n){if(e){if("string"==typeof e)return t(e,n);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}var a=function(){return e((function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{theme:"quikchat-theme-light",onSend:function(){}};!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._parentElement=e,this._theme=n.theme,this._onSend=n.onSend?n.onSend:function(){},this._createWidget(),n.titleArea&&(this.titleAreaSetContents(n.titleArea.title,n.titleArea.align),n.titleArea.show?this.titleAreaShow():this.titleAreaHide()),this._attachEventListeners()}),[{key:"_createWidget",value:function(){var t='\n <div class="quikchat-base '.concat(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 ');this._parentElement.innerHTML=t,this._chatWidget=this._parentElement.querySelector(".quikchat-base"),this._titleArea=this._chatWidget.querySelector(".quikchat-title-area"),this._messagesArea=this._chatWidget.querySelector(".quikchat-messages-area"),this._inputArea=this._chatWidget.querySelector(".quikchat-input-area"),this._textEntry=this._inputArea.querySelector(".quikchat-input-textbox"),this._sendButton=this._inputArea.querySelector(".quikchat-input-send-btn"),this.msgid=0}},{key:"$",value:function(){}},{key:"_attachEventListeners",value:function(){var t=this;this._sendButton.addEventListener("click",(function(){return t._onSend(t,t._textEntry.value.trim())})),window.addEventListener("resize",(function(){return t._handleContainerResize()})),this._chatWidget.addEventListener("resize",(function(){return t._handleContainerResize()})),this._textEntry.addEventListener("keydown",(function(e){e.shiftKey&&13===e.keyCode&&(e.preventDefault(),t._onSend(t,t._textEntry.value.trim()))}))}},{key:"titleAreaToggle",value:function(){"none"===this._titleArea.style.display?this.titleAreaShow():this.titleAreaHide()}},{key:"titleAreaShow",value:function(){this._titleArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"titleAreaHide",value:function(){this._titleArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"titleAreaSetContents",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"center";this._titleArea.innerHTML=t,this._titleArea.style.textAlign=e}},{key:"titleAreaGetContents",value:function(){return this._titleArea.innerHTML}},{key:"inputAreaToggle",value:function(){this._inputArea.classList.toggle("hidden"),"none"===this._inputArea.style.display?this.inputAreaShow():this.inputAreaHide()}},{key:"inputAreaShow",value:function(){this._inputArea.style.display="",this._adjustMessagesAreaHeight()}},{key:"inputAreaHide",value:function(){this._inputArea.style.display="none",this._adjustMessagesAreaHeight()}},{key:"_adjustMessagesAreaHeight",value:function(){var t=n(this._chatWidget.children).filter((function(t){return t.classList.contains("hidden")})).reduce((function(t,e){return t+e.offsetHeight}),0),e=this._chatWidget.offsetHeight;this._messagesArea.style.height="calc(100% - ".concat(e-t,"px)")}},{key:"_handleContainerResize",value:function(){this._adjustMessagesAreaHeight(),this._adjustSendButtonWidth()}},{key:"_adjustSendButtonWidth",value:function(){var t=this._sendButton.textContent.trim(),e=parseFloat(getComputedStyle(this._sendButton).fontSize)*t.length+16;this._sendButton.style.minWidth="".concat(e,"px")}},{key:"messageAddNew",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"foo",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left",i=document.createElement("div"),a=this.msgid,s="quikchat-msgid-"+String(a).padStart(10,"0");i.classList.add("quikchat-message",s),this.msgid++,i.classList.add(this._messagesArea.children.length%2==1?"quikchat-message-1":"quikchat-message-2");var r=document.createElement("div");r.innerHTML=e,r.style="width: 100%; text-align: ".concat(n,"; font-size: 1em; font-weight:700; color: #444;");var o=document.createElement("div");return o.style="width: 100%; text-align: ".concat(n,";"),o.innerHTML=t,i.appendChild(r),i.appendChild(o),this._messagesArea.appendChild(i),this._messagesArea.lastChild.scrollIntoView(),this._textEntry.value="",this._adjustMessagesAreaHeight(),{msgid:a}}},{key:"messageRemove",value:function(t){var e=!1;try{this._messagesArea.removeChild(this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))),e=!0}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetDOMObject",value:function(t){var e=null;try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0")))}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageGetContent",value:function(t){var e="";try{e=this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.textContent}catch(t){console.log("{String(n)} : Message ID not found")}return e}},{key:"messageAppendContent",value:function(t,e){try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML+=e,!0}catch(t){console.log("{String(n)} : Message ID not found")}}},{key:"messageReplaceContent",value:function(t,e){var n=!1;try{this._messagesArea.querySelector(".quikchat-msgid-".concat(String(t).padStart(10,"0"))).lastChild.innerHTML=e,n=!0}catch(t){console.log("{String(n)} : Message ID not found")}return n}},{key:"changeTheme",value:function(t){this._chatWidget.classList.remove(this._theme),this._chatWidget.classList.add(t),this._theme=t}}])}();module.exports=a;
|
|
2
|
+
//# sourceMappingURL=quikchat.cjs.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"quikchat.cjs.min.js","sources":["../src/quikchat.js"],"sourcesContent":["// quikchat.js\n\nclass quikchat {\n constructor(parentElement, meta = { theme: 'quikchat-theme-light', onSend: () => { } }) {\n this._parentElement = parentElement;\n this._theme = meta.theme;\n this._onSend = meta.onSend ? meta.onSend : () => { };\n this._createWidget();\n // title area\n if (meta.titleArea) {\n this.titleAreaSetContents(meta.titleArea.title, meta.titleArea.align);\n if (meta.titleArea.show) {\n this.titleAreaShow();\n } else {\n this.titleAreaHide();\n }\n }\n this._attachEventListeners();\n }\n\n _createWidget() {\n const widgetHTML =\n `\n <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 _attachEventListeners() {\n this._sendButton.addEventListener('click', () => this._onSend(this, this._textEntry.value.trim()));\n window.addEventListener('resize', () => this._handleContainerResize());\n this._chatWidget.addEventListener('resize', () => this._handleContainerResize());\n this._textEntry.addEventListener('keydown', (event) => {\n // Check if Shift + Enter is pressed\n if (event.shiftKey && event.keyCode === 13) {\n // Prevent default behavior (adding new line)\n event.preventDefault();\n this._onSend(this, this._textEntry.value.trim())\n }\n });\n }\n\n titleAreaToggle() {\n this._titleArea.style.display === 'none' ? this.titleAreaShow() : this.titleAreaHide();\n }\n\n titleAreaShow() {\n this._titleArea.style.display = '';\n this._adjustMessagesAreaHeight();\n }\n\n titleAreaHide() {\n this._titleArea.style.display = 'none';\n this._adjustMessagesAreaHeight();\n }\n\n 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 messageAddNew(message, user = \"foo\", align = 'left') {\n const messageDiv = document.createElement('div');\n const msgid = this.msgid;\n const msgidClass = 'quikchat-msgid-' + String(msgid).padStart(10, '0');\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 = user;\n userDiv.style = `width: 100%; text-align: ${align}; font-size: 1em; font-weight:700; color: #444;`;\n\n const contentDiv = document.createElement('div');\n contentDiv.style = `width: 100%; text-align: ${align};`;\n contentDiv.innerHTML = message;\n\n messageDiv.appendChild(userDiv);\n messageDiv.appendChild(contentDiv);\n this._messagesArea.appendChild(messageDiv);\n this._messagesArea.lastChild.scrollIntoView();\n\n this._textEntry.value = '';\n this._adjustMessagesAreaHeight();\n return {msgid};\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 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 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 sucess = true;\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 sucess = true;\n } \n catch (error) \n {\n console.log(`{String(n)} : Message ID not found`);\n }\n return sucess;\n }\n\n changeTheme(newTheme) {\n this._chatWidget.classList.remove(this._theme);\n this._chatWidget.classList.add(newTheme);\n this._theme = newTheme;\n }\n}\n\nexport default quikchat;\n"],"names":["quikchat","_createClass","parentElement","meta","arguments","length","undefined","theme","onSend","_classCallCheck","this","_parentElement","_theme","_onSend","_createWidget","titleArea","titleAreaSetContents","title","align","show","titleAreaShow","titleAreaHide","_attachEventListeners","key","value","widgetHTML","concat","innerHTML","_chatWidget","querySelector","_titleArea","_messagesArea","_inputArea","_textEntry","_sendButton","msgid","_this","addEventListener","trim","window","_handleContainerResize","event","shiftKey","keyCode","preventDefault","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","message","user","messageDiv","document","createElement","msgidClass","String","padStart","add","userDiv","contentDiv","appendChild","lastChild","scrollIntoView","n","sucess","removeChild","error","console","log","msg","content","newTheme","remove"],"mappings":"sxCAAA,IAEMA,EAAQ,WAgBT,OAAAC,GAfD,SAAAD,EAAYE,GAA4E,IAA7DC,EAAIC,UAAAC,OAAAD,QAAAE,IAAAF,UAAAE,GAAAF,UAAG,GAAA,CAAEG,MAAO,uBAAwBC,OAAQ,WAAQ,gGAAGC,MAAAT,GAClFU,KAAKC,eAAiBT,EACtBQ,KAAKE,OAAST,EAAKI,MACnBG,KAAKG,QAAUV,EAAKK,OAASL,EAAKK,OAAS,aAC3CE,KAAKI,gBAEDX,EAAKY,YACLL,KAAKM,qBAAqBb,EAAKY,UAAUE,MAAOd,EAAKY,UAAUG,OAC3Df,EAAKY,UAAUI,KACfT,KAAKU,gBAELV,KAAKW,iBAGbX,KAAKY,uBACT,GAAC,CAAA,CAAAC,IAAA,gBAAAC,MAED,WACI,IAAMC,EAAUC,2CAAAA,OAEgBhB,KAAKH,MAUhC,weAELG,KAAKC,eAAegB,UAAYF,EAChCf,KAAKkB,YAAclB,KAAKC,eAAekB,cAAc,kBACrDnB,KAAKoB,WAAapB,KAAKkB,YAAYC,cAAc,wBACjDnB,KAAKqB,cAAgBrB,KAAKkB,YAAYC,cAAc,2BACpDnB,KAAKsB,WAAatB,KAAKkB,YAAYC,cAAc,wBACjDnB,KAAKuB,WAAavB,KAAKsB,WAAWH,cAAc,2BAChDnB,KAAKwB,YAAcxB,KAAKsB,WAAWH,cAAc,4BACjDnB,KAAKyB,MAAQ,CACjB,GAAC,CAAAZ,IAAA,IAAAC,MACD,WACA,GAAC,CAAAD,IAAA,wBAAAC,MACD,WAAwB,IAAAY,EAAA1B,KACpBA,KAAKwB,YAAYG,iBAAiB,SAAS,WAAA,OAAMD,EAAKvB,QAAQuB,EAAMA,EAAKH,WAAWT,MAAMc,WAC1FC,OAAOF,iBAAi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