@codebards/ik-embeddable-form 0.0.2791646055-qa → 0.0.2792346196-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
@@ -1713,10 +1713,12 @@ var IKEmbeddableFormBundle = function(exports) {
1713
1713
  privacyPolicyUrl: getPrivacyPolicyUrl()
1714
1714
  };
1715
1715
  }
1716
- function shouldShowLeftPanel(config, openConfig) {
1716
+ function shouldShowLeftPanel(config, openConfig, currentStepId) {
1717
1717
  var _a;
1718
1718
  if (openConfig == null ? void 0 : openConfig.hideLeftPanel) return false;
1719
1719
  if ((_a = resolveLayoutConfig(config)) == null ? void 0 : _a.hideLeftPanel) return false;
1720
+ const currentStep = config.steps.find((s2) => s2.id === currentStepId);
1721
+ if (currentStep == null ? void 0 : currentStep.hideLeftPanel) return false;
1720
1722
  return !!getLeftPanel(config);
1721
1723
  }
1722
1724
  function getDisplayMode(openConfig) {
@@ -16902,7 +16904,7 @@ var IKEmbeddableFormBundle = function(exports) {
16902
16904
  }) {
16903
16905
  const leftPanel = getLeftPanel(config);
16904
16906
  const rightPanel = getRightPanel(config);
16905
- const showLeftPanel = shouldShowLeftPanel(config, openConfig);
16907
+ const showLeftPanel = shouldShowLeftPanel(config, openConfig, currentStepId);
16906
16908
  const showProgress = shouldShowStepper(config, openConfig, progressSteps, currentStepId);
16907
16909
  const formIntro = getFormIntro(config, openConfig);
16908
16910
  const showFormIntro = shouldShowFormIntro(config, openConfig, progressSteps, currentStepId);
@@ -22253,6 +22255,7 @@ var IKEmbeddableFormBundle = function(exports) {
22253
22255
  id: "success",
22254
22256
  type: "success",
22255
22257
  hidden: true,
22258
+ hideLeftPanel: true,
22256
22259
  title: "Registration completed!",
22257
22260
  analyticsEvents: [
22258
22261
  {
@@ -22461,7 +22464,8 @@ ${intlTelStyles}`;
22461
22464
  uuidPlacement: "path",
22462
22465
  resultParams: { tab: "resume-insights" },
22463
22466
  gateBehindGqlForm: true,
22464
- gqlGateConfig: GQL_GATE_CONFIG
22467
+ gqlGateConfig: GQL_GATE_CONFIG,
22468
+ pollResultBeforeRedirect: true
22465
22469
  },
22466
22470
  {
22467
22471
  id: "salary-analyser",
@@ -22655,6 +22659,8 @@ ${leadMagnetStyles}`;
22655
22659
  function delay(ms) {
22656
22660
  return new Promise((resolve) => setTimeout(resolve, ms));
22657
22661
  }
22662
+ class AnalysisFailedError extends Error {
22663
+ }
22658
22664
  async function pollUntilComplete(tool, uuid, api) {
22659
22665
  const deadline = Date.now() + POLL_MAX_MS;
22660
22666
  while (Date.now() < deadline) {
@@ -22670,7 +22676,7 @@ ${leadMagnetStyles}`;
22670
22676
  if (!res.ok) continue;
22671
22677
  const body = await res.json();
22672
22678
  if (body.state === "FAILED" || body.state === "ERROR") {
22673
- throw new Error("The analyser could not read that resume. Please try another file.");
22679
+ throw new AnalysisFailedError("The analyser could not read that resume. Please try another file.");
22674
22680
  }
22675
22681
  if (body.state === "COMPLETED") {
22676
22682
  return body.data ?? {};
@@ -22810,6 +22816,17 @@ ${leadMagnetStyles}`;
22810
22816
  } catch {
22811
22817
  }
22812
22818
  }
22819
+ function updatePendingTabMessage(tab, heading, body) {
22820
+ try {
22821
+ const h1 = tab.document.querySelector(".wrap h1");
22822
+ const p2 = tab.document.querySelector(".wrap p");
22823
+ if (h1) h1.textContent = heading;
22824
+ if (p2) p2.textContent = body;
22825
+ const [, toolName] = tab.document.title.split(" — ");
22826
+ if (toolName) tab.document.title = `${heading} — ${toolName}`;
22827
+ } catch {
22828
+ }
22829
+ }
22813
22830
  function renderFailedTab(tab, message) {
22814
22831
  try {
22815
22832
  const target = tab.document.querySelector(".wrap");
@@ -22824,7 +22841,7 @@ ${leadMagnetStyles}`;
22824
22841
  (c2) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[c2]
22825
22842
  );
22826
22843
  }
22827
- const GATE_TERMINAL_STEP_ID = "goals-details";
22844
+ const GATE_SUBMIT_BUTTON_TESTID = "goals-details__submit-btn";
22828
22845
  function openGqlGate(options) {
22829
22846
  const { tool, identity, dataClickId, onRegistered, onDismissed } = options;
22830
22847
  const IKForm = typeof window !== "undefined" ? window.IKForm : void 0;
@@ -22870,8 +22887,8 @@ ${leadMagnetStyles}`;
22870
22887
  let claimed = false;
22871
22888
  const onClick = (event) => {
22872
22889
  if (claimed) return;
22873
- const onTerminalStep = event.composedPath().some((el) => el instanceof HTMLElement && el.dataset.testid === GATE_TERMINAL_STEP_ID);
22874
- if (!onTerminalStep) return;
22890
+ const onSubmitButton = event.composedPath().some((el) => el instanceof HTMLElement && el.dataset.testid === GATE_SUBMIT_BUTTON_TESTID);
22891
+ if (!onSubmitButton) return;
22875
22892
  claimed = true;
22876
22893
  resultTab = window.open("", "_blank");
22877
22894
  if (resultTab) {
@@ -22937,6 +22954,28 @@ ${leadMagnetStyles}`;
22937
22954
  }
22938
22955
  return null;
22939
22956
  }
22957
+ async function deliverResult(tab, tool, uuid, resultUrl) {
22958
+ if (!tab || tab.closed) {
22959
+ goToResult(resultUrl);
22960
+ return;
22961
+ }
22962
+ if (tool.pollResultBeforeRedirect) {
22963
+ updatePendingTabMessage(
22964
+ tab,
22965
+ "Wrapping up your analysis",
22966
+ "Almost there — putting together your resume insights. This can take up to a minute."
22967
+ );
22968
+ try {
22969
+ await pollUntilComplete(tool, uuid, "RESUME_ANALYSIS");
22970
+ } catch (err) {
22971
+ if (err instanceof AnalysisFailedError) {
22972
+ if (!tab.closed) renderFailedTab(tab, err.message);
22973
+ return;
22974
+ }
22975
+ }
22976
+ }
22977
+ if (!tab.closed) tab.location.href = resultUrl;
22978
+ }
22940
22979
  function useUploadController(tool, surface) {
22941
22980
  const [state2, setState] = d(() => getToolState(tool.id));
22942
22981
  const [localFile, setLocalFile] = d(null);
@@ -22981,17 +23020,16 @@ ${leadMagnetStyles}`;
22981
23020
  identity: data,
22982
23021
  dataClickId: resolveClickId(surface, tool.id),
22983
23022
  // `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.
23023
+ // if the browser refused it, in which case deliverResult's own goToResult
23024
+ // fallback tries once more and, failing that, falls back to navigating this tab.
22986
23025
  onRegistered: (gateTab) => {
22987
- if (gateTab && !gateTab.closed) gateTab.location.href = resultUrl;
22988
- else goToResult(resultUrl);
23026
+ void deliverResult(gateTab, tool, uuid, resultUrl);
22989
23027
  }
22990
23028
  });
22991
23029
  } else if (resultTab) {
22992
23030
  resultTab.location.href = resultUrl;
22993
23031
  } else {
22994
- goToResult(resultUrl);
23032
+ void deliverResult(resultTab, tool, uuid, resultUrl);
22995
23033
  }
22996
23034
  } catch (err) {
22997
23035
  const message = err instanceof Error ? err.message : "Upload failed. Please try again.";