@product7/product7-js 0.7.0 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/product7-js.js +80 -11
- 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/liveChat-components.js +15 -3
- package/src/utils/getIpInfo.js +2 -2
- package/src/widgets/LiveChatWidget.js +19 -0
- package/src/widgets/liveChat/views/FeedbackFormView.js +44 -6
package/dist/product7-js.js
CHANGED
|
@@ -1464,10 +1464,10 @@
|
|
|
1464
1464
|
if (_cached) return _cached;
|
|
1465
1465
|
|
|
1466
1466
|
try {
|
|
1467
|
-
const res = await fetch('https://
|
|
1467
|
+
const res = await fetch('https://ipapi.co/json/');
|
|
1468
1468
|
if (!res.ok) return null;
|
|
1469
1469
|
const data = await res.json();
|
|
1470
|
-
if (data.
|
|
1470
|
+
if (data.ip) {
|
|
1471
1471
|
_cached = data;
|
|
1472
1472
|
}
|
|
1473
1473
|
return _cached;
|
|
@@ -4416,6 +4416,12 @@
|
|
|
4416
4416
|
cursor: not-allowed;
|
|
4417
4417
|
}
|
|
4418
4418
|
|
|
4419
|
+
.liveChat-feedback-error {
|
|
4420
|
+
font-size: var(--font-size-xs);
|
|
4421
|
+
color: #ef4444;
|
|
4422
|
+
margin-top: calc(var(--spacing-2) * -1);
|
|
4423
|
+
}
|
|
4424
|
+
|
|
4419
4425
|
.liveChat-feedback-thankyou {
|
|
4420
4426
|
display: flex;
|
|
4421
4427
|
flex-direction: column;
|
|
@@ -4427,9 +4433,15 @@
|
|
|
4427
4433
|
gap: var(--spacing-3);
|
|
4428
4434
|
}
|
|
4429
4435
|
|
|
4430
|
-
.liveChat-feedback-
|
|
4431
|
-
|
|
4432
|
-
|
|
4436
|
+
.liveChat-feedback-success-icon {
|
|
4437
|
+
width: 56px;
|
|
4438
|
+
height: 56px;
|
|
4439
|
+
border-radius: 50%;
|
|
4440
|
+
background: #037F0C;
|
|
4441
|
+
display: flex;
|
|
4442
|
+
align-items: center;
|
|
4443
|
+
justify-content: center;
|
|
4444
|
+
margin-bottom: var(--spacing-2);
|
|
4433
4445
|
}
|
|
4434
4446
|
|
|
4435
4447
|
.liveChat-feedback-thankyou h3 {
|
|
@@ -11656,7 +11668,6 @@
|
|
|
11656
11668
|
this.options = options;
|
|
11657
11669
|
this.element = null;
|
|
11658
11670
|
this._isSubmitting = false;
|
|
11659
|
-
this._selectedRating = null;
|
|
11660
11671
|
}
|
|
11661
11672
|
|
|
11662
11673
|
render() {
|
|
@@ -11686,6 +11697,7 @@
|
|
|
11686
11697
|
placeholder="Your feedback..."
|
|
11687
11698
|
rows="5"
|
|
11688
11699
|
></textarea>
|
|
11700
|
+
<span class="liveChat-feedback-error" style="display:none;"></span>
|
|
11689
11701
|
<button class="liveChat-feedback-submit">Send feedback</button>
|
|
11690
11702
|
</div>
|
|
11691
11703
|
`;
|
|
@@ -11701,9 +11713,13 @@
|
|
|
11701
11713
|
<span class="liveChat-feedback-title">Leave us feedback</span>
|
|
11702
11714
|
</div>
|
|
11703
11715
|
<div class="liveChat-feedback-thankyou">
|
|
11704
|
-
<
|
|
11705
|
-
|
|
11706
|
-
|
|
11716
|
+
<div class="liveChat-feedback-success-icon">
|
|
11717
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" fill="none" stroke="#ffffff" stroke-width="24" stroke-linecap="round" stroke-linejoin="round" viewBox="0 0 256 256">
|
|
11718
|
+
<polyline points="216,72 96,192 40,136"/>
|
|
11719
|
+
</svg>
|
|
11720
|
+
</div>
|
|
11721
|
+
<h3>Thank you!</h3>
|
|
11722
|
+
<p>Your feedback has been submitted successfully.</p>
|
|
11707
11723
|
<button class="liveChat-feedback-done-btn">Done</button>
|
|
11708
11724
|
</div>
|
|
11709
11725
|
`;
|
|
@@ -11729,7 +11745,36 @@
|
|
|
11729
11745
|
});
|
|
11730
11746
|
}
|
|
11731
11747
|
|
|
11748
|
+
_showError(text) {
|
|
11749
|
+
const errorEl = this.element.querySelector('.liveChat-feedback-error');
|
|
11750
|
+
if (errorEl) {
|
|
11751
|
+
errorEl.textContent = text;
|
|
11752
|
+
errorEl.style.display = 'block';
|
|
11753
|
+
}
|
|
11754
|
+
}
|
|
11755
|
+
|
|
11756
|
+
_hideError() {
|
|
11757
|
+
const errorEl = this.element.querySelector('.liveChat-feedback-error');
|
|
11758
|
+
if (errorEl) {
|
|
11759
|
+
errorEl.style.display = 'none';
|
|
11760
|
+
}
|
|
11761
|
+
}
|
|
11762
|
+
|
|
11732
11763
|
async _submit(title, message) {
|
|
11764
|
+
this._hideError();
|
|
11765
|
+
|
|
11766
|
+
if (!title) {
|
|
11767
|
+
this._showError('Please enter a title.');
|
|
11768
|
+
this.element.querySelector('.liveChat-feedback-input').focus();
|
|
11769
|
+
return;
|
|
11770
|
+
}
|
|
11771
|
+
|
|
11772
|
+
if (!message) {
|
|
11773
|
+
this._showError('Please enter your feedback message.');
|
|
11774
|
+
this.element.querySelector('.liveChat-feedback-textarea').focus();
|
|
11775
|
+
return;
|
|
11776
|
+
}
|
|
11777
|
+
|
|
11733
11778
|
this._isSubmitting = true;
|
|
11734
11779
|
const submitBtn = this.element.querySelector('.liveChat-feedback-submit');
|
|
11735
11780
|
if (submitBtn) {
|
|
@@ -11741,11 +11786,16 @@
|
|
|
11741
11786
|
if (this.options.onSubmitFeedback) {
|
|
11742
11787
|
await this.options.onSubmitFeedback({ title, message });
|
|
11743
11788
|
}
|
|
11789
|
+
this._renderThankYou();
|
|
11744
11790
|
} catch (e) {
|
|
11745
11791
|
console.warn('[FeedbackFormView] Submit error:', e);
|
|
11792
|
+
this._isSubmitting = false;
|
|
11793
|
+
this._showError('Failed to submit feedback. Please try again.');
|
|
11794
|
+
if (submitBtn) {
|
|
11795
|
+
submitBtn.disabled = false;
|
|
11796
|
+
submitBtn.textContent = 'Send feedback';
|
|
11797
|
+
}
|
|
11746
11798
|
}
|
|
11747
|
-
|
|
11748
|
-
this._renderThankYou();
|
|
11749
11799
|
}
|
|
11750
11800
|
|
|
11751
11801
|
destroy() {
|
|
@@ -12013,6 +12063,24 @@
|
|
|
12013
12063
|
}
|
|
12014
12064
|
}
|
|
12015
12065
|
|
|
12066
|
+
async _handleSubmitFeedback({ title, message }) {
|
|
12067
|
+
const payload = {
|
|
12068
|
+
title: title || 'Feedback',
|
|
12069
|
+
content: message,
|
|
12070
|
+
board_id:
|
|
12071
|
+
this.liveChatOptions.feedbackBoardName || this.sdk.config.boardName,
|
|
12072
|
+
};
|
|
12073
|
+
|
|
12074
|
+
const response = await this.apiService.submitFeedback(payload);
|
|
12075
|
+
|
|
12076
|
+
this.sdk.eventBus.emit('feedback:submitted', {
|
|
12077
|
+
widget: this,
|
|
12078
|
+
feedback: response,
|
|
12079
|
+
});
|
|
12080
|
+
|
|
12081
|
+
return response;
|
|
12082
|
+
}
|
|
12083
|
+
|
|
12016
12084
|
_render() {
|
|
12017
12085
|
const container = document.createElement('div');
|
|
12018
12086
|
container.className = `liveChat-widget theme-${this.liveChatOptions.theme}`;
|
|
@@ -12065,6 +12133,7 @@
|
|
|
12065
12133
|
onFeedbackClick:
|
|
12066
12134
|
this.liveChatOptions.onFeedbackClick ||
|
|
12067
12135
|
(this._feedbackWidget ? () => this._feedbackWidget.open() : null),
|
|
12136
|
+
onSubmitFeedback: this._handleSubmitFeedback.bind(this),
|
|
12068
12137
|
onArticleClick: this.liveChatOptions.onArticleClick,
|
|
12069
12138
|
onChangelogClick: this.liveChatOptions.onChangelogClick,
|
|
12070
12139
|
});
|