UNPKG

@datalayer/primer-rjsf

Version:

React JSON Schema Form (RJSF) for Primer

19 lines (18 loc) 829 B
import { jsx as _jsx } from "react/jsx-runtime"; import { getTemplate, localToUTC, utcToLocal, } from "@rjsf/utils"; /** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms * the value to/from utc using the appropriate utility functions. * * @param props - The `WidgetProps` for this component */ export default function DateTimeWidget(props) { const { options, registry } = props; const BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options); const value = utcToLocal(props.value); const onChange = (value) => { props.onChange(localToUTC(value)); }; return (_jsx(BaseInputTemplate, { type: "datetime-local", InputLabelProps: { shrink: true, }, ...props, value: value, onChange: onChange })); }