@hashicorp/react-boolean-input
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -69,8 +69,13 @@ 'use strict'; | ||
// set up state for the input value | ||
var _useState = React.useState(value || false), | ||
var _useState = React.useState(false), | ||
_useState2 = _slicedToArray(_useState, 2), | ||
stateValue = _useState2[0], | ||
setValue = _useState2[1]; // if the parent changes the value, reflect it to state | ||
setValue = _useState2[1]; | ||
var _useState3 = React.useState(false), | ||
_useState4 = _slicedToArray(_useState3, 2), | ||
isDirty = _useState4[0], | ||
setIsDirty = _useState4[1]; // if the parent changes the value, reflect it to state | ||
React.useEffect(function () { | ||
@@ -81,2 +86,4 @@ return setValue(value); | ||
React.useEffect(function () { | ||
// if the input hasn't been touched, don't pass up the value | ||
if (!isDirty) return; | ||
return onValueChange && onValueChange(stateValue); | ||
@@ -98,2 +105,3 @@ }, [stateValue]); // generate a uid to pair the label to the input | ||
onChange: function onChange(e) { | ||
setIsDirty(true); | ||
return setValue(e.target.checked); | ||
@@ -100,0 +108,0 @@ } |
{ | ||
"name": "@hashicorp/react-boolean-input", | ||
"description": "A checkbox input", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"main": "dist", | ||
@@ -18,3 +18,3 @@ "dependencies": { | ||
}, | ||
"gitHead": "2f16ae732cb52aebad1e0e533952c6b526ac7701" | ||
"gitHead": "ec287ce1525fcf8d4bd84969367e55711cad9cbb" | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
28656
369
0