bhl-forms 0.0.41 → 0.0.42

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.
@@ -10004,16 +10004,24 @@ var handleSubmitError = (err, node2) => {
10004
10004
  node2.setErrors(err.toString());
10005
10005
  return true;
10006
10006
  };
10007
- var keyValOverlap = function keyValOverlap2(o1, o2) {
10008
- var multiple = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
10007
+ var getKey = (d2, path) => {
10008
+ if (typeof path === "string") {
10009
+ path = path.split(".");
10010
+ }
10011
+ return path.reduce((x2, y) => x2[y], d2);
10012
+ };
10013
+ var keyValOverlap = (o1, o2) => {
10009
10014
  var result = null;
10010
- for (var input2 of Object.keys(o1)) {
10011
- var value = o1[input2];
10012
- if (o2[input2] && o2[input2][value]) {
10013
- if (result !== null && !multiple) {
10014
- throw Error("Multiple values not allowed");
10015
- }
10016
- result = o2[input2][value];
10015
+ for (var key of Object.keys(o2)) {
10016
+ if (key === "*") {
10017
+ continue;
10018
+ }
10019
+ var o1_value = getKey(o1, key);
10020
+ if (!o1_value) {
10021
+ continue;
10022
+ }
10023
+ if (o2[key][o1_value]) {
10024
+ result = o2[key][o1_value];
10017
10025
  break;
10018
10026
  }
10019
10027
  }
@@ -10025,12 +10033,6 @@ var keyValOverlap = function keyValOverlap2(o1, o2) {
10025
10033
  }
10026
10034
  return result;
10027
10035
  };
10028
- var getKey = (d2, path) => {
10029
- if (typeof path === "string") {
10030
- path = path.split(".");
10031
- }
10032
- return path.reduce((x2, y) => x2[y], d2);
10033
- };
10034
10036
  var strSubUrl = (str, obj) => str.replace(/\${(.*?)}/g, (x2, g2) => encodeURIComponent(getKey(obj, g2)));
10035
10037
  function useSteps() {
10036
10038
  var activeStep2 = ref("");
@@ -10041,6 +10043,19 @@ function useSteps() {
10041
10043
  var lastItem = (x2) => {
10042
10044
  return x2.value[x2.value.length - 1];
10043
10045
  };
10046
+ var findFirstInput = (n2) => {
10047
+ for (var i2 = 0; i2 < n2.children.length; i2++) {
10048
+ var child = n2.children[i2];
10049
+ if ((child.type === "input" || child.type === "list") && !(child.context.type === "hidden")) {
10050
+ return child;
10051
+ }
10052
+ var res = findFirstInput(child);
10053
+ if (res) {
10054
+ return res;
10055
+ }
10056
+ }
10057
+ return null;
10058
+ };
10044
10059
  var firstStep2 = () => {
10045
10060
  if (stepHistory2.value.length > 0) {
10046
10061
  return stepHistory2.value[0];
@@ -10081,12 +10096,13 @@ function useSteps() {
10081
10096
  }
10082
10097
  };
10083
10098
  var getNextStepsFromMap = (node2, nextStepMap) => {
10084
- return keyValOverlap(node2.value, nextStepMap, false);
10099
+ return keyValOverlap(node2.value, nextStepMap);
10085
10100
  };
10086
10101
  var setStep2 = function setStep22() {
10087
10102
  var {
10088
10103
  nextStep = 1,
10089
- validate: validate2 = true
10104
+ validate: validate2 = true,
10105
+ autoFocus = true
10090
10106
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
10091
10107
  var node2 = steps2[activeStep2.value].node;
10092
10108
  if (validate2) {
@@ -10112,6 +10128,17 @@ function useSteps() {
10112
10128
  } else {
10113
10129
  throw Error("Unexpected value for nextStep: " + nextStep);
10114
10130
  }
10131
+ if (autoFocus) {
10132
+ var newNode = steps2[activeStep2.value].node;
10133
+ setTimeout(function() {
10134
+ var firstInput = findFirstInput(newNode);
10135
+ if (!firstInput) {
10136
+ return;
10137
+ }
10138
+ var elem = document.getElementById(firstInput.context.id);
10139
+ elem.focus();
10140
+ }, 300);
10141
+ }
10115
10142
  return true;
10116
10143
  };
10117
10144
  var setNextStep2 = (callback) => {
@@ -10257,7 +10284,7 @@ var dataDefaults = {
10257
10284
  if (!node2 || !node2.props.attrs.redirectMap) {
10258
10285
  return;
10259
10286
  }
10260
- return keyValOverlap(formData, node2.props.attrs.redirectMap, false);
10287
+ return keyValOverlap(formData, node2.props.attrs.redirectMap);
10261
10288
  },
10262
10289
  submit: function submit(postUrl) {
10263
10290
  var prepData2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;