@premieroctet/next-admin
Version:
Next-Admin provides a customizable and turnkey admin dashboard for applications built with Next.js and powered by the Prisma ORM. It aims to simplify the development process by providing a turnkey admin system that can be easily integrated into your proje
24 lines (23 loc) • 842 B
JavaScript
import { jsx } from "react/jsx-runtime";
import { useCallback } from "react";
import { useFormState } from "../../context/FormStateContext.mjs";
import { getTemplate } from "../../utils/rjsf.mjs";
function DateWidget(props) {
const { onChange, options, registry, value } = props;
const BaseInputTemplate = getTemplate("BaseInputTemplate", registry, options);
const { setFieldDirty } = useFormState();
const handleChange = useCallback((value)=>{
setFieldDirty(props.name);
onChange(value || void 0);
}, [
onChange
]);
const inputValue = value ? new Date(value).toISOString().split("T")[0] : void 0;
return /*#__PURE__*/ jsx(BaseInputTemplate, {
type: "date",
...props,
value: inputValue,
onChange: handleChange
});
}
export { DateWidget as default };