@aokiapp/rjsf-mantine-theme
Version:
Mantine theme, fields and widgets for react-jsonschema-form
52 lines (49 loc) • 1.36 kB
JavaScript
import { 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.mjs';
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;
const inputValue = value ? new Date(value) : null;
const _onChange = useCallback((value2) => onChange(value2 ? value2.toJSON() : void 0), [onChange]);
return /* @__PURE__ */ jsx(
DateTimePicker,
{
withSeconds: true,
value: inputValue,
onChange: onChangeOverride || _onChange,
id,
placeholder,
label: labelValue(label, hideLabel, void 0),
required,
clearable: !required,
disabled: disabled || readonly,
autoFocus: autofocus,
error: createErrors(rawErrors, hideError),
"aria-describedby": ariaDescribedByIds(id),
className: "armt-widget-datetime-mt",
description
},
id
);
}
export { MantineDateTimeWidget as default };
//# sourceMappingURL=MantineDateTimeWidget.mjs.map