UNPKG

@clayui/form

Version:
61 lines (60 loc) 1.61 kB
import classNames from "classnames"; import React from "react"; const Checkbox = React.forwardRef( ({ checked, children, className, containerProps = {}, disabled, indeterminate = false, inline, label, ...otherProps }, ref) => { const inputRef = React.useRef(null); React.useEffect(() => { if (inputRef.current) { inputRef.current.indeterminate = indeterminate; } }, [indeterminate]); return /* @__PURE__ */ React.createElement( "div", { ...containerProps, className: classNames( "custom-control custom-checkbox", containerProps.className, { "custom-control-inline": inline, "custom-control-outside": label } ) }, /* @__PURE__ */ React.createElement("label", null, /* @__PURE__ */ React.createElement( "input", { ...otherProps, checked, className: classNames( "custom-control-input", className ), disabled, ref: (r) => { inputRef.current = r; if (typeof ref === "function") { ref(r); } }, type: "checkbox" } ), /* @__PURE__ */ React.createElement("span", { className: "custom-control-label" }, label && /* @__PURE__ */ React.createElement("span", { className: "custom-control-label-text" }, label)), children) ); } ); Checkbox.displayName = "ClayCheckbox"; var Checkbox_default = Checkbox; export { Checkbox_default as default };