@unvired/turboforms-embed-sdk 2.0.55 → 2.0.57

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.
@@ -2444,7 +2444,6 @@
2444
2444
  width: 200px;
2445
2445
  z-index: 1050;
2446
2446
  padding: 8px 0;
2447
- overflow: hidden;
2448
2447
  animation: sdkFadeInUp 0.2s ease-out;
2449
2448
  display: none;
2450
2449
  flex-direction: column;
@@ -41870,12 +41869,12 @@ async function loadTRform(
41870
41869
 
41871
41870
  // Setup language dropdown if translations are provided
41872
41871
  if (window.FORMIO_I18N && Object.keys(window.FORMIO_I18N).length > 0) {
41873
- const modalLangSelector = document.getElementById('modalLanguageSelector');
41872
+ const languageSubMenu = document.getElementById('languageSubMenu');
41874
41873
  const langMainOption = document.getElementById('languageMainOption');
41875
41874
  const langDivider = document.getElementById('languageDivider');
41876
41875
 
41877
- if (modalLangSelector && langMainOption) {
41878
- modalLangSelector.innerHTML = '';
41876
+ if (languageSubMenu && langMainOption) {
41877
+ languageSubMenu.innerHTML = '';
41879
41878
 
41880
41879
  let languages = Object.keys(window.FORMIO_I18N).filter(lang =>
41881
41880
  typeof window.FORMIO_I18N[lang] === 'object' && window.FORMIO_I18N[lang] !== null
@@ -41883,16 +41882,16 @@ async function loadTRform(
41883
41882
  const currentLang = window.FORMIO_LANGUAGE || 'en';
41884
41883
  if (!languages.includes(currentLang) && typeof window.FORMIO_I18N[currentLang] === 'object') {
41885
41884
  languages.unshift(currentLang);
41886
- } else if (!languages.includes(currentLang) && languages.length > 0) {
41887
- // If the currentLang has no translations, we should maybe still show it, but let's just stick to what has translations.
41888
- // The user specifically only wants to see options they passed translations for.
41889
41885
  }
41890
41886
 
41891
41887
  const displayNames = new Intl.DisplayNames(['en'], { type: 'language' });
41892
41888
 
41893
41889
  languages.forEach(lang => {
41894
- const option = document.createElement('option');
41895
- option.value = lang;
41890
+ const optionDiv = document.createElement('div');
41891
+ optionDiv.className = langMainOption.className;
41892
+ optionDiv.style.cursor = 'pointer';
41893
+ optionDiv.style.padding = '0.5rem 1rem';
41894
+ optionDiv.style.borderTop = 'none';
41896
41895
 
41897
41896
  let displayName = lang.toUpperCase();
41898
41897
  try {
@@ -41901,27 +41900,58 @@ async function loadTRform(
41901
41900
  // Fallback if the language code is invalid
41902
41901
  }
41903
41902
 
41904
- option.text = displayName;
41905
- if (lang === currentLang) option.selected = true;
41906
- modalLangSelector.appendChild(option);
41903
+ let iconHTML = lang === currentLang ? '<i class="bi bi-check2 text-primary" style="margin-right: 8px;"></i>' : '<i class="bi bi-check2" style="margin-right: 8px; visibility: hidden;"></i>';
41904
+ if (langMainOption.innerHTML.includes('icon chevron')) {
41905
+ iconHTML = lang === currentLang ? '<i class="icon check" style="margin-right: 8px;"></i>' : '<i class="icon check" style="margin-right: 8px; visibility: hidden;"></i>';
41906
+ }
41907
+
41908
+ optionDiv.innerHTML = `${iconHTML}${displayName}`;
41909
+
41910
+ optionDiv.onclick = function(e) {
41911
+ e.stopPropagation();
41912
+ if (window.changeFormLanguage) {
41913
+ window.changeFormLanguage(lang);
41914
+ window.FORMIO_LANGUAGE = lang;
41915
+ }
41916
+
41917
+ const children = languageSubMenu.children;
41918
+ for (let i = 0; i < children.length; i++) {
41919
+ const child = children[i];
41920
+ const icon = child.querySelector('i');
41921
+ if (icon) {
41922
+ if (languages[i] === lang) {
41923
+ icon.style.visibility = 'visible';
41924
+ if (icon.className.includes('bi')) icon.classList.add('text-primary');
41925
+ } else {
41926
+ icon.style.visibility = 'hidden';
41927
+ if (icon.className.includes('bi')) icon.classList.remove('text-primary');
41928
+ }
41929
+ }
41930
+ }
41931
+
41932
+ if (window.toggleLanguageSubMenu) window.toggleLanguageSubMenu();
41933
+
41934
+ if (window.showToast) {
41935
+ window.showToast(`Language set to ${displayName}`, 'success');
41936
+ }
41937
+ };
41938
+
41939
+ languageSubMenu.appendChild(optionDiv);
41907
41940
  });
41908
41941
 
41909
- if (window.Choices) {
41910
- // Destroy previous instance if it exists
41911
- if (window.languageChoicesInstance) {
41912
- window.languageChoicesInstance.destroy();
41913
- }
41914
- window.languageChoicesInstance = new Choices(modalLangSelector, {
41915
- searchEnabled: false,
41916
- itemSelectText: '',
41917
- shouldSort: false,
41918
- allowHTML: true
41919
- });
41942
+ if (languages.length > 1) {
41943
+ langMainOption.style.display = langMainOption.className.includes('d-flex') ? 'flex' : 'block';
41944
+ if (langDivider) langDivider.style.display = 'block';
41945
+ } else {
41946
+ langMainOption.style.display = 'none';
41947
+ if (langDivider) langDivider.style.display = 'none';
41920
41948
  }
41921
-
41922
- langMainOption.style.display = langMainOption.className.includes('d-flex') ? 'flex' : 'block';
41923
- if (langDivider) langDivider.style.display = 'block';
41924
41949
  }
41950
+ } else {
41951
+ const langMainOption = document.getElementById('languageMainOption');
41952
+ const langDivider = document.getElementById('languageDivider');
41953
+ if (langMainOption) langMainOption.style.display = 'none';
41954
+ if (langDivider) langDivider.style.display = 'none';
41925
41955
  }
41926
41956
  if (!formObj) {
41927
41957
  logger.error("[TF_SDK:299] ❌ Form not initialized.");
@@ -43166,7 +43196,7 @@ window.CommentOnBack = CommentOnBack;
43166
43196
 
43167
43197
 
43168
43198
  <div id="sticky-footer">
43169
- <div class="build-version">SDK v2.0.55</div>
43199
+ <div class="build-version">SDK v2.0.57</div>
43170
43200
  <div class="relative-position">
43171
43201
  <button id="unvired-more-btn" class="ui button primary dataGrid-addRow" onclick="toggleTooltip()">
43172
43202
  <i class="icon options"></i>