bhl-forms 0.3.3 → 0.4.1
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.
- package/dist/bhl-forms.es.js +190 -90
- package/dist/bhl-forms.iife.js +7 -7
- package/dist/bhl-forms.modern.es.js +219 -104
- package/dist/bhl-forms.modern.iife.js +9 -9
- package/dist/bhl-forms.modern.umd.js +9 -9
- package/dist/bhl-forms.umd.js +7 -7
- package/dist/forms/accidentsAndInjuries.es.js +19 -9
- package/dist/forms/accidentsAndInjuries.iife.js +1 -1
- package/dist/forms/accidentsAndInjuries.json +1 -1
- package/dist/forms/appraisals.es.js +14 -4
- package/dist/forms/appraisals.iife.js +1 -1
- package/dist/forms/appraisals.json +1 -1
- package/dist/forms/childAndFamily.es.js +19 -9
- package/dist/forms/childAndFamily.iife.js +1 -1
- package/dist/forms/childAndFamily.json +1 -1
- package/dist/forms/civilLawsuit.es.js +22 -10
- package/dist/forms/civilLawsuit.iife.js +1 -1
- package/dist/forms/civilLawsuit.json +1 -1
- package/dist/forms/coins.es.js +14 -4
- package/dist/forms/coins.iife.js +1 -1
- package/dist/forms/coins.json +1 -1
- package/dist/forms/contracts.es.js +19 -9
- package/dist/forms/contracts.iife.js +1 -1
- package/dist/forms/contracts.json +1 -1
- package/dist/forms/criminal.es.js +19 -9
- package/dist/forms/criminal.iife.js +1 -1
- package/dist/forms/criminal.json +1 -1
- package/dist/forms/employmentAndWorkplace.es.js +19 -9
- package/dist/forms/employmentAndWorkplace.iife.js +1 -1
- package/dist/forms/employmentAndWorkplace.json +1 -1
- package/dist/forms/generalLegal.es.js +247 -18
- package/dist/forms/generalLegal.iife.js +1 -1
- package/dist/forms/generalLegal.json +1 -1
- package/dist/forms/generalLegalPopUnder.es.js +22 -10
- package/dist/forms/generalLegalPopUnder.iife.js +1 -1
- package/dist/forms/generalLegalPopUnder.json +1 -1
- package/dist/forms/generalLegalPopUnderTF.es.js +19 -9
- package/dist/forms/generalLegalPopUnderTF.iife.js +1 -1
- package/dist/forms/generalLegalPopUnderTF.json +1 -1
- package/dist/forms/generalLegalThankYou.es.js +19 -9
- package/dist/forms/generalLegalThankYou.iife.js +1 -1
- package/dist/forms/generalLegalThankYou.json +1 -1
- package/dist/forms/harassmentAndDiscrimination.es.js +19 -9
- package/dist/forms/harassmentAndDiscrimination.iife.js +1 -1
- package/dist/forms/harassmentAndDiscrimination.json +1 -1
- package/dist/forms/malpractice.es.js +19 -9
- package/dist/forms/malpractice.iife.js +1 -1
- package/dist/forms/malpractice.json +1 -1
- package/dist/forms/mechanics.es.js +14 -4
- package/dist/forms/mechanics.iife.js +1 -1
- package/dist/forms/mechanics.json +1 -1
- package/dist/forms/realEstate.es.js +19 -9
- package/dist/forms/realEstate.iife.js +1 -1
- package/dist/forms/realEstate.json +1 -1
- package/dist/forms/repossession.es.js +19 -9
- package/dist/forms/repossession.iife.js +1 -1
- package/dist/forms/repossession.json +1 -1
- package/dist/forms/ssdi.es.js +19 -9
- package/dist/forms/ssdi.iife.js +1 -1
- package/dist/forms/ssdi.json +1 -1
- package/dist/forms/testForm.es.js +19 -9
- package/dist/forms/testForm.iife.js +1 -1
- package/dist/forms/testForm.json +1 -1
- package/dist/forms/testRedirects.es.js +14 -4
- package/dist/forms/testRedirects.iife.js +1 -1
- package/dist/forms/testRedirects.json +1 -1
- package/dist/forms/vets.es.js +15 -5
- package/dist/forms/vets.iife.js +1 -1
- package/dist/forms/vets.json +1 -1
- package/dist/forms/willsAndTrusts.es.js +19 -9
- package/dist/forms/willsAndTrusts.iife.js +1 -1
- package/dist/forms/willsAndTrusts.json +1 -1
- package/package.json +6 -6
|
@@ -10090,7 +10090,17 @@ var getRedirect = (formData, node2) => {
|
|
|
10090
10090
|
}
|
|
10091
10091
|
return redirectUrl;
|
|
10092
10092
|
};
|
|
10093
|
+
var clearErrorTimeout = 0;
|
|
10094
|
+
var setNodeError = (node2, message2) => {
|
|
10095
|
+
node2.setErrors(message2);
|
|
10096
|
+
clearErrorTimeout = setTimeout(() => {
|
|
10097
|
+
node2.store.filter((m3) => {
|
|
10098
|
+
return m3.type !== "error";
|
|
10099
|
+
});
|
|
10100
|
+
}, 5e3);
|
|
10101
|
+
};
|
|
10093
10102
|
var handleSubmitError = (err, node2) => {
|
|
10103
|
+
clearTimeout(clearErrorTimeout);
|
|
10094
10104
|
if (err.response) {
|
|
10095
10105
|
var code = err.response.status;
|
|
10096
10106
|
if (node2.props.attrs.errorCodes && code in node2.props.attrs.errorCodes) {
|
|
@@ -10108,12 +10118,12 @@ var handleSubmitError = (err, node2) => {
|
|
|
10108
10118
|
}
|
|
10109
10119
|
}
|
|
10110
10120
|
if (message2) {
|
|
10111
|
-
node2
|
|
10121
|
+
setNodeError(node2, message2);
|
|
10112
10122
|
}
|
|
10113
10123
|
return abort;
|
|
10114
10124
|
}
|
|
10115
10125
|
}
|
|
10116
|
-
node2
|
|
10126
|
+
setNodeError(node2, err.toString());
|
|
10117
10127
|
return true;
|
|
10118
10128
|
};
|
|
10119
10129
|
var _getKey = (d3, path, def2) => {
|
|
@@ -10759,39 +10769,46 @@ function syncListNodes$1(node2, context) {
|
|
|
10759
10769
|
var newChildren = [];
|
|
10760
10770
|
var unused = new Set(context.children);
|
|
10761
10771
|
var placeholderValues = /* @__PURE__ */ new Map();
|
|
10762
|
-
_value.forEach((
|
|
10763
|
-
if (context.children[i2] && context.children[i2]._value ===
|
|
10772
|
+
_value.forEach((value, i2) => {
|
|
10773
|
+
if (context.children[i2] && context.children[i2]._value === value) {
|
|
10764
10774
|
newChildren.push(context.children[i2]);
|
|
10765
10775
|
unused.delete(context.children[i2]);
|
|
10766
10776
|
} else {
|
|
10767
10777
|
newChildren.push(null);
|
|
10768
|
-
placeholderValues.
|
|
10778
|
+
var indexes = placeholderValues.get(value) || [];
|
|
10779
|
+
indexes.push(i2);
|
|
10780
|
+
placeholderValues.set(value, indexes);
|
|
10769
10781
|
}
|
|
10770
10782
|
});
|
|
10771
10783
|
if (unused.size && placeholderValues.size) {
|
|
10772
10784
|
unused.forEach((child2) => {
|
|
10773
10785
|
if (placeholderValues.has(child2._value)) {
|
|
10774
|
-
|
|
10786
|
+
var indexes = placeholderValues.get(child2._value);
|
|
10787
|
+
var index3 = indexes.shift();
|
|
10788
|
+
newChildren[index3] = child2;
|
|
10775
10789
|
unused.delete(child2);
|
|
10776
|
-
|
|
10790
|
+
if (!indexes.length)
|
|
10791
|
+
placeholderValues.delete(child2._value);
|
|
10777
10792
|
}
|
|
10778
10793
|
});
|
|
10779
10794
|
}
|
|
10780
|
-
|
|
10795
|
+
var emptyIndexes = [];
|
|
10796
|
+
placeholderValues.forEach((indexes) => {
|
|
10797
|
+
emptyIndexes.push(...indexes);
|
|
10798
|
+
});
|
|
10799
|
+
while (unused.size && emptyIndexes.length) {
|
|
10781
10800
|
var child = unused.values().next().value;
|
|
10782
|
-
var
|
|
10783
|
-
|
|
10801
|
+
var index2 = emptyIndexes.shift();
|
|
10802
|
+
if (index2 === void 0)
|
|
10803
|
+
break;
|
|
10784
10804
|
newChildren[index2] = child;
|
|
10785
10805
|
unused.delete(child);
|
|
10786
|
-
placeholderValues.delete(value);
|
|
10787
10806
|
}
|
|
10788
|
-
|
|
10789
|
-
|
|
10790
|
-
|
|
10791
|
-
value: value2
|
|
10792
|
-
});
|
|
10807
|
+
emptyIndexes.forEach((index3, value) => {
|
|
10808
|
+
newChildren[index3] = createPlaceholder$1({
|
|
10809
|
+
value
|
|
10793
10810
|
});
|
|
10794
|
-
}
|
|
10811
|
+
});
|
|
10795
10812
|
if (unused.size) {
|
|
10796
10813
|
unused.forEach((child2) => {
|
|
10797
10814
|
if (!("__FKP" in child2)) {
|
|
@@ -11332,6 +11349,9 @@ function useSteps() {
|
|
|
11332
11349
|
var setStepQueue = (value) => {
|
|
11333
11350
|
stepQueue2.value = [...value];
|
|
11334
11351
|
};
|
|
11352
|
+
var stepEnabled2 = (stepName) => {
|
|
11353
|
+
return enabledSteps2().indexOf(stepName) > -1;
|
|
11354
|
+
};
|
|
11335
11355
|
var queueStep = function queueStep2(stepName) {
|
|
11336
11356
|
var next3 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
11337
11357
|
if (next3 == true) {
|
|
@@ -11396,16 +11416,18 @@ function useSteps() {
|
|
|
11396
11416
|
throw Error("Unexpected value for nextStep: " + nextStep);
|
|
11397
11417
|
}
|
|
11398
11418
|
if (autoFocus) {
|
|
11399
|
-
|
|
11400
|
-
var firstInput = findFirstInput(newNode);
|
|
11401
|
-
if (firstInput && autoFocusTypes.indexOf(firstInput.context.type) > -1) {
|
|
11402
|
-
var elem = document.getElementById(firstInput.context.id);
|
|
11419
|
+
setTimeout(function() {
|
|
11403
11420
|
try {
|
|
11404
|
-
|
|
11421
|
+
var newNode = steps2[activeStep2.value].node;
|
|
11422
|
+
var firstInput = findFirstInput(newNode);
|
|
11423
|
+
if (firstInput && autoFocusTypes.indexOf(firstInput.context.type) > -1) {
|
|
11424
|
+
var elem = document.getElementById(firstInput.context.id);
|
|
11425
|
+
focusAndOpenKeyboard(elem);
|
|
11426
|
+
}
|
|
11405
11427
|
} catch (e2) {
|
|
11406
11428
|
console.warn("Failed to autoFocus:", e2);
|
|
11407
11429
|
}
|
|
11408
|
-
}
|
|
11430
|
+
}, 50);
|
|
11409
11431
|
}
|
|
11410
11432
|
return true;
|
|
11411
11433
|
};
|
|
@@ -11434,39 +11456,43 @@ function useSteps() {
|
|
|
11434
11456
|
if (node2.props.attrs.defaultOrder) {
|
|
11435
11457
|
defaultOrder2.push(...node2.props.attrs.defaultOrder);
|
|
11436
11458
|
}
|
|
11437
|
-
|
|
11438
|
-
}
|
|
11439
|
-
if (node2.props.type == "group") {
|
|
11440
|
-
if (defaultOrder2.length > 0) {
|
|
11441
|
-
if (Object.keys(steps2).length === 0) {
|
|
11442
|
-
setStepQueue(defaultOrder2);
|
|
11443
|
-
}
|
|
11444
|
-
} else {
|
|
11445
|
-
if (!(node2.name in steps2)) {
|
|
11446
|
-
queueStep(node2.name);
|
|
11447
|
-
}
|
|
11448
|
-
}
|
|
11449
|
-
steps2[node2.name] = steps2[node2.name] || {};
|
|
11450
|
-
steps2[node2.name].node = node2;
|
|
11451
|
-
node2.on("created", () => {
|
|
11452
|
-
steps2[node2.name].valid = toRef(node2.context.state, "valid");
|
|
11453
|
-
});
|
|
11454
|
-
node2.on("count:errors", (_ref5) => {
|
|
11459
|
+
node2.on("child", (_ref5) => {
|
|
11455
11460
|
var {
|
|
11456
|
-
payload:
|
|
11461
|
+
payload: childNode
|
|
11457
11462
|
} = _ref5;
|
|
11458
|
-
|
|
11459
|
-
|
|
11460
|
-
|
|
11461
|
-
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11463
|
+
if (childNode.type === "group") {
|
|
11464
|
+
if (defaultOrder2.length > 0) {
|
|
11465
|
+
if (Object.keys(steps2).length === 0) {
|
|
11466
|
+
setStepQueue(defaultOrder2);
|
|
11467
|
+
}
|
|
11468
|
+
} else {
|
|
11469
|
+
if (!stepEnabled2(childNode.name)) {
|
|
11470
|
+
queueStep(childNode.name);
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
steps2[childNode.name] = {};
|
|
11474
|
+
steps2[childNode.name].node = childNode;
|
|
11475
|
+
childNode.on("created", () => {
|
|
11476
|
+
steps2[childNode.name].valid = toRef(childNode.context.state, "valid");
|
|
11477
|
+
});
|
|
11478
|
+
childNode.on("count:errors", (_ref6) => {
|
|
11479
|
+
var {
|
|
11480
|
+
payload: count2
|
|
11481
|
+
} = _ref6;
|
|
11482
|
+
steps2[childNode.name].errorCount = count2;
|
|
11483
|
+
});
|
|
11484
|
+
childNode.on("count:blocking", (_ref7) => {
|
|
11485
|
+
var {
|
|
11486
|
+
payload: count2
|
|
11487
|
+
} = _ref7;
|
|
11488
|
+
steps2[childNode.name].blockingCount = count2;
|
|
11489
|
+
});
|
|
11490
|
+
if (activeStep2.value === "") {
|
|
11491
|
+
activeStep2.value = childNode.name;
|
|
11492
|
+
}
|
|
11493
|
+
}
|
|
11465
11494
|
});
|
|
11466
|
-
|
|
11467
|
-
activeStep2.value = node2.name;
|
|
11468
|
-
}
|
|
11469
|
-
return false;
|
|
11495
|
+
return true;
|
|
11470
11496
|
}
|
|
11471
11497
|
};
|
|
11472
11498
|
return {
|
|
@@ -11475,6 +11501,7 @@ function useSteps() {
|
|
|
11475
11501
|
stepHistory: stepHistory2,
|
|
11476
11502
|
stepQueue: stepQueue2,
|
|
11477
11503
|
enabledSteps: enabledSteps2,
|
|
11504
|
+
stepEnabled: stepEnabled2,
|
|
11478
11505
|
defaultOrder: defaultOrder2,
|
|
11479
11506
|
activeStep: activeStep2,
|
|
11480
11507
|
firstStep: firstStep2,
|
|
@@ -11494,6 +11521,7 @@ var {
|
|
|
11494
11521
|
stepHistory,
|
|
11495
11522
|
stepQueue,
|
|
11496
11523
|
enabledSteps,
|
|
11524
|
+
stepEnabled: _stepEnabled,
|
|
11497
11525
|
defaultOrder,
|
|
11498
11526
|
activeStep,
|
|
11499
11527
|
firstStep: _firstStep,
|
|
@@ -11513,6 +11541,9 @@ var dataDefaults = {
|
|
|
11513
11541
|
var backup = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : null;
|
|
11514
11542
|
return urlParams$2.get(name) || backup;
|
|
11515
11543
|
},
|
|
11544
|
+
stepKeys: () => {
|
|
11545
|
+
return Object.keys(steps$1);
|
|
11546
|
+
},
|
|
11516
11547
|
firstStep: () => {
|
|
11517
11548
|
return _firstStep();
|
|
11518
11549
|
},
|
|
@@ -11533,19 +11564,19 @@ var dataDefaults = {
|
|
|
11533
11564
|
preStep
|
|
11534
11565
|
});
|
|
11535
11566
|
},
|
|
11536
|
-
|
|
11567
|
+
stepValid: (stepName) => {
|
|
11537
11568
|
return steps$1[stepName].valid && steps$1[stepName].errorCount === 0;
|
|
11538
11569
|
},
|
|
11539
|
-
|
|
11570
|
+
stepEnabled: (stepName) => {
|
|
11540
11571
|
if (!enabledSteps().length) {
|
|
11541
11572
|
return true;
|
|
11542
11573
|
}
|
|
11543
|
-
return
|
|
11574
|
+
return _stepEnabled(stepName);
|
|
11544
11575
|
},
|
|
11545
11576
|
getKey: (d3, k2, def2) => {
|
|
11546
11577
|
return _getKey(d3, k2, def2);
|
|
11547
11578
|
},
|
|
11548
|
-
|
|
11579
|
+
inputEnabled: (node2, key, inputName) => {
|
|
11549
11580
|
if (!node2 || !key || !node2.attrs.inputMap) {
|
|
11550
11581
|
return true;
|
|
11551
11582
|
}
|
|
@@ -11568,7 +11599,7 @@ var dataDefaults = {
|
|
|
11568
11599
|
var redirect = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
11569
11600
|
var contentType = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "application/json";
|
|
11570
11601
|
return /* @__PURE__ */ function() {
|
|
11571
|
-
var
|
|
11602
|
+
var _ref8 = _asyncToGenerator(function* (formData, node2) {
|
|
11572
11603
|
if (prepData2 && prepData2 != "null") {
|
|
11573
11604
|
if (!(prepData2 instanceof Function)) {
|
|
11574
11605
|
throw "prepData must be a function";
|
|
@@ -11598,7 +11629,7 @@ var dataDefaults = {
|
|
|
11598
11629
|
}
|
|
11599
11630
|
});
|
|
11600
11631
|
return function(_x4, _x5) {
|
|
11601
|
-
return
|
|
11632
|
+
return _ref8.apply(this, arguments);
|
|
11602
11633
|
};
|
|
11603
11634
|
}();
|
|
11604
11635
|
},
|
|
@@ -12804,39 +12835,46 @@ function syncListNodes(node2, context) {
|
|
|
12804
12835
|
var newChildren = [];
|
|
12805
12836
|
var unused = new Set(context.children);
|
|
12806
12837
|
var placeholderValues = /* @__PURE__ */ new Map();
|
|
12807
|
-
_value.forEach((
|
|
12808
|
-
if (context.children[i2] && context.children[i2]._value ===
|
|
12838
|
+
_value.forEach((value, i2) => {
|
|
12839
|
+
if (context.children[i2] && context.children[i2]._value === value) {
|
|
12809
12840
|
newChildren.push(context.children[i2]);
|
|
12810
12841
|
unused.delete(context.children[i2]);
|
|
12811
12842
|
} else {
|
|
12812
12843
|
newChildren.push(null);
|
|
12813
|
-
placeholderValues.
|
|
12844
|
+
var indexes = placeholderValues.get(value) || [];
|
|
12845
|
+
indexes.push(i2);
|
|
12846
|
+
placeholderValues.set(value, indexes);
|
|
12814
12847
|
}
|
|
12815
12848
|
});
|
|
12816
12849
|
if (unused.size && placeholderValues.size) {
|
|
12817
12850
|
unused.forEach((child2) => {
|
|
12818
12851
|
if (placeholderValues.has(child2._value)) {
|
|
12819
|
-
|
|
12852
|
+
var indexes = placeholderValues.get(child2._value);
|
|
12853
|
+
var index3 = indexes.shift();
|
|
12854
|
+
newChildren[index3] = child2;
|
|
12820
12855
|
unused.delete(child2);
|
|
12821
|
-
|
|
12856
|
+
if (!indexes.length)
|
|
12857
|
+
placeholderValues.delete(child2._value);
|
|
12822
12858
|
}
|
|
12823
12859
|
});
|
|
12824
12860
|
}
|
|
12825
|
-
|
|
12861
|
+
var emptyIndexes = [];
|
|
12862
|
+
placeholderValues.forEach((indexes) => {
|
|
12863
|
+
emptyIndexes.push(...indexes);
|
|
12864
|
+
});
|
|
12865
|
+
while (unused.size && emptyIndexes.length) {
|
|
12826
12866
|
var child = unused.values().next().value;
|
|
12827
|
-
var
|
|
12828
|
-
|
|
12867
|
+
var index2 = emptyIndexes.shift();
|
|
12868
|
+
if (index2 === void 0)
|
|
12869
|
+
break;
|
|
12829
12870
|
newChildren[index2] = child;
|
|
12830
12871
|
unused.delete(child);
|
|
12831
|
-
placeholderValues.delete(value);
|
|
12832
12872
|
}
|
|
12833
|
-
|
|
12834
|
-
|
|
12835
|
-
|
|
12836
|
-
value: value2
|
|
12837
|
-
});
|
|
12873
|
+
emptyIndexes.forEach((index3, value) => {
|
|
12874
|
+
newChildren[index3] = createPlaceholder({
|
|
12875
|
+
value
|
|
12838
12876
|
});
|
|
12839
|
-
}
|
|
12877
|
+
});
|
|
12840
12878
|
if (unused.size) {
|
|
12841
12879
|
unused.forEach((child2) => {
|
|
12842
12880
|
if (!("__FKP" in child2)) {
|
|
@@ -13848,7 +13886,7 @@ function clearErrors(id2) {
|
|
|
13848
13886
|
warn(652, id2);
|
|
13849
13887
|
}
|
|
13850
13888
|
}
|
|
13851
|
-
var FORMKIT_VERSION = "0.17.
|
|
13889
|
+
var FORMKIT_VERSION = "0.17.2";
|
|
13852
13890
|
function createLibraryPlugin() {
|
|
13853
13891
|
for (var _len = arguments.length, libraries = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13854
13892
|
libraries[_key] = arguments[_key];
|
|
@@ -18630,7 +18668,7 @@ function useInput(props2, context) {
|
|
|
18630
18668
|
}
|
|
18631
18669
|
if (isVModeled && node2.context) {
|
|
18632
18670
|
clonedValueBeforeVmodel = cloneAny(node2.value);
|
|
18633
|
-
context.emit("update:modelValue", node2.value);
|
|
18671
|
+
context.emit("update:modelValue", shallowClone(node2.value));
|
|
18634
18672
|
}
|
|
18635
18673
|
});
|
|
18636
18674
|
if (isVModeled) {
|
|
@@ -18675,6 +18713,9 @@ function createInput(schemaOrComponent) {
|
|
|
18675
18713
|
schema = createSection("input", () => cloneAny(schemaOrComponent));
|
|
18676
18714
|
}
|
|
18677
18715
|
definition2.schema = useSchema(schema || "Schema undefined");
|
|
18716
|
+
if (!definition2.schemaMemoKey) {
|
|
18717
|
+
definition2.schemaMemoKey = "".concat(Math.random());
|
|
18718
|
+
}
|
|
18678
18719
|
return definition2;
|
|
18679
18720
|
}
|
|
18680
18721
|
var messages = createSection("messages", () => ({
|
|
@@ -18973,8 +19014,12 @@ var vueBindings = function vueBindings2(node2) {
|
|
|
18973
19014
|
var {
|
|
18974
19015
|
payload
|
|
18975
19016
|
} = _ref10;
|
|
18976
|
-
|
|
18977
|
-
|
|
19017
|
+
if (node2.type !== "input" && !isRef(payload) && !isReactive(payload)) {
|
|
19018
|
+
value.value = _value.value = shallowClone(payload);
|
|
19019
|
+
} else {
|
|
19020
|
+
value.value = _value.value = payload;
|
|
19021
|
+
triggerRef(value);
|
|
19022
|
+
}
|
|
18978
19023
|
node2.emit("modelUpdated");
|
|
18979
19024
|
});
|
|
18980
19025
|
node2.on("commit", () => {
|
|
@@ -19646,42 +19691,112 @@ var multiStepOuter = createSection("multiStepOuter", () => ({
|
|
|
19646
19691
|
props: ["previousLabel", "nextLabel", "beforeStepChange", "previousAttrs", "nextAttrs", "validStepIcon"],
|
|
19647
19692
|
features: [localize$2("next"), localize$2("prev")]
|
|
19648
19693
|
});
|
|
19649
|
-
function createLocalStoragePlugin(
|
|
19694
|
+
function createLocalStoragePlugin(localStorageOptions) {
|
|
19650
19695
|
var localStoragePlugin = (node2) => {
|
|
19651
|
-
if (node2.
|
|
19696
|
+
if (node2.type !== "group")
|
|
19652
19697
|
return;
|
|
19653
|
-
|
|
19654
|
-
|
|
19655
|
-
|
|
19656
|
-
|
|
19657
|
-
|
|
19658
|
-
|
|
19659
|
-
|
|
19660
|
-
|
|
19661
|
-
var
|
|
19662
|
-
|
|
19663
|
-
|
|
19664
|
-
|
|
19665
|
-
|
|
19666
|
-
|
|
19667
|
-
|
|
19668
|
-
|
|
19698
|
+
var shouldUseLocalStorage = (controlNode) => {
|
|
19699
|
+
var controlFieldValue = true;
|
|
19700
|
+
if (controlNode) {
|
|
19701
|
+
controlFieldValue = controlNode.value === true;
|
|
19702
|
+
}
|
|
19703
|
+
return undefine(node2.props.useLocalStorage) && controlFieldValue;
|
|
19704
|
+
};
|
|
19705
|
+
node2.on("created", /* @__PURE__ */ _asyncToGenerator(function* () {
|
|
19706
|
+
var _a, _b, _c;
|
|
19707
|
+
node2.addProps(["useLocalStorage"]);
|
|
19708
|
+
yield node2.settled;
|
|
19709
|
+
var controlField = (_a = localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.control) !== null && _a !== void 0 ? _a : void 0;
|
|
19710
|
+
var controlNode;
|
|
19711
|
+
if (typeof controlField === "string") {
|
|
19712
|
+
var _controlNode = node2.at(controlField);
|
|
19713
|
+
if (_controlNode) {
|
|
19714
|
+
_controlNode.on("commit", () => {
|
|
19715
|
+
useLocalStorage = shouldUseLocalStorage(_controlNode);
|
|
19716
|
+
if (!useLocalStorage) {
|
|
19717
|
+
localStorage.removeItem(storageKey);
|
|
19718
|
+
}
|
|
19719
|
+
});
|
|
19669
19720
|
}
|
|
19670
19721
|
}
|
|
19671
|
-
|
|
19722
|
+
var useLocalStorage = shouldUseLocalStorage(controlNode);
|
|
19723
|
+
var saveTimeout = 0;
|
|
19724
|
+
var debounce = typeof (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.debounce) === "number" ? localStorageOptions.debounce : 200;
|
|
19725
|
+
var prefix2 = (_b = localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.prefix) !== null && _b !== void 0 ? _b : "formkit";
|
|
19726
|
+
var maxAge = (_c = localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.maxAge) !== null && _c !== void 0 ? _c : 36e5;
|
|
19727
|
+
var key = (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.key) ? "-".concat(localStorageOptions.key) : "";
|
|
19728
|
+
var storageKey = "".concat(prefix2).concat(key, "-").concat(node2.name);
|
|
19729
|
+
var loadValue = /* @__PURE__ */ function() {
|
|
19730
|
+
var _ref7 = _asyncToGenerator(function* () {
|
|
19731
|
+
var value = localStorage.getItem(storageKey);
|
|
19732
|
+
if (!value)
|
|
19733
|
+
return;
|
|
19734
|
+
var loadValue2 = JSON.parse(value);
|
|
19735
|
+
if (typeof (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.beforeLoad) === "function") {
|
|
19736
|
+
node2.props.disabled = true;
|
|
19737
|
+
try {
|
|
19738
|
+
loadValue2.data = yield localStorageOptions.beforeLoad(loadValue2.data);
|
|
19739
|
+
} catch (error2) {
|
|
19740
|
+
console.error(error2);
|
|
19741
|
+
}
|
|
19742
|
+
node2.props.disabled = false;
|
|
19743
|
+
}
|
|
19744
|
+
if (!loadValue2 || typeof loadValue2.data !== "object")
|
|
19745
|
+
return;
|
|
19746
|
+
if (loadValue2.maxAge > Date.now()) {
|
|
19747
|
+
node2.input(loadValue2.data, false);
|
|
19748
|
+
} else {
|
|
19749
|
+
localStorage.removeItem(storageKey);
|
|
19750
|
+
}
|
|
19751
|
+
});
|
|
19752
|
+
return function loadValue2() {
|
|
19753
|
+
return _ref7.apply(this, arguments);
|
|
19754
|
+
};
|
|
19755
|
+
}();
|
|
19756
|
+
var saveValue = /* @__PURE__ */ function() {
|
|
19757
|
+
var _ref8 = _asyncToGenerator(function* (payload) {
|
|
19758
|
+
var savePayload = payload;
|
|
19759
|
+
if (typeof (localStorageOptions === null || localStorageOptions === void 0 ? void 0 : localStorageOptions.beforeSave) === "function") {
|
|
19760
|
+
try {
|
|
19761
|
+
savePayload = yield localStorageOptions.beforeSave(payload);
|
|
19762
|
+
} catch (error2) {
|
|
19763
|
+
console.error(error2);
|
|
19764
|
+
}
|
|
19765
|
+
}
|
|
19766
|
+
if (!savePayload)
|
|
19767
|
+
return;
|
|
19768
|
+
localStorage.setItem(storageKey, JSON.stringify({
|
|
19769
|
+
maxAge: Date.now() + maxAge,
|
|
19770
|
+
data: savePayload
|
|
19771
|
+
}));
|
|
19772
|
+
});
|
|
19773
|
+
return function saveValue2(_x) {
|
|
19774
|
+
return _ref8.apply(this, arguments);
|
|
19775
|
+
};
|
|
19776
|
+
}();
|
|
19777
|
+
node2.on("commit", (_ref9) => {
|
|
19672
19778
|
var {
|
|
19673
19779
|
payload
|
|
19674
|
-
} =
|
|
19675
|
-
|
|
19676
|
-
|
|
19677
|
-
|
|
19678
|
-
|
|
19780
|
+
} = _ref9;
|
|
19781
|
+
if (!useLocalStorage)
|
|
19782
|
+
return;
|
|
19783
|
+
clearTimeout(saveTimeout);
|
|
19784
|
+
saveTimeout = setTimeout(/* @__PURE__ */ _asyncToGenerator(function* () {
|
|
19785
|
+
saveValue(payload);
|
|
19786
|
+
}), debounce);
|
|
19787
|
+
});
|
|
19788
|
+
node2.on("prop:useLocalStorage", () => {
|
|
19789
|
+
useLocalStorage = shouldUseLocalStorage(controlNode);
|
|
19790
|
+
if (!useLocalStorage) {
|
|
19791
|
+
localStorage.removeItem(storageKey);
|
|
19792
|
+
}
|
|
19679
19793
|
});
|
|
19680
19794
|
node2.hook.submit((payload, next3) => {
|
|
19681
|
-
localStorage.removeItem(
|
|
19795
|
+
localStorage.removeItem(storageKey);
|
|
19682
19796
|
return next3(payload);
|
|
19683
19797
|
});
|
|
19684
|
-
|
|
19798
|
+
yield loadValue();
|
|
19799
|
+
}));
|
|
19685
19800
|
};
|
|
19686
19801
|
return localStoragePlugin;
|
|
19687
19802
|
}
|