@gravel-form/blueprintjs
Version:
A flexible middlewares driven json schema form with Blueprintjs
1 lines • 1.12 kB
Source Map (JSON)
{"version":3,"sources":["middlewares/SliderMw.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,aAAa,CAAC,4BAA4B,CAiBtE,CAAC;AAEF,eAAe,QAAQ,CAAC","file":"SliderMw.d.ts","sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { Slider } from '@blueprintjs/core';\nimport { BlueprintFormMiddlewareProps } from '../share';\n\nexport const SliderMw: React.ComponentType<BlueprintFormMiddlewareProps> = (props) => {\n const { next, schema, data, onChange, extraProps } = props;\n if (typeof schema === 'boolean' || !(schema.type === 'number' || schema.type === 'integer')) return next(props);\n const min = schema.minimum || 0;\n const max = schema.maximum || 100;\n return (\n <Slider\n min={min}\n max={max}\n labelStepSize={max - min}\n value={typeof data === 'number' ? data : undefined}\n onChange={(value) => {\n if (!Array.isArray(value)) onChange(value);\n }}\n {...get(extraProps, 'props')}\n />\n );\n};\n\nexport default SliderMw;\n"]}