@nysds/nys-datepicker 1.16.1 → 1.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nys-datepicker.js +68 -56
- package/dist/nys-datepicker.js.map +1 -1
- package/package.json +5 -5
package/dist/nys-datepicker.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LitElement as
|
|
1
|
+
import { LitElement as ne, unsafeCSS as je, html as I } from "lit";
|
|
2
2
|
import { property as g, state as He } from "lit/decorators.js";
|
|
3
3
|
import { ifDefined as M } from "lit/directives/if-defined.js";
|
|
4
4
|
/*!
|
|
@@ -6,7 +6,7 @@ import { ifDefined as M } from "lit/directives/if-defined.js";
|
|
|
6
6
|
* █ █ █ █▄▄▄█ ▀▀▀▄▄ █ █ ▀▀▀▄▄
|
|
7
7
|
* █ ▀█ █ █▄▄▄█ █▄▄▀ █▄▄▄█
|
|
8
8
|
*
|
|
9
|
-
* Datepicker Component v1.
|
|
9
|
+
* Datepicker Component v1.18.0
|
|
10
10
|
* Part of the New York State Design System
|
|
11
11
|
* Repository: https://github.com/its-hcd/nysds
|
|
12
12
|
* License: MIT
|
|
@@ -158,10 +158,10 @@ const h = (t, e, ...a) => {
|
|
|
158
158
|
}, rt = (t, e, a) => {
|
|
159
159
|
const s = b.ce(e, a);
|
|
160
160
|
return t.dispatchEvent(s), s;
|
|
161
|
-
}, he = /* @__PURE__ */ new WeakMap(),
|
|
161
|
+
}, he = /* @__PURE__ */ new WeakMap(), it = (t, e, a) => {
|
|
162
162
|
let s = K.get(t);
|
|
163
163
|
Ot && a ? (s = s || new CSSStyleSheet(), typeof s == "string" ? s = e : s.replaceSync(e)) : s = e, K.set(t, s);
|
|
164
|
-
},
|
|
164
|
+
}, nt = (t, e, a, s) => {
|
|
165
165
|
var r;
|
|
166
166
|
let n = Se(e, a);
|
|
167
167
|
const i = K.get(n);
|
|
@@ -180,11 +180,11 @@ const h = (t, e, ...a) => {
|
|
|
180
180
|
} else t.adoptedStyleSheets.includes(i) || (t.adoptedStyleSheets = [...t.adoptedStyleSheets, i]);
|
|
181
181
|
return n;
|
|
182
182
|
}, ot = (t) => {
|
|
183
|
-
const e = t.$cmpMeta$, a = t.$hostElement$, s = e.$flags$, r = T("attachStyles", e.$tagName$), n =
|
|
183
|
+
const e = t.$cmpMeta$, a = t.$hostElement$, s = e.$flags$, r = T("attachStyles", e.$tagName$), n = nt(a.shadowRoot ? a.shadowRoot : a.getRootNode(), e, t.$modeName$);
|
|
184
184
|
s & 10 && (a["s-sc"] = n, a.classList.add(n + "-h"), s & 2 && a.classList.add(n + "-s")), r();
|
|
185
185
|
}, Se = (t, e) => "sc-" + (e && t.$flags$ & 32 ? t.$tagName$ + "-" + e : t.$tagName$), pe = (t, e, a, s, r, n) => {
|
|
186
186
|
if (a !== s) {
|
|
187
|
-
let i =
|
|
187
|
+
let i = ve(t, e), o = e.toLowerCase();
|
|
188
188
|
if (e === "class") {
|
|
189
189
|
const c = t.classList, l = fe(a), u = fe(s);
|
|
190
190
|
c.remove(...l.filter((d) => d && !u.includes(d))), c.add(...u.filter((d) => d && !l.includes(d)));
|
|
@@ -197,7 +197,7 @@ const h = (t, e, ...a) => {
|
|
|
197
197
|
if (e === "ref")
|
|
198
198
|
s && s(t);
|
|
199
199
|
else if (!t.__lookupSetter__(e) && e[0] === "o" && e[1] === "n")
|
|
200
|
-
e[2] === "-" ? e = e.slice(3) :
|
|
200
|
+
e[2] === "-" ? e = e.slice(3) : ve(Z, o) ? e = o.slice(2) : e = o[2] + e.slice(3), a && b.rel(t, e, a, !1), s && b.ael(t, e, s, !1);
|
|
201
201
|
else {
|
|
202
202
|
const c = re(s);
|
|
203
203
|
if ((i || c && s !== null) && !r)
|
|
@@ -245,18 +245,18 @@ const h = (t, e, ...a) => {
|
|
|
245
245
|
const a = t.childNodes;
|
|
246
246
|
for (let s = a.length - 1; s >= 0; s--) {
|
|
247
247
|
const r = a[s];
|
|
248
|
-
r["s-hn"] !== X && r["s-ol"] && (Le(r).insertBefore(r,
|
|
248
|
+
r["s-hn"] !== X && r["s-ol"] && (Le(r).insertBefore(r, ie(r)), r["s-ol"].remove(), r["s-ol"] = void 0, se = !0), e && q(r, e);
|
|
249
249
|
}
|
|
250
250
|
b.$flags$ &= -2;
|
|
251
251
|
}, Ce = (t, e, a, s, r, n) => {
|
|
252
252
|
let i = t["s-cr"] && t["s-cr"].parentNode || t, o;
|
|
253
253
|
for (i.shadowRoot && i.tagName === X && (i = i.shadowRoot); r <= n; ++r)
|
|
254
|
-
s[r] && (o = H(null, a, r, t), o && (s[r].$elm$ = o, i.insertBefore(o,
|
|
254
|
+
s[r] && (o = H(null, a, r, t), o && (s[r].$elm$ = o, i.insertBefore(o, ie(e))));
|
|
255
255
|
}, Te = (t, e, a, s, r) => {
|
|
256
256
|
for (; e <= a; ++e)
|
|
257
257
|
(s = t[e]) && (r = s.$elm$, Oe(s), z = !0, r["s-ol"] ? r["s-ol"].remove() : q(r, !0), r.remove());
|
|
258
258
|
}, lt = (t, e, a, s) => {
|
|
259
|
-
let r = 0, n = 0, i = 0, o = 0, c = e.length - 1, l = e[0], u = e[c], d = s.length - 1, p = s[0],
|
|
259
|
+
let r = 0, n = 0, i = 0, o = 0, c = e.length - 1, l = e[0], u = e[c], d = s.length - 1, p = s[0], v = s[d], _, S;
|
|
260
260
|
for (; r <= c && n <= d; )
|
|
261
261
|
if (l == null)
|
|
262
262
|
l = e[++r];
|
|
@@ -264,26 +264,26 @@ const h = (t, e, ...a) => {
|
|
|
264
264
|
u = e[--c];
|
|
265
265
|
else if (p == null)
|
|
266
266
|
p = s[++n];
|
|
267
|
-
else if (
|
|
268
|
-
|
|
267
|
+
else if (v == null)
|
|
268
|
+
v = s[--d];
|
|
269
269
|
else if (P(l, p))
|
|
270
270
|
R(l, p), l = e[++r], p = s[++n];
|
|
271
|
-
else if (P(u,
|
|
272
|
-
R(u,
|
|
273
|
-
else if (P(l,
|
|
274
|
-
(l.$tag$ === "slot" ||
|
|
271
|
+
else if (P(u, v))
|
|
272
|
+
R(u, v), u = e[--c], v = s[--d];
|
|
273
|
+
else if (P(l, v))
|
|
274
|
+
(l.$tag$ === "slot" || v.$tag$ === "slot") && q(l.$elm$.parentNode, !1), R(l, v), t.insertBefore(l.$elm$, u.$elm$.nextSibling), l = e[++r], v = s[--d];
|
|
275
275
|
else if (P(u, p))
|
|
276
|
-
(l.$tag$ === "slot" ||
|
|
276
|
+
(l.$tag$ === "slot" || v.$tag$ === "slot") && q(u.$elm$.parentNode, !1), R(u, p), t.insertBefore(u.$elm$, l.$elm$), u = e[--c], p = s[++n];
|
|
277
277
|
else {
|
|
278
278
|
for (i = -1, o = r; o <= c; ++o)
|
|
279
279
|
if (e[o] && e[o].$key$ !== null && e[o].$key$ === p.$key$) {
|
|
280
280
|
i = o;
|
|
281
281
|
break;
|
|
282
282
|
}
|
|
283
|
-
i >= 0 ? (S = e[i], S.$tag$ !== p.$tag$ ? _ = H(e && e[n], a, i, t) : (R(S, p), e[i] = void 0, _ = S.$elm$), p = s[++n]) : (_ = H(e && e[n], a, n, t), p = s[++n]), _ && Le(l.$elm$).insertBefore(_,
|
|
283
|
+
i >= 0 ? (S = e[i], S.$tag$ !== p.$tag$ ? _ = H(e && e[n], a, i, t) : (R(S, p), e[i] = void 0, _ = S.$elm$), p = s[++n]) : (_ = H(e && e[n], a, n, t), p = s[++n]), _ && Le(l.$elm$).insertBefore(_, ie(l.$elm$));
|
|
284
284
|
}
|
|
285
285
|
r > c ? Ce(t, s[d + 1] == null ? null : s[d + 1].$elm$, a, s, n, d) : n > d && Te(e, r, c);
|
|
286
|
-
}, P = (t, e) => t.$tag$ === e.$tag$ ? t.$tag$ === "slot" ? t.$name$ === e.$name$ : t.$key$ === e.$key$ : !1,
|
|
286
|
+
}, P = (t, e) => t.$tag$ === e.$tag$ ? t.$tag$ === "slot" ? t.$name$ === e.$name$ : t.$key$ === e.$key$ : !1, ie = (t) => t && t["s-ol"] || t, Le = (t) => (t["s-ol"] ? t["s-ol"] : t).parentNode, R = (t, e) => {
|
|
287
287
|
const a = e.$elm$ = t.$elm$, s = t.$children$, r = e.$children$, n = e.$tag$, i = e.$text$;
|
|
288
288
|
let o;
|
|
289
289
|
i === null ? ($ = n === "svg" ? !0 : n === "foreignObject" ? !1 : $, n === "slot" || Me(t, e, $), s !== null && r !== null ? lt(a, s, e, r) : r !== null ? (t.$text$ !== null && (a.textContent = ""), Ce(a, null, e, r, 0, r.length - 1)) : s !== null && Te(s, 0, s.length - 1), $ && n === "svg" && ($ = !1)) : (o = a["s-cr"]) ? o.parentNode.textContent = i : t.$text$ !== i && (a.data = i);
|
|
@@ -373,7 +373,7 @@ const h = (t, e, ...a) => {
|
|
|
373
373
|
} catch (s) {
|
|
374
374
|
Y(s);
|
|
375
375
|
}
|
|
376
|
-
}, ge = (t, e) => t && t.then ? t.then(e) : e(), gt = (t, e) => J(t).$instanceValues$.get(e),
|
|
376
|
+
}, ge = (t, e) => t && t.then ? t.then(e) : e(), gt = (t, e) => J(t).$instanceValues$.get(e), vt = (t, e, a, s) => {
|
|
377
377
|
const r = J(t), n = t, i = r.$instanceValues$.get(e), o = r.$flags$, c = n;
|
|
378
378
|
a = at(a, s.$members$[e][0]);
|
|
379
379
|
const l = Number.isNaN(i) && Number.isNaN(a);
|
|
@@ -385,8 +385,8 @@ const h = (t, e, ...a) => {
|
|
|
385
385
|
d && d.map((p) => {
|
|
386
386
|
try {
|
|
387
387
|
c[p](a, i, e);
|
|
388
|
-
} catch (
|
|
389
|
-
Y(
|
|
388
|
+
} catch (v) {
|
|
389
|
+
Y(v, n);
|
|
390
390
|
}
|
|
391
391
|
});
|
|
392
392
|
}
|
|
@@ -397,7 +397,7 @@ const h = (t, e, ...a) => {
|
|
|
397
397
|
}
|
|
398
398
|
}
|
|
399
399
|
}
|
|
400
|
-
},
|
|
400
|
+
}, kt = (t, e, a) => {
|
|
401
401
|
if (e.$members$) {
|
|
402
402
|
t.watchers && (e.$watchers$ = t.watchers);
|
|
403
403
|
const s = Object.entries(e.$members$), r = t.prototype;
|
|
@@ -407,7 +407,7 @@ const h = (t, e, ...a) => {
|
|
|
407
407
|
return gt(this, n);
|
|
408
408
|
},
|
|
409
409
|
set(o) {
|
|
410
|
-
|
|
410
|
+
vt(this, n, o, e);
|
|
411
411
|
},
|
|
412
412
|
configurable: !0,
|
|
413
413
|
enumerable: !0
|
|
@@ -441,7 +441,7 @@ const h = (t, e, ...a) => {
|
|
|
441
441
|
const o = Se(a, e.$modeName$);
|
|
442
442
|
if (!K.has(o)) {
|
|
443
443
|
const c = T("registerStyles", a.$tagName$);
|
|
444
|
-
|
|
444
|
+
it(o, i, !!(a.$flags$ & 1)), c();
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
447
|
e.$ancestorComponent$, Re(e, !0);
|
|
@@ -487,7 +487,7 @@ const h = (t, e, ...a) => {
|
|
|
487
487
|
delegatesFocus: !!(a.$flags$ & 16)
|
|
488
488
|
});
|
|
489
489
|
}
|
|
490
|
-
}), t.is = a.$tagName$,
|
|
490
|
+
}), t.is = a.$tagName$, kt(t, a);
|
|
491
491
|
}, Ne = (t, e, a, s) => {
|
|
492
492
|
a && a.map(([r, n, i]) => {
|
|
493
493
|
const o = St(t, r), c = xt(e, i), l = Mt(r);
|
|
@@ -510,7 +510,7 @@ const h = (t, e, ...a) => {
|
|
|
510
510
|
$instanceValues$: /* @__PURE__ */ new Map()
|
|
511
511
|
};
|
|
512
512
|
return Ne(t, a, e.$listeners$), Ie.set(t, a);
|
|
513
|
-
},
|
|
513
|
+
}, ve = (t, e) => e in t, Y = (t, e) => (0, console.error)(t, e), K = /* @__PURE__ */ new Map(), Tt = [], Z = typeof window < "u" ? window : {}, w = Z.document || { head: {} }, Lt = Z.HTMLElement || class {
|
|
514
514
|
}, b = {
|
|
515
515
|
$flags$: 0,
|
|
516
516
|
$resourcesUrl$: "",
|
|
@@ -536,7 +536,7 @@ const h = (t, e, ...a) => {
|
|
|
536
536
|
} catch {
|
|
537
537
|
}
|
|
538
538
|
return !1;
|
|
539
|
-
})(),
|
|
539
|
+
})(), ke = [], Fe = [], Rt = (t, e) => (a) => {
|
|
540
540
|
t.push(a), te || (te = !0, e && b.$flags$ & 4 ? Nt(ae) : b.raf(ae));
|
|
541
541
|
}, be = (t) => {
|
|
542
542
|
for (let e = 0; e < t.length; e++)
|
|
@@ -547,7 +547,7 @@ const h = (t, e, ...a) => {
|
|
|
547
547
|
}
|
|
548
548
|
t.length = 0;
|
|
549
549
|
}, ae = () => {
|
|
550
|
-
be(
|
|
550
|
+
be(ke), be(Fe), (te = ke.length > 0) && b.raf(ae);
|
|
551
551
|
}, Nt = (t) => Bt().then(t), It = /* @__PURE__ */ Rt(Fe, !0);
|
|
552
552
|
function U(t, e) {
|
|
553
553
|
const a = new Date(t);
|
|
@@ -556,9 +556,9 @@ function U(t, e) {
|
|
|
556
556
|
function Ft(t, e, a) {
|
|
557
557
|
const s = [], r = Q(t), n = r.getDay() === 0 ? 7 : r.getDay(), i = F(t), o = i.getDay() === 0 ? 7 : i.getDay(), c = a === 1 ? 7 : a - 1, l = [], u = [];
|
|
558
558
|
{
|
|
559
|
-
let
|
|
560
|
-
for (;
|
|
561
|
-
l.push(_), _ = G(_),
|
|
559
|
+
let v = (7 - a + n) % 7, _ = G(r);
|
|
560
|
+
for (; v > 0; )
|
|
561
|
+
l.push(_), _ = G(_), v -= 1;
|
|
562
562
|
l.reverse();
|
|
563
563
|
let L = (7 - o + c) % 7, E = A(i);
|
|
564
564
|
for (; L > 0; )
|
|
@@ -570,7 +570,7 @@ function Ft(t, e, a) {
|
|
|
570
570
|
return [...l, ...s, ...u];
|
|
571
571
|
}
|
|
572
572
|
function Q(t) {
|
|
573
|
-
return
|
|
573
|
+
return k(/* @__PURE__ */ new Date(`${String(qe(t)).padStart(4, "0")}-${String(Ae(t)).padStart(2, "0")}-01`));
|
|
574
574
|
}
|
|
575
575
|
function C(t) {
|
|
576
576
|
if (t instanceof Date)
|
|
@@ -585,7 +585,7 @@ function Ae(t) {
|
|
|
585
585
|
}
|
|
586
586
|
function At(t) {
|
|
587
587
|
return new Array(12).fill(void 0).map((e, a) => {
|
|
588
|
-
const s =
|
|
588
|
+
const s = k(/* @__PURE__ */ new Date(`2006-${String(a + 1).padStart(2, "0")}-01`));
|
|
589
589
|
return Intl.DateTimeFormat(t, {
|
|
590
590
|
month: "long"
|
|
591
591
|
}).format(s);
|
|
@@ -615,7 +615,7 @@ function _e(t) {
|
|
|
615
615
|
}
|
|
616
616
|
function qt(t, e) {
|
|
617
617
|
return new Array(7).fill(void 0).map((a, s) => (t + s) % 7 + 1).map((a) => {
|
|
618
|
-
const s =
|
|
618
|
+
const s = k(/* @__PURE__ */ new Date(`2006-01-0${a}`));
|
|
619
619
|
return [
|
|
620
620
|
Intl.DateTimeFormat(e, {
|
|
621
621
|
weekday: "short"
|
|
@@ -638,7 +638,7 @@ function me(t, e) {
|
|
|
638
638
|
function D(t, e) {
|
|
639
639
|
return !t || !e ? !1 : t.getFullYear() === e.getFullYear() && t.getMonth() === e.getMonth() && t.getDate() === e.getDate();
|
|
640
640
|
}
|
|
641
|
-
function
|
|
641
|
+
function k(t) {
|
|
642
642
|
const e = new Date(t);
|
|
643
643
|
return e.setMinutes(e.getMinutes() + e.getTimezoneOffset()), e;
|
|
644
644
|
}
|
|
@@ -659,7 +659,7 @@ const Yt = ".visually-hidden.sc-wc-datepicker{position:absolute;overflow:hidden;
|
|
|
659
659
|
}, Ut = /* @__PURE__ */ Dt(class extends Lt {
|
|
660
660
|
constructor() {
|
|
661
661
|
super(), this.__registerHost(), this.selectDate = ue(this, "selectDate"), this.changeMonth = ue(this, "changeMonth"), this.disabled = !1, this.disableDate = () => !1, this.elementClassName = "wc-datepicker", this.firstDayOfWeek = 0, this.goToRangeStartOnSelect = !0, this.labels = Pt, this.locale = navigator?.language || "en-US", this.maxSearchDays = 365, this.showClearButton = !1, this.showMonthStepper = !0, this.showTodayButton = !1, this.showYearStepper = !1, this.startDate = C(/* @__PURE__ */ new Date()), this.pendingClick = !1, this.init = () => {
|
|
662
|
-
this.currentDate = this.startDate ?
|
|
662
|
+
this.currentDate = this.startDate ? k(new Date(this.startDate)) : /* @__PURE__ */ new Date(), this.updateWeekdays(), this.handleMinDate(), this.handleMaxDate();
|
|
663
663
|
}, this.getAvailableDate = (t, e) => {
|
|
664
664
|
let a, s = !1;
|
|
665
665
|
switch (e) {
|
|
@@ -756,7 +756,7 @@ const Yt = ".visually-hidden.sc-wc-datepicker{position:absolute;overflow:hidden;
|
|
|
756
756
|
const e = t.target.closest("[data-date]");
|
|
757
757
|
if (!e)
|
|
758
758
|
return;
|
|
759
|
-
const a =
|
|
759
|
+
const a = k(new Date(e.dataset.date));
|
|
760
760
|
this.isDateDisabled(a) || (this.updateCurrentDate(a), this.onSelectDate(a));
|
|
761
761
|
}, this.onMonthSelect = (t) => {
|
|
762
762
|
const e = +t.target.value - 1, a = this.currentDate.getDate(), s = new Date(this.currentDate.getFullYear(), e, 1), r = F(s).getDate(), n = Math.min(a, r), i = new Date(this.currentDate.getFullYear(), e, n);
|
|
@@ -774,7 +774,7 @@ const Yt = ".visually-hidden.sc-wc-datepicker{position:absolute;overflow:hidden;
|
|
|
774
774
|
}, this.onMouseEnter = (t) => {
|
|
775
775
|
if (this.disabled)
|
|
776
776
|
return;
|
|
777
|
-
const e =
|
|
777
|
+
const e = k(new Date(t.target.closest("td").dataset.date));
|
|
778
778
|
this.hoveredDate = e;
|
|
779
779
|
}, this.onMouseLeave = () => {
|
|
780
780
|
this.hoveredDate = void 0;
|
|
@@ -783,7 +783,7 @@ const Yt = ".visually-hidden.sc-wc-datepicker{position:absolute;overflow:hidden;
|
|
|
783
783
|
}, this.onFocus = (t) => {
|
|
784
784
|
if (this.pendingClick)
|
|
785
785
|
return;
|
|
786
|
-
const e =
|
|
786
|
+
const e = k(new Date(t.target.dataset.date));
|
|
787
787
|
D(e, this.currentDate) || this.updateCurrentDate(e);
|
|
788
788
|
};
|
|
789
789
|
}
|
|
@@ -800,16 +800,16 @@ const Yt = ".visually-hidden.sc-wc-datepicker{position:absolute;overflow:hidden;
|
|
|
800
800
|
this.value = void 0, this.selectDate.emit(void 0);
|
|
801
801
|
}
|
|
802
802
|
watchStartDate() {
|
|
803
|
-
this.currentDate = this.startDate ?
|
|
803
|
+
this.currentDate = this.startDate ? k(new Date(this.startDate)) : /* @__PURE__ */ new Date();
|
|
804
804
|
}
|
|
805
805
|
watchValue() {
|
|
806
806
|
this.value && (Array.isArray(this.value) ? this.currentDate = this.value.length > 1 && !this.goToRangeStartOnSelect ? this.value[1] : this.value[0] : this.value instanceof Date && (this.currentDate = this.value));
|
|
807
807
|
}
|
|
808
808
|
handleMinDate() {
|
|
809
|
-
this.minDate && this.currentDate <
|
|
809
|
+
this.minDate && this.currentDate < k(new Date(this.minDate)) && (this.currentDate = k(new Date(this.minDate)));
|
|
810
810
|
}
|
|
811
811
|
handleMaxDate() {
|
|
812
|
-
this.maxDate && this.currentDate >
|
|
812
|
+
this.maxDate && this.currentDate > k(new Date(this.maxDate)) && (this.currentDate = k(new Date(this.maxDate)));
|
|
813
813
|
}
|
|
814
814
|
componentDidRender() {
|
|
815
815
|
this.moveFocusAfterMonthChanged && (this.focusDate(this.currentDate), this.moveFocusAfterMonthChanged = !1);
|
|
@@ -883,19 +883,19 @@ const Yt = ".visually-hidden.sc-wc-datepicker{position:absolute;overflow:hidden;
|
|
|
883
883
|
get isPreviousMonthDisabled() {
|
|
884
884
|
if (!this.minDate)
|
|
885
885
|
return !1;
|
|
886
|
-
const t = ee(this.currentDate), e =
|
|
886
|
+
const t = ee(this.currentDate), e = k(new Date(this.minDate));
|
|
887
887
|
return F(t) < e;
|
|
888
888
|
}
|
|
889
889
|
get isNextMonthDisabled() {
|
|
890
890
|
if (!this.maxDate)
|
|
891
891
|
return !1;
|
|
892
|
-
const t = V(this.currentDate), e =
|
|
892
|
+
const t = V(this.currentDate), e = k(new Date(this.maxDate));
|
|
893
893
|
return Q(t) > e;
|
|
894
894
|
}
|
|
895
895
|
isDateDisabled(t) {
|
|
896
896
|
if (this.disableDate(t))
|
|
897
897
|
return !0;
|
|
898
|
-
const e = this.minDate && t <
|
|
898
|
+
const e = this.minDate && t < k(new Date(this.minDate)), a = this.maxDate && t > k(new Date(this.maxDate));
|
|
899
899
|
return !!(e || a);
|
|
900
900
|
}
|
|
901
901
|
render() {
|
|
@@ -916,10 +916,10 @@ const Yt = ".visually-hidden.sc-wc-datepicker{position:absolute;overflow:hidden;
|
|
|
916
916
|
const l = D(s, this.currentDate), u = s.getMonth() !== this.currentDate.getMonth(), d = Array.isArray(this.value) ? D(s, this.value[0]) || D(s, this.value[1]) : D(s, this.value), p = this.isRangeValue ? me(s, {
|
|
917
917
|
from: (r = this.value) === null || r === void 0 ? void 0 : r[0],
|
|
918
918
|
to: ((n = this.value) === null || n === void 0 ? void 0 : n[1]) || this.hoveredDate || this.currentDate
|
|
919
|
-
}) : !1,
|
|
919
|
+
}) : !1, v = !((i = this.value) === null || i === void 0) && i[0] ? [
|
|
920
920
|
(o = this.value) === null || o === void 0 ? void 0 : o[0],
|
|
921
921
|
((c = this.value) === null || c === void 0 ? void 0 : c[1]) || this.hoveredDate
|
|
922
|
-
].sort((We, ze) => We - ze) : [], _ = this.range && D(
|
|
922
|
+
].sort((We, ze) => We - ze) : [], _ = this.range && D(v[0], s), S = this.range && D(v[1], s), L = D(s, /* @__PURE__ */ new Date()), E = this.isDateDisabled(s), Ye = `cell-${s.getMonth()}-${s.getDate()}`, Pe = {
|
|
923
923
|
[this.getClassName("date")]: !0,
|
|
924
924
|
[this.getClassName("date--current")]: l,
|
|
925
925
|
[this.getClassName("date--disabled")]: E,
|
|
@@ -991,7 +991,7 @@ var zt = Object.defineProperty, y = (t, e, a, s) => {
|
|
|
991
991
|
customElements.get("wc-datepicker") || customElements.define("wc-datepicker", Wt);
|
|
992
992
|
let jt = 0;
|
|
993
993
|
var x;
|
|
994
|
-
const f = (x = class extends
|
|
994
|
+
const f = (x = class extends ne {
|
|
995
995
|
// allows use of elementInternals' API
|
|
996
996
|
constructor() {
|
|
997
997
|
super(), this.id = "", this.name = "", this.width = "md", this.hideTodayButton = !1, this.hideClearButton = !1, this.disabled = !1, this.required = !1, this.optional = !1, this.showError = !1, this.errorMessage = "", this.form = null, this.tooltip = "", this.type = "date", this.label = "", this.description = "", this.startDate = "", this.minDate = "", this.maxDate = "", this.inverted = !1, this.value = void 0, this.datepickerIsOpen = !1, this._hasUserInteracted = !1, this._onKeydownEsc = (e) => {
|
|
@@ -1009,6 +1009,12 @@ const f = (x = class extends ie {
|
|
|
1009
1009
|
async firstUpdated() {
|
|
1010
1010
|
this._setValue(this.value), !(this._shouldUseNativeDatepicker() || !await this._whenWcDatepickerReady()) && (setTimeout(() => this._replaceButtonSVG(), 0), setTimeout(() => this._addMonthDropdownIcon(), 0), setTimeout(() => this._handleDateChange(), 0), setTimeout(() => this._onDocumentClick(), 0));
|
|
1011
1011
|
}
|
|
1012
|
+
updated(e) {
|
|
1013
|
+
if (super.updated(e), e.has("value")) {
|
|
1014
|
+
const a = e.get("value"), s = this.value;
|
|
1015
|
+
!s && a !== s ? (this._internals.setFormValue(""), this._manageRequire()) : s && this._setValue(s);
|
|
1016
|
+
}
|
|
1017
|
+
}
|
|
1012
1018
|
async _whenWcDatepickerReady() {
|
|
1013
1019
|
await customElements.whenDefined("wc-datepicker");
|
|
1014
1020
|
const e = this.shadowRoot?.querySelector(
|
|
@@ -1062,8 +1068,8 @@ const f = (x = class extends ie {
|
|
|
1062
1068
|
const e = this.shadowRoot?.querySelector("input");
|
|
1063
1069
|
if (!e) return;
|
|
1064
1070
|
this._manageRequire();
|
|
1065
|
-
|
|
1066
|
-
this._setValidityMessage(a);
|
|
1071
|
+
let a = "";
|
|
1072
|
+
e.validity.valueMissing ? a = this.errorMessage || "This field is required." : a = e.validationMessage, this._setValidityMessage(a);
|
|
1067
1073
|
}
|
|
1068
1074
|
/**
|
|
1069
1075
|
* Passive check of validity:
|
|
@@ -1079,11 +1085,11 @@ const f = (x = class extends ie {
|
|
|
1079
1085
|
_setValidityMessage(e = "") {
|
|
1080
1086
|
if (!this._internals) return;
|
|
1081
1087
|
const a = this.shadowRoot?.querySelector("input");
|
|
1082
|
-
a && (this.showError = !!e, this.errorMessage?.trim() && e !== "" && (e = this.errorMessage), this._internals.setValidity(
|
|
1088
|
+
a && (!e && this.showError && this.errorMessage?.trim() || (this.showError = !!e, this.errorMessage?.trim() && e !== "" && (e = this.errorMessage), this._internals.setValidity(
|
|
1083
1089
|
e ? { customError: !0 } : {},
|
|
1084
1090
|
e,
|
|
1085
1091
|
a
|
|
1086
|
-
));
|
|
1092
|
+
)));
|
|
1087
1093
|
}
|
|
1088
1094
|
// Handles native 'invalid' events
|
|
1089
1095
|
_handleInvalid(e) {
|
|
@@ -1141,6 +1147,12 @@ const f = (x = class extends ie {
|
|
|
1141
1147
|
e.setHours(0, 0, 0, 0), this._setValue(e), this._setFocusOnTodayDate();
|
|
1142
1148
|
}
|
|
1143
1149
|
async _setFocusOnTodayDate(e = !1) {
|
|
1150
|
+
if (this.minDate) {
|
|
1151
|
+
const i = /* @__PURE__ */ new Date();
|
|
1152
|
+
i.setHours(0, 0, 0, 0);
|
|
1153
|
+
const o = this._parseLocalDate(this.minDate);
|
|
1154
|
+
if (i < o) return;
|
|
1155
|
+
}
|
|
1144
1156
|
const a = /* @__PURE__ */ new Date();
|
|
1145
1157
|
a.setHours(0, 0, 0, 0);
|
|
1146
1158
|
const s = [
|
|
@@ -1183,7 +1195,8 @@ const f = (x = class extends ie {
|
|
|
1183
1195
|
}
|
|
1184
1196
|
_handleBlur(e) {
|
|
1185
1197
|
const a = e.relatedTarget;
|
|
1186
|
-
if (a && (this.contains(a) || this.shadowRoot?.contains(a)))
|
|
1198
|
+
if (a && (this.contains(a) || this.shadowRoot?.contains(a)) || this.datepickerIsOpen && !a)
|
|
1199
|
+
return;
|
|
1187
1200
|
this._hasUserInteracted || (this._hasUserInteracted = !0), this.shadowRoot?.querySelector("wc-datepicker")?.classList.remove("active"), this.datepickerIsOpen = !1, this._validate(), this.dispatchEvent(
|
|
1188
1201
|
new Event("nys-blur", { bubbles: !0, composed: !0 })
|
|
1189
1202
|
), this.removeEventListener("keydown", this._handleFocusTrap);
|
|
@@ -1299,7 +1312,6 @@ const f = (x = class extends ie {
|
|
|
1299
1312
|
const e = this._shouldUseNativeDatepicker();
|
|
1300
1313
|
return I` <div class="nys-datepicker--container">
|
|
1301
1314
|
<nys-label
|
|
1302
|
-
for=${this.id}
|
|
1303
1315
|
label=${this.label}
|
|
1304
1316
|
description=${this.description}
|
|
1305
1317
|
flag=${this.required ? "required" : this.optional ? "optional" : ""}
|
|
@@ -1387,7 +1399,7 @@ const f = (x = class extends ie {
|
|
|
1387
1399
|
></nys-errormessage>`;
|
|
1388
1400
|
}
|
|
1389
1401
|
}, x.styles = je(Ke), x.shadowRootOptions = {
|
|
1390
|
-
...
|
|
1402
|
+
...ne.shadowRootOptions,
|
|
1391
1403
|
delegatesFocus: !0
|
|
1392
1404
|
}, x.formAssociated = !0, x);
|
|
1393
1405
|
y([
|