UNPKG

@harvest-profit/npk

Version:
19 lines 2.04 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const jsx_runtime_1 = require("react/jsx-runtime"); const utils_1 = require("./utils"); const Day_1 = __importDefault(require("./Day")); const Month = ({ visibleDate: initialVisibleDate, monthOffset = null, state }) => { // Adjust the visible date based on the month offset // Allows for showing multiple months in the calendar. let visibleDate = initialVisibleDate; if (monthOffset) { visibleDate = new Date(visibleDate.getFullYear(), visibleDate.getMonth() + monthOffset, 1); } return ((0, jsx_runtime_1.jsxs)("table", { "aria-label": `${visibleDate.toLocaleString('default', { month: 'long', year: 'numeric' })} calendar`, role: "grid", "aria-multiselectable": state.range, children: [(0, jsx_runtime_1.jsx)("thead", { "aria-hidden": true, children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { "aria-label": "Sunday", children: "S" }), (0, jsx_runtime_1.jsx)("th", { "aria-label": "Monday", children: "M" }), (0, jsx_runtime_1.jsx)("th", { "aria-label": "Tuesday", children: "T" }), (0, jsx_runtime_1.jsx)("th", { "aria-label": "Wednesday", children: "W" }), (0, jsx_runtime_1.jsx)("th", { "aria-label": "Thursday", children: "T" }), (0, jsx_runtime_1.jsx)("th", { "aria-label": "Friday", children: "F" }), (0, jsx_runtime_1.jsx)("th", { "aria-label": "Saturday", children: "S" })] }) }), (0, jsx_runtime_1.jsx)("tbody", { children: [...new Array((0, utils_1.getWeeksInMonth)(visibleDate)).keys()].map((weekIndex) => ((0, jsx_runtime_1.jsx)("tr", { children: (0, utils_1.getDatesInWeek)(weekIndex, visibleDate).map((date, i) => date ? ((0, jsx_runtime_1.jsx)(Day_1.default, { visibleDate: visibleDate, date: date, state: state }, i)) : ((0, jsx_runtime_1.jsx)("td", {}, i))) }, weekIndex))) })] })); }; exports.default = Month; //# sourceMappingURL=Month.js.map