UNPKG

zmp-react

Version:

Build full featured iOS & Android apps using ZMP & React

47 lines (44 loc) 1.35 kB
import _extends from "@babel/runtime/helpers/extends"; import React, { useRef, forwardRef, useImperativeHandle } from 'react'; import Checkbox from '../components/checkbox'; import { classNames } from '../shared/utils'; /* dts-props id: string | number; className: string; style: React.CSSProperties; checked? : boolean indeterminate? : boolean name? : number | string value? : number | string | boolean disabled? : boolean readonly? : boolean label? : string defaultChecked? : boolean ref?: React.MutableRefObject<{el: HTMLElement | null; inputEl: HTMLElement | null}>; COLOR_PROPS onChange? : (event?: any) => void CHILDREN_PROP */ var ZMPCheckbox = /*#__PURE__*/forwardRef(function (props, ref) { var elRef = useRef(null); var label = props.label, children = props.children, className = props.className; useImperativeHandle(ref, function () { return elRef.current; }); var labelEl = null; if (label) { labelEl = /*#__PURE__*/React.createElement("span", { className: "zmp-checkbox-label" }, label); } var classes = classNames(className, 'no-ripple'); return /*#__PURE__*/React.createElement(Checkbox, _extends({ ref: elRef }, props, { className: classes }), labelEl, children); }); ZMPCheckbox.displayName = 'zmp-checkbox'; export default ZMPCheckbox;