@product7/product7-js 0.1.5 → 0.1.7
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/dist/product7-js.js +146 -3
- package/dist/product7-js.js.map +1 -1
- package/dist/product7-js.min.js +1 -1
- package/dist/product7-js.min.js.map +1 -1
- package/package.json +1 -1
- package/src/styles/messenger-components.js +43 -0
- package/src/styles/messenger-views.js +10 -2
- package/src/widgets/messenger/views/ChatView.js +93 -1
package/dist/product7-js.js
CHANGED
|
@@ -3880,6 +3880,49 @@
|
|
|
3880
3880
|
COMPOSE AREA
|
|
3881
3881
|
======================================== */
|
|
3882
3882
|
|
|
3883
|
+
/* ========================================
|
|
3884
|
+
EMOJI PICKER
|
|
3885
|
+
======================================== */
|
|
3886
|
+
|
|
3887
|
+
.messenger-emoji-picker-container {
|
|
3888
|
+
padding: 0 var(--spacing-3) var(--spacing-2);
|
|
3889
|
+
}
|
|
3890
|
+
|
|
3891
|
+
.messenger-emoji-picker-container emoji-picker {
|
|
3892
|
+
width: 100%;
|
|
3893
|
+
height: 320px;
|
|
3894
|
+
border-radius: var(--radius-xl);
|
|
3895
|
+
border: 1px solid var(--msg-border);
|
|
3896
|
+
box-shadow: var(--shadow-lg);
|
|
3897
|
+
|
|
3898
|
+
--background: var(--msg-bg);
|
|
3899
|
+
--border-color: var(--msg-border);
|
|
3900
|
+
--border-radius: 12px;
|
|
3901
|
+
--category-font-color: var(--msg-text-secondary);
|
|
3902
|
+
--category-font-size: 0.7rem;
|
|
3903
|
+
--emoji-size: 1.35rem;
|
|
3904
|
+
--emoji-padding: 0.3rem;
|
|
3905
|
+
--input-border-color: var(--msg-border);
|
|
3906
|
+
--input-border-radius: 8px;
|
|
3907
|
+
--input-font-color: var(--msg-text);
|
|
3908
|
+
--input-font-size: 0.8rem;
|
|
3909
|
+
--input-placeholder-color: var(--msg-text-tertiary);
|
|
3910
|
+
--input-padding: 0.375rem 0.625rem;
|
|
3911
|
+
--outline-color: var(--color-primary);
|
|
3912
|
+
--num-columns: 8;
|
|
3913
|
+
--indicator-color: var(--color-primary);
|
|
3914
|
+
--hover-background: var(--msg-bg-hover);
|
|
3915
|
+
}
|
|
3916
|
+
|
|
3917
|
+
.messenger-widget.theme-dark .messenger-emoji-picker-container emoji-picker {
|
|
3918
|
+
--background: var(--msg-bg);
|
|
3919
|
+
--border-color: var(--msg-border);
|
|
3920
|
+
--category-font-color: var(--msg-text-secondary);
|
|
3921
|
+
--input-font-color: var(--msg-text);
|
|
3922
|
+
--input-placeholder-color: var(--msg-text-tertiary);
|
|
3923
|
+
--hover-background: var(--msg-bg-hover);
|
|
3924
|
+
}
|
|
3925
|
+
|
|
3883
3926
|
.messenger-chat-compose {
|
|
3884
3927
|
display: flex;
|
|
3885
3928
|
flex-direction: column;
|
|
@@ -5285,11 +5328,19 @@
|
|
|
5285
5328
|
color: var(--msg-text-secondary);
|
|
5286
5329
|
}
|
|
5287
5330
|
|
|
5288
|
-
.messenger-help-collection-icon svg
|
|
5289
|
-
.messenger-help-collection-icon iconify-icon {
|
|
5331
|
+
.messenger-help-collection-icon svg {
|
|
5290
5332
|
width: 2rem;
|
|
5291
5333
|
height: 2rem;
|
|
5292
5334
|
display: block;
|
|
5335
|
+
flex-shrink: 0;
|
|
5336
|
+
}
|
|
5337
|
+
|
|
5338
|
+
.messenger-help-collection-icon iconify-icon {
|
|
5339
|
+
font-size: 2rem;
|
|
5340
|
+
width: 1em;
|
|
5341
|
+
height: 1em;
|
|
5342
|
+
display: block;
|
|
5343
|
+
flex-shrink: 0;
|
|
5293
5344
|
}
|
|
5294
5345
|
|
|
5295
5346
|
.messenger-help-collection-content {
|
|
@@ -9130,6 +9181,8 @@
|
|
|
9130
9181
|
this._typingIndicator = null;
|
|
9131
9182
|
this._isConversationClosed = false;
|
|
9132
9183
|
this._pendingAttachments = [];
|
|
9184
|
+
this._emojiPickerOpen = false;
|
|
9185
|
+
this._emojiOutsideHandler = null;
|
|
9133
9186
|
}
|
|
9134
9187
|
|
|
9135
9188
|
render() {
|
|
@@ -9250,7 +9303,7 @@
|
|
|
9250
9303
|
<button class="sdk-btn-icon messenger-compose-attach" aria-label="Attach file">
|
|
9251
9304
|
<iconify-icon icon="ph:paperclip-duotone" width="20" height="20"></iconify-icon>
|
|
9252
9305
|
</button>
|
|
9253
|
-
<button class="sdk-btn-icon" aria-label="Emoji">
|
|
9306
|
+
<button class="sdk-btn-icon messenger-emoji-btn" aria-label="Emoji">
|
|
9254
9307
|
<iconify-icon icon="ph:smiley-duotone" width="20" height="20"></iconify-icon>
|
|
9255
9308
|
</button>
|
|
9256
9309
|
</div>
|
|
@@ -9519,6 +9572,14 @@
|
|
|
9519
9572
|
});
|
|
9520
9573
|
}
|
|
9521
9574
|
|
|
9575
|
+
const emojiBtn = this.element.querySelector('.messenger-emoji-btn');
|
|
9576
|
+
if (emojiBtn) {
|
|
9577
|
+
emojiBtn.addEventListener('click', (e) => {
|
|
9578
|
+
e.stopPropagation();
|
|
9579
|
+
this._toggleEmojiPicker();
|
|
9580
|
+
});
|
|
9581
|
+
}
|
|
9582
|
+
|
|
9522
9583
|
const attachBtn = this.element.querySelector('.messenger-compose-attach');
|
|
9523
9584
|
const fileInput = this.element.querySelector(
|
|
9524
9585
|
'.messenger-compose-file-input'
|
|
@@ -9649,6 +9710,85 @@
|
|
|
9649
9710
|
this._updateSendButtonState();
|
|
9650
9711
|
}
|
|
9651
9712
|
|
|
9713
|
+
_loadEmojiPicker() {
|
|
9714
|
+
if (document.querySelector('#product7-emoji-picker-script')) {
|
|
9715
|
+
return Promise.resolve();
|
|
9716
|
+
}
|
|
9717
|
+
return new Promise((resolve, reject) => {
|
|
9718
|
+
const script = document.createElement('script');
|
|
9719
|
+
script.id = 'product7-emoji-picker-script';
|
|
9720
|
+
script.type = 'module';
|
|
9721
|
+
script.src =
|
|
9722
|
+
'https://cdn.jsdelivr.net/npm/emoji-picker-element@1/index.js';
|
|
9723
|
+
script.onload = resolve;
|
|
9724
|
+
script.onerror = reject;
|
|
9725
|
+
document.head.appendChild(script);
|
|
9726
|
+
});
|
|
9727
|
+
}
|
|
9728
|
+
|
|
9729
|
+
async _toggleEmojiPicker() {
|
|
9730
|
+
const existing = this.element.querySelector(
|
|
9731
|
+
'.messenger-emoji-picker-container'
|
|
9732
|
+
);
|
|
9733
|
+
if (existing) {
|
|
9734
|
+
existing.remove();
|
|
9735
|
+
this._emojiPickerOpen = false;
|
|
9736
|
+
if (this._emojiOutsideHandler) {
|
|
9737
|
+
document.removeEventListener('click', this._emojiOutsideHandler);
|
|
9738
|
+
this._emojiOutsideHandler = null;
|
|
9739
|
+
}
|
|
9740
|
+
return;
|
|
9741
|
+
}
|
|
9742
|
+
|
|
9743
|
+
try {
|
|
9744
|
+
await this._loadEmojiPicker();
|
|
9745
|
+
} catch {
|
|
9746
|
+
return;
|
|
9747
|
+
}
|
|
9748
|
+
|
|
9749
|
+
const container = document.createElement('div');
|
|
9750
|
+
container.className = 'messenger-emoji-picker-container';
|
|
9751
|
+
|
|
9752
|
+
const picker = document.createElement('emoji-picker');
|
|
9753
|
+
container.appendChild(picker);
|
|
9754
|
+
|
|
9755
|
+
const compose = this.element.querySelector('.messenger-chat-compose');
|
|
9756
|
+
compose.parentNode.insertBefore(container, compose);
|
|
9757
|
+
this._emojiPickerOpen = true;
|
|
9758
|
+
|
|
9759
|
+
picker.addEventListener('emoji-click', (e) => {
|
|
9760
|
+
this._insertEmoji(e.detail.unicode);
|
|
9761
|
+
container.remove();
|
|
9762
|
+
this._emojiPickerOpen = false;
|
|
9763
|
+
if (this._emojiOutsideHandler) {
|
|
9764
|
+
document.removeEventListener('click', this._emojiOutsideHandler);
|
|
9765
|
+
this._emojiOutsideHandler = null;
|
|
9766
|
+
}
|
|
9767
|
+
});
|
|
9768
|
+
|
|
9769
|
+
this._emojiOutsideHandler = (e) => {
|
|
9770
|
+
if (!container.contains(e.target) && !e.target.closest('.messenger-emoji-btn')) {
|
|
9771
|
+
container.remove();
|
|
9772
|
+
this._emojiPickerOpen = false;
|
|
9773
|
+
document.removeEventListener('click', this._emojiOutsideHandler);
|
|
9774
|
+
this._emojiOutsideHandler = null;
|
|
9775
|
+
}
|
|
9776
|
+
};
|
|
9777
|
+
setTimeout(() => document.addEventListener('click', this._emojiOutsideHandler), 0);
|
|
9778
|
+
}
|
|
9779
|
+
|
|
9780
|
+
_insertEmoji(emoji) {
|
|
9781
|
+
const input = this.element.querySelector('.messenger-compose-input');
|
|
9782
|
+
if (!input) return;
|
|
9783
|
+
const start = input.selectionStart;
|
|
9784
|
+
const end = input.selectionEnd;
|
|
9785
|
+
input.value =
|
|
9786
|
+
input.value.slice(0, start) + emoji + input.value.slice(end);
|
|
9787
|
+
input.selectionStart = input.selectionEnd = start + emoji.length;
|
|
9788
|
+
input.focus();
|
|
9789
|
+
input.dispatchEvent(new Event('input'));
|
|
9790
|
+
}
|
|
9791
|
+
|
|
9652
9792
|
_startTyping() {
|
|
9653
9793
|
if (this._isConversationClosed) return;
|
|
9654
9794
|
if (!this._isTyping && this.state.activeConversationId) {
|
|
@@ -9706,6 +9846,9 @@
|
|
|
9706
9846
|
clearTimeout(this._typingTimeout);
|
|
9707
9847
|
}
|
|
9708
9848
|
this._stopTyping();
|
|
9849
|
+
if (this._emojiOutsideHandler) {
|
|
9850
|
+
document.removeEventListener('click', this._emojiOutsideHandler);
|
|
9851
|
+
}
|
|
9709
9852
|
if (this.element && this.element.parentNode) {
|
|
9710
9853
|
this.element.parentNode.removeChild(this.element);
|
|
9711
9854
|
}
|