@gravel-form/blueprintjs
Version:
A flexible middlewares driven json schema form with Blueprintjs
1 lines • 1.35 kB
Source Map (JSON)
{"version":3,"sources":["middlewares/DatePickerMw.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B,OAAO,EAAE,4BAA4B,EAAE,MAAM,UAAU,CAAC;AAUxD,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,EAAE,CAAC,4BAA4B,CAmB9D,CAAC;AAEF,eAAe,WAAW,CAAC","file":"DatePickerMw.d.ts","sourcesContent":["import * as React from 'react';\nimport get from 'lodash/get';\nimport { Callout, Intent } from '@blueprintjs/core';\n\nimport { BlueprintFormMiddlewareProps } from '../share';\n\nconst { DateInput } = (() => {\n try {\n return require('@blueprintjs/datetime');\n } catch (_) {\n return {};\n }\n})();\n\nexport const DateInputMw: React.FC<BlueprintFormMiddlewareProps> = (props) => {\n const { next, schema, data, onChange, extraProps } = props;\n\n if (typeof schema === 'boolean' || schema.type !== 'string') return next(props);\n\n if (!DateInput) return <Callout intent={Intent.DANGER}>\"@blueprintjs/datetime\" is not installed</Callout>;\n\n return (\n <DateInput\n fill\n value={typeof data === 'string' ? new Date(data) : null}\n parseDate={(date: Date) => date}\n formatDate={(date: Date) => date.toLocaleDateString()}\n onChange={(date: Date) => {\n onChange(date ? date.toISOString() : undefined);\n }}\n {...get(extraProps, 'props')}\n />\n );\n};\n\nexport default DateInputMw;\n"]}