@thecb/components 6.1.0-beta.4 → 6.1.0-beta.7
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/index.esm.js
CHANGED
|
@@ -6097,9 +6097,10 @@ var generateClickHandler = function generateClickHandler(form, handleErrors, sub
|
|
|
6097
6097
|
e.preventDefault();
|
|
6098
6098
|
|
|
6099
6099
|
if (resetErrors) {
|
|
6100
|
-
// if provided, will reset error state tracker
|
|
6100
|
+
console.log("reset errors", resetErrors); // if provided, will reset error state tracker
|
|
6101
6101
|
// allows hooks that depend on error state to re-run
|
|
6102
|
-
|
|
6102
|
+
|
|
6103
|
+
resetErrors(false);
|
|
6103
6104
|
}
|
|
6104
6105
|
|
|
6105
6106
|
var formHasError = Object.values(form.fields).reduce(function (acc, curr) {
|
|
@@ -43654,23 +43655,27 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
43654
43655
|
fontWeights: style_constants
|
|
43655
43656
|
});
|
|
43656
43657
|
|
|
43657
|
-
var useFocusInvalidInput = function useFocusInvalidInput() {
|
|
43658
|
-
var
|
|
43659
|
-
console.log("hey show errors",
|
|
43660
|
-
// "
|
|
43658
|
+
var useFocusInvalidInput = function useFocusInvalidInput(hasErrors) {
|
|
43659
|
+
var resetHasErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
|
|
43660
|
+
console.log("hey show errors", hasErrors); // Only move focus when "hasErrors" is true
|
|
43661
|
+
// "hasErrors" is managed by container page of form
|
|
43661
43662
|
// typically set to "true" on attempted form submission, if errors exist
|
|
43662
43663
|
|
|
43663
43664
|
useEffect$1(function () {
|
|
43664
|
-
console.log("inside use effect show errors",
|
|
43665
|
+
console.log("inside use effect show errors", hasErrors);
|
|
43665
43666
|
|
|
43666
|
-
if (
|
|
43667
|
+
if (hasErrors) {
|
|
43667
43668
|
var _inputsWithErrors$;
|
|
43668
43669
|
|
|
43669
43670
|
var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
|
|
43670
43671
|
console.log("inputs with errors is", inputsWithErrors);
|
|
43671
43672
|
inputsWithErrors === null || inputsWithErrors === void 0 ? void 0 : (_inputsWithErrors$ = inputsWithErrors[0]) === null || _inputsWithErrors$ === void 0 ? void 0 : _inputsWithErrors$.focus();
|
|
43672
43673
|
}
|
|
43673
|
-
|
|
43674
|
+
|
|
43675
|
+
return function () {
|
|
43676
|
+
return resetHasErrors(false);
|
|
43677
|
+
};
|
|
43678
|
+
});
|
|
43674
43679
|
};
|
|
43675
43680
|
|
|
43676
43681
|
|