UNPKG

zent

Version:

一套前端设计语言和基于React的实现

20 lines (19 loc) 1.19 kB
import { __assign } from "tslib"; import { jsx as _jsx } from "react/jsx-runtime"; import cx from 'classnames'; import { useContext, useMemo } from 'react'; import GroupContext from './GroupContext'; import { DisabledContext } from '../disabled'; export function RadioGroup(props) { var disabledCtx = useContext(DisabledContext); var value = props.value, _a = props.disabled, disabled = _a === void 0 ? disabledCtx.value : _a, _b = props.readOnly, readOnly = _b === void 0 ? false : _b, _c = props.isValueEqual, isValueEqual = _c === void 0 ? Object.is : _c, className = props.className, style = props.style, children = props.children, onChange = props.onChange; var ctx = useMemo(function () { return ({ value: value, disabled: disabled, readOnly: readOnly, isValueEqual: isValueEqual, onRadioChange: onChange, }); }, [value, disabled, readOnly, isValueEqual, onChange]); return (_jsx(GroupContext.Provider, __assign({ value: ctx }, { children: _jsx("div", __assign({ className: cx('zent-radio-group', className), style: style, "data-zv": '10.0.17' }, { children: children }), void 0) }), void 0)); } export default RadioGroup;