@product7/product7-js 0.7.0 → 0.7.3

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.
@@ -1464,10 +1464,10 @@
1464
1464
  if (_cached) return _cached;
1465
1465
 
1466
1466
  try {
1467
- const res = await fetch('https://ipwho.is/');
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.success) {
1470
+ if (data.ip) {
1471
1471
  _cached = data;
1472
1472
  }
1473
1473
  return _cached;
@@ -4333,87 +4333,26 @@
4333
4333
  .liveChat-feedback-body {
4334
4334
  display: flex;
4335
4335
  flex-direction: column;
4336
- gap: var(--spacing-4);
4336
+ gap: var(--spacing-3);
4337
4337
  padding: var(--spacing-5) var(--spacing-4);
4338
4338
  flex: 1;
4339
4339
  overflow-y: auto;
4340
4340
  }
4341
4341
 
4342
+ .liveChat-feedback-body .sdk-form-group {
4343
+ margin-bottom: 0;
4344
+ }
4345
+
4342
4346
  .liveChat-feedback-prompt {
4343
4347
  margin: 0;
4344
4348
  font-size: var(--font-size-sm);
4345
4349
  color: var(--text-secondary);
4346
4350
  }
4347
4351
 
4348
-
4349
- .liveChat-feedback-input {
4350
- width: 100%;
4351
- border: 1px solid var(--border-color);
4352
- border-radius: var(--radius-md);
4353
- padding: var(--spacing-3);
4354
- font-size: var(--font-size-sm);
4355
- font-family: inherit;
4356
- color: var(--text-primary);
4357
- background: var(--msg-bg);
4358
- box-sizing: border-box;
4359
- transition: border-color var(--transition-fast);
4360
- }
4361
-
4362
- .liveChat-feedback-input::placeholder {
4363
- color: var(--msg-text-secondary);
4364
- }
4365
-
4366
- .liveChat-feedback-input:focus {
4367
- outline: none;
4368
- border-color: var(--color-primary);
4369
- }
4370
-
4371
- .liveChat-feedback-textarea {
4372
- width: 100%;
4373
- resize: none;
4374
- border: 1px solid var(--border-color);
4375
- border-radius: var(--radius-md);
4376
- padding: var(--spacing-3);
4377
- font-size: var(--font-size-sm);
4378
- font-family: inherit;
4379
- color: var(--text-primary);
4380
- background: var(--msg-bg);
4381
- box-sizing: border-box;
4382
- transition: border-color var(--transition-fast);
4383
- }
4384
-
4385
- .liveChat-feedback-textarea::placeholder {
4386
- color: var(--msg-text-secondary);
4387
- }
4388
-
4389
- .liveChat-feedback-textarea:focus {
4390
- outline: none;
4391
- border-color: var(--color-primary);
4392
- }
4393
-
4394
- .liveChat-feedback-submit {
4395
- display: flex;
4396
- align-items: center;
4397
- justify-content: center;
4398
- padding: var(--spacing-3);
4399
- border-radius: var(--radius-md);
4400
- font-size: var(--font-size-sm);
4401
- font-weight: var(--font-weight-medium);
4402
- font-family: inherit;
4403
- cursor: pointer;
4404
- border: none;
4405
- background: var(--color-primary);
4406
- color: #ffffff;
4407
- transition: all var(--transition-fast);
4408
- }
4409
-
4410
- .liveChat-feedback-submit:hover:not(:disabled) {
4411
- background: var(--color-primary-hover);
4412
- }
4413
-
4414
- .liveChat-feedback-submit:disabled {
4415
- opacity: 0.5;
4416
- cursor: not-allowed;
4352
+ .liveChat-feedback-error {
4353
+ font-size: var(--font-size-xs);
4354
+ color: #ef4444;
4355
+ margin-top: calc(var(--spacing-2) * -1);
4417
4356
  }
4418
4357
 
4419
4358
  .liveChat-feedback-thankyou {
@@ -4427,9 +4366,15 @@
4427
4366
  gap: var(--spacing-3);
4428
4367
  }
4429
4368
 
4430
- .liveChat-feedback-thankyou-emoji {
4431
- font-size: 48px;
4432
- line-height: 1;
4369
+ .liveChat-feedback-success-icon {
4370
+ width: 56px;
4371
+ height: 56px;
4372
+ border-radius: 50%;
4373
+ background: #037F0C;
4374
+ display: flex;
4375
+ align-items: center;
4376
+ justify-content: center;
4377
+ margin-bottom: var(--spacing-2);
4433
4378
  }
4434
4379
 
4435
4380
  .liveChat-feedback-thankyou h3 {
@@ -11656,7 +11601,6 @@
11656
11601
  this.options = options;
11657
11602
  this.element = null;
11658
11603
  this._isSubmitting = false;
11659
- this._selectedRating = null;
11660
11604
  }
11661
11605
 
11662
11606
  render() {
@@ -11676,17 +11620,23 @@
11676
11620
  </div>
11677
11621
  <div class="liveChat-feedback-body">
11678
11622
  <p class="liveChat-feedback-prompt">Share your thoughts with us. We read every message.</p>
11679
- <input
11680
- type="text"
11681
- class="liveChat-feedback-input"
11682
- placeholder="Title"
11683
- />
11684
- <textarea
11685
- class="liveChat-feedback-textarea"
11686
- placeholder="Your feedback..."
11687
- rows="5"
11688
- ></textarea>
11689
- <button class="liveChat-feedback-submit">Send feedback</button>
11623
+ <div class="sdk-form-group">
11624
+ <label class="sdk-label">Title <span class="sdk-required">*</span></label>
11625
+ <input
11626
+ type="text"
11627
+ class="sdk-input liveChat-feedback-input"
11628
+ placeholder="Brief description of your feedback"
11629
+ />
11630
+ </div>
11631
+ <div class="sdk-form-group">
11632
+ <label class="sdk-label">Message <span class="sdk-required">*</span></label>
11633
+ <textarea
11634
+ class="sdk-textarea liveChat-feedback-textarea"
11635
+ placeholder="Tell us what you think..."
11636
+ ></textarea>
11637
+ </div>
11638
+ <span class="liveChat-feedback-error" style="display:none;"></span>
11639
+ <button class="sdk-btn-primary sdk-btn-block liveChat-feedback-submit">Send feedback</button>
11690
11640
  </div>
11691
11641
  `;
11692
11642
  this._attachEvents();
@@ -11701,9 +11651,13 @@
11701
11651
  <span class="liveChat-feedback-title">Leave us feedback</span>
11702
11652
  </div>
11703
11653
  <div class="liveChat-feedback-thankyou">
11704
- <span class="liveChat-feedback-thankyou-emoji">🙏</span>
11705
- <h3>Thanks for your feedback!</h3>
11706
- <p>We appreciate you taking the time to share your thoughts.</p>
11654
+ <div class="liveChat-feedback-success-icon">
11655
+ <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">
11656
+ <polyline points="216,72 96,192 40,136"/>
11657
+ </svg>
11658
+ </div>
11659
+ <h3>Thank you!</h3>
11660
+ <p>Your feedback has been submitted successfully.</p>
11707
11661
  <button class="liveChat-feedback-done-btn">Done</button>
11708
11662
  </div>
11709
11663
  `;
@@ -11729,7 +11683,36 @@
11729
11683
  });
11730
11684
  }
11731
11685
 
11686
+ _showError(text) {
11687
+ const errorEl = this.element.querySelector('.liveChat-feedback-error');
11688
+ if (errorEl) {
11689
+ errorEl.textContent = text;
11690
+ errorEl.style.display = 'block';
11691
+ }
11692
+ }
11693
+
11694
+ _hideError() {
11695
+ const errorEl = this.element.querySelector('.liveChat-feedback-error');
11696
+ if (errorEl) {
11697
+ errorEl.style.display = 'none';
11698
+ }
11699
+ }
11700
+
11732
11701
  async _submit(title, message) {
11702
+ this._hideError();
11703
+
11704
+ if (!title) {
11705
+ this._showError('Please enter a title.');
11706
+ this.element.querySelector('.liveChat-feedback-input').focus();
11707
+ return;
11708
+ }
11709
+
11710
+ if (!message) {
11711
+ this._showError('Please enter your feedback message.');
11712
+ this.element.querySelector('.liveChat-feedback-textarea').focus();
11713
+ return;
11714
+ }
11715
+
11733
11716
  this._isSubmitting = true;
11734
11717
  const submitBtn = this.element.querySelector('.liveChat-feedback-submit');
11735
11718
  if (submitBtn) {
@@ -11741,11 +11724,16 @@
11741
11724
  if (this.options.onSubmitFeedback) {
11742
11725
  await this.options.onSubmitFeedback({ title, message });
11743
11726
  }
11727
+ this._renderThankYou();
11744
11728
  } catch (e) {
11745
11729
  console.warn('[FeedbackFormView] Submit error:', e);
11730
+ this._isSubmitting = false;
11731
+ this._showError('Failed to submit feedback. Please try again.');
11732
+ if (submitBtn) {
11733
+ submitBtn.disabled = false;
11734
+ submitBtn.textContent = 'Send feedback';
11735
+ }
11746
11736
  }
11747
-
11748
- this._renderThankYou();
11749
11737
  }
11750
11738
 
11751
11739
  destroy() {
@@ -12013,6 +12001,24 @@
12013
12001
  }
12014
12002
  }
12015
12003
 
12004
+ async _handleSubmitFeedback({ title, message }) {
12005
+ const payload = {
12006
+ title: title || 'Feedback',
12007
+ content: message,
12008
+ board_id:
12009
+ this.liveChatOptions.feedbackBoardName || this.sdk.config.boardName,
12010
+ };
12011
+
12012
+ const response = await this.apiService.submitFeedback(payload);
12013
+
12014
+ this.sdk.eventBus.emit('feedback:submitted', {
12015
+ widget: this,
12016
+ feedback: response,
12017
+ });
12018
+
12019
+ return response;
12020
+ }
12021
+
12016
12022
  _render() {
12017
12023
  const container = document.createElement('div');
12018
12024
  container.className = `liveChat-widget theme-${this.liveChatOptions.theme}`;
@@ -12065,6 +12071,7 @@
12065
12071
  onFeedbackClick:
12066
12072
  this.liveChatOptions.onFeedbackClick ||
12067
12073
  (this._feedbackWidget ? () => this._feedbackWidget.open() : null),
12074
+ onSubmitFeedback: this._handleSubmitFeedback.bind(this),
12068
12075
  onArticleClick: this.liveChatOptions.onArticleClick,
12069
12076
  onChangelogClick: this.liveChatOptions.onChangelogClick,
12070
12077
  });