fui-fancyui
Version:
FancyUI Libary
78 lines (77 loc) • 2.55 kB
JavaScript
"use client";
import { jsxs as y, jsx as n } from "react/jsx-runtime";
import { useState as w, useMemo as M, useEffect as k } from "react";
import S from "../../atoms/Typography/Typography.js";
import x from "../DateNumberWithStatus/DateNumberWithStatus.js";
import { CalendarWrapper as C, DaysContainer as W, DateNumber as A } from "./MonthWithDays.style.js";
import N from "./utils/createDaysOfMonth/createDaysOfMonth.js";
function E(i) {
const {
monthIdx: t,
year: a,
handleDateClick: m,
selectedDates: h,
isRangePicking: c,
disabledDateSetting: d,
externalMonthWithDays: r,
startWeekOn: u,
layer: f = 1,
themeType: D = "secondary"
} = i, [p, g] = w([]), l = M(() => ({
// Get the name of the month
name: new Date(0, t + 1, 0).toLocaleString("default", { month: "long" }),
// Create the weeks of the month
weeks: N({
monthIdx: t,
year: a,
fillAdjacentMonths: !1,
weekStartsOn: u || 1,
selectedDates: h,
disabledDateSetting: d,
isRangePicking: c,
externalMonthWithDays: p
})
}), [t, h, c, p, a, d, u]);
return k(() => {
var o;
if (r) {
const s = Array.from({ length: O(t + 1, a) });
(o = r == null ? void 0 : r.dates) == null || o.forEach((e) => {
s[e.date] = e;
}), g(s);
}
}, [r, a, t]), /* @__PURE__ */ y(C, { children: [
/* @__PURE__ */ n(
S,
{
variant: "bodytextLg",
fontWeight: "bold",
elType: "span",
tabIndex: 0,
className: "month_with_days_and_headding",
"aria-label": `${l.name} ${a}`,
themeType: D,
layer: f,
children: l.name
}
),
/* @__PURE__ */ n(W, { children: /* @__PURE__ */ n("tbody", { children: l.weeks.map((o, s) => /* @__PURE__ */ n("tr", { children: o.map((e, b) => e ? /* @__PURE__ */ n("td", { children: /* @__PURE__ */ n(
x,
{
themeType: D,
layer: f,
disabled: e.disabled,
dateNumber: e.number,
isCurrentDay: e.number === (/* @__PURE__ */ new Date()).getDate() && t === (/* @__PURE__ */ new Date()).getMonth() && a === (/* @__PURE__ */ new Date()).getFullYear(),
isSelected: e.isSelected,
range: e.range,
isAvailable: e.isAvilable || "completly",
onClick: () => m && m(e, t, a)
}
) }, e.number) : /* @__PURE__ */ n("td", { children: /* @__PURE__ */ n(A, {}) }, `empty-${b}`)) }, s)) }) })
] });
}
const O = (i, t) => new Date(t, i, 0).getDate();
export {
E as default
};