bhl-forms 0.0.51 → 0.0.54

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.
@@ -4675,6 +4675,15 @@ function dbg$1() {
4675
4675
  return;
4676
4676
  console.debug(...arguments);
4677
4677
  }
4678
+ const getCoords$1 = (elem) => {
4679
+ let box2 = elem.getBoundingClientRect();
4680
+ return {
4681
+ top: box2.top + window.pageYOffset,
4682
+ right: box2.right + window.pageXOffset,
4683
+ bottom: box2.bottom + window.pageYOffset,
4684
+ left: box2.left + window.pageXOffset
4685
+ };
4686
+ };
4678
4687
  const postJSON = (url3, data) => __async(this, null, function* () {
4679
4688
  dbg$1("Post to: " + url3);
4680
4689
  const raw2 = yield fetch(url3, {
@@ -5686,9 +5695,10 @@ function useSteps() {
5686
5695
  }
5687
5696
  if (el) {
5688
5697
  var __tempEl__ = document.createElement("input");
5698
+ var coords = getCoords$1(el);
5689
5699
  __tempEl__.style.position = "absolute";
5690
- __tempEl__.style.top = el.offsetTop + 7 + "px";
5691
- __tempEl__.style.left = el.offsetLeft + "px";
5700
+ __tempEl__.style.top = coords.top + 7 + "px";
5701
+ __tempEl__.style.left = coords.left + "px";
5692
5702
  __tempEl__.style.height = 0;
5693
5703
  __tempEl__.style.opacity = 0;
5694
5704
  document.body.appendChild(__tempEl__);
@@ -5769,14 +5779,14 @@ function useSteps() {
5769
5779
  if (autoFocus) {
5770
5780
  const newNode = steps2[activeStep2.value].node;
5771
5781
  const firstInput = findFirstInput(newNode);
5772
- if (!firstInput) {
5773
- return;
5774
- }
5775
- if (autoFocusTypes.indexOf(firstInput.context.type) === -1) {
5776
- return;
5782
+ if (firstInput && autoFocusTypes.indexOf(firstInput.context.type) > -1) {
5783
+ const elem = document.getElementById(firstInput.context.id);
5784
+ try {
5785
+ focusAndOpenKeyboard(elem);
5786
+ } catch (e) {
5787
+ console.warn("Failed to autoFocus:", e);
5788
+ }
5777
5789
  }
5778
- const elem = document.getElementById(firstInput.context.id);
5779
- focusAndOpenKeyboard(elem);
5780
5790
  }
5781
5791
  return true;
5782
5792
  };
@@ -11100,6 +11110,7 @@ const scrollAnchor = (formNode) => () => {
11100
11110
  const anchor = document.getElementById(anchorId);
11101
11111
  if (anchor) {
11102
11112
  const pos = getCoords(anchor);
11113
+ dbg("scrollTo", pos);
11103
11114
  window.scrollTo(pos.right, pos.top);
11104
11115
  }
11105
11116
  }
@@ -15532,6 +15543,7 @@ const init = () => {
15532
15543
  data.onEnter = (callback) => (e) => {
15533
15544
  if (e.key === "Enter" || e.keyCode === 13) {
15534
15545
  callback();
15546
+ e.preventDefault();
15535
15547
  }
15536
15548
  };
15537
15549
  const app = createApp(_sfc_main$1, { schema: schemaObj, data }).use(plugin$1, defaultConfig({