Comparing version 0.0.25 to 0.0.26
/*! | ||
* Eyzy v0.0.24 | ||
* Eyzy v0.0.26 | ||
* (c) 2022 amsik | ||
@@ -492,3 +492,3 @@ * Released under the MIT License. | ||
function Checkbox(props, ref) { | ||
var className = props.className, width = props.width, required = props.required, error = props.error, helpText = props.helpText, label = props.label, onChange = props.onChange, children = props.children, rest = __rest(props, ["className", "width", "required", "error", "helpText", "label", "onChange", "children"]); | ||
var className = props.className, width = props.width, required = props.required, error = props.error, helpText = props.helpText, label = props.label, autoFocus = props.autoFocus, children = props.children, defaultChecked = props.defaultChecked, useRing = props.useRing, onChange = props.onChange, rest = __rest(props, ["className", "width", "required", "error", "helpText", "label", "autoFocus", "children", "defaultChecked", "useRing", "onChange"]); | ||
var id = React.useMemo(function () { return "e-" + uid(); }, []); | ||
@@ -498,8 +498,23 @@ var _a = React.useState('checked' in props | ||
: !!props.defaultChecked), checked = _a[0], setChecked = _a[1]; | ||
var isFocused = useFocusRing(id, !!autoFocus); | ||
var classNames = cn('e-checkbox', className); | ||
var eOuterClassName = cn('e-outer', { | ||
'e-ring': useRing && isFocused | ||
}); | ||
var handleChange = function (e) { | ||
setChecked(e.target.checked); | ||
if (onChange) { | ||
onChange(e.target.checked); | ||
} | ||
}; | ||
return (React__default.createElement("div", { className: 'e-checkbox' }, | ||
React__default.createElement("input", __assign({ type: "checkbox", onChange: handleChange, checked: checked, id: id }, rest)), | ||
React__default.createElement("span", { className: "e-outer" }, | ||
React.useEffect(function () { | ||
if (props.checked === undefined) { | ||
setChecked(!!props.defaultChecked); | ||
} | ||
else | ||
(setChecked(props.checked)); | ||
}, [props.checked, props.defaultChecked]); | ||
return (React__default.createElement("div", { className: classNames }, | ||
React__default.createElement("input", __assign({ type: "checkbox", onChange: handleChange, checked: checked, id: id, autoFocus: autoFocus, ref: ref }, rest)), | ||
React__default.createElement("span", { className: eOuterClassName }, | ||
React__default.createElement("span", { className: "e-inner" }, checked && (React__default.createElement("svg", { focusable: "false", role: "img" }, | ||
@@ -506,0 +521,0 @@ React__default.createElement("path", { d: "M3.788 9A.999.999 0 0 1 3 8.615l-2.288-3a1 1 0 1 1 1.576-1.23l1.5 1.991 3.924-4.991a1 1 0 1 1 1.576 1.23l-4.712 6A.999.999 0 0 1 3.788 9z" }))))), |
/*! | ||
* Eyzy v0.0.24 | ||
* Eyzy v0.0.26 | ||
* (c) 2022 amsik | ||
@@ -486,3 +486,3 @@ * Released under the MIT License. | ||
function Checkbox(props, ref) { | ||
var className = props.className, width = props.width, required = props.required, error = props.error, helpText = props.helpText, label = props.label, onChange = props.onChange, children = props.children, rest = __rest(props, ["className", "width", "required", "error", "helpText", "label", "onChange", "children"]); | ||
var className = props.className, width = props.width, required = props.required, error = props.error, helpText = props.helpText, label = props.label, autoFocus = props.autoFocus, children = props.children, defaultChecked = props.defaultChecked, useRing = props.useRing, onChange = props.onChange, rest = __rest(props, ["className", "width", "required", "error", "helpText", "label", "autoFocus", "children", "defaultChecked", "useRing", "onChange"]); | ||
var id = useMemo(function () { return "e-" + uid(); }, []); | ||
@@ -492,8 +492,23 @@ var _a = useState('checked' in props | ||
: !!props.defaultChecked), checked = _a[0], setChecked = _a[1]; | ||
var isFocused = useFocusRing(id, !!autoFocus); | ||
var classNames = cn('e-checkbox', className); | ||
var eOuterClassName = cn('e-outer', { | ||
'e-ring': useRing && isFocused | ||
}); | ||
var handleChange = function (e) { | ||
setChecked(e.target.checked); | ||
if (onChange) { | ||
onChange(e.target.checked); | ||
} | ||
}; | ||
return (React.createElement("div", { className: 'e-checkbox' }, | ||
React.createElement("input", __assign({ type: "checkbox", onChange: handleChange, checked: checked, id: id }, rest)), | ||
React.createElement("span", { className: "e-outer" }, | ||
useEffect(function () { | ||
if (props.checked === undefined) { | ||
setChecked(!!props.defaultChecked); | ||
} | ||
else | ||
(setChecked(props.checked)); | ||
}, [props.checked, props.defaultChecked]); | ||
return (React.createElement("div", { className: classNames }, | ||
React.createElement("input", __assign({ type: "checkbox", onChange: handleChange, checked: checked, id: id, autoFocus: autoFocus, ref: ref }, rest)), | ||
React.createElement("span", { className: eOuterClassName }, | ||
React.createElement("span", { className: "e-inner" }, checked && (React.createElement("svg", { focusable: "false", role: "img" }, | ||
@@ -500,0 +515,0 @@ React.createElement("path", { d: "M3.788 9A.999.999 0 0 1 3 8.615l-2.288-3a1 1 0 1 1 1.576-1.23l1.5 1.991 3.924-4.991a1 1 0 1 1 1.576 1.23l-4.712 6A.999.999 0 0 1 3.788 9z" }))))), |
{ | ||
"name": "eyzy", | ||
"version": "0.0.25", | ||
"version": "0.0.26", | ||
"author": "Kostiantyn", | ||
@@ -5,0 +5,0 @@ "description": "React UI Toolkit", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
176171
1708