bhl-forms 0.0.39 → 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.
@@ -5333,15 +5333,24 @@ const handleSubmitError = (err, node) => {
5333
5333
  node.setErrors(err.toString());
5334
5334
  return true;
5335
5335
  };
5336
- const keyValOverlap = (o1, o2, multiple = true) => {
5336
+ const getKey = (d2, path) => {
5337
+ if (typeof path === "string") {
5338
+ path = path.split(".");
5339
+ }
5340
+ return path.reduce((x2, y) => x2[y], d2);
5341
+ };
5342
+ const keyValOverlap = (o1, o2) => {
5337
5343
  let result = null;
5338
- for (var input2 of Object.keys(o1)) {
5339
- const value = o1[input2];
5340
- if (o2[input2] && o2[input2][value]) {
5341
- if (result !== null && !multiple) {
5342
- throw Error("Multiple values not allowed");
5343
- }
5344
- result = o2[input2][value];
5344
+ for (var key of Object.keys(o2)) {
5345
+ if (key === "*") {
5346
+ continue;
5347
+ }
5348
+ const o1_value = getKey(o1, key);
5349
+ if (!o1_value) {
5350
+ continue;
5351
+ }
5352
+ if (o2[key][o1_value]) {
5353
+ result = o2[key][o1_value];
5345
5354
  break;
5346
5355
  }
5347
5356
  }
@@ -5353,12 +5362,6 @@ const keyValOverlap = (o1, o2, multiple = true) => {
5353
5362
  }
5354
5363
  return result;
5355
5364
  };
5356
- const getKey = (d2, path) => {
5357
- if (typeof path === "string") {
5358
- path = path.split(".");
5359
- }
5360
- return path.reduce((x2, y) => x2[y], d2);
5361
- };
5362
5365
  const strSubUrl = (str, obj) => str.replace(/\${(.*?)}/g, (x2, g2) => encodeURIComponent(getKey(obj, g2)));
5363
5366
  function useSteps() {
5364
5367
  const activeStep2 = ref("");
@@ -5369,6 +5372,19 @@ function useSteps() {
5369
5372
  const lastItem = (x2) => {
5370
5373
  return x2.value[x2.value.length - 1];
5371
5374
  };
5375
+ const findFirstInput = (n2) => {
5376
+ for (var i2 = 0; i2 < n2.children.length; i2++) {
5377
+ const child = n2.children[i2];
5378
+ if ((child.type === "input" || child.type === "list") && !(child.context.type === "hidden")) {
5379
+ return child;
5380
+ }
5381
+ const res = findFirstInput(child);
5382
+ if (res) {
5383
+ return res;
5384
+ }
5385
+ }
5386
+ return null;
5387
+ };
5372
5388
  const firstStep2 = () => {
5373
5389
  if (stepHistory2.value.length > 0) {
5374
5390
  return stepHistory2.value[0];
@@ -5408,9 +5424,9 @@ function useSteps() {
5408
5424
  }
5409
5425
  };
5410
5426
  const getNextStepsFromMap = (node, nextStepMap) => {
5411
- return keyValOverlap(node.value, nextStepMap, false);
5427
+ return keyValOverlap(node.value, nextStepMap);
5412
5428
  };
5413
- const setStep2 = ({ nextStep = 1, validate: validate2 = true } = {}) => {
5429
+ const setStep2 = ({ nextStep = 1, validate: validate2 = true, autoFocus = true } = {}) => {
5414
5430
  const node = steps2[activeStep2.value].node;
5415
5431
  if (validate2) {
5416
5432
  node.walk((n2) => {
@@ -5435,6 +5451,17 @@ function useSteps() {
5435
5451
  } else {
5436
5452
  throw Error("Unexpected value for nextStep: " + nextStep);
5437
5453
  }
5454
+ if (autoFocus) {
5455
+ const newNode = steps2[activeStep2.value].node;
5456
+ setTimeout(function() {
5457
+ const firstInput = findFirstInput(newNode);
5458
+ if (!firstInput) {
5459
+ return;
5460
+ }
5461
+ const elem = document.getElementById(firstInput.context.id);
5462
+ elem.focus();
5463
+ }, 300);
5464
+ }
5438
5465
  return true;
5439
5466
  };
5440
5467
  const setNextStep2 = (callback) => {
@@ -5539,7 +5566,7 @@ const dataDefaults = {
5539
5566
  if (!node || !node.props.attrs.redirectMap) {
5540
5567
  return;
5541
5568
  }
5542
- return keyValOverlap(formData, node.props.attrs.redirectMap, false);
5569
+ return keyValOverlap(formData, node.props.attrs.redirectMap);
5543
5570
  },
5544
5571
  submit: (postUrl, prepData2 = null, redirectUrl = null) => (formData, node) => __async(this, null, function* () {
5545
5572
  if (prepData2 && prepData2 != "null") {
@@ -10916,7 +10943,7 @@ const boxClassification = {
10916
10943
  wrapper: "t-flex t-items-center t-mb-1 t-cursor-pointer",
10917
10944
  help: "t-mb-2",
10918
10945
  input: "t-form-check-input t-appearance-none t-h-5 t-w-5 t-mr-2 t-border t-border-gray-500 t-rounded-sm t-bg-white checked:t-bg-blue-500 focus:t-outline-none focus:t-ring-0 t-transition t-duration-100",
10919
- label: "t-text-base t-text-gray-700"
10946
+ label: "t-font-normal t-text-base t-text-gray-700"
10920
10947
  };
10921
10948
  const checkBoxClassification = {
10922
10949
  fieldset: "t-max-w-md t-border t-border-gray-400 t-rounded-md t-px-2 t-pb-1",
@@ -10924,7 +10951,7 @@ const checkBoxClassification = {
10924
10951
  wrapper: "t-flex t-items-center t-mb-1 t-cursor-pointer",
10925
10952
  help: "t-mb-2",
10926
10953
  input: "t-h-5 t-w-5 t-mr-2 t-border t-border-gray-500 t-rounded-sm t-bg-white checked:t-bg-blue-500 focus:t-outline-none focus:t-ring-0 t-transition t-duration-100",
10927
- label: "t-text-base t-text-gray-700"
10954
+ label: "t-font-normal t-text-base t-text-gray-700"
10928
10955
  };
10929
10956
  const buttonClassification = {
10930
10957
  wrapper: "t-mb-1",