@thecb/components 6.1.0-beta.3 → 6.1.0-beta.4

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
@@ -6092,9 +6092,16 @@ 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, resetErrors) {
6096
6096
  return function (e) {
6097
6097
  e.preventDefault();
6098
+
6099
+ if (resetErrors) {
6100
+ // if provided, will reset error state tracker
6101
+ // allows hooks that depend on error state to re-run
6102
+ resetErrors();
6103
+ }
6104
+
6098
6105
  var formHasError = Object.values(form.fields).reduce(function (acc, curr) {
6099
6106
  return acc || curr.hasErrors;
6100
6107
  }, false);
@@ -43649,14 +43656,18 @@ var index$4 = /*#__PURE__*/Object.freeze({
43649
43656
 
43650
43657
  var useFocusInvalidInput = function useFocusInvalidInput() {
43651
43658
  var showErrors = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
43652
- // Only move focus when "showErrors" is true
43659
+ console.log("hey show errors", showErrors); // Only move focus when "showErrors" is true
43653
43660
  // "showErrors" is managed by container page of form
43654
43661
  // typically set to "true" on attempted form submission, if errors exist
43662
+
43655
43663
  useEffect$1(function () {
43664
+ console.log("inside use effect show errors", showErrors);
43665
+
43656
43666
  if (showErrors) {
43657
43667
  var _inputsWithErrors$;
43658
43668
 
43659
43669
  var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
43670
+ console.log("inputs with errors is", inputsWithErrors);
43660
43671
  inputsWithErrors === null || inputsWithErrors === void 0 ? void 0 : (_inputsWithErrors$ = inputsWithErrors[0]) === null || _inputsWithErrors$ === void 0 ? void 0 : _inputsWithErrors$.focus();
43661
43672
  }
43662
43673
  }, [showErrors]);