bhl-forms 0.0.64 → 0.0.65

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.
@@ -9353,9 +9353,28 @@ var postJSON = /* @__PURE__ */ function() {
9353
9353
  return _ref.apply(this, arguments);
9354
9354
  };
9355
9355
  }();
9356
- var redirect = (url3) => {
9356
+ var redirectTo = (url3) => {
9357
9357
  window.location.href = url3;
9358
9358
  };
9359
+ var openNewTab = (url3) => {
9360
+ var otherTab = window.open();
9361
+ if (otherTab !== null) {
9362
+ otherTab.opener = null;
9363
+ otherTab.target = "_blank";
9364
+ otherTab.location = url3;
9365
+ }
9366
+ return otherTab;
9367
+ };
9368
+ var getRedirect = (formData, node2) => {
9369
+ if (!node2 || !node2.props.attrs.redirectMap) {
9370
+ return null;
9371
+ }
9372
+ var redirectUrl = keyValOverlap(formData, node2.props.attrs.redirectMap);
9373
+ if (redirectUrl && formData) {
9374
+ redirectUrl = strSubUrl(redirectUrl, formData);
9375
+ }
9376
+ return redirectUrl;
9377
+ };
9359
9378
  var handleSubmitError = (err, node2) => {
9360
9379
  if (err.response) {
9361
9380
  var code = err.response.status;
@@ -10649,15 +10668,15 @@ var dataDefaults = {
10649
10668
  }
10650
10669
  return true;
10651
10670
  },
10652
- getRedirect: (formData, node2) => {
10653
- if (!node2 || !node2.props.attrs.redirectMap) {
10654
- return;
10671
+ handleRedirectMap: (formData, node2) => {
10672
+ var redirectUrl = getRedirect(formData, node2);
10673
+ if (redirectUrl && redirectUrl !== "null") {
10674
+ redirectTo(redirectUrl);
10655
10675
  }
10656
- return keyValOverlap(formData, node2.props.attrs.redirectMap);
10657
10676
  },
10658
10677
  submit: function submit(postUrl) {
10659
10678
  var prepData2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
10660
- var redirectUrl = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
10679
+ var redirect = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
10661
10680
  return /* @__PURE__ */ function() {
10662
10681
  var _ref6 = _asyncToGenerator(function* (formData, node2) {
10663
10682
  if (prepData2 && prepData2 != "null") {
@@ -10676,14 +10695,13 @@ var dataDefaults = {
10676
10695
  if (abort) {
10677
10696
  return false;
10678
10697
  }
10679
- if (redirectUrl instanceof Function) {
10680
- redirectUrl = redirectUrl(formData, node2);
10681
- }
10682
- if (redirectUrl && redirectUrl !== "null") {
10698
+ if (typeof redirect === "string" && redirect !== "null") {
10683
10699
  if (formData) {
10684
- redirectUrl = strSubUrl(redirectUrl, formData);
10700
+ redirect = strSubUrl(redirect, formData);
10685
10701
  }
10686
- redirect(redirectUrl);
10702
+ redirectTo(redirect);
10703
+ } else if (redirect instanceof Function) {
10704
+ redirect(formData, node2);
10687
10705
  }
10688
10706
  return true;
10689
10707
  });
@@ -17974,6 +17992,32 @@ var fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
17974
17992
  }
17975
17993
  }
17976
17994
  };
17995
+ var handleRedirect = (formData, node2) => {
17996
+ try {
17997
+ var redirectUrl = getRedirect(formData, node2);
17998
+ if (redirectUrl && redirectUrl !== "null") {
17999
+ if (node2 && node2.props.attrs.popUnder) {
18000
+ var popUnderUrl = node2.props.attrs.popUnder;
18001
+ var res = openNewTab(redirectUrl);
18002
+ if (res !== null) {
18003
+ if (popUnderUrl && formData) {
18004
+ popUnderUrl = strSubUrl(popUnderUrl, formData);
18005
+ }
18006
+ redirectTo(popUnderUrl);
18007
+ } else {
18008
+ dbg("new tab failed");
18009
+ redirectTo(redirectUrl);
18010
+ }
18011
+ } else {
18012
+ redirectTo(redirectUrl);
18013
+ }
18014
+ }
18015
+ } catch (err) {
18016
+ var msg = "failed to handleRedirect: " + err.toString();
18017
+ console.warn(msg);
18018
+ rollbar("warning", msg);
18019
+ }
18020
+ };
17977
18021
  var textClassification = {
17978
18022
  label: "t-block t-mb-3 t-font-semibold t-text-base formkit-invalid:t-text-red-500",
17979
18023
  inner: "\n t-max-w-lg\n t-border\n t-border-gray-400\n formkit-invalid:t-border-red-500\n t-rounded t-mb-1\n t-overflow-hidden\n focus-within:t-border-blue-500\n ",
@@ -22338,6 +22382,7 @@ var init = () => {
22338
22382
  data2.prepData = data2.prepData || prepData;
22339
22383
  data2.preStepFunc = data2.preStepFunc || preStepFunc;
22340
22384
  data2.fireStepEvent = data2.fireStepEvent || fireStepEvent;
22385
+ data2.handleRedirect = data2.handleRedirect || handleRedirect;
22341
22386
  data2.scrollAnchor = data2.scrollAnchor || scrollAnchor;
22342
22387
  data2.onEnter = (callback) => (e2) => {
22343
22388
  if (e2.key === "Enter" || e2.keyCode === 13) {