@keenmate/web-daterangepicker 1.0.0-rc01
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 +197 -0
- package/dist/date-range-picker.js +1768 -0
- package/dist/date-range-picker.umd.js +26 -0
- package/dist/style.css +1 -0
- package/package.json +68 -0
|
@@ -0,0 +1,1768 @@
|
|
|
1
|
+
var Te = Object.defineProperty;
|
|
2
|
+
var Fe = (n, e, t) => e in n ? Te(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var _ = (n, e, t) => Fe(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
const re = Math.min, V = Math.max, U = Math.round, C = (n) => ({
|
|
5
|
+
x: n,
|
|
6
|
+
y: n
|
|
7
|
+
}), Ye = {
|
|
8
|
+
left: "right",
|
|
9
|
+
right: "left",
|
|
10
|
+
bottom: "top",
|
|
11
|
+
top: "bottom"
|
|
12
|
+
}, qe = {
|
|
13
|
+
start: "end",
|
|
14
|
+
end: "start"
|
|
15
|
+
};
|
|
16
|
+
function ue(n, e, t) {
|
|
17
|
+
return V(n, re(e, t));
|
|
18
|
+
}
|
|
19
|
+
function G(n, e) {
|
|
20
|
+
return typeof n == "function" ? n(e) : n;
|
|
21
|
+
}
|
|
22
|
+
function q(n) {
|
|
23
|
+
return n.split("-")[0];
|
|
24
|
+
}
|
|
25
|
+
function Q(n) {
|
|
26
|
+
return n.split("-")[1];
|
|
27
|
+
}
|
|
28
|
+
function De(n) {
|
|
29
|
+
return n === "x" ? "y" : "x";
|
|
30
|
+
}
|
|
31
|
+
function we(n) {
|
|
32
|
+
return n === "y" ? "height" : "width";
|
|
33
|
+
}
|
|
34
|
+
const Oe = /* @__PURE__ */ new Set(["top", "bottom"]);
|
|
35
|
+
function L(n) {
|
|
36
|
+
return Oe.has(q(n)) ? "y" : "x";
|
|
37
|
+
}
|
|
38
|
+
function xe(n) {
|
|
39
|
+
return De(L(n));
|
|
40
|
+
}
|
|
41
|
+
function Ve(n, e, t) {
|
|
42
|
+
t === void 0 && (t = !1);
|
|
43
|
+
const a = Q(n), i = xe(n), r = we(i);
|
|
44
|
+
let o = i === "x" ? a === (t ? "end" : "start") ? "right" : "left" : a === "start" ? "bottom" : "top";
|
|
45
|
+
return e.reference[r] > e.floating[r] && (o = J(o)), [o, J(o)];
|
|
46
|
+
}
|
|
47
|
+
function Ne(n) {
|
|
48
|
+
const e = J(n);
|
|
49
|
+
return [se(n), e, se(e)];
|
|
50
|
+
}
|
|
51
|
+
function se(n) {
|
|
52
|
+
return n.replace(/start|end/g, (e) => qe[e]);
|
|
53
|
+
}
|
|
54
|
+
const fe = ["left", "right"], ge = ["right", "left"], ze = ["top", "bottom"], He = ["bottom", "top"];
|
|
55
|
+
function Be(n, e, t) {
|
|
56
|
+
switch (n) {
|
|
57
|
+
case "top":
|
|
58
|
+
case "bottom":
|
|
59
|
+
return t ? e ? ge : fe : e ? fe : ge;
|
|
60
|
+
case "left":
|
|
61
|
+
case "right":
|
|
62
|
+
return e ? ze : He;
|
|
63
|
+
default:
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function We(n, e, t, a) {
|
|
68
|
+
const i = Q(n);
|
|
69
|
+
let r = Be(q(n), t === "start", a);
|
|
70
|
+
return i && (r = r.map((o) => o + "-" + i), e && (r = r.concat(r.map(se)))), r;
|
|
71
|
+
}
|
|
72
|
+
function J(n) {
|
|
73
|
+
return n.replace(/left|right|bottom|top/g, (e) => Ye[e]);
|
|
74
|
+
}
|
|
75
|
+
function Ke(n) {
|
|
76
|
+
return {
|
|
77
|
+
top: 0,
|
|
78
|
+
right: 0,
|
|
79
|
+
bottom: 0,
|
|
80
|
+
left: 0,
|
|
81
|
+
...n
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
function je(n) {
|
|
85
|
+
return typeof n != "number" ? Ke(n) : {
|
|
86
|
+
top: n,
|
|
87
|
+
right: n,
|
|
88
|
+
bottom: n,
|
|
89
|
+
left: n
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function X(n) {
|
|
93
|
+
const {
|
|
94
|
+
x: e,
|
|
95
|
+
y: t,
|
|
96
|
+
width: a,
|
|
97
|
+
height: i
|
|
98
|
+
} = n;
|
|
99
|
+
return {
|
|
100
|
+
width: a,
|
|
101
|
+
height: i,
|
|
102
|
+
top: t,
|
|
103
|
+
left: e,
|
|
104
|
+
right: e + a,
|
|
105
|
+
bottom: t + i,
|
|
106
|
+
x: e,
|
|
107
|
+
y: t
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
function ye(n, e, t) {
|
|
111
|
+
let {
|
|
112
|
+
reference: a,
|
|
113
|
+
floating: i
|
|
114
|
+
} = n;
|
|
115
|
+
const r = L(e), o = xe(e), s = we(o), l = q(e), c = r === "y", d = a.x + a.width / 2 - i.width / 2, p = a.y + a.height / 2 - i.height / 2, h = a[s] / 2 - i[s] / 2;
|
|
116
|
+
let u;
|
|
117
|
+
switch (l) {
|
|
118
|
+
case "top":
|
|
119
|
+
u = {
|
|
120
|
+
x: d,
|
|
121
|
+
y: a.y - i.height
|
|
122
|
+
};
|
|
123
|
+
break;
|
|
124
|
+
case "bottom":
|
|
125
|
+
u = {
|
|
126
|
+
x: d,
|
|
127
|
+
y: a.y + a.height
|
|
128
|
+
};
|
|
129
|
+
break;
|
|
130
|
+
case "right":
|
|
131
|
+
u = {
|
|
132
|
+
x: a.x + a.width,
|
|
133
|
+
y: p
|
|
134
|
+
};
|
|
135
|
+
break;
|
|
136
|
+
case "left":
|
|
137
|
+
u = {
|
|
138
|
+
x: a.x - i.width,
|
|
139
|
+
y: p
|
|
140
|
+
};
|
|
141
|
+
break;
|
|
142
|
+
default:
|
|
143
|
+
u = {
|
|
144
|
+
x: a.x,
|
|
145
|
+
y: a.y
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
switch (Q(e)) {
|
|
149
|
+
case "start":
|
|
150
|
+
u[o] -= h * (t && c ? -1 : 1);
|
|
151
|
+
break;
|
|
152
|
+
case "end":
|
|
153
|
+
u[o] += h * (t && c ? -1 : 1);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
return u;
|
|
157
|
+
}
|
|
158
|
+
const Ue = async (n, e, t) => {
|
|
159
|
+
const {
|
|
160
|
+
placement: a = "bottom",
|
|
161
|
+
strategy: i = "absolute",
|
|
162
|
+
middleware: r = [],
|
|
163
|
+
platform: o
|
|
164
|
+
} = t, s = r.filter(Boolean), l = await (o.isRTL == null ? void 0 : o.isRTL(e));
|
|
165
|
+
let c = await o.getElementRects({
|
|
166
|
+
reference: n,
|
|
167
|
+
floating: e,
|
|
168
|
+
strategy: i
|
|
169
|
+
}), {
|
|
170
|
+
x: d,
|
|
171
|
+
y: p
|
|
172
|
+
} = ye(c, a, l), h = a, u = {}, f = 0;
|
|
173
|
+
for (let g = 0; g < s.length; g++) {
|
|
174
|
+
const {
|
|
175
|
+
name: y,
|
|
176
|
+
fn: w
|
|
177
|
+
} = s[g], {
|
|
178
|
+
x: D,
|
|
179
|
+
y: v,
|
|
180
|
+
data: k,
|
|
181
|
+
reset: m
|
|
182
|
+
} = await w({
|
|
183
|
+
x: d,
|
|
184
|
+
y: p,
|
|
185
|
+
initialPlacement: a,
|
|
186
|
+
placement: h,
|
|
187
|
+
strategy: i,
|
|
188
|
+
middlewareData: u,
|
|
189
|
+
rects: c,
|
|
190
|
+
platform: o,
|
|
191
|
+
elements: {
|
|
192
|
+
reference: n,
|
|
193
|
+
floating: e
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
d = D ?? d, p = v ?? p, u = {
|
|
197
|
+
...u,
|
|
198
|
+
[y]: {
|
|
199
|
+
...u[y],
|
|
200
|
+
...k
|
|
201
|
+
}
|
|
202
|
+
}, m && f <= 50 && (f++, typeof m == "object" && (m.placement && (h = m.placement), m.rects && (c = m.rects === !0 ? await o.getElementRects({
|
|
203
|
+
reference: n,
|
|
204
|
+
floating: e,
|
|
205
|
+
strategy: i
|
|
206
|
+
}) : m.rects), {
|
|
207
|
+
x: d,
|
|
208
|
+
y: p
|
|
209
|
+
} = ye(c, h, l)), g = -1);
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
x: d,
|
|
213
|
+
y: p,
|
|
214
|
+
placement: h,
|
|
215
|
+
strategy: i,
|
|
216
|
+
middlewareData: u
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
async function be(n, e) {
|
|
220
|
+
var t;
|
|
221
|
+
e === void 0 && (e = {});
|
|
222
|
+
const {
|
|
223
|
+
x: a,
|
|
224
|
+
y: i,
|
|
225
|
+
platform: r,
|
|
226
|
+
rects: o,
|
|
227
|
+
elements: s,
|
|
228
|
+
strategy: l
|
|
229
|
+
} = n, {
|
|
230
|
+
boundary: c = "clippingAncestors",
|
|
231
|
+
rootBoundary: d = "viewport",
|
|
232
|
+
elementContext: p = "floating",
|
|
233
|
+
altBoundary: h = !1,
|
|
234
|
+
padding: u = 0
|
|
235
|
+
} = G(e, n), f = je(u), y = s[h ? p === "floating" ? "reference" : "floating" : p], w = X(await r.getClippingRect({
|
|
236
|
+
element: (t = await (r.isElement == null ? void 0 : r.isElement(y))) == null || t ? y : y.contextElement || await (r.getDocumentElement == null ? void 0 : r.getDocumentElement(s.floating)),
|
|
237
|
+
boundary: c,
|
|
238
|
+
rootBoundary: d,
|
|
239
|
+
strategy: l
|
|
240
|
+
})), D = p === "floating" ? {
|
|
241
|
+
x: a,
|
|
242
|
+
y: i,
|
|
243
|
+
width: o.floating.width,
|
|
244
|
+
height: o.floating.height
|
|
245
|
+
} : o.reference, v = await (r.getOffsetParent == null ? void 0 : r.getOffsetParent(s.floating)), k = await (r.isElement == null ? void 0 : r.isElement(v)) ? await (r.getScale == null ? void 0 : r.getScale(v)) || {
|
|
246
|
+
x: 1,
|
|
247
|
+
y: 1
|
|
248
|
+
} : {
|
|
249
|
+
x: 1,
|
|
250
|
+
y: 1
|
|
251
|
+
}, m = X(r.convertOffsetParentRelativeRectToViewportRelativeRect ? await r.convertOffsetParentRelativeRectToViewportRelativeRect({
|
|
252
|
+
elements: s,
|
|
253
|
+
rect: D,
|
|
254
|
+
offsetParent: v,
|
|
255
|
+
strategy: l
|
|
256
|
+
}) : D);
|
|
257
|
+
return {
|
|
258
|
+
top: (w.top - m.top + f.top) / k.y,
|
|
259
|
+
bottom: (m.bottom - w.bottom + f.bottom) / k.y,
|
|
260
|
+
left: (w.left - m.left + f.left) / k.x,
|
|
261
|
+
right: (m.right - w.right + f.right) / k.x
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
const Je = function(n) {
|
|
265
|
+
return n === void 0 && (n = {}), {
|
|
266
|
+
name: "flip",
|
|
267
|
+
options: n,
|
|
268
|
+
async fn(e) {
|
|
269
|
+
var t, a;
|
|
270
|
+
const {
|
|
271
|
+
placement: i,
|
|
272
|
+
middlewareData: r,
|
|
273
|
+
rects: o,
|
|
274
|
+
initialPlacement: s,
|
|
275
|
+
platform: l,
|
|
276
|
+
elements: c
|
|
277
|
+
} = e, {
|
|
278
|
+
mainAxis: d = !0,
|
|
279
|
+
crossAxis: p = !0,
|
|
280
|
+
fallbackPlacements: h,
|
|
281
|
+
fallbackStrategy: u = "bestFit",
|
|
282
|
+
fallbackAxisSideDirection: f = "none",
|
|
283
|
+
flipAlignment: g = !0,
|
|
284
|
+
...y
|
|
285
|
+
} = G(n, e);
|
|
286
|
+
if ((t = r.arrow) != null && t.alignmentOffset)
|
|
287
|
+
return {};
|
|
288
|
+
const w = q(i), D = L(s), v = q(s) === s, k = await (l.isRTL == null ? void 0 : l.isRTL(c.floating)), m = h || (v || !g ? [J(s)] : Ne(s)), b = f !== "none";
|
|
289
|
+
!h && b && m.push(...We(s, g, f, k));
|
|
290
|
+
const T = [s, ...m], P = await be(e, y), j = [];
|
|
291
|
+
let O = ((a = r.flip) == null ? void 0 : a.overflows) || [];
|
|
292
|
+
if (d && j.push(P[w]), p) {
|
|
293
|
+
const F = Ve(i, o, k);
|
|
294
|
+
j.push(P[F[0]], P[F[1]]);
|
|
295
|
+
}
|
|
296
|
+
if (O = [...O, {
|
|
297
|
+
placement: i,
|
|
298
|
+
overflows: j
|
|
299
|
+
}], !j.every((F) => F <= 0)) {
|
|
300
|
+
var de, pe;
|
|
301
|
+
const F = (((de = r.flip) == null ? void 0 : de.index) || 0) + 1, ne = T[F];
|
|
302
|
+
if (ne && (!(p === "alignment" ? D !== L(ne) : !1) || // We leave the current main axis only if every placement on that axis
|
|
303
|
+
// overflows the main axis.
|
|
304
|
+
O.every((S) => L(S.placement) === D ? S.overflows[0] > 0 : !0)))
|
|
305
|
+
return {
|
|
306
|
+
data: {
|
|
307
|
+
index: F,
|
|
308
|
+
overflows: O
|
|
309
|
+
},
|
|
310
|
+
reset: {
|
|
311
|
+
placement: ne
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
let B = (pe = O.filter((Y) => Y.overflows[0] <= 0).sort((Y, S) => Y.overflows[1] - S.overflows[1])[0]) == null ? void 0 : pe.placement;
|
|
315
|
+
if (!B)
|
|
316
|
+
switch (u) {
|
|
317
|
+
case "bestFit": {
|
|
318
|
+
var he;
|
|
319
|
+
const Y = (he = O.filter((S) => {
|
|
320
|
+
if (b) {
|
|
321
|
+
const A = L(S.placement);
|
|
322
|
+
return A === D || // Create a bias to the `y` side axis due to horizontal
|
|
323
|
+
// reading directions favoring greater width.
|
|
324
|
+
A === "y";
|
|
325
|
+
}
|
|
326
|
+
return !0;
|
|
327
|
+
}).map((S) => [S.placement, S.overflows.filter((A) => A > 0).reduce((A, Re) => A + Re, 0)]).sort((S, A) => S[1] - A[1])[0]) == null ? void 0 : he[0];
|
|
328
|
+
Y && (B = Y);
|
|
329
|
+
break;
|
|
330
|
+
}
|
|
331
|
+
case "initialPlacement":
|
|
332
|
+
B = s;
|
|
333
|
+
break;
|
|
334
|
+
}
|
|
335
|
+
if (i !== B)
|
|
336
|
+
return {
|
|
337
|
+
reset: {
|
|
338
|
+
placement: B
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
return {};
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
}, Xe = /* @__PURE__ */ new Set(["left", "top"]);
|
|
346
|
+
async function Ge(n, e) {
|
|
347
|
+
const {
|
|
348
|
+
placement: t,
|
|
349
|
+
platform: a,
|
|
350
|
+
elements: i
|
|
351
|
+
} = n, r = await (a.isRTL == null ? void 0 : a.isRTL(i.floating)), o = q(t), s = Q(t), l = L(t) === "y", c = Xe.has(o) ? -1 : 1, d = r && l ? -1 : 1, p = G(e, n);
|
|
352
|
+
let {
|
|
353
|
+
mainAxis: h,
|
|
354
|
+
crossAxis: u,
|
|
355
|
+
alignmentAxis: f
|
|
356
|
+
} = typeof p == "number" ? {
|
|
357
|
+
mainAxis: p,
|
|
358
|
+
crossAxis: 0,
|
|
359
|
+
alignmentAxis: null
|
|
360
|
+
} : {
|
|
361
|
+
mainAxis: p.mainAxis || 0,
|
|
362
|
+
crossAxis: p.crossAxis || 0,
|
|
363
|
+
alignmentAxis: p.alignmentAxis
|
|
364
|
+
};
|
|
365
|
+
return s && typeof f == "number" && (u = s === "end" ? f * -1 : f), l ? {
|
|
366
|
+
x: u * d,
|
|
367
|
+
y: h * c
|
|
368
|
+
} : {
|
|
369
|
+
x: h * c,
|
|
370
|
+
y: u * d
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
const Qe = function(n) {
|
|
374
|
+
return n === void 0 && (n = 0), {
|
|
375
|
+
name: "offset",
|
|
376
|
+
options: n,
|
|
377
|
+
async fn(e) {
|
|
378
|
+
var t, a;
|
|
379
|
+
const {
|
|
380
|
+
x: i,
|
|
381
|
+
y: r,
|
|
382
|
+
placement: o,
|
|
383
|
+
middlewareData: s
|
|
384
|
+
} = e, l = await Ge(e, n);
|
|
385
|
+
return o === ((t = s.offset) == null ? void 0 : t.placement) && (a = s.arrow) != null && a.alignmentOffset ? {} : {
|
|
386
|
+
x: i + l.x,
|
|
387
|
+
y: r + l.y,
|
|
388
|
+
data: {
|
|
389
|
+
...l,
|
|
390
|
+
placement: o
|
|
391
|
+
}
|
|
392
|
+
};
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
}, Ze = function(n) {
|
|
396
|
+
return n === void 0 && (n = {}), {
|
|
397
|
+
name: "shift",
|
|
398
|
+
options: n,
|
|
399
|
+
async fn(e) {
|
|
400
|
+
const {
|
|
401
|
+
x: t,
|
|
402
|
+
y: a,
|
|
403
|
+
placement: i
|
|
404
|
+
} = e, {
|
|
405
|
+
mainAxis: r = !0,
|
|
406
|
+
crossAxis: o = !1,
|
|
407
|
+
limiter: s = {
|
|
408
|
+
fn: (y) => {
|
|
409
|
+
let {
|
|
410
|
+
x: w,
|
|
411
|
+
y: D
|
|
412
|
+
} = y;
|
|
413
|
+
return {
|
|
414
|
+
x: w,
|
|
415
|
+
y: D
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
},
|
|
419
|
+
...l
|
|
420
|
+
} = G(n, e), c = {
|
|
421
|
+
x: t,
|
|
422
|
+
y: a
|
|
423
|
+
}, d = await be(e, l), p = L(q(i)), h = De(p);
|
|
424
|
+
let u = c[h], f = c[p];
|
|
425
|
+
if (r) {
|
|
426
|
+
const y = h === "y" ? "top" : "left", w = h === "y" ? "bottom" : "right", D = u + d[y], v = u - d[w];
|
|
427
|
+
u = ue(D, u, v);
|
|
428
|
+
}
|
|
429
|
+
if (o) {
|
|
430
|
+
const y = p === "y" ? "top" : "left", w = p === "y" ? "bottom" : "right", D = f + d[y], v = f - d[w];
|
|
431
|
+
f = ue(D, f, v);
|
|
432
|
+
}
|
|
433
|
+
const g = s.fn({
|
|
434
|
+
...e,
|
|
435
|
+
[h]: u,
|
|
436
|
+
[p]: f
|
|
437
|
+
});
|
|
438
|
+
return {
|
|
439
|
+
...g,
|
|
440
|
+
data: {
|
|
441
|
+
x: g.x - t,
|
|
442
|
+
y: g.y - a,
|
|
443
|
+
enabled: {
|
|
444
|
+
[h]: r,
|
|
445
|
+
[p]: o
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
function Z() {
|
|
453
|
+
return typeof window < "u";
|
|
454
|
+
}
|
|
455
|
+
function H(n) {
|
|
456
|
+
return Se(n) ? (n.nodeName || "").toLowerCase() : "#document";
|
|
457
|
+
}
|
|
458
|
+
function x(n) {
|
|
459
|
+
var e;
|
|
460
|
+
return (n == null || (e = n.ownerDocument) == null ? void 0 : e.defaultView) || window;
|
|
461
|
+
}
|
|
462
|
+
function $(n) {
|
|
463
|
+
var e;
|
|
464
|
+
return (e = (Se(n) ? n.ownerDocument : n.document) || window.document) == null ? void 0 : e.documentElement;
|
|
465
|
+
}
|
|
466
|
+
function Se(n) {
|
|
467
|
+
return Z() ? n instanceof Node || n instanceof x(n).Node : !1;
|
|
468
|
+
}
|
|
469
|
+
function I(n) {
|
|
470
|
+
return Z() ? n instanceof Element || n instanceof x(n).Element : !1;
|
|
471
|
+
}
|
|
472
|
+
function E(n) {
|
|
473
|
+
return Z() ? n instanceof HTMLElement || n instanceof x(n).HTMLElement : !1;
|
|
474
|
+
}
|
|
475
|
+
function me(n) {
|
|
476
|
+
return !Z() || typeof ShadowRoot > "u" ? !1 : n instanceof ShadowRoot || n instanceof x(n).ShadowRoot;
|
|
477
|
+
}
|
|
478
|
+
const et = /* @__PURE__ */ new Set(["inline", "contents"]);
|
|
479
|
+
function K(n) {
|
|
480
|
+
const {
|
|
481
|
+
overflow: e,
|
|
482
|
+
overflowX: t,
|
|
483
|
+
overflowY: a,
|
|
484
|
+
display: i
|
|
485
|
+
} = M(n);
|
|
486
|
+
return /auto|scroll|overlay|hidden|clip/.test(e + a + t) && !et.has(i);
|
|
487
|
+
}
|
|
488
|
+
const tt = /* @__PURE__ */ new Set(["table", "td", "th"]);
|
|
489
|
+
function at(n) {
|
|
490
|
+
return tt.has(H(n));
|
|
491
|
+
}
|
|
492
|
+
const nt = [":popover-open", ":modal"];
|
|
493
|
+
function ee(n) {
|
|
494
|
+
return nt.some((e) => {
|
|
495
|
+
try {
|
|
496
|
+
return n.matches(e);
|
|
497
|
+
} catch {
|
|
498
|
+
return !1;
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
const it = ["transform", "translate", "scale", "rotate", "perspective"], rt = ["transform", "translate", "scale", "rotate", "perspective", "filter"], st = ["paint", "layout", "strict", "content"];
|
|
503
|
+
function ce(n) {
|
|
504
|
+
const e = le(), t = I(n) ? M(n) : n;
|
|
505
|
+
return it.some((a) => t[a] ? t[a] !== "none" : !1) || (t.containerType ? t.containerType !== "normal" : !1) || !e && (t.backdropFilter ? t.backdropFilter !== "none" : !1) || !e && (t.filter ? t.filter !== "none" : !1) || rt.some((a) => (t.willChange || "").includes(a)) || st.some((a) => (t.contain || "").includes(a));
|
|
506
|
+
}
|
|
507
|
+
function ot(n) {
|
|
508
|
+
let e = R(n);
|
|
509
|
+
for (; E(e) && !z(e); ) {
|
|
510
|
+
if (ce(e))
|
|
511
|
+
return e;
|
|
512
|
+
if (ee(e))
|
|
513
|
+
return null;
|
|
514
|
+
e = R(e);
|
|
515
|
+
}
|
|
516
|
+
return null;
|
|
517
|
+
}
|
|
518
|
+
function le() {
|
|
519
|
+
return typeof CSS > "u" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
|
|
520
|
+
}
|
|
521
|
+
const ct = /* @__PURE__ */ new Set(["html", "body", "#document"]);
|
|
522
|
+
function z(n) {
|
|
523
|
+
return ct.has(H(n));
|
|
524
|
+
}
|
|
525
|
+
function M(n) {
|
|
526
|
+
return x(n).getComputedStyle(n);
|
|
527
|
+
}
|
|
528
|
+
function te(n) {
|
|
529
|
+
return I(n) ? {
|
|
530
|
+
scrollLeft: n.scrollLeft,
|
|
531
|
+
scrollTop: n.scrollTop
|
|
532
|
+
} : {
|
|
533
|
+
scrollLeft: n.scrollX,
|
|
534
|
+
scrollTop: n.scrollY
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function R(n) {
|
|
538
|
+
if (H(n) === "html")
|
|
539
|
+
return n;
|
|
540
|
+
const e = (
|
|
541
|
+
// Step into the shadow DOM of the parent of a slotted node.
|
|
542
|
+
n.assignedSlot || // DOM Element detected.
|
|
543
|
+
n.parentNode || // ShadowRoot detected.
|
|
544
|
+
me(n) && n.host || // Fallback.
|
|
545
|
+
$(n)
|
|
546
|
+
);
|
|
547
|
+
return me(e) ? e.host : e;
|
|
548
|
+
}
|
|
549
|
+
function Ie(n) {
|
|
550
|
+
const e = R(n);
|
|
551
|
+
return z(e) ? n.ownerDocument ? n.ownerDocument.body : n.body : E(e) && K(e) ? e : Ie(e);
|
|
552
|
+
}
|
|
553
|
+
function Me(n, e, t) {
|
|
554
|
+
var a;
|
|
555
|
+
e === void 0 && (e = []);
|
|
556
|
+
const i = Ie(n), r = i === ((a = n.ownerDocument) == null ? void 0 : a.body), o = x(i);
|
|
557
|
+
return r ? (oe(o), e.concat(o, o.visualViewport || [], K(i) ? i : [], [])) : e.concat(i, Me(i, []));
|
|
558
|
+
}
|
|
559
|
+
function oe(n) {
|
|
560
|
+
return n.parent && Object.getPrototypeOf(n.parent) ? n.frameElement : null;
|
|
561
|
+
}
|
|
562
|
+
function Ce(n) {
|
|
563
|
+
const e = M(n);
|
|
564
|
+
let t = parseFloat(e.width) || 0, a = parseFloat(e.height) || 0;
|
|
565
|
+
const i = E(n), r = i ? n.offsetWidth : t, o = i ? n.offsetHeight : a, s = U(t) !== r || U(a) !== o;
|
|
566
|
+
return s && (t = r, a = o), {
|
|
567
|
+
width: t,
|
|
568
|
+
height: a,
|
|
569
|
+
$: s
|
|
570
|
+
};
|
|
571
|
+
}
|
|
572
|
+
function Ee(n) {
|
|
573
|
+
return I(n) ? n : n.contextElement;
|
|
574
|
+
}
|
|
575
|
+
function N(n) {
|
|
576
|
+
const e = Ee(n);
|
|
577
|
+
if (!E(e))
|
|
578
|
+
return C(1);
|
|
579
|
+
const t = e.getBoundingClientRect(), {
|
|
580
|
+
width: a,
|
|
581
|
+
height: i,
|
|
582
|
+
$: r
|
|
583
|
+
} = Ce(e);
|
|
584
|
+
let o = (r ? U(t.width) : t.width) / a, s = (r ? U(t.height) : t.height) / i;
|
|
585
|
+
return (!o || !Number.isFinite(o)) && (o = 1), (!s || !Number.isFinite(s)) && (s = 1), {
|
|
586
|
+
x: o,
|
|
587
|
+
y: s
|
|
588
|
+
};
|
|
589
|
+
}
|
|
590
|
+
const lt = /* @__PURE__ */ C(0);
|
|
591
|
+
function Pe(n) {
|
|
592
|
+
const e = x(n);
|
|
593
|
+
return !le() || !e.visualViewport ? lt : {
|
|
594
|
+
x: e.visualViewport.offsetLeft,
|
|
595
|
+
y: e.visualViewport.offsetTop
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
function dt(n, e, t) {
|
|
599
|
+
return e === void 0 && (e = !1), !t || e && t !== x(n) ? !1 : e;
|
|
600
|
+
}
|
|
601
|
+
function W(n, e, t, a) {
|
|
602
|
+
e === void 0 && (e = !1), t === void 0 && (t = !1);
|
|
603
|
+
const i = n.getBoundingClientRect(), r = Ee(n);
|
|
604
|
+
let o = C(1);
|
|
605
|
+
e && (a ? I(a) && (o = N(a)) : o = N(n));
|
|
606
|
+
const s = dt(r, t, a) ? Pe(r) : C(0);
|
|
607
|
+
let l = (i.left + s.x) / o.x, c = (i.top + s.y) / o.y, d = i.width / o.x, p = i.height / o.y;
|
|
608
|
+
if (r) {
|
|
609
|
+
const h = x(r), u = a && I(a) ? x(a) : a;
|
|
610
|
+
let f = h, g = oe(f);
|
|
611
|
+
for (; g && a && u !== f; ) {
|
|
612
|
+
const y = N(g), w = g.getBoundingClientRect(), D = M(g), v = w.left + (g.clientLeft + parseFloat(D.paddingLeft)) * y.x, k = w.top + (g.clientTop + parseFloat(D.paddingTop)) * y.y;
|
|
613
|
+
l *= y.x, c *= y.y, d *= y.x, p *= y.y, l += v, c += k, f = x(g), g = oe(f);
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return X({
|
|
617
|
+
width: d,
|
|
618
|
+
height: p,
|
|
619
|
+
x: l,
|
|
620
|
+
y: c
|
|
621
|
+
});
|
|
622
|
+
}
|
|
623
|
+
function ae(n, e) {
|
|
624
|
+
const t = te(n).scrollLeft;
|
|
625
|
+
return e ? e.left + t : W($(n)).left + t;
|
|
626
|
+
}
|
|
627
|
+
function $e(n, e) {
|
|
628
|
+
const t = n.getBoundingClientRect(), a = t.left + e.scrollLeft - ae(n, t), i = t.top + e.scrollTop;
|
|
629
|
+
return {
|
|
630
|
+
x: a,
|
|
631
|
+
y: i
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
function pt(n) {
|
|
635
|
+
let {
|
|
636
|
+
elements: e,
|
|
637
|
+
rect: t,
|
|
638
|
+
offsetParent: a,
|
|
639
|
+
strategy: i
|
|
640
|
+
} = n;
|
|
641
|
+
const r = i === "fixed", o = $(a), s = e ? ee(e.floating) : !1;
|
|
642
|
+
if (a === o || s && r)
|
|
643
|
+
return t;
|
|
644
|
+
let l = {
|
|
645
|
+
scrollLeft: 0,
|
|
646
|
+
scrollTop: 0
|
|
647
|
+
}, c = C(1);
|
|
648
|
+
const d = C(0), p = E(a);
|
|
649
|
+
if ((p || !p && !r) && ((H(a) !== "body" || K(o)) && (l = te(a)), E(a))) {
|
|
650
|
+
const u = W(a);
|
|
651
|
+
c = N(a), d.x = u.x + a.clientLeft, d.y = u.y + a.clientTop;
|
|
652
|
+
}
|
|
653
|
+
const h = o && !p && !r ? $e(o, l) : C(0);
|
|
654
|
+
return {
|
|
655
|
+
width: t.width * c.x,
|
|
656
|
+
height: t.height * c.y,
|
|
657
|
+
x: t.x * c.x - l.scrollLeft * c.x + d.x + h.x,
|
|
658
|
+
y: t.y * c.y - l.scrollTop * c.y + d.y + h.y
|
|
659
|
+
};
|
|
660
|
+
}
|
|
661
|
+
function ht(n) {
|
|
662
|
+
return Array.from(n.getClientRects());
|
|
663
|
+
}
|
|
664
|
+
function ut(n) {
|
|
665
|
+
const e = $(n), t = te(n), a = n.ownerDocument.body, i = V(e.scrollWidth, e.clientWidth, a.scrollWidth, a.clientWidth), r = V(e.scrollHeight, e.clientHeight, a.scrollHeight, a.clientHeight);
|
|
666
|
+
let o = -t.scrollLeft + ae(n);
|
|
667
|
+
const s = -t.scrollTop;
|
|
668
|
+
return M(a).direction === "rtl" && (o += V(e.clientWidth, a.clientWidth) - i), {
|
|
669
|
+
width: i,
|
|
670
|
+
height: r,
|
|
671
|
+
x: o,
|
|
672
|
+
y: s
|
|
673
|
+
};
|
|
674
|
+
}
|
|
675
|
+
const ve = 25;
|
|
676
|
+
function ft(n, e) {
|
|
677
|
+
const t = x(n), a = $(n), i = t.visualViewport;
|
|
678
|
+
let r = a.clientWidth, o = a.clientHeight, s = 0, l = 0;
|
|
679
|
+
if (i) {
|
|
680
|
+
r = i.width, o = i.height;
|
|
681
|
+
const d = le();
|
|
682
|
+
(!d || d && e === "fixed") && (s = i.offsetLeft, l = i.offsetTop);
|
|
683
|
+
}
|
|
684
|
+
const c = ae(a);
|
|
685
|
+
if (c <= 0) {
|
|
686
|
+
const d = a.ownerDocument, p = d.body, h = getComputedStyle(p), u = d.compatMode === "CSS1Compat" && parseFloat(h.marginLeft) + parseFloat(h.marginRight) || 0, f = Math.abs(a.clientWidth - p.clientWidth - u);
|
|
687
|
+
f <= ve && (r -= f);
|
|
688
|
+
} else c <= ve && (r += c);
|
|
689
|
+
return {
|
|
690
|
+
width: r,
|
|
691
|
+
height: o,
|
|
692
|
+
x: s,
|
|
693
|
+
y: l
|
|
694
|
+
};
|
|
695
|
+
}
|
|
696
|
+
const gt = /* @__PURE__ */ new Set(["absolute", "fixed"]);
|
|
697
|
+
function yt(n, e) {
|
|
698
|
+
const t = W(n, !0, e === "fixed"), a = t.top + n.clientTop, i = t.left + n.clientLeft, r = E(n) ? N(n) : C(1), o = n.clientWidth * r.x, s = n.clientHeight * r.y, l = i * r.x, c = a * r.y;
|
|
699
|
+
return {
|
|
700
|
+
width: o,
|
|
701
|
+
height: s,
|
|
702
|
+
x: l,
|
|
703
|
+
y: c
|
|
704
|
+
};
|
|
705
|
+
}
|
|
706
|
+
function _e(n, e, t) {
|
|
707
|
+
let a;
|
|
708
|
+
if (e === "viewport")
|
|
709
|
+
a = ft(n, t);
|
|
710
|
+
else if (e === "document")
|
|
711
|
+
a = ut($(n));
|
|
712
|
+
else if (I(e))
|
|
713
|
+
a = yt(e, t);
|
|
714
|
+
else {
|
|
715
|
+
const i = Pe(n);
|
|
716
|
+
a = {
|
|
717
|
+
x: e.x - i.x,
|
|
718
|
+
y: e.y - i.y,
|
|
719
|
+
width: e.width,
|
|
720
|
+
height: e.height
|
|
721
|
+
};
|
|
722
|
+
}
|
|
723
|
+
return X(a);
|
|
724
|
+
}
|
|
725
|
+
function Ae(n, e) {
|
|
726
|
+
const t = R(n);
|
|
727
|
+
return t === e || !I(t) || z(t) ? !1 : M(t).position === "fixed" || Ae(t, e);
|
|
728
|
+
}
|
|
729
|
+
function mt(n, e) {
|
|
730
|
+
const t = e.get(n);
|
|
731
|
+
if (t)
|
|
732
|
+
return t;
|
|
733
|
+
let a = Me(n, []).filter((s) => I(s) && H(s) !== "body"), i = null;
|
|
734
|
+
const r = M(n).position === "fixed";
|
|
735
|
+
let o = r ? R(n) : n;
|
|
736
|
+
for (; I(o) && !z(o); ) {
|
|
737
|
+
const s = M(o), l = ce(o);
|
|
738
|
+
!l && s.position === "fixed" && (i = null), (r ? !l && !i : !l && s.position === "static" && !!i && gt.has(i.position) || K(o) && !l && Ae(n, o)) ? a = a.filter((d) => d !== o) : i = s, o = R(o);
|
|
739
|
+
}
|
|
740
|
+
return e.set(n, a), a;
|
|
741
|
+
}
|
|
742
|
+
function vt(n) {
|
|
743
|
+
let {
|
|
744
|
+
element: e,
|
|
745
|
+
boundary: t,
|
|
746
|
+
rootBoundary: a,
|
|
747
|
+
strategy: i
|
|
748
|
+
} = n;
|
|
749
|
+
const o = [...t === "clippingAncestors" ? ee(e) ? [] : mt(e, this._c) : [].concat(t), a], s = o[0], l = o.reduce((c, d) => {
|
|
750
|
+
const p = _e(e, d, i);
|
|
751
|
+
return c.top = V(p.top, c.top), c.right = re(p.right, c.right), c.bottom = re(p.bottom, c.bottom), c.left = V(p.left, c.left), c;
|
|
752
|
+
}, _e(e, s, i));
|
|
753
|
+
return {
|
|
754
|
+
width: l.right - l.left,
|
|
755
|
+
height: l.bottom - l.top,
|
|
756
|
+
x: l.left,
|
|
757
|
+
y: l.top
|
|
758
|
+
};
|
|
759
|
+
}
|
|
760
|
+
function _t(n) {
|
|
761
|
+
const {
|
|
762
|
+
width: e,
|
|
763
|
+
height: t
|
|
764
|
+
} = Ce(n);
|
|
765
|
+
return {
|
|
766
|
+
width: e,
|
|
767
|
+
height: t
|
|
768
|
+
};
|
|
769
|
+
}
|
|
770
|
+
function kt(n, e, t) {
|
|
771
|
+
const a = E(e), i = $(e), r = t === "fixed", o = W(n, !0, r, e);
|
|
772
|
+
let s = {
|
|
773
|
+
scrollLeft: 0,
|
|
774
|
+
scrollTop: 0
|
|
775
|
+
};
|
|
776
|
+
const l = C(0);
|
|
777
|
+
function c() {
|
|
778
|
+
l.x = ae(i);
|
|
779
|
+
}
|
|
780
|
+
if (a || !a && !r)
|
|
781
|
+
if ((H(e) !== "body" || K(i)) && (s = te(e)), a) {
|
|
782
|
+
const u = W(e, !0, r, e);
|
|
783
|
+
l.x = u.x + e.clientLeft, l.y = u.y + e.clientTop;
|
|
784
|
+
} else i && c();
|
|
785
|
+
r && !a && i && c();
|
|
786
|
+
const d = i && !a && !r ? $e(i, s) : C(0), p = o.left + s.scrollLeft - l.x - d.x, h = o.top + s.scrollTop - l.y - d.y;
|
|
787
|
+
return {
|
|
788
|
+
x: p,
|
|
789
|
+
y: h,
|
|
790
|
+
width: o.width,
|
|
791
|
+
height: o.height
|
|
792
|
+
};
|
|
793
|
+
}
|
|
794
|
+
function ie(n) {
|
|
795
|
+
return M(n).position === "static";
|
|
796
|
+
}
|
|
797
|
+
function ke(n, e) {
|
|
798
|
+
if (!E(n) || M(n).position === "fixed")
|
|
799
|
+
return null;
|
|
800
|
+
if (e)
|
|
801
|
+
return e(n);
|
|
802
|
+
let t = n.offsetParent;
|
|
803
|
+
return $(n) === t && (t = t.ownerDocument.body), t;
|
|
804
|
+
}
|
|
805
|
+
function Le(n, e) {
|
|
806
|
+
const t = x(n);
|
|
807
|
+
if (ee(n))
|
|
808
|
+
return t;
|
|
809
|
+
if (!E(n)) {
|
|
810
|
+
let i = R(n);
|
|
811
|
+
for (; i && !z(i); ) {
|
|
812
|
+
if (I(i) && !ie(i))
|
|
813
|
+
return i;
|
|
814
|
+
i = R(i);
|
|
815
|
+
}
|
|
816
|
+
return t;
|
|
817
|
+
}
|
|
818
|
+
let a = ke(n, e);
|
|
819
|
+
for (; a && at(a) && ie(a); )
|
|
820
|
+
a = ke(a, e);
|
|
821
|
+
return a && z(a) && ie(a) && !ce(a) ? t : a || ot(n) || t;
|
|
822
|
+
}
|
|
823
|
+
const Dt = async function(n) {
|
|
824
|
+
const e = this.getOffsetParent || Le, t = this.getDimensions, a = await t(n.floating);
|
|
825
|
+
return {
|
|
826
|
+
reference: kt(n.reference, await e(n.floating), n.strategy),
|
|
827
|
+
floating: {
|
|
828
|
+
x: 0,
|
|
829
|
+
y: 0,
|
|
830
|
+
width: a.width,
|
|
831
|
+
height: a.height
|
|
832
|
+
}
|
|
833
|
+
};
|
|
834
|
+
};
|
|
835
|
+
function wt(n) {
|
|
836
|
+
return M(n).direction === "rtl";
|
|
837
|
+
}
|
|
838
|
+
const xt = {
|
|
839
|
+
convertOffsetParentRelativeRectToViewportRelativeRect: pt,
|
|
840
|
+
getDocumentElement: $,
|
|
841
|
+
getClippingRect: vt,
|
|
842
|
+
getOffsetParent: Le,
|
|
843
|
+
getElementRects: Dt,
|
|
844
|
+
getClientRects: ht,
|
|
845
|
+
getDimensions: _t,
|
|
846
|
+
getScale: N,
|
|
847
|
+
isElement: I,
|
|
848
|
+
isRTL: wt
|
|
849
|
+
}, bt = Qe, St = Ze, It = Je, Mt = (n, e, t) => {
|
|
850
|
+
const a = /* @__PURE__ */ new Map(), i = {
|
|
851
|
+
platform: xt,
|
|
852
|
+
...t
|
|
853
|
+
}, r = {
|
|
854
|
+
...i.platform,
|
|
855
|
+
_c: a
|
|
856
|
+
};
|
|
857
|
+
return Ue(n, e, {
|
|
858
|
+
...i,
|
|
859
|
+
platform: r
|
|
860
|
+
});
|
|
861
|
+
};
|
|
862
|
+
class Ct {
|
|
863
|
+
constructor(e, t = {}) {
|
|
864
|
+
_(this, "input");
|
|
865
|
+
_(this, "options");
|
|
866
|
+
_(this, "formatInfo");
|
|
867
|
+
_(this, "_previousInputValue");
|
|
868
|
+
_(this, "currentDate");
|
|
869
|
+
_(this, "monthDates");
|
|
870
|
+
_(this, "displayMonths");
|
|
871
|
+
_(this, "selectedDate");
|
|
872
|
+
_(this, "selectedStartDate");
|
|
873
|
+
_(this, "selectedEndDate");
|
|
874
|
+
_(this, "focusedDayIndex");
|
|
875
|
+
_(this, "activeMonthIndex");
|
|
876
|
+
_(this, "showingRollingSelector");
|
|
877
|
+
_(this, "draggingType");
|
|
878
|
+
_(this, "isDragging");
|
|
879
|
+
_(this, "dragStartDate");
|
|
880
|
+
_(this, "originalStartDate");
|
|
881
|
+
_(this, "originalEndDate");
|
|
882
|
+
_(this, "dragPreviewStart");
|
|
883
|
+
_(this, "dragPreviewEnd");
|
|
884
|
+
_(this, "autoScrollInterval");
|
|
885
|
+
_(this, "navInterval");
|
|
886
|
+
_(this, "calendar");
|
|
887
|
+
_(this, "containerElement");
|
|
888
|
+
_(this, "onDragMoveBound");
|
|
889
|
+
_(this, "onDragEndBound");
|
|
890
|
+
_(this, "clickOutsideHandler");
|
|
891
|
+
_(this, "isFirstRender", !0);
|
|
892
|
+
console.log("[DatePicker 4] Constructor called for input:", e), this.input = e, this.containerElement = t.container || document.body, this.options = {
|
|
893
|
+
mode: t.mode || "single",
|
|
894
|
+
position: t.position || "bottom-start",
|
|
895
|
+
monthsToShow: t.monthsToShow || (t.mode === "range" ? 2 : 1),
|
|
896
|
+
format: t.format || "YYYY-MM-DD",
|
|
897
|
+
calendarTrigger: t.calendarTrigger || "auto",
|
|
898
|
+
onSelect: t.onSelect || void 0,
|
|
899
|
+
container: this.containerElement
|
|
900
|
+
}, this.formatInfo = this.parseFormat(this.options.format), console.log("[DatePicker] Format info:", this.formatInfo), this._previousInputValue = "", this.currentDate = /* @__PURE__ */ new Date(), this.monthDates = [];
|
|
901
|
+
const a = /* @__PURE__ */ new Date();
|
|
902
|
+
for (let i = 0; i < this.options.monthsToShow; i++) {
|
|
903
|
+
const r = new Date(a.getFullYear(), a.getMonth() + i, 1);
|
|
904
|
+
this.monthDates.push(r), console.log(`[DatePicker Init] monthDates[${i}] = ${r.getFullYear()}-${r.getMonth() + 1}`);
|
|
905
|
+
}
|
|
906
|
+
if (this.options.mode === "range") {
|
|
907
|
+
this.displayMonths = [];
|
|
908
|
+
for (let i = 0; i < this.options.monthsToShow; i++) {
|
|
909
|
+
const r = new Date(a.getFullYear(), a.getMonth() + i, 1);
|
|
910
|
+
this.displayMonths.push({
|
|
911
|
+
month: r.getMonth(),
|
|
912
|
+
year: r.getFullYear()
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
this.selectedDate = null, this.selectedStartDate = null, this.selectedEndDate = null, this.focusedDayIndex = null, this.activeMonthIndex = 0, this.showingRollingSelector = [];
|
|
917
|
+
for (let i = 0; i < this.options.monthsToShow; i++)
|
|
918
|
+
this.showingRollingSelector.push(!1);
|
|
919
|
+
this.draggingType = null, this.isDragging = !1, this.dragStartDate = null, this.originalStartDate = null, this.originalEndDate = null, this.dragPreviewStart = null, this.dragPreviewEnd = null, this.autoScrollInterval = null, this.init();
|
|
920
|
+
}
|
|
921
|
+
init() {
|
|
922
|
+
console.log("[DatePicker 5] Init called"), this.createCalendar(), this.attachInputListeners(), console.log("[DatePicker 6] Init complete");
|
|
923
|
+
}
|
|
924
|
+
createCalendar() {
|
|
925
|
+
console.log("[DatePicker 7] Creating calendar"), this.calendar = document.createElement("div"), this.calendar.className = "pa-date-picker";
|
|
926
|
+
const e = document.createElement("div");
|
|
927
|
+
e.className = "pa-date-picker__months";
|
|
928
|
+
for (let a = 0; a < this.options.monthsToShow; a++) {
|
|
929
|
+
const i = document.createElement("div");
|
|
930
|
+
i.className = "pa-date-picker__month", i.dataset.monthIndex = a, i.innerHTML = `
|
|
931
|
+
<div class="pa-date-picker__header">
|
|
932
|
+
<button class="pa-date-picker__nav pa-date-picker__nav--prev" data-action="prev" data-month-index="${a}"></button>
|
|
933
|
+
<div class="pa-date-picker__month-year" data-action="toggle-rolling" data-month-index="${a}"></div>
|
|
934
|
+
<button class="pa-date-picker__nav pa-date-picker__nav--next" data-action="next" data-month-index="${a}"></button>
|
|
935
|
+
</div>
|
|
936
|
+
<div class="pa-date-picker__rolling-selector" data-month-index="${a}">
|
|
937
|
+
<div class="pa-date-picker__rolling-list" data-list="years" data-month-index="${a}"></div>
|
|
938
|
+
<div class="pa-date-picker__rolling-list" data-list="months" data-month-index="${a}"></div>
|
|
939
|
+
</div>
|
|
940
|
+
<div class="pa-date-picker__weekdays"></div>
|
|
941
|
+
<div class="pa-date-picker__days" data-month-index="${a}"></div>
|
|
942
|
+
`, e.appendChild(i);
|
|
943
|
+
}
|
|
944
|
+
if (this.calendar.appendChild(e), this.options.mode === "range") {
|
|
945
|
+
const a = document.createElement("div");
|
|
946
|
+
a.className = "pa-date-picker__summary pa-date-picker__summary--hidden", this.calendar.appendChild(a);
|
|
947
|
+
}
|
|
948
|
+
const t = document.createElement("div");
|
|
949
|
+
t.className = "pa-date-picker__actions", t.innerHTML = `
|
|
950
|
+
<button class="pa-date-picker__button pa-date-picker__button--today" data-action="today">Today</button>
|
|
951
|
+
<button class="pa-date-picker__button pa-date-picker__button--clear" data-action="clear">Clear</button>
|
|
952
|
+
${this.options.mode === "range" ? '<button class="pa-date-picker__button pa-date-picker__button--apply" data-action="apply">Apply</button>' : ""}
|
|
953
|
+
`, this.calendar.appendChild(t), this.containerElement.appendChild(this.calendar), console.log("[DatePicker 7b] Calendar appended to container:", this.calendar), this.attachCalendarListeners(), this.showingRollingSelector = new Array(this.options.monthsToShow).fill(!1);
|
|
954
|
+
}
|
|
955
|
+
attachInputListeners() {
|
|
956
|
+
console.log("[DatePicker 8] Attaching input listeners"), this.options.calendarTrigger === "auto" && (this.input.addEventListener("click", () => {
|
|
957
|
+
console.log("[DatePicker 9] Input clicked"), this.show();
|
|
958
|
+
}), this.input.addEventListener("focus", () => {
|
|
959
|
+
console.log("[DatePicker 10] Input focused"), this.show();
|
|
960
|
+
})), this.input.addEventListener("input", (e) => this.handleInputMask(e)), this.input.addEventListener("keydown", (e) => this.handleKeydown(e)), this.input.addEventListener("paste", (e) => this.handlePaste(e));
|
|
961
|
+
}
|
|
962
|
+
attachCalendarListeners() {
|
|
963
|
+
this.calendar.addEventListener("click", (e) => {
|
|
964
|
+
e.stopPropagation();
|
|
965
|
+
const t = e.target.dataset.action, a = parseInt(e.target.dataset.monthIndex);
|
|
966
|
+
if (t === "prev") this.prevMonth(a);
|
|
967
|
+
else if (t === "next") this.nextMonth(a);
|
|
968
|
+
else if (t === "toggle-rolling") this.toggleRollingSelector(a);
|
|
969
|
+
else if (t === "today") this.selectToday();
|
|
970
|
+
else if (t === "clear") this.clear();
|
|
971
|
+
else if (t === "apply") this.apply();
|
|
972
|
+
else if (e.target.closest(".pa-date-picker__day:not(.pa-date-picker__day--disabled)"))
|
|
973
|
+
this.selectDay(e.target.closest(".pa-date-picker__day"));
|
|
974
|
+
else if (e.target.closest("[data-year]")) {
|
|
975
|
+
const i = e.target.closest("[data-year]");
|
|
976
|
+
this.selectYear(parseInt(i.dataset.year), parseInt(i.dataset.monthIndex));
|
|
977
|
+
} else if (e.target.closest("[data-month]")) {
|
|
978
|
+
const i = e.target.closest("[data-month]");
|
|
979
|
+
this.selectMonth(parseInt(i.dataset.month), parseInt(i.dataset.monthIndex));
|
|
980
|
+
}
|
|
981
|
+
}), document.addEventListener("keydown", (e) => {
|
|
982
|
+
var t, a, i, r, o;
|
|
983
|
+
if (this.calendar.classList.contains("pa-date-picker--visible")) {
|
|
984
|
+
if (console.log("[DatePicker Keydown]", e.key, "Ctrl:", e.ctrlKey, "Meta:", e.metaKey, "Shift:", e.shiftKey, "Alt:", e.altKey), e.key === "Escape")
|
|
985
|
+
this.hide(), e.preventDefault();
|
|
986
|
+
else if (e.key === "ArrowUp")
|
|
987
|
+
this.moveFocus(-7), e.preventDefault();
|
|
988
|
+
else if (e.key === "ArrowDown")
|
|
989
|
+
this.moveFocus(7), e.preventDefault();
|
|
990
|
+
else if (e.key === "ArrowLeft") {
|
|
991
|
+
if (e.ctrlKey || e.metaKey) {
|
|
992
|
+
console.log("[DatePicker] Ctrl+Left: Navigate to previous month");
|
|
993
|
+
const s = this.focusedDayIndex;
|
|
994
|
+
this.prevMonth(this.activeMonthIndex), setTimeout(() => {
|
|
995
|
+
var d, p;
|
|
996
|
+
const c = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
997
|
+
this.focusedDayIndex = Math.min(s !== null ? s : 0, c.length - 1), (d = c[this.focusedDayIndex]) == null || d.classList.add("pa-date-picker__day--focused"), (p = c[this.focusedDayIndex]) == null || p.scrollIntoView({ block: "nearest" });
|
|
998
|
+
}, 0);
|
|
999
|
+
} else
|
|
1000
|
+
this.moveFocus(-1);
|
|
1001
|
+
e.preventDefault();
|
|
1002
|
+
} else if (e.key === "ArrowRight") {
|
|
1003
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1004
|
+
console.log("[DatePicker] Ctrl+Right: Navigate to next month");
|
|
1005
|
+
const s = this.focusedDayIndex;
|
|
1006
|
+
this.nextMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1007
|
+
var d, p;
|
|
1008
|
+
const c = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1009
|
+
this.focusedDayIndex = Math.min(s !== null ? s : 0, c.length - 1), (d = c[this.focusedDayIndex]) == null || d.classList.add("pa-date-picker__day--focused"), (p = c[this.focusedDayIndex]) == null || p.scrollIntoView({ block: "nearest" });
|
|
1010
|
+
}, 0);
|
|
1011
|
+
} else
|
|
1012
|
+
this.moveFocus(1);
|
|
1013
|
+
e.preventDefault();
|
|
1014
|
+
} else if (e.key === "Enter")
|
|
1015
|
+
this.focusedDayIndex !== null ? (t = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)")[this.focusedDayIndex]) == null || t.click() : this.hide(), e.preventDefault();
|
|
1016
|
+
else if (e.key === "Tab") {
|
|
1017
|
+
if (this.options.monthsToShow > 1) {
|
|
1018
|
+
const s = e.shiftKey ? -1 : 1, l = this.activeMonthIndex + s;
|
|
1019
|
+
if (l >= 0 && l < this.monthDates.length) {
|
|
1020
|
+
console.log(`[DatePicker] Tab: switching from Col${this.activeMonthIndex} to Col${l}`);
|
|
1021
|
+
const c = this.focusedDayIndex ?? 0;
|
|
1022
|
+
this.activeMonthIndex = l;
|
|
1023
|
+
const d = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`);
|
|
1024
|
+
if (d) {
|
|
1025
|
+
const p = d.querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1026
|
+
this.focusedDayIndex = Math.min(c, p.length - 1), console.log(`[DatePicker Col${this.activeMonthIndex}] Tab: set focusedDayIndex to ${this.focusedDayIndex}`);
|
|
1027
|
+
}
|
|
1028
|
+
this.renderCalendar();
|
|
1029
|
+
}
|
|
1030
|
+
e.preventDefault();
|
|
1031
|
+
}
|
|
1032
|
+
} else if (e.key === "t" || e.key === "T")
|
|
1033
|
+
this.monthDates[this.activeMonthIndex] = /* @__PURE__ */ new Date(), this.renderCalendar(), setTimeout(() => {
|
|
1034
|
+
const l = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)"), c = Array.from(l).findIndex((d) => d.classList.contains("pa-date-picker__day--today"));
|
|
1035
|
+
c !== -1 && (this.focusedDayIndex = c, l[c].classList.add("pa-date-picker__day--focused"), l[c].scrollIntoView({ block: "nearest" }));
|
|
1036
|
+
}, 0), e.preventDefault();
|
|
1037
|
+
else if (e.key === "PageUp") {
|
|
1038
|
+
const s = this.focusedDayIndex;
|
|
1039
|
+
this.prevMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1040
|
+
var d, p;
|
|
1041
|
+
const c = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1042
|
+
this.focusedDayIndex = Math.min(s !== null ? s : 0, c.length - 1), (d = c[this.focusedDayIndex]) == null || d.classList.add("pa-date-picker__day--focused"), (p = c[this.focusedDayIndex]) == null || p.scrollIntoView({ block: "nearest" });
|
|
1043
|
+
}, 0), e.preventDefault();
|
|
1044
|
+
} else if (e.key === "PageDown") {
|
|
1045
|
+
const s = this.focusedDayIndex;
|
|
1046
|
+
this.nextMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1047
|
+
var d, p;
|
|
1048
|
+
const c = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1049
|
+
this.focusedDayIndex = Math.min(s !== null ? s : 0, c.length - 1), (d = c[this.focusedDayIndex]) == null || d.classList.add("pa-date-picker__day--focused"), (p = c[this.focusedDayIndex]) == null || p.scrollIntoView({ block: "nearest" });
|
|
1050
|
+
}, 0), e.preventDefault();
|
|
1051
|
+
} else if (e.key === "Home") {
|
|
1052
|
+
console.log("[DatePicker] Home key pressed, Ctrl:", e.ctrlKey, "Meta:", e.metaKey);
|
|
1053
|
+
const s = this.monthDates[this.activeMonthIndex].getFullYear(), l = this.monthDates[this.activeMonthIndex].getMonth();
|
|
1054
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1055
|
+
console.log("[DatePicker] Ctrl+Home: Navigate to year start");
|
|
1056
|
+
const c = l === 0, d = this.focusedDayIndex === 0;
|
|
1057
|
+
c && d ? (console.log("[DatePicker] Already at Jan 1, going to previous year"), this.monthDates[this.activeMonthIndex] = new Date(s - 1, 0, 1)) : (console.log("[DatePicker] Going to Jan 1 of current year"), this.monthDates[this.activeMonthIndex] = new Date(s, 0, 1)), this.renderCalendar(), setTimeout(() => {
|
|
1058
|
+
var u, f;
|
|
1059
|
+
const h = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1060
|
+
this.focusedDayIndex = 0, (u = h[0]) == null || u.classList.add("pa-date-picker__day--focused"), (f = h[0]) == null || f.scrollIntoView({ block: "nearest" });
|
|
1061
|
+
}, 0);
|
|
1062
|
+
} else if (console.log("[DatePicker] Home: Navigate to first day (cycles to previous month if already there)"), this.focusedDayIndex === 0)
|
|
1063
|
+
console.log("[DatePicker] Already on first day, going to previous month"), this.prevMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1064
|
+
var h, u;
|
|
1065
|
+
const p = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1066
|
+
this.focusedDayIndex = 0, this.calendar.querySelectorAll(".pa-date-picker__day--focused").forEach((f) => f.classList.remove("pa-date-picker__day--focused")), (h = p[0]) == null || h.classList.add("pa-date-picker__day--focused"), (u = p[0]) == null || u.scrollIntoView({ block: "nearest" });
|
|
1067
|
+
}, 0);
|
|
1068
|
+
else {
|
|
1069
|
+
this.focusedDayIndex = 0;
|
|
1070
|
+
const p = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1071
|
+
this.calendar.querySelectorAll(".pa-date-picker__day--focused").forEach((h) => h.classList.remove("pa-date-picker__day--focused")), (a = p[0]) == null || a.classList.add("pa-date-picker__day--focused"), (i = p[0]) == null || i.scrollIntoView({ block: "nearest" });
|
|
1072
|
+
}
|
|
1073
|
+
e.preventDefault();
|
|
1074
|
+
} else if (e.key === "End") {
|
|
1075
|
+
console.log("[DatePicker] End key pressed, Ctrl:", e.ctrlKey, "Meta:", e.metaKey);
|
|
1076
|
+
const s = this.monthDates[this.activeMonthIndex].getFullYear(), l = this.monthDates[this.activeMonthIndex].getMonth();
|
|
1077
|
+
if (e.ctrlKey || e.metaKey) {
|
|
1078
|
+
console.log("[DatePicker] Ctrl+End: Navigate to year end");
|
|
1079
|
+
const c = l === 11, p = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)"), h = this.focusedDayIndex === p.length - 1;
|
|
1080
|
+
c && h ? this.monthDates[this.activeMonthIndex] = new Date(s + 1, 11, 31) : this.monthDates[this.activeMonthIndex] = new Date(s, 11, 31), this.renderCalendar(), setTimeout(() => {
|
|
1081
|
+
var g, y;
|
|
1082
|
+
const f = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1083
|
+
this.focusedDayIndex = f.length - 1, (g = f[this.focusedDayIndex]) == null || g.classList.add("pa-date-picker__day--focused"), (y = f[this.focusedDayIndex]) == null || y.scrollIntoView({ block: "nearest" });
|
|
1084
|
+
}, 0);
|
|
1085
|
+
} else {
|
|
1086
|
+
console.log("[DatePicker] End: Navigate to last day (cycles to next month if already there)");
|
|
1087
|
+
const d = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1088
|
+
this.focusedDayIndex === d.length - 1 ? (console.log("[DatePicker] Already on last day, going to next month"), this.nextMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1089
|
+
var f, g;
|
|
1090
|
+
const u = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`).querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1091
|
+
this.focusedDayIndex = u.length - 1, this.calendar.querySelectorAll(".pa-date-picker__day--focused").forEach((y) => y.classList.remove("pa-date-picker__day--focused")), (f = u[this.focusedDayIndex]) == null || f.classList.add("pa-date-picker__day--focused"), (g = u[this.focusedDayIndex]) == null || g.scrollIntoView({ block: "nearest" });
|
|
1092
|
+
}, 0)) : (this.focusedDayIndex = d.length - 1, this.calendar.querySelectorAll(".pa-date-picker__day--focused").forEach((h) => h.classList.remove("pa-date-picker__day--focused")), (r = d[this.focusedDayIndex]) == null || r.classList.add("pa-date-picker__day--focused"), (o = d[this.focusedDayIndex]) == null || o.scrollIntoView({ block: "nearest" }));
|
|
1093
|
+
}
|
|
1094
|
+
e.preventDefault();
|
|
1095
|
+
}
|
|
1096
|
+
}
|
|
1097
|
+
}), this.clickOutsideHandler = (e) => {
|
|
1098
|
+
var s;
|
|
1099
|
+
const t = e.composedPath(), a = t[0], i = t.includes(this.calendar), r = t.includes(this.input), o = (s = a.closest) == null ? void 0 : s.call(a, "[data-calendar-button]");
|
|
1100
|
+
!i && !r && !o && this.hide();
|
|
1101
|
+
}, document.addEventListener("click", this.clickOutsideHandler);
|
|
1102
|
+
}
|
|
1103
|
+
show() {
|
|
1104
|
+
console.log("[DatePicker 11] Show called - adding visible class"), this.isFirstRender && (this.renderCalendar(), this.isFirstRender = !1), this.calendar.classList.add("pa-date-picker--visible"), console.log("[DatePicker 11a] Calendar classes:", this.calendar.className), this.position(), setTimeout(() => {
|
|
1105
|
+
const e = window.getComputedStyle(this.calendar);
|
|
1106
|
+
console.log("[DatePicker 11e] Calendar display:", e.display, "position:", e.position, "left:", e.left, "top:", e.top, "z-index:", e.zIndex);
|
|
1107
|
+
}, 100);
|
|
1108
|
+
}
|
|
1109
|
+
hide() {
|
|
1110
|
+
if (this.calendar.classList.contains("pa-date-picker--visible")) {
|
|
1111
|
+
this.calendar.classList.remove("pa-date-picker--visible");
|
|
1112
|
+
for (let e = 0; e < this.showingRollingSelector.length; e++)
|
|
1113
|
+
this.showingRollingSelector[e] = !1;
|
|
1114
|
+
this.isFirstRender || this.renderCalendar();
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
toggle() {
|
|
1118
|
+
this.calendar.classList.contains("pa-date-picker--visible") ? this.hide() : this.show();
|
|
1119
|
+
}
|
|
1120
|
+
async position() {
|
|
1121
|
+
console.log("[DatePicker 11b] Position method called");
|
|
1122
|
+
const { x: e, y: t } = await Mt(this.input, this.calendar, {
|
|
1123
|
+
placement: this.options.position,
|
|
1124
|
+
middleware: [bt(8), It(), St({ padding: 8 })]
|
|
1125
|
+
});
|
|
1126
|
+
console.log("[DatePicker 11c] FloatingUI computed position - x:", e, "y:", t), this.calendar.style.left = `${e}px`, this.calendar.style.top = `${t}px`, console.log("[DatePicker 11d] Position applied to calendar");
|
|
1127
|
+
}
|
|
1128
|
+
renderCalendar() {
|
|
1129
|
+
console.log("[DatePicker 18] renderCalendar called, showingRollingSelector:", this.showingRollingSelector, `activeCol: ${this.activeMonthIndex}`), console.log("[DatePicker 18] monthDates array:", this.monthDates.map((e, t) => `Col${t}: ${e.getFullYear()}-${e.getMonth() + 1}`).join(", "));
|
|
1130
|
+
for (let e = 0; e < this.options.monthsToShow; e++)
|
|
1131
|
+
this.showingRollingSelector[e] ? this.renderRollingSelector(e) : this.renderNormalView(e);
|
|
1132
|
+
requestAnimationFrame(() => {
|
|
1133
|
+
for (let e = 0; e < this.options.monthsToShow; e++) {
|
|
1134
|
+
const t = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${e}"]`);
|
|
1135
|
+
if (!t) continue;
|
|
1136
|
+
const a = t.querySelector(".pa-date-picker__weekdays"), i = t.querySelector(".pa-date-picker__days"), r = t.querySelector(".pa-date-picker__rolling-selector");
|
|
1137
|
+
if (a && i && r) {
|
|
1138
|
+
const o = a.offsetHeight + i.offsetHeight;
|
|
1139
|
+
r.style.height = `${o}px`;
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}), this.options.mode === "range" && !this.isDragging && this.initDragListeners();
|
|
1143
|
+
}
|
|
1144
|
+
renderNormalView(e) {
|
|
1145
|
+
console.log(`[DatePicker Col${e} 19] renderNormalView called for month`, e);
|
|
1146
|
+
const t = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${e}"]`);
|
|
1147
|
+
if (!t) return;
|
|
1148
|
+
t.querySelector(".pa-date-picker__rolling-selector").classList.remove("pa-date-picker__rolling-selector--visible");
|
|
1149
|
+
const i = this.monthDates[e], r = [
|
|
1150
|
+
"January",
|
|
1151
|
+
"February",
|
|
1152
|
+
"March",
|
|
1153
|
+
"April",
|
|
1154
|
+
"May",
|
|
1155
|
+
"June",
|
|
1156
|
+
"July",
|
|
1157
|
+
"August",
|
|
1158
|
+
"September",
|
|
1159
|
+
"October",
|
|
1160
|
+
"November",
|
|
1161
|
+
"December"
|
|
1162
|
+
], o = t.querySelector(".pa-date-picker__month-year");
|
|
1163
|
+
o.textContent = `${r[i.getMonth()]} ${i.getFullYear()}`;
|
|
1164
|
+
const s = t.querySelector(".pa-date-picker__weekdays");
|
|
1165
|
+
s.innerHTML = ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"].map((l) => `<div class="pa-date-picker__weekday">${l}</div>`).join(""), this.renderDays(e, i);
|
|
1166
|
+
}
|
|
1167
|
+
renderDays(e, t) {
|
|
1168
|
+
console.log(`[DatePicker Col${e} 20] renderDays called for month`, e);
|
|
1169
|
+
const a = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${e}"]`);
|
|
1170
|
+
if (!a) return;
|
|
1171
|
+
const i = a.querySelector(".pa-date-picker__days"), r = t.getFullYear(), o = t.getMonth();
|
|
1172
|
+
console.log(`[DatePicker Col${e} 21] Rendering days for:`, r, o + 1);
|
|
1173
|
+
const s = new Date(r, o, 1).getDay(), l = new Date(r, o + 1, 0).getDate(), c = new Date(r, o, 0).getDate(), d = new Date(r, o - 1, 1), p = d.getFullYear(), h = d.getMonth(), u = new Date(r, o + 1, 1), f = u.getFullYear(), g = u.getMonth();
|
|
1174
|
+
let y = "";
|
|
1175
|
+
for (let v = s - 1; v >= 0; v--) {
|
|
1176
|
+
const k = c - v, m = new Date(p, h, k), b = ["pa-date-picker__day", "pa-date-picker__day--other-month"];
|
|
1177
|
+
this.options.mode === "range" && (this.isSameDay(m, this.selectedStartDate) && b.push("pa-date-picker__day--range-start"), this.isSameDay(m, this.selectedEndDate) && b.push("pa-date-picker__day--range-end"), this.isInRange(m) && b.push("pa-date-picker__day--in-range")), y += `<div class="${b.join(" ")}" data-date="${p}-${h}-${k}">${k}</div>`;
|
|
1178
|
+
}
|
|
1179
|
+
for (let v = 1; v <= l; v++) {
|
|
1180
|
+
const k = new Date(r, o, v), m = ["pa-date-picker__day"];
|
|
1181
|
+
this.isToday(k) && m.push("pa-date-picker__day--today"), this.options.mode === "single" && this.isSameDay(k, this.selectedDate) && m.push("pa-date-picker__day--selected"), this.options.mode === "range" && (this.isSameDay(k, this.selectedStartDate) && m.push("pa-date-picker__day--range-start"), this.isSameDay(k, this.selectedEndDate) && m.push("pa-date-picker__day--range-end"), this.isInRange(k) && m.push("pa-date-picker__day--in-range")), y += `<div class="${m.join(" ")}" data-date="${r}-${o}-${v}">${v}</div>`;
|
|
1182
|
+
}
|
|
1183
|
+
const D = Math.ceil((s + l) / 7) * 7 - (s + l);
|
|
1184
|
+
for (let v = 1; v <= D; v++) {
|
|
1185
|
+
const k = new Date(f, g, v), m = ["pa-date-picker__day", "pa-date-picker__day--other-month"];
|
|
1186
|
+
this.options.mode === "range" && (this.isSameDay(k, this.selectedStartDate) && m.push("pa-date-picker__day--range-start"), this.isSameDay(k, this.selectedEndDate) && m.push("pa-date-picker__day--range-end"), this.isInRange(k) && m.push("pa-date-picker__day--in-range")), y += `<div class="${m.join(" ")}" data-date="${f}-${g}-${v}">${v}</div>`;
|
|
1187
|
+
}
|
|
1188
|
+
i.innerHTML = y;
|
|
1189
|
+
}
|
|
1190
|
+
renderRollingSelector(e) {
|
|
1191
|
+
var p, h;
|
|
1192
|
+
const t = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${e}"]`);
|
|
1193
|
+
if (!t) return;
|
|
1194
|
+
const a = t.querySelector(".pa-date-picker__rolling-selector");
|
|
1195
|
+
a.classList.add("pa-date-picker__rolling-selector--visible");
|
|
1196
|
+
const i = this.monthDates[e], r = a.querySelector('[data-list="years"]'), o = i.getFullYear();
|
|
1197
|
+
let s = "";
|
|
1198
|
+
for (let u = o - 50; u <= o + 50; u++)
|
|
1199
|
+
s += `<div class="pa-date-picker__rolling-item ${u === o ? "pa-date-picker__rolling-item--selected" : ""}" data-year="${u}" data-month-index="${e}">${u}</div>`;
|
|
1200
|
+
r.innerHTML = s, (p = r.querySelector(".pa-date-picker__rolling-item--selected")) == null || p.scrollIntoView({ block: "center" });
|
|
1201
|
+
const l = a.querySelector('[data-list="months"]'), c = [
|
|
1202
|
+
"January",
|
|
1203
|
+
"February",
|
|
1204
|
+
"March",
|
|
1205
|
+
"April",
|
|
1206
|
+
"May",
|
|
1207
|
+
"June",
|
|
1208
|
+
"July",
|
|
1209
|
+
"August",
|
|
1210
|
+
"September",
|
|
1211
|
+
"October",
|
|
1212
|
+
"November",
|
|
1213
|
+
"December"
|
|
1214
|
+
], d = i.getMonth();
|
|
1215
|
+
l.innerHTML = c.map((u, f) => `<div class="pa-date-picker__rolling-item ${f === d ? "pa-date-picker__rolling-item--selected" : ""}" data-month="${f}" data-month-index="${e}">${u}</div>`).join(""), (h = l.querySelector(".pa-date-picker__rolling-item--selected")) == null || h.scrollIntoView({ block: "center" });
|
|
1216
|
+
}
|
|
1217
|
+
toggleRollingSelector(e) {
|
|
1218
|
+
this.showingRollingSelector[e] = !this.showingRollingSelector[e], this.renderCalendar();
|
|
1219
|
+
}
|
|
1220
|
+
selectYear(e, t) {
|
|
1221
|
+
const a = this.monthDates[t].getFullYear();
|
|
1222
|
+
this.monthDates[t].setFullYear(e), console.log(`[DatePicker Col${t}] selectYear - changed from ${a} to ${e}`), this.checkAndResolveCollisions(t), this.showingRollingSelector[t] = !1, this.renderCalendar();
|
|
1223
|
+
}
|
|
1224
|
+
selectMonth(e, t) {
|
|
1225
|
+
const a = this.monthDates[t].getMonth();
|
|
1226
|
+
this.monthDates[t].setMonth(e), console.log(`[DatePicker Col${t}] selectMonth - changed from ${a + 1} to ${e + 1}`), this.checkAndResolveCollisions(t), this.showingRollingSelector[t] = !1, this.renderCalendar();
|
|
1227
|
+
}
|
|
1228
|
+
// Check and resolve collisions after changing a column's date
|
|
1229
|
+
checkAndResolveCollisions(e) {
|
|
1230
|
+
const t = this.monthDates[e];
|
|
1231
|
+
if (e < this.monthDates.length - 1) {
|
|
1232
|
+
const a = this.monthDates[e + 1];
|
|
1233
|
+
if (this.isSameOrAfterMonth(t, a)) {
|
|
1234
|
+
console.log(`[DatePicker Col${e}] Collision with Col${e + 1}, shifting forward`);
|
|
1235
|
+
const i = new Date(t.getFullYear(), t.getMonth() + 1, 1);
|
|
1236
|
+
this.monthDates[e + 1] = i, this.checkAndResolveCollisions(e + 1);
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
if (e > 0) {
|
|
1240
|
+
const a = this.monthDates[e - 1];
|
|
1241
|
+
if (this.isSameOrAfterMonth(a, t)) {
|
|
1242
|
+
console.log(`[DatePicker Col${e}] Collision with Col${e - 1}, shifting backward`);
|
|
1243
|
+
const i = new Date(t.getFullYear(), t.getMonth() - 1, 1);
|
|
1244
|
+
this.monthDates[e - 1] = i, this.checkAndResolveCollisions(e - 1);
|
|
1245
|
+
}
|
|
1246
|
+
}
|
|
1247
|
+
}
|
|
1248
|
+
// Helper: Compare if date1 >= date2 (by year-month only)
|
|
1249
|
+
isSameOrAfterMonth(e, t) {
|
|
1250
|
+
const a = e.getFullYear(), i = e.getMonth(), r = t.getFullYear(), o = t.getMonth();
|
|
1251
|
+
return a > r || a === r && i >= o;
|
|
1252
|
+
}
|
|
1253
|
+
prevMonth(e) {
|
|
1254
|
+
const t = isNaN(e) ? this.activeMonthIndex : e, a = this.monthDates[t], i = new Date(a.getFullYear(), a.getMonth() - 1, 1);
|
|
1255
|
+
if (this.monthDates[t] = i, console.log(`[DatePicker Col${t}] prevMonth - changed from ${a.getFullYear()}-${a.getMonth() + 1} to ${i.getFullYear()}-${i.getMonth() + 1}`), t > 0) {
|
|
1256
|
+
const r = this.monthDates[t - 1];
|
|
1257
|
+
this.isSameOrAfterMonth(r, i) && (console.log(`[DatePicker Col${t}] Collision detected with Col${t - 1}, shifting previous columns back`), this.prevMonth(t - 1));
|
|
1258
|
+
}
|
|
1259
|
+
this.renderCalendar();
|
|
1260
|
+
}
|
|
1261
|
+
nextMonth(e) {
|
|
1262
|
+
const t = isNaN(e) ? this.activeMonthIndex : e, a = this.monthDates[t], i = new Date(a.getFullYear(), a.getMonth() + 1, 1);
|
|
1263
|
+
if (this.monthDates[t] = i, console.log(`[DatePicker Col${t}] nextMonth - changed from ${a.getFullYear()}-${a.getMonth() + 1} to ${i.getFullYear()}-${i.getMonth() + 1}`), t < this.monthDates.length - 1) {
|
|
1264
|
+
const r = this.monthDates[t + 1];
|
|
1265
|
+
this.isSameOrAfterMonth(i, r) && (console.log(`[DatePicker Col${t}] Collision detected with Col${t + 1}, shifting next columns forward`), this.nextMonth(t + 1));
|
|
1266
|
+
}
|
|
1267
|
+
this.renderCalendar();
|
|
1268
|
+
}
|
|
1269
|
+
selectDay(e) {
|
|
1270
|
+
if (e.classList.contains("pa-date-picker__day--disabled")) return;
|
|
1271
|
+
if (!e.dataset || !e.dataset.date) {
|
|
1272
|
+
console.warn("[DatePicker] selectDay called with invalid element:", e);
|
|
1273
|
+
return;
|
|
1274
|
+
}
|
|
1275
|
+
const [t, a, i] = e.dataset.date.split("-").map(Number), r = new Date(t, a, i);
|
|
1276
|
+
e.classList.contains("pa-date-picker__day--other-month");
|
|
1277
|
+
const o = e.closest(".pa-date-picker__days");
|
|
1278
|
+
if (o) {
|
|
1279
|
+
this.activeMonthIndex = parseInt(o.dataset.monthIndex) || 0, console.log(`[DatePicker Col${this.activeMonthIndex}] selectDay - activeMonthIndex:`, this.activeMonthIndex);
|
|
1280
|
+
const s = o.querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1281
|
+
this.focusedDayIndex = Array.from(s).indexOf(e), console.log(`[DatePicker Col${this.activeMonthIndex}] selectDay - set focusedDayIndex to:`, this.focusedDayIndex);
|
|
1282
|
+
}
|
|
1283
|
+
this.options.mode === "single" ? (this.selectedDate = r, this.input.value = this.formatDate(r), this.options.onSelect && this.options.onSelect(r), this.hide()) : !this.selectedStartDate || this.selectedEndDate ? (this.selectedStartDate = r, this.selectedEndDate = null, this.input.value = `${this.formatDate(this.selectedStartDate)} - ...`) : (r >= this.selectedStartDate ? this.selectedEndDate = r : (this.selectedEndDate = this.selectedStartDate, this.selectedStartDate = r), this.input.value = `${this.formatDate(this.selectedStartDate)} - ${this.formatDate(this.selectedEndDate)}`, this.options.onSelect && this.options.onSelect({ start: this.selectedStartDate, end: this.selectedEndDate })), this.renderCalendar(), this.updateSummary();
|
|
1284
|
+
}
|
|
1285
|
+
updateSummary() {
|
|
1286
|
+
if (this.options.mode !== "range") return;
|
|
1287
|
+
const e = this.calendar.querySelector(".pa-date-picker__summary");
|
|
1288
|
+
if (e)
|
|
1289
|
+
if (this.selectedStartDate && this.selectedEndDate) {
|
|
1290
|
+
const a = this.selectedEndDate - this.selectedStartDate, i = Math.floor(a / 864e5) + 1, r = i - 1;
|
|
1291
|
+
e.className = "pa-date-picker__summary pa-date-picker__summary--visible", e.innerHTML = `
|
|
1292
|
+
<span class="pa-date-picker__summary-count">${i} ${i === 1 ? "day" : "days"}</span>
|
|
1293
|
+
<span>, </span>
|
|
1294
|
+
<span class="pa-date-picker__summary-count">${r} ${r === 1 ? "night" : "nights"}</span>
|
|
1295
|
+
`;
|
|
1296
|
+
} else
|
|
1297
|
+
e.className = "pa-date-picker__summary pa-date-picker__summary--hidden", e.innerHTML = "";
|
|
1298
|
+
}
|
|
1299
|
+
selectToday() {
|
|
1300
|
+
this.monthDates[this.activeMonthIndex] = /* @__PURE__ */ new Date(), this.selectedDate = /* @__PURE__ */ new Date(), this.input.value = this.formatDate(this.selectedDate), this.options.onSelect && this.options.onSelect(this.selectedDate), this.renderCalendar(), this.options.mode === "single" && this.hide();
|
|
1301
|
+
}
|
|
1302
|
+
clear() {
|
|
1303
|
+
this.selectedDate = null, this.selectedStartDate = null, this.selectedEndDate = null, this.input.value = "", this.renderCalendar(), this.updateSummary();
|
|
1304
|
+
}
|
|
1305
|
+
apply() {
|
|
1306
|
+
this.selectedStartDate && this.selectedEndDate && this.hide();
|
|
1307
|
+
}
|
|
1308
|
+
// === DRAG FUNCTIONALITY ===
|
|
1309
|
+
initDragListeners() {
|
|
1310
|
+
const e = this.calendar.querySelectorAll(".pa-date-picker__day--range-start"), t = this.calendar.querySelectorAll(".pa-date-picker__day--range-end");
|
|
1311
|
+
e.forEach((a) => {
|
|
1312
|
+
a.addEventListener("mousedown", (i) => this.startDrag(i, "start"));
|
|
1313
|
+
}), t.forEach((a) => {
|
|
1314
|
+
a.addEventListener("mousedown", (i) => this.startDrag(i, "end"));
|
|
1315
|
+
});
|
|
1316
|
+
}
|
|
1317
|
+
startDrag(e, t) {
|
|
1318
|
+
e.preventDefault(), e.stopPropagation(), this.isDragging = !0, this.draggingType = t, this.originalStartDate = new Date(this.selectedStartDate), this.originalEndDate = new Date(this.selectedEndDate), e.currentTarget.classList.add("pa-date-picker__day--dragging"), console.log(`[DatePicker Drag] Started dragging ${t} date`), this.onDragMoveBound = this.onDragMove.bind(this), this.onDragEndBound = this.onDragEnd.bind(this), document.addEventListener("mousemove", this.onDragMoveBound), document.addEventListener("mouseup", this.onDragEndBound), document.body.style.cursor = "grabbing";
|
|
1319
|
+
}
|
|
1320
|
+
onDragMove(e) {
|
|
1321
|
+
if (!this.isDragging) return;
|
|
1322
|
+
let t = null;
|
|
1323
|
+
this.containerElement instanceof ShadowRoot && this.containerElement.elementsFromPoint ? t = this.containerElement.elementsFromPoint(e.clientX, e.clientY)[0] || null : t = document.elementFromPoint(e.clientX, e.clientY);
|
|
1324
|
+
const a = t == null ? void 0 : t.closest(".pa-date-picker__nav--prev"), i = t == null ? void 0 : t.closest(".pa-date-picker__nav--next");
|
|
1325
|
+
if (a || i) {
|
|
1326
|
+
if (!this.navInterval) {
|
|
1327
|
+
const p = (a || i).closest(".pa-date-picker__month");
|
|
1328
|
+
if (p) {
|
|
1329
|
+
const h = parseInt(p.dataset.monthIndex), u = !!a;
|
|
1330
|
+
u ? this.prevMonth(h) : this.nextMonth(h), this.navInterval = setInterval(() => {
|
|
1331
|
+
u ? this.prevMonth(h) : this.nextMonth(h);
|
|
1332
|
+
}, 1e3);
|
|
1333
|
+
}
|
|
1334
|
+
}
|
|
1335
|
+
return;
|
|
1336
|
+
} else
|
|
1337
|
+
this.navInterval && (clearInterval(this.navInterval), this.navInterval = null);
|
|
1338
|
+
const r = t;
|
|
1339
|
+
if (!r || !r.classList.contains("pa-date-picker__day") || r.classList.contains("pa-date-picker__day--disabled")) return;
|
|
1340
|
+
const [o, s, l] = r.dataset.date.split("-").map(Number), c = new Date(o, s, l);
|
|
1341
|
+
this.draggingType === "start" ? (this.dragPreviewStart = c, this.dragPreviewEnd = this.originalEndDate, this.dragPreviewStart > this.dragPreviewEnd && ([this.dragPreviewStart, this.dragPreviewEnd] = [this.dragPreviewEnd, this.dragPreviewStart], this.draggingType = "end")) : (this.dragPreviewStart = this.originalStartDate, this.dragPreviewEnd = c, this.dragPreviewEnd < this.dragPreviewStart && ([this.dragPreviewStart, this.dragPreviewEnd] = [this.dragPreviewEnd, this.dragPreviewStart], this.draggingType = "start")), this.updateDragPreview();
|
|
1342
|
+
}
|
|
1343
|
+
updateDragPreview() {
|
|
1344
|
+
if (this.calendar.querySelectorAll(".pa-date-picker__day--drag-preview").forEach((t) => {
|
|
1345
|
+
t.classList.remove("pa-date-picker__day--drag-preview");
|
|
1346
|
+
}), !this.dragPreviewStart || !this.dragPreviewEnd) return;
|
|
1347
|
+
this.calendar.querySelectorAll(".pa-date-picker__day").forEach((t) => {
|
|
1348
|
+
const [a, i, r] = t.dataset.date.split("-").map(Number), o = new Date(a, i, r);
|
|
1349
|
+
o >= this.dragPreviewStart && o <= this.dragPreviewEnd && t.classList.add("pa-date-picker__day--drag-preview");
|
|
1350
|
+
}), this.updateSummaryWithPreview();
|
|
1351
|
+
}
|
|
1352
|
+
updateSummaryWithPreview() {
|
|
1353
|
+
if (this.options.mode !== "range") return;
|
|
1354
|
+
const e = this.calendar.querySelector(".pa-date-picker__summary");
|
|
1355
|
+
if (e && this.dragPreviewStart && this.dragPreviewEnd) {
|
|
1356
|
+
const a = this.dragPreviewEnd - this.dragPreviewStart, i = Math.floor(a / 864e5) + 1, r = i - 1;
|
|
1357
|
+
e.className = "pa-date-picker__summary pa-date-picker__summary--visible", e.innerHTML = `
|
|
1358
|
+
<span style="opacity: 0.7;">Preview: </span>
|
|
1359
|
+
<span class="pa-date-picker__summary-count">${i} ${i === 1 ? "day" : "days"}</span>
|
|
1360
|
+
<span>, </span>
|
|
1361
|
+
<span class="pa-date-picker__summary-count">${r} ${r === 1 ? "night" : "nights"}</span>
|
|
1362
|
+
`;
|
|
1363
|
+
}
|
|
1364
|
+
}
|
|
1365
|
+
onDragEnd(e) {
|
|
1366
|
+
this.isDragging && (console.log("[DatePicker Drag] Ended dragging, finalizing selection"), this.dragPreviewStart && this.dragPreviewEnd && (this.selectedStartDate = this.dragPreviewStart, this.selectedEndDate = this.dragPreviewEnd, this.input.value = `${this.formatDate(this.selectedStartDate)} - ${this.formatDate(this.selectedEndDate)}`, this.options.onSelect && this.options.onSelect({ start: this.selectedStartDate, end: this.selectedEndDate })), this.isDragging = !1, this.draggingType = null, this.dragPreviewStart = null, this.dragPreviewEnd = null, this.calendar.querySelectorAll(".pa-date-picker__day--dragging").forEach((t) => {
|
|
1367
|
+
t.classList.remove("pa-date-picker__day--dragging");
|
|
1368
|
+
}), document.removeEventListener("mousemove", this.onDragMoveBound), document.removeEventListener("mouseup", this.onDragEndBound), this.navInterval && (clearInterval(this.navInterval), this.navInterval = null), document.body.style.cursor = "", this.renderCalendar(), this.updateSummary());
|
|
1369
|
+
}
|
|
1370
|
+
// === END DRAG FUNCTIONALITY ===
|
|
1371
|
+
moveFocus(e) {
|
|
1372
|
+
var r, o, s;
|
|
1373
|
+
console.log(`[DatePicker Col${this.activeMonthIndex}] moveFocus(${e}) - focusedDayIndex:`, this.focusedDayIndex);
|
|
1374
|
+
const t = this.calendar.querySelector(`.pa-date-picker__days[data-month-index="${this.activeMonthIndex}"]`);
|
|
1375
|
+
if (!t) {
|
|
1376
|
+
console.log(`[DatePicker Col${this.activeMonthIndex}] ERROR: daysContainer not found!`);
|
|
1377
|
+
return;
|
|
1378
|
+
}
|
|
1379
|
+
const a = t.querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1380
|
+
if (console.log(`[DatePicker Col${this.activeMonthIndex}] Found ${a.length} days in column`), a.length === 0) return;
|
|
1381
|
+
if (this.focusedDayIndex === null) {
|
|
1382
|
+
const l = Array.from(a).findIndex((c) => c.classList.contains("pa-date-picker__day--today"));
|
|
1383
|
+
this.focusedDayIndex = l !== -1 ? l : 0, console.log(`[DatePicker Col${this.activeMonthIndex}] Initialized focusedDayIndex to ${this.focusedDayIndex} (today or first day), will move by offset ${e}`);
|
|
1384
|
+
}
|
|
1385
|
+
(r = a[this.focusedDayIndex]) == null || r.classList.remove("pa-date-picker__day--focused");
|
|
1386
|
+
const i = this.focusedDayIndex + e;
|
|
1387
|
+
if (i < 0) {
|
|
1388
|
+
const l = this.activeMonthIndex;
|
|
1389
|
+
if (e === -1)
|
|
1390
|
+
console.log(`[DatePicker Col${l}] Edge navigation LEFT: going to last day of prev month`), this.prevMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1391
|
+
var p, h;
|
|
1392
|
+
const c = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${l}"] .pa-date-picker__days`);
|
|
1393
|
+
if (!c) return;
|
|
1394
|
+
const d = c.querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1395
|
+
this.focusedDayIndex = d.length - 1, (p = d[this.focusedDayIndex]) == null || p.classList.add("pa-date-picker__day--focused"), (h = d[this.focusedDayIndex]) == null || h.scrollIntoView({ block: "nearest" });
|
|
1396
|
+
}, 0);
|
|
1397
|
+
else {
|
|
1398
|
+
const c = a[this.focusedDayIndex], [d, p, h] = c.dataset.date.split("-").map(Number), f = new Date(d, p, h).getDay();
|
|
1399
|
+
console.log(`[DatePicker Col${l}] Edge navigation UP: current day ${h} is weekday ${f}, going to prev month`), this.prevMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1400
|
+
var T, P;
|
|
1401
|
+
const g = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${l}"] .pa-date-picker__days`);
|
|
1402
|
+
if (!g) return;
|
|
1403
|
+
const y = g.querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)"), [w, D, v] = y[y.length - 1].dataset.date.split("-").map(Number), m = new Date(w, D, v).getDay(), b = (m - f + 7) % 7;
|
|
1404
|
+
this.focusedDayIndex = y.length - 1 - b, console.log(`[DatePicker Col${l}] Last day weekday ${m}, target ${f}, focusing on day ${this.focusedDayIndex + 1}`), (T = y[this.focusedDayIndex]) == null || T.classList.add("pa-date-picker__day--focused"), (P = y[this.focusedDayIndex]) == null || P.scrollIntoView({ block: "nearest" });
|
|
1405
|
+
}, 0);
|
|
1406
|
+
}
|
|
1407
|
+
return;
|
|
1408
|
+
} else if (i >= a.length) {
|
|
1409
|
+
const l = this.activeMonthIndex;
|
|
1410
|
+
if (e === 1)
|
|
1411
|
+
console.log(`[DatePicker Col${l}] Edge navigation RIGHT: going to first day of next month`), this.nextMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1412
|
+
var p, h;
|
|
1413
|
+
const c = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${l}"] .pa-date-picker__days`);
|
|
1414
|
+
if (!c) return;
|
|
1415
|
+
const d = c.querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)");
|
|
1416
|
+
this.focusedDayIndex = 0, (p = d[this.focusedDayIndex]) == null || p.classList.add("pa-date-picker__day--focused"), (h = d[this.focusedDayIndex]) == null || h.scrollIntoView({ block: "nearest" });
|
|
1417
|
+
}, 0);
|
|
1418
|
+
else {
|
|
1419
|
+
const c = a[this.focusedDayIndex], [d, p, h] = c.dataset.date.split("-").map(Number), f = new Date(d, p, h).getDay();
|
|
1420
|
+
console.log(`[DatePicker Col${l}] Edge navigation DOWN: current day ${h} is weekday ${f}, going to next month`), this.nextMonth(this.activeMonthIndex), setTimeout(() => {
|
|
1421
|
+
var T, P;
|
|
1422
|
+
const g = this.calendar.querySelector(`.pa-date-picker__month[data-month-index="${l}"] .pa-date-picker__days`);
|
|
1423
|
+
if (!g) return;
|
|
1424
|
+
const y = g.querySelectorAll(".pa-date-picker__day:not(.pa-date-picker__day--other-month)"), [w, D, v] = y[0].dataset.date.split("-").map(Number), m = new Date(w, D, v).getDay(), b = (f - m + 7) % 7;
|
|
1425
|
+
this.focusedDayIndex = b, console.log(`[DatePicker Col${l}] First day weekday ${m}, target ${f}, focusing on day ${this.focusedDayIndex + 1}`), (T = y[this.focusedDayIndex]) == null || T.classList.add("pa-date-picker__day--focused"), (P = y[this.focusedDayIndex]) == null || P.scrollIntoView({ block: "nearest" });
|
|
1426
|
+
}, 0);
|
|
1427
|
+
}
|
|
1428
|
+
return;
|
|
1429
|
+
}
|
|
1430
|
+
this.focusedDayIndex = i, (o = a[this.focusedDayIndex]) == null || o.classList.add("pa-date-picker__day--focused"), (s = a[this.focusedDayIndex]) == null || s.scrollIntoView({ block: "nearest" });
|
|
1431
|
+
}
|
|
1432
|
+
// === INPUT MASKING ===
|
|
1433
|
+
handleInputMask(e) {
|
|
1434
|
+
const t = e.target, a = t.value, i = t.selectionStart, r = this._previousInputValue || "", o = a.length < r.length, { separator: s } = this.formatInfo;
|
|
1435
|
+
if (this.options.mode === "range") {
|
|
1436
|
+
const l = a.replace(new RegExp(`[^0-9${s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}to ]`, "gi"), ""), c = this.applyRangeMask(l);
|
|
1437
|
+
if (c !== a) {
|
|
1438
|
+
t.value = c;
|
|
1439
|
+
let d = i;
|
|
1440
|
+
if (o)
|
|
1441
|
+
d = i;
|
|
1442
|
+
else if (c.length > a.length)
|
|
1443
|
+
if (c.includes(" to ") && !a.includes(" to ")) {
|
|
1444
|
+
const p = c.indexOf(" to ");
|
|
1445
|
+
i >= p && i <= p + 4 ? d = p + 4 : d = i + (c.length - a.length);
|
|
1446
|
+
} else
|
|
1447
|
+
d = i + (c.length - a.length);
|
|
1448
|
+
t.setSelectionRange(d, d);
|
|
1449
|
+
}
|
|
1450
|
+
} else {
|
|
1451
|
+
const l = a.replace(new RegExp(`[^0-9${s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}]`, "g"), ""), c = this.applyMask(l);
|
|
1452
|
+
if (c !== a) {
|
|
1453
|
+
t.value = c;
|
|
1454
|
+
let d = i;
|
|
1455
|
+
if (o)
|
|
1456
|
+
d = i;
|
|
1457
|
+
else if (c.length > a.length && c[i] === s)
|
|
1458
|
+
d = i + 1;
|
|
1459
|
+
else if (c.length > a.length) {
|
|
1460
|
+
const p = (a.substring(0, i).match(new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g")) || []).length, u = (c.substring(0, i).match(new RegExp(s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g")) || []).length - p;
|
|
1461
|
+
d = i + u;
|
|
1462
|
+
}
|
|
1463
|
+
t.setSelectionRange(d, d);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
this._previousInputValue = t.value, this.updateCalendarFromInput();
|
|
1467
|
+
}
|
|
1468
|
+
applyMask(e) {
|
|
1469
|
+
var d, p, h;
|
|
1470
|
+
const { separator: t, parts: a, maxLength: i } = this.formatInfo, r = e.replace(new RegExp(t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), ""), o = a.year ? a.year.length : 4, s = [
|
|
1471
|
+
{ type: "year", pos: (d = a.year) == null ? void 0 : d.index, length: o },
|
|
1472
|
+
{ type: "month", pos: (p = a.month) == null ? void 0 : p.index, length: 2 },
|
|
1473
|
+
{ type: "day", pos: (h = a.day) == null ? void 0 : h.index, length: 2 }
|
|
1474
|
+
].sort((u, f) => u.pos - f.pos);
|
|
1475
|
+
let l = "", c = 0;
|
|
1476
|
+
for (let u = 0; u < s.length; u++) {
|
|
1477
|
+
const f = s[u], g = r.substring(c, c + f.length);
|
|
1478
|
+
if (!g) break;
|
|
1479
|
+
l += g, c += g.length, u < s.length - 1 && g.length === f.length && (l += t);
|
|
1480
|
+
}
|
|
1481
|
+
return l.substring(0, i);
|
|
1482
|
+
}
|
|
1483
|
+
applyRangeMask(e) {
|
|
1484
|
+
const { separator: t, maxLength: a } = this.formatInfo, i = " to ";
|
|
1485
|
+
let r = "", o = "";
|
|
1486
|
+
if (e.includes(i)) {
|
|
1487
|
+
const l = e.split(i);
|
|
1488
|
+
r = l[0], o = l.slice(1).join(i);
|
|
1489
|
+
} else
|
|
1490
|
+
r = e;
|
|
1491
|
+
const s = this.applyMask(r);
|
|
1492
|
+
if (s.length === a)
|
|
1493
|
+
if (e.includes(i)) {
|
|
1494
|
+
const l = this.applyMask(o);
|
|
1495
|
+
return s + i + l;
|
|
1496
|
+
} else
|
|
1497
|
+
return s + i;
|
|
1498
|
+
else
|
|
1499
|
+
return s;
|
|
1500
|
+
}
|
|
1501
|
+
handleKeydown(e) {
|
|
1502
|
+
const { key: t, ctrlKey: a, metaKey: i } = e, { separator: r } = this.formatInfo;
|
|
1503
|
+
if (this.calendar.classList.contains("pa-date-picker--visible") && ["ArrowUp", "ArrowDown", "Home", "End", "PageUp", "PageDown"].includes(t)) {
|
|
1504
|
+
e.preventDefault();
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1507
|
+
if (!([
|
|
1508
|
+
"Backspace",
|
|
1509
|
+
"Delete",
|
|
1510
|
+
"Tab",
|
|
1511
|
+
"Escape",
|
|
1512
|
+
"Enter",
|
|
1513
|
+
"ArrowLeft",
|
|
1514
|
+
"ArrowRight",
|
|
1515
|
+
"ArrowUp",
|
|
1516
|
+
"ArrowDown",
|
|
1517
|
+
"Home",
|
|
1518
|
+
"End"
|
|
1519
|
+
].includes(t) || a || i)) {
|
|
1520
|
+
if (t === r) {
|
|
1521
|
+
const s = e.target, l = s.selectionStart, c = s.value;
|
|
1522
|
+
let d = 0;
|
|
1523
|
+
for (let h = l - 1; h >= 0; h--)
|
|
1524
|
+
if (c[h] === r || c[h] === " ") {
|
|
1525
|
+
d = h + 1;
|
|
1526
|
+
break;
|
|
1527
|
+
}
|
|
1528
|
+
const p = c.substring(d, l);
|
|
1529
|
+
if (/^\d$/.test(p)) {
|
|
1530
|
+
e.preventDefault();
|
|
1531
|
+
const h = c.substring(0, d) + "0" + p + r + c.substring(l);
|
|
1532
|
+
s.value = h;
|
|
1533
|
+
const u = d + 2 + r.length;
|
|
1534
|
+
s.setSelectionRange(u, u), this._previousInputValue = h, s.dispatchEvent(new Event("input", { bubbles: !0 }));
|
|
1535
|
+
return;
|
|
1536
|
+
}
|
|
1537
|
+
}
|
|
1538
|
+
this.options.mode === "range" ? !/^\d$/.test(t) && t !== r && t !== " " && t.toLowerCase() !== "t" && t.toLowerCase() !== "o" && e.preventDefault() : !/^\d$/.test(t) && t !== r && e.preventDefault();
|
|
1539
|
+
}
|
|
1540
|
+
}
|
|
1541
|
+
handlePaste(e) {
|
|
1542
|
+
e.preventDefault();
|
|
1543
|
+
const t = (e.clipboardData || window.clipboardData).getData("text"), { separator: a } = this.formatInfo, i = t.replace(new RegExp(`[^0-9${a.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}]`, "g"), ""), r = this.applyMask(i), o = e.target, s = o.selectionStart, l = o.selectionEnd, c = o.value, d = c.substring(0, s) + r + c.substring(l);
|
|
1544
|
+
o.value = this.applyMask(d);
|
|
1545
|
+
const p = s + r.length;
|
|
1546
|
+
o.setSelectionRange(p, p), o.dispatchEvent(new Event("input", { bubbles: !0 })), this.updateCalendarFromInput();
|
|
1547
|
+
}
|
|
1548
|
+
// === END INPUT MASKING ===
|
|
1549
|
+
// Helper methods
|
|
1550
|
+
parseFormat(e) {
|
|
1551
|
+
const t = {};
|
|
1552
|
+
let a = "";
|
|
1553
|
+
return e.includes("-") ? a = "-" : e.includes("/") ? a = "/" : e.includes(".") && (a = "."), e.split(a).forEach((r, o) => {
|
|
1554
|
+
r === "YYYY" || r === "YY" ? t.year = { index: o, length: r.length } : r === "MM" || r === "M" ? t.month = { index: o, length: 2 } : (r === "DD" || r === "D") && (t.day = { index: o, length: 2 });
|
|
1555
|
+
}), {
|
|
1556
|
+
format: e,
|
|
1557
|
+
separator: a,
|
|
1558
|
+
parts: t,
|
|
1559
|
+
maxLength: e.length
|
|
1560
|
+
};
|
|
1561
|
+
}
|
|
1562
|
+
formatDate(e) {
|
|
1563
|
+
if (!e) return "";
|
|
1564
|
+
const t = e.getFullYear(), a = String(e.getMonth() + 1).padStart(2, "0"), i = String(e.getDate()).padStart(2, "0"), { format: r, separator: o, parts: s } = this.formatInfo, l = [];
|
|
1565
|
+
for (let c = 0; c < 3; c++)
|
|
1566
|
+
s.year && s.year.index === c ? l.push(s.year.length === 2 ? String(t).slice(-2) : t) : s.month && s.month.index === c ? l.push(a) : s.day && s.day.index === c && l.push(i);
|
|
1567
|
+
return l.join(o);
|
|
1568
|
+
}
|
|
1569
|
+
parseInputValue(e) {
|
|
1570
|
+
if (!e) return null;
|
|
1571
|
+
const { separator: t, parts: a, maxLength: i } = this.formatInfo;
|
|
1572
|
+
if (e.length !== i) return null;
|
|
1573
|
+
const r = e.split(t);
|
|
1574
|
+
if (r.length !== 3) return null;
|
|
1575
|
+
let o, s, l;
|
|
1576
|
+
if (r.forEach((d, p) => {
|
|
1577
|
+
a.year && a.year.index === p ? (o = parseInt(d, 10), a.year.length === 2 && o < 100 && (o += 2e3)) : a.month && a.month.index === p ? s = parseInt(d, 10) : a.day && a.day.index === p && (l = parseInt(d, 10));
|
|
1578
|
+
}), !o || !s || !l || s < 1 || s > 12 || l < 1 || l > 31) return null;
|
|
1579
|
+
const c = new Date(o, s - 1, l);
|
|
1580
|
+
return c.getMonth() !== s - 1 ? null : c;
|
|
1581
|
+
}
|
|
1582
|
+
parseAndUpdateSingleDate(e, t = "single") {
|
|
1583
|
+
const { separator: a, parts: i, maxLength: r } = this.formatInfo, o = e.split(a);
|
|
1584
|
+
let s = null, l = null, c = null;
|
|
1585
|
+
if (o.forEach((d, p) => {
|
|
1586
|
+
if (d) {
|
|
1587
|
+
if (i.year && i.year.index === p) {
|
|
1588
|
+
const h = parseInt(d, 10);
|
|
1589
|
+
i.year.length === 4 && d.length === 4 ? s = h : i.year.length === 2 && d.length === 2 && (s = h < 100 ? h + 2e3 : h);
|
|
1590
|
+
} else if (i.month && i.month.index === p) {
|
|
1591
|
+
const h = parseInt(d, 10);
|
|
1592
|
+
d.length === 2 && h >= 1 && h <= 12 && (l = h);
|
|
1593
|
+
} else if (i.day && i.day.index === p) {
|
|
1594
|
+
const h = parseInt(d, 10);
|
|
1595
|
+
d.length === 2 && h >= 1 && h <= 31 && (c = h);
|
|
1596
|
+
}
|
|
1597
|
+
}
|
|
1598
|
+
}), console.log(`[DatePicker] parseAndUpdateSingleDate(${t}) - year:`, s, "month:", l, "day:", c), s !== null || l !== null) {
|
|
1599
|
+
const d = s || (/* @__PURE__ */ new Date()).getFullYear(), p = l !== null ? l - 1 : (/* @__PURE__ */ new Date()).getMonth();
|
|
1600
|
+
if (this.options.mode === "single") {
|
|
1601
|
+
this.currentYear = d, this.currentMonth = p, this.monthDates = [];
|
|
1602
|
+
for (let h = 0; h < this.options.monthsToShow; h++) {
|
|
1603
|
+
const u = new Date(d, p + h, 1);
|
|
1604
|
+
this.monthDates.push(u);
|
|
1605
|
+
}
|
|
1606
|
+
} else if (this.options.mode === "range" && (t === "start" || !this.selectedStartDate)) {
|
|
1607
|
+
if (this.displayMonths = [
|
|
1608
|
+
{ month: p, year: d }
|
|
1609
|
+
], this.options.monthsToShow > 1) {
|
|
1610
|
+
const h = new Date(d, p + 1, 1);
|
|
1611
|
+
this.displayMonths.push({
|
|
1612
|
+
month: h.getMonth(),
|
|
1613
|
+
year: h.getFullYear()
|
|
1614
|
+
});
|
|
1615
|
+
}
|
|
1616
|
+
this.monthDates = [];
|
|
1617
|
+
for (let h = 0; h < this.options.monthsToShow; h++) {
|
|
1618
|
+
const u = this.displayMonths[h], f = new Date(u.year, u.month, 1);
|
|
1619
|
+
this.monthDates.push(f);
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
this.renderCalendar();
|
|
1623
|
+
}
|
|
1624
|
+
if (s !== null && l !== null && c !== null) {
|
|
1625
|
+
const d = new Date(s, l - 1, c);
|
|
1626
|
+
d.getMonth() === l - 1 && (t === "single" ? this.selectedDate = d : t === "start" ? this.selectedStartDate = d : t === "end" && (this.selectedEndDate = d), this.renderCalendar(), this.options.mode === "range" && this.updateSummary(), console.log(`[DatePicker] Set ${t} date:`, d));
|
|
1627
|
+
}
|
|
1628
|
+
}
|
|
1629
|
+
updateCalendarFromInput() {
|
|
1630
|
+
const e = this.input.value;
|
|
1631
|
+
if (console.log("[DatePicker] updateCalendarFromInput - value:", e), !e) return;
|
|
1632
|
+
const { separator: t, parts: a, maxLength: i } = this.formatInfo;
|
|
1633
|
+
if (console.log("[DatePicker] Format info:", { separator: t, parts: a, maxLength: i }), this.options.mode === "range" && e.includes(" to ")) {
|
|
1634
|
+
const o = e.split(" to "), s = o[0], l = o[1];
|
|
1635
|
+
console.log("[DatePicker] Range parts - start:", s, "end:", l), this.parseAndUpdateSingleDate(s, "start"), l && this.parseAndUpdateSingleDate(l, "end");
|
|
1636
|
+
return;
|
|
1637
|
+
}
|
|
1638
|
+
const r = this.options.mode === "range" ? "start" : "single";
|
|
1639
|
+
this.parseAndUpdateSingleDate(e, r);
|
|
1640
|
+
}
|
|
1641
|
+
isToday(e) {
|
|
1642
|
+
const t = /* @__PURE__ */ new Date();
|
|
1643
|
+
return this.isSameDay(e, t);
|
|
1644
|
+
}
|
|
1645
|
+
isSameDay(e, t) {
|
|
1646
|
+
return !e || !t ? !1 : e.getFullYear() === t.getFullYear() && e.getMonth() === t.getMonth() && e.getDate() === t.getDate();
|
|
1647
|
+
}
|
|
1648
|
+
isInRange(e) {
|
|
1649
|
+
return !this.selectedStartDate || !this.selectedEndDate ? !1 : e > this.selectedStartDate && e < this.selectedEndDate;
|
|
1650
|
+
}
|
|
1651
|
+
destroy() {
|
|
1652
|
+
this.clickOutsideHandler && document.removeEventListener("click", this.clickOutsideHandler), this.calendar.remove();
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
const Et = '@charset "UTF-8";:root{--drp-card-bg: #ffffff;--drp-border-color: #e5e7eb;--drp-primary-bg: #f3f4f6;--drp-primary-bg-hover: #e5e7eb;--drp-accent-color: #3b82f6;--drp-accent-color-hover: #2563eb;--drp-text-primary: #111827;--drp-text-secondary: #6b7280;--drp-spacing-xs: .25rem;--drp-spacing-sm: .5rem;--drp-spacing-md: 1rem;--drp-spacing-lg: 1.5rem;--drp-spacing-xl: 2rem;--drp-font-size-2xs: .625rem;--drp-font-size-xs: .75rem;--drp-font-size-sm: .875rem;--drp-font-size-base: 1rem;--drp-font-size-lg: 1.125rem;--drp-font-size-xl: 1.25rem;--drp-font-size-2xl: 1.5rem;--drp-font-weight-medium: 500;--drp-font-weight-semibold: 600;--drp-border-width-base: 1px;--drp-border-radius: .375rem;--drp-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / .1), 0 8px 10px -6px rgb(0 0 0 / .1);--drp-transition-fast: .15s;--drp-easing-snappy: cubic-bezier(.4, 0, .2, 1);--drp-input-padding-h: .75rem}.pa-date-picker-input{position:relative;cursor:pointer}.pa-date-picker-input:after{content:"📅";position:absolute;right:var(--drp-input-padding-h);top:50%;transform:translateY(-50%);pointer-events:none;opacity:.6}.pa-date-picker{position:absolute;z-index:9500;background:var(--drp-card-bg);border:var(--drp-border-width-base) solid var(--drp-border-color);border-radius:var(--drp-border-radius);box-shadow:var(--drp-shadow-xl);padding:var(--drp-spacing-md);min-width:280px;-webkit-user-select:none;user-select:none}.pa-date-picker:not(.pa-date-picker--visible){display:none}.pa-date-picker__months{display:flex;gap:var(--drp-spacing-lg)}.pa-date-picker__month{flex:1;min-width:280px}.pa-date-picker__header{display:flex;align-items:center;justify-content:space-between;margin-bottom:var(--drp-spacing-md);gap:var(--drp-spacing-sm)}.pa-date-picker__month-year{flex:1;text-align:center;font-weight:var(--drp-font-weight-semibold);font-size:var(--drp-font-size-base);padding:var(--drp-spacing-sm) var(--drp-spacing-md);border-radius:var(--drp-border-radius);cursor:pointer;transition:background-color var(--drp-transition-fast) var(--drp-easing-snappy)}.pa-date-picker__month-year:hover{background-color:var(--drp-primary-bg)}.pa-date-picker__month-year:active{background-color:var(--drp-primary-bg-hover)}.pa-date-picker__nav{width:2rem;height:2rem;display:flex;align-items:center;justify-content:center;border:var(--drp-border-width-base) solid var(--drp-border-color);border-radius:var(--drp-border-radius);background:transparent;cursor:pointer;transition:all var(--drp-transition-fast) var(--drp-easing-snappy);font-size:var(--drp-font-size-lg);color:var(--drp-text-primary)}.pa-date-picker__nav:hover{background-color:var(--drp-primary-bg);border-color:var(--drp-accent-color)}.pa-date-picker__nav:active{background-color:var(--drp-primary-bg-hover)}.pa-date-picker__nav--prev:before{content:"‹"}.pa-date-picker__nav--next:before{content:"›"}.pa-date-picker__rolling-selector{display:none}.pa-date-picker__rolling-selector.pa-date-picker__rolling-selector--visible{display:flex}.pa-date-picker__rolling-selector.pa-date-picker__rolling-selector--visible~.pa-date-picker__weekdays,.pa-date-picker__rolling-selector.pa-date-picker__rolling-selector--visible~.pa-date-picker__days{display:none}.pa-date-picker__rolling-selector{gap:var(--drp-spacing-md);margin-bottom:var(--drp-spacing-md)}.pa-date-picker__rolling-list{flex:1;height:100%;overflow-y:auto;border:var(--drp-border-width-base) solid var(--drp-border-color);border-radius:var(--drp-border-radius);scroll-behavior:smooth}.pa-date-picker__rolling-list::-webkit-scrollbar{width:6px}.pa-date-picker__rolling-list::-webkit-scrollbar-track{background:var(--drp-primary-bg)}.pa-date-picker__rolling-list::-webkit-scrollbar-thumb{background:var(--drp-border-color);border-radius:3px}.pa-date-picker__rolling-list::-webkit-scrollbar-thumb:hover{background:var(--drp-accent-color)}.pa-date-picker__rolling-item{padding:var(--drp-spacing-sm) var(--drp-spacing-md);text-align:center;cursor:pointer;font-size:var(--drp-font-size-sm);transition:background-color var(--drp-transition-fast) var(--drp-easing-snappy)}.pa-date-picker__rolling-item:hover{background-color:var(--drp-primary-bg)}.pa-date-picker__rolling-item--selected{background-color:var(--drp-accent-color);color:#fff;font-weight:var(--drp-font-weight-semibold)}.pa-date-picker__rolling-item--selected:hover{background-color:var(--drp-accent-color-hover)}.pa-date-picker__weekdays{display:grid;grid-template-columns:repeat(7,1fr);gap:var(--drp-spacing-xs);margin-bottom:var(--drp-spacing-sm)}.pa-date-picker__weekday{text-align:center;font-size:var(--drp-font-size-xs);font-weight:var(--drp-font-weight-semibold);color:var(--drp-text-secondary);padding:var(--drp-spacing-xs);text-transform:uppercase}.pa-date-picker__days{display:grid;grid-template-columns:repeat(7,1fr);gap:var(--drp-spacing-xs);margin-bottom:var(--drp-spacing-md)}.pa-date-picker__day{aspect-ratio:1;display:flex;align-items:center;justify-content:center;font-size:var(--drp-font-size-sm);border-radius:var(--drp-border-radius);cursor:pointer;transition:all var(--drp-transition-fast) var(--drp-easing-snappy);border:2px solid transparent}.pa-date-picker__day:hover:not(.pa-date-picker__day--disabled):not(.pa-date-picker__day--other-month){background-color:var(--drp-primary-bg);border-color:var(--drp-accent-color)}.pa-date-picker__day--today{border-color:var(--drp-accent-color);font-weight:var(--drp-font-weight-semibold)}.pa-date-picker__day--selected{background-color:var(--drp-accent-color);color:#fff;font-weight:var(--drp-font-weight-semibold)}.pa-date-picker__day--selected:hover{background-color:var(--drp-accent-color-hover)}.pa-date-picker__day--focused{outline:2px solid var(--drp-accent-color);outline-offset:2px}.pa-date-picker__day--disabled{color:var(--drp-text-secondary);opacity:.4;cursor:not-allowed}.pa-date-picker__day--disabled:hover{background-color:transparent;border-color:transparent}.pa-date-picker__day--other-month{color:var(--drp-text-secondary);opacity:.5}.pa-date-picker__day--other-month.pa-date-picker__day--range-start,.pa-date-picker__day--other-month.pa-date-picker__day--range-end,.pa-date-picker__day--other-month.pa-date-picker__day--in-range,.pa-date-picker__day--other-month.pa-date-picker__day--drag-preview{opacity:1}.pa-date-picker__day--range-start,.pa-date-picker__day--range-end{background-color:var(--drp-accent-color);color:#fff;font-weight:var(--drp-font-weight-semibold);cursor:grab;-webkit-user-select:none;user-select:none}.pa-date-picker__day--range-start:active,.pa-date-picker__day--range-end:active{cursor:grabbing}.pa-date-picker__day--in-range{background-color:color-mix(in srgb,var(--drp-accent-color) 15%,transparent)}.pa-date-picker__day--in-range:hover{background-color:color-mix(in srgb,var(--drp-accent-color) 25%,transparent)}.pa-date-picker__day--dragging{cursor:grabbing!important;opacity:.7;transform:scale(1.1);transition:transform var(--drp-transition-fast) var(--drp-easing-snappy)}.pa-date-picker__day--drag-preview{background-color:color-mix(in srgb,var(--drp-accent-color) 30%,transparent);border:2px dashed var(--drp-accent-color)}.pa-date-picker__day--drag-preview.pa-date-picker__day--range-start,.pa-date-picker__day--drag-preview.pa-date-picker__day--range-end{background-color:color-mix(in srgb,var(--drp-accent-color) 60%,transparent);color:#fff}.pa-date-picker__summary{text-align:center;padding:var(--drp-spacing-md);border-top:var(--drp-border-width-base) solid var(--drp-border-color);font-size:var(--drp-font-size-sm);color:var(--drp-text-secondary)}.pa-date-picker__summary--visible{display:block}.pa-date-picker__summary--hidden{display:none}.pa-date-picker__summary-count{font-weight:var(--drp-font-weight-semibold);color:var(--drp-accent-color);font-size:var(--drp-font-size-base)}.pa-date-picker__actions{display:flex;gap:var(--drp-spacing-sm);justify-content:space-between;padding-top:var(--drp-spacing-sm);border-top:var(--drp-border-width-base) solid var(--drp-border-color)}.pa-date-picker__button{flex:1;padding:var(--drp-spacing-sm) var(--drp-spacing-md);border:var(--drp-border-width-base) solid var(--drp-border-color);border-radius:var(--drp-border-radius);background:transparent;cursor:pointer;font-size:var(--drp-font-size-sm);font-weight:var(--drp-font-weight-medium);transition:all var(--drp-transition-fast) var(--drp-easing-snappy)}.pa-date-picker__button:hover{background-color:var(--drp-primary-bg);border-color:var(--drp-accent-color)}.pa-date-picker__button--today{color:var(--drp-accent-color)}.pa-date-picker__button--clear{color:var(--drp-text-secondary)}.pa-date-picker__button--apply{background-color:var(--drp-accent-color);color:#fff;border-color:var(--drp-accent-color)}.pa-date-picker__button--apply:hover{background-color:var(--drp-accent-color-hover)}.pa-date-picker__button--cancel{color:var(--drp-text-secondary)}.pa-date-picker--xs{padding:var(--drp-spacing-sm);min-width:240px}.pa-date-picker--xs .pa-date-picker__month-year{font-size:var(--drp-font-size-xs);padding:var(--drp-spacing-xs) var(--drp-spacing-sm)}.pa-date-picker--xs .pa-date-picker__nav{width:1.5rem;height:1.5rem;font-size:var(--drp-font-size-sm)}.pa-date-picker--xs .pa-date-picker__weekday{font-size:var(--drp-font-size-2xs)}.pa-date-picker--xs .pa-date-picker__day{font-size:var(--drp-font-size-xs)}.pa-date-picker--sm{padding:var(--drp-spacing-sm);min-width:260px}.pa-date-picker--sm .pa-date-picker__month-year{font-size:var(--drp-font-size-sm);padding:var(--drp-spacing-xs) var(--drp-spacing-sm)}.pa-date-picker--sm .pa-date-picker__nav{width:1.75rem;height:1.75rem;font-size:var(--drp-font-size-base)}.pa-date-picker--sm .pa-date-picker__day{font-size:var(--drp-font-size-xs)}.pa-date-picker--lg{padding:var(--drp-spacing-lg);min-width:320px}.pa-date-picker--lg .pa-date-picker__month-year{font-size:var(--drp-font-size-lg);padding:var(--drp-spacing-md) var(--drp-spacing-lg)}.pa-date-picker--lg .pa-date-picker__nav{width:2.5rem;height:2.5rem;font-size:var(--drp-font-size-xl)}.pa-date-picker--lg .pa-date-picker__day{font-size:var(--drp-font-size-base)}.pa-date-picker--xl{padding:var(--drp-spacing-xl);min-width:360px}.pa-date-picker--xl .pa-date-picker__month-year{font-size:var(--drp-font-size-xl);padding:var(--drp-spacing-lg) var(--drp-spacing-xl)}.pa-date-picker--xl .pa-date-picker__nav{width:3rem;height:3rem;font-size:var(--drp-font-size-2xl)}.pa-date-picker--xl .pa-date-picker__day{font-size:var(--drp-font-size-lg)}.pa-date-picker--inline{position:static;display:block;box-shadow:none}';
|
|
1656
|
+
class Pt extends HTMLElement {
|
|
1657
|
+
constructor() {
|
|
1658
|
+
super();
|
|
1659
|
+
_(this, "picker");
|
|
1660
|
+
_(this, "inputElement");
|
|
1661
|
+
_(this, "shadow");
|
|
1662
|
+
this.shadow = this.attachShadow({ mode: "open" });
|
|
1663
|
+
}
|
|
1664
|
+
static get observedAttributes() {
|
|
1665
|
+
return ["mode", "format", "months-to-show", "trigger", "value", "disabled", "placeholder"];
|
|
1666
|
+
}
|
|
1667
|
+
connectedCallback() {
|
|
1668
|
+
this.render(), this.initializePicker();
|
|
1669
|
+
}
|
|
1670
|
+
disconnectedCallback() {
|
|
1671
|
+
this.picker && this.picker.destroy();
|
|
1672
|
+
}
|
|
1673
|
+
attributeChangedCallback(t, a, i) {
|
|
1674
|
+
a !== i && (this.picker && t !== "value" && t !== "placeholder" && (this.picker.destroy(), this.initializePicker()), t === "value" && this.inputElement && i !== null && (this.inputElement.value = i), t === "placeholder" && this.inputElement && i !== null && (this.inputElement.placeholder = i), t === "disabled" && this.inputElement && (i !== null ? this.inputElement.disabled = !0 : this.inputElement.disabled = !1));
|
|
1675
|
+
}
|
|
1676
|
+
render() {
|
|
1677
|
+
const t = document.createElement("style");
|
|
1678
|
+
t.textContent = Et, this.inputElement = document.createElement("input"), this.inputElement.type = "text", this.inputElement.classList.add("pa-input", "pa-date-picker-input");
|
|
1679
|
+
const a = this.getAttribute("placeholder");
|
|
1680
|
+
a && (this.inputElement.placeholder = a);
|
|
1681
|
+
const i = this.getAttribute("value");
|
|
1682
|
+
i && (this.inputElement.value = i), this.hasAttribute("disabled") && (this.inputElement.disabled = !0), this.shadow.appendChild(t), this.shadow.appendChild(this.inputElement);
|
|
1683
|
+
}
|
|
1684
|
+
initializePicker() {
|
|
1685
|
+
if (!this.inputElement) return;
|
|
1686
|
+
const t = {
|
|
1687
|
+
mode: this.getAttribute("mode") || "single",
|
|
1688
|
+
format: this.getAttribute("format") || "YYYY-MM-DD",
|
|
1689
|
+
monthsToShow: parseInt(this.getAttribute("months-to-show") || "0") || void 0,
|
|
1690
|
+
calendarTrigger: this.getAttribute("trigger") || "auto",
|
|
1691
|
+
onSelect: (a) => this.handleDateSelect(a),
|
|
1692
|
+
container: this.shadow
|
|
1693
|
+
// Append calendar to shadow root
|
|
1694
|
+
};
|
|
1695
|
+
this.picker = new Ct(this.inputElement, t);
|
|
1696
|
+
}
|
|
1697
|
+
handleDateSelect(t) {
|
|
1698
|
+
var i;
|
|
1699
|
+
const a = {
|
|
1700
|
+
date: t instanceof Date ? t : void 0,
|
|
1701
|
+
dateRange: t instanceof Date ? void 0 : t,
|
|
1702
|
+
formattedValue: ((i = this.inputElement) == null ? void 0 : i.value) || ""
|
|
1703
|
+
};
|
|
1704
|
+
this.dispatchEvent(new CustomEvent("date-select", {
|
|
1705
|
+
detail: a,
|
|
1706
|
+
bubbles: !0,
|
|
1707
|
+
composed: !0
|
|
1708
|
+
})), this.dispatchEvent(new CustomEvent("change", {
|
|
1709
|
+
detail: a,
|
|
1710
|
+
bubbles: !0,
|
|
1711
|
+
composed: !0
|
|
1712
|
+
}));
|
|
1713
|
+
}
|
|
1714
|
+
// Public API methods
|
|
1715
|
+
show() {
|
|
1716
|
+
var t;
|
|
1717
|
+
(t = this.picker) == null || t.show();
|
|
1718
|
+
}
|
|
1719
|
+
hide() {
|
|
1720
|
+
var t;
|
|
1721
|
+
(t = this.picker) == null || t.hide();
|
|
1722
|
+
}
|
|
1723
|
+
toggle() {
|
|
1724
|
+
var t;
|
|
1725
|
+
(t = this.picker) == null || t.toggle();
|
|
1726
|
+
}
|
|
1727
|
+
clear() {
|
|
1728
|
+
var t;
|
|
1729
|
+
(t = this.picker) == null || t.clear();
|
|
1730
|
+
}
|
|
1731
|
+
getValue() {
|
|
1732
|
+
var t;
|
|
1733
|
+
return ((t = this.inputElement) == null ? void 0 : t.value) || "";
|
|
1734
|
+
}
|
|
1735
|
+
setValue(t) {
|
|
1736
|
+
this.inputElement && (this.inputElement.value = t), this.setAttribute("value", t);
|
|
1737
|
+
}
|
|
1738
|
+
// Property accessors
|
|
1739
|
+
get mode() {
|
|
1740
|
+
return this.getAttribute("mode") || "single";
|
|
1741
|
+
}
|
|
1742
|
+
set mode(t) {
|
|
1743
|
+
this.setAttribute("mode", t);
|
|
1744
|
+
}
|
|
1745
|
+
get format() {
|
|
1746
|
+
return this.getAttribute("format") || "YYYY-MM-DD";
|
|
1747
|
+
}
|
|
1748
|
+
set format(t) {
|
|
1749
|
+
this.setAttribute("format", t);
|
|
1750
|
+
}
|
|
1751
|
+
get value() {
|
|
1752
|
+
return this.getValue();
|
|
1753
|
+
}
|
|
1754
|
+
set value(t) {
|
|
1755
|
+
this.setValue(t);
|
|
1756
|
+
}
|
|
1757
|
+
get disabled() {
|
|
1758
|
+
return this.hasAttribute("disabled");
|
|
1759
|
+
}
|
|
1760
|
+
set disabled(t) {
|
|
1761
|
+
t ? this.setAttribute("disabled", "") : this.removeAttribute("disabled");
|
|
1762
|
+
}
|
|
1763
|
+
}
|
|
1764
|
+
customElements.get("date-range-picker") || customElements.define("date-range-picker", Pt);
|
|
1765
|
+
export {
|
|
1766
|
+
Pt as DateRangePickerElement,
|
|
1767
|
+
Ct as PureDatePicker
|
|
1768
|
+
};
|