@thecb/components 6.1.0-beta.6 → 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.cjs.js
CHANGED
|
@@ -43663,23 +43663,27 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
43663
43663
|
fontWeights: style_constants
|
|
43664
43664
|
});
|
|
43665
43665
|
|
|
43666
|
-
var useFocusInvalidInput = function useFocusInvalidInput() {
|
|
43667
|
-
var
|
|
43668
|
-
console.log("hey show errors",
|
|
43669
|
-
// "
|
|
43666
|
+
var useFocusInvalidInput = function useFocusInvalidInput(hasErrors) {
|
|
43667
|
+
var resetHasErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
|
|
43668
|
+
console.log("hey show errors", hasErrors); // Only move focus when "hasErrors" is true
|
|
43669
|
+
// "hasErrors" is managed by container page of form
|
|
43670
43670
|
// typically set to "true" on attempted form submission, if errors exist
|
|
43671
43671
|
|
|
43672
43672
|
React.useEffect(function () {
|
|
43673
|
-
console.log("inside use effect show errors",
|
|
43673
|
+
console.log("inside use effect show errors", hasErrors);
|
|
43674
43674
|
|
|
43675
|
-
if (
|
|
43675
|
+
if (hasErrors) {
|
|
43676
43676
|
var _inputsWithErrors$;
|
|
43677
43677
|
|
|
43678
43678
|
var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
|
|
43679
43679
|
console.log("inputs with errors is", inputsWithErrors);
|
|
43680
43680
|
inputsWithErrors === null || inputsWithErrors === void 0 ? void 0 : (_inputsWithErrors$ = inputsWithErrors[0]) === null || _inputsWithErrors$ === void 0 ? void 0 : _inputsWithErrors$.focus();
|
|
43681
43681
|
}
|
|
43682
|
-
|
|
43682
|
+
|
|
43683
|
+
return function () {
|
|
43684
|
+
return resetHasErrors(false);
|
|
43685
|
+
};
|
|
43686
|
+
});
|
|
43683
43687
|
};
|
|
43684
43688
|
|
|
43685
43689
|
|