UNPKG

@aokiapp/rjsf-mantine-theme

Version:

Mantine theme, fields and widgets for react-jsonschema-form

19 lines 1.47 kB
import { jsx as _jsx } from "react/jsx-runtime"; import { labelValue, ariaDescribedByIds, } from '@rjsf/utils'; import { useCallback } from 'react'; import { DateTimePicker } from '@mantine/dates'; import { createErrors } from '../utils/createErrors'; /** 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 MantineDateTimeWidget(props) { const { id, placeholder, label, hideLabel, value, required, readonly, disabled, onChange, onChangeOverride, autofocus, rawErrors, hideError, options, schema, } = props; const description = options.description || schema.description; // TODO: options const inputValue = value ? new Date(value) : null; const _onChange = useCallback((value) => onChange(value ? value.toJSON() : undefined), [onChange]); return (_jsx(DateTimePicker, { withSeconds: true, value: inputValue, onChange: onChangeOverride || _onChange, id: id, placeholder: placeholder, label: labelValue(label, hideLabel, undefined), required: required, clearable: !required, disabled: disabled || readonly, autoFocus: autofocus, error: createErrors(rawErrors, hideError), "aria-describedby": ariaDescribedByIds(id), className: 'armt-widget-datetime-mt', description: description }, id)); } //# sourceMappingURL=MantineDateTimeWidget.js.map