@wener/console
Version:
Base console UI toolkit
27 lines (26 loc) • 904 B
JavaScript
import React, { forwardRef, useEffect, useRef } from "react";
import { mergeRefs } from "@wener/reaction";
import classNames from "clsx";
import { daisy, omit } from "../utils/daisy.js";
export const Checkbox = /*#__PURE__*/ forwardRef(({ indeterminate, className, ...props }, _ref) => {
const ref = useRef(null);
useEffect(() => {
if (typeof indeterminate === "boolean" && ref.current) {
ref.current.indeterminate = !props.checked && indeterminate;
}
}, [
ref,
indeterminate
]);
return /*#__PURE__*/ React.createElement("input", {
type: "checkbox",
ref: mergeRefs(ref, _ref),
className: classNames("cursor-pointer", daisy("checkbox", props), className),
...omit(props, [
"intent",
"size"
])
});
});
Checkbox.displayName = "Checkbox";
//# sourceMappingURL=Checkbox.js.map