UNPKG

@uiw-admin/components

Version:
28 lines (26 loc) 943 B
import _extends from "@babel/runtime/helpers/extends"; import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose"; var _excluded = ["disabled", "option"]; import React, { useState, useEffect } from 'react'; import { Radio, RadioGroup } from 'uiw'; import { jsx as _jsx } from "react/jsx-runtime"; var FormRadio = _ref => { var { disabled, option } = _ref, others = _objectWithoutPropertiesLoose(_ref, _excluded); var [allDisabled, setAllDisabled] = useState(false); // 全部枚举设为disabled useEffect(() => { setAllDisabled(disabled || false); }, [disabled]); return /*#__PURE__*/_jsx(RadioGroup, _extends({}, others, { children: option && option.map(opt => /*#__PURE__*/_jsx(Radio, { disabled: allDisabled || (opt == null ? void 0 : opt.disabled), value: opt.value, children: opt.label }, opt.value)) })); }; export default FormRadio;