react-modular-datepicker 0.0.5-canary.0 → 0.0.7
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/README.md +54 -468
- package/dist/components/Calendar.d.ts +1 -1
- package/dist/components/Day.d.ts +1 -1
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +58 -1386
- package/dist/index.js +314 -1
- package/dist/index.js.map +1 -1
- package/dist/{useDates-CpcW1GpF.mjs → useDates-CjPuu-VA.js} +2 -2
- package/dist/{useDates-CCrn42eQ.js.map → useDates-CjPuu-VA.js.map} +1 -1
- package/dist/useDates-c17u4Qfs.cjs +2 -0
- package/dist/{useDates-CpcW1GpF.mjs.map → useDates-c17u4Qfs.cjs.map} +1 -1
- package/dist/useDates.cjs +1 -0
- package/dist/useDates.js +3 -1
- package/dist/utils.cjs +2 -0
- package/dist/{utils.mjs.map → utils.cjs.map} +1 -1
- package/dist/utils.js +168 -1
- package/dist/utils.js.map +1 -1
- package/package.json +31 -12
- package/dist/index.mjs +0 -323
- package/dist/index.mjs.map +0 -1
- package/dist/useDates-CCrn42eQ.js +0 -2
- package/dist/useDates.mjs +0 -3
- package/dist/utils.mjs +0 -169
package/dist/index.mjs
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./useDates-CpcW1GpF.mjs";
|
|
2
|
-
import { addMonth as r, composeEventHandlers as i, getCalendars as a, isBackDisabled as o, isForwardDisabled as s, subtractMonth as c } from "./utils.mjs";
|
|
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 mb-3",
|
|
128
|
-
calendarsContainer: "flex flex-col md:flex-row gap-4",
|
|
129
|
-
calendarContainer: "flex-1 min-w-[280px] min-h-[260px]",
|
|
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 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-4 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: _.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
|
-
|
|
323
|
-
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","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":";;;;;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,gBA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AAS,KAClB,kBAAC,UAAD;QACE,MAAK;QACL,cAAY,EAAW,EAAS;QAChC,WAAU;QAHZ,UAAA;SAKG,EAAW,EAAS;SAAO;SAAE,EAAU,EAAE,CAAC,SAAS,EAAU,EAAU,SAAS,EAAE,CAAC,OAAuB,KAAhB,EAAS;QAC9F;;OAEV,kBAAC,OAAD;QAAK,WAAW,EAAW;QACxB,UAAA,EAAe,KAAK,MACnB,kBAAC,OAAD;SAAe,WAAW,EAAW;SAAU,UAAA;QAAS,GAA9C,CAA8C,CACzD;OACE,CAAA;OACL,kBAAC,OAAD;QAAK,WAAW,GAAG,EAAW,SAAS,GAAG,MAAmB,SAAS,0BAA0B,MAAmB,UAAU,2BAA2B;QACrJ,UAAA,EAAS,MAAM,KAAK,GAAM,MACzB,EAAK,KAAK,GAAS,MACjB,kBAAC,GAAD;SAEW;SACK;SACF;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,2 +0,0 @@
|
|
|
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.js");let l=require("react"),u=require("dayjs");u=s(u);let d=require("dayjs/plugin/isBetween");d=s(d);let f=require("dayjs/plugin/customParseFormat");f=s(f);let p=require("dayjs/plugin/localeData");p=s(p),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-CCrn42eQ.js.map
|
package/dist/useDates.mjs
DELETED
package/dist/utils.mjs
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
//#region src/utils.ts
|
|
2
|
-
function e(...e) {
|
|
3
|
-
return (t, ...n) => e.some((e) => (e && e(t, ...n), t && t.defaultPrevented));
|
|
4
|
-
}
|
|
5
|
-
function t({ calendars: e, offset: t, minDate: n, adapter: r }) {
|
|
6
|
-
let i = e[0].firstDayOfMonth, a = r.subtract(r.date(i), t, "month");
|
|
7
|
-
return n && r.isBefore(a, r.startOf(r.date(n), "month")) ? r.diff(r.startOf(r.date(i), "month"), r.startOf(r.date(n), "month"), "month") : t;
|
|
8
|
-
}
|
|
9
|
-
function n({ calendars: e, offset: t, maxDate: n, adapter: r }) {
|
|
10
|
-
let i = e[e.length - 1].firstDayOfMonth, a = r.add(r.date(i), t, "month");
|
|
11
|
-
return n && r.isAfter(a, r.startOf(r.date(n), "month")) ? r.diff(r.startOf(r.date(n), "month"), r.startOf(r.date(i), "month"), "month") : t;
|
|
12
|
-
}
|
|
13
|
-
function r({ date: e, selected: t, disabledDates: n, modifiers: r, monthsToDisplay: a, minDate: o, maxDate: s, offset: c, firstDayOfWeek: l, showOutsideDays: u, adapter: d, selectionMode: f, hoveredDate: p }) {
|
|
14
|
-
let m = [], h = d.add(d.startOf(d.date(e), "month"), c, "month");
|
|
15
|
-
for (let e = 0; e < a; e++) {
|
|
16
|
-
let a = d.add(h, e, "month");
|
|
17
|
-
m.push(i({
|
|
18
|
-
month: d.get(a, "month"),
|
|
19
|
-
year: d.get(a, "year"),
|
|
20
|
-
selectedDates: t,
|
|
21
|
-
disabledDates: n,
|
|
22
|
-
modifiers: r,
|
|
23
|
-
minDate: o,
|
|
24
|
-
maxDate: s,
|
|
25
|
-
firstDayOfWeek: l,
|
|
26
|
-
showOutsideDays: u,
|
|
27
|
-
adapter: d,
|
|
28
|
-
selectionMode: f,
|
|
29
|
-
hoveredDate: p
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
return m;
|
|
33
|
-
}
|
|
34
|
-
function i({ month: e, year: t, selectedDates: n, disabledDates: r, modifiers: i, minDate: l, maxDate: u, firstDayOfWeek: d, showOutsideDays: f, adapter: p, selectionMode: m, hoveredDate: h }) {
|
|
35
|
-
let g = p.set(p.set(p.date(), "year", t), "month", e);
|
|
36
|
-
e = p.get(g, "month"), t = p.get(g, "year");
|
|
37
|
-
let _ = p.getDaysInMonth(g), v = [];
|
|
38
|
-
for (let o = 1; o <= _; o++) {
|
|
39
|
-
let s = a(p.toDate(p.set(g, "day", o)), n, r, i, l, u, p, m, !1, h, e, t);
|
|
40
|
-
v.push(s);
|
|
41
|
-
}
|
|
42
|
-
let y = p.toDate(p.startOf(g, "month")), b = p.toDate(p.endOf(g, "month")), x = o({
|
|
43
|
-
firstDayOfMonth: y,
|
|
44
|
-
minDate: l,
|
|
45
|
-
maxDate: u,
|
|
46
|
-
selectedDates: n,
|
|
47
|
-
disabledDates: r,
|
|
48
|
-
modifiers: i,
|
|
49
|
-
firstDayOfWeek: d,
|
|
50
|
-
showOutsideDays: f,
|
|
51
|
-
adapter: p,
|
|
52
|
-
selectionMode: m,
|
|
53
|
-
hoveredDate: h,
|
|
54
|
-
month: e,
|
|
55
|
-
year: t
|
|
56
|
-
}), S = s({
|
|
57
|
-
lastDayOfMonth: b,
|
|
58
|
-
minDate: l,
|
|
59
|
-
maxDate: u,
|
|
60
|
-
selectedDates: n,
|
|
61
|
-
disabledDates: r,
|
|
62
|
-
modifiers: i,
|
|
63
|
-
firstDayOfWeek: d,
|
|
64
|
-
showOutsideDays: f,
|
|
65
|
-
adapter: p,
|
|
66
|
-
selectionMode: m,
|
|
67
|
-
hoveredDate: h,
|
|
68
|
-
month: e,
|
|
69
|
-
year: t
|
|
70
|
-
});
|
|
71
|
-
v.unshift(...x), v.push(...S);
|
|
72
|
-
let C = c(v);
|
|
73
|
-
return {
|
|
74
|
-
firstDayOfMonth: y,
|
|
75
|
-
lastDayOfMonth: b,
|
|
76
|
-
month: e,
|
|
77
|
-
year: t,
|
|
78
|
-
weeks: C
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function a(e, t, n, r, i, a, o, s, c = !1, d, f, p) {
|
|
82
|
-
let { selected: m, isRangeStart: h, isRangeEnd: g, isRangeBetween: _, isRangeHovering: v, isRangeActive: y } = l(t, e, o, s, d), b = o.isSame(o.date(e), o.date(), "day"), x = c && o.isBefore(o.date(e), o.startOf(o.date(e), "month")), S = c && o.isAfter(o.date(e), o.endOf(o.date(e), "month")), C = {
|
|
83
|
-
"text-brand-gold border border-brand-gold": (e) => o.isSame(o.date(e), o.date(), "day"),
|
|
84
|
-
"text-gray-400 opacity-50": (e, t) => o.get(o.date(e), "month") !== t,
|
|
85
|
-
...r
|
|
86
|
-
}, w = Object.keys(C).filter((t) => C[t](e, f ?? o.get(o.date(e), "month"), p ?? o.get(o.date(e), "year")));
|
|
87
|
-
return b && w.push("today"), c && w.push("outside"), x && w.push("prev-month"), S && w.push("next-month"), {
|
|
88
|
-
date: e,
|
|
89
|
-
selected: m,
|
|
90
|
-
modifiers: w,
|
|
91
|
-
selectable: u(i, a, n, e, o),
|
|
92
|
-
today: b,
|
|
93
|
-
prevMonth: x,
|
|
94
|
-
nextMonth: S,
|
|
95
|
-
isRangeStart: h,
|
|
96
|
-
isRangeEnd: g,
|
|
97
|
-
isRangeBetween: _,
|
|
98
|
-
isRangeHovering: v,
|
|
99
|
-
isRangeActive: y
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
function o({ firstDayOfMonth: e, minDate: t, maxDate: n, selectedDates: r, disabledDates: i, modifiers: o, firstDayOfWeek: s, showOutsideDays: c, adapter: l, selectionMode: u, hoveredDate: d, month: f, year: p }) {
|
|
103
|
-
let m = [], h = (l.toDate(l.date(e)).getDay() + 7 - s) % 7, g = l.subtract(l.date(e), 1, "day");
|
|
104
|
-
for (let e = 0; e < h; e++) {
|
|
105
|
-
let e = a(l.toDate(g), r, i, o, t, n, l, u, !0, d, f, p);
|
|
106
|
-
e.prevMonth = !0, c || (e.selectable = !1), m.unshift(e), g = l.subtract(g, 1, "day");
|
|
107
|
-
}
|
|
108
|
-
return m;
|
|
109
|
-
}
|
|
110
|
-
function s({ lastDayOfMonth: e, minDate: t, maxDate: n, selectedDates: r, disabledDates: i, modifiers: o, firstDayOfWeek: s, showOutsideDays: c, adapter: l, selectionMode: u, hoveredDate: d, month: f, year: p }) {
|
|
111
|
-
let m = [], h = (l.toDate(l.date(e)).getDay() + 7 - s) % 7, g = l.add(l.date(e), 1, "day");
|
|
112
|
-
for (let e = 0; e < 6 - h; e++) {
|
|
113
|
-
let e = a(l.toDate(g), r, i, o, t, n, l, u, !0, d, f, p);
|
|
114
|
-
e.nextMonth = !0, c || (e.selectable = !1), m.push(e), g = l.add(g, 1, "day");
|
|
115
|
-
}
|
|
116
|
-
return m;
|
|
117
|
-
}
|
|
118
|
-
function c(e) {
|
|
119
|
-
let t = Math.ceil(e.length / 7), n = [];
|
|
120
|
-
for (let r = 0; r < t; r++) {
|
|
121
|
-
n[r] = [];
|
|
122
|
-
for (let t = 0; t < 7; t++) n[r].push(e[r * 7 + t]);
|
|
123
|
-
}
|
|
124
|
-
return n;
|
|
125
|
-
}
|
|
126
|
-
function l(e, t, n, r, i) {
|
|
127
|
-
if (!e && !i) return { selected: !1 };
|
|
128
|
-
let a = n.date(t);
|
|
129
|
-
if (r === "single" && e instanceof Date) return { selected: n.isSame(a, n.date(e), "day") };
|
|
130
|
-
if (r === "multiple" && Array.isArray(e)) return { selected: e.some((e) => n.isSame(a, n.date(e), "day")) };
|
|
131
|
-
if (r === "range") {
|
|
132
|
-
let { start: t, end: r } = e && typeof e == "object" && !(e instanceof Date) && !Array.isArray(e) ? e : {
|
|
133
|
-
start: void 0,
|
|
134
|
-
end: void 0
|
|
135
|
-
}, o = t ? n.isSame(a, n.date(t), "day") : !1, s = r ? n.isSame(a, n.date(r), "day") : !1, c = t && r ? n.isAfter(a, n.date(t), "day") && n.isBefore(a, n.date(r), "day") : !1, l = !1;
|
|
136
|
-
if (t && !r && i) {
|
|
137
|
-
let e = n.date(i), r = n.date(t);
|
|
138
|
-
n.isAfter(e, r, "day") ? (l = n.isAfter(a, r, "day") && n.isBefore(a, e, "day") || n.isSame(a, e, "day"), n.isSame(a, e, "day") && (s = !0)) : n.isBefore(e, r, "day") && (l = n.isAfter(a, e, "day") && n.isBefore(a, r, "day") || n.isSame(a, e, "day"), n.isSame(a, e, "day") && (o = !0), n.isSame(a, r, "day") && (o = !1, s = !0));
|
|
139
|
-
}
|
|
140
|
-
let u = !!(t && r && !n.isSame(n.date(t), n.date(r), "day") || t && !r && i && !n.isSame(n.date(t), n.date(i), "day"));
|
|
141
|
-
return {
|
|
142
|
-
selected: o || s || c,
|
|
143
|
-
isRangeStart: o,
|
|
144
|
-
isRangeEnd: s,
|
|
145
|
-
isRangeBetween: c,
|
|
146
|
-
isRangeHovering: l,
|
|
147
|
-
isRangeActive: u
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
return Array.isArray(e) && e.length === 1 && r === "single" ? { selected: n.isSame(a, n.date(e[0]), "day") } : { selected: !1 };
|
|
151
|
-
}
|
|
152
|
-
function u(e, t, n, r, i) {
|
|
153
|
-
let a = i.date(r), o = e && i.isBefore(a, i.date(e), "day"), s = t && i.isAfter(a, i.date(t), "day"), c = n?.some((e) => i.isSame(a, i.date(e), "day"));
|
|
154
|
-
return !o && !s && !c;
|
|
155
|
-
}
|
|
156
|
-
function d({ calendars: e, minDate: t, adapter: n }) {
|
|
157
|
-
if (!t) return !1;
|
|
158
|
-
let r = e[0].firstDayOfMonth;
|
|
159
|
-
return n.isSame(n.startOf(n.date(r), "month"), n.startOf(n.date(t), "month"), "month") || n.isBefore(n.date(r), n.date(t), "month");
|
|
160
|
-
}
|
|
161
|
-
function f({ calendars: e, maxDate: t, adapter: n }) {
|
|
162
|
-
if (!t) return !1;
|
|
163
|
-
let r = e[e.length - 1].firstDayOfMonth;
|
|
164
|
-
return n.isSame(n.startOf(n.date(r), "month"), n.startOf(n.date(t), "month"), "month") || n.isAfter(n.date(r), n.date(t), "month");
|
|
165
|
-
}
|
|
166
|
-
//#endregion
|
|
167
|
-
export { n as addMonth, e as composeEventHandlers, r as getCalendars, d as isBackDisabled, f as isForwardDisabled, t as subtractMonth };
|
|
168
|
-
|
|
169
|
-
//# sourceMappingURL=utils.mjs.map
|