bhl-forms 0.0.45 → 0.0.48

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.
@@ -17993,18 +17993,31 @@ function prepData(formData) {
17993
17993
  };
17994
17994
  return data2;
17995
17995
  }
17996
- var isMobile = window.matchMedia("only screen and (max-width: 480px)").matches;
17997
- var fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
17998
- if (!stepResult) {
17999
- return;
18000
- }
17996
+ window.matchMedia("only screen and (max-width: 480px)").matches;
17997
+ function getCoords(elem) {
17998
+ var box2 = elem.getBoundingClientRect();
17999
+ return {
18000
+ top: box2.top + window.pageYOffset,
18001
+ right: box2.right + window.pageXOffset,
18002
+ bottom: box2.bottom + window.pageYOffset,
18003
+ left: box2.left + window.pageXOffset
18004
+ };
18005
+ }
18006
+ var scrollAnchor = (formNode) => () => {
18001
18007
  var anchorId = formNode.attrs.anchorElement || formNode.id;
18002
- if (anchorId && isMobile) {
18008
+ if (anchorId) {
18003
18009
  var anchor = document.getElementById(anchorId);
18004
18010
  if (anchor) {
18005
- anchor.scrollIntoView(true);
18011
+ var pos = getCoords(anchor);
18012
+ window.scrollTo(pos.right, pos.top);
18006
18013
  }
18007
18014
  }
18015
+ };
18016
+ var fireStepEvent = (formNode) => (stepResult, stepHistory2, stepQueue2) => {
18017
+ if (!stepResult) {
18018
+ return;
18019
+ }
18020
+ scrollAnchor(formNode)();
18008
18021
  var step_values = null;
18009
18022
  if (stepHistory2.value.length > 0) {
18010
18023
  step_values = flattenObj(formNode.value[stepHistory2.value[stepHistory2.value.length - 1]] || {});
@@ -18117,6 +18130,21 @@ $({ target: "Object", stat: true }, {
18117
18130
  return obj;
18118
18131
  }
18119
18132
  });
18133
+ if (!Object.fromEntries) {
18134
+ Object.defineProperty(Object, "fromEntries", {
18135
+ value(entries2) {
18136
+ if (!entries2 || !entries2[Symbol.iterator]) {
18137
+ throw new Error("Object.fromEntries() requires a single iterable argument");
18138
+ }
18139
+ var o2 = {};
18140
+ Object.keys(entries2).forEach((key) => {
18141
+ var [k3, v] = entries2[key];
18142
+ o2[k3] = v;
18143
+ });
18144
+ return o2;
18145
+ }
18146
+ });
18147
+ }
18120
18148
  function toInteger(dirtyNumber) {
18121
18149
  if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
18122
18150
  return NaN;
@@ -22379,6 +22407,12 @@ var init = () => {
22379
22407
  data2.submitUrl = data2.submitUrl || defaultSubmitUrl;
22380
22408
  data2.prepData = data2.prepData || prepData;
22381
22409
  data2.fireStepEvent = data2.fireStepEvent || fireStepEvent;
22410
+ data2.scrollAnchor = data2.scrollAnchor || scrollAnchor;
22411
+ data2.onEnter = (callback) => (e3) => {
22412
+ if (e3.key === "Enter" || e3.keyCode === 13) {
22413
+ callback();
22414
+ }
22415
+ };
22382
22416
  var app = createApp(_sfc_main$1, {
22383
22417
  schema: schemaObj,
22384
22418
  data: data2