@gravel-form/blueprintjs
Version:
A flexible middlewares driven json schema form with Blueprintjs
1 lines • 897 B
Source Map (JSON)
{"version":3,"sources":["middlewares/SwitchMw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAExD,eAAO,MAAM,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAY3D,CAAC;AAEF,eAAe,QAAQ,CAAC","file":"SwitchMw.d.ts","sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { Switch } from '@blueprintjs/core';\nimport { BlueprintFormMiddlewareProps } from '../share';\n\nexport const SwitchMw: React.FC<BlueprintFormMiddlewareProps> = (props) => {\n const { schema, onChange, data, next, extraProps } = props;\n if (typeof schema === 'boolean' || schema.type !== 'boolean') return next(props);\n\n return (\n <Switch\n label={schema.title}\n checked={data}\n onChange={(e) => onChange(e.currentTarget.checked)}\n {...get(extraProps, 'props')}\n />\n );\n};\n\nexport default SwitchMw;\n"]}