react-modular-datepicker 0.0.7 → 0.0.9
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 +2 -2
- package/dist/classNames.d.ts +6 -33
- package/dist/components/Calendar.d.ts +2 -2
- package/dist/components/CalendarHeader.d.ts +3 -5
- package/dist/components/Day.d.ts +8 -2
- package/dist/components/MonthSelection.d.ts +1 -1
- package/dist/components/YearSelection.d.ts +1 -1
- package/dist/i18n.d.ts +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +2 -453
- package/dist/index.js +432 -224
- package/dist/index.js.map +1 -1
- package/dist/{useDates-CjPuu-VA.js → useDates-BVAPuyDo.js} +46 -44
- package/dist/useDates-BVAPuyDo.js.map +1 -0
- package/dist/{useDates-c17u4Qfs.cjs → useDates-DqKgwgF7.cjs} +2 -2
- package/dist/useDates-DqKgwgF7.cjs.map +1 -0
- package/dist/useDates.cjs +1 -1
- package/dist/useDates.d.ts +2 -3
- package/dist/useDates.js +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +2 -3
- package/dist/utils.js +53 -49
- package/dist/utils.js.map +1 -1
- package/package.json +10 -8
- package/dist/useDates-CjPuu-VA.js.map +0 -1
- package/dist/useDates-c17u4Qfs.cjs.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,45 +1,44 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./useDates-
|
|
1
|
+
import { n as e, r as t, t as n } from "./useDates-BVAPuyDo.js";
|
|
2
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,
|
|
4
|
-
import { jsx as
|
|
5
|
-
//#region
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
children: i.getDate()
|
|
22
|
-
});
|
|
23
|
-
};
|
|
3
|
+
import { useEffect as l, useMemo as u, useRef as d, useState as f } from "react";
|
|
4
|
+
import { jsx as p, jsxs as m } from "react/jsx-runtime";
|
|
5
|
+
//#region ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
6
|
+
function h(e) {
|
|
7
|
+
var t, n, r = "";
|
|
8
|
+
if (typeof e == "string" || typeof e == "number") r += e;
|
|
9
|
+
else if (typeof e == "object") {
|
|
10
|
+
if (Array.isArray(e)) {
|
|
11
|
+
var i = e.length;
|
|
12
|
+
for (t = 0; t < i; t++) e[t] && (n = h(e[t])) && (r && (r += " "), r += n);
|
|
13
|
+
} else for (n in e) e[n] && (r && (r += " "), r += n);
|
|
14
|
+
}
|
|
15
|
+
return r;
|
|
16
|
+
}
|
|
17
|
+
function g() {
|
|
18
|
+
for (var e, t, n = 0, r = "", i = arguments.length; n < i; n++) (e = arguments[n]) && (t = h(e)) && (r && (r += " "), r += t);
|
|
19
|
+
return r;
|
|
20
|
+
}
|
|
24
21
|
//#endregion
|
|
25
22
|
//#region src/i18n.ts
|
|
26
|
-
function
|
|
23
|
+
function _(e = t, n) {
|
|
27
24
|
return {
|
|
28
25
|
months: e.getMonths(n),
|
|
29
26
|
weekdays: e.getWeekdays(n),
|
|
30
27
|
back: "Previous month",
|
|
31
|
-
forward: "Next month"
|
|
28
|
+
forward: "Next month",
|
|
29
|
+
selectMonth: "Select month",
|
|
30
|
+
selectYear: "Select year"
|
|
32
31
|
};
|
|
33
32
|
}
|
|
34
|
-
function
|
|
33
|
+
function v(e = t, n, r) {
|
|
35
34
|
return {
|
|
36
|
-
...
|
|
35
|
+
..._(e, n),
|
|
37
36
|
...r
|
|
38
37
|
};
|
|
39
38
|
}
|
|
40
39
|
//#endregion
|
|
41
40
|
//#region src/components/CalendarHeader.tsx
|
|
42
|
-
var
|
|
41
|
+
var y = () => /* @__PURE__ */ p("svg", {
|
|
43
42
|
width: "20",
|
|
44
43
|
height: "20",
|
|
45
44
|
viewBox: "0 0 24 24",
|
|
@@ -48,8 +47,8 @@ var _ = () => /* @__PURE__ */ f("svg", {
|
|
|
48
47
|
strokeWidth: "2",
|
|
49
48
|
strokeLinecap: "round",
|
|
50
49
|
strokeLinejoin: "round",
|
|
51
|
-
children: /* @__PURE__ */
|
|
52
|
-
}),
|
|
50
|
+
children: /* @__PURE__ */ p("polyline", { points: "15 18 9 12 15 6" })
|
|
51
|
+
}), b = () => /* @__PURE__ */ p("svg", {
|
|
53
52
|
width: "20",
|
|
54
53
|
height: "20",
|
|
55
54
|
viewBox: "0 0 24 24",
|
|
@@ -58,258 +57,467 @@ var _ = () => /* @__PURE__ */ f("svg", {
|
|
|
58
57
|
strokeWidth: "2",
|
|
59
58
|
strokeLinecap: "round",
|
|
60
59
|
strokeLinejoin: "round",
|
|
61
|
-
children: /* @__PURE__ */
|
|
62
|
-
}),
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
className:
|
|
76
|
-
children:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
" - ",
|
|
102
|
-
i[n.month],
|
|
103
|
-
" ",
|
|
104
|
-
n.year
|
|
105
|
-
] });
|
|
106
|
-
})()
|
|
60
|
+
children: /* @__PURE__ */ p("polyline", { points: "9 18 15 12 9 6" })
|
|
61
|
+
}), x = ({ calendars: e, getBackProps: t, getForwardProps: n, setView: r, monthNames: i, t: a, classNames: o, slideDirection: s, currentView: c }) => {
|
|
62
|
+
if (e.length > 1 && e.length < 12) return null;
|
|
63
|
+
let l = e[0], u = e[e.length - 1], d = !!(c && c !== "days"), f = g("rmd-nav-button", d && "rmd-nav-button-hidden", o?.navButton, d && o?.navButtonHidden), h = g("rmd-month-year-label", s === "left" && "rmd-slide-left", s === "right" && "rmd-slide-right", o?.monthYearLabel);
|
|
64
|
+
return /* @__PURE__ */ m("div", {
|
|
65
|
+
className: g("rmd-header", e.length > 1 && "rmd-header-multi-month", o?.header, e.length > 1 && o?.headerMultiMonth),
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ p("button", {
|
|
68
|
+
...t({ calendars: e }),
|
|
69
|
+
className: f,
|
|
70
|
+
"aria-label": a.back,
|
|
71
|
+
children: /* @__PURE__ */ p(y, {})
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ p("div", {
|
|
74
|
+
className: g("rmd-month-year-container", o?.monthYearContainer),
|
|
75
|
+
children: e.length === 1 ? /* @__PURE__ */ m("div", {
|
|
76
|
+
className: h,
|
|
77
|
+
children: [/* @__PURE__ */ p("button", {
|
|
78
|
+
onClick: () => r(c === "months" ? "days" : "months"),
|
|
79
|
+
className: g("rmd-month-year-button", o?.monthYearButton),
|
|
80
|
+
"aria-label": `${i[e[0].month]}, ${a.selectMonth || "Select month"}`,
|
|
81
|
+
"aria-expanded": c === "months",
|
|
82
|
+
children: i[e[0].month]
|
|
83
|
+
}), /* @__PURE__ */ p("button", {
|
|
84
|
+
onClick: () => r(c === "years" ? "days" : "years"),
|
|
85
|
+
className: g("rmd-month-year-button", o?.monthYearButton),
|
|
86
|
+
"aria-label": `${e[0].year}, ${a.selectYear || "Select year"}`,
|
|
87
|
+
"aria-expanded": c === "years",
|
|
88
|
+
children: e[0].year
|
|
89
|
+
})]
|
|
90
|
+
}, `${e[0].month}-${e[0].year}`) : /* @__PURE__ */ p("div", {
|
|
91
|
+
className: h,
|
|
92
|
+
children: /* @__PURE__ */ p("span", { children: l.year === u.year ? l.year : `${l.year} - ${u.year}` })
|
|
93
|
+
})
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ p("button", {
|
|
96
|
+
...n({ calendars: e }),
|
|
97
|
+
className: f,
|
|
98
|
+
"aria-label": a.forward,
|
|
99
|
+
children: /* @__PURE__ */ p(b, {})
|
|
107
100
|
})
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
101
|
+
]
|
|
102
|
+
});
|
|
103
|
+
}, S = ({ dateObj: e, getDateProps: t, dayProps: n, classNames: r, tabIndex: i = -1, adapter: a, locale: o, onKeyDown: s, onFocus: c, buttonRef: l }) => {
|
|
104
|
+
if (!e) return /* @__PURE__ */ p("div", {
|
|
105
|
+
role: "gridcell",
|
|
106
|
+
"aria-hidden": "true",
|
|
107
|
+
className: g("rmd-day-empty", r?.day?.empty)
|
|
108
|
+
});
|
|
109
|
+
let { date: u, selected: d, selectable: f, isRangeStart: m, isRangeEnd: h, isRangeBetween: _, isRangeHovering: v, isRangeActive: y } = e, b = r?.day, x = "", S = "";
|
|
110
|
+
m && h ? (x = "rmd-day-selected", S = b?.selected || "") : m ? (x = g("rmd-day-range-start", y && "rmd-day-range-active"), S = b?.rangeStart || "") : h ? (x = g("rmd-day-range-end", y && "rmd-day-range-active"), S = b?.rangeEnd || "") : _ ? (x = "rmd-day-range-between", S = b?.rangeBetween || "") : v ? (x = "rmd-day-range-hovering", S = b?.rangeHovering || "") : d ? (x = "rmd-day-selected", S = b?.selected || "") : f ? (x = "rmd-day-unselected", S = b?.unselected || "") : (x = "rmd-day-disabled", S = b?.disabled || "");
|
|
111
|
+
let C = (e.modifiers || []).map((e) => b?.[e] || e).filter(Boolean), w = a ? a.format(a.date(u), "dddd, MMMM D, YYYY", o) : u.toDateString(), T = !!(d || m || h), E = t({
|
|
112
|
+
dateObj: e,
|
|
113
|
+
...n
|
|
114
|
+
});
|
|
115
|
+
return /* @__PURE__ */ p("button", {
|
|
116
|
+
role: "gridcell",
|
|
117
|
+
"aria-selected": T,
|
|
118
|
+
"aria-disabled": !f,
|
|
119
|
+
"aria-label": w,
|
|
120
|
+
tabIndex: i,
|
|
121
|
+
...E,
|
|
122
|
+
ref: l,
|
|
123
|
+
onKeyDown: (t) => {
|
|
124
|
+
E.onKeyDown?.(t), s?.(t, e);
|
|
125
|
+
},
|
|
126
|
+
onFocus: (t) => {
|
|
127
|
+
E.onFocus?.(t), c?.(e);
|
|
128
|
+
},
|
|
129
|
+
className: g("rmd-day", b?.day, x, S, C),
|
|
130
|
+
children: u.getDate()
|
|
131
|
+
});
|
|
132
|
+
}, C = ({ year: e, month: t, monthNames: n, minDate: r, maxDate: i, onMonthSelect: a, classNames: o }) => {
|
|
133
|
+
let [s, c] = f(t), u = d([]);
|
|
134
|
+
l(() => {
|
|
135
|
+
u.current[s]?.focus();
|
|
136
|
+
}, [s]);
|
|
137
|
+
let m = (t) => !!(r && e === r.getFullYear() && t < r.getMonth() || i && e === i.getFullYear() && t > i.getMonth()), h = (e, t) => {
|
|
138
|
+
let n = s;
|
|
139
|
+
switch (e.key) {
|
|
140
|
+
case "ArrowLeft":
|
|
141
|
+
e.preventDefault(), n = (t - 1 + 12) % 12;
|
|
142
|
+
break;
|
|
143
|
+
case "ArrowRight":
|
|
144
|
+
e.preventDefault(), n = (t + 1) % 12;
|
|
145
|
+
break;
|
|
146
|
+
case "ArrowUp":
|
|
147
|
+
e.preventDefault(), n = (t - 3 + 12) % 12;
|
|
148
|
+
break;
|
|
149
|
+
case "ArrowDown":
|
|
150
|
+
e.preventDefault(), n = (t + 3) % 12;
|
|
151
|
+
break;
|
|
152
|
+
case "Home":
|
|
153
|
+
e.preventDefault(), n = 0;
|
|
154
|
+
break;
|
|
155
|
+
case "End":
|
|
156
|
+
e.preventDefault(), n = 11;
|
|
157
|
+
break;
|
|
158
|
+
case "Enter":
|
|
159
|
+
case " ":
|
|
160
|
+
e.preventDefault(), m(t) || a(t);
|
|
161
|
+
return;
|
|
162
|
+
default: return;
|
|
163
|
+
}
|
|
164
|
+
c(n);
|
|
165
|
+
}, _ = g("rmd-months-grid", o?.monthsGrid);
|
|
166
|
+
return /* @__PURE__ */ p("div", {
|
|
167
|
+
role: "grid",
|
|
168
|
+
"aria-label": "Select month",
|
|
169
|
+
className: _,
|
|
163
170
|
children: n.map((e, n) => {
|
|
164
|
-
let r =
|
|
165
|
-
return /* @__PURE__ */
|
|
166
|
-
|
|
171
|
+
let r = m(n), i = n === t, l = n === s, d = g("rmd-month-button", i ? "rmd-month-button-selected" : "rmd-month-button-unselected", o?.monthButton, i ? o?.monthButtonSelected : o?.monthButtonUnselected);
|
|
172
|
+
return /* @__PURE__ */ p("button", {
|
|
173
|
+
ref: (e) => {
|
|
174
|
+
u.current[n] = e;
|
|
175
|
+
},
|
|
176
|
+
role: "gridcell",
|
|
177
|
+
"aria-selected": i,
|
|
178
|
+
"aria-disabled": r,
|
|
179
|
+
tabIndex: l ? 0 : -1,
|
|
167
180
|
onClick: () => !r && a(n),
|
|
168
|
-
|
|
181
|
+
onKeyDown: (e) => h(e, n),
|
|
182
|
+
onFocus: () => c(n),
|
|
183
|
+
className: d,
|
|
169
184
|
disabled: r,
|
|
170
185
|
children: e
|
|
171
186
|
}, e);
|
|
172
187
|
})
|
|
173
188
|
});
|
|
174
|
-
},
|
|
175
|
-
let o =
|
|
189
|
+
}, w = ({ year: e, minDate: t, maxDate: n, adapter: r, onYearSelect: i, classNames: a }) => {
|
|
190
|
+
let o = d(null), [s, c] = f(e), u = d(/* @__PURE__ */ new Map()), m = t ? r.get(r.date(t), "year") : e - 50, h = n ? r.get(r.date(n), "year") : e + 50, _ = [];
|
|
191
|
+
for (let e = m; e <= h; e++) _.push(e);
|
|
176
192
|
l(() => {
|
|
177
193
|
if (o.current) {
|
|
178
|
-
let e = o.current.querySelector("[data-selected=\"true\"]");
|
|
179
|
-
|
|
194
|
+
let e = o.current, t = e.querySelector("[data-selected=\"true\"]");
|
|
195
|
+
if (t) {
|
|
196
|
+
let n = t.offsetTop - e.clientHeight / 2 + t.clientHeight / 2;
|
|
197
|
+
e.scrollTop = Math.max(0, n);
|
|
198
|
+
}
|
|
180
199
|
}
|
|
181
|
-
}, [])
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
200
|
+
}, []), l(() => {
|
|
201
|
+
let e = u.current.get(s);
|
|
202
|
+
e && e.focus();
|
|
203
|
+
}, [s]);
|
|
204
|
+
let v = (e, t) => {
|
|
205
|
+
let n = s;
|
|
206
|
+
switch (e.key) {
|
|
207
|
+
case "ArrowLeft":
|
|
208
|
+
e.preventDefault(), n = Math.max(m, t - 1);
|
|
209
|
+
break;
|
|
210
|
+
case "ArrowRight":
|
|
211
|
+
e.preventDefault(), n = Math.min(h, t + 1);
|
|
212
|
+
break;
|
|
213
|
+
case "ArrowUp":
|
|
214
|
+
e.preventDefault(), n = Math.max(m, t - 3);
|
|
215
|
+
break;
|
|
216
|
+
case "ArrowDown":
|
|
217
|
+
e.preventDefault(), n = Math.min(h, t + 3);
|
|
218
|
+
break;
|
|
219
|
+
case "PageUp":
|
|
220
|
+
e.preventDefault(), n = Math.max(m, t - 10);
|
|
221
|
+
break;
|
|
222
|
+
case "PageDown":
|
|
223
|
+
e.preventDefault(), n = Math.min(h, t + 10);
|
|
224
|
+
break;
|
|
225
|
+
case "Home":
|
|
226
|
+
e.preventDefault(), n = m;
|
|
227
|
+
break;
|
|
228
|
+
case "End":
|
|
229
|
+
e.preventDefault(), n = h;
|
|
230
|
+
break;
|
|
231
|
+
case "Enter":
|
|
232
|
+
case " ":
|
|
233
|
+
e.preventDefault(), i(t);
|
|
234
|
+
return;
|
|
235
|
+
default: return;
|
|
236
|
+
}
|
|
237
|
+
c(n);
|
|
238
|
+
};
|
|
239
|
+
return /* @__PURE__ */ p("div", {
|
|
185
240
|
ref: o,
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
241
|
+
role: "grid",
|
|
242
|
+
"aria-label": "Select year",
|
|
243
|
+
className: g("rmd-years-grid", a?.yearsGrid),
|
|
244
|
+
children: _.map((t) => {
|
|
245
|
+
let n = t === e, r = t === s, o = g("rmd-year-button", n ? "rmd-year-button-selected" : "rmd-year-button-unselected", a?.yearButton, n ? a?.yearButtonSelected : a?.yearButtonUnselected);
|
|
246
|
+
return /* @__PURE__ */ p("button", {
|
|
247
|
+
ref: (e) => {
|
|
248
|
+
e ? u.current.set(t, e) : u.current.delete(t);
|
|
249
|
+
},
|
|
250
|
+
"data-selected": n,
|
|
251
|
+
role: "gridcell",
|
|
252
|
+
"aria-selected": n,
|
|
253
|
+
tabIndex: r ? 0 : -1,
|
|
254
|
+
onClick: () => i(t),
|
|
255
|
+
onKeyDown: (e) => v(e, t),
|
|
256
|
+
onFocus: () => c(t),
|
|
257
|
+
className: o,
|
|
258
|
+
children: t
|
|
259
|
+
}, t);
|
|
260
|
+
})
|
|
194
261
|
});
|
|
195
|
-
},
|
|
196
|
-
let { classNames: r, locale: i, translations: a, adapter: o = t, firstDayOfWeek: s = 0, header: c, footer:
|
|
197
|
-
...
|
|
262
|
+
}, T = (e) => `${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`, E = (e) => {
|
|
263
|
+
let { classNames: r, locale: i, translations: a, adapter: o = t, firstDayOfWeek: s = 0, header: c, footer: h, getDayProps: _, ...E } = e, [D, O] = f("days"), [k, A] = f(null), [j, M] = f(null), [N, P] = f(null), [F, I] = f(""), L = d(null), R = d(null), z = d(/* @__PURE__ */ new Map()), B = d(!1), V = v(o, i, a), H = V.weekdays, U = V.months, { calendars: W, getBackProps: G, getForwardProps: ee, getDateProps: K, setOffset: q } = n({
|
|
264
|
+
...E,
|
|
198
265
|
adapter: o,
|
|
199
266
|
firstDayOfWeek: s
|
|
200
|
-
})
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
267
|
+
});
|
|
268
|
+
l(() => {
|
|
269
|
+
if (D === "days" && L.current) {
|
|
270
|
+
let e = L.current, t = () => {
|
|
271
|
+
e.offsetHeight > 0 && M(e.offsetHeight);
|
|
272
|
+
};
|
|
273
|
+
if (t(), typeof ResizeObserver < "u") {
|
|
274
|
+
let n = new ResizeObserver(() => {
|
|
275
|
+
t();
|
|
276
|
+
});
|
|
277
|
+
return n.observe(e), () => n.disconnect();
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}, [D, W]), l(() => {
|
|
281
|
+
D === "days" && W.length > 0 ? W.length === 1 ? I(`${U[W[0].month]} ${W[0].year}`) : I(`${U[W[0].month]} ${W[0].year} to ${U[W[W.length - 1].month]} ${W[W.length - 1].year}`) : D === "months" ? I("Month selection view") : D === "years" && I("Year selection view");
|
|
282
|
+
}, [
|
|
283
|
+
D,
|
|
284
|
+
W,
|
|
285
|
+
U
|
|
286
|
+
]);
|
|
287
|
+
let te = u(() => {
|
|
288
|
+
for (let e of W) for (let t of e.weeks) for (let e of t) if (e?.selectable && e.selected) return e.date;
|
|
289
|
+
for (let e of W) for (let t of e.weeks) for (let e of t) if (e?.selectable && e.today) return e.date;
|
|
290
|
+
for (let e of W) for (let t of e.weeks) for (let e of t) if (e?.selectable && !e.prevMonth && !e.nextMonth) return e.date;
|
|
291
|
+
return W[0]?.weeks[0]?.find((e) => e?.selectable)?.date || /* @__PURE__ */ new Date();
|
|
292
|
+
}, [W]), J = N || te;
|
|
293
|
+
l(() => {
|
|
294
|
+
if (D === "days" && J && B.current) {
|
|
295
|
+
let e = T(J), t = z.current.get(e);
|
|
296
|
+
t && t.focus();
|
|
297
|
+
}
|
|
298
|
+
}, [
|
|
299
|
+
J,
|
|
300
|
+
W,
|
|
301
|
+
D
|
|
302
|
+
]);
|
|
303
|
+
let ne = [...H.slice(s), ...H.slice(0, s)], { month: Y, year: X } = W[0], re = (t) => {
|
|
304
|
+
let n = o.set(o.set(o.date(e.date || /* @__PURE__ */ new Date()), "year", X), "month", Y), r = o.set(n, "month", t), i = o.startOf(o.date(e.date || /* @__PURE__ */ new Date()), "month"), a = o.diff(r, i, "month");
|
|
305
|
+
A(null), q(a), O("days");
|
|
306
|
+
}, ie = (t) => {
|
|
307
|
+
let n = o.set(o.set(o.date(e.date || /* @__PURE__ */ new Date()), "year", X), "month", Y), r = o.set(n, "year", t), i = o.startOf(o.date(e.date || /* @__PURE__ */ new Date()), "month"), a = o.diff(r, i, "month");
|
|
308
|
+
A(null), q(a), O("days");
|
|
309
|
+
}, Z = E.monthsToDisplay || 1, Q = (e) => {
|
|
310
|
+
let t = G({
|
|
311
|
+
offset: Z,
|
|
312
|
+
...e
|
|
313
|
+
});
|
|
208
314
|
return {
|
|
209
315
|
...t,
|
|
210
316
|
onClick: (e) => {
|
|
211
|
-
|
|
317
|
+
A("left"), t.onClick?.(e);
|
|
212
318
|
}
|
|
213
319
|
};
|
|
214
|
-
},
|
|
215
|
-
let t =
|
|
320
|
+
}, $ = (e) => {
|
|
321
|
+
let t = ee({
|
|
322
|
+
offset: Z,
|
|
323
|
+
...e
|
|
324
|
+
});
|
|
216
325
|
return {
|
|
217
326
|
...t,
|
|
218
327
|
onClick: (e) => {
|
|
219
|
-
|
|
328
|
+
A("right"), t.onClick?.(e);
|
|
220
329
|
}
|
|
221
330
|
};
|
|
331
|
+
}, ae = (t, n) => {
|
|
332
|
+
let r = !!(R.current?.closest("[dir=\"rtl\"]") || typeof document < "u" && document.documentElement.dir === "rtl"), i = null, a = o.date(n.date);
|
|
333
|
+
switch (t.key) {
|
|
334
|
+
case "ArrowLeft":
|
|
335
|
+
t.preventDefault(), i = o.toDate(o.add(a, r ? 1 : -1, "day"));
|
|
336
|
+
break;
|
|
337
|
+
case "ArrowRight":
|
|
338
|
+
t.preventDefault(), i = o.toDate(o.add(a, r ? -1 : 1, "day"));
|
|
339
|
+
break;
|
|
340
|
+
case "ArrowUp":
|
|
341
|
+
t.preventDefault(), i = o.toDate(o.subtract(a, 7, "day"));
|
|
342
|
+
break;
|
|
343
|
+
case "ArrowDown":
|
|
344
|
+
t.preventDefault(), i = o.toDate(o.add(a, 7, "day"));
|
|
345
|
+
break;
|
|
346
|
+
case "Home": {
|
|
347
|
+
t.preventDefault();
|
|
348
|
+
let e = (o.toDate(a).getDay() - s + 7) % 7;
|
|
349
|
+
i = o.toDate(o.subtract(a, e, "day"));
|
|
350
|
+
break;
|
|
351
|
+
}
|
|
352
|
+
case "End": {
|
|
353
|
+
t.preventDefault();
|
|
354
|
+
let e = 6 - (o.toDate(a).getDay() - s + 7) % 7;
|
|
355
|
+
i = o.toDate(o.add(a, e, "day"));
|
|
356
|
+
break;
|
|
357
|
+
}
|
|
358
|
+
case "PageUp": {
|
|
359
|
+
t.preventDefault();
|
|
360
|
+
let e = t.shiftKey ? "year" : "month";
|
|
361
|
+
i = o.toDate(o.subtract(a, 1, e));
|
|
362
|
+
break;
|
|
363
|
+
}
|
|
364
|
+
case "PageDown": {
|
|
365
|
+
t.preventDefault();
|
|
366
|
+
let e = t.shiftKey ? "year" : "month";
|
|
367
|
+
i = o.toDate(o.add(a, 1, e));
|
|
368
|
+
break;
|
|
369
|
+
}
|
|
370
|
+
case "Enter":
|
|
371
|
+
case " ": return;
|
|
372
|
+
default: return;
|
|
373
|
+
}
|
|
374
|
+
if (i) {
|
|
375
|
+
B.current = !0, P(i);
|
|
376
|
+
let t = o.startOf(o.date(e.date || /* @__PURE__ */ new Date()), "month"), n = o.startOf(o.date(i), "month"), r = o.diff(n, t, "month");
|
|
377
|
+
q(r);
|
|
378
|
+
}
|
|
222
379
|
};
|
|
223
|
-
return /* @__PURE__ */
|
|
224
|
-
|
|
380
|
+
return /* @__PURE__ */ m("div", {
|
|
381
|
+
ref: R,
|
|
382
|
+
className: g("rmd", "rmd-root", r?.root),
|
|
225
383
|
children: [
|
|
384
|
+
/* @__PURE__ */ p("div", {
|
|
385
|
+
className: "rmd-sr-only",
|
|
386
|
+
"aria-live": "polite",
|
|
387
|
+
"aria-atomic": "true",
|
|
388
|
+
children: F
|
|
389
|
+
}),
|
|
226
390
|
typeof c == "function" ? c({
|
|
227
|
-
calendars:
|
|
228
|
-
getBackProps:
|
|
229
|
-
getForwardProps:
|
|
230
|
-
setView:
|
|
231
|
-
monthNames:
|
|
232
|
-
t:
|
|
233
|
-
slideDirection:
|
|
234
|
-
currentView:
|
|
235
|
-
}) : c || /* @__PURE__ */
|
|
236
|
-
calendars:
|
|
237
|
-
getBackProps:
|
|
238
|
-
getForwardProps:
|
|
239
|
-
setView:
|
|
240
|
-
monthNames:
|
|
241
|
-
t:
|
|
242
|
-
classNames:
|
|
243
|
-
slideDirection:
|
|
244
|
-
currentView:
|
|
391
|
+
calendars: W,
|
|
392
|
+
getBackProps: Q,
|
|
393
|
+
getForwardProps: $,
|
|
394
|
+
setView: O,
|
|
395
|
+
monthNames: U,
|
|
396
|
+
t: V,
|
|
397
|
+
slideDirection: k,
|
|
398
|
+
currentView: D
|
|
399
|
+
}) : c || /* @__PURE__ */ p(x, {
|
|
400
|
+
calendars: W,
|
|
401
|
+
getBackProps: Q,
|
|
402
|
+
getForwardProps: $,
|
|
403
|
+
setView: O,
|
|
404
|
+
monthNames: U,
|
|
405
|
+
t: V,
|
|
406
|
+
classNames: r,
|
|
407
|
+
slideDirection: k,
|
|
408
|
+
currentView: D
|
|
245
409
|
}),
|
|
246
|
-
/* @__PURE__ */
|
|
247
|
-
className:
|
|
410
|
+
/* @__PURE__ */ m("div", {
|
|
411
|
+
className: g("rmd-calendars-container", r?.calendarsContainer),
|
|
248
412
|
children: [
|
|
249
|
-
|
|
250
|
-
className:
|
|
251
|
-
|
|
413
|
+
D === "months" && W.map((t) => /* @__PURE__ */ p("div", {
|
|
414
|
+
className: g("rmd-calendar-container", r?.calendarContainer),
|
|
415
|
+
style: j ? { height: `${j}px` } : void 0,
|
|
416
|
+
children: /* @__PURE__ */ p(C, {
|
|
252
417
|
year: t.year,
|
|
253
418
|
month: t.month,
|
|
254
|
-
monthNames:
|
|
419
|
+
monthNames: U,
|
|
255
420
|
minDate: e.minDate,
|
|
256
421
|
maxDate: e.maxDate,
|
|
257
|
-
onMonthSelect:
|
|
258
|
-
classNames:
|
|
422
|
+
onMonthSelect: re,
|
|
423
|
+
classNames: r
|
|
259
424
|
})
|
|
260
425
|
}, `months-${t.year}`)),
|
|
261
|
-
|
|
262
|
-
className:
|
|
263
|
-
|
|
426
|
+
D === "years" && W.map((t) => /* @__PURE__ */ p("div", {
|
|
427
|
+
className: g("rmd-calendar-container", r?.calendarContainer),
|
|
428
|
+
style: j ? { height: `${j}px` } : void 0,
|
|
429
|
+
children: /* @__PURE__ */ p(w, {
|
|
264
430
|
year: t.year,
|
|
265
431
|
minDate: e.minDate,
|
|
266
432
|
maxDate: e.maxDate,
|
|
267
433
|
adapter: o,
|
|
268
|
-
onYearSelect:
|
|
269
|
-
classNames:
|
|
434
|
+
onYearSelect: ie,
|
|
435
|
+
classNames: r
|
|
270
436
|
})
|
|
271
437
|
}, `years-${t.year}`)),
|
|
272
|
-
|
|
273
|
-
|
|
438
|
+
D === "days" && W.map((e, t) => /* @__PURE__ */ m("div", {
|
|
439
|
+
ref: t === 0 ? L : void 0,
|
|
440
|
+
role: "grid",
|
|
441
|
+
"aria-label": `${U[e.month]} ${e.year}`,
|
|
442
|
+
className: g("rmd-calendar-container", r?.calendarContainer),
|
|
274
443
|
children: [
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
"aria-label": O[e.month],
|
|
278
|
-
className: "block w-full text-center font-semibold mb-2 text-brand-text",
|
|
444
|
+
W.length > 1 && /* @__PURE__ */ m("div", {
|
|
445
|
+
className: g("rmd-header", r?.header),
|
|
279
446
|
children: [
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
447
|
+
/* @__PURE__ */ p("div", {
|
|
448
|
+
className: g("rmd-nav-button-slot-start", r?.navButtonSlotStart),
|
|
449
|
+
children: t === 0 && W.length < 12 && /* @__PURE__ */ p("button", {
|
|
450
|
+
...Q({ calendars: W }),
|
|
451
|
+
className: g("rmd-nav-button", r?.navButton),
|
|
452
|
+
"aria-label": V.back,
|
|
453
|
+
children: /* @__PURE__ */ p(y, {})
|
|
454
|
+
})
|
|
455
|
+
}),
|
|
456
|
+
/* @__PURE__ */ m("span", {
|
|
457
|
+
className: g("rmd-header-title-container", r?.headerTitleContainer),
|
|
458
|
+
children: [U[e.month], W.length < 12 ? ` ${e.year}` : ""]
|
|
459
|
+
}),
|
|
460
|
+
/* @__PURE__ */ p("div", {
|
|
461
|
+
className: g("rmd-nav-button-slot-end", r?.navButtonSlotEnd),
|
|
462
|
+
children: t === W.length - 1 && W.length < 12 && /* @__PURE__ */ p("button", {
|
|
463
|
+
...$({ calendars: W }),
|
|
464
|
+
className: g("rmd-nav-button", r?.navButton),
|
|
465
|
+
"aria-label": V.forward,
|
|
466
|
+
children: /* @__PURE__ */ p(b, {})
|
|
467
|
+
})
|
|
468
|
+
})
|
|
283
469
|
]
|
|
284
470
|
}),
|
|
285
|
-
/* @__PURE__ */
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
471
|
+
/* @__PURE__ */ p("div", {
|
|
472
|
+
role: "row",
|
|
473
|
+
className: g("rmd-weekday-grid", r?.weekdayGrid),
|
|
474
|
+
children: ne.map((e) => /* @__PURE__ */ p("div", {
|
|
475
|
+
role: "columnheader",
|
|
476
|
+
"aria-label": e,
|
|
477
|
+
className: g("rmd-weekday", r?.weekday),
|
|
289
478
|
children: e
|
|
290
479
|
}, e))
|
|
291
480
|
}),
|
|
292
|
-
/* @__PURE__ */
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
481
|
+
/* @__PURE__ */ p("div", {
|
|
482
|
+
role: "row",
|
|
483
|
+
className: g("rmd-days-grid", k === "left" && "rmd-slide-left", k === "right" && "rmd-slide-right", r?.daysGrid),
|
|
484
|
+
children: e.weeks.map((e, t) => e.map((e, n) => {
|
|
485
|
+
if (!e) return /* @__PURE__ */ p(S, {
|
|
486
|
+
dateObj: null,
|
|
487
|
+
getDateProps: K,
|
|
488
|
+
classNames: r
|
|
489
|
+
}, `${t}-${n}`);
|
|
490
|
+
let a = T(e.date), s = o.isSame(o.date(e.date), o.date(J), "day");
|
|
491
|
+
return /* @__PURE__ */ p(S, {
|
|
492
|
+
dateObj: e,
|
|
493
|
+
getDateProps: K,
|
|
494
|
+
dayProps: _?.(e),
|
|
495
|
+
classNames: r,
|
|
496
|
+
tabIndex: s ? 0 : -1,
|
|
497
|
+
adapter: o,
|
|
498
|
+
locale: i,
|
|
499
|
+
onKeyDown: ae,
|
|
500
|
+
onFocus: (e) => {
|
|
501
|
+
P(e.date);
|
|
502
|
+
},
|
|
503
|
+
buttonRef: (e) => {
|
|
504
|
+
e ? z.current.set(a, e) : z.current.delete(a);
|
|
505
|
+
}
|
|
506
|
+
}, `${t}-${n}`);
|
|
507
|
+
}))
|
|
508
|
+
}, `daysGrid-${e.month}-${e.year}`)
|
|
301
509
|
]
|
|
302
510
|
}, `${e.month}-${e.year}`))
|
|
303
511
|
]
|
|
304
512
|
}),
|
|
305
|
-
|
|
306
|
-
className:
|
|
307
|
-
children:
|
|
513
|
+
h && /* @__PURE__ */ p("div", {
|
|
514
|
+
className: g("rmd-footer", r?.footer),
|
|
515
|
+
children: h
|
|
308
516
|
})
|
|
309
517
|
]
|
|
310
518
|
});
|
|
311
519
|
};
|
|
312
520
|
//#endregion
|
|
313
|
-
export {
|
|
521
|
+
export { E as Calendar, x as CalendarHeader, y as ChevronLeftIcon, b as ChevronRightIcon, S as Day, e as DayjsAdapter, C as MonthSelection, w as YearSelection, r as addMonth, i as composeEventHandlers, t as defaultAdapter, a as getCalendars, _ as getDefaults, v as getTranslations, o as isBackDisabled, s as isForwardDisabled, c as subtractMonth, n as useDates };
|
|
314
522
|
|
|
315
523
|
//# sourceMappingURL=index.js.map
|