@harvest-profit/npk
Version:
NPK UI Design System
19 lines • 1.69 kB
JavaScript
;
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", { children: [(0, jsx_runtime_1.jsx)("thead", { children: (0, jsx_runtime_1.jsxs)("tr", { children: [(0, jsx_runtime_1.jsx)("th", { children: "S" }), (0, jsx_runtime_1.jsx)("th", { children: "M" }), (0, jsx_runtime_1.jsx)("th", { children: "T" }), (0, jsx_runtime_1.jsx)("th", { children: "W" }), (0, jsx_runtime_1.jsx)("th", { children: "T" }), (0, jsx_runtime_1.jsx)("th", { children: "F" }), (0, jsx_runtime_1.jsx)("th", { 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