fui-fancyui
Version:
FancyUI Libary
79 lines (78 loc) • 2.46 kB
JavaScript
"use client";
import { jsxs as Y, jsx as a } from "react/jsx-runtime";
import { useState as l, useEffect as A } from "react";
import C from "../../atoms/WeekDays/WeekDays.js";
import k from "../../atoms/YearSelector/YearSelector.js";
import v from "../../molecules/DateOutputFromTo/DateOutputFromTo.js";
import b from "../../molecules/Calendar/Calendar.js";
import { DatePickerContainer as I, WrapperYearSelector as M } from "./FancyDatePicker.style.js";
import O from "../../../utils/functions/clampLayer/clampLayer.js";
import S from "../../../utils/hooks/useDebounce/useDebounce.js";
function z(f) {
const {
rangeCalendar: d = !1,
dateSelectHandler: i,
monthYearInView: m,
disabledDateSetting: u,
externalData: T,
themeType: o,
layer: t,
yearSelector: r,
startWeekOn: w = 1
} = f, h = o ? o === "primary" ? "secondary" : "primary" : void 0, [n, D] = l([void 0, void 0]), [y, g] = l("from"), [s, c] = l({
month: (/* @__PURE__ */ new Date()).getMonth(),
year: (/* @__PURE__ */ new Date()).getFullYear()
}), F = (e) => {
i == null || i(e), D(e);
}, p = (e) => {
g(e);
}, [x] = S((e) => {
c({ month: s.month, year: e });
}, 100);
return A(() => {
m && c(m);
}, [m]), /* @__PURE__ */ Y(I, { $themeType: o, $layer: t, children: [
/* @__PURE__ */ a(M, { children: /* @__PURE__ */ a(
k,
{
borderRadius: "complete",
selectedYear: s.year,
yearChangeHandler: (e) => x(e),
themeType: "transparent",
ariaTextLeftArrow: (r == null ? void 0 : r.ariaTextLeftArrow) || "go one year back",
ariaTextRightArrow: (r == null ? void 0 : r.ariaTextRightArrow) || "go one year forward"
}
) }),
/* @__PURE__ */ a(C, { themeType: h, layer: t }),
/* @__PURE__ */ a(
b,
{
startWeekOnDay: w,
rangeCalendar: d,
externalMonthsWithDays: T,
selectedYearMonth: s,
handleDates: F,
currentInViewhandler: (e) => c(e),
selectFromTo: y ?? "from",
handleSwitchFromTo: p,
disabledDateSetting: u,
themeType: h,
layer: t
}
),
d && /* @__PURE__ */ a(
v,
{
themeType: o,
layer: t ? O(t + 1) : void 0,
whichIsSelecting: y,
handleFromTo: p,
dateFrom: Array.isArray(n) ? n[0] : void 0,
dateTo: Array.isArray(n) ? n[1] : void 0
}
)
] });
}
export {
z as default
};