@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.cjs.js CHANGED
@@ -6105,9 +6105,10 @@ var generateClickHandler = function generateClickHandler(form, handleErrors, sub
6105
6105
  e.preventDefault();
6106
6106
 
6107
6107
  if (resetErrors) {
6108
- // if provided, will reset error state tracker
6108
+ console.log("reset errors", resetErrors); // if provided, will reset error state tracker
6109
6109
  // allows hooks that depend on error state to re-run
6110
- resetErrors();
6110
+
6111
+ resetErrors(false);
6111
6112
  }
6112
6113
 
6113
6114
  var formHasError = Object.values(form.fields).reduce(function (acc, curr) {
@@ -43662,23 +43663,27 @@ var index$4 = /*#__PURE__*/Object.freeze({
43662
43663
  fontWeights: style_constants
43663
43664
  });
43664
43665
 
43665
- var useFocusInvalidInput = function useFocusInvalidInput() {
43666
- var showErrors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
43667
- console.log("hey show errors", showErrors); // Only move focus when "showErrors" is true
43668
- // "showErrors" is managed by container page of form
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
43669
43670
  // typically set to "true" on attempted form submission, if errors exist
43670
43671
 
43671
43672
  React.useEffect(function () {
43672
- console.log("inside use effect show errors", showErrors);
43673
+ console.log("inside use effect show errors", hasErrors);
43673
43674
 
43674
- if (showErrors) {
43675
+ if (hasErrors) {
43675
43676
  var _inputsWithErrors$;
43676
43677
 
43677
43678
  var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
43678
43679
  console.log("inputs with errors is", inputsWithErrors);
43679
43680
  inputsWithErrors === null || inputsWithErrors === void 0 ? void 0 : (_inputsWithErrors$ = inputsWithErrors[0]) === null || _inputsWithErrors$ === void 0 ? void 0 : _inputsWithErrors$.focus();
43680
43681
  }
43681
- }, [showErrors]);
43682
+
43683
+ return function () {
43684
+ return resetHasErrors(false);
43685
+ };
43686
+ });
43682
43687
  };
43683
43688
 
43684
43689