react-modular-datepicker 0.0.5-canary.0 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2 +1,323 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./useDates-CCrn42eQ.js"),t=require("./utils.js");let n=require("react");n=e.i(n);let r=require("react/jsx-runtime");var i=({dateObj:e,getDateProps:t,classNames:i,tooltip:a})=>{let[o,s]=(0,n.useState)(!1);if(!e)return(0,r.jsx)(`div`,{className:`aspect-square bg-white`});let{date:c,selected:l,selectable:u,isRangeStart:d,isRangeEnd:f,isRangeBetween:p,isRangeHovering:m,isRangeActive:h}=e,g=i.day,_=`rounded-full`;_=d&&f?`${g.selected} rounded-full`:d?`${g.rangeStart} ${h?`rounded-l-full rounded-r-none`:`rounded-full`}`:f?`${g.rangeEnd} ${h?`rounded-r-full rounded-l-none`:`rounded-full`}`:p?g.rangeBetween||``:m?g.rangeHovering||``:l?g.selected||``:u?g.unselected||``:g.disabled||``;let v=[g.day,_,...(e.modifiers||[]).map(e=>g[e]||e)].filter(Boolean).join(` `);return(0,r.jsxs)(`button`,{...t({dateObj:e,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1)}),className:v,children:[c.getDate(),a&&o&&(0,r.jsx)(`div`,{className:`absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10`,children:(0,r.jsxs)(`div`,{className:`bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg`,children:[a,(0,r.jsx)(`div`,{className:`absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800`})]})})]})};function a(t=e.r,n){return{months:t.getMonths(n),weekdays:t.getWeekdays(n),back:`Previous month`,forward:`Next month`}}function o(t=e.r,n,r){return{...a(t,n),...r}}var s=()=>(0,r.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,r.jsx)(`polyline`,{points:`15 18 9 12 15 6`})}),c=()=>(0,r.jsx)(`svg`,{width:`20`,height:`20`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,r.jsx)(`polyline`,{points:`9 18 15 12 9 6`})}),l=({calendars:e,getBackProps:t,getForwardProps:n,setView:i,monthNames:a,t:o,classNames:l,slideDirection:u,currentView:d})=>(0,r.jsxs)(`div`,{className:l.header,children:[(0,r.jsx)(`button`,{...t({calendars:e}),onMouseDown:e=>e.preventDefault(),className:`${l.navButton} ${d&&d!==`days`?`invisible pointer-events-none`:``}`,"aria-label":o.back,children:(0,r.jsx)(s,{})}),(0,r.jsx)(`div`,{className:l.monthYearContainer,children:e.length===1?(0,r.jsxs)(`div`,{className:`${l.monthYearLabel} ${u===`left`?`animate-slide-in-left`:u===`right`?`animate-slide-in-right`:``}`,children:[(0,r.jsx)(`button`,{onMouseDown:e=>e.preventDefault(),onClick:()=>i(d===`months`?`days`:`months`),className:l.monthYearButton,children:a[e[0].month]}),(0,r.jsx)(`button`,{onMouseDown:e=>e.preventDefault(),onClick:()=>i(d===`years`?`days`:`years`),className:l.monthYearButton,children:e[0].year})]},`${e[0].month}-${e[0].year}`):(0,r.jsx)(`div`,{className:`${l.monthYearLabel} ${u===`left`?`animate-slide-in-left`:u===`right`?`animate-slide-in-right`:``}`,children:(()=>{let t=e[0],n=e[e.length-1];return e.length===12&&t.month===0&&n.month===11&&t.year===n.year?(0,r.jsx)(`span`,{children:t.year}):t.year===n.year?(0,r.jsxs)(`span`,{children:[a[t.month],` - `,a[n.month],` `,t.year]}):(0,r.jsxs)(`span`,{children:[a[t.month],` `,t.year,` - `,a[n.month],` `,n.year]})})()})}),(0,r.jsx)(`button`,{...n({calendars:e}),onMouseDown:e=>e.preventDefault(),className:`${l.navButton} ${d&&d!==`days`?`invisible pointer-events-none`:``}`,"aria-label":o.forward,children:(0,r.jsx)(c,{})})]}),u={root:`w-fit flex flex-col p-4 bg-white rounded-lg shadow-lg`,header:`flex items-center justify-between border-b-2 border-brand-gray-light/40 pb-2 mb-3`,calendarsContainer:`flex flex-col md:flex-row gap-4`,calendarContainer:`flex-1 min-w-[280px] min-h-[260px]`,weekdayGrid:`grid grid-cols-7 gap-1 mb-1 border-b border-brand-gray-light/40`,weekday:`text-center text-xs text-gray-400 py-2`,daysGrid:`grid grid-cols-7 gap-px bg-brand-gray-light/20`,footer:`mt-4`,navButton:`p-2 hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none`,monthYearContainer:`flex gap-8`,monthYearLabel:`flex gap-1 items-center font-semibold text-brand-text`,monthYearButton:`hover:bg-gray-100 px-2 py-1 rounded cursor-pointer`,day:{day:`aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px`,selected:`bg-brand-gold text-white rounded-full`,unselected:`bg-white hover:bg-brand-gray-light text-brand-text`,disabled:`bg-white text-gray-300 cursor-not-allowed`,rangeStart:`bg-brand-gold text-white`,rangeEnd:`bg-brand-gold text-white`,rangeBetween:`bg-brand-gold/25 text-brand-text`,rangeHovering:`bg-brand-gold/25 text-brand-text`},monthsGrid:`grid grid-cols-3 gap-2 animate-slide-in-top`,monthButton:`py-4 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none`,monthButtonSelected:`bg-brand-gold text-white`,monthButtonUnselected:`text-brand-text`,yearsGrid:`grid grid-cols-3 gap-2 max-h-[300px] overflow-y-auto pr-2 animate-slide-in-top`,yearButton:`py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none`,yearButtonSelected:`bg-brand-gold text-white`,yearButtonUnselected:`text-brand-text`},d=e=>{let t={...u};if(!e)return t;for(let n in e){let r=n;r===`day`&&e.day?t.day={...u.day,...e.day}:e[r]&&(t[r]=e[r])}return t},f=({year:e,month:t,monthNames:n,minDate:i,maxDate:a,onMonthSelect:o,classNames:s})=>{let c=t=>!!(i&&e===i.getFullYear()&&t<i.getMonth()||a&&e===a.getFullYear()&&t>a.getMonth());return(0,r.jsx)(`div`,{className:s.monthsGrid,children:n.map((e,n)=>{let i=c(n);return(0,r.jsx)(`button`,{onMouseDown:e=>e.preventDefault(),onClick:()=>!i&&o(n),className:`${s.monthButton} ${n===t?s.monthButtonSelected:s.monthButtonUnselected}`,disabled:i,children:e},e)})})},p=({year:e,minDate:t,maxDate:i,adapter:a,onYearSelect:o,classNames:s})=>{let c=(0,n.useRef)(null);(0,n.useEffect)(()=>{if(c.current){let e=c.current.querySelector(`[data-selected="true"]`);e&&e.scrollIntoView({block:`center`})}},[]);let l=t?a.get(a.date(t),`year`):e-50,u=i?a.get(a.date(i),`year`):e+50,d=[];for(let e=l;e<=u;e++)d.push(e);return(0,r.jsx)(`div`,{ref:c,className:s.yearsGrid,children:d.map(t=>(0,r.jsx)(`button`,{"data-selected":t===e,onMouseDown:e=>e.preventDefault(),onClick:()=>o(t),className:`${s.yearButton} ${t===e?s.yearButtonSelected:s.yearButtonUnselected}`,children:t},t))})},m=t=>{let{classNames:a,locale:s,translations:c,adapter:u=e.r,firstDayOfWeek:m=0,header:h,footer:g,renderDayTooltip:_,...v}=t,y=d(a),[b,x]=(0,n.useState)(`days`),[S,C]=(0,n.useState)(null),w=o(u,s,c),T=w.weekdays,E=w.months,{calendars:D,getBackProps:O,getForwardProps:k,getDateProps:A,setOffset:j}=e.t({...v,adapter:u,firstDayOfWeek:m}),M=[...T.slice(m),...T.slice(0,m)],{month:N,year:P}=D[0],F=e=>{let n=u.set(u.set(u.date(t.date||new Date),`year`,P),`month`,N),r=u.set(n,`month`,e),i=u.startOf(u.date(t.date||new Date),`month`),a=u.diff(r,i,`month`);C(null),j(a),x(`days`)},I=e=>{let n=u.set(u.set(u.date(t.date||new Date),`year`,P),`month`,N),r=u.set(n,`year`,e),i=u.startOf(u.date(t.date||new Date),`month`),a=u.diff(r,i,`month`);C(null),j(a),x(`days`)},L=e=>{let t=O(e);return{...t,onClick:e=>{C(`left`),t.onClick?.(e)}}},R=e=>{let t=k(e);return{...t,onClick:e=>{C(`right`),t.onClick?.(e)}}};return(0,r.jsxs)(`div`,{className:y.root,children:[typeof h==`function`?h({calendars:D,getBackProps:L,getForwardProps:R,setView:x,monthNames:E,t:w,slideDirection:S,currentView:b}):h||(0,r.jsx)(l,{calendars:D,getBackProps:L,getForwardProps:R,setView:x,monthNames:E,t:w,classNames:y,slideDirection:S,currentView:b}),(0,r.jsxs)(`div`,{className:y.calendarsContainer,children:[b===`months`&&D.map(e=>(0,r.jsx)(`div`,{className:y.calendarContainer,children:(0,r.jsx)(f,{year:e.year,month:e.month,monthNames:E,minDate:t.minDate,maxDate:t.maxDate,onMonthSelect:F,classNames:y})},`months-${e.year}`)),b===`years`&&D.map(e=>(0,r.jsx)(`div`,{className:y.calendarContainer,children:(0,r.jsx)(p,{year:e.year,minDate:t.minDate,maxDate:t.maxDate,adapter:u,onYearSelect:I,classNames:y})},`years-${e.year}`)),b===`days`&&D.map(e=>(0,r.jsxs)(`div`,{className:y.calendarContainer,children:[D.length>1&&(0,r.jsxs)(`button`,{type:`button`,"aria-label":E[e.month],className:`block w-full text-center font-semibold mb-2 text-brand-text`,children:[E[e.month],` `,D[0].year===D[D.length-1].year?``:e.year]}),(0,r.jsx)(`div`,{className:y.weekdayGrid,children:M.map(e=>(0,r.jsx)(`div`,{className:y.weekday,children:e},e))}),(0,r.jsx)(`div`,{className:`${y.daysGrid} ${S===`left`?`animate-slide-in-left`:S===`right`?`animate-slide-in-right`:``}`,children:e.weeks.map((e,t)=>e.map((e,n)=>(0,r.jsx)(i,{dateObj:e,getDateProps:A,classNames:y,tooltip:e&&_?.(e)},`${t}-${n}`)))})]},`${e.month}-${e.year}`))]}),g&&(0,r.jsx)(`div`,{className:y.footer,children:g})]})};exports.Calendar=m,exports.CalendarHeader=l,exports.ChevronLeftIcon=s,exports.ChevronRightIcon=c,exports.Day=i,exports.DayjsAdapter=e.n,exports.MonthSelection=f,exports.YearSelection=p,exports.addMonth=t.addMonth,exports.composeEventHandlers=t.composeEventHandlers,exports.defaultAdapter=e.r,exports.defaultClassNames=u,exports.getCalendars=t.getCalendars,exports.getDefaults=a,exports.getTranslations=o,exports.isBackDisabled=t.isBackDisabled,exports.isForwardDisabled=t.isForwardDisabled,exports.mergeClassNames=d,exports.subtractMonth=t.subtractMonth,exports.useDates=e.t;
1
+ import { n as e, r as t, t as n } from "./useDates-CjPuu-VA.js";
2
+ import { addMonth as r, composeEventHandlers as i, getCalendars as a, isBackDisabled as o, isForwardDisabled as s, subtractMonth as c } from "./utils.js";
3
+ import { useEffect as l, useRef as u, useState as d } from "react";
4
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
5
+ //#region src/components/Day.tsx
6
+ var m = ({ dateObj: e, getDateProps: t, classNames: n, tooltip: r }) => {
7
+ let [i, a] = d(!1);
8
+ if (!e) return /* @__PURE__ */ f("div", { className: "aspect-square bg-white" });
9
+ let { date: o, selected: s, selectable: c, isRangeStart: l, isRangeEnd: u, isRangeBetween: m, isRangeHovering: h, isRangeActive: g } = e, _ = n.day, v = "rounded-full";
10
+ v = l && u ? `${_.selected} rounded-full` : l ? `${_.rangeStart} ${g ? "rounded-l-full rounded-r-none" : "rounded-full"}` : u ? `${_.rangeEnd} ${g ? "rounded-r-full rounded-l-none" : "rounded-full"}` : m ? _.rangeBetween || "" : h ? _.rangeHovering || "" : s ? _.selected || "" : c ? _.unselected || "" : _.disabled || "";
11
+ let y = [
12
+ _.day,
13
+ v,
14
+ ...(e.modifiers || []).map((e) => _[e] || e)
15
+ ].filter(Boolean).join(" ");
16
+ return /* @__PURE__ */ p("button", {
17
+ ...t({
18
+ dateObj: e,
19
+ onMouseEnter: () => a(!0),
20
+ onMouseLeave: () => a(!1)
21
+ }),
22
+ className: y,
23
+ children: [o.getDate(), r && i && /* @__PURE__ */ f("div", {
24
+ className: "absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10",
25
+ children: /* @__PURE__ */ p("div", {
26
+ className: "bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg",
27
+ children: [r, /* @__PURE__ */ f("div", { className: "absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800" })]
28
+ })
29
+ })]
30
+ });
31
+ };
32
+ //#endregion
33
+ //#region src/i18n.ts
34
+ function h(e = t, n) {
35
+ return {
36
+ months: e.getMonths(n),
37
+ weekdays: e.getWeekdays(n),
38
+ back: "Previous month",
39
+ forward: "Next month"
40
+ };
41
+ }
42
+ function g(e = t, n, r) {
43
+ return {
44
+ ...h(e, n),
45
+ ...r
46
+ };
47
+ }
48
+ //#endregion
49
+ //#region src/components/CalendarHeader.tsx
50
+ var _ = () => /* @__PURE__ */ f("svg", {
51
+ width: "20",
52
+ height: "20",
53
+ viewBox: "0 0 24 24",
54
+ fill: "none",
55
+ stroke: "currentColor",
56
+ strokeWidth: "2",
57
+ strokeLinecap: "round",
58
+ strokeLinejoin: "round",
59
+ children: /* @__PURE__ */ f("polyline", { points: "15 18 9 12 15 6" })
60
+ }), v = () => /* @__PURE__ */ f("svg", {
61
+ width: "20",
62
+ height: "20",
63
+ viewBox: "0 0 24 24",
64
+ fill: "none",
65
+ stroke: "currentColor",
66
+ strokeWidth: "2",
67
+ strokeLinecap: "round",
68
+ strokeLinejoin: "round",
69
+ children: /* @__PURE__ */ f("polyline", { points: "9 18 15 12 9 6" })
70
+ }), y = ({ calendars: e, getBackProps: t, getForwardProps: n, setView: r, monthNames: i, t: a, classNames: o, slideDirection: s, currentView: c }) => /* @__PURE__ */ p("div", {
71
+ className: o.header,
72
+ children: [
73
+ /* @__PURE__ */ f("button", {
74
+ ...t({ calendars: e }),
75
+ onMouseDown: (e) => e.preventDefault(),
76
+ className: `${o.navButton} ${c && c !== "days" ? "invisible pointer-events-none" : ""}`,
77
+ "aria-label": a.back,
78
+ children: /* @__PURE__ */ f(_, {})
79
+ }),
80
+ /* @__PURE__ */ f("div", {
81
+ className: o.monthYearContainer,
82
+ children: e.length === 1 ? /* @__PURE__ */ p("div", {
83
+ className: `${o.monthYearLabel} ${s === "left" ? "animate-slide-in-left" : s === "right" ? "animate-slide-in-right" : ""}`,
84
+ children: [/* @__PURE__ */ f("button", {
85
+ onMouseDown: (e) => e.preventDefault(),
86
+ onClick: () => r(c === "months" ? "days" : "months"),
87
+ className: o.monthYearButton,
88
+ children: i[e[0].month]
89
+ }), /* @__PURE__ */ f("button", {
90
+ onMouseDown: (e) => e.preventDefault(),
91
+ onClick: () => r(c === "years" ? "days" : "years"),
92
+ className: o.monthYearButton,
93
+ children: e[0].year
94
+ })]
95
+ }, `${e[0].month}-${e[0].year}`) : /* @__PURE__ */ f("div", {
96
+ className: `${o.monthYearLabel} ${s === "left" ? "animate-slide-in-left" : s === "right" ? "animate-slide-in-right" : ""}`,
97
+ children: (() => {
98
+ let t = e[0], n = e[e.length - 1];
99
+ return e.length === 12 && t.month === 0 && n.month === 11 && t.year === n.year ? /* @__PURE__ */ f("span", { children: t.year }) : t.year === n.year ? /* @__PURE__ */ p("span", { children: [
100
+ i[t.month],
101
+ " - ",
102
+ i[n.month],
103
+ " ",
104
+ t.year
105
+ ] }) : /* @__PURE__ */ p("span", { children: [
106
+ i[t.month],
107
+ " ",
108
+ t.year,
109
+ " - ",
110
+ i[n.month],
111
+ " ",
112
+ n.year
113
+ ] });
114
+ })()
115
+ })
116
+ }),
117
+ /* @__PURE__ */ f("button", {
118
+ ...n({ calendars: e }),
119
+ onMouseDown: (e) => e.preventDefault(),
120
+ className: `${o.navButton} ${c && c !== "days" ? "invisible pointer-events-none" : ""}`,
121
+ "aria-label": a.forward,
122
+ children: /* @__PURE__ */ f(v, {})
123
+ })
124
+ ]
125
+ }), b = {
126
+ root: "w-fit flex flex-col p-4 bg-white rounded-lg shadow-lg",
127
+ header: "flex items-center justify-between border-b-2 border-brand-gray-light/40 pb-2",
128
+ calendarsContainer: "flex flex-wrap gap-4 mt-3",
129
+ calendarContainer: "flex-1 min-w-[280px] max-w-full",
130
+ weekdayGrid: "grid grid-cols-7 gap-1 mb-1 border-b border-brand-gray-light/40",
131
+ weekday: "text-center text-xs text-gray-400 py-2",
132
+ daysGrid: "grid grid-cols-7 gap-px bg-brand-gray-light/20",
133
+ footer: "mt-4",
134
+ navButton: "p-2 text-brand-text hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none",
135
+ monthYearContainer: "flex gap-8",
136
+ monthYearLabel: "flex gap-1 items-center font-semibold text-brand-text",
137
+ monthYearButton: "hover:bg-gray-100 px-2 py-1 rounded cursor-pointer",
138
+ day: {
139
+ day: "aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px",
140
+ selected: "bg-brand-gold text-white rounded-full",
141
+ unselected: "bg-white hover:bg-brand-gray-light text-brand-text",
142
+ disabled: "bg-white text-gray-300 cursor-not-allowed",
143
+ rangeStart: "bg-brand-gold text-white",
144
+ rangeEnd: "bg-brand-gold text-white",
145
+ rangeBetween: "bg-brand-gold/25 text-brand-text",
146
+ rangeHovering: "bg-brand-gold/25 text-brand-text"
147
+ },
148
+ monthsGrid: "grid grid-cols-3 gap-2 animate-slide-in-top",
149
+ monthButton: "py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none",
150
+ monthButtonSelected: "bg-brand-gold text-white",
151
+ monthButtonUnselected: "text-brand-text",
152
+ yearsGrid: "grid grid-cols-3 gap-2 max-h-[300px] overflow-y-auto pr-2 animate-slide-in-top",
153
+ yearButton: "py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none",
154
+ yearButtonSelected: "bg-brand-gold text-white",
155
+ yearButtonUnselected: "text-brand-text"
156
+ }, x = (e) => {
157
+ let t = { ...b };
158
+ if (!e) return t;
159
+ for (let n in e) {
160
+ let r = n;
161
+ r === "day" && e.day ? t.day = {
162
+ ...b.day,
163
+ ...e.day
164
+ } : e[r] && (t[r] = e[r]);
165
+ }
166
+ return t;
167
+ }, S = ({ year: e, month: t, monthNames: n, minDate: r, maxDate: i, onMonthSelect: a, classNames: o }) => {
168
+ let s = (t) => !!(r && e === r.getFullYear() && t < r.getMonth() || i && e === i.getFullYear() && t > i.getMonth());
169
+ return /* @__PURE__ */ f("div", {
170
+ className: o.monthsGrid,
171
+ children: n.map((e, n) => {
172
+ let r = s(n);
173
+ return /* @__PURE__ */ f("button", {
174
+ onMouseDown: (e) => e.preventDefault(),
175
+ onClick: () => !r && a(n),
176
+ className: `${o.monthButton} ${n === t ? o.monthButtonSelected : o.monthButtonUnselected}`,
177
+ disabled: r,
178
+ children: e
179
+ }, e);
180
+ })
181
+ });
182
+ }, C = ({ year: e, minDate: t, maxDate: n, adapter: r, onYearSelect: i, classNames: a }) => {
183
+ let o = u(null);
184
+ l(() => {
185
+ if (o.current) {
186
+ let e = o.current.querySelector("[data-selected=\"true\"]");
187
+ e && e.scrollIntoView({ block: "center" });
188
+ }
189
+ }, []);
190
+ let s = t ? r.get(r.date(t), "year") : e - 50, c = n ? r.get(r.date(n), "year") : e + 50, d = [];
191
+ for (let e = s; e <= c; e++) d.push(e);
192
+ return /* @__PURE__ */ f("div", {
193
+ ref: o,
194
+ className: a.yearsGrid,
195
+ children: d.map((t) => /* @__PURE__ */ f("button", {
196
+ "data-selected": t === e,
197
+ onMouseDown: (e) => e.preventDefault(),
198
+ onClick: () => i(t),
199
+ className: `${a.yearButton} ${t === e ? a.yearButtonSelected : a.yearButtonUnselected}`,
200
+ children: t
201
+ }, t))
202
+ });
203
+ }, w = (e) => {
204
+ let { classNames: r, locale: i, translations: a, adapter: o = t, firstDayOfWeek: s = 0, header: c, footer: l, renderDayTooltip: u, ...h } = e, _ = x(r), [v, b] = d("days"), [w, T] = d(null), E = g(o, i, a), D = E.weekdays, O = E.months, { calendars: k, getBackProps: A, getForwardProps: j, getDateProps: M, setOffset: N } = n({
205
+ ...h,
206
+ adapter: o,
207
+ firstDayOfWeek: s
208
+ }), P = [...D.slice(s), ...D.slice(0, s)], { month: F, year: I } = k[0], L = (t) => {
209
+ let n = o.set(o.set(o.date(e.date || /* @__PURE__ */ new Date()), "year", I), "month", F), r = o.set(n, "month", t), i = o.startOf(o.date(e.date || /* @__PURE__ */ new Date()), "month"), a = o.diff(r, i, "month");
210
+ T(null), N(a), b("days");
211
+ }, R = (t) => {
212
+ let n = o.set(o.set(o.date(e.date || /* @__PURE__ */ new Date()), "year", I), "month", F), r = o.set(n, "year", t), i = o.startOf(o.date(e.date || /* @__PURE__ */ new Date()), "month"), a = o.diff(r, i, "month");
213
+ T(null), N(a), b("days");
214
+ }, z = (e) => {
215
+ let t = A(e);
216
+ return {
217
+ ...t,
218
+ onClick: (e) => {
219
+ T("left"), t.onClick?.(e);
220
+ }
221
+ };
222
+ }, B = (e) => {
223
+ let t = j(e);
224
+ return {
225
+ ...t,
226
+ onClick: (e) => {
227
+ T("right"), t.onClick?.(e);
228
+ }
229
+ };
230
+ };
231
+ return /* @__PURE__ */ p("div", {
232
+ className: `rmdp ${_.root}`,
233
+ children: [
234
+ typeof c == "function" ? c({
235
+ calendars: k,
236
+ getBackProps: z,
237
+ getForwardProps: B,
238
+ setView: b,
239
+ monthNames: O,
240
+ t: E,
241
+ slideDirection: w,
242
+ currentView: v
243
+ }) : c || /* @__PURE__ */ f(y, {
244
+ calendars: k,
245
+ getBackProps: z,
246
+ getForwardProps: B,
247
+ setView: b,
248
+ monthNames: O,
249
+ t: E,
250
+ classNames: _,
251
+ slideDirection: w,
252
+ currentView: v
253
+ }),
254
+ /* @__PURE__ */ p("div", {
255
+ className: _.calendarsContainer,
256
+ children: [
257
+ v === "months" && k.map((t) => /* @__PURE__ */ f("div", {
258
+ className: _.calendarContainer,
259
+ children: /* @__PURE__ */ f(S, {
260
+ year: t.year,
261
+ month: t.month,
262
+ monthNames: O,
263
+ minDate: e.minDate,
264
+ maxDate: e.maxDate,
265
+ onMonthSelect: L,
266
+ classNames: _
267
+ })
268
+ }, `months-${t.year}`)),
269
+ v === "years" && k.map((t) => /* @__PURE__ */ f("div", {
270
+ className: _.calendarContainer,
271
+ children: /* @__PURE__ */ f(C, {
272
+ year: t.year,
273
+ minDate: e.minDate,
274
+ maxDate: e.maxDate,
275
+ adapter: o,
276
+ onYearSelect: R,
277
+ classNames: _
278
+ })
279
+ }, `years-${t.year}`)),
280
+ v === "days" && k.map((e) => /* @__PURE__ */ p("div", {
281
+ className: _.calendarContainer,
282
+ children: [
283
+ k.length > 1 && /* @__PURE__ */ p("button", {
284
+ type: "button",
285
+ "aria-label": O[e.month],
286
+ className: "block w-full text-center font-semibold mb-2 text-brand-text",
287
+ children: [
288
+ O[e.month],
289
+ " ",
290
+ k[0].year === k[k.length - 1].year ? "" : e.year
291
+ ]
292
+ }),
293
+ /* @__PURE__ */ f("div", {
294
+ className: _.weekdayGrid,
295
+ children: P.map((e) => /* @__PURE__ */ f("div", {
296
+ className: _.weekday,
297
+ children: e
298
+ }, e))
299
+ }),
300
+ /* @__PURE__ */ f("div", {
301
+ className: `${_.daysGrid} ${w === "left" ? "animate-slide-in-left" : w === "right" ? "animate-slide-in-right" : ""}`,
302
+ children: e.weeks.map((e, t) => e.map((e, n) => /* @__PURE__ */ f(m, {
303
+ dateObj: e,
304
+ getDateProps: M,
305
+ classNames: _,
306
+ tooltip: e && u?.(e)
307
+ }, `${t}-${n}`)))
308
+ })
309
+ ]
310
+ }, `${e.month}-${e.year}`))
311
+ ]
312
+ }),
313
+ l && /* @__PURE__ */ f("div", {
314
+ className: _.footer,
315
+ children: l
316
+ })
317
+ ]
318
+ });
319
+ };
320
+ //#endregion
321
+ export { w as Calendar, y as CalendarHeader, _ as ChevronLeftIcon, v as ChevronRightIcon, m as Day, e as DayjsAdapter, S as MonthSelection, C as YearSelection, r as addMonth, i as composeEventHandlers, t as defaultAdapter, b as defaultClassNames, a as getCalendars, h as getDefaults, g as getTranslations, o as isBackDisabled, s as isForwardDisabled, x as mergeClassNames, c as subtractMonth, n as useDates };
322
+
2
323
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/components/Day.tsx","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/classNames.ts","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport type { CalendarClassNames, DateObj } from '../types';\n\ninterface DayProps {\n dateObj: DateObj | null;\n getDateProps: (args: { dateObj: DateObj, [key: string]: any }) => any;\n tooltip?: React.ReactNode;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const Day: React.FC<DayProps> = ({ dateObj, getDateProps, classNames, tooltip }) => {\n const [isHovered, setIsHovered] = useState(false);\n\n if (!dateObj) {\n return <div className=\"aspect-square bg-white\" />;\n }\n\n const { date, selected, selectable, isRangeStart, isRangeEnd, isRangeBetween, isRangeHovering, isRangeActive } = dateObj;\n const dayClasses = classNames.day;\n\n let stateClasses = \"rounded-full\";\n if (isRangeStart && isRangeEnd) {\n stateClasses = `${dayClasses.selected} rounded-full`;\n } else if (isRangeStart) {\n stateClasses = `${dayClasses.rangeStart} ${isRangeActive ? 'rounded-l-full rounded-r-none' : 'rounded-full'}`;\n } else if (isRangeEnd) {\n stateClasses = `${dayClasses.rangeEnd} ${isRangeActive ? 'rounded-r-full rounded-l-none' : 'rounded-full'}`;\n } else if (isRangeBetween) {\n stateClasses = dayClasses.rangeBetween || '';\n } else if (isRangeHovering) {\n stateClasses = dayClasses.rangeHovering || '';\n } else if (selected) {\n stateClasses = dayClasses.selected || '';\n } else if (!selectable) {\n stateClasses = dayClasses.disabled || '';\n } else {\n stateClasses = dayClasses.unselected || '';\n }\n\n const className = [\n dayClasses.day,\n stateClasses,\n ...(dateObj.modifiers || []).map(m => (dayClasses as any)[m] || m)\n ].filter(Boolean).join(' ');\n\n return (\n <button\n {...getDateProps({\n dateObj,\n onMouseEnter: () => setIsHovered(true),\n onMouseLeave: () => setIsHovered(false)\n })}\n className={className}\n >\n {date.getDate()}\n {tooltip && isHovered && (\n <div className=\"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10\">\n <div className=\"bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg\">\n {tooltip}\n <div className=\"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800\" />\n </div>\n </div>\n )}\n </button>\n );\n};\n","import { DateAdapter } from \"./types\";\nimport { defaultAdapter } from \"./adapters/dayjs\";\n\nexport interface Translations {\n months: string[];\n weekdays: string[];\n back: string;\n forward: string;\n}\n\nexport function getDefaults(adapter: DateAdapter = defaultAdapter, locale?: string): Translations {\n return {\n months: adapter.getMonths(locale),\n weekdays: adapter.getWeekdays(locale),\n back: 'Previous month',\n forward: 'Next month'\n };\n}\n\nexport function getTranslations(\n adapter: DateAdapter = defaultAdapter,\n locale?: string,\n custom?: Partial<Translations>\n): Translations {\n const base = getDefaults(adapter, locale);\n return { ...base, ...custom };\n}\n","import React from 'react';\nimport { Calendar, CalendarClassNames } from '../types';\n\nexport interface HeaderProps {\n calendars: Calendar[];\n getBackProps: (args: any) => any;\n getForwardProps: (args: any) => any;\n setView: (view: 'days' | 'months' | 'years') => void;\n monthNames: string[];\n t: { back: string; forward: string };\n classNames: Required<CalendarClassNames>;\n slideDirection?: 'left' | 'right' | null;\n currentView?: 'days' | 'months' | 'years';\n}\n\nexport const ChevronLeftIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n);\n\nexport const ChevronRightIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n);\n\nexport const CalendarHeader: React.FC<HeaderProps> = ({\n calendars,\n getBackProps,\n getForwardProps,\n setView,\n monthNames,\n t,\n classNames,\n slideDirection,\n currentView\n}) => {\n return (\n <div className={classNames.header}>\n <button\n {...getBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n\n <div className={classNames.monthYearContainer}>\n {calendars.length === 1 ? (\n <div key={`${calendars[0].month}-${calendars[0].year}`} className={`${classNames.monthYearLabel} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n <button\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => setView(currentView === 'months' ? 'days' : 'months')}\n className={classNames.monthYearButton}\n >\n {monthNames[calendars[0].month]}\n </button>\n <button\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => setView(currentView === 'years' ? 'days' : 'years')}\n className={classNames.monthYearButton}\n >\n {calendars[0].year}\n </button>\n </div>\n ) : (\n <div className={`${classNames.monthYearLabel} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n {(() => {\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n const isFullYear = calendars.length === 12 && first.month === 0 && last.month === 11 && first.year === last.year;\n\n if (isFullYear) {\n return <span>{first.year}</span>;\n } else if (first.year === last.year) {\n return <span>{monthNames[first.month]} - {monthNames[last.month]} {first.year}</span>;\n } else {\n return <span>{monthNames[first.month]} {first.year} - {monthNames[last.month]} {last.year}</span>;\n }\n })()}\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","export interface DayClassNames {\n day?: string;\n selected?: string;\n unselected?: string;\n disabled?: string;\n rangeStart?: string;\n rangeEnd?: string;\n rangeBetween?: string;\n rangeHovering?: string;\n [key: string]: string | undefined;\n}\n\nexport const defaultClassNames = {\n root: \"w-fit flex flex-col p-4 bg-white rounded-lg shadow-lg\",\n header: \"flex items-center justify-between border-b-2 border-brand-gray-light/40 pb-2 mb-3\",\n calendarsContainer: \"flex flex-col md:flex-row gap-4\",\n calendarContainer: \"flex-1 min-w-[280px] min-h-[260px]\",\n weekdayGrid: \"grid grid-cols-7 gap-1 mb-1 border-b border-brand-gray-light/40\",\n weekday: \"text-center text-xs text-gray-400 py-2\",\n daysGrid: \"grid grid-cols-7 gap-px bg-brand-gray-light/20\",\n footer: \"mt-4\",\n\n navButton: \"p-2 hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n monthYearContainer: \"flex gap-8\",\n monthYearLabel: \"flex gap-1 items-center font-semibold text-brand-text\",\n monthYearButton: \"hover:bg-gray-100 px-2 py-1 rounded cursor-pointer\",\n\n day: {\n day: \"aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px\",\n selected: \"bg-brand-gold text-white rounded-full\",\n unselected: \"bg-white hover:bg-brand-gray-light text-brand-text\",\n disabled: \"bg-white text-gray-300 cursor-not-allowed\",\n rangeStart: \"bg-brand-gold text-white\",\n rangeEnd: \"bg-brand-gold text-white\",\n rangeBetween: \"bg-brand-gold/25 text-brand-text\",\n rangeHovering: \"bg-brand-gold/25 text-brand-text\",\n },\n\n monthsGrid: \"grid grid-cols-3 gap-2 animate-slide-in-top\",\n monthButton: \"py-4 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n monthButtonSelected: \"bg-brand-gold text-white\",\n monthButtonUnselected: \"text-brand-text\",\n\n yearsGrid: \"grid grid-cols-3 gap-2 max-h-[300px] overflow-y-auto pr-2 animate-slide-in-top\",\n yearButton: \"py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n yearButtonSelected: \"bg-brand-gold text-white\",\n yearButtonUnselected: \"text-brand-text\",\n}\n\nexport interface CalendarClassNames {\n root?: string;\n header?: string;\n calendarsContainer?: string;\n calendarContainer?: string;\n weekdayGrid?: string;\n weekday?: string;\n daysGrid?: string;\n footer?: string;\n\n navButton?: string;\n monthYearContainer?: string;\n monthYearLabel?: string;\n monthYearButton?: string;\n\n day?: DayClassNames;\n\n monthsGrid?: string;\n monthButton?: string;\n monthButtonSelected?: string;\n monthButtonUnselected?: string;\n\n yearsGrid?: string;\n yearButton?: string;\n yearButtonSelected?: string;\n yearButtonUnselected?: string;\n}\n\nexport const mergeClassNames = (custom?: CalendarClassNames): Required<CalendarClassNames> => {\n const result = { ...defaultClassNames };\n if (!custom) return result;\n\n for (const key in custom) {\n const k = key as keyof CalendarClassNames;\n if (k === 'day' && custom.day) {\n result.day = { ...defaultClassNames.day, ...custom.day };\n } else if (custom[k]) {\n (result as any)[k] = custom[k];\n }\n }\n return result;\n};\n","import React from 'react';\nimport { CalendarClassNames } from '../types';\n\ninterface MonthSelectionProps {\n year: number;\n month: number;\n monthNames: string[];\n minDate?: Date | null;\n maxDate?: Date | null;\n onMonthSelect: (month: number) => void;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const MonthSelection: React.FC<MonthSelectionProps> = ({\n year,\n month,\n monthNames,\n minDate,\n maxDate,\n onMonthSelect,\n classNames,\n}) => {\n const isMonthDisabled = (monthIdx: number) => {\n if (minDate && year === minDate.getFullYear() && monthIdx < minDate.getMonth()) {\n return true;\n }\n if (maxDate && year === maxDate.getFullYear() && monthIdx > maxDate.getMonth()) {\n return true;\n }\n return false;\n };\n\n return (\n <div className={classNames.monthsGrid}>\n {monthNames.map((name, idx) => {\n const disabled = isMonthDisabled(idx);\n return (\n <button\n key={name}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => !disabled && onMonthSelect(idx)}\n className={`${classNames.monthButton} ${idx === month ? classNames.monthButtonSelected : classNames.monthButtonUnselected}`}\n disabled={disabled}\n >\n {name}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useEffect, useRef } from 'react';\nimport { CalendarClassNames, DateAdapter } from '../types';\n\ninterface YearSelectionProps {\n year: number;\n minDate?: Date | null;\n maxDate?: Date | null;\n adapter: DateAdapter;\n onYearSelect: (year: number) => void;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const YearSelection: React.FC<YearSelectionProps> = ({\n year,\n minDate,\n maxDate,\n adapter,\n onYearSelect,\n classNames,\n}) => {\n const yearListRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (yearListRef.current) {\n const selectedYearBtn = yearListRef.current.querySelector('[data-selected=\"true\"]');\n if (selectedYearBtn) {\n selectedYearBtn.scrollIntoView({ block: 'center' });\n }\n }\n }, []);\n\n const startYear = minDate ? adapter.get(adapter.date(minDate), 'year') : year - 50;\n const endYear = maxDate ? adapter.get(adapter.date(maxDate), 'year') : year + 50;\n const years = [];\n for (let y = startYear; y <= endYear; y++) {\n years.push(y);\n }\n\n return (\n <div ref={yearListRef} className={classNames.yearsGrid}>\n {years.map((y) => (\n <button\n key={y}\n data-selected={y === year}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => onYearSelect(y)}\n className={`${classNames.yearButton} ${y === year ? classNames.yearButtonSelected : classNames.yearButtonUnselected}`}\n >\n {y}\n </button>\n ))}\n </div>\n );\n};\n","import React, { useState } from 'react';\nimport { useDates, UseDatesProps } from '../useDates';\nimport { Day } from './Day';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarHeader } from './CalendarHeader';\nimport { DateObj, CalendarClassNames } from '../types';\nimport { mergeClassNames } from '../classNames';\nimport { MonthSelection } from './MonthSelection';\nimport { YearSelection } from './YearSelection';\n\ninterface CalendarProps extends UseDatesProps {\n classNames?: CalendarClassNames;\n locale?: string;\n translations?: Partial<Translations>;\n header?: React.ReactNode | ((props: any) => React.ReactNode);\n footer?: React.ReactNode;\n renderDayTooltip?: (dateObj: DateObj) => React.ReactNode;\n}\n\ntype CalendarView = 'days' | 'months' | 'years';\n\nexport const Calendar: React.FC<CalendarProps> = (props) => {\n const {\n classNames: customClassNames,\n locale,\n translations: customTranslations,\n adapter = defaultAdapter,\n firstDayOfWeek = 0,\n header,\n footer,\n renderDayTooltip,\n ...useDatesProps\n } = props;\n\n const classNames = mergeClassNames(customClassNames);\n\n const [view, setView] = useState<CalendarView>('days');\n const [slideDirection, setSlideDirection] = useState<'left' | 'right' | null>(null);\n\n const t = getTranslations(adapter, locale, customTranslations);\n const weekdayNames = t.weekdays;\n const monthNames = t.months;\n\n const {\n calendars,\n getBackProps,\n getForwardProps,\n getDateProps,\n setOffset\n } = useDates({ ...useDatesProps, adapter, firstDayOfWeek });\n\n // Adjust weekday names based on firstDayOfWeek\n const sortedWeekdays = [...weekdayNames.slice(firstDayOfWeek), ...weekdayNames.slice(0, firstDayOfWeek)];\n\n const currentCalendar = calendars[0];\n const { month, year } = currentCalendar;\n\n const handleMonthSelect = (newMonth: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'month', newMonth);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const handleYearSelect = (newYear: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'year', newYear);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const wrappedGetBackProps = (args: any) => {\n const props = getBackProps(args);\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('left');\n props.onClick?.(e);\n }\n };\n };\n\n const wrappedGetForwardProps = (args: any) => {\n const props = getForwardProps(args);\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('right');\n props.onClick?.(e);\n }\n };\n };\n\n const renderDefaultHeader = () => (\n <CalendarHeader\n calendars={calendars}\n getBackProps={wrappedGetBackProps}\n getForwardProps={wrappedGetForwardProps}\n setView={setView}\n monthNames={monthNames}\n t={t}\n classNames={classNames}\n slideDirection={slideDirection}\n currentView={view}\n />\n );\n\n return (\n <div className={classNames.root}>\n {typeof header === 'function' ? header({\n calendars,\n getBackProps: wrappedGetBackProps,\n getForwardProps: wrappedGetForwardProps,\n setView,\n monthNames,\n t,\n slideDirection,\n currentView: view\n }) : (header || renderDefaultHeader())}\n\n <div className={classNames.calendarsContainer}>\n {view === 'months' && calendars.map((calendar) => (\n <div key={`months-${calendar.year}`} className={classNames.calendarContainer}>\n <MonthSelection\n year={calendar.year}\n month={calendar.month}\n monthNames={monthNames}\n minDate={props.minDate}\n maxDate={props.maxDate}\n onMonthSelect={handleMonthSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'years' && calendars.map((calendar) => (\n <div key={`years-${calendar.year}`} className={classNames.calendarContainer}>\n <YearSelection\n year={calendar.year}\n minDate={props.minDate}\n maxDate={props.maxDate}\n adapter={adapter}\n onYearSelect={handleYearSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'days' && calendars.map((calendar) => (\n <div key={`${calendar.month}-${calendar.year}`} className={classNames.calendarContainer}>\n {calendars.length > 1 && (\n <button\n type=\"button\"\n aria-label={monthNames[calendar.month]}\n className=\"block w-full text-center font-semibold mb-2 text-brand-text\"\n >\n {monthNames[calendar.month]} {calendars[0].year !== calendars[calendars.length - 1].year ? calendar.year : ''}\n </button>\n )}\n <div className={classNames.weekdayGrid}>\n {sortedWeekdays.map((day) => (\n <div key={day} className={classNames.weekday}>{day}</div>\n ))}\n </div>\n <div className={`${classNames.daysGrid} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n {calendar.weeks.map((week, wi) =>\n week.map((dateObj, di) => (\n <Day\n key={`${wi}-${di}`}\n dateObj={dateObj}\n getDateProps={getDateProps}\n classNames={classNames}\n tooltip={dateObj && renderDayTooltip?.(dateObj)}\n />\n ))\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={classNames.footer}>{footer}</div>}\n </div>\n );\n};\n"],"mappings":"wMAUA,IAAa,GAA2B,CAAE,UAAS,eAAc,aAAY,aAAc,CACzF,GAAM,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,CAAS,EAAK,EAEhD,GAAI,CAAC,EACH,OAAO,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAU,wBAA0B,CAAA,EAGlD,GAAM,CAAE,OAAM,WAAU,aAAY,eAAc,aAAY,iBAAgB,kBAAiB,iBAAkB,EAC3G,EAAa,EAAW,IAE1B,EAAe,eACnB,AAaE,EAbE,GAAgB,EACH,GAAG,EAAW,SAAS,eAC7B,EACM,GAAG,EAAW,WAAW,GAAG,EAAgB,gCAAkC,iBACpF,EACM,GAAG,EAAW,SAAS,GAAG,EAAgB,gCAAkC,iBAClF,EACM,EAAW,cAAgB,GACjC,EACM,EAAW,eAAiB,GAClC,EACM,EAAW,UAAY,GAC5B,EAGK,EAAW,YAAc,GAFzB,EAAW,UAAY,GAKxC,IAAM,EAAY,CAChB,EAAW,IACX,EACA,IAAI,EAAQ,WAAa,CAAC,EAAA,CAAG,IAAI,GAAM,EAAmB,IAAM,CAAC,CACnE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG,EAE1B,OACE,EAAA,EAAA,KAAA,CAAC,SAAD,C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sx","../src/i18n.ts","../src/components/CalendarHeader.tsx","../src/classNames.ts","../src/components/MonthSelection.tsx","../src/components/YearSelection.tsx","../src/components/Calendar.tsx"],"sourcesContent":["import React, { useState } from 'react';\nimport type { CalendarClassNames, DateObj } from '../types';\n\ninterface DayProps {\n dateObj: DateObj | null;\n getDateProps: (args: { dateObj: DateObj, [key: string]: any }) => any;\n tooltip?: React.ReactNode;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const Day: React.FC<DayProps> = ({ dateObj, getDateProps, classNames, tooltip }) => {\n const [isHovered, setIsHovered] = useState(false);\n\n if (!dateObj) {\n return <div className=\"aspect-square bg-white\" />;\n }\n\n const { date, selected, selectable, isRangeStart, isRangeEnd, isRangeBetween, isRangeHovering, isRangeActive } = dateObj;\n const dayClasses = classNames.day;\n\n let stateClasses = \"rounded-full\";\n if (isRangeStart && isRangeEnd) {\n stateClasses = `${dayClasses.selected} rounded-full`;\n } else if (isRangeStart) {\n stateClasses = `${dayClasses.rangeStart} ${isRangeActive ? 'rounded-l-full rounded-r-none' : 'rounded-full'}`;\n } else if (isRangeEnd) {\n stateClasses = `${dayClasses.rangeEnd} ${isRangeActive ? 'rounded-r-full rounded-l-none' : 'rounded-full'}`;\n } else if (isRangeBetween) {\n stateClasses = dayClasses.rangeBetween || '';\n } else if (isRangeHovering) {\n stateClasses = dayClasses.rangeHovering || '';\n } else if (selected) {\n stateClasses = dayClasses.selected || '';\n } else if (!selectable) {\n stateClasses = dayClasses.disabled || '';\n } else {\n stateClasses = dayClasses.unselected || '';\n }\n\n const className = [\n dayClasses.day,\n stateClasses,\n ...(dateObj.modifiers || []).map(m => (dayClasses as any)[m] || m)\n ].filter(Boolean).join(' ');\n\n return (\n <button\n {...getDateProps({\n dateObj,\n onMouseEnter: () => setIsHovered(true),\n onMouseLeave: () => setIsHovered(false)\n })}\n className={className}\n >\n {date.getDate()}\n {tooltip && isHovered && (\n <div className=\"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 hidden group-hover:block z-10\">\n <div className=\"bg-gray-800 text-white text-xs py-1 px-2 rounded whitespace-nowrap shadow-lg\">\n {tooltip}\n <div className=\"absolute top-full left-1/2 -translate-x-1/2 border-8 border-transparent border-t-gray-800\" />\n </div>\n </div>\n )}\n </button>\n );\n};\n","import { DateAdapter } from \"./types\";\nimport { defaultAdapter } from \"./adapters/dayjs\";\n\nexport interface Translations {\n months: string[];\n weekdays: string[];\n back: string;\n forward: string;\n}\n\nexport function getDefaults(adapter: DateAdapter = defaultAdapter, locale?: string): Translations {\n return {\n months: adapter.getMonths(locale),\n weekdays: adapter.getWeekdays(locale),\n back: 'Previous month',\n forward: 'Next month'\n };\n}\n\nexport function getTranslations(\n adapter: DateAdapter = defaultAdapter,\n locale?: string,\n custom?: Partial<Translations>\n): Translations {\n const base = getDefaults(adapter, locale);\n return { ...base, ...custom };\n}\n","import React from 'react';\nimport { Calendar, CalendarClassNames } from '../types';\n\nexport interface HeaderProps {\n calendars: Calendar[];\n getBackProps: (args: any) => any;\n getForwardProps: (args: any) => any;\n setView: (view: 'days' | 'months' | 'years') => void;\n monthNames: string[];\n t: { back: string; forward: string };\n classNames: Required<CalendarClassNames>;\n slideDirection?: 'left' | 'right' | null;\n currentView?: 'days' | 'months' | 'years';\n}\n\nexport const ChevronLeftIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"15 18 9 12 15 6\"></polyline>\n </svg>\n);\n\nexport const ChevronRightIcon = () => (\n <svg width=\"20\" height=\"20\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\">\n <polyline points=\"9 18 15 12 9 6\"></polyline>\n </svg>\n);\n\nexport const CalendarHeader: React.FC<HeaderProps> = ({\n calendars,\n getBackProps,\n getForwardProps,\n setView,\n monthNames,\n t,\n classNames,\n slideDirection,\n currentView\n}) => {\n return (\n <div className={classNames.header}>\n <button\n {...getBackProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.back}\n >\n <ChevronLeftIcon />\n </button>\n\n <div className={classNames.monthYearContainer}>\n {calendars.length === 1 ? (\n <div key={`${calendars[0].month}-${calendars[0].year}`} className={`${classNames.monthYearLabel} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n <button\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => setView(currentView === 'months' ? 'days' : 'months')}\n className={classNames.monthYearButton}\n >\n {monthNames[calendars[0].month]}\n </button>\n <button\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => setView(currentView === 'years' ? 'days' : 'years')}\n className={classNames.monthYearButton}\n >\n {calendars[0].year}\n </button>\n </div>\n ) : (\n <div className={`${classNames.monthYearLabel} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n {(() => {\n const first = calendars[0];\n const last = calendars[calendars.length - 1];\n const isFullYear = calendars.length === 12 && first.month === 0 && last.month === 11 && first.year === last.year;\n\n if (isFullYear) {\n return <span>{first.year}</span>;\n } else if (first.year === last.year) {\n return <span>{monthNames[first.month]} - {monthNames[last.month]} {first.year}</span>;\n } else {\n return <span>{monthNames[first.month]} {first.year} - {monthNames[last.month]} {last.year}</span>;\n }\n })()}\n </div>\n )}\n </div>\n\n <button\n {...getForwardProps({ calendars })}\n onMouseDown={(e) => e.preventDefault()}\n className={`${classNames.navButton} ${currentView && currentView !== 'days' ? 'invisible pointer-events-none' : ''}`}\n aria-label={t.forward}\n >\n <ChevronRightIcon />\n </button>\n </div>\n );\n};\n","export interface DayClassNames {\n day?: string;\n selected?: string;\n unselected?: string;\n disabled?: string;\n rangeStart?: string;\n rangeEnd?: string;\n rangeBetween?: string;\n rangeHovering?: string;\n [key: string]: string | undefined;\n}\n\nexport const defaultClassNames = {\n root: \"w-fit flex flex-col p-4 bg-white rounded-lg shadow-lg\",\n header: \"flex items-center justify-between border-b-2 border-brand-gray-light/40 pb-2\",\n calendarsContainer: \"flex flex-wrap gap-4 mt-3\",\n calendarContainer: \"flex-1 min-w-[280px] max-w-full\",\n weekdayGrid: \"grid grid-cols-7 gap-1 mb-1 border-b border-brand-gray-light/40\",\n weekday: \"text-center text-xs text-gray-400 py-2\",\n daysGrid: \"grid grid-cols-7 gap-px bg-brand-gray-light/20\",\n footer: \"mt-4\",\n\n navButton: \"p-2 text-brand-text hover:bg-gray-100 rounded-full transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n monthYearContainer: \"flex gap-8\",\n monthYearLabel: \"flex gap-1 items-center font-semibold text-brand-text\",\n monthYearButton: \"hover:bg-gray-100 px-2 py-1 rounded cursor-pointer\",\n\n day: {\n day: \"aspect-square flex items-center justify-center text-sm font-medium transition-all relative group cursor-pointer p-px\",\n selected: \"bg-brand-gold text-white rounded-full\",\n unselected: \"bg-white hover:bg-brand-gray-light text-brand-text\",\n disabled: \"bg-white text-gray-300 cursor-not-allowed\",\n rangeStart: \"bg-brand-gold text-white\",\n rangeEnd: \"bg-brand-gold text-white\",\n rangeBetween: \"bg-brand-gold/25 text-brand-text\",\n rangeHovering: \"bg-brand-gold/25 text-brand-text\",\n },\n\n monthsGrid: \"grid grid-cols-3 gap-2 animate-slide-in-top\",\n monthButton: \"py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n monthButtonSelected: \"bg-brand-gold text-white\",\n monthButtonUnselected: \"text-brand-text\",\n\n yearsGrid: \"grid grid-cols-3 gap-2 max-h-[300px] overflow-y-auto pr-2 animate-slide-in-top\",\n yearButton: \"py-3 rounded-lg hover:bg-brand-gray-light transition-colors cursor-pointer disabled:opacity-30 disabled:pointer-events-none\",\n yearButtonSelected: \"bg-brand-gold text-white\",\n yearButtonUnselected: \"text-brand-text\",\n}\n\nexport interface CalendarClassNames {\n root?: string;\n header?: string;\n calendarsContainer?: string;\n calendarContainer?: string;\n weekdayGrid?: string;\n weekday?: string;\n daysGrid?: string;\n footer?: string;\n\n navButton?: string;\n monthYearContainer?: string;\n monthYearLabel?: string;\n monthYearButton?: string;\n\n day?: DayClassNames;\n\n monthsGrid?: string;\n monthButton?: string;\n monthButtonSelected?: string;\n monthButtonUnselected?: string;\n\n yearsGrid?: string;\n yearButton?: string;\n yearButtonSelected?: string;\n yearButtonUnselected?: string;\n}\n\nexport const mergeClassNames = (custom?: CalendarClassNames): Required<CalendarClassNames> => {\n const result = { ...defaultClassNames };\n if (!custom) return result;\n\n for (const key in custom) {\n const k = key as keyof CalendarClassNames;\n if (k === 'day' && custom.day) {\n result.day = { ...defaultClassNames.day, ...custom.day };\n } else if (custom[k]) {\n (result as any)[k] = custom[k];\n }\n }\n return result;\n};\n","import React from 'react';\nimport { CalendarClassNames } from '../types';\n\ninterface MonthSelectionProps {\n year: number;\n month: number;\n monthNames: string[];\n minDate?: Date | null;\n maxDate?: Date | null;\n onMonthSelect: (month: number) => void;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const MonthSelection: React.FC<MonthSelectionProps> = ({\n year,\n month,\n monthNames,\n minDate,\n maxDate,\n onMonthSelect,\n classNames,\n}) => {\n const isMonthDisabled = (monthIdx: number) => {\n if (minDate && year === minDate.getFullYear() && monthIdx < minDate.getMonth()) {\n return true;\n }\n if (maxDate && year === maxDate.getFullYear() && monthIdx > maxDate.getMonth()) {\n return true;\n }\n return false;\n };\n\n return (\n <div className={classNames.monthsGrid}>\n {monthNames.map((name, idx) => {\n const disabled = isMonthDisabled(idx);\n return (\n <button\n key={name}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => !disabled && onMonthSelect(idx)}\n className={`${classNames.monthButton} ${idx === month ? classNames.monthButtonSelected : classNames.monthButtonUnselected}`}\n disabled={disabled}\n >\n {name}\n </button>\n );\n })}\n </div>\n );\n};\n","import React, { useEffect, useRef } from 'react';\nimport { CalendarClassNames, DateAdapter } from '../types';\n\ninterface YearSelectionProps {\n year: number;\n minDate?: Date | null;\n maxDate?: Date | null;\n adapter: DateAdapter;\n onYearSelect: (year: number) => void;\n classNames: Required<CalendarClassNames>;\n}\n\nexport const YearSelection: React.FC<YearSelectionProps> = ({\n year,\n minDate,\n maxDate,\n adapter,\n onYearSelect,\n classNames,\n}) => {\n const yearListRef = useRef<HTMLDivElement>(null);\n\n useEffect(() => {\n if (yearListRef.current) {\n const selectedYearBtn = yearListRef.current.querySelector('[data-selected=\"true\"]');\n if (selectedYearBtn) {\n selectedYearBtn.scrollIntoView({ block: 'center' });\n }\n }\n }, []);\n\n const startYear = minDate ? adapter.get(adapter.date(minDate), 'year') : year - 50;\n const endYear = maxDate ? adapter.get(adapter.date(maxDate), 'year') : year + 50;\n const years = [];\n for (let y = startYear; y <= endYear; y++) {\n years.push(y);\n }\n\n return (\n <div ref={yearListRef} className={classNames.yearsGrid}>\n {years.map((y) => (\n <button\n key={y}\n data-selected={y === year}\n onMouseDown={(e) => e.preventDefault()}\n onClick={() => onYearSelect(y)}\n className={`${classNames.yearButton} ${y === year ? classNames.yearButtonSelected : classNames.yearButtonUnselected}`}\n >\n {y}\n </button>\n ))}\n </div>\n );\n};\n","import React, { useState } from 'react';\nimport { useDates, UseDatesProps } from '../useDates';\nimport { Day } from './Day';\nimport { defaultAdapter } from '../adapters/dayjs';\nimport { getTranslations, Translations } from '../i18n';\nimport { CalendarHeader } from './CalendarHeader';\nimport { DateObj, CalendarClassNames } from '../types';\nimport { mergeClassNames } from '../classNames';\nimport { MonthSelection } from './MonthSelection';\nimport { YearSelection } from './YearSelection';\n\ninterface CalendarProps extends UseDatesProps {\n classNames?: CalendarClassNames;\n locale?: string;\n translations?: Partial<Translations>;\n header?: React.ReactNode | ((props: any) => React.ReactNode);\n footer?: React.ReactNode;\n renderDayTooltip?: (dateObj: DateObj) => React.ReactNode;\n}\n\ntype CalendarView = 'days' | 'months' | 'years';\n\nexport const Calendar: React.FC<CalendarProps> = (props) => {\n const {\n classNames: customClassNames,\n locale,\n translations: customTranslations,\n adapter = defaultAdapter,\n firstDayOfWeek = 0,\n header,\n footer,\n renderDayTooltip,\n ...useDatesProps\n } = props;\n\n const classNames = mergeClassNames(customClassNames);\n\n const [view, setView] = useState<CalendarView>('days');\n const [slideDirection, setSlideDirection] = useState<'left' | 'right' | null>(null);\n\n const t = getTranslations(adapter, locale, customTranslations);\n const weekdayNames = t.weekdays;\n const monthNames = t.months;\n\n const {\n calendars,\n getBackProps,\n getForwardProps,\n getDateProps,\n setOffset\n } = useDates({ ...useDatesProps, adapter, firstDayOfWeek });\n\n // Adjust weekday names based on firstDayOfWeek\n const sortedWeekdays = [...weekdayNames.slice(firstDayOfWeek), ...weekdayNames.slice(0, firstDayOfWeek)];\n\n const currentCalendar = calendars[0];\n const { month, year } = currentCalendar;\n\n const handleMonthSelect = (newMonth: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'month', newMonth);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const handleYearSelect = (newYear: number) => {\n const currentMonth = adapter.set(adapter.set(adapter.date(props.date || new Date()), 'year', year), 'month', month);\n const targetMonth = adapter.set(currentMonth, 'year', newYear);\n const baseMonth = adapter.startOf(adapter.date(props.date || new Date()), 'month');\n const newOffset = adapter.diff(targetMonth, baseMonth, 'month');\n setSlideDirection(null);\n setOffset(newOffset);\n setView('days');\n };\n\n const wrappedGetBackProps = (args: any) => {\n const props = getBackProps(args);\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('left');\n props.onClick?.(e);\n }\n };\n };\n\n const wrappedGetForwardProps = (args: any) => {\n const props = getForwardProps(args);\n return {\n ...props,\n onClick: (e: any) => {\n setSlideDirection('right');\n props.onClick?.(e);\n }\n };\n };\n\n const renderDefaultHeader = () => (\n <CalendarHeader\n calendars={calendars}\n getBackProps={wrappedGetBackProps}\n getForwardProps={wrappedGetForwardProps}\n setView={setView}\n monthNames={monthNames}\n t={t}\n classNames={classNames}\n slideDirection={slideDirection}\n currentView={view}\n />\n );\n\n return (\n <div className={`rmdp ${classNames.root}`}>\n {typeof header === 'function' ? header({\n calendars,\n getBackProps: wrappedGetBackProps,\n getForwardProps: wrappedGetForwardProps,\n setView,\n monthNames,\n t,\n slideDirection,\n currentView: view\n }) : (header || renderDefaultHeader())}\n\n <div className={classNames.calendarsContainer}>\n {view === 'months' && calendars.map((calendar) => (\n <div key={`months-${calendar.year}`} className={classNames.calendarContainer}>\n <MonthSelection\n year={calendar.year}\n month={calendar.month}\n monthNames={monthNames}\n minDate={props.minDate}\n maxDate={props.maxDate}\n onMonthSelect={handleMonthSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'years' && calendars.map((calendar) => (\n <div key={`years-${calendar.year}`} className={classNames.calendarContainer}>\n <YearSelection\n year={calendar.year}\n minDate={props.minDate}\n maxDate={props.maxDate}\n adapter={adapter}\n onYearSelect={handleYearSelect}\n classNames={classNames}\n />\n </div>\n ))}\n {view === 'days' && calendars.map((calendar) => (\n <div key={`${calendar.month}-${calendar.year}`} className={classNames.calendarContainer}>\n {calendars.length > 1 && (\n <button\n type=\"button\"\n aria-label={monthNames[calendar.month]}\n className=\"block w-full text-center font-semibold mb-2 text-brand-text\"\n >\n {monthNames[calendar.month]} {calendars[0].year !== calendars[calendars.length - 1].year ? calendar.year : ''}\n </button>\n )}\n <div className={classNames.weekdayGrid}>\n {sortedWeekdays.map((day) => (\n <div key={day} className={classNames.weekday}>{day}</div>\n ))}\n </div>\n <div className={`${classNames.daysGrid} ${slideDirection === 'left' ? 'animate-slide-in-left' : slideDirection === 'right' ? 'animate-slide-in-right' : ''}`}>\n {calendar.weeks.map((week, wi) =>\n week.map((dateObj, di) => (\n <Day\n key={`${wi}-${di}`}\n dateObj={dateObj}\n getDateProps={getDateProps}\n classNames={classNames}\n tooltip={dateObj && renderDayTooltip?.(dateObj)}\n />\n ))\n )}\n </div>\n </div>\n ))}\n </div>\n {footer && <div className={classNames.footer}>{footer}</div>}\n </div>\n );\n};\n"],"mappings":";;;;;AAUA,IAAa,KAA2B,EAAE,YAAS,iBAAc,eAAY,iBAAc;CACzF,IAAM,CAAC,GAAW,KAAgB,EAAS,EAAK;CAEhD,IAAI,CAAC,GACH,OAAO,kBAAC,OAAD,EAAK,WAAU,yBAA0B,CAAA;CAGlD,IAAM,EAAE,SAAM,aAAU,eAAY,iBAAc,eAAY,mBAAgB,oBAAiB,qBAAkB,GAC3G,IAAa,EAAW,KAE1B,IAAe;CACnB,AAaE,IAbE,KAAgB,IACH,GAAG,EAAW,SAAS,iBAC7B,IACM,GAAG,EAAW,WAAW,GAAG,IAAgB,kCAAkC,mBACpF,IACM,GAAG,EAAW,SAAS,GAAG,IAAgB,kCAAkC,mBAClF,IACM,EAAW,gBAAgB,KACjC,IACM,EAAW,iBAAiB,KAClC,IACM,EAAW,YAAY,KAC5B,IAGK,EAAW,cAAc,KAFzB,EAAW,YAAY;CAKxC,IAAM,IAAY;EAChB,EAAW;EACX;EACA,IAAI,EAAQ,aAAa,CAAC,EAAA,CAAG,KAAI,MAAM,EAAmB,MAAM,CAAC;CACnE,CAAC,CAAC,OAAO,OAAO,CAAC,CAAC,KAAK,GAAG;CAE1B,OACE,kBAAC,UAAD;EACE,GAAI,EAAa;GACf;GACA,oBAAoB,EAAa,EAAI;GACrC,oBAAoB,EAAa,EAAK;EACxC,CAAC;EACU;EANb,UAAA,CAQG,EAAK,QAAQ,GACb,KAAW,KACV,kBAAC,OAAD;GAAK,WAAU;GACb,UAAA,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACG,GACD,kBAAC,OAAD,EAAK,WAAU,4FAA6F,CA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ACF;SACZ,SAAS,KAAW,IAAmB,CAAO;QAC/C,GALM,GAAG,EAAG,GAAG,GAKf,CACF,CACH;OACG,CAAA;MACF;KA5BK,GAAA,GAAG,EAAS,MAAM,GAAG,EAAS,MA4BnC,CACN;IACE;;GACJ,KAAU,kBAAC,OAAD;IAAK,WAAW,EAAW;IAAS,UAAA;GAAY,CAAA;EACxD;;AAET"}
@@ -1,4 +1,4 @@
1
- import { addMonth as e, composeEventHandlers as t, getCalendars as n, isBackDisabled as r, isForwardDisabled as i, subtractMonth as a } from "./utils.mjs";
1
+ import { addMonth as e, composeEventHandlers as t, getCalendars as n, isBackDisabled as r, isForwardDisabled as i, subtractMonth as a } from "./utils.js";
2
2
  import { useCallback as o, useState as s } from "react";
3
3
  import c from "dayjs";
4
4
  import l from "dayjs/plugin/isBetween";
@@ -195,4 +195,4 @@ function y({ date: e = /* @__PURE__ */ new Date(), maxDate: r, minDate: i, disab
195
195
  //#endregion
196
196
  export { f as n, p as r, y as t };
197
197
 
198
- //# sourceMappingURL=useDates-CpcW1GpF.mjs.map
198
+ //# sourceMappingURL=useDates-CjPuu-VA.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useDates-CCrn42eQ.js","names":[],"sources":["../src/adapters/dayjs.ts","../src/useDates.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { Dayjs } from 'dayjs';\nimport isBetween from 'dayjs/plugin/isBetween';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport localeData from 'dayjs/plugin/localeData';\nimport type { DateAdapter } from '../types';\n\ndayjs.extend(isBetween);\ndayjs.extend(customParseFormat);\ndayjs.extend(localeData);\n\nexport class DayjsAdapter implements DateAdapter<Dayjs> {\n date(value?: any): Dayjs {\n return dayjs(value);\n }\n\n add(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.add(amount, unit);\n }\n\n subtract(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.subtract(amount, unit);\n }\n\n startOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.startOf(unit);\n }\n\n endOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.endOf(unit);\n }\n\n isBefore(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isBefore(comparison, unit);\n }\n\n isAfter(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isAfter(comparison, unit);\n }\n\n isSame(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isSame(comparison, unit);\n }\n\n set(date: Dayjs, unit: 'day' | 'month' | 'year', value: number): Dayjs {\n if (unit === 'day') return date.date(value);\n return date.set(unit, value);\n }\n\n get(date: Dayjs, unit: 'day' | 'month' | 'year'): number {\n if (unit === 'day') return date.date();\n return date.get(unit);\n }\n\n format(date: Dayjs, formatStr: string, locale?: string): string {\n if (locale) {\n return date.locale(locale).format(formatStr);\n }\n return date.format(formatStr);\n }\n\n getDaysInMonth(date: Dayjs): number {\n return date.daysInMonth();\n }\n\n toDate(date: Dayjs): Date {\n return date.toDate();\n }\n\n diff(date: Dayjs, comparison: Dayjs, unit: 'month' | 'year'): number {\n return date.diff(comparison, unit);\n }\n\n getMonths(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().months() : dayjs.localeData().months();\n }\n\n getWeekdays(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().weekdaysShort().map(d => d.toUpperCase()) : dayjs.localeData().weekdaysShort().map(d => d.toUpperCase());\n }\n}\n\nexport const defaultAdapter = new DayjsAdapter();\n","import { useState, useCallback } from 'react';\nimport type { DateAdapter, DateObj, SelectionMode, Calendar } from './types';\nimport { defaultAdapter } from './adapters/dayjs';\nimport {\n addMonth,\n composeEventHandlers,\n getCalendars,\n isBackDisabled,\n isForwardDisabled,\n subtractMonth\n} from './utils';\n\nfunction isOffsetControlled(propOffset?: number) {\n return propOffset !== undefined;\n}\n\nfunction getOffset(prop?: number, state: number = 0): number {\n return isOffsetControlled(prop) ? prop! : state;\n}\n\nfunction getDateProps(\n onDateSelected: (dateObj: DateObj, event: any) => void,\n { onClick, dateObj, ...rest }: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, (event: any) => {\n onDateSelected(dateObj, event);\n }),\n disabled: !dateObj.selectable,\n 'aria-pressed': dateObj.selected,\n role: 'button',\n ...rest\n };\n}\n\nfunction getBackProps(\n { minDate, offsetMonth, handleOffsetChanged, adapter }: { minDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth - subtractMonth({ calendars, offset, minDate, adapter })\n );\n }),\n disabled: isBackDisabled({ calendars, minDate, adapter }),\n ...rest\n };\n}\n\nfunction getForwardProps(\n { maxDate, offsetMonth, handleOffsetChanged, adapter }: { maxDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth + addMonth({ calendars, offset, maxDate, adapter })\n );\n }),\n disabled: isForwardDisabled({ calendars, maxDate, adapter }),\n ...rest\n };\n}\n\nexport interface UseDatesProps {\n date?: Date;\n maxDate?: Date;\n minDate?: Date;\n disabledDates?: Date[];\n monthsToDisplay?: number;\n firstDayOfWeek?: number;\n showOutsideDays?: boolean;\n offset?: number;\n onDateSelected?: (dateObj: DateObj, event: any) => void;\n onOffsetChanged?: (newOffset: number) => void;\n selected?: Date | Date[] | { start?: Date, end?: Date };\n modifiers?: Record<string, (date: Date, month: number, year: number) => boolean>;\n selectionMode?: SelectionMode;\n adapter?: DateAdapter;\n onChange?: (selected: Date | Date[] | { start?: Date, end?: Date } | null) => void;\n onMonthChange?: (date: Date) => void;\n onYearChange?: (date: Date) => void;\n}\n\nexport function useDates({\n date = new Date(),\n maxDate,\n minDate,\n disabledDates,\n monthsToDisplay = 1,\n firstDayOfWeek = 0,\n showOutsideDays = false,\n offset,\n onDateSelected,\n onOffsetChanged = () => { },\n selected,\n modifiers,\n selectionMode = 'single',\n adapter = defaultAdapter,\n onChange,\n onMonthChange,\n onYearChange\n}: UseDatesProps) {\n const [stateOffset, setStateOffset] = useState(0);\n const [hoveredDate, setHoveredDate] = useState<Date | undefined>(undefined);\n const offsetMonth = getOffset(offset, stateOffset);\n\n const handleOffsetChanged = useCallback((newOffset: number) => {\n if (!isOffsetControlled(offset)) {\n setStateOffset(newOffset);\n }\n onOffsetChanged(newOffset);\n\n const newDate = adapter.toDate(adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month'));\n onMonthChange?.(newDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, onMonthChange, onYearChange]);\n\n const handleDateSelected = useCallback((dateObj: DateObj, event: any) => {\n onDateSelected?.(dateObj, event);\n\n if (!onChange) return;\n\n if (selectionMode === 'single') {\n onChange(dateObj.date);\n } else if (selectionMode === 'multiple') {\n const currentSelected = Array.isArray(selected) ? selected : (selected ? [selected as Date] : []);\n const isAlreadySelected = currentSelected.some(d => adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day'));\n if (isAlreadySelected) {\n onChange(currentSelected.filter(d => !adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')));\n } else {\n onChange([...currentSelected, dateObj.date]);\n }\n } else if (selectionMode === 'range') {\n const range = (selected && typeof selected === 'object' && !(selected instanceof Date) && !Array.isArray(selected)) ? (selected as { start?: Date, end?: Date }) : { start: undefined, end: undefined };\n if (!range.start || (range.start && range.end)) {\n onChange({ start: dateObj.date, end: undefined });\n } else {\n if (adapter.isBefore(adapter.date(dateObj.date), adapter.date(range.start), 'day')) {\n onChange({ start: dateObj.date, end: range.start });\n } else {\n onChange({ start: range.start, end: dateObj.date });\n }\n }\n }\n }, [onDateSelected, onChange, selectionMode, selected, adapter]);\n\n const calendars = getCalendars({\n date,\n selected,\n disabledDates,\n modifiers,\n monthsToDisplay,\n minDate,\n maxDate,\n offset: offsetMonth,\n firstDayOfWeek,\n showOutsideDays,\n adapter,\n selectionMode,\n hoveredDate\n });\n\n return {\n calendars,\n getDateProps: (args: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }) => {\n const props = getDateProps(handleDateSelected, args);\n return {\n ...props,\n onMouseEnter: composeEventHandlers(args.onMouseEnter, () => {\n setHoveredDate(args.dateObj.date);\n }),\n onMouseLeave: composeEventHandlers(args.onMouseLeave, () => {\n setHoveredDate(undefined);\n })\n };\n },\n getBackProps: getBackProps.bind(null, {\n minDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n getForwardProps: getForwardProps.bind(null, {\n maxDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n setOffset: handleOffsetChanged\n };\n}\n"],"mappings":"ytBAOA,EAAA,QAAM,OAAO,EAAA,OAAS,EACtB,EAAA,QAAM,OAAO,EAAA,OAAiB,EAC9B,EAAA,QAAM,OAAO,EAAA,OAAU,EAEvB,IAAa,EAAb,KAAwD,CACtD,KAAK,EAAoB,CACvB,OAAA,EAAO,EAAA,QAAA,CAAM,CAAK,CACpB,CAEA,IAAI,EAAa,EAAgB,EAAuC,CACtE,OAAO,EAAK,IAAI,EAAQ,CAAI,CAC9B,CAEA,SAAS,EAAa,EAAgB,EAAuC,CAC3E,OAAO,EAAK,SAAS,EAAQ,CAAI,CACnC,CAEA,QAAQ,EAAa,EAAuC,CAC1D,OAAO,EAAK,QAAQ,CAAI,CAC1B,CAEA,MAAM,EAAa,EAAuC,CACxD,OAAO,EAAK,MAAM,CAAI,CACxB,CAE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O,EAAQ,KAAM,IAAK,EAAM,KAAM,CAAC,EAElD,EAAS,CAAE,MAAO,EAAM,MAAO,IAAK,EAAQ,IAAK,CAAC,CAG9D,EACJ,EAAG,CAAC,EAAgB,EAAU,EAAe,EAAU,CAAO,CAAC,EAkB/D,MAAO,CACH,UAjBc,EAAA,aAAa,CAC3B,OACA,WACA,gBACA,YACA,kBACA,UACA,UACA,OAAQ,EACR,iBACA,kBACA,UACA,gBACA,aACJ,CAGI,EACA,aAAe,IAEJ,CACH,GAFU,EAAa,EAAoB,CAExC,EACH,aAAc,EAAA,qBAAqB,EAAK,iBAAoB,CACxD,EAAe,EAAK,QAAQ,IAAI,CACpC,CAAC,EACD,aAAc,EAAA,qBAAqB,EAAK,iBAAoB,CACxD,EAAe,IAAA,EAAS,CAC5B,CAAC,CACL,GAEJ,aAAc,EAAa,KAAK,KAAM,CAClC,UACA,cACA,sBACA,SACJ,CAAC,EACD,gBAAiB,EAAgB,KAAK,KAAM,CACxC,UACA,cACA,sBACA,SACJ,CAAC,EACD,UAAW,CACf,CACJ"}
1
+ {"version":3,"file":"useDates-CjPuu-VA.js","names":[],"sources":["../src/adapters/dayjs.ts","../src/useDates.tsx"],"sourcesContent":["import dayjs from 'dayjs';\nimport type { Dayjs } from 'dayjs';\nimport isBetween from 'dayjs/plugin/isBetween';\nimport customParseFormat from 'dayjs/plugin/customParseFormat';\nimport localeData from 'dayjs/plugin/localeData';\nimport type { DateAdapter } from '../types';\n\ndayjs.extend(isBetween);\ndayjs.extend(customParseFormat);\ndayjs.extend(localeData);\n\nexport class DayjsAdapter implements DateAdapter<Dayjs> {\n date(value?: any): Dayjs {\n return dayjs(value);\n }\n\n add(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.add(amount, unit);\n }\n\n subtract(date: Dayjs, amount: number, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.subtract(amount, unit);\n }\n\n startOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.startOf(unit);\n }\n\n endOf(date: Dayjs, unit: 'day' | 'month' | 'year'): Dayjs {\n return date.endOf(unit);\n }\n\n isBefore(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isBefore(comparison, unit);\n }\n\n isAfter(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isAfter(comparison, unit);\n }\n\n isSame(date: Dayjs, comparison: Dayjs, unit?: 'day' | 'month' | 'year'): boolean {\n return date.isSame(comparison, unit);\n }\n\n set(date: Dayjs, unit: 'day' | 'month' | 'year', value: number): Dayjs {\n if (unit === 'day') return date.date(value);\n return date.set(unit, value);\n }\n\n get(date: Dayjs, unit: 'day' | 'month' | 'year'): number {\n if (unit === 'day') return date.date();\n return date.get(unit);\n }\n\n format(date: Dayjs, formatStr: string, locale?: string): string {\n if (locale) {\n return date.locale(locale).format(formatStr);\n }\n return date.format(formatStr);\n }\n\n getDaysInMonth(date: Dayjs): number {\n return date.daysInMonth();\n }\n\n toDate(date: Dayjs): Date {\n return date.toDate();\n }\n\n diff(date: Dayjs, comparison: Dayjs, unit: 'month' | 'year'): number {\n return date.diff(comparison, unit);\n }\n\n getMonths(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().months() : dayjs.localeData().months();\n }\n\n getWeekdays(locale?: string): string[] {\n return locale ? dayjs().locale(locale).localeData().weekdaysShort().map(d => d.toUpperCase()) : dayjs.localeData().weekdaysShort().map(d => d.toUpperCase());\n }\n}\n\nexport const defaultAdapter = new DayjsAdapter();\n","import { useState, useCallback } from 'react';\nimport type { DateAdapter, DateObj, SelectionMode, Calendar } from './types';\nimport { defaultAdapter } from './adapters/dayjs';\nimport {\n addMonth,\n composeEventHandlers,\n getCalendars,\n isBackDisabled,\n isForwardDisabled,\n subtractMonth\n} from './utils';\n\nfunction isOffsetControlled(propOffset?: number) {\n return propOffset !== undefined;\n}\n\nfunction getOffset(prop?: number, state: number = 0): number {\n return isOffsetControlled(prop) ? prop! : state;\n}\n\nfunction getDateProps(\n onDateSelected: (dateObj: DateObj, event: any) => void,\n { onClick, dateObj, ...rest }: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, (event: any) => {\n onDateSelected(dateObj, event);\n }),\n disabled: !dateObj.selectable,\n 'aria-pressed': dateObj.selected,\n role: 'button',\n ...rest\n };\n}\n\nfunction getBackProps(\n { minDate, offsetMonth, handleOffsetChanged, adapter }: { minDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth - subtractMonth({ calendars, offset, minDate, adapter })\n );\n }),\n disabled: isBackDisabled({ calendars, minDate, adapter }),\n ...rest\n };\n}\n\nfunction getForwardProps(\n { maxDate, offsetMonth, handleOffsetChanged, adapter }: { maxDate?: Date, offsetMonth: number, handleOffsetChanged: (newOffset: number) => void, adapter: DateAdapter },\n {\n onClick,\n offset = 1,\n calendars,\n ...rest\n }: { onClick?: (event: any) => void, offset?: number, calendars: Calendar[], [key: string]: any }\n) {\n return {\n onClick: composeEventHandlers(onClick, () => {\n handleOffsetChanged(\n offsetMonth + addMonth({ calendars, offset, maxDate, adapter })\n );\n }),\n disabled: isForwardDisabled({ calendars, maxDate, adapter }),\n ...rest\n };\n}\n\nexport interface UseDatesProps {\n date?: Date;\n maxDate?: Date;\n minDate?: Date;\n disabledDates?: Date[];\n monthsToDisplay?: number;\n firstDayOfWeek?: number;\n showOutsideDays?: boolean;\n offset?: number;\n onDateSelected?: (dateObj: DateObj, event: any) => void;\n onOffsetChanged?: (newOffset: number) => void;\n selected?: Date | Date[] | { start?: Date, end?: Date };\n modifiers?: Record<string, (date: Date, month: number, year: number) => boolean>;\n selectionMode?: SelectionMode;\n adapter?: DateAdapter;\n onChange?: (selected: Date | Date[] | { start?: Date, end?: Date } | null) => void;\n onMonthChange?: (date: Date) => void;\n onYearChange?: (date: Date) => void;\n}\n\nexport function useDates({\n date = new Date(),\n maxDate,\n minDate,\n disabledDates,\n monthsToDisplay = 1,\n firstDayOfWeek = 0,\n showOutsideDays = false,\n offset,\n onDateSelected,\n onOffsetChanged = () => { },\n selected,\n modifiers,\n selectionMode = 'single',\n adapter = defaultAdapter,\n onChange,\n onMonthChange,\n onYearChange\n}: UseDatesProps) {\n const [stateOffset, setStateOffset] = useState(0);\n const [hoveredDate, setHoveredDate] = useState<Date | undefined>(undefined);\n const offsetMonth = getOffset(offset, stateOffset);\n\n const handleOffsetChanged = useCallback((newOffset: number) => {\n if (!isOffsetControlled(offset)) {\n setStateOffset(newOffset);\n }\n onOffsetChanged(newOffset);\n\n const newDate = adapter.toDate(adapter.add(adapter.startOf(adapter.date(date), 'month'), newOffset, 'month'));\n onMonthChange?.(newDate);\n onYearChange?.(newDate);\n }, [offset, onOffsetChanged, date, adapter, onMonthChange, onYearChange]);\n\n const handleDateSelected = useCallback((dateObj: DateObj, event: any) => {\n onDateSelected?.(dateObj, event);\n\n if (!onChange) return;\n\n if (selectionMode === 'single') {\n onChange(dateObj.date);\n } else if (selectionMode === 'multiple') {\n const currentSelected = Array.isArray(selected) ? selected : (selected ? [selected as Date] : []);\n const isAlreadySelected = currentSelected.some(d => adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day'));\n if (isAlreadySelected) {\n onChange(currentSelected.filter(d => !adapter.isSame(adapter.date(d), adapter.date(dateObj.date), 'day')));\n } else {\n onChange([...currentSelected, dateObj.date]);\n }\n } else if (selectionMode === 'range') {\n const range = (selected && typeof selected === 'object' && !(selected instanceof Date) && !Array.isArray(selected)) ? (selected as { start?: Date, end?: Date }) : { start: undefined, end: undefined };\n if (!range.start || (range.start && range.end)) {\n onChange({ start: dateObj.date, end: undefined });\n } else {\n if (adapter.isBefore(adapter.date(dateObj.date), adapter.date(range.start), 'day')) {\n onChange({ start: dateObj.date, end: range.start });\n } else {\n onChange({ start: range.start, end: dateObj.date });\n }\n }\n }\n }, [onDateSelected, onChange, selectionMode, selected, adapter]);\n\n const calendars = getCalendars({\n date,\n selected,\n disabledDates,\n modifiers,\n monthsToDisplay,\n minDate,\n maxDate,\n offset: offsetMonth,\n firstDayOfWeek,\n showOutsideDays,\n adapter,\n selectionMode,\n hoveredDate\n });\n\n return {\n calendars,\n getDateProps: (args: { onClick?: (event: any) => void, dateObj: DateObj, [key: string]: any }) => {\n const props = getDateProps(handleDateSelected, args);\n return {\n ...props,\n onMouseEnter: composeEventHandlers(args.onMouseEnter, () => {\n setHoveredDate(args.dateObj.date);\n }),\n onMouseLeave: composeEventHandlers(args.onMouseLeave, () => {\n setHoveredDate(undefined);\n })\n };\n },\n getBackProps: getBackProps.bind(null, {\n minDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n getForwardProps: getForwardProps.bind(null, {\n maxDate,\n offsetMonth,\n handleOffsetChanged,\n adapter\n }),\n setOffset: handleOffsetChanged\n };\n}\n"],"mappings":";;;;;;AAOA,EAAM,OAAO,CAAS,GACtB,EAAM,OAAO,CAAiB,GAC9B,EAAM,OAAO,CAAU;AAEvB,IAAa,IAAb,MAAwD;CACtD,KAAK,GAAoB;EACvB,OAAO,EAAM,CAAK;CACpB;CAEA,IAAI,GAAa,GAAgB,GAAuC;EACtE,OAAO,EAAK,IAAI,GAAQ,CAAI;CAC9B;CAEA,SAAS,GAAa,GAAgB,GAAuC;EAC3E,OAAO,EAAK,SAAS,GAAQ,CAAI;CACnC;CAEA,QAAQ,GAAa,GAAuC;EAC1D,OAAO,EAAK,QAAQ,CAAI;CAC1B;CAEA,MAAM,GAAa,GAAuC;EACxD,OAAO,EAAK,MAAM,CAAI;CACxB;CAEA,SAAS,GAAa,GAAmB,GAA0C;EACjF,OAAO,EAAK,SAAS,GAAY,CAAI;CACvC;CAEA,QAAQ,GAAa,GAAmB,GAA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ACA;GACA;GACA;GACA,QAAQ;GACR;GACA;GACA;GACA;GACA;EACJ,CAGI;EACA,eAAe,OAEJ;GACH,GAFU,EAAa,GAAoB,CAExC;GACH,cAAc,EAAqB,EAAK,oBAAoB;IACxD,EAAe,EAAK,QAAQ,IAAI;GACpC,CAAC;GACD,cAAc,EAAqB,EAAK,oBAAoB;IACxD,EAAe,KAAA,CAAS;GAC5B,CAAC;EACL;EAEJ,cAAc,EAAa,KAAK,MAAM;GAClC;GACA;GACA;GACA;EACJ,CAAC;EACD,iBAAiB,EAAgB,KAAK,MAAM;GACxC;GACA;GACA;GACA;EACJ,CAAC;EACD,WAAW;CACf;AACJ"}
@@ -0,0 +1,2 @@
1
+ var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,s)=>(s=n==null?{}:e(i(n)),o(r||!n||!n.__esModule||!a.call(n,`default`)?t(s,`default`,{value:n,enumerable:!0}):s,n));const c=require("./utils.cjs");let l=require("react"),u=require("dayjs");u=s(u,1);let d=require("dayjs/plugin/isBetween");d=s(d,1);let f=require("dayjs/plugin/customParseFormat");f=s(f,1);let p=require("dayjs/plugin/localeData");p=s(p,1),u.default.extend(d.default),u.default.extend(f.default),u.default.extend(p.default);var m=class{date(e){return(0,u.default)(e)}add(e,t,n){return e.add(t,n)}subtract(e,t,n){return e.subtract(t,n)}startOf(e,t){return e.startOf(t)}endOf(e,t){return e.endOf(t)}isBefore(e,t,n){return e.isBefore(t,n)}isAfter(e,t,n){return e.isAfter(t,n)}isSame(e,t,n){return e.isSame(t,n)}set(e,t,n){return t===`day`?e.date(n):e.set(t,n)}get(e,t){return t===`day`?e.date():e.get(t)}format(e,t,n){return n?e.locale(n).format(t):e.format(t)}getDaysInMonth(e){return e.daysInMonth()}toDate(e){return e.toDate()}diff(e,t,n){return e.diff(t,n)}getMonths(e){return e?(0,u.default)().locale(e).localeData().months():u.default.localeData().months()}getWeekdays(e){return e?(0,u.default)().locale(e).localeData().weekdaysShort().map(e=>e.toUpperCase()):u.default.localeData().weekdaysShort().map(e=>e.toUpperCase())}},h=new m;function g(e){return e!==void 0}function _(e,t=0){return g(e)?e:t}function v(e,{onClick:t,dateObj:n,...r}){return{onClick:c.composeEventHandlers(t,t=>{e(n,t)}),disabled:!n.selectable,"aria-pressed":n.selected,role:`button`,...r}}function y({minDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o,...s}){return{onClick:c.composeEventHandlers(i,()=>{n(t-c.subtractMonth({calendars:o,offset:a,minDate:e,adapter:r}))}),disabled:c.isBackDisabled({calendars:o,minDate:e,adapter:r}),...s}}function b({maxDate:e,offsetMonth:t,handleOffsetChanged:n,adapter:r},{onClick:i,offset:a=1,calendars:o,...s}){return{onClick:c.composeEventHandlers(i,()=>{n(t+c.addMonth({calendars:o,offset:a,maxDate:e,adapter:r}))}),disabled:c.isForwardDisabled({calendars:o,maxDate:e,adapter:r}),...s}}function x({date:e=new Date,maxDate:t,minDate:n,disabledDates:r,monthsToDisplay:i=1,firstDayOfWeek:a=0,showOutsideDays:o=!1,offset:s,onDateSelected:u,onOffsetChanged:d=()=>{},selected:f,modifiers:p,selectionMode:m=`single`,adapter:x=h,onChange:S,onMonthChange:C,onYearChange:w}){let[T,E]=(0,l.useState)(0),[D,O]=(0,l.useState)(void 0),k=_(s,T),A=(0,l.useCallback)(t=>{g(s)||E(t),d(t);let n=x.toDate(x.add(x.startOf(x.date(e),`month`),t,`month`));C?.(n),w?.(n)},[s,d,e,x,C,w]),j=(0,l.useCallback)((e,t)=>{if(u?.(e,t),S){if(m===`single`)S(e.date);else if(m===`multiple`){let t=Array.isArray(f)?f:f?[f]:[];t.some(t=>x.isSame(x.date(t),x.date(e.date),`day`))?S(t.filter(t=>!x.isSame(x.date(t),x.date(e.date),`day`))):S([...t,e.date])}else if(m===`range`){let t=f&&typeof f==`object`&&!(f instanceof Date)&&!Array.isArray(f)?f:{start:void 0,end:void 0};!t.start||t.start&&t.end?S({start:e.date,end:void 0}):x.isBefore(x.date(e.date),x.date(t.start),`day`)?S({start:e.date,end:t.start}):S({start:t.start,end:e.date})}}},[u,S,m,f,x]);return{calendars:c.getCalendars({date:e,selected:f,disabledDates:r,modifiers:p,monthsToDisplay:i,minDate:n,maxDate:t,offset:k,firstDayOfWeek:a,showOutsideDays:o,adapter:x,selectionMode:m,hoveredDate:D}),getDateProps:e=>({...v(j,e),onMouseEnter:c.composeEventHandlers(e.onMouseEnter,()=>{O(e.dateObj.date)}),onMouseLeave:c.composeEventHandlers(e.onMouseLeave,()=>{O(void 0)})}),getBackProps:y.bind(null,{minDate:n,offsetMonth:k,handleOffsetChanged:A,adapter:x}),getForwardProps:b.bind(null,{maxDate:t,offsetMonth:k,handleOffsetChanged:A,adapter:x}),setOffset:A}}Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return x}});
2
+ //# sourceMappingURL=useDates-c17u4Qfs.cjs.map