@codebards/ik-embeddable-form 0.0.2788003631-qa → 0.0.2791646055-qa

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/dist/embed.js CHANGED
@@ -1393,8 +1393,6 @@ var IKEmbeddableFormBundle = function(exports) {
1393
1393
  { value: "Embedded Software Engineer", label: "Embedded Software Engineer" },
1394
1394
  { value: "Other Software Engineers", label: "Other Software Engineers" },
1395
1395
  { value: "Data Analyst / Business Analyst", label: "Data Analyst / Business Analyst" },
1396
- { value: "Core Engineering", label: "Core Engineering" },
1397
- { value: "Salesforce developer", label: "Salesforce developer" },
1398
1396
  { value: "DevOps Engineer", label: "DevOps Engineer" },
1399
1397
  { value: "None of the above", label: "None of the above" }
1400
1398
  ];
@@ -22768,7 +22766,9 @@ ${leadMagnetStyles}`;
22768
22766
  }
22769
22767
  }
22770
22768
  function renderPendingTab(tab, tool, options = {}) {
22771
- const waitingCopy = options.gated ? `Finish signing up in the tab you came from and your results will appear here.` : `This usually takes under a minute. Please keep this tab open — your results will
22769
+ const heading = options.gated ? "Finishing up" : "Analysing your resume";
22770
+ const waitingCopy = options.gated ? `We're wrapping up your registration in the tab you came from — your results will
22771
+ appear here automatically the moment it's done.` : `This usually takes under a minute. Please keep this tab open — your results will
22772
22772
  appear here automatically.`;
22773
22773
  try {
22774
22774
  tab.document.write(`<!doctype html>
@@ -22776,7 +22776,7 @@ ${leadMagnetStyles}`;
22776
22776
  <head>
22777
22777
  <meta charset="utf-8">
22778
22778
  <meta name="viewport" content="width=device-width, initial-scale=1">
22779
- <title>Analysing your resume — ${escapeHtml(tool.copy.title)}</title>
22779
+ <title>${escapeHtml(heading)} — ${escapeHtml(tool.copy.title)}</title>
22780
22780
  <style>
22781
22781
  :root { color-scheme: light dark; }
22782
22782
  * { box-sizing: border-box; }
@@ -22801,7 +22801,7 @@ ${leadMagnetStyles}`;
22801
22801
  <body>
22802
22802
  <div class="wrap" role="status" aria-live="polite">
22803
22803
  <div class="spinner"></div>
22804
- <h1>Analysing your resume</h1>
22804
+ <h1>${escapeHtml(heading)}</h1>
22805
22805
  <p>${waitingCopy}</p>
22806
22806
  </div>
22807
22807
  </body>
@@ -22824,24 +22824,31 @@ ${leadMagnetStyles}`;
22824
22824
  (c2) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c2]
22825
22825
  );
22826
22826
  }
22827
+ const GATE_TERMINAL_STEP_ID = "goals-details";
22827
22828
  function openGqlGate(options) {
22828
22829
  const { tool, identity, dataClickId, onRegistered, onDismissed } = options;
22829
22830
  const IKForm = typeof window !== "undefined" ? window.IKForm : void 0;
22830
22831
  if (!IKForm) {
22831
- onRegistered();
22832
+ onRegistered(null);
22832
22833
  return;
22833
22834
  }
22835
+ const releaseClaim = claimResultTab(tool);
22834
22836
  let settled = false;
22835
22837
  const handOffOnce = () => {
22836
22838
  if (settled) return;
22837
22839
  settled = true;
22838
22840
  IKForm.close();
22839
- onRegistered();
22841
+ onRegistered(releaseClaim());
22840
22842
  };
22841
22843
  const dismissOnce = () => {
22842
22844
  if (settled) return;
22843
- settled = true;
22844
- onDismissed == null ? void 0 : onDismissed();
22845
+ setTimeout(() => {
22846
+ var _a;
22847
+ if (settled) return;
22848
+ settled = true;
22849
+ (_a = releaseClaim()) == null ? void 0 : _a.close();
22850
+ onDismissed == null ? void 0 : onDismissed();
22851
+ }, 3e3);
22845
22852
  };
22846
22853
  IKForm.open({
22847
22854
  ...tool.gqlGateConfig,
@@ -22858,6 +22865,27 @@ ${leadMagnetStyles}`;
22858
22865
  onClose: dismissOnce
22859
22866
  });
22860
22867
  }
22868
+ function claimResultTab(tool) {
22869
+ let resultTab = null;
22870
+ let claimed = false;
22871
+ const onClick = (event) => {
22872
+ if (claimed) return;
22873
+ const onTerminalStep = event.composedPath().some((el) => el instanceof HTMLElement && el.dataset.testid === GATE_TERMINAL_STEP_ID);
22874
+ if (!onTerminalStep) return;
22875
+ claimed = true;
22876
+ resultTab = window.open("", "_blank");
22877
+ if (resultTab) {
22878
+ renderPendingTab(resultTab, tool, { gated: true });
22879
+ window.focus();
22880
+ }
22881
+ document.removeEventListener("click", onClick, true);
22882
+ };
22883
+ document.addEventListener("click", onClick, true);
22884
+ return () => {
22885
+ document.removeEventListener("click", onClick, true);
22886
+ return resultTab;
22887
+ };
22888
+ }
22861
22889
  function goToResult(url) {
22862
22890
  const tab = window.open(url, "_blank");
22863
22891
  if (!tab) window.location.href = url;
@@ -22935,11 +22963,8 @@ ${leadMagnetStyles}`;
22935
22963
  );
22936
22964
  const submit = q$1(async () => {
22937
22965
  if (!localFile) return;
22938
- const resultTab = window.open("", "_blank");
22939
- if (resultTab) {
22940
- renderPendingTab(resultTab, tool, { gated: tool.gateBehindGqlForm });
22941
- if (tool.gateBehindGqlForm) window.focus();
22942
- }
22966
+ const resultTab = tool.gateBehindGqlForm ? null : window.open("", "_blank");
22967
+ if (resultTab) renderPendingTab(resultTab, tool);
22943
22968
  setToolState(tool.id, { status: "uploading" });
22944
22969
  try {
22945
22970
  const base64 = await fileToBase64(localFile);
@@ -22950,22 +22975,23 @@ ${leadMagnetStyles}`;
22950
22975
  const resultUrl = buildResultUrl(tool, uuid);
22951
22976
  setToolState(tool.id, { status: "done" });
22952
22977
  reportLeadMagnetClick(buildLifecycleClickId(surface, tool.id, "upload-success"));
22953
- const handOff = () => {
22954
- if (resultTab && !resultTab.closed) resultTab.location.href = resultUrl;
22955
- else goToResult(resultUrl);
22956
- };
22957
22978
  if (tool.gateBehindGqlForm) {
22958
22979
  openGqlGate({
22959
22980
  tool,
22960
22981
  identity: data,
22961
22982
  dataClickId: resolveClickId(surface, tool.id),
22962
- onRegistered: handOff,
22963
- // Abandoned the form don't leave a tab spinning on a result they will never
22964
- // be sent to.
22965
- onDismissed: () => resultTab == null ? void 0 : resultTab.close()
22983
+ // `gateTab` is whatever openGqlGate managed to claim on the submit click — null
22984
+ // if the browser refused it, in which case goToResult tries once more and,
22985
+ // failing that, falls back to navigating this tab.
22986
+ onRegistered: (gateTab) => {
22987
+ if (gateTab && !gateTab.closed) gateTab.location.href = resultUrl;
22988
+ else goToResult(resultUrl);
22989
+ }
22966
22990
  });
22991
+ } else if (resultTab) {
22992
+ resultTab.location.href = resultUrl;
22967
22993
  } else {
22968
- handOff();
22994
+ goToResult(resultUrl);
22969
22995
  }
22970
22996
  } catch (err) {
22971
22997
  const message = err instanceof Error ? err.message : "Upload failed. Please try again.";