(react) add a temporary Checkbox

We need a temporary Checkbox in order to implement the row
selection feature of the future DataGrid. This do not come
from designer sketches for now.
This commit is contained in:
Nathan Vasse
2023-03-06 15:52:01 +01:00
committed by NathanVss
parent 88e478d9f6
commit b84af99c36
2 changed files with 42 additions and 0 deletions

View File

@@ -0,0 +1,17 @@
import React, { HTMLProps, useEffect, useRef } from "react";
export const Checkbox = ({
indeterminate,
className = "",
...rest
}: { indeterminate?: boolean } & HTMLProps<HTMLInputElement>) => {
const ref = useRef<HTMLInputElement>(null!);
useEffect(() => {
if (typeof indeterminate === "boolean") {
ref.current.indeterminate = !rest.checked && indeterminate;
}
}, [ref, indeterminate]);
return <input type="checkbox" ref={ref} className={className} {...rest} />;
};