@unvired/turboforms-embed-sdk 2.0.54 → 2.0.55

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.
@@ -41867,6 +41867,62 @@ async function loadTRform(
41867
41867
  document.dispatchEvent(new CustomEvent("LessRenderingComplete"));
41868
41868
 
41869
41869
  window.formObj = formObj;
41870
+
41871
+ // Setup language dropdown if translations are provided
41872
+ if (window.FORMIO_I18N && Object.keys(window.FORMIO_I18N).length > 0) {
41873
+ const modalLangSelector = document.getElementById('modalLanguageSelector');
41874
+ const langMainOption = document.getElementById('languageMainOption');
41875
+ const langDivider = document.getElementById('languageDivider');
41876
+
41877
+ if (modalLangSelector && langMainOption) {
41878
+ modalLangSelector.innerHTML = '';
41879
+
41880
+ let languages = Object.keys(window.FORMIO_I18N).filter(lang =>
41881
+ typeof window.FORMIO_I18N[lang] === 'object' && window.FORMIO_I18N[lang] !== null
41882
+ );
41883
+ const currentLang = window.FORMIO_LANGUAGE || 'en';
41884
+ if (!languages.includes(currentLang) && typeof window.FORMIO_I18N[currentLang] === 'object') {
41885
+ 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
+ }
41890
+
41891
+ const displayNames = new Intl.DisplayNames(['en'], { type: 'language' });
41892
+
41893
+ languages.forEach(lang => {
41894
+ const option = document.createElement('option');
41895
+ option.value = lang;
41896
+
41897
+ let displayName = lang.toUpperCase();
41898
+ try {
41899
+ displayName = displayNames.of(lang) || displayName;
41900
+ } catch (e) {
41901
+ // Fallback if the language code is invalid
41902
+ }
41903
+
41904
+ option.text = displayName;
41905
+ if (lang === currentLang) option.selected = true;
41906
+ modalLangSelector.appendChild(option);
41907
+ });
41908
+
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
+ });
41920
+ }
41921
+
41922
+ langMainOption.style.display = langMainOption.className.includes('d-flex') ? 'flex' : 'block';
41923
+ if (langDivider) langDivider.style.display = 'block';
41924
+ }
41925
+ }
41870
41926
  if (!formObj) {
41871
41927
  logger.error("[TF_SDK:299] ❌ Form not initialized.");
41872
41928
  return;
@@ -43110,7 +43166,7 @@ window.CommentOnBack = CommentOnBack;
43110
43166
 
43111
43167
 
43112
43168
  <div id="sticky-footer">
43113
- <div class="build-version">SDK v2.0.54</div>
43169
+ <div class="build-version">SDK v2.0.55</div>
43114
43170
  <div class="relative-position">
43115
43171
  <button id="unvired-more-btn" class="ui button primary dataGrid-addRow" onclick="toggleTooltip()">
43116
43172
  <i class="icon options"></i>
@@ -43122,7 +43178,9 @@ window.CommentOnBack = CommentOnBack;
43122
43178
  <div class="divider"></div>
43123
43179
  <div class="item" onclick="setTimeout(() => loadComments(), 200)">Comments</div>
43124
43180
  <div class="divider"></div>
43125
- <div class="item" onclick="openHelpLink()">Help</div>
43181
+ <div class="item" id="help-item" onclick="openHelpLink()">Help</div>
43182
+ <div class="divider" id="languageDivider" style="display: none;"></div>
43183
+ <div class="item" id="languageMainOption" style="display: none; cursor: pointer;" onclick="openLanguageModal()">Language</div>
43126
43184
  </div>
43127
43185
  </div>
43128
43186
 
@@ -43138,7 +43196,61 @@ window.CommentOnBack = CommentOnBack;
43138
43196
  </button>
43139
43197
  </div>
43140
43198
 
43199
+ <div id="languageModalOverlay" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1040; backdrop-filter: blur(2px);" onclick="closeLanguageModal()"></div>
43200
+ <div id="languageModal" style="display: none; position: fixed; top: 15%; left: 50%; transform: translate(-50%, 0); z-index: 1050; background: var(--tf-app-card-bg, #ffffff); color: var(--tf-app-label-color, #333); padding: 24px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.15); width: 90%; max-width: 400px; pointer-events: auto; font-family: var(--tf-app-font-family, inherit);">
43201
+ <style>
43202
+ #languageModal .choices { margin-bottom: 0; }
43203
+ #languageModal .choices__inner {
43204
+ display: flex;
43205
+ align-items: center;
43206
+ padding: 0 16px;
43207
+ min-height: 44px;
43208
+ border-radius: 8px;
43209
+ background-color: var(--tf-app-bg-color, #fff);
43210
+ border: 1px solid var(--tf-border-color, #ced4da);
43211
+ }
43212
+ #languageModal .choices__list--single { padding: 0; }
43213
+ #languageModal .choices[data-type*=select-one]::after { margin-top: -6px; }
43214
+ </style>
43215
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px;">
43216
+ <h3 style="margin: 0; font-weight: 600; font-size: calc(var(--tf-app-font-size-base, 14px) + 2px);">Select Language</h3>
43217
+ <span style="cursor:pointer; font-weight: bold; font-size: 1.2rem; color: var(--tf-app-label-color, #333);" onclick="closeLanguageModal()">X</span>
43218
+ </div>
43219
+ <div style="margin-bottom: 20px; margin-top: 10px;">
43220
+ <select id="modalLanguageSelector" style="width: 100%; border: 1px solid var(--tf-border-color, #ced4da); border-radius: 8px; padding: 0.6rem 1rem; font-size: var(--tf-app-font-size-base, 14px); background-color: var(--tf-app-bg-color, #fff); color: var(--tf-app-label-color, #333); cursor: pointer; box-shadow: none;">
43221
+ </select>
43222
+ </div>
43223
+ <div style="text-align: right;">
43224
+ <button style="padding: 0.5rem 1rem; margin-right: 10px; border: 1px solid #6c757d; background: transparent; color: #6c757d; cursor: pointer; border-radius: 8px; font-size: var(--tf-app-font-size-base, 14px);" onclick="closeLanguageModal()">Cancel</button>
43225
+ <button style="padding: 0.5rem 1rem; background-color: var(--tf-primary-color, #2185d0); color: var(--tf-secondary-color, #fff); border: 1px solid var(--tf-primary-color, #2185d0); cursor: pointer; border-radius: 8px; font-size: var(--tf-app-font-size-base, 14px);" onclick="applyLanguage()">Apply</button>
43226
+ </div>
43227
+ </div>
43228
+
43141
43229
  <script>
43230
+ window.openLanguageModal = function () {
43231
+ const tooltip = document.getElementById("moreTooltip");
43232
+ if (tooltip) tooltip.style.display = "none";
43233
+ const overlay = document.getElementById("languageModalOverlay");
43234
+ if (overlay) overlay.style.display = "block";
43235
+ const modal = document.getElementById("languageModal");
43236
+ if (modal) modal.style.display = "block";
43237
+ };
43238
+
43239
+ window.closeLanguageModal = function () {
43240
+ const overlay = document.getElementById("languageModalOverlay");
43241
+ if (overlay) overlay.style.display = "none";
43242
+ const modal = document.getElementById("languageModal");
43243
+ if (modal) modal.style.display = "none";
43244
+ };
43245
+
43246
+ window.applyLanguage = function () {
43247
+ const select = document.getElementById("modalLanguageSelector");
43248
+ if (select && window.changeFormLanguage) {
43249
+ window.changeFormLanguage(select.value);
43250
+ }
43251
+ window.closeLanguageModal();
43252
+ };
43253
+
43142
43254
  function toggleTooltip() {
43143
43255
  try {
43144
43256
  const tooltip = document.getElementById('moreTooltip');
@@ -43150,6 +43262,12 @@ window.CommentOnBack = CommentOnBack;
43150
43262
  }
43151
43263
  }
43152
43264
 
43265
+ function changeFormLanguage(lang) {
43266
+ if (window.formObj) {
43267
+ window.formObj.language = lang;
43268
+ }
43269
+ }
43270
+
43153
43271
  function openHelpLink() {
43154
43272
  try {
43155
43273
  const helpUrl = 'https://docs.unvired.com/formsapp/formfill/';