@mantine/dates
Version:
Calendars, date and time pickers based on Mantine components
34 lines (33 loc) • 1.13 kB
JavaScript
"use client";
import { toDateString, toDateTimeString } from "../../utils/to-date-string/to-date-string.mjs";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/dates/src/components/HiddenDatesInput/HiddenDatesInput.tsx
function formatValue({ value, type, withTime }) {
const formatter = withTime ? toDateTimeString : toDateString;
if (type === "range" && Array.isArray(value)) {
const startDate = formatter(value[0]);
const endDate = formatter(value[1]);
if (!startDate) return "";
if (!endDate) return `${startDate} –`;
return `${startDate} – ${endDate}`;
}
if (type === "multiple" && Array.isArray(value)) return value.filter(Boolean).join(", ");
if (!Array.isArray(value) && value) return formatter(value);
return "";
}
function HiddenDatesInput({ value, type, name, form, withTime = false }) {
return /* @__PURE__ */ jsx("input", {
type: "hidden",
value: formatValue({
value,
type,
withTime
}),
name,
form
});
}
HiddenDatesInput.displayName = "@mantine/dates/HiddenDatesInput";
//#endregion
export { HiddenDatesInput };
//# sourceMappingURL=HiddenDatesInput.mjs.map