UNPKG

@aokiapp/rjsf-mantine-theme

Version:

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

1 lines 3.07 kB
{"version":3,"file":"MantineDateTimeWidget.mjs","sources":["../../src/widgets/MantineDateTimeWidget.tsx"],"sourcesContent":["import {\n FormContextType,\n RJSFSchema,\n StrictRJSFSchema,\n WidgetProps,\n labelValue,\n ariaDescribedByIds,\n} from '@rjsf/utils';\nimport { useCallback } from 'react';\n\nimport { DateTimePicker } from '@mantine/dates';\nimport { createErrors } from '../utils/createErrors';\n\n/** The `DateTimeWidget` component uses the `BaseInputTemplate` changing the type to `datetime-local` and transforms\n * the value to/from utc using the appropriate utility functions.\n *\n * @param props - The `WidgetProps` for this component\n */\nexport default function MantineDateTimeWidget<\n T = any,\n S extends StrictRJSFSchema = RJSFSchema,\n F extends FormContextType = any,\n>(props: WidgetProps<T, S, F>) {\n const {\n id,\n placeholder,\n label,\n hideLabel,\n value,\n required,\n readonly,\n disabled,\n onChange,\n onChangeOverride,\n autofocus,\n rawErrors,\n hideError,\n options,\n schema,\n } = props;\n const description = options.description || schema.description;\n\n // TODO: options\n const inputValue = value ? new Date(value) : null;\n\n const _onChange = useCallback((value: Date | null) => onChange(value ? value.toJSON() : undefined), [onChange]);\n return (\n <DateTimePicker\n withSeconds\n value={inputValue}\n onChange={onChangeOverride || _onChange}\n key={id}\n id={id}\n placeholder={placeholder}\n label={labelValue(label, hideLabel, undefined)}\n required={required}\n clearable={!required}\n disabled={disabled || readonly}\n autoFocus={autofocus}\n error={createErrors<T>(rawErrors, hideError)}\n aria-describedby={ariaDescribedByIds<T>(id)}\n className='armt-widget-datetime-mt'\n description={description}\n />\n );\n}\n"],"names":[],"mappings":";;;;;;AASe,SAAS,qBAAqB,CAAC,KAAK,EAAE;AACrD,EAAE,MAAM;AACR,IAAI,EAAE;AACN,IAAI,WAAW;AACf,IAAI,KAAK;AACT,IAAI,SAAS;AACb,IAAI,KAAK;AACT,IAAI,QAAQ;AACZ,IAAI,QAAQ;AACZ,I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