react-photo-calendar 0.1.0
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/LICENSE +21 -0
- package/README.md +220 -0
- package/dist/PhotoCalendar.d.ts +98 -0
- package/dist/PhotoCalendar.d.ts.map +1 -0
- package/dist/components/CalendarBanner.d.ts +17 -0
- package/dist/components/CalendarBanner.d.ts.map +1 -0
- package/dist/components/PhotoCalendarScrollView.d.ts +24 -0
- package/dist/components/PhotoCalendarScrollView.d.ts.map +1 -0
- package/dist/context/PhotoCalendarContext.d.ts +9 -0
- package/dist/context/PhotoCalendarContext.d.ts.map +1 -0
- package/dist/hooks/useCalendarActiveMonthTracking.d.ts +14 -0
- package/dist/hooks/useCalendarActiveMonthTracking.d.ts.map +1 -0
- package/dist/hooks/useCalendarMonthVisibility.d.ts +18 -0
- package/dist/hooks/useCalendarMonthVisibility.d.ts.map +1 -0
- package/dist/hooks/useCalendarMonthWindow.d.ts +18 -0
- package/dist/hooks/useCalendarMonthWindow.d.ts.map +1 -0
- package/dist/hooks/useCalendarWindowExpansionObserver.d.ts +17 -0
- package/dist/hooks/useCalendarWindowExpansionObserver.d.ts.map +1 -0
- package/dist/hooks/usePhotoCalendarState.d.ts +73 -0
- package/dist/hooks/usePhotoCalendarState.d.ts.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/photo-calendar.cjs +22 -0
- package/dist/photo-calendar.css +1 -0
- package/dist/photo-calendar.mjs +1099 -0
- package/dist/primitives/PhotoCalendarDay.d.ts +7 -0
- package/dist/primitives/PhotoCalendarDay.d.ts.map +1 -0
- package/dist/primitives/PhotoCalendarMonthGrid.d.ts +17 -0
- package/dist/primitives/PhotoCalendarMonthGrid.d.ts.map +1 -0
- package/dist/primitives/PhotoCalendarNavigation.d.ts +17 -0
- package/dist/primitives/PhotoCalendarNavigation.d.ts.map +1 -0
- package/dist/primitives/PhotoCalendarRoot.d.ts +7 -0
- package/dist/primitives/PhotoCalendarRoot.d.ts.map +1 -0
- package/dist/primitives/PhotoCalendarWeekdays.d.ts +15 -0
- package/dist/primitives/PhotoCalendarWeekdays.d.ts.map +1 -0
- package/dist/types/calendar.d.ts +25 -0
- package/dist/types/calendar.d.ts.map +1 -0
- package/dist/types/photo.d.ts +15 -0
- package/dist/types/photo.d.ts.map +1 -0
- package/dist/utils/calendar.d.ts +15 -0
- package/dist/utils/calendar.d.ts.map +1 -0
- package/dist/utils/photos.d.ts +6 -0
- package/dist/utils/photos.d.ts.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,1099 @@
|
|
|
1
|
+
import He, { useContext as Xe, createContext as Ze, useState as ve, useMemo as N, useCallback as P, useEffect as J, Fragment as Qe, useRef as B } from "react";
|
|
2
|
+
var me = { exports: {} }, ue = {};
|
|
3
|
+
/**
|
|
4
|
+
* @license React
|
|
5
|
+
* react-jsx-runtime.production.js
|
|
6
|
+
*
|
|
7
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the MIT license found in the
|
|
10
|
+
* LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/
|
|
12
|
+
var Ae;
|
|
13
|
+
function et() {
|
|
14
|
+
if (Ae) return ue;
|
|
15
|
+
Ae = 1;
|
|
16
|
+
var t = Symbol.for("react.transitional.element"), a = Symbol.for("react.fragment");
|
|
17
|
+
function c(d, l, h) {
|
|
18
|
+
var f = null;
|
|
19
|
+
if (h !== void 0 && (f = "" + h), l.key !== void 0 && (f = "" + l.key), "key" in l) {
|
|
20
|
+
h = {};
|
|
21
|
+
for (var g in l)
|
|
22
|
+
g !== "key" && (h[g] = l[g]);
|
|
23
|
+
} else h = l;
|
|
24
|
+
return l = h.ref, {
|
|
25
|
+
$$typeof: t,
|
|
26
|
+
type: d,
|
|
27
|
+
key: f,
|
|
28
|
+
ref: l !== void 0 ? l : null,
|
|
29
|
+
props: h
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
return ue.Fragment = a, ue.jsx = c, ue.jsxs = c, ue;
|
|
33
|
+
}
|
|
34
|
+
var de = {};
|
|
35
|
+
/**
|
|
36
|
+
* @license React
|
|
37
|
+
* react-jsx-runtime.development.js
|
|
38
|
+
*
|
|
39
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
40
|
+
*
|
|
41
|
+
* This source code is licensed under the MIT license found in the
|
|
42
|
+
* LICENSE file in the root directory of this source tree.
|
|
43
|
+
*/
|
|
44
|
+
var Oe;
|
|
45
|
+
function tt() {
|
|
46
|
+
return Oe || (Oe = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
|
+
function t(e) {
|
|
48
|
+
if (e == null) return null;
|
|
49
|
+
if (typeof e == "function")
|
|
50
|
+
return e.$$typeof === z ? null : e.displayName || e.name || null;
|
|
51
|
+
if (typeof e == "string") return e;
|
|
52
|
+
switch (e) {
|
|
53
|
+
case S:
|
|
54
|
+
return "Fragment";
|
|
55
|
+
case I:
|
|
56
|
+
return "Profiler";
|
|
57
|
+
case k:
|
|
58
|
+
return "StrictMode";
|
|
59
|
+
case M:
|
|
60
|
+
return "Suspense";
|
|
61
|
+
case K:
|
|
62
|
+
return "SuspenseList";
|
|
63
|
+
case te:
|
|
64
|
+
return "Activity";
|
|
65
|
+
}
|
|
66
|
+
if (typeof e == "object")
|
|
67
|
+
switch (typeof e.tag == "number" && console.error(
|
|
68
|
+
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
|
+
), e.$$typeof) {
|
|
70
|
+
case Y:
|
|
71
|
+
return "Portal";
|
|
72
|
+
case U:
|
|
73
|
+
return e.displayName || "Context";
|
|
74
|
+
case $:
|
|
75
|
+
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
|
+
case F:
|
|
77
|
+
var n = e.render;
|
|
78
|
+
return e = e.displayName, e || (e = n.displayName || n.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
+
case R:
|
|
80
|
+
return n = e.displayName || null, n !== null ? n : t(e.type) || "Memo";
|
|
81
|
+
case j:
|
|
82
|
+
n = e._payload, e = e._init;
|
|
83
|
+
try {
|
|
84
|
+
return t(e(n));
|
|
85
|
+
} catch {
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
function a(e) {
|
|
91
|
+
return "" + e;
|
|
92
|
+
}
|
|
93
|
+
function c(e) {
|
|
94
|
+
try {
|
|
95
|
+
a(e);
|
|
96
|
+
var n = !1;
|
|
97
|
+
} catch {
|
|
98
|
+
n = !0;
|
|
99
|
+
}
|
|
100
|
+
if (n) {
|
|
101
|
+
n = console;
|
|
102
|
+
var o = n.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return o.call(
|
|
104
|
+
n,
|
|
105
|
+
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
|
+
i
|
|
107
|
+
), a(e);
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
function d(e) {
|
|
111
|
+
if (e === S) return "<>";
|
|
112
|
+
if (typeof e == "object" && e !== null && e.$$typeof === j)
|
|
113
|
+
return "<...>";
|
|
114
|
+
try {
|
|
115
|
+
var n = t(e);
|
|
116
|
+
return n ? "<" + n + ">" : "<...>";
|
|
117
|
+
} catch {
|
|
118
|
+
return "<...>";
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function l() {
|
|
122
|
+
var e = W.A;
|
|
123
|
+
return e === null ? null : e.getOwner();
|
|
124
|
+
}
|
|
125
|
+
function h() {
|
|
126
|
+
return Error("react-stack-top-frame");
|
|
127
|
+
}
|
|
128
|
+
function f(e) {
|
|
129
|
+
if (X.call(e, "key")) {
|
|
130
|
+
var n = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
131
|
+
if (n && n.isReactWarning) return !1;
|
|
132
|
+
}
|
|
133
|
+
return e.key !== void 0;
|
|
134
|
+
}
|
|
135
|
+
function g(e, n) {
|
|
136
|
+
function o() {
|
|
137
|
+
se || (se = !0, console.error(
|
|
138
|
+
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
|
+
n
|
|
140
|
+
));
|
|
141
|
+
}
|
|
142
|
+
o.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: o,
|
|
144
|
+
configurable: !0
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
function w() {
|
|
148
|
+
var e = t(this.type);
|
|
149
|
+
return ne[e] || (ne[e] = !0, console.error(
|
|
150
|
+
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
|
+
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
|
+
}
|
|
153
|
+
function D(e, n, o, i, C, u) {
|
|
154
|
+
var b = o.ref;
|
|
155
|
+
return e = {
|
|
156
|
+
$$typeof: E,
|
|
157
|
+
type: e,
|
|
158
|
+
key: n,
|
|
159
|
+
props: o,
|
|
160
|
+
_owner: i
|
|
161
|
+
}, (b !== void 0 ? b : null) !== null ? Object.defineProperty(e, "ref", {
|
|
162
|
+
enumerable: !1,
|
|
163
|
+
get: w
|
|
164
|
+
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
165
|
+
configurable: !1,
|
|
166
|
+
enumerable: !1,
|
|
167
|
+
writable: !0,
|
|
168
|
+
value: 0
|
|
169
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
170
|
+
configurable: !1,
|
|
171
|
+
enumerable: !1,
|
|
172
|
+
writable: !0,
|
|
173
|
+
value: null
|
|
174
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
175
|
+
configurable: !1,
|
|
176
|
+
enumerable: !1,
|
|
177
|
+
writable: !0,
|
|
178
|
+
value: C
|
|
179
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
180
|
+
configurable: !1,
|
|
181
|
+
enumerable: !1,
|
|
182
|
+
writable: !0,
|
|
183
|
+
value: u
|
|
184
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
185
|
+
}
|
|
186
|
+
function p(e, n, o, i, C, u) {
|
|
187
|
+
var b = n.children;
|
|
188
|
+
if (b !== void 0)
|
|
189
|
+
if (i)
|
|
190
|
+
if (le(b)) {
|
|
191
|
+
for (i = 0; i < b.length; i++)
|
|
192
|
+
v(b[i]);
|
|
193
|
+
Object.freeze && Object.freeze(b);
|
|
194
|
+
} else
|
|
195
|
+
console.error(
|
|
196
|
+
"React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
|
|
197
|
+
);
|
|
198
|
+
else v(b);
|
|
199
|
+
if (X.call(n, "key")) {
|
|
200
|
+
b = t(e);
|
|
201
|
+
var _ = Object.keys(n).filter(function(q) {
|
|
202
|
+
return q !== "key";
|
|
203
|
+
});
|
|
204
|
+
i = 0 < _.length ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}", oe[b + i] || (_ = 0 < _.length ? "{" + _.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
|
+
`A props object containing a "key" prop is being spread into JSX:
|
|
206
|
+
let props = %s;
|
|
207
|
+
<%s {...props} />
|
|
208
|
+
React keys must be passed directly to JSX without using spread:
|
|
209
|
+
let props = %s;
|
|
210
|
+
<%s key={someKey} {...props} />`,
|
|
211
|
+
i,
|
|
212
|
+
b,
|
|
213
|
+
_,
|
|
214
|
+
b
|
|
215
|
+
), oe[b + i] = !0);
|
|
216
|
+
}
|
|
217
|
+
if (b = null, o !== void 0 && (c(o), b = "" + o), f(n) && (c(n.key), b = "" + n.key), "key" in n) {
|
|
218
|
+
o = {};
|
|
219
|
+
for (var A in n)
|
|
220
|
+
A !== "key" && (o[A] = n[A]);
|
|
221
|
+
} else o = n;
|
|
222
|
+
return b && g(
|
|
223
|
+
o,
|
|
224
|
+
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
225
|
+
), D(
|
|
226
|
+
e,
|
|
227
|
+
b,
|
|
228
|
+
o,
|
|
229
|
+
l(),
|
|
230
|
+
C,
|
|
231
|
+
u
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
function v(e) {
|
|
235
|
+
x(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === j && (e._payload.status === "fulfilled" ? x(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
236
|
+
}
|
|
237
|
+
function x(e) {
|
|
238
|
+
return typeof e == "object" && e !== null && e.$$typeof === E;
|
|
239
|
+
}
|
|
240
|
+
var T = He, E = Symbol.for("react.transitional.element"), Y = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), k = Symbol.for("react.strict_mode"), I = Symbol.for("react.profiler"), $ = Symbol.for("react.consumer"), U = Symbol.for("react.context"), F = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), K = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), j = Symbol.for("react.lazy"), te = Symbol.for("react.activity"), z = Symbol.for("react.client.reference"), W = T.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, X = Object.prototype.hasOwnProperty, le = Array.isArray, Z = console.createTask ? console.createTask : function() {
|
|
241
|
+
return null;
|
|
242
|
+
};
|
|
243
|
+
T = {
|
|
244
|
+
react_stack_bottom_frame: function(e) {
|
|
245
|
+
return e();
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
var se, ne = {}, re = T.react_stack_bottom_frame.bind(
|
|
249
|
+
T,
|
|
250
|
+
h
|
|
251
|
+
)(), ae = Z(d(h)), oe = {};
|
|
252
|
+
de.Fragment = S, de.jsx = function(e, n, o) {
|
|
253
|
+
var i = 1e4 > W.recentlyCreatedOwnerStacks++;
|
|
254
|
+
return p(
|
|
255
|
+
e,
|
|
256
|
+
n,
|
|
257
|
+
o,
|
|
258
|
+
!1,
|
|
259
|
+
i ? Error("react-stack-top-frame") : re,
|
|
260
|
+
i ? Z(d(e)) : ae
|
|
261
|
+
);
|
|
262
|
+
}, de.jsxs = function(e, n, o) {
|
|
263
|
+
var i = 1e4 > W.recentlyCreatedOwnerStacks++;
|
|
264
|
+
return p(
|
|
265
|
+
e,
|
|
266
|
+
n,
|
|
267
|
+
o,
|
|
268
|
+
!0,
|
|
269
|
+
i ? Error("react-stack-top-frame") : re,
|
|
270
|
+
i ? Z(d(e)) : ae
|
|
271
|
+
);
|
|
272
|
+
};
|
|
273
|
+
})()), de;
|
|
274
|
+
}
|
|
275
|
+
var Ue;
|
|
276
|
+
function nt() {
|
|
277
|
+
return Ue || (Ue = 1, process.env.NODE_ENV === "production" ? me.exports = et() : me.exports = tt()), me.exports;
|
|
278
|
+
}
|
|
279
|
+
var r = nt();
|
|
280
|
+
const $e = Ze(null);
|
|
281
|
+
function rt({ value: t, children: a }) {
|
|
282
|
+
return /* @__PURE__ */ r.jsx($e.Provider, { value: t, children: a });
|
|
283
|
+
}
|
|
284
|
+
function ee(t = "usePhotoCalendarContext") {
|
|
285
|
+
const a = Xe($e);
|
|
286
|
+
if (!a)
|
|
287
|
+
throw new Error(`${t} must be used within a <PhotoCalendarRoot> or <PhotoCalendarContextProvider>.`);
|
|
288
|
+
return a;
|
|
289
|
+
}
|
|
290
|
+
function H(t) {
|
|
291
|
+
if (!t) {
|
|
292
|
+
const h = /* @__PURE__ */ new Date();
|
|
293
|
+
return new Date(Date.UTC(h.getUTCFullYear(), h.getUTCMonth(), 1));
|
|
294
|
+
}
|
|
295
|
+
const [a = "", c = ""] = t.split("-"), d = Number(a), l = Number(c) - 1;
|
|
296
|
+
if (Number.isNaN(d) || Number.isNaN(l) || l < 0 || l > 11) {
|
|
297
|
+
const h = /* @__PURE__ */ new Date();
|
|
298
|
+
return new Date(Date.UTC(h.getUTCFullYear(), h.getUTCMonth(), 1));
|
|
299
|
+
}
|
|
300
|
+
return new Date(Date.UTC(d, l, 1));
|
|
301
|
+
}
|
|
302
|
+
function at(t) {
|
|
303
|
+
return t.toISOString().slice(0, 10);
|
|
304
|
+
}
|
|
305
|
+
function ot(t, a) {
|
|
306
|
+
const c = t.getUTCFullYear(), d = t.getUTCMonth(), f = (new Date(Date.UTC(c, d, 1)).getUTCDay() - a + 7) % 7, g = new Date(Date.UTC(c, d + 1, 0)).getUTCDate(), w = Math.ceil((f + g) / 7) * 7, D = new Date(Date.UTC(c, d, 1 - f)), p = [];
|
|
307
|
+
for (let v = 0; v < w; v += 1) {
|
|
308
|
+
const x = new Date(
|
|
309
|
+
Date.UTC(D.getUTCFullYear(), D.getUTCMonth(), D.getUTCDate() + v)
|
|
310
|
+
);
|
|
311
|
+
p.push({
|
|
312
|
+
date: x,
|
|
313
|
+
isoDate: at(x),
|
|
314
|
+
day: x.getUTCDate(),
|
|
315
|
+
inCurrentMonth: x.getUTCMonth() === d
|
|
316
|
+
});
|
|
317
|
+
}
|
|
318
|
+
return p;
|
|
319
|
+
}
|
|
320
|
+
function ce(t) {
|
|
321
|
+
const a = `${t.getUTCMonth() + 1}`.padStart(2, "0");
|
|
322
|
+
return `${t.getUTCFullYear()}-${a}`;
|
|
323
|
+
}
|
|
324
|
+
function Fe(t, a) {
|
|
325
|
+
return new Date(Date.UTC(t.getUTCFullYear(), t.getUTCMonth() + a, 1));
|
|
326
|
+
}
|
|
327
|
+
function st(t) {
|
|
328
|
+
if (t.length === 0)
|
|
329
|
+
return null;
|
|
330
|
+
const a = t[0].date, c = t[t.length - 1].date;
|
|
331
|
+
return {
|
|
332
|
+
start: new Date(a.getTime()),
|
|
333
|
+
end: new Date(c.getTime())
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
function ct(t) {
|
|
337
|
+
return !t || t.length === 0 ? {} : t.reduce((a, c) => {
|
|
338
|
+
if (c.photos.length > 0) {
|
|
339
|
+
const d = c.datetime.slice(0, 10), l = a[d] ?? [];
|
|
340
|
+
a[d] = l.concat(c.photos);
|
|
341
|
+
}
|
|
342
|
+
return a;
|
|
343
|
+
}, {});
|
|
344
|
+
}
|
|
345
|
+
function it({
|
|
346
|
+
monthKey: t,
|
|
347
|
+
defaultMonthKey: a,
|
|
348
|
+
onMonthChange: c,
|
|
349
|
+
onDaySelect: d,
|
|
350
|
+
firstDayOfWeek: l = 0,
|
|
351
|
+
entries: h,
|
|
352
|
+
maxThumbnailsPerDay: f = 1,
|
|
353
|
+
minMonthKey: g,
|
|
354
|
+
maxMonthKey: w,
|
|
355
|
+
onRangeChange: D,
|
|
356
|
+
onVisibleMonthChange: p,
|
|
357
|
+
locale: v,
|
|
358
|
+
timeZone: x
|
|
359
|
+
} = {}) {
|
|
360
|
+
const T = t !== void 0, [E, Y] = ve(() => ce(H(a))), S = T ? t : E, k = N(() => H(S), [S]), I = N(() => g ? H(g) : void 0, [g]), $ = N(() => w ? H(w) : void 0, [w]), U = k.getUTCFullYear(), F = k.getUTCMonth(), M = v ?? void 0, K = x ?? "UTC", R = N(() => ({ timeZone: K }), [K]), j = N(
|
|
361
|
+
() => new Intl.DateTimeFormat(M, { month: "long", year: "numeric", ...R }),
|
|
362
|
+
[M, R]
|
|
363
|
+
), te = N(
|
|
364
|
+
() => new Intl.DateTimeFormat(M, { day: "numeric", month: "long", year: "numeric", ...R }),
|
|
365
|
+
[M, R]
|
|
366
|
+
), z = N(
|
|
367
|
+
() => new Intl.DateTimeFormat(M, { weekday: "short", ...R }),
|
|
368
|
+
[M, R]
|
|
369
|
+
), W = N(
|
|
370
|
+
() => new Intl.DateTimeFormat(M, { weekday: "long", ...R }),
|
|
371
|
+
[M, R]
|
|
372
|
+
), X = N(
|
|
373
|
+
() => new Intl.DateTimeFormat(M, { month: "short", ...R }),
|
|
374
|
+
[M, R]
|
|
375
|
+
), le = N(
|
|
376
|
+
() => Array.from(
|
|
377
|
+
{ length: 12 },
|
|
378
|
+
(s, m) => X.format(new Date(Date.UTC(2021, m, 1)))
|
|
379
|
+
),
|
|
380
|
+
[X]
|
|
381
|
+
), Z = N(() => ct(h), [h]), se = N(() => {
|
|
382
|
+
const s = Array.from({ length: 7 }, (L, xe) => new Date(Date.UTC(2021, 7, xe + 1))), m = s.map((L) => z.format(L)), y = s.map((L) => W.format(L)), Q = (L) => L.slice(l).concat(L.slice(0, l));
|
|
383
|
+
return {
|
|
384
|
+
short: Q(m),
|
|
385
|
+
long: Q(y)
|
|
386
|
+
};
|
|
387
|
+
}, [l, z, W]), ne = Math.max(1, f), re = N(() => (/* @__PURE__ */ new Date()).toISOString().slice(0, 10), []), ae = P(
|
|
388
|
+
(s) => {
|
|
389
|
+
d == null || d({
|
|
390
|
+
isoDate: s.isoDate,
|
|
391
|
+
date: s.date
|
|
392
|
+
});
|
|
393
|
+
},
|
|
394
|
+
[d]
|
|
395
|
+
), oe = P((s) => {
|
|
396
|
+
const m = st(s);
|
|
397
|
+
return m ? {
|
|
398
|
+
start: m.start,
|
|
399
|
+
end: m.end,
|
|
400
|
+
startIso: m.start.toISOString().slice(0, 10),
|
|
401
|
+
endIso: m.end.toISOString().slice(0, 10)
|
|
402
|
+
} : null;
|
|
403
|
+
}, []), e = P(
|
|
404
|
+
(s) => {
|
|
405
|
+
const m = ot(s, l), y = oe(m), Q = ce(s), L = j.format(s), xe = m.map((G) => {
|
|
406
|
+
const fe = Z[G.isoDate] ?? [], Se = fe.slice(0, ne), qe = Math.max(0, fe.length - Se.length), Ge = G.isoDate === re, ke = G.inCurrentMonth, Je = {
|
|
407
|
+
date: G.date,
|
|
408
|
+
isoDate: G.isoDate,
|
|
409
|
+
day: G.day,
|
|
410
|
+
isCurrentMonth: G.inCurrentMonth,
|
|
411
|
+
isToday: Ge,
|
|
412
|
+
photos: fe,
|
|
413
|
+
visibleThumbnails: Se,
|
|
414
|
+
overflow: qe,
|
|
415
|
+
selectDay: () => {
|
|
416
|
+
ke && ae(G);
|
|
417
|
+
}
|
|
418
|
+
}, pe = fe.length, ze = pe === 0 ? "No photos" : `${pe} ${pe === 1 ? "photo" : "photos"}`;
|
|
419
|
+
return {
|
|
420
|
+
cell: G,
|
|
421
|
+
context: Je,
|
|
422
|
+
ariaLabel: `${te.format(G.date)}. ${ze}`,
|
|
423
|
+
isSelectable: ke
|
|
424
|
+
};
|
|
425
|
+
});
|
|
426
|
+
return {
|
|
427
|
+
monthKey: Q,
|
|
428
|
+
monthDate: new Date(s.getTime()),
|
|
429
|
+
monthLabel: L,
|
|
430
|
+
visibleRange: y,
|
|
431
|
+
dayStates: xe
|
|
432
|
+
};
|
|
433
|
+
},
|
|
434
|
+
[oe, te, l, ae, ne, j, Z, re]
|
|
435
|
+
), n = N(() => e(k), [e, k]), { monthLabel: o, visibleRange: i, dayStates: C } = n;
|
|
436
|
+
J(() => {
|
|
437
|
+
!D || !i || D(i);
|
|
438
|
+
}, [D, i]), J(() => {
|
|
439
|
+
p && p(S);
|
|
440
|
+
}, [S, p]);
|
|
441
|
+
const u = P((s) => s.getUTCFullYear() * 12 + s.getUTCMonth(), []), b = N(() => I ? u(I) : null, [I, u]), _ = N(() => $ ? u($) : null, [$, u]), A = N(() => u(k), [k, u]), q = P(
|
|
442
|
+
(s) => {
|
|
443
|
+
const m = u(s);
|
|
444
|
+
return !(b !== null && m < b || _ !== null && m > _);
|
|
445
|
+
},
|
|
446
|
+
[_, b, u]
|
|
447
|
+
), O = P(
|
|
448
|
+
(s) => I && u(s) < b ? I : $ && u(s) > _ ? $ : s,
|
|
449
|
+
[$, _, I, b, u]
|
|
450
|
+
), V = P(
|
|
451
|
+
(s) => {
|
|
452
|
+
const m = ce(s);
|
|
453
|
+
m !== S && (c == null || c(m), T || Y(m));
|
|
454
|
+
},
|
|
455
|
+
[S, T, c]
|
|
456
|
+
), Ce = P(
|
|
457
|
+
(s) => {
|
|
458
|
+
const m = new Date(Date.UTC(U, s, 1));
|
|
459
|
+
if (!q(m)) {
|
|
460
|
+
const y = O(m);
|
|
461
|
+
if (u(y) === A)
|
|
462
|
+
return;
|
|
463
|
+
V(y);
|
|
464
|
+
return;
|
|
465
|
+
}
|
|
466
|
+
V(m);
|
|
467
|
+
},
|
|
468
|
+
[O, V, A, U, q, u]
|
|
469
|
+
), Te = P(
|
|
470
|
+
(s) => {
|
|
471
|
+
const m = Fe(k, s), y = O(m);
|
|
472
|
+
u(y) !== A && V(y);
|
|
473
|
+
},
|
|
474
|
+
[O, V, A, k, u]
|
|
475
|
+
), ye = P(
|
|
476
|
+
(s) => {
|
|
477
|
+
const m = new Date(Date.UTC(U + s, F, 1)), y = O(m);
|
|
478
|
+
u(y) !== A && V(y);
|
|
479
|
+
},
|
|
480
|
+
[O, V, F, A, U, u]
|
|
481
|
+
), Ne = P(() => {
|
|
482
|
+
const s = /* @__PURE__ */ new Date(), m = new Date(Date.UTC(s.getUTCFullYear(), s.getUTCMonth(), 1)), y = O(m);
|
|
483
|
+
u(y) !== A && V(y);
|
|
484
|
+
}, [O, V, A, u]), he = P(
|
|
485
|
+
(s) => ce(O(H(s))),
|
|
486
|
+
[O]
|
|
487
|
+
), je = P(
|
|
488
|
+
(s) => {
|
|
489
|
+
const m = H(s), y = O(m);
|
|
490
|
+
return e(y);
|
|
491
|
+
},
|
|
492
|
+
[e, O]
|
|
493
|
+
), we = P(
|
|
494
|
+
(s, m) => {
|
|
495
|
+
if (m === 0)
|
|
496
|
+
return he(s);
|
|
497
|
+
const y = H(s), Q = Fe(y, m);
|
|
498
|
+
if (!q(Q)) {
|
|
499
|
+
const L = O(Q);
|
|
500
|
+
return u(L) === u(y) ? null : ce(L);
|
|
501
|
+
}
|
|
502
|
+
return ce(Q);
|
|
503
|
+
},
|
|
504
|
+
[he, O, q, u]
|
|
505
|
+
), Pe = P(
|
|
506
|
+
(s) => q(H(s)),
|
|
507
|
+
[q]
|
|
508
|
+
), Me = P(
|
|
509
|
+
(s) => {
|
|
510
|
+
const m = H(s), y = O(m);
|
|
511
|
+
V(y);
|
|
512
|
+
},
|
|
513
|
+
[O, V]
|
|
514
|
+
), De = P(
|
|
515
|
+
(s) => {
|
|
516
|
+
const m = new Date(Date.UTC(U, s, 1));
|
|
517
|
+
return !q(m);
|
|
518
|
+
},
|
|
519
|
+
[U, q]
|
|
520
|
+
), Ee = N(() => {
|
|
521
|
+
const s = /* @__PURE__ */ new Date(), m = new Date(Date.UTC(s.getUTCFullYear(), s.getUTCMonth(), 1)), y = O(m);
|
|
522
|
+
return u(y) === A;
|
|
523
|
+
}, [O, A, u]), be = N(
|
|
524
|
+
() => b === null || A > b,
|
|
525
|
+
[A, b]
|
|
526
|
+
), ge = N(
|
|
527
|
+
() => _ === null || A < _,
|
|
528
|
+
[A, _]
|
|
529
|
+
), Re = be, _e = ge, Ke = N(
|
|
530
|
+
() => ({
|
|
531
|
+
canNavigatePrevMonth: be,
|
|
532
|
+
canNavigateNextMonth: ge,
|
|
533
|
+
canNavigatePrevYear: Re,
|
|
534
|
+
canNavigateNextYear: _e,
|
|
535
|
+
isTodayDisabled: Ee,
|
|
536
|
+
navigateMonth: Te,
|
|
537
|
+
navigateYear: ye,
|
|
538
|
+
navigateToMonth: Ce,
|
|
539
|
+
goToToday: Ne,
|
|
540
|
+
isMonthDisabled: De
|
|
541
|
+
}),
|
|
542
|
+
[
|
|
543
|
+
be,
|
|
544
|
+
ge,
|
|
545
|
+
Re,
|
|
546
|
+
_e,
|
|
547
|
+
Ne,
|
|
548
|
+
De,
|
|
549
|
+
Ee,
|
|
550
|
+
Te,
|
|
551
|
+
Ce,
|
|
552
|
+
ye
|
|
553
|
+
]
|
|
554
|
+
), We = N(
|
|
555
|
+
() => ({
|
|
556
|
+
getMonthSnapshot: je,
|
|
557
|
+
getAdjacentMonthKey: we,
|
|
558
|
+
clampMonthKey: he,
|
|
559
|
+
isMonthWithinBounds: Pe,
|
|
560
|
+
syncVisibleMonth: Me
|
|
561
|
+
}),
|
|
562
|
+
[he, we, je, Pe, Me]
|
|
563
|
+
);
|
|
564
|
+
return {
|
|
565
|
+
currentYear: U,
|
|
566
|
+
currentMonth: F,
|
|
567
|
+
monthDate: k,
|
|
568
|
+
monthKey: S,
|
|
569
|
+
monthLabel: o,
|
|
570
|
+
monthNames: le,
|
|
571
|
+
weekdayLabels: se,
|
|
572
|
+
visibleRange: i,
|
|
573
|
+
dayStates: C,
|
|
574
|
+
navigation: Ke,
|
|
575
|
+
scroll: We,
|
|
576
|
+
isControlled: T
|
|
577
|
+
};
|
|
578
|
+
}
|
|
579
|
+
function Ye({ children: t, ...a }) {
|
|
580
|
+
const c = it(a), d = typeof t == "function" ? t(c) : t;
|
|
581
|
+
return /* @__PURE__ */ r.jsx(rt, { value: c, children: d });
|
|
582
|
+
}
|
|
583
|
+
function lt({ children: t }) {
|
|
584
|
+
return /* @__PURE__ */ r.jsx("div", { className: "calendar-banner", children: t });
|
|
585
|
+
}
|
|
586
|
+
function ut() {
|
|
587
|
+
const { currentYear: t } = ee("PhotoCalendarNavigationYearHeading");
|
|
588
|
+
return /* @__PURE__ */ r.jsx("div", { className: "calendar-year-row", children: /* @__PURE__ */ r.jsx("strong", { className: "calendar-year", children: t }) });
|
|
589
|
+
}
|
|
590
|
+
function dt({ children: t }) {
|
|
591
|
+
return /* @__PURE__ */ r.jsx("div", { className: "month-chips-row", children: t });
|
|
592
|
+
}
|
|
593
|
+
const ie = (t) => {
|
|
594
|
+
const { navigation: a } = ee(t);
|
|
595
|
+
return a;
|
|
596
|
+
};
|
|
597
|
+
function ht() {
|
|
598
|
+
const t = ie("PhotoCalendarNavigationPrevYearButton");
|
|
599
|
+
return /* @__PURE__ */ r.jsxs(
|
|
600
|
+
"button",
|
|
601
|
+
{
|
|
602
|
+
type: "button",
|
|
603
|
+
className: "nav-button nav-button--prev nav-button--year",
|
|
604
|
+
"aria-label": "Previous year",
|
|
605
|
+
onClick: () => t.navigateYear(-1),
|
|
606
|
+
disabled: !t.canNavigatePrevYear,
|
|
607
|
+
children: [
|
|
608
|
+
/* @__PURE__ */ r.jsx("span", { "aria-hidden": "true", className: "nav-button-icon", children: "‹" }),
|
|
609
|
+
/* @__PURE__ */ r.jsx("span", { className: "nav-button-label", children: "Previous year" })
|
|
610
|
+
]
|
|
611
|
+
}
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
function ft() {
|
|
615
|
+
const t = ie("PhotoCalendarNavigationNextYearButton");
|
|
616
|
+
return /* @__PURE__ */ r.jsxs(
|
|
617
|
+
"button",
|
|
618
|
+
{
|
|
619
|
+
type: "button",
|
|
620
|
+
className: "nav-button nav-button--next nav-button--year",
|
|
621
|
+
"aria-label": "Next year",
|
|
622
|
+
onClick: () => t.navigateYear(1),
|
|
623
|
+
disabled: !t.canNavigateNextYear,
|
|
624
|
+
children: [
|
|
625
|
+
/* @__PURE__ */ r.jsx("span", { "aria-hidden": "true", className: "nav-button-icon", children: "›" }),
|
|
626
|
+
/* @__PURE__ */ r.jsx("span", { className: "nav-button-label", children: "Next year" })
|
|
627
|
+
]
|
|
628
|
+
}
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
function mt() {
|
|
632
|
+
const t = ie("PhotoCalendarNavigationPrevMonthButton");
|
|
633
|
+
return /* @__PURE__ */ r.jsxs(
|
|
634
|
+
"button",
|
|
635
|
+
{
|
|
636
|
+
type: "button",
|
|
637
|
+
className: "nav-button nav-button--prev nav-button--month",
|
|
638
|
+
"aria-label": "Previous month",
|
|
639
|
+
onClick: () => t.navigateMonth(-1),
|
|
640
|
+
disabled: !t.canNavigatePrevMonth,
|
|
641
|
+
children: [
|
|
642
|
+
/* @__PURE__ */ r.jsx("span", { "aria-hidden": "true", className: "nav-button-icon", children: "‹" }),
|
|
643
|
+
/* @__PURE__ */ r.jsx("span", { className: "nav-button-label", children: "Previous month" })
|
|
644
|
+
]
|
|
645
|
+
}
|
|
646
|
+
);
|
|
647
|
+
}
|
|
648
|
+
function vt() {
|
|
649
|
+
const t = ie("PhotoCalendarNavigationNextMonthButton");
|
|
650
|
+
return /* @__PURE__ */ r.jsxs(
|
|
651
|
+
"button",
|
|
652
|
+
{
|
|
653
|
+
type: "button",
|
|
654
|
+
className: "nav-button nav-button--next nav-button--month",
|
|
655
|
+
"aria-label": "Next month",
|
|
656
|
+
onClick: () => t.navigateMonth(1),
|
|
657
|
+
disabled: !t.canNavigateNextMonth,
|
|
658
|
+
children: [
|
|
659
|
+
/* @__PURE__ */ r.jsx("span", { "aria-hidden": "true", className: "nav-button-icon", children: "›" }),
|
|
660
|
+
/* @__PURE__ */ r.jsx("span", { className: "nav-button-label", children: "Next month" })
|
|
661
|
+
]
|
|
662
|
+
}
|
|
663
|
+
);
|
|
664
|
+
}
|
|
665
|
+
function bt() {
|
|
666
|
+
const { currentYear: t, currentMonth: a, monthNames: c } = ee("PhotoCalendarNavigationMonthChips"), d = ie("PhotoCalendarNavigationMonthChips");
|
|
667
|
+
return /* @__PURE__ */ r.jsx("div", { className: "month-chips", children: c.map((l, h) => /* @__PURE__ */ r.jsx(
|
|
668
|
+
"button",
|
|
669
|
+
{
|
|
670
|
+
type: "button",
|
|
671
|
+
className: `month-chip ${h === a ? "month-chip--active" : ""}`,
|
|
672
|
+
"aria-label": `Go to ${l} ${t}`,
|
|
673
|
+
"aria-current": h === a ? "date" : void 0,
|
|
674
|
+
onClick: () => d.navigateToMonth(h),
|
|
675
|
+
disabled: d.isMonthDisabled(h),
|
|
676
|
+
children: l
|
|
677
|
+
},
|
|
678
|
+
l
|
|
679
|
+
)) });
|
|
680
|
+
}
|
|
681
|
+
function gt() {
|
|
682
|
+
const { monthLabel: t } = ee("PhotoCalendarNavigationMonthLabelMobile");
|
|
683
|
+
return /* @__PURE__ */ r.jsx("div", { className: "month-label-mobile", children: /* @__PURE__ */ r.jsx("strong", { children: t }) });
|
|
684
|
+
}
|
|
685
|
+
function xt() {
|
|
686
|
+
const t = ie("PhotoCalendarNavigationTodayButton");
|
|
687
|
+
return /* @__PURE__ */ r.jsx(
|
|
688
|
+
"button",
|
|
689
|
+
{
|
|
690
|
+
type: "button",
|
|
691
|
+
className: "today-button-icon",
|
|
692
|
+
"aria-label": "Go to current month",
|
|
693
|
+
onClick: t.goToToday,
|
|
694
|
+
disabled: t.isTodayDisabled,
|
|
695
|
+
children: /* @__PURE__ */ r.jsx("span", { "aria-hidden": "true", children: "📅" })
|
|
696
|
+
}
|
|
697
|
+
);
|
|
698
|
+
}
|
|
699
|
+
function pt() {
|
|
700
|
+
return /* @__PURE__ */ r.jsxs(lt, { children: [
|
|
701
|
+
/* @__PURE__ */ r.jsx(ut, {}),
|
|
702
|
+
/* @__PURE__ */ r.jsxs(dt, { children: [
|
|
703
|
+
/* @__PURE__ */ r.jsx(ht, {}),
|
|
704
|
+
/* @__PURE__ */ r.jsx(mt, {}),
|
|
705
|
+
/* @__PURE__ */ r.jsx(bt, {}),
|
|
706
|
+
/* @__PURE__ */ r.jsx(gt, {}),
|
|
707
|
+
/* @__PURE__ */ r.jsx(ft, {}),
|
|
708
|
+
/* @__PURE__ */ r.jsx(vt, {}),
|
|
709
|
+
/* @__PURE__ */ r.jsx(xt, {})
|
|
710
|
+
] })
|
|
711
|
+
] });
|
|
712
|
+
}
|
|
713
|
+
function Ct({ children: t }) {
|
|
714
|
+
const { currentYear: a, currentMonth: c, monthLabel: d, monthNames: l, navigation: h } = ee("PhotoCalendarNavigation"), f = {
|
|
715
|
+
...h,
|
|
716
|
+
currentYear: a,
|
|
717
|
+
currentMonth: c,
|
|
718
|
+
monthLabel: d,
|
|
719
|
+
monthNames: l
|
|
720
|
+
};
|
|
721
|
+
return t ? /* @__PURE__ */ r.jsx(r.Fragment, { children: t(f) }) : /* @__PURE__ */ r.jsx(pt, {});
|
|
722
|
+
}
|
|
723
|
+
function Le({ className: t = "calendar-weekdays", children: a }) {
|
|
724
|
+
const { weekdayLabels: c } = ee("PhotoCalendarWeekdays"), d = {
|
|
725
|
+
shortLabels: c.short,
|
|
726
|
+
longLabels: c.long
|
|
727
|
+
};
|
|
728
|
+
return a ? /* @__PURE__ */ r.jsx(r.Fragment, { children: a(d) }) : /* @__PURE__ */ r.jsx("div", { className: t, role: "row", children: c.short.map((l, h) => /* @__PURE__ */ r.jsx(
|
|
729
|
+
"span",
|
|
730
|
+
{
|
|
731
|
+
className: "calendar-weekday",
|
|
732
|
+
role: "columnheader",
|
|
733
|
+
"aria-label": c.long[h],
|
|
734
|
+
children: l
|
|
735
|
+
},
|
|
736
|
+
`${l}-${h}`
|
|
737
|
+
)) });
|
|
738
|
+
}
|
|
739
|
+
function Ve({ day: t, className: a }) {
|
|
740
|
+
const {
|
|
741
|
+
defaultContent: c,
|
|
742
|
+
ariaLabel: d,
|
|
743
|
+
isSelectable: l,
|
|
744
|
+
isCurrentMonth: h,
|
|
745
|
+
isToday: f,
|
|
746
|
+
visibleThumbnails: g,
|
|
747
|
+
selectDay: w
|
|
748
|
+
} = t, D = [
|
|
749
|
+
"calendar-cell",
|
|
750
|
+
h ? "" : "calendar-cell--placeholder",
|
|
751
|
+
f ? "calendar-cell--today" : "",
|
|
752
|
+
g.length > 0 ? "calendar-cell--has-photo" : "",
|
|
753
|
+
a ?? ""
|
|
754
|
+
].filter(Boolean).join(" ");
|
|
755
|
+
return /* @__PURE__ */ r.jsx(
|
|
756
|
+
"button",
|
|
757
|
+
{
|
|
758
|
+
type: "button",
|
|
759
|
+
className: D,
|
|
760
|
+
role: "gridcell",
|
|
761
|
+
"aria-label": d,
|
|
762
|
+
"aria-disabled": !l,
|
|
763
|
+
disabled: !l,
|
|
764
|
+
onClick: w,
|
|
765
|
+
children: c
|
|
766
|
+
}
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
function Be({ className: t = "calendar-grid", renderDay: a, dayStates: c }) {
|
|
770
|
+
const { dayStates: d } = ee("PhotoCalendarMonthGrid"), l = c ?? d;
|
|
771
|
+
return /* @__PURE__ */ r.jsx("div", { className: t, children: l.map((h, f) => {
|
|
772
|
+
const { cell: g, context: w, ariaLabel: D, isSelectable: p } = h, { visibleThumbnails: v, overflow: x } = w, T = /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
773
|
+
v.length > 0 && /* @__PURE__ */ r.jsxs("div", { className: "calendar-cell-thumbnails", "data-count": v.length, children: [
|
|
774
|
+
v.map((Y, S) => /* @__PURE__ */ r.jsx(
|
|
775
|
+
"img",
|
|
776
|
+
{
|
|
777
|
+
src: Y,
|
|
778
|
+
alt: "",
|
|
779
|
+
loading: "lazy",
|
|
780
|
+
decoding: "async",
|
|
781
|
+
className: "calendar-cell-image"
|
|
782
|
+
},
|
|
783
|
+
`${g.isoDate}-${S}`
|
|
784
|
+
)),
|
|
785
|
+
x > 0 && /* @__PURE__ */ r.jsxs("span", { className: "calendar-cell-overflow", children: [
|
|
786
|
+
"+",
|
|
787
|
+
x
|
|
788
|
+
] })
|
|
789
|
+
] }),
|
|
790
|
+
/* @__PURE__ */ r.jsx("span", { className: "cell-label", children: g.day })
|
|
791
|
+
] }), E = {
|
|
792
|
+
...w,
|
|
793
|
+
defaultContent: T,
|
|
794
|
+
ariaLabel: D,
|
|
795
|
+
isSelectable: p
|
|
796
|
+
};
|
|
797
|
+
return a ? /* @__PURE__ */ r.jsx(Qe, { children: a(E) }, `calendar-cell-${f}`) : /* @__PURE__ */ r.jsx(Ve, { day: E }, `calendar-cell-${f}`);
|
|
798
|
+
}) });
|
|
799
|
+
}
|
|
800
|
+
function Tt({
|
|
801
|
+
containerRef: t,
|
|
802
|
+
monthRefs: a,
|
|
803
|
+
monthKeys: c,
|
|
804
|
+
threshold: d = 0.01,
|
|
805
|
+
rootMargin: l
|
|
806
|
+
}) {
|
|
807
|
+
const [h, f] = ve(/* @__PURE__ */ new Set()), g = B(null), w = (p) => f((v) => v.has(p) ? v : /* @__PURE__ */ new Set([...v, p])), D = (p) => f((v) => {
|
|
808
|
+
if (!v.has(p)) return v;
|
|
809
|
+
const x = new Set(v);
|
|
810
|
+
return x.delete(p), x;
|
|
811
|
+
});
|
|
812
|
+
return J(() => {
|
|
813
|
+
const p = t.current;
|
|
814
|
+
if (!p || typeof IntersectionObserver > "u")
|
|
815
|
+
return;
|
|
816
|
+
const v = new IntersectionObserver(
|
|
817
|
+
(x) => {
|
|
818
|
+
x.forEach((T) => {
|
|
819
|
+
const Y = T.target.getAttribute("data-month-key");
|
|
820
|
+
Y && (T.isIntersecting ? w(Y) : D(Y));
|
|
821
|
+
});
|
|
822
|
+
},
|
|
823
|
+
{ root: p, threshold: d, rootMargin: l }
|
|
824
|
+
);
|
|
825
|
+
return g.current = v, c.forEach((x) => {
|
|
826
|
+
const T = a.current.get(x);
|
|
827
|
+
T && v.observe(T);
|
|
828
|
+
}), () => {
|
|
829
|
+
v.disconnect(), g.current = null;
|
|
830
|
+
};
|
|
831
|
+
}, [t, a, c, d, l]), J(() => {
|
|
832
|
+
const p = g.current;
|
|
833
|
+
p && c.forEach((v) => {
|
|
834
|
+
const x = a.current.get(v);
|
|
835
|
+
x && p.observe(x);
|
|
836
|
+
});
|
|
837
|
+
}, [a, c]), N(() => h, [h]);
|
|
838
|
+
}
|
|
839
|
+
const yt = 7;
|
|
840
|
+
function Ie(t, a) {
|
|
841
|
+
return a ? `${t} ${a}` : t;
|
|
842
|
+
}
|
|
843
|
+
function Nt({
|
|
844
|
+
renderDay: t,
|
|
845
|
+
renderWeekdays: a,
|
|
846
|
+
children: c,
|
|
847
|
+
maxRenderedMonths: d = yt,
|
|
848
|
+
className: l,
|
|
849
|
+
...h
|
|
850
|
+
}) {
|
|
851
|
+
const { monthKey: f, scroll: g } = ee("PhotoCalendarScrollView"), w = B(null), D = B(null), p = B(null), v = B(/* @__PURE__ */ new Map()), x = Math.max(1, d), T = P(
|
|
852
|
+
(e, n) => {
|
|
853
|
+
const o = [e];
|
|
854
|
+
let i = e, C = e;
|
|
855
|
+
for (; o.length < n; ) {
|
|
856
|
+
const u = g.getAdjacentMonthKey(i, -1), b = g.getAdjacentMonthKey(C, 1);
|
|
857
|
+
if (u && !o.includes(u) && (o.unshift(u), i = u), o.length >= n || (b && !o.includes(b) && (o.push(b), C = b), !u && !b)) break;
|
|
858
|
+
}
|
|
859
|
+
return o;
|
|
860
|
+
},
|
|
861
|
+
[g]
|
|
862
|
+
), [E, Y] = ve(
|
|
863
|
+
() => T(f, Math.min(3, x))
|
|
864
|
+
);
|
|
865
|
+
J(() => {
|
|
866
|
+
v.current.forEach((e, n) => {
|
|
867
|
+
E.includes(n) || v.current.delete(n);
|
|
868
|
+
});
|
|
869
|
+
}, [E]);
|
|
870
|
+
const S = P(
|
|
871
|
+
(e) => (n) => {
|
|
872
|
+
if (!n) {
|
|
873
|
+
v.current.delete(e);
|
|
874
|
+
return;
|
|
875
|
+
}
|
|
876
|
+
v.current.set(e, n);
|
|
877
|
+
},
|
|
878
|
+
[]
|
|
879
|
+
), k = P(
|
|
880
|
+
(e) => {
|
|
881
|
+
Y((n) => {
|
|
882
|
+
if (n.length === 0) return n;
|
|
883
|
+
const o = e === "prev" ? n[0] : n[n.length - 1], i = e === "prev" ? -1 : 1, C = g.getAdjacentMonthKey(o, i);
|
|
884
|
+
if (!C || n.includes(C)) return n;
|
|
885
|
+
const u = e === "prev" ? [C, ...n] : [...n, C];
|
|
886
|
+
return u.length <= x ? u : e === "prev" ? u.slice(0, x) : u.slice(u.length - x);
|
|
887
|
+
});
|
|
888
|
+
},
|
|
889
|
+
[x, g]
|
|
890
|
+
), I = P(
|
|
891
|
+
(e) => {
|
|
892
|
+
Y((n) => n.includes(e) ? n : T(e, x));
|
|
893
|
+
},
|
|
894
|
+
[T, x]
|
|
895
|
+
), [$, U] = ve(f), F = B($), M = B(!1), K = B(!1), R = B(null), j = B(null), te = B(/* @__PURE__ */ new Map()), z = P((e, n = "smooth") => {
|
|
896
|
+
const o = v.current.get(e), i = w.current;
|
|
897
|
+
if (!(!o || !i))
|
|
898
|
+
if (typeof o.scrollIntoView == "function")
|
|
899
|
+
o.scrollIntoView({ block: "start", behavior: n });
|
|
900
|
+
else {
|
|
901
|
+
const C = o.offsetTop - i.offsetTop;
|
|
902
|
+
i.scrollTop = C;
|
|
903
|
+
}
|
|
904
|
+
}, []);
|
|
905
|
+
J(() => {
|
|
906
|
+
if (I(f), K.current) return;
|
|
907
|
+
const e = requestAnimationFrame(() => {
|
|
908
|
+
K.current = !0, F.current !== f && (F.current = f, U(f)), M.current = !0, z(f, "auto"), requestAnimationFrame(() => {
|
|
909
|
+
M.current = !1;
|
|
910
|
+
});
|
|
911
|
+
});
|
|
912
|
+
return () => cancelAnimationFrame(e);
|
|
913
|
+
}, [I, f, z]), J(() => {
|
|
914
|
+
if (R.current === f) {
|
|
915
|
+
R.current = null;
|
|
916
|
+
return;
|
|
917
|
+
}
|
|
918
|
+
F.current !== f && (F.current = f, U(f)), K.current && (I(f), M.current = !0, z(f), requestAnimationFrame(() => {
|
|
919
|
+
M.current = !1;
|
|
920
|
+
}));
|
|
921
|
+
}, [I, f, z]);
|
|
922
|
+
const W = Tt({
|
|
923
|
+
containerRef: w,
|
|
924
|
+
monthRefs: v,
|
|
925
|
+
monthKeys: E,
|
|
926
|
+
threshold: 0.01
|
|
927
|
+
});
|
|
928
|
+
J(() => {
|
|
929
|
+
W.forEach((e) => {
|
|
930
|
+
const n = v.current.get(e);
|
|
931
|
+
if (!n) return;
|
|
932
|
+
const o = n.getBoundingClientRect();
|
|
933
|
+
o.height > 0 && te.current.set(e, o.height);
|
|
934
|
+
});
|
|
935
|
+
}, [W, v]), J(() => {
|
|
936
|
+
const e = w.current, n = D.current, o = p.current;
|
|
937
|
+
if (!e || !n || !o || typeof IntersectionObserver > "u") return;
|
|
938
|
+
let i = null, C = null;
|
|
939
|
+
return i = requestAnimationFrame(() => {
|
|
940
|
+
C = new IntersectionObserver(
|
|
941
|
+
(b) => {
|
|
942
|
+
b.forEach((_) => {
|
|
943
|
+
if (_.isIntersecting)
|
|
944
|
+
if (_.target === n) {
|
|
945
|
+
if (e.scrollTop === 0) return;
|
|
946
|
+
k("prev");
|
|
947
|
+
} else _.target === o && k("next");
|
|
948
|
+
});
|
|
949
|
+
},
|
|
950
|
+
{ root: e, threshold: 0.1 }
|
|
951
|
+
), C.observe(n), C.observe(o);
|
|
952
|
+
}), () => {
|
|
953
|
+
i && cancelAnimationFrame(i), C == null || C.disconnect();
|
|
954
|
+
};
|
|
955
|
+
}, [k]), J(() => {
|
|
956
|
+
const e = w.current;
|
|
957
|
+
if (!e) return;
|
|
958
|
+
const n = () => {
|
|
959
|
+
M.current || (j.current !== null && cancelAnimationFrame(j.current), j.current = requestAnimationFrame(() => {
|
|
960
|
+
j.current = null;
|
|
961
|
+
const o = e.getBoundingClientRect().top;
|
|
962
|
+
let i = E[0] ?? F.current;
|
|
963
|
+
for (const C of E) {
|
|
964
|
+
const u = v.current.get(C);
|
|
965
|
+
if (!u) continue;
|
|
966
|
+
if (u.getBoundingClientRect().top - o <= 2) i = C;
|
|
967
|
+
else break;
|
|
968
|
+
}
|
|
969
|
+
i !== F.current && (F.current = i, U(i), i !== f && (R.current = i, g.syncVisibleMonth(i)));
|
|
970
|
+
}));
|
|
971
|
+
};
|
|
972
|
+
return e.addEventListener("scroll", n, { passive: !0 }), n(), () => {
|
|
973
|
+
e.removeEventListener("scroll", n), j.current !== null && cancelAnimationFrame(j.current);
|
|
974
|
+
};
|
|
975
|
+
}, [E, f, g]);
|
|
976
|
+
const X = N(() => E.map((e) => g.getMonthSnapshot(e)), [E, g]), le = X.find((e) => e.monthKey === $) ?? g.getMonthSnapshot($), { role: Z, ["aria-label"]: se, ...ne } = h, re = Z ?? "grid", ae = se ?? `Photo calendar timeline – currently viewing ${le.monthLabel}`, oe = Ie("calendar-scroll-container", l);
|
|
977
|
+
return /* @__PURE__ */ r.jsx("div", { className: "calendar-scroll-view", children: /* @__PURE__ */ r.jsxs(
|
|
978
|
+
"div",
|
|
979
|
+
{
|
|
980
|
+
...ne,
|
|
981
|
+
role: re,
|
|
982
|
+
"aria-label": ae,
|
|
983
|
+
className: oe,
|
|
984
|
+
ref: w,
|
|
985
|
+
children: [
|
|
986
|
+
/* @__PURE__ */ r.jsx("div", { ref: D, "aria-hidden": "true", className: "calendar-scroll-sentinel" }),
|
|
987
|
+
X.map((e) => {
|
|
988
|
+
const n = e.monthKey === $, o = `calendar-month-${e.monthKey}`, i = W.has(e.monthKey);
|
|
989
|
+
return /* @__PURE__ */ r.jsxs(
|
|
990
|
+
"section",
|
|
991
|
+
{
|
|
992
|
+
className: "calendar-month-section",
|
|
993
|
+
"data-month-key": e.monthKey,
|
|
994
|
+
"aria-labelledby": `${o}-header`,
|
|
995
|
+
ref: S(e.monthKey),
|
|
996
|
+
children: [
|
|
997
|
+
/* @__PURE__ */ r.jsx(
|
|
998
|
+
"div",
|
|
999
|
+
{
|
|
1000
|
+
id: `${o}-header`,
|
|
1001
|
+
className: Ie(
|
|
1002
|
+
"calendar-month-header",
|
|
1003
|
+
n ? "calendar-month-header--active" : void 0
|
|
1004
|
+
),
|
|
1005
|
+
"aria-current": n ? "date" : void 0,
|
|
1006
|
+
children: /* @__PURE__ */ r.jsx("strong", { children: e.monthLabel })
|
|
1007
|
+
}
|
|
1008
|
+
),
|
|
1009
|
+
i ? /* @__PURE__ */ r.jsxs(r.Fragment, { children: [
|
|
1010
|
+
/* @__PURE__ */ r.jsx(Le, { children: a }),
|
|
1011
|
+
/* @__PURE__ */ r.jsx(Be, { renderDay: t, dayStates: e.dayStates })
|
|
1012
|
+
] }) : /* @__PURE__ */ r.jsx("div", { "aria-hidden": "true", style: { height: te.current.get(e.monthKey) ?? 480 } })
|
|
1013
|
+
]
|
|
1014
|
+
},
|
|
1015
|
+
e.monthKey
|
|
1016
|
+
);
|
|
1017
|
+
}),
|
|
1018
|
+
/* @__PURE__ */ r.jsx("div", { ref: p, "aria-hidden": "true", className: "calendar-scroll-sentinel" }),
|
|
1019
|
+
c
|
|
1020
|
+
]
|
|
1021
|
+
}
|
|
1022
|
+
) });
|
|
1023
|
+
}
|
|
1024
|
+
function wt({
|
|
1025
|
+
monthKey: t,
|
|
1026
|
+
defaultMonthKey: a,
|
|
1027
|
+
onMonthChange: c,
|
|
1028
|
+
onDaySelect: d,
|
|
1029
|
+
firstDayOfWeek: l = 0,
|
|
1030
|
+
entries: h,
|
|
1031
|
+
maxThumbnailsPerDay: f = 1,
|
|
1032
|
+
minMonthKey: g,
|
|
1033
|
+
maxMonthKey: w,
|
|
1034
|
+
onRangeChange: D,
|
|
1035
|
+
onVisibleMonthChange: p,
|
|
1036
|
+
locale: v,
|
|
1037
|
+
timeZone: x,
|
|
1038
|
+
renderDayContent: T,
|
|
1039
|
+
renderDay: E,
|
|
1040
|
+
renderNavigation: Y,
|
|
1041
|
+
renderWeekdays: S,
|
|
1042
|
+
children: k,
|
|
1043
|
+
navigationMode: I = "controls",
|
|
1044
|
+
scrollMaxRenderedMonths: $,
|
|
1045
|
+
...U
|
|
1046
|
+
}) {
|
|
1047
|
+
const F = {
|
|
1048
|
+
monthKey: t,
|
|
1049
|
+
defaultMonthKey: a,
|
|
1050
|
+
onMonthChange: c,
|
|
1051
|
+
onDaySelect: d,
|
|
1052
|
+
firstDayOfWeek: l,
|
|
1053
|
+
entries: h,
|
|
1054
|
+
maxThumbnailsPerDay: f,
|
|
1055
|
+
minMonthKey: g,
|
|
1056
|
+
maxMonthKey: w,
|
|
1057
|
+
onRangeChange: D,
|
|
1058
|
+
onVisibleMonthChange: p,
|
|
1059
|
+
locale: v,
|
|
1060
|
+
timeZone: x
|
|
1061
|
+
}, M = E || (T ? (j) => /* @__PURE__ */ r.jsx(Ve, { day: { ...j, defaultContent: T(j) ?? j.defaultContent } }) : void 0), K = Y ? (j) => Y(j) : void 0, R = S ? (j) => S(j) : void 0;
|
|
1062
|
+
return I === "scroll" ? /* @__PURE__ */ r.jsx(Ye, { ...F, children: () => /* @__PURE__ */ r.jsx(
|
|
1063
|
+
Nt,
|
|
1064
|
+
{
|
|
1065
|
+
...U,
|
|
1066
|
+
renderDay: M,
|
|
1067
|
+
renderWeekdays: R,
|
|
1068
|
+
maxRenderedMonths: $,
|
|
1069
|
+
children: k
|
|
1070
|
+
}
|
|
1071
|
+
) }) : /* @__PURE__ */ r.jsx(Ye, { ...F, children: (j) => /* @__PURE__ */ r.jsxs("div", { role: "grid", "aria-label": `Photo calendar for ${j.monthLabel}`, "data-view": "calendar", ...U, children: [
|
|
1072
|
+
/* @__PURE__ */ r.jsx(Ct, { children: K }),
|
|
1073
|
+
/* @__PURE__ */ r.jsx(Le, { children: R }),
|
|
1074
|
+
/* @__PURE__ */ r.jsx(Be, { renderDay: M }),
|
|
1075
|
+
k
|
|
1076
|
+
] }) });
|
|
1077
|
+
}
|
|
1078
|
+
export {
|
|
1079
|
+
wt as PhotoCalendar,
|
|
1080
|
+
rt as PhotoCalendarContextProvider,
|
|
1081
|
+
Ve as PhotoCalendarDay,
|
|
1082
|
+
Be as PhotoCalendarMonthGrid,
|
|
1083
|
+
Ct as PhotoCalendarNavigation,
|
|
1084
|
+
dt as PhotoCalendarNavigationControls,
|
|
1085
|
+
lt as PhotoCalendarNavigationLayout,
|
|
1086
|
+
bt as PhotoCalendarNavigationMonthChips,
|
|
1087
|
+
gt as PhotoCalendarNavigationMonthLabelMobile,
|
|
1088
|
+
vt as PhotoCalendarNavigationNextMonthButton,
|
|
1089
|
+
ft as PhotoCalendarNavigationNextYearButton,
|
|
1090
|
+
mt as PhotoCalendarNavigationPrevMonthButton,
|
|
1091
|
+
ht as PhotoCalendarNavigationPrevYearButton,
|
|
1092
|
+
xt as PhotoCalendarNavigationTodayButton,
|
|
1093
|
+
ut as PhotoCalendarNavigationYearHeading,
|
|
1094
|
+
Ye as PhotoCalendarRoot,
|
|
1095
|
+
Nt as PhotoCalendarScrollView,
|
|
1096
|
+
Le as PhotoCalendarWeekdays,
|
|
1097
|
+
ee as usePhotoCalendarContext,
|
|
1098
|
+
it as usePhotoCalendarState
|
|
1099
|
+
};
|