@schema-render/form-render-react
Version:
Out-of-the-box form rendering library based on Core and Antd.
31 lines (30 loc) • 959 B
JavaScript
import { jsx as _jsx } from "react/jsx-runtime";
import { Radio as AntRadio } from "antd";
import React from "react";
import Description from "../components/Description";
import { getOptionsLabels } from "../utils";
/**
* 编辑与禁用态组件
*/ const Radio = ({ schema, disabled, value, onChange })=>{
return /*#__PURE__*/ _jsx(AntRadio.Group, {
...schema.renderOptions,
value: value,
onChange: (e)=>onChange(e.target.value),
disabled: disabled
});
};
/**
* 只读态组件
*/ const ReadonlyRadio = ({ schema, value })=>{
var _schema_renderOptions;
const labels = getOptionsLabels((_schema_renderOptions = schema.renderOptions) === null || _schema_renderOptions === void 0 ? void 0 : _schema_renderOptions.options, [
value
]);
return /*#__PURE__*/ _jsx(Description, {
children: labels[0]
});
};
export default {
component: Radio,
readonlyComponent: ReadonlyRadio
};