@product7/product7-js 0.2.1 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@product7/product7-js",
3
- "version": "0.2.1",
3
+ "version": "0.2.4",
4
4
  "description": "JavaScript SDK for integrating Product7 feedback widgets into any website",
5
5
  "main": "dist/product7-js.js",
6
6
  "module": "src/index.js",
@@ -35,8 +35,12 @@ export class BaseAPIService {
35
35
  if (!env || env === 'production') {
36
36
  const hostname =
37
37
  (typeof window !== 'undefined' && window.location?.hostname) || '';
38
+ const port =
39
+ (typeof window !== 'undefined' && window.location?.port) || '';
38
40
  if (hostname.includes('staging')) {
39
41
  env = 'staging';
42
+ } else if (hostname === 'app.localhost' && port === '3005') {
43
+ env = 'localstack';
40
44
  }
41
45
  }
42
46
 
@@ -1,6 +1,6 @@
1
+ import { CSS_STYLES } from '../styles/styles.js';
1
2
  import { ConfigError, SDKError } from '../utils/errors.js';
2
3
  import { deepMerge, generateId } from '../utils/helpers.js';
3
- import { CSS_STYLES } from '../styles/styles.js';
4
4
  import { WidgetFactory } from '../widgets/WidgetFactory.js';
5
5
  import { APIService } from './APIService.js';
6
6
  import { EventBus } from './EventBus.js';
@@ -726,11 +726,16 @@ export class Product7 {
726
726
  }
727
727
 
728
728
  const hostname = window.location.hostname.toLowerCase();
729
+ const port = window.location.port;
729
730
 
730
731
  if (hostname.includes('staging')) {
731
732
  return 'staging';
732
733
  }
733
734
 
735
+ if (hostname === 'app.localhost' && port === '3005') {
736
+ return 'localstack';
737
+ }
738
+
734
739
  return 'production';
735
740
  }
736
741
 
package/src/index.js CHANGED
@@ -18,7 +18,6 @@ import { SurveyWidget } from './widgets/SurveyWidget.js';
18
18
  import { TabWidget } from './widgets/TabWidget.js';
19
19
  import { WidgetFactory } from './widgets/WidgetFactory.js';
20
20
 
21
-
22
21
  // --- Identify: transform flat user data into internal format ---
23
22
 
24
23
  function transformIdentifyData(data) {
@@ -616,8 +616,8 @@ export const messengerViewsStyles = `
616
616
 
617
617
  .messenger-help-collection-icon {
618
618
  flex-shrink: 0;
619
- width: 2.25rem;
620
- height: 2.25rem;
619
+ width: 1.75rem;
620
+ height: 1.75rem;
621
621
  display: flex;
622
622
  align-items: center;
623
623
  justify-content: center;
@@ -625,14 +625,14 @@ export const messengerViewsStyles = `
625
625
  }
626
626
 
627
627
  .messenger-help-collection-icon svg {
628
- width: 1.5rem;
629
- height: 1.5rem;
628
+ width: 1.1rem;
629
+ height: 1.1rem;
630
630
  display: block;
631
631
  flex-shrink: 0;
632
632
  }
633
633
 
634
634
  .messenger-help-collection-icon iconify-icon {
635
- font-size: 1.5rem;
635
+ font-size: 1.1rem;
636
636
  width: 1em;
637
637
  height: 1em;
638
638
  display: block;
@@ -799,7 +799,9 @@ export class SurveyWidget extends BaseWidget {
799
799
  const pageId = page.id || `page_${this.surveyState.currentPageIndex}`;
800
800
 
801
801
  if (page.type === 'rating') {
802
- const isStarRating = !!this.surveyElement.querySelector('.feedback-survey-star-btn');
802
+ const isStarRating = !!this.surveyElement.querySelector(
803
+ '.feedback-survey-star-btn'
804
+ );
803
805
 
804
806
  this.surveyElement
805
807
  .querySelectorAll('.feedback-survey-page-rating-btn')
@@ -838,7 +840,9 @@ export class SurveyWidget extends BaseWidget {
838
840
  });
839
841
 
840
842
  if (isStarRating) {
841
- const container = this.surveyElement.querySelector('.feedback-survey-stars');
843
+ const container = this.surveyElement.querySelector(
844
+ '.feedback-survey-stars'
845
+ );
842
846
  if (container) {
843
847
  container.addEventListener('mouseleave', () => {
844
848
  this.surveyElement
@@ -119,7 +119,9 @@ export class ChangelogView {
119
119
  }
120
120
 
121
121
  _attachEvents() {
122
- const mobileCloseBtn = this.element.querySelector('.messenger-changelog-close-btn');
122
+ const mobileCloseBtn = this.element.querySelector(
123
+ '.messenger-changelog-close-btn'
124
+ );
123
125
  if (mobileCloseBtn) {
124
126
  mobileCloseBtn.addEventListener('click', () => {
125
127
  this.state.setOpen(false);
@@ -365,7 +365,9 @@ export class ChatView {
365
365
  this.state.setView('messages');
366
366
  });
367
367
 
368
- const mobileCloseBtn = this.element.querySelector('.messenger-mobile-close-btn');
368
+ const mobileCloseBtn = this.element.querySelector(
369
+ '.messenger-mobile-close-btn'
370
+ );
369
371
  if (mobileCloseBtn) {
370
372
  mobileCloseBtn.addEventListener('click', () => {
371
373
  this.state.setOpen(false);
@@ -593,14 +595,20 @@ export class ChatView {
593
595
  });
594
596
 
595
597
  this._emojiOutsideHandler = (e) => {
596
- if (!container.contains(e.target) && !e.target.closest('.messenger-emoji-btn')) {
598
+ if (
599
+ !container.contains(e.target) &&
600
+ !e.target.closest('.messenger-emoji-btn')
601
+ ) {
597
602
  container.remove();
598
603
  this._emojiPickerOpen = false;
599
604
  document.removeEventListener('click', this._emojiOutsideHandler);
600
605
  this._emojiOutsideHandler = null;
601
606
  }
602
607
  };
603
- setTimeout(() => document.addEventListener('click', this._emojiOutsideHandler), 0);
608
+ setTimeout(
609
+ () => document.addEventListener('click', this._emojiOutsideHandler),
610
+ 0
611
+ );
604
612
  }
605
613
 
606
614
  _insertEmoji(emoji) {
@@ -608,8 +616,7 @@ export class ChatView {
608
616
  if (!input) return;
609
617
  const start = input.selectionStart;
610
618
  const end = input.selectionEnd;
611
- input.value =
612
- input.value.slice(0, start) + emoji + input.value.slice(end);
619
+ input.value = input.value.slice(0, start) + emoji + input.value.slice(end);
613
620
  input.selectionStart = input.selectionEnd = start + emoji.length;
614
621
  input.focus();
615
622
  input.dispatchEvent(new Event('input'));
@@ -196,7 +196,9 @@ export class HelpView {
196
196
  }
197
197
 
198
198
  _attachEvents() {
199
- const mobileCloseBtn = this.element.querySelector('.messenger-help-close-btn');
199
+ const mobileCloseBtn = this.element.querySelector(
200
+ '.messenger-help-close-btn'
201
+ );
200
202
  if (mobileCloseBtn) {
201
203
  mobileCloseBtn.addEventListener('click', () => {
202
204
  this.state.setOpen(false);