@cerberus-design/react
Version:
The Cerberus Design React component library.
45 lines (43 loc) • 2.03 kB
JavaScript
import {
DatePickerViewControlGroup
} from "./chunk-X24O5DTP.js";
import {
DatePickerParts
} from "./chunk-BXDQ5AXV.js";
// src/components/date-picker/day-view.tsx
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
function DatePickerDayView(props) {
function isToday(date) {
const today = /* @__PURE__ */ new Date();
const formatted = today.toISOString().split("T")[0];
const arkDate = `${date.year}-${String(date.month).padStart(2, "0")}-${String(date.day).padStart(2, "0")}`;
return formatted === arkDate;
}
function isPastDay(date) {
const today = /* @__PURE__ */ new Date();
const arkDate = `${date.year}-${String(date.month).padStart(2, "0")}-${String(date.day).padStart(2, "0")}`;
return new Date(arkDate) < today;
}
function getDayValue(date) {
if (isToday(date)) return "today";
if (isPastDay(date)) return "past";
return "future";
}
return /* @__PURE__ */ jsx(DatePickerParts.View, { ...props, view: "day", children: /* @__PURE__ */ jsx(DatePickerParts.Context, { children: (datePickerData) => /* @__PURE__ */ jsxs(Fragment, { children: [
/* @__PURE__ */ jsx(DatePickerViewControlGroup, {}),
/* @__PURE__ */ jsxs(DatePickerParts.Table, { children: [
/* @__PURE__ */ jsx(DatePickerParts.TableHead, { children: /* @__PURE__ */ jsx(DatePickerParts.TableRow, { children: datePickerData.weekDays.map((weekDay, id) => /* @__PURE__ */ jsx(DatePickerParts.TableHeader, { children: weekDay.narrow }, id)) }) }),
/* @__PURE__ */ jsx(DatePickerParts.TableBody, { children: datePickerData.weeks.map((week, id) => /* @__PURE__ */ jsx(DatePickerParts.TableRow, { children: week.map((day, id2) => /* @__PURE__ */ jsx(DatePickerParts.TableCell, { value: day, children: /* @__PURE__ */ jsx(
DatePickerParts.TableCellTrigger,
{
"data-date": getDayValue(day),
children: day.day
}
) }, id2)) }, id)) })
] })
] }) }) });
}
export {
DatePickerDayView
};
//# sourceMappingURL=chunk-FSX64HPK.js.map