@thecb/components 6.1.0-beta.5 → 6.1.0
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 +12 -19
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +12 -19
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/util/focusFirstInvalidInputHook.js +7 -8
- package/src/util/general.js +1 -12
package/dist/index.esm.js
CHANGED
|
@@ -6092,17 +6092,9 @@ var safeChildren = function safeChildren(children) {
|
|
|
6092
6092
|
|
|
6093
6093
|
return unsafeValues.includes(children) ? replacement : children;
|
|
6094
6094
|
};
|
|
6095
|
-
var generateClickHandler = function generateClickHandler(form, handleErrors, submitForm
|
|
6095
|
+
var generateClickHandler = function generateClickHandler(form, handleErrors, submitForm) {
|
|
6096
6096
|
return function (e) {
|
|
6097
6097
|
e.preventDefault();
|
|
6098
|
-
|
|
6099
|
-
if (resetErrors) {
|
|
6100
|
-
console.log("reset errors", resetErrors); // if provided, will reset error state tracker
|
|
6101
|
-
// allows hooks that depend on error state to re-run
|
|
6102
|
-
|
|
6103
|
-
resetErrors();
|
|
6104
|
-
}
|
|
6105
|
-
|
|
6106
6098
|
var formHasError = Object.values(form.fields).reduce(function (acc, curr) {
|
|
6107
6099
|
return acc || curr.hasErrors;
|
|
6108
6100
|
}, false);
|
|
@@ -43655,23 +43647,24 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
43655
43647
|
fontWeights: style_constants
|
|
43656
43648
|
});
|
|
43657
43649
|
|
|
43658
|
-
var useFocusInvalidInput = function useFocusInvalidInput() {
|
|
43659
|
-
var
|
|
43660
|
-
|
|
43661
|
-
// "
|
|
43650
|
+
var useFocusInvalidInput = function useFocusInvalidInput(hasErrors) {
|
|
43651
|
+
var resetHasErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
|
|
43652
|
+
// Only move focus when "hasErrors" is true
|
|
43653
|
+
// "hasErrors" is managed by container page of form
|
|
43662
43654
|
// typically set to "true" on attempted form submission, if errors exist
|
|
43663
|
-
|
|
43655
|
+
// Reset errors, if provided, resets the error state tracking in order to properly re-run
|
|
43664
43656
|
useEffect$1(function () {
|
|
43665
|
-
|
|
43666
|
-
|
|
43667
|
-
if (showErrors) {
|
|
43657
|
+
if (hasErrors) {
|
|
43668
43658
|
var _inputsWithErrors$;
|
|
43669
43659
|
|
|
43670
43660
|
var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
|
|
43671
|
-
console.log("inputs with errors is", inputsWithErrors);
|
|
43672
43661
|
inputsWithErrors === null || inputsWithErrors === void 0 ? void 0 : (_inputsWithErrors$ = inputsWithErrors[0]) === null || _inputsWithErrors$ === void 0 ? void 0 : _inputsWithErrors$.focus();
|
|
43673
43662
|
}
|
|
43674
|
-
|
|
43663
|
+
|
|
43664
|
+
return function () {
|
|
43665
|
+
return resetHasErrors(false);
|
|
43666
|
+
};
|
|
43667
|
+
});
|
|
43675
43668
|
};
|
|
43676
43669
|
|
|
43677
43670
|
|