@gravel-form/blueprintjs
Version:
A flexible middlewares driven json schema form with Blueprintjs
1 lines • 1.2 kB
Source Map (JSON)
{"version":3,"sources":["middlewares/RadioGroupMw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAiB/D,CAAC;AAEF,eAAe,YAAY,CAAC","file":"RadioGroupMw.d.ts","sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { Radio, RadioGroup } from '@blueprintjs/core';\nimport { BlueprintFormMiddlewareProps } from '../share';\n\nexport const RadioGroupMw: React.FC<BlueprintFormMiddlewareProps> = (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 <RadioGroup onChange={(e) => onChange(e.currentTarget.value)} selectedValue={data} {...get(extraProps, 'props')}>\n {schema.enum.map((value, index) => (\n <Radio\n key={JSON.stringify(value)}\n label={get(labels, index, null)}\n value={typeof value === 'string' || typeof value === 'number' ? value : undefined}\n />\n ))}\n </RadioGroup>\n );\n};\n\nexport default RadioGroupMw;\n"]}