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

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