@product7/product7-js 0.7.2 → 0.7.5

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.
@@ -4333,89 +4333,22 @@
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;
4417
- }
4418
-
4419
4352
  .liveChat-feedback-error {
4420
4353
  font-size: var(--font-size-xs);
4421
4354
  color: #ef4444;
@@ -9023,6 +8956,7 @@
9023
8956
  this.messagesModuleEnabled = options.messagesModuleEnabled !== false;
9024
8957
 
9025
8958
  this.requireEmailBeforeChat = options.requireEmailBeforeChat || false;
8959
+ this.allowAnonymousChat = options.allowAnonymousChat !== false;
9026
8960
  this.allowAttachments = options.allowAttachments !== false;
9027
8961
  this.allowEmoji = options.allowEmoji !== false;
9028
8962
  this.showReplyTime = options.showReplyTime !== false;
@@ -11687,18 +11621,23 @@
11687
11621
  </div>
11688
11622
  <div class="liveChat-feedback-body">
11689
11623
  <p class="liveChat-feedback-prompt">Share your thoughts with us. We read every message.</p>
11690
- <input
11691
- type="text"
11692
- class="liveChat-feedback-input"
11693
- placeholder="Title"
11694
- />
11695
- <textarea
11696
- class="liveChat-feedback-textarea"
11697
- placeholder="Your feedback..."
11698
- rows="5"
11699
- ></textarea>
11624
+ <div class="sdk-form-group">
11625
+ <label class="sdk-label">Title <span class="sdk-required">*</span></label>
11626
+ <input
11627
+ type="text"
11628
+ class="sdk-input liveChat-feedback-input"
11629
+ placeholder="Brief description of your feedback"
11630
+ />
11631
+ </div>
11632
+ <div class="sdk-form-group">
11633
+ <label class="sdk-label">Message <span class="sdk-required">*</span></label>
11634
+ <textarea
11635
+ class="sdk-textarea liveChat-feedback-textarea"
11636
+ placeholder="Tell us what you think..."
11637
+ ></textarea>
11638
+ </div>
11700
11639
  <span class="liveChat-feedback-error" style="display:none;"></span>
11701
- <button class="liveChat-feedback-submit">Send feedback</button>
11640
+ <button class="sdk-btn-primary sdk-btn-block liveChat-feedback-submit">Send feedback</button>
11702
11641
  </div>
11703
11642
  `;
11704
11643
  this._attachEvents();
@@ -11820,20 +11759,31 @@
11820
11759
  return this.element;
11821
11760
  }
11822
11761
 
11762
+ _isNameRequired() {
11763
+ return this.state.allowAnonymousChat === false;
11764
+ }
11765
+
11823
11766
  _updateContent() {
11767
+ const nameRequired = this._isNameRequired();
11768
+ const namePlaceholder = nameRequired ? 'Your name' : 'Your name (optional)';
11769
+ const subtitle = nameRequired
11770
+ ? 'Enter your name and email so we can get back to you.'
11771
+ : 'Enter your email so we can get back to you.';
11772
+
11824
11773
  this.element.innerHTML = `
11825
11774
  <div class="liveChat-prechat-overlay">
11826
11775
  <div class="liveChat-prechat-card">
11827
11776
  <h4 class="liveChat-prechat-title">Before we continue</h4>
11828
- <p class="liveChat-prechat-subtitle">Enter your details so we can get back to you.</p>
11777
+ <p class="liveChat-prechat-subtitle">${subtitle}</p>
11829
11778
  <form class="liveChat-prechat-form" novalidate>
11830
11779
  <div class="liveChat-prechat-field">
11831
11780
  <input
11832
11781
  type="text"
11833
11782
  name="name"
11834
11783
  class="liveChat-prechat-input"
11835
- placeholder="Your name"
11784
+ placeholder="${namePlaceholder}"
11836
11785
  autocomplete="name"
11786
+ ${nameRequired ? 'required' : ''}
11837
11787
  />
11838
11788
  </div>
11839
11789
  <div class="liveChat-prechat-field">
@@ -11845,8 +11795,8 @@
11845
11795
  autocomplete="email"
11846
11796
  required
11847
11797
  />
11848
- <span class="liveChat-prechat-error" style="display:none;"></span>
11849
11798
  </div>
11799
+ <span class="liveChat-prechat-error" style="display:none;"></span>
11850
11800
  <button type="submit" class="liveChat-prechat-submit">
11851
11801
  Start chat
11852
11802
  </button>
@@ -11866,6 +11816,15 @@
11866
11816
  });
11867
11817
  }
11868
11818
 
11819
+ _validate(nameRequired, name, email) {
11820
+ if (nameRequired && !name) return { msg: 'Please enter your name.', field: 'name' };
11821
+ if (!email) return { msg: 'Please enter your email address.', field: 'email' };
11822
+ if (!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
11823
+ return { msg: 'Please enter a valid email address.', field: 'email' };
11824
+ }
11825
+ return null;
11826
+ }
11827
+
11869
11828
  async _handleSubmit() {
11870
11829
  if (this._isSubmitting) return;
11871
11830
 
@@ -11876,11 +11835,13 @@
11876
11835
 
11877
11836
  const email = emailInput.value.trim();
11878
11837
  const name = nameInput.value.trim();
11838
+ const nameRequired = this._isNameRequired();
11879
11839
 
11880
- if (!email || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email)) {
11881
- errorEl.textContent = 'Please enter a valid email address.';
11840
+ const error = this._validate(nameRequired, name, email);
11841
+ if (error) {
11842
+ errorEl.textContent = error.msg;
11882
11843
  errorEl.style.display = 'block';
11883
- emailInput.focus();
11844
+ (error.field === 'name' ? nameInput : emailInput).focus();
11884
11845
  return;
11885
11846
  }
11886
11847
 
@@ -11896,7 +11857,7 @@
11896
11857
  if (this.options.onIdentifyContact) {
11897
11858
  await this.options.onIdentifyContact({
11898
11859
  name: name || undefined,
11899
- email,
11860
+ email: email || undefined,
11900
11861
  });
11901
11862
  }
11902
11863
 
@@ -12192,10 +12153,7 @@
12192
12153
 
12193
12154
  async _handleStartConversation(messageContent, pendingAttachments) {
12194
12155
  try {
12195
- if (
12196
- this.LiveChatState.requireEmailBeforeChat &&
12197
- !this.LiveChatState.isIdentified
12198
- ) {
12156
+ if (!this.LiveChatState.isIdentified) {
12199
12157
  this.LiveChatState.pendingMessage = {
12200
12158
  content: messageContent,
12201
12159
  attachments: pendingAttachments,
@@ -12893,9 +12851,15 @@
12893
12851
  this.liveChatOptions.textColor = s.text_color;
12894
12852
  stylesChanged = true;
12895
12853
  }
12896
- if (s.theme && !this._hasExplicitOption('theme')) {
12854
+ let themeChanged = false;
12855
+ if (
12856
+ s.theme &&
12857
+ !this._hasExplicitOption('theme') &&
12858
+ s.theme !== this.liveChatOptions.theme
12859
+ ) {
12897
12860
  this.liveChatOptions.theme = s.theme;
12898
12861
  stylesChanged = true;
12862
+ themeChanged = true;
12899
12863
  }
12900
12864
  if (stylesChanged) {
12901
12865
  applyliveChatCustomStyles({
@@ -12905,6 +12869,9 @@
12905
12869
  theme: this.liveChatOptions.theme,
12906
12870
  });
12907
12871
  }
12872
+ if (themeChanged && this._widgetContainer) {
12873
+ this._widgetContainer.className = `liveChat-widget theme-${this.liveChatOptions.theme}`;
12874
+ }
12908
12875
 
12909
12876
  // Launcher position & padding
12910
12877
  if (s.launcher_position && !this._hasExplicitOption('position')) {
@@ -12963,6 +12930,36 @@
12963
12930
  this.LiveChatState.homeModuleEnabled !== false ? 'home' : 'help';
12964
12931
  }
12965
12932
  }
12933
+ if (
12934
+ typeof s.help_module_enabled === 'boolean' &&
12935
+ !this._hasExplicitOption('enableHelp')
12936
+ ) {
12937
+ this.LiveChatState.enableHelp = s.help_module_enabled;
12938
+ if (
12939
+ !s.help_module_enabled &&
12940
+ this.LiveChatState.currentView === 'help'
12941
+ ) {
12942
+ this.LiveChatState.currentView =
12943
+ this.LiveChatState.homeModuleEnabled !== false
12944
+ ? 'home'
12945
+ : 'messages';
12946
+ }
12947
+ }
12948
+ if (
12949
+ typeof s.changelog_module_enabled === 'boolean' &&
12950
+ !this._hasExplicitOption('enableChangelog')
12951
+ ) {
12952
+ this.LiveChatState.enableChangelog = s.changelog_module_enabled;
12953
+ if (
12954
+ !s.changelog_module_enabled &&
12955
+ this.LiveChatState.currentView === 'changelog'
12956
+ ) {
12957
+ this.LiveChatState.currentView =
12958
+ this.LiveChatState.homeModuleEnabled !== false
12959
+ ? 'home'
12960
+ : 'messages';
12961
+ }
12962
+ }
12966
12963
 
12967
12964
  // Feature flags
12968
12965
  if (
@@ -12980,6 +12977,12 @@
12980
12977
  ) {
12981
12978
  this.LiveChatState.requireEmailBeforeChat = s.require_email_before_chat;
12982
12979
  }
12980
+ if (
12981
+ typeof s.allow_anonymous_chat === 'boolean' &&
12982
+ !this._hasExplicitOption('allowAnonymousChat')
12983
+ ) {
12984
+ this.LiveChatState.allowAnonymousChat = s.allow_anonymous_chat;
12985
+ }
12983
12986
  if (
12984
12987
  typeof s.allow_attachments === 'boolean' &&
12985
12988
  !this._hasExplicitOption('allowAttachments')