@thecb/components 6.1.0-beta.6 → 6.1.1
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 +15 -20
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +15 -20
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/components/atoms/checkbox/Checkbox.js +2 -0
- 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(false);
|
|
6104
|
-
}
|
|
6105
|
-
|
|
6106
6098
|
var formHasError = Object.values(form.fields).reduce(function (acc, curr) {
|
|
6107
6099
|
return acc || curr.hasErrors;
|
|
6108
6100
|
}, false);
|
|
@@ -19169,7 +19161,9 @@ var Checkbox = function Checkbox(_ref4) {
|
|
|
19169
19161
|
"aria-label": name,
|
|
19170
19162
|
checked: checked,
|
|
19171
19163
|
onChange: onChange,
|
|
19172
|
-
tabIndex: "-1"
|
|
19164
|
+
tabIndex: "-1",
|
|
19165
|
+
"aria-invalid": error,
|
|
19166
|
+
"aria-describedby": "".concat(name, "-error-message")
|
|
19173
19167
|
}), /*#__PURE__*/React.createElement(StyledCheckbox, {
|
|
19174
19168
|
error: error,
|
|
19175
19169
|
disabled: disabled,
|
|
@@ -43655,23 +43649,24 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
43655
43649
|
fontWeights: style_constants
|
|
43656
43650
|
});
|
|
43657
43651
|
|
|
43658
|
-
var useFocusInvalidInput = function useFocusInvalidInput() {
|
|
43659
|
-
var
|
|
43660
|
-
|
|
43661
|
-
// "
|
|
43652
|
+
var useFocusInvalidInput = function useFocusInvalidInput(hasErrors) {
|
|
43653
|
+
var resetHasErrors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function () {};
|
|
43654
|
+
// Only move focus when "hasErrors" is true
|
|
43655
|
+
// "hasErrors" is managed by container page of form
|
|
43662
43656
|
// typically set to "true" on attempted form submission, if errors exist
|
|
43663
|
-
|
|
43657
|
+
// Reset errors, if provided, resets the error state tracking in order to properly re-run
|
|
43664
43658
|
useEffect$1(function () {
|
|
43665
|
-
|
|
43666
|
-
|
|
43667
|
-
if (showErrors) {
|
|
43659
|
+
if (hasErrors) {
|
|
43668
43660
|
var _inputsWithErrors$;
|
|
43669
43661
|
|
|
43670
43662
|
var inputsWithErrors = document.querySelectorAll("input[aria-invalid=true]");
|
|
43671
|
-
console.log("inputs with errors is", inputsWithErrors);
|
|
43672
43663
|
inputsWithErrors === null || inputsWithErrors === void 0 ? void 0 : (_inputsWithErrors$ = inputsWithErrors[0]) === null || _inputsWithErrors$ === void 0 ? void 0 : _inputsWithErrors$.focus();
|
|
43673
43664
|
}
|
|
43674
|
-
|
|
43665
|
+
|
|
43666
|
+
return function () {
|
|
43667
|
+
return resetHasErrors(false);
|
|
43668
|
+
};
|
|
43669
|
+
});
|
|
43675
43670
|
};
|
|
43676
43671
|
|
|
43677
43672
|
|