Skip to content

Commit

Permalink
update checkbox types
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt committed Dec 10, 2023
1 parent 3188ee9 commit b1e0db0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/components/input-elements/Checkbox/Checkbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { twMerge } from "tailwind-merge";
import { makeClassName } from "lib";
import { useInternalState } from "hooks";

export interface CheckboxProps {
onChange: (checked: boolean) => void;
export interface CheckboxProps extends React.InputHTMLAttributes<HTMLInputElement> {
onValueChange: (checked: boolean) => void;
checked?: boolean;
defaultChecked?: boolean;
disabled?: boolean;
Expand All @@ -15,11 +15,11 @@ export interface CheckboxProps {
const makeCheckboxClassName = makeClassName("Checkbox");

const Checkbox = React.forwardRef<HTMLInputElement, CheckboxProps>((props, ref) => {
const { onChange, checked, defaultChecked = false, disabled, className, ...other } = props;
const { onValueChange, checked, defaultChecked = false, disabled, className, ...other } = props;
const [isChecked, setIsChecked] = useInternalState(defaultChecked, checked);

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
onChange(e.target.checked);
onValueChange(e.target.checked);
setIsChecked(e.target.checked);
};

Expand Down
2 changes: 1 addition & 1 deletion src/stories/input-elements/helpers/SimpleCheckbox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const SimpleIdCheckbox = (args: any) => {
id="a"
{...args}
checked={checked}
onChange={setChecked}
onValueChange={setChecked}
/>
</div>
<div className="flex gap-4 mt-2">
Expand Down

0 comments on commit b1e0db0

Please sign in to comment.