@unvired/turboforms-embed-sdk 1.0.23 → 1.0.30

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.
@@ -58970,16 +58970,13 @@ function showDynamicModal(
58970
58970
  .custom-modal.show, .custom-modal-backdrop.show {
58971
58971
  display: flex;
58972
58972
  }
58973
- /* Center the dialog using translate which behaves consistently across browsers */
58973
+ /* Flexbox on the parent handles centering */
58974
58974
  .custom-modal-dialog {
58975
58975
  width: 100%;
58976
58976
  max-width: 500px;
58977
- margin: 0; /* reset; we position via transform */
58977
+ margin: auto;
58978
58978
  box-sizing: border-box;
58979
58979
  position: relative;
58980
- top: 50%;
58981
- left: 50%;
58982
- transform: translate(-50%, -50%);
58983
58980
  }
58984
58981
  .custom-modal-content {
58985
58982
  background: #fff;
@@ -59031,9 +59028,7 @@ function showDynamicModal(
59031
59028
  @media (max-width: 600px) {
59032
59029
  .custom-modal-dialog {
59033
59030
  max-width: 95vw;
59034
- /* On small screens prefer slightly higher vertical position so header isn't cut off */
59035
- top: 40%;
59036
- transform: translate(-50%, -40%);
59031
+ margin: 1rem auto;
59037
59032
  }
59038
59033
  .custom-modal-content {
59039
59034
  border-radius: 0.15rem;
@@ -60715,7 +60710,7 @@ window.CommentOnBack = CommentOnBack;
60715
60710
 
60716
60711
 
60717
60712
  <div id="sticky-footer">
60718
- <div class="build-version">SDK v1.0.23</div>
60713
+ <div class="build-version">SDK v1.0.30</div>
60719
60714
  <div class="relative-position">
60720
60715
  <button id="unvired-more-btn" class="ui button primary dataGrid-addRow" onclick="toggleTooltip()">
60721
60716
  <i class="icon options"></i>
@@ -43,11 +43,18 @@ function attachMasterDataToForm(obj, masterdataResults, key = "dataSrc", type =
43
43
  attachMasterDataToForm(obj[k], masterdataResults, key, type, true);
44
44
  } else if (k === key && obj[k] === type) {
45
45
  if (Array.isArray(masterdataResults)) {
46
- obj.masterdata = masterdataResults.flatMap(
47
- (md) => md.submissionData || []
48
- );
46
+ let matchedData = [];
47
+ if (obj.selMasterdataId) {
48
+ const match = masterdataResults.find((md) => md.masterdataId === obj.selMasterdataId);
49
+ if (match && match.submissionData) {
50
+ matchedData = match.submissionData;
51
+ }
52
+ } else {
53
+ matchedData = masterdataResults.flatMap((md) => md.submissionData || []);
54
+ }
55
+ obj.masterdata = matchedData.map((item) => item && item.data !== void 0 ? item : { data: item });
49
56
  } else if (masterdataResults && Array.isArray(masterdataResults.submissionData)) {
50
- obj.masterdata = masterdataResults.submissionData;
57
+ obj.masterdata = masterdataResults.submissionData.map((item) => item && item.data !== void 0 ? item : { data: item });
51
58
  } else {
52
59
  obj.masterdata = [];
53
60
  }
@@ -939,6 +946,8 @@ async function loadUnviredForms({
939
946
  const template = formJson;
940
947
  const nestedFormArrTemp = options.nestedFormData || [];
941
948
  const masterDataArrTemp = options.masterData || [];
949
+ console.log("[SDK:3] Debug - options.masterData received:", options.masterData);
950
+ console.log("[SDK:3] Debug - masterDataArrTemp evaluated to:", masterDataArrTemp);
942
951
  const nestedFormError = validateNestedForms(formJson, nestedFormArrTemp);
943
952
  if (nestedFormError) {
944
953
  console.error("[SDK] \u274C Step 3: Nested form validation failed", nestedFormError);
@@ -27823,6 +27832,7 @@ select.ui.dropdown {
27823
27832
  height: 100%;
27824
27833
  background: rgba(255, 255, 255, 0.95);
27825
27834
  backdrop-filter: blur(10px);
27835
+ -webkit-backdrop-filter: blur(10px);
27826
27836
  display: flex;
27827
27837
  flex-direction: column;
27828
27838
  justify-content: center;
@@ -27842,15 +27852,23 @@ select.ui.dropdown {
27842
27852
  border: 4px solid #e0e0e0;
27843
27853
  border-top: 4px solid #0077b6;
27844
27854
  border-radius: 50%;
27855
+ -webkit-animation: sdk-spin 1s linear infinite;
27845
27856
  animation: sdk-spin 1s linear infinite;
27846
27857
  margin-bottom: 20px;
27858
+ -webkit-transform: translateZ(0);
27859
+ transform: translateZ(0);
27860
+ will-change: transform;
27847
27861
  }
27848
27862
  .sdk-loader-text {
27849
27863
  color: #0077b6;
27850
27864
  font-size: 1.1rem;
27851
27865
  font-weight: 500;
27852
27866
  letter-spacing: 0.5px;
27867
+ -webkit-animation: sdk-pulse 1.5s ease-in-out infinite;
27853
27868
  animation: sdk-pulse 1.5s ease-in-out infinite;
27869
+ -webkit-transform: translateZ(0);
27870
+ transform: translateZ(0);
27871
+ will-change: opacity;
27854
27872
  }
27855
27873
  .sdk-loader-subtext {
27856
27874
  color: #666;
@@ -27858,10 +27876,18 @@ select.ui.dropdown {
27858
27876
  margin-top: 8px;
27859
27877
  opacity: 0.7;
27860
27878
  }
27879
+ @-webkit-keyframes sdk-spin {
27880
+ 0% { -webkit-transform: rotate(0deg); transform: rotate(0deg); }
27881
+ 100% { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
27882
+ }
27861
27883
  @keyframes sdk-spin {
27862
27884
  0% { transform: rotate(0deg); }
27863
27885
  100% { transform: rotate(360deg); }
27864
27886
  }
27887
+ @-webkit-keyframes sdk-pulse {
27888
+ 0%, 100% { opacity: 1; }
27889
+ 50% { opacity: 0.5; }
27890
+ }
27865
27891
  @keyframes sdk-pulse {
27866
27892
  0%, 100% { opacity: 1; }
27867
27893
  50% { opacity: 0.5; }
@@ -27922,7 +27948,7 @@ select.ui.dropdown {
27922
27948
  <div id="formio-cmt" style="margin-bottom: 20px;"></div>
27923
27949
  </div>
27924
27950
  <div id="sticky-footer">
27925
- <div class="build-version">SDK v1.0.23</div>
27951
+ <div class="build-version">SDK v1.0.30</div>
27926
27952
  <button class="ui button primary dataGrid-addRow" id="saveBtn" disabled="true" onclick="FormOnSave()">
27927
27953
  <i class="icon save large"></i>Save
27928
27954
  </button>
@@ -66224,16 +66250,13 @@ function showDynamicModal(
66224
66250
  .custom-modal.show, .custom-modal-backdrop.show {
66225
66251
  display: flex;
66226
66252
  }
66227
- /* Center the dialog using translate which behaves consistently across browsers */
66253
+ /* Flexbox on the parent handles centering */
66228
66254
  .custom-modal-dialog {
66229
66255
  width: 100%;
66230
66256
  max-width: 500px;
66231
- margin: 0; /* reset; we position via transform */
66257
+ margin: auto;
66232
66258
  box-sizing: border-box;
66233
66259
  position: relative;
66234
- top: 50%;
66235
- left: 50%;
66236
- transform: translate(-50%, -50%);
66237
66260
  }
66238
66261
  .custom-modal-content {
66239
66262
  background: #fff;
@@ -66285,9 +66308,7 @@ function showDynamicModal(
66285
66308
  @media (max-width: 600px) {
66286
66309
  .custom-modal-dialog {
66287
66310
  max-width: 95vw;
66288
- /* On small screens prefer slightly higher vertical position so header isn't cut off */
66289
- top: 40%;
66290
- transform: translate(-50%, -40%);
66311
+ margin: 1rem auto;
66291
66312
  }
66292
66313
  .custom-modal-content {
66293
66314
  border-radius: 0.15rem;
@@ -67275,6 +67296,11 @@ function buildMandatoryFieldsCache() {
67275
67296
  cacheMandatoryFields(comp.components, fieldPath);
67276
67297
  }
67277
67298
 
67299
+ // Nested forms
67300
+ if (comp.type === 'form' && comp.subForm && Array.isArray(comp.subForm.components)) {
67301
+ cacheMandatoryFields(comp.subForm.components, fieldPath ? \`\${fieldPath}.data\` : 'data');
67302
+ }
67303
+
67278
67304
  // Columns component handles children differently in instances?
67279
67305
  // Usually comp.columns is an array of objects which contain .components (instances)
67280
67306
  if (Array.isArray(comp.columns)) {
@@ -67704,6 +67730,12 @@ function FormOnSave() {
67704
67730
  }
67705
67731
 
67706
67732
  function FormOnBack() {
67733
+ // Do not ask for confirmation in read-only mode
67734
+ if (formObj && formObj.options && formObj.options.readOnly) {
67735
+ FormOnBackNavigation();
67736
+ return;
67737
+ }
67738
+
67707
67739
  let currentData;
67708
67740
  try {
67709
67741
  currentData = formObj ? formObj.getValue().data : null;
@@ -67711,10 +67743,10 @@ function FormOnBack() {
67711
67743
  currentData = null;
67712
67744
  }
67713
67745
 
67714
- const hasChanges =
67746
+ const noChanges =
67715
67747
  JSON.stringify(currentData) === JSON.stringify(initialFormData);
67716
67748
 
67717
- if (hasChanges) {
67749
+ if (noChanges) {
67718
67750
  FormOnBackNavigation();
67719
67751
  } else {
67720
67752
  showDynamicModal(
@@ -68224,7 +68256,7 @@ window.CommentOnBack = CommentOnBack;
68224
68256
  );
68225
68257
  if (!window.__unviredSdkScriptsLoaded && !window.__unviredSdkScriptsLoading) {
68226
68258
  window.__unviredSdkScriptsLoading = true;
68227
- console.log("[SDK:10] \u{1F527} Loading SDK scripts (jQuery, Formio, Recogito, LESS, components)...");
68259
+ console.log("[SDK:10] \u{1F527} Loading SDK scripts (jQuery, Forms, Recogito, LESS, components)...");
68228
68260
  if (scriptContents[0] && scriptContents[0].trim()) {
68229
68261
  const jqueryScript = document.createElement("script");
68230
68262
  jqueryScript.textContent = scriptContents[0];
@@ -68233,7 +68265,7 @@ window.CommentOnBack = CommentOnBack;
68233
68265
  }
68234
68266
  if (loaderElement) {
68235
68267
  const loaderText = loaderElement.querySelector(".sdk-loader-text");
68236
- if (loaderText) loaderText.textContent = "Loading Formio Library...";
68268
+ if (loaderText) loaderText.textContent = "Loading Forms Library...";
68237
68269
  }
68238
68270
  try {
68239
68271
  await new Promise((resolve, reject) => {
@@ -68242,14 +68274,14 @@ window.CommentOnBack = CommentOnBack;
68242
68274
  formioScript.async = false;
68243
68275
  formioScript.onload = () => {
68244
68276
  if (typeof window.Formio !== "undefined") {
68245
- console.log("[SDK:10.2] \u2705 Formio library loaded from:", options.formioLibPath.formioPath);
68277
+ console.log("[SDK:10.2] \u2705 Forms library loaded from:", options.formioLibPath.formioPath);
68246
68278
  resolve();
68247
68279
  } else {
68248
- reject(new Error("Formio script loaded but window.Formio is undefined"));
68280
+ reject(new Error("Forms script loaded but window.Forms is undefined"));
68249
68281
  }
68250
68282
  };
68251
68283
  formioScript.onerror = () => {
68252
- reject(new Error(`Failed to load Formio script from ${options.formioLibPath.formioPath}`));
68284
+ reject(new Error(`Failed to load Forms script from ${options.formioLibPath.formioPath}`));
68253
68285
  };
68254
68286
  document.head.appendChild(formioScript);
68255
68287
  });
@@ -68257,19 +68289,28 @@ window.CommentOnBack = CommentOnBack;
68257
68289
  window.__unviredSdkScriptsLoading = false;
68258
68290
  throw error;
68259
68291
  }
68260
- for (let i = 1; i <= 2; i++) {
68261
- if (scriptContents[i] && scriptContents[i].trim()) {
68262
- const scriptElement = document.createElement("script");
68263
- scriptElement.textContent = scriptContents[i];
68264
- scriptElement.setAttribute("data-unvired-script", `recogito-${i}`);
68265
- document.head.appendChild(scriptElement);
68292
+ if (options.showComments) {
68293
+ for (let i = 1; i <= 2; i++) {
68294
+ if (scriptContents[i] && scriptContents[i].trim()) {
68295
+ const scriptElement = document.createElement("script");
68296
+ scriptElement.textContent = scriptContents[i];
68297
+ scriptElement.setAttribute("data-unvired-script", `recogito-${i}`);
68298
+ document.head.appendChild(scriptElement);
68299
+ await new Promise((r) => setTimeout(r, 0));
68300
+ }
68266
68301
  }
68302
+ } else {
68303
+ console.log("[SDK:10.3] \u26A1 Skipping Recogito (comments disabled, optimized load)");
68267
68304
  }
68268
- if (scriptContents[3] && scriptContents[3].trim()) {
68305
+ const hasThemeOverrides = options.themeData && Object.keys(options.themeData).length > 0;
68306
+ if (hasThemeOverrides && scriptContents[3] && scriptContents[3].trim()) {
68269
68307
  const lessScript = document.createElement("script");
68270
68308
  lessScript.textContent = scriptContents[3];
68271
68309
  lessScript.setAttribute("data-unvired-script", "less");
68272
68310
  document.head.appendChild(lessScript);
68311
+ } else {
68312
+ console.log("[SDK:10.4] \u26A1 Skipping LESS.js (no theme overrides, optimized load)");
68313
+ window.less = window.less || { modifyVars: () => Promise.resolve() };
68273
68314
  }
68274
68315
  window.form = window.form || {};
68275
68316
  window.platform = window.platform || {};
@@ -68292,6 +68333,9 @@ window.CommentOnBack = CommentOnBack;
68292
68333
  scriptElement.textContent = scriptContent;
68293
68334
  scriptElement.setAttribute("data-unvired-script", `script-${i}`);
68294
68335
  document.head.appendChild(scriptElement);
68336
+ if (i % 5 === 0) {
68337
+ await new Promise((r) => setTimeout(r, 0));
68338
+ }
68295
68339
  }
68296
68340
  }
68297
68341
  window.__unviredSdkScriptsLoaded = true;
@@ -68306,7 +68350,7 @@ window.CommentOnBack = CommentOnBack;
68306
68350
  } else {
68307
68351
  console.log("[SDK:10] \u2705 SDK scripts already loaded \u2014 skipping injection");
68308
68352
  if (typeof window.Formio === "undefined") {
68309
- const errorMsg = `ErrorCode : 005, Formio library not available even though scripts were loaded. Path: ${options.formioLibPath.formioPath}`;
68353
+ const errorMsg = `ErrorCode : 005, Forms library not available even though scripts were loaded. Path: ${options.formioLibPath.formioPath}`;
68310
68354
  console.error(errorMsg);
68311
68355
  if (loaderElement) {
68312
68356
  loaderElement.classList.add("hidden");
@@ -68322,7 +68366,7 @@ window.CommentOnBack = CommentOnBack;
68322
68366
  });
68323
68367
  throw new Error(errorMsg);
68324
68368
  }
68325
- console.log("[SDK:10] \u2705 Formio verified (previously loaded)");
68369
+ console.log("[SDK:10] \u2705 Forms verified (previously loaded)");
68326
68370
  }
68327
68371
  window.FORM_TEMPLATE = mergedWithMasterData;
68328
68372
  window.FORM_PREVIOUS_DATA = submissionData;
@@ -68426,7 +68470,7 @@ window.CommentOnBack = CommentOnBack;
68426
68470
  if (loaderText) loaderText.textContent = "Initializing Form...";
68427
68471
  }
68428
68472
  if (typeof window.loadRNform !== "function") {
68429
- console.log("[SDK:14] \u23F3 loadRNform not ready yet \u2014 waiting for web-unvired-formio.js to signal...");
68473
+ console.log("[SDK:14] \u23F3 loadRNform not ready yet \u2014 waiting for web-unvired.js to signal...");
68430
68474
  await new Promise((resolve) => {
68431
68475
  const onReady = () => {
68432
68476
  document.removeEventListener("LoadRNformReady", onReady);
@@ -68441,7 +68485,7 @@ window.CommentOnBack = CommentOnBack;
68441
68485
  } else {
68442
68486
  console.log("[SDK:14] \u2705 loadRNform already available \u2014 invoking immediately");
68443
68487
  }
68444
- console.log("[SDK:14] \u{1F680} Handing off to loadRNform (web-unvired-formio.js)...");
68488
+ console.log("[SDK:14] \u{1F680} Handing off to loadRNform (web-unvired.js)...");
68445
68489
  await window.loadRNform(
68446
68490
  mergedWithMasterData,
68447
68491
  processedSubmissionData,
@@ -68517,7 +68561,7 @@ window.deleteAppDocument = async function(id) {
68517
68561
  window.getAllDocuments = getAllDocuments;
68518
68562
  window.hasDocuments = hasDocuments;
68519
68563
  function getBuildVersion() {
68520
- return "1.0.23";
68564
+ return "1.0.30";
68521
68565
  }
68522
68566
  export {
68523
68567
  getBuildVersion,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unvired/turboforms-embed-sdk",
3
- "version": "1.0.23",
3
+ "version": "1.0.30",
4
4
  "description": "Reusable vanilla JS form library that works with React, Angular, Ionic, etc.",
5
5
  "main": "dist/unvired-forms-sdk.js",
6
6
  "types": "dist/index.d.ts",