@gravel-form/antd
Version:
A flexible middlewares driven json schema form with Ant Design
1 lines • 1.04 kB
Source Map (JSON)
{"version":3,"sources":["middlewares/RadioGroupMw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,eAAe,CAelD,CAAC;AAEF,eAAe,YAAY,CAAC","file":"RadioGroupMw.d.ts","sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { Radio } from 'antd';\nimport { MiddlewareProps } from '../share';\n\nexport const RadioGroupMw: React.FC<MiddlewareProps> = (props) => {\n const { schema, onChange, data, extraProps, next } = props;\n if (typeof schema === 'boolean' || !schema.enum) return next(props);\n\n const labels = get(extraProps, 'labels', schema.enum);\n\n return (\n <Radio.Group onChange={(e) => onChange(e.target.value)} value={data} {...get(extraProps, 'props')}>\n {schema.enum.map((value, index) => (\n <Radio key={JSON.stringify(value)} value={value}>\n {get(labels, index, null)}\n </Radio>\n ))}\n </Radio.Group>\n );\n};\n\nexport default RadioGroupMw;\n"]}