@editora/ui-core 0.1.17 → 0.1.19
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/button.cjs.js +4 -4
- package/dist/button.esm.js +2 -0
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +1 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +1 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/date-picker.cjs.js +25 -4
- package/dist/date-picker.esm.js +21 -0
- package/dist/date-range-picker.cjs.js +19 -0
- package/dist/date-range-picker.esm.js +78 -59
- package/dist/date-range-time-picker.cjs.js +26 -10
- package/dist/date-range-time-picker.esm.js +46 -30
- package/dist/date-time-picker.cjs.js +23 -7
- package/dist/date-time-picker.esm.js +64 -48
- package/dist/time-picker.cjs.js +11 -3
- package/dist/time-picker.esm.js +9 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E as tt } from "./ElementBase-909688f3.mjs";
|
|
2
2
|
import { c as et } from "./dismissable-layer-9c7e6b58.mjs";
|
|
3
3
|
import { r as it } from "./calendar-2c11b824.mjs";
|
|
4
|
-
import { r as rt, e as st, i as C, s as nt, b as at, j as D, k, f as ot, m as I, o as P, l as lt, c as dt, q as
|
|
4
|
+
import { r as rt, e as st, i as C, s as nt, b as at, j as D, k as A, f as ot, m as I, o as P, l as lt, c as dt, q as k, g as ut, h as ct } from "./date-time-utils-a2c7af25.mjs";
|
|
5
5
|
import "./scroll-lock-31da444f.mjs";
|
|
6
6
|
import "./positioner-e9770c66.mjs";
|
|
7
7
|
let pt = 0;
|
|
@@ -21,7 +21,7 @@ const ht = `
|
|
|
21
21
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
22
22
|
<path d="M10 2a8 8 0 1 1 0 16 8 8 0 0 1 0-16Zm0 1.5a6.5 6.5 0 1 0 0 13 6.5 6.5 0 0 0 0-13Zm.75 2.75a.75.75 0 0 0-1.5 0v3.88c0 .2.08.4.22.54l2.5 2.5a.75.75 0 1 0 1.06-1.06l-2.28-2.28V6.25Z" fill="currentColor"/>
|
|
23
23
|
</svg>
|
|
24
|
-
`,
|
|
24
|
+
`, ft = `
|
|
25
25
|
:host {
|
|
26
26
|
--ui-drtp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
27
27
|
--ui-drtp-surface: linear-gradient(
|
|
@@ -272,7 +272,23 @@ const ht = `
|
|
|
272
272
|
outline-color: Highlight;
|
|
273
273
|
}
|
|
274
274
|
}
|
|
275
|
-
`,
|
|
275
|
+
`, gt = `
|
|
276
|
+
.ui-date-range-time-picker-overlay-host {
|
|
277
|
+
--ui-drtp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
278
|
+
--ui-drtp-surface: linear-gradient(
|
|
279
|
+
180deg,
|
|
280
|
+
color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent),
|
|
281
|
+
color-mix(in srgb, var(--ui-color-surface, #ffffff) 90%, var(--ui-color-surface-alt, #f8fafc))
|
|
282
|
+
);
|
|
283
|
+
--ui-drtp-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
284
|
+
--ui-dp-text: var(--ui-color-text, #0f172a);
|
|
285
|
+
--ui-dp-muted: var(--ui-color-muted, #64748b);
|
|
286
|
+
--ui-drtp-accent: var(--ui-color-primary, #2563eb);
|
|
287
|
+
--ui-drtp-panel-radius: 14px;
|
|
288
|
+
--ui-drtp-shadow: none;
|
|
289
|
+
--ui-drtp-duration: 160ms;
|
|
290
|
+
--ui-drtp-ease: cubic-bezier(0.2, 0.9, 0.24, 1);
|
|
291
|
+
}
|
|
276
292
|
.overlay { position: fixed; z-index: var(--ui-drtp-z, 1600); pointer-events: none; }
|
|
277
293
|
.panel {
|
|
278
294
|
pointer-events: auto;
|
|
@@ -534,7 +550,7 @@ function c(h) {
|
|
|
534
550
|
}
|
|
535
551
|
function w(h) {
|
|
536
552
|
var n, s;
|
|
537
|
-
const t = /* @__PURE__ */ new Date(), e = `${S(t.getHours())}:${S(t.getMinutes())}`, i = `${S((t.getHours() + 1) % 24)}:${S(t.getMinutes())}`, r =
|
|
553
|
+
const t = /* @__PURE__ */ new Date(), e = `${S(t.getHours())}:${S(t.getMinutes())}`, i = `${S((t.getHours() + 1) % 24)}:${S(t.getMinutes())}`, r = A(h.start || null), o = A(h.end || null);
|
|
538
554
|
return {
|
|
539
555
|
startDate: (r == null ? void 0 : r.date) || null,
|
|
540
556
|
endDate: (o == null ? void 0 : o.date) || null,
|
|
@@ -696,7 +712,7 @@ class _t extends tt {
|
|
|
696
712
|
};
|
|
697
713
|
}
|
|
698
714
|
_formatDateTimeDisplay(t) {
|
|
699
|
-
const e =
|
|
715
|
+
const e = A(t);
|
|
700
716
|
return e ? `${ot(e.date, this._locale(), "locale", null)} ${e.time}` : t || "";
|
|
701
717
|
}
|
|
702
718
|
_formatDisplay() {
|
|
@@ -707,17 +723,17 @@ class _t extends tt {
|
|
|
707
723
|
var p, m;
|
|
708
724
|
let e = D(t.startDate, t.startTime), i = D(t.endDate, t.endTime);
|
|
709
725
|
if (e && i && I(e, i) > 0 && this._autoNormalize()) {
|
|
710
|
-
const
|
|
711
|
-
e = i, i =
|
|
726
|
+
const f = e;
|
|
727
|
+
e = i, i = f;
|
|
712
728
|
}
|
|
713
729
|
const r = P(this.getAttribute("min")), o = P(this.getAttribute("max"));
|
|
714
730
|
let n = r ? `${r.date}T${r.time}` : null, s = o ? `${o.date}T${o.time}` : null;
|
|
715
731
|
if (n && s && I(n, s) > 0) {
|
|
716
|
-
const
|
|
717
|
-
n = s, s =
|
|
732
|
+
const f = n;
|
|
733
|
+
n = s, s = f;
|
|
718
734
|
}
|
|
719
735
|
e && n && I(e, n) < 0 && (e = n), e && s && I(e, s) > 0 && (e = s), i && n && I(i, n) < 0 && (i = n), i && s && I(i, s) > 0 && (i = s);
|
|
720
|
-
const a =
|
|
736
|
+
const a = A(e || ""), l = A(i || "");
|
|
721
737
|
return {
|
|
722
738
|
startDate: (a == null ? void 0 : a.date) || null,
|
|
723
739
|
endDate: (l == null ? void 0 : l.date) || null,
|
|
@@ -766,7 +782,7 @@ class _t extends tt {
|
|
|
766
782
|
if (this._overlay || typeof document > "u")
|
|
767
783
|
return;
|
|
768
784
|
const t = document.createElement("div");
|
|
769
|
-
t.style.position = "fixed", t.style.left = "0", t.style.top = "0", t.style.pointerEvents = "none", t.addEventListener("click", this._onOverlayClickBound), t.addEventListener("change", this._onOverlayChangeBound), t.addEventListener("change", this._onOverlayCalendarBound), document.body.appendChild(t), this._overlay = t, this._syncOverlayHostZIndex(), document.addEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.addEventListener("keydown", this._onDocumentKeyDownBound), window.addEventListener("resize", this._onWindowResizeBound), window.addEventListener("scroll", this._onWindowScrollBound, { passive: !0, capture: !0 }), this._isMobileSheet() && (this._releaseScrollLock = lt());
|
|
785
|
+
t.className = "ui-date-range-time-picker-overlay-host", t.style.position = "fixed", t.style.left = "0", t.style.top = "0", t.style.pointerEvents = "none", t.addEventListener("click", this._onOverlayClickBound), t.addEventListener("change", this._onOverlayChangeBound), t.addEventListener("change", this._onOverlayCalendarBound), document.body.appendChild(t), this._overlay = t, this._syncOverlayHostZIndex(), document.addEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.addEventListener("keydown", this._onDocumentKeyDownBound), window.addEventListener("resize", this._onWindowResizeBound), window.addEventListener("scroll", this._onWindowScrollBound, { passive: !0, capture: !0 }), this._isMobileSheet() && (this._releaseScrollLock = lt());
|
|
770
786
|
}
|
|
771
787
|
_syncOverlayHostZIndex() {
|
|
772
788
|
if (!this._overlay || typeof window > "u")
|
|
@@ -808,14 +824,14 @@ class _t extends tt {
|
|
|
808
824
|
e.style.position = "absolute", e.style.top = `${Math.round(r.top)}px`, e.style.left = `${Math.round(r.left)}px`, e.setAttribute("data-placement", r.placement);
|
|
809
825
|
}
|
|
810
826
|
_timeOptions(t) {
|
|
811
|
-
const e =
|
|
827
|
+
const e = k(t, !0) || { hours: 0, minutes: 0, seconds: 0 }, i = this._step(), r = Array.from({ length: 24 }, (n, s) => `<option value="${s}" ${s === e.hours ? "selected" : ""}>${S(s)}</option>`).join(""), o = Array.from({ length: Math.ceil(60 / i) }, (n, s) => {
|
|
812
828
|
const a = Math.min(59, s * i);
|
|
813
829
|
return `<option value="${a}" ${a === e.minutes ? "selected" : ""}>${S(a)}</option>`;
|
|
814
830
|
}).join("");
|
|
815
831
|
return { hours: r, minutes: o };
|
|
816
832
|
}
|
|
817
833
|
_renderSurfaceInner(t, e = !1) {
|
|
818
|
-
const i = this._translations(), r = this._timeOptions(this._pending.startTime), o = this._timeOptions(this._pending.endTime), n = (this.getAttribute("label") || "").trim(), s = c(n), a = c(n || i.selectDateRange), l = this._valueFromPending(), p = l.start && l.end ? `${this._formatDateTimeDisplay(l.start)} — ${this._formatDateTimeDisplay(l.end)}` : i.selectDateRange, m = c(`${i.startTime} ${i.hour}`),
|
|
834
|
+
const i = this._translations(), r = this._timeOptions(this._pending.startTime), o = this._timeOptions(this._pending.endTime), n = (this.getAttribute("label") || "").trim(), s = c(n), a = c(n || i.selectDateRange), l = this._valueFromPending(), p = l.start && l.end ? `${this._formatDateTimeDisplay(l.start)} — ${this._formatDateTimeDisplay(l.end)}` : i.selectDateRange, m = c(`${i.startTime} ${i.hour}`), f = c(`${i.startTime} ${i.minute}`), v = c(`${i.endTime} ${i.hour}`), d = c(`${i.endTime} ${i.minute}`), g = `
|
|
819
835
|
<header class="head">
|
|
820
836
|
<div>
|
|
821
837
|
<p class="head-title" ${n ? "" : "hidden"}>${s}</p>
|
|
@@ -836,7 +852,7 @@ class _t extends tt {
|
|
|
836
852
|
<div class="time-row">
|
|
837
853
|
<p class="time-row-label"><span class="icon-inline">${B}</span>${c(i.startTime)}</p>
|
|
838
854
|
<select data-time="start" data-segment="hours" aria-label="${m}">${r.hours}</select>
|
|
839
|
-
<select data-time="start" data-segment="minutes" aria-label="${
|
|
855
|
+
<select data-time="start" data-segment="minutes" aria-label="${f}">${r.minutes}</select>
|
|
840
856
|
</div>
|
|
841
857
|
<div class="time-row">
|
|
842
858
|
<p class="time-row-label"><span class="icon-inline">${B}</span>${c(i.endTime)}</p>
|
|
@@ -858,10 +874,10 @@ class _t extends tt {
|
|
|
858
874
|
<button type="button" class="action" data-action="apply" data-tone="primary">${c(i.apply)}</button>
|
|
859
875
|
</footer>
|
|
860
876
|
`;
|
|
861
|
-
return e ?
|
|
862
|
-
<style>${
|
|
877
|
+
return e ? g : `
|
|
878
|
+
<style>${gt}</style>
|
|
863
879
|
${t ? '<div class="sheet-backdrop" data-action="backdrop"></div>' : ""}
|
|
864
|
-
<section class="${t ? "sheet" : "panel"}" id="${this._panelId}" role="dialog" aria-modal="${t ? "true" : "false"}" aria-label="${a}" part="${t ? "sheet" : "popover"}">${
|
|
880
|
+
<section class="${t ? "sheet" : "panel"}" id="${this._panelId}" role="dialog" aria-modal="${t ? "true" : "false"}" aria-label="${a}" part="${t ? "sheet" : "popover"}">${g}</section>
|
|
865
881
|
`;
|
|
866
882
|
}
|
|
867
883
|
_syncCalendar(t) {
|
|
@@ -928,10 +944,10 @@ class _t extends tt {
|
|
|
928
944
|
a && (a.textContent = l.start && l.end ? `${this._formatDateTimeDisplay(l.start)} — ${this._formatDateTimeDisplay(l.end)}` : e.selectDateRange);
|
|
929
945
|
const p = this._overlay.querySelector(".drtp-calendar");
|
|
930
946
|
p && this._syncCalendar(p);
|
|
931
|
-
const m =
|
|
932
|
-
v && this._setClosestOptionValue(v, m.hours), d && this._setClosestOptionValue(d, m.minutes),
|
|
947
|
+
const m = k(this._pending.startTime, !0) || { hours: 0, minutes: 0, seconds: 0 }, f = k(this._pending.endTime, !0) || { hours: 0, minutes: 0, seconds: 0 }, v = this._overlay.querySelector('select[data-time="start"][data-segment="hours"]'), d = this._overlay.querySelector('select[data-time="start"][data-segment="minutes"]'), g = this._overlay.querySelector('select[data-time="end"][data-segment="hours"]'), _ = this._overlay.querySelector('select[data-time="end"][data-segment="minutes"]');
|
|
948
|
+
v && this._setClosestOptionValue(v, m.hours), d && this._setClosestOptionValue(d, m.minutes), g && this._setClosestOptionValue(g, f.hours), _ && this._setClosestOptionValue(_, f.minutes);
|
|
933
949
|
const y = this._isInteractionBlocked() || this._isReadonly();
|
|
934
|
-
[v, d,
|
|
950
|
+
[v, d, g, _].forEach((b) => {
|
|
935
951
|
b && (b.disabled = y);
|
|
936
952
|
}), this._overlay.querySelectorAll(".action, .preset").forEach((b) => {
|
|
937
953
|
b.disabled = y;
|
|
@@ -1090,8 +1106,8 @@ class _t extends tt {
|
|
|
1090
1106
|
return;
|
|
1091
1107
|
const t = this.getAttribute("label") || "", e = this.getAttribute("hint") || "", i = this.getAttribute("error") || "", r = this._inlineError || i, o = !!(this._value.start || this._value.end), n = this.getAttribute("name") || "", s = this._isInlineMode(), a = this._translations(), l = r ? "error" : this._state(), p = this._formatDisplay();
|
|
1092
1108
|
this._display = p, this._state() === "loading" ? this.setAttribute("aria-busy", "true") : this.removeAttribute("aria-busy");
|
|
1093
|
-
const m = this.root.querySelector(".label"),
|
|
1094
|
-
if (m && (m.hidden = !t, m.id = this._labelId, m.setAttribute("for", this._inputId)),
|
|
1109
|
+
const m = this.root.querySelector(".label"), f = this.root.querySelector(".label-text"), v = this.root.querySelector(".required"), d = this.root.querySelector(".input"), g = this.root.querySelector('.btn[data-action="clear"]'), _ = this.root.querySelector('.btn[data-action="toggle"]'), y = this.root.querySelector(".hint"), b = this.root.querySelector(".error"), $ = this.root.querySelector(".hidden-input");
|
|
1110
|
+
if (m && (m.hidden = !t, m.id = this._labelId, m.setAttribute("for", this._inputId)), f && (f.textContent = t), v && (v.hidden = !this.hasAttribute("required")), d && (d.value !== p && (d.value = p), d.id = this._inputId, d.placeholder = a.dateRangeTimePlaceholder, d.readOnly = !0, d.disabled = this._isInteractionBlocked(), d.required = this.hasAttribute("required"), d.autocomplete = "off", d.setAttribute("role", "combobox"), d.setAttribute("aria-haspopup", "dialog"), d.setAttribute("aria-expanded", s ? "false" : String(this._open)), d.setAttribute("aria-controls", this._panelId), d.setAttribute("aria-invalid", r ? "true" : "false"), t ? d.setAttribute("aria-labelledby", this._labelId) : d.removeAttribute("aria-labelledby")), g && (g.hidden = !(this._clearable() && o), g.setAttribute("aria-label", a.clearDateRange), g.disabled = this._isInteractionBlocked()), _ && (_.hidden = s, _.setAttribute("aria-label", a.toggleCalendar), _.setAttribute("aria-expanded", s ? "false" : String(this._open)), _.setAttribute("aria-controls", this._panelId), _.disabled = this._isInteractionBlocked()), y && (y.id = this._hintId, y.hidden = !e, y.textContent = e), b && (b.id = this._errorId, b.hidden = !r, b.textContent = r), d) {
|
|
1095
1111
|
const x = [];
|
|
1096
1112
|
e && y && !y.hidden && x.push(this._hintId), r && x.push(this._errorId), x.length ? d.setAttribute("aria-describedby", x.join(" ")) : d.removeAttribute("aria-describedby");
|
|
1097
1113
|
}
|
|
@@ -1105,13 +1121,13 @@ class _t extends tt {
|
|
|
1105
1121
|
x && (x.textContent = t, x.hidden = !t);
|
|
1106
1122
|
const R = u.querySelector(".head-title");
|
|
1107
1123
|
R && (R.textContent = t, R.hidden = !t);
|
|
1108
|
-
const H = u.querySelector(".head-meta"),
|
|
1109
|
-
H && (H.textContent =
|
|
1124
|
+
const H = u.querySelector(".head-meta"), z = this._valueFromPending();
|
|
1125
|
+
H && (H.textContent = z.start && z.end ? `${this._formatDateTimeDisplay(z.start)} — ${this._formatDateTimeDisplay(z.end)}` : a.selectDateRange);
|
|
1110
1126
|
const V = u.querySelector(".drtp-calendar-inline");
|
|
1111
1127
|
V && this._syncCalendar(V);
|
|
1112
|
-
const L = u.querySelector('select[data-time="start"][data-segment="hours"]'), q = u.querySelector('select[data-time="start"][data-segment="minutes"]'), E = u.querySelector('select[data-time="end"][data-segment="hours"]'), M = u.querySelector('select[data-time="end"][data-segment="minutes"]'), F =
|
|
1113
|
-
L && this._setClosestOptionValue(L, F.hours), q && this._setClosestOptionValue(q, F.minutes), E && this._setClosestOptionValue(E, N.hours), M && this._setClosestOptionValue(M, N.minutes), [L, q, E, M].forEach((
|
|
1114
|
-
|
|
1128
|
+
const L = u.querySelector('select[data-time="start"][data-segment="hours"]'), q = u.querySelector('select[data-time="start"][data-segment="minutes"]'), E = u.querySelector('select[data-time="end"][data-segment="hours"]'), M = u.querySelector('select[data-time="end"][data-segment="minutes"]'), F = k(this._pending.startTime, !0) || { hours: 0, minutes: 0, seconds: 0 }, N = k(this._pending.endTime, !0) || { hours: 0, minutes: 0, seconds: 0 };
|
|
1129
|
+
L && this._setClosestOptionValue(L, F.hours), q && this._setClosestOptionValue(q, F.minutes), E && this._setClosestOptionValue(E, N.hours), M && this._setClosestOptionValue(M, N.minutes), [L, q, E, M].forEach((T) => {
|
|
1130
|
+
T && (T.disabled = this._isInteractionBlocked() || this._isReadonly());
|
|
1115
1131
|
});
|
|
1116
1132
|
const K = u.querySelector('[data-action="preset-today"]');
|
|
1117
1133
|
K && (K.textContent = a.today);
|
|
@@ -1124,8 +1140,8 @@ class _t extends tt {
|
|
|
1124
1140
|
const W = u.querySelector('[data-action="apply"]');
|
|
1125
1141
|
W && (W.textContent = a.apply);
|
|
1126
1142
|
const J = u.querySelector(".presets"), Y = u.querySelector(".footer"), G = this._showFooter();
|
|
1127
|
-
J && (J.hidden = !G), Y && (Y.hidden = !G), u.querySelectorAll(".action, .preset").forEach((
|
|
1128
|
-
|
|
1143
|
+
J && (J.hidden = !G), Y && (Y.hidden = !G), u.querySelectorAll(".action, .preset").forEach((T) => {
|
|
1144
|
+
T.disabled = this._isInteractionBlocked() || this._isReadonly();
|
|
1129
1145
|
});
|
|
1130
1146
|
}
|
|
1131
1147
|
!s && this._open && this._syncOverlayState(), s && this._destroyOverlay();
|
|
@@ -1134,7 +1150,7 @@ class _t extends tt {
|
|
|
1134
1150
|
if (!this._hasView) {
|
|
1135
1151
|
const t = this._translations();
|
|
1136
1152
|
this.setContent(`
|
|
1137
|
-
<style>${
|
|
1153
|
+
<style>${ft}</style>
|
|
1138
1154
|
<div class="root">
|
|
1139
1155
|
<label class="label" part="label" id="${this._labelId}">
|
|
1140
1156
|
<span class="label-text"></span>
|
|
@@ -281,6 +281,22 @@
|
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
283
|
`,J=`
|
|
284
|
+
.ui-date-time-picker-overlay-host {
|
|
285
|
+
--ui-dtp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
286
|
+
--ui-dtp-surface: linear-gradient(
|
|
287
|
+
180deg,
|
|
288
|
+
color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent),
|
|
289
|
+
color-mix(in srgb, var(--ui-color-surface, #ffffff) 90%, var(--ui-color-surface-alt, #f8fafc))
|
|
290
|
+
);
|
|
291
|
+
--ui-dtp-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
292
|
+
--ui-dp-text: var(--ui-color-text, #0f172a);
|
|
293
|
+
--ui-dp-muted: var(--ui-color-muted, #64748b);
|
|
294
|
+
--ui-dtp-accent: var(--ui-color-primary, #2563eb);
|
|
295
|
+
--ui-dtp-panel-radius: 14px;
|
|
296
|
+
--ui-dtp-shadow: none;
|
|
297
|
+
--ui-dtp-duration: 160ms;
|
|
298
|
+
--ui-dtp-ease: cubic-bezier(0.2, 0.9, 0.24, 1);
|
|
299
|
+
}
|
|
284
300
|
.overlay { position: fixed; z-index: var(--ui-dtp-z, 1600); pointer-events: none; }
|
|
285
301
|
.panel {
|
|
286
302
|
pointer-events: auto;
|
|
@@ -442,11 +458,11 @@
|
|
|
442
458
|
from { opacity: 0; transform: translateY(6px) scale(0.985); }
|
|
443
459
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
444
460
|
}
|
|
445
|
-
`;function h(m){return String(m).padStart(2,"0")}function p(m){return m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function H(m){const t=l.splitDateTime(m);return t?{date:t.date,time:t.time}:{date:null,time:null}}function y(m){return l.combineDateTime(m.date,m.time)}class V extends F.ElementBase{constructor(){super(...arguments),this._value={date:null,time:null},this._pending={date:null,time:null},this._draft="",this._inlineError="",this._open=!1,this._syncing=!1,this._overlay=null,this._dismissableLayer=null,this._releaseScrollLock=null,this._isInitialized=!1,this._hasView=!1,this._restoreFocusEl=null,this._overlayKey=null,this._uid=`ui-dtp-${++U}`,this._inputId=`${this._uid}-input`,this._labelId=`${this._uid}-label`,this._hintId=`${this._uid}-hint`,this._errorId=`${this._uid}-error`,this._panelId=`${this._uid}-panel`,this._schedulePosition=l.rafThrottle(()=>this._positionOverlay()),this._onRootClickBound=t=>this._onRootClick(t),this._onRootInputBound=t=>this._onRootInput(t),this._onRootChangeBound=t=>this._onRootChange(t),this._onRootBlurBound=t=>this._onRootBlur(t),this._onRootKeyDownBound=t=>this._onRootKeyDown(t),this._onOverlayClickBound=t=>this._onOverlayClick(t),this._onOverlayChangeBound=t=>this._onOverlayChange(t),this._onOverlayCalendarBound=t=>this._onOverlayCalendar(t),this._onDocumentPointerDownBound=t=>this._onDocumentPointerDown(t),this._onDocumentKeyDownBound=t=>this._onDocumentKeyDown(t),this._onWindowResizeBound=()=>this._schedulePosition.run(),this._onWindowScrollBound=t=>{l.eventOriginatesWithin(t,[this._overlay])||this._schedulePosition.run()}}static get observedAttributes(){return["open","default-open","value","default-value","min","max","locale","translations","week-start","size","shape","bare","variant","state","step","format","disabled","readonly","required","name","close-on-select","clearable","allow-input","mode","label","hint","error","show-footer"]}connectedCallback(){if(super.connectedCallback(),this.root.addEventListener("click",this._onRootClickBound),this.root.addEventListener("input",this._onRootInputBound),this.root.addEventListener("change",this._onRootChangeBound),this.root.addEventListener("focusout",this._onRootBlurBound),this.root.addEventListener("keydown",this._onRootKeyDownBound),!this._isInitialized){const t=H(this.getAttribute("value")||this.getAttribute("default-value"));this._value=t,this._pending={...t},this._draft=this._formatDisplay(t),this._open=this.hasAttribute("open")||l.isTruthyAttr(this.getAttribute("default-open")),this._isInitialized=!0}this._open&&!this._isInlineMode()&&this._ensureOverlay()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClickBound),this.root.removeEventListener("input",this._onRootInputBound),this.root.removeEventListener("change",this._onRootChangeBound),this.root.removeEventListener("focusout",this._onRootBlurBound),this.root.removeEventListener("keydown",this._onRootKeyDownBound),this._destroyOverlay(),super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e!==i&&(t==="value"&&!this._syncing&&(this._value=H(i),this._pending={...this._value},this._draft=this._formatDisplay(this._value),this._inlineError=""),t==="open"&&!this._syncing&&(this._open=this.hasAttribute("open"),this._syncOverlay("attribute")),t==="mode"&&this._syncOverlay("attribute"),t==="disabled"&&this.hasAttribute("disabled")&&this._setOpen(!1,"outside"),t==="state"&&this._state()==="loading"&&this._setOpen(!1,"outside"),!!this.isConnected)){if(!this._hasView){this.requestRender();return}this._updateHostState()}}_isInlineMode(){return(this.getAttribute("mode")||"popover")==="inline"}_isMobileSheet(){return l.shouldUseMobileSheet(this.getAttribute("mode"))}_isDisabled(){return this.hasAttribute("disabled")}_state(){const t=(this.getAttribute("state")||"").trim().toLowerCase();return t==="loading"||t==="error"||t==="success"?t:"idle"}_isInteractionBlocked(){return this._isDisabled()||this._state()==="loading"}_isReadonly(){return this.hasAttribute("readonly")}_allowInput(){return l.isTruthyAttr(this.getAttribute("allow-input"),!0)}_clearable(){return l.isTruthyAttr(this.getAttribute("clearable"),!0)}_closeOnSelect(){return l.isTruthyAttr(this.getAttribute("close-on-select"),!1)}_shouldAutoCommit(){return this._closeOnSelect()||!this._showFooter()}_showFooter(){return l.isTruthyAttr(this.getAttribute("show-footer"),!0)}_isBare(){return l.isTruthyAttr(this.getAttribute("bare"),!1)}_locale(){return l.normalizeLocale(this.getAttribute("locale"))}_translations(){return K.resolveDateTimeTranslations(this.getAttribute("locale"),this.getAttribute("translations"))}_minuteStep(){const t=Number(this.getAttribute("step")||5);return!Number.isFinite(t)||t<1?5:Math.min(60,Math.trunc(t))}_formatDisplay(t){if(!t.date||!t.time)return"";const e=l.formatDateForDisplay(t.date,this._locale(),"locale",null);return this._is12h()?`${e} ${l.to12hDisplay(t.time,this._locale())}`:`${e} ${t.time}`}_is12h(){return(this.getAttribute("format")||"24h")==="12h"}_parseDateInput(t){const e=l.normalizeDateIso(t);if(e)return e;const i=l.parseUserDateInput(t,this._locale());if(i)return i;const s=new Date(t);if(!Number.isFinite(s.getTime()))return null;const a=s.getFullYear(),o=String(s.getMonth()+1).padStart(2,"0"),n=String(s.getDate()).padStart(2,"0");return`${a}-${o}-${n}`}_syncOpenAttribute(t){this._syncing=!0;try{t?this.hasAttribute("open")||this.setAttribute("open",""):this.hasAttribute("open")&&this.removeAttribute("open")}finally{this._syncing=!1}}_syncValueAttribute(t){const e=y(t);this._syncing=!0;try{e?this.getAttribute("value")!==e&&this.setAttribute("value",e):this.hasAttribute("value")&&this.removeAttribute("value")}finally{this._syncing=!1}}_emitInput(t){const e={mode:"datetime",value:y(this._pending),date:this._pending.date,time:this._pending.time,source:t};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,composed:!0}))}_emitChange(t){const e={mode:"datetime",value:y(this._value),date:this._value.date,time:this._value.time,source:t};this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,composed:!0}))}_emitInvalid(t,e){this.dispatchEvent(new CustomEvent("invalid",{detail:{raw:t,reason:e},bubbles:!0,composed:!0}))}_minDate(){return l.parseConstraintDate(this.getAttribute("min"))}_maxDate(){return l.parseConstraintDate(this.getAttribute("max"))}_minDateTime(){const t=l.parseConstraintDateTime(this.getAttribute("min"));return t?`${t.date}T${t.time}`:null}_maxDateTime(){const t=l.parseConstraintDateTime(this.getAttribute("max"));return t?`${t.date}T${t.time}`:null}_clampState(t){if(!t.date)return{date:null,time:t.time};const e=this._minDate(),i=this._maxDate(),s=l.clampDateIso(t.date,e,i),a=t.time||"00:00";let o=this._minDateTime(),n=this._maxDateTime();if(o&&n&&l.compareDateTimes(o,n)>0){const f=o;o=n,n=f}let r=l.combineDateTime(s,a)||`${s}T00:00`;o&&l.compareDateTimes(r,o)<0&&(r=o),n&&l.compareDateTimes(r,n)>0&&(r=n);const u=l.splitDateTime(r);return u?{date:u.date,time:u.time}:{date:s,time:a}}_commit(t,e){if(this._isInteractionBlocked()||this._isReadonly())return;if(!t.date&&!t.time){this._value={date:null,time:null},this._pending={date:null,time:null},this._draft="",this._inlineError="",this._syncValueAttribute(this._value),this._emitInput(e),this._emitChange(e),this._updateHostState();return}const i=l.parseTimeInput(t.time||"",!0),s=this._clampState({date:l.normalizeDateIso(t.date),time:i?`${h(i.hours)}:${h(i.minutes)}`:null});if(!s.date||!s.time){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(JSON.stringify(t),"parse"),this._updateHostState();return}this._value=s,this._pending={...s},this._draft=this._formatDisplay(s),this._inlineError="",this._syncValueAttribute(this._value),this._emitInput(e),this._emitChange(e),this._updateHostState()}_setOpen(t,e){t&&this._isInteractionBlocked()||this._open!==t&&(this._open=t,this._syncOpenAttribute(t),this._syncOverlay(e),this._updateHostState(),this.dispatchEvent(new CustomEvent(t?"open":"close",{bubbles:!0,composed:!0})))}_syncOverlay(t){if(this._isInlineMode()){this._destroyOverlay();return}if(this._open){this._ensureOverlay(),this._syncOverlayState();return}this._destroyOverlay();const e=this._restoreFocusEl;if(this._restoreFocusEl=null,e&&e.isConnected)try{e.focus()}catch{}}_ensureOverlay(){if(this._overlay||typeof document>"u")return;const t=document.createElement("div");t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.pointerEvents="none",t.addEventListener("click",this._onOverlayClickBound),t.addEventListener("change",this._onOverlayChangeBound),t.addEventListener("change",this._onOverlayCalendarBound),t.addEventListener("select",this._onOverlayCalendarBound),document.body.appendChild(t),this._overlay=t,this._syncOverlayHostZIndex(),document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound),window.addEventListener("resize",this._onWindowResizeBound),window.addEventListener("scroll",this._onWindowScrollBound,{passive:!0,capture:!0}),this._isMobileSheet()&&(this._releaseScrollLock=l.lockBodyScroll())}_syncOverlayHostZIndex(){if(!this._overlay||typeof window>"u")return;const t=window.getComputedStyle(this).getPropertyValue("--ui-dtp-z").trim();this._overlay.style.zIndex=t||"1600"}_destroyOverlay(){var t;(t=this._dismissableLayer)==null||t.destroy(),this._dismissableLayer=null,this._overlay&&(this._schedulePosition.cancel(),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound),window.removeEventListener("resize",this._onWindowResizeBound),window.removeEventListener("scroll",this._onWindowScrollBound,!0),this._overlay.removeEventListener("click",this._onOverlayClickBound),this._overlay.removeEventListener("change",this._onOverlayChangeBound),this._overlay.removeEventListener("change",this._onOverlayCalendarBound),this._overlay.removeEventListener("select",this._onOverlayCalendarBound),this._overlay.parentElement&&this._overlay.parentElement.removeChild(this._overlay),this._overlay=null,this._overlayKey=null,this._releaseScrollLock&&(this._releaseScrollLock(),this._releaseScrollLock=null))}_syncDismissableLayer(){var i;if((i=this._dismissableLayer)==null||i.destroy(),this._dismissableLayer=null,!this._open||!this._overlay)return;const t=this._overlay.querySelector(".panel, .sheet"),e=this.root.querySelector(".field");t&&(this._dismissableLayer=N.createDismissableLayer({node:t,trigger:e,closeOnEscape:!0,closeOnPointerOutside:!0,closeOnFocusOutside:!1,onBeforeDismiss:s=>s==="escape-key"?(this._setOpen(!1,"escape"),!1):(s==="outside-pointer"&&this._setOpen(!1,"outside"),!1)}))}_positionOverlay(){if(!this._overlay||!this._open||this._isMobileSheet())return;const t=this.root.querySelector(".field"),e=this._overlay.querySelector(".panel");if(!t||!e)return;const i=e.getAttribute("data-placement"),s=l.computePopoverPosition(t.getBoundingClientRect(),e.getBoundingClientRect(),8,8,i==="top"?"top":i==="bottom"?"bottom":null);e.style.position="absolute",e.style.top=`${Math.round(s.top)}px`,e.style.left=`${Math.round(s.left)}px`,e.setAttribute("data-placement",s.placement)}_timeOptions(){const t=l.parseTimeInput(this._pending.time||"00:00",!0)||{hours:0,minutes:0,seconds:0},e=this._minuteStep(),i=this._is12h()?Array.from({length:12},(o,n)=>{const r=n+1,u=t.hours%12||12;return`<option value="${r}" ${r===u?"selected":""}>${h(r)}</option>`}).join(""):Array.from({length:24},(o,n)=>`<option value="${n}" ${n===t.hours?"selected":""}>${h(n)}</option>`).join(""),s=Array.from({length:Math.ceil(60/e)},(o,n)=>{const r=Math.min(59,n*e);return`<option value="${r}" ${r===t.minutes?"selected":""}>${h(r)}</option>`}).join(""),a=t.hours>=12?"pm":"am";return{hours:i,minutes:s,meridiem:a}}_renderSurfaceInner(t,e=!1){const i=this._translations(),s=this._timeOptions(),a=(this.getAttribute("label")||"").trim(),o=p(a),n=p(a||i.selectDate),r=this._pending.date&&this._pending.time?this._formatDisplay(this._pending):"",u=`
|
|
461
|
+
`;function h(m){return String(m).padStart(2,"0")}function p(m){return m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function H(m){const t=l.splitDateTime(m);return t?{date:t.date,time:t.time}:{date:null,time:null}}function y(m){return l.combineDateTime(m.date,m.time)}class V extends F.ElementBase{constructor(){super(...arguments),this._value={date:null,time:null},this._pending={date:null,time:null},this._draft="",this._inlineError="",this._open=!1,this._syncing=!1,this._overlay=null,this._dismissableLayer=null,this._releaseScrollLock=null,this._isInitialized=!1,this._hasView=!1,this._restoreFocusEl=null,this._overlayKey=null,this._uid=`ui-dtp-${++U}`,this._inputId=`${this._uid}-input`,this._labelId=`${this._uid}-label`,this._hintId=`${this._uid}-hint`,this._errorId=`${this._uid}-error`,this._panelId=`${this._uid}-panel`,this._schedulePosition=l.rafThrottle(()=>this._positionOverlay()),this._onRootClickBound=t=>this._onRootClick(t),this._onRootInputBound=t=>this._onRootInput(t),this._onRootChangeBound=t=>this._onRootChange(t),this._onRootBlurBound=t=>this._onRootBlur(t),this._onRootKeyDownBound=t=>this._onRootKeyDown(t),this._onOverlayClickBound=t=>this._onOverlayClick(t),this._onOverlayChangeBound=t=>this._onOverlayChange(t),this._onOverlayCalendarBound=t=>this._onOverlayCalendar(t),this._onDocumentPointerDownBound=t=>this._onDocumentPointerDown(t),this._onDocumentKeyDownBound=t=>this._onDocumentKeyDown(t),this._onWindowResizeBound=()=>this._schedulePosition.run(),this._onWindowScrollBound=t=>{l.eventOriginatesWithin(t,[this._overlay])||this._schedulePosition.run()}}static get observedAttributes(){return["open","default-open","value","default-value","min","max","locale","translations","week-start","size","shape","bare","variant","state","step","format","disabled","readonly","required","name","close-on-select","clearable","allow-input","mode","label","hint","error","show-footer"]}connectedCallback(){if(super.connectedCallback(),this.root.addEventListener("click",this._onRootClickBound),this.root.addEventListener("input",this._onRootInputBound),this.root.addEventListener("change",this._onRootChangeBound),this.root.addEventListener("focusout",this._onRootBlurBound),this.root.addEventListener("keydown",this._onRootKeyDownBound),!this._isInitialized){const t=H(this.getAttribute("value")||this.getAttribute("default-value"));this._value=t,this._pending={...t},this._draft=this._formatDisplay(t),this._open=this.hasAttribute("open")||l.isTruthyAttr(this.getAttribute("default-open")),this._isInitialized=!0}this._open&&!this._isInlineMode()&&this._ensureOverlay()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClickBound),this.root.removeEventListener("input",this._onRootInputBound),this.root.removeEventListener("change",this._onRootChangeBound),this.root.removeEventListener("focusout",this._onRootBlurBound),this.root.removeEventListener("keydown",this._onRootKeyDownBound),this._destroyOverlay(),super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e!==i&&(t==="value"&&!this._syncing&&(this._value=H(i),this._pending={...this._value},this._draft=this._formatDisplay(this._value),this._inlineError=""),t==="open"&&!this._syncing&&(this._open=this.hasAttribute("open"),this._syncOverlay("attribute")),t==="mode"&&this._syncOverlay("attribute"),t==="disabled"&&this.hasAttribute("disabled")&&this._setOpen(!1,"outside"),t==="state"&&this._state()==="loading"&&this._setOpen(!1,"outside"),!!this.isConnected)){if(!this._hasView){this.requestRender();return}this._updateHostState()}}_isInlineMode(){return(this.getAttribute("mode")||"popover")==="inline"}_isMobileSheet(){return l.shouldUseMobileSheet(this.getAttribute("mode"))}_isDisabled(){return this.hasAttribute("disabled")}_state(){const t=(this.getAttribute("state")||"").trim().toLowerCase();return t==="loading"||t==="error"||t==="success"?t:"idle"}_isInteractionBlocked(){return this._isDisabled()||this._state()==="loading"}_isReadonly(){return this.hasAttribute("readonly")}_allowInput(){return l.isTruthyAttr(this.getAttribute("allow-input"),!0)}_clearable(){return l.isTruthyAttr(this.getAttribute("clearable"),!0)}_closeOnSelect(){return l.isTruthyAttr(this.getAttribute("close-on-select"),!1)}_shouldAutoCommit(){return this._closeOnSelect()||!this._showFooter()}_showFooter(){return l.isTruthyAttr(this.getAttribute("show-footer"),!0)}_isBare(){return l.isTruthyAttr(this.getAttribute("bare"),!1)}_locale(){return l.normalizeLocale(this.getAttribute("locale"))}_translations(){return K.resolveDateTimeTranslations(this.getAttribute("locale"),this.getAttribute("translations"))}_minuteStep(){const t=Number(this.getAttribute("step")||5);return!Number.isFinite(t)||t<1?5:Math.min(60,Math.trunc(t))}_formatDisplay(t){if(!t.date||!t.time)return"";const e=l.formatDateForDisplay(t.date,this._locale(),"locale",null);return this._is12h()?`${e} ${l.to12hDisplay(t.time,this._locale())}`:`${e} ${t.time}`}_is12h(){return(this.getAttribute("format")||"24h")==="12h"}_parseDateInput(t){const e=l.normalizeDateIso(t);if(e)return e;const i=l.parseUserDateInput(t,this._locale());if(i)return i;const r=new Date(t);if(!Number.isFinite(r.getTime()))return null;const a=r.getFullYear(),o=String(r.getMonth()+1).padStart(2,"0"),s=String(r.getDate()).padStart(2,"0");return`${a}-${o}-${s}`}_syncOpenAttribute(t){this._syncing=!0;try{t?this.hasAttribute("open")||this.setAttribute("open",""):this.hasAttribute("open")&&this.removeAttribute("open")}finally{this._syncing=!1}}_syncValueAttribute(t){const e=y(t);this._syncing=!0;try{e?this.getAttribute("value")!==e&&this.setAttribute("value",e):this.hasAttribute("value")&&this.removeAttribute("value")}finally{this._syncing=!1}}_emitInput(t){const e={mode:"datetime",value:y(this._pending),date:this._pending.date,time:this._pending.time,source:t};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,composed:!0}))}_emitChange(t){const e={mode:"datetime",value:y(this._value),date:this._value.date,time:this._value.time,source:t};this.dispatchEvent(new CustomEvent("change",{detail:e,bubbles:!0,composed:!0}))}_emitInvalid(t,e){this.dispatchEvent(new CustomEvent("invalid",{detail:{raw:t,reason:e},bubbles:!0,composed:!0}))}_minDate(){return l.parseConstraintDate(this.getAttribute("min"))}_maxDate(){return l.parseConstraintDate(this.getAttribute("max"))}_minDateTime(){const t=l.parseConstraintDateTime(this.getAttribute("min"));return t?`${t.date}T${t.time}`:null}_maxDateTime(){const t=l.parseConstraintDateTime(this.getAttribute("max"));return t?`${t.date}T${t.time}`:null}_clampState(t){if(!t.date)return{date:null,time:t.time};const e=this._minDate(),i=this._maxDate(),r=l.clampDateIso(t.date,e,i),a=t.time||"00:00";let o=this._minDateTime(),s=this._maxDateTime();if(o&&s&&l.compareDateTimes(o,s)>0){const b=o;o=s,s=b}let n=l.combineDateTime(r,a)||`${r}T00:00`;o&&l.compareDateTimes(n,o)<0&&(n=o),s&&l.compareDateTimes(n,s)>0&&(n=s);const u=l.splitDateTime(n);return u?{date:u.date,time:u.time}:{date:r,time:a}}_commit(t,e){if(this._isInteractionBlocked()||this._isReadonly())return;if(!t.date&&!t.time){this._value={date:null,time:null},this._pending={date:null,time:null},this._draft="",this._inlineError="",this._syncValueAttribute(this._value),this._emitInput(e),this._emitChange(e),this._updateHostState();return}const i=l.parseTimeInput(t.time||"",!0),r=this._clampState({date:l.normalizeDateIso(t.date),time:i?`${h(i.hours)}:${h(i.minutes)}`:null});if(!r.date||!r.time){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(JSON.stringify(t),"parse"),this._updateHostState();return}this._value=r,this._pending={...r},this._draft=this._formatDisplay(r),this._inlineError="",this._syncValueAttribute(this._value),this._emitInput(e),this._emitChange(e),this._updateHostState()}_setOpen(t,e){t&&this._isInteractionBlocked()||this._open!==t&&(this._open=t,this._syncOpenAttribute(t),this._syncOverlay(e),this._updateHostState(),this.dispatchEvent(new CustomEvent(t?"open":"close",{bubbles:!0,composed:!0})))}_syncOverlay(t){if(this._isInlineMode()){this._destroyOverlay();return}if(this._open){this._ensureOverlay(),this._syncOverlayState();return}this._destroyOverlay();const e=this._restoreFocusEl;if(this._restoreFocusEl=null,e&&e.isConnected)try{e.focus()}catch{}}_ensureOverlay(){if(this._overlay||typeof document>"u")return;const t=document.createElement("div");t.className="ui-date-time-picker-overlay-host",t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.pointerEvents="none",t.addEventListener("click",this._onOverlayClickBound),t.addEventListener("change",this._onOverlayChangeBound),t.addEventListener("change",this._onOverlayCalendarBound),t.addEventListener("select",this._onOverlayCalendarBound),document.body.appendChild(t),this._overlay=t,this._syncOverlayHostZIndex(),document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound),window.addEventListener("resize",this._onWindowResizeBound),window.addEventListener("scroll",this._onWindowScrollBound,{passive:!0,capture:!0}),this._isMobileSheet()&&(this._releaseScrollLock=l.lockBodyScroll())}_syncOverlayHostZIndex(){if(!this._overlay||typeof window>"u")return;const t=window.getComputedStyle(this).getPropertyValue("--ui-dtp-z").trim();this._overlay.style.zIndex=t||"1600"}_destroyOverlay(){var t;(t=this._dismissableLayer)==null||t.destroy(),this._dismissableLayer=null,this._overlay&&(this._schedulePosition.cancel(),document.removeEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.removeEventListener("keydown",this._onDocumentKeyDownBound),window.removeEventListener("resize",this._onWindowResizeBound),window.removeEventListener("scroll",this._onWindowScrollBound,!0),this._overlay.removeEventListener("click",this._onOverlayClickBound),this._overlay.removeEventListener("change",this._onOverlayChangeBound),this._overlay.removeEventListener("change",this._onOverlayCalendarBound),this._overlay.removeEventListener("select",this._onOverlayCalendarBound),this._overlay.parentElement&&this._overlay.parentElement.removeChild(this._overlay),this._overlay=null,this._overlayKey=null,this._releaseScrollLock&&(this._releaseScrollLock(),this._releaseScrollLock=null))}_syncDismissableLayer(){var i;if((i=this._dismissableLayer)==null||i.destroy(),this._dismissableLayer=null,!this._open||!this._overlay)return;const t=this._overlay.querySelector(".panel, .sheet"),e=this.root.querySelector(".field");t&&(this._dismissableLayer=N.createDismissableLayer({node:t,trigger:e,closeOnEscape:!0,closeOnPointerOutside:!0,closeOnFocusOutside:!1,onBeforeDismiss:r=>r==="escape-key"?(this._setOpen(!1,"escape"),!1):(r==="outside-pointer"&&this._setOpen(!1,"outside"),!1)}))}_positionOverlay(){if(!this._overlay||!this._open||this._isMobileSheet())return;const t=this.root.querySelector(".field"),e=this._overlay.querySelector(".panel");if(!t||!e)return;const i=e.getAttribute("data-placement"),r=l.computePopoverPosition(t.getBoundingClientRect(),e.getBoundingClientRect(),8,8,i==="top"?"top":i==="bottom"?"bottom":null);e.style.position="absolute",e.style.top=`${Math.round(r.top)}px`,e.style.left=`${Math.round(r.left)}px`,e.setAttribute("data-placement",r.placement)}_timeOptions(){const t=l.parseTimeInput(this._pending.time||"00:00",!0)||{hours:0,minutes:0,seconds:0},e=this._minuteStep(),i=this._is12h()?Array.from({length:12},(o,s)=>{const n=s+1,u=t.hours%12||12;return`<option value="${n}" ${n===u?"selected":""}>${h(n)}</option>`}).join(""):Array.from({length:24},(o,s)=>`<option value="${s}" ${s===t.hours?"selected":""}>${h(s)}</option>`).join(""),r=Array.from({length:Math.ceil(60/e)},(o,s)=>{const n=Math.min(59,s*e);return`<option value="${n}" ${n===t.minutes?"selected":""}>${h(n)}</option>`}).join(""),a=t.hours>=12?"pm":"am";return{hours:i,minutes:r,meridiem:a}}_renderSurfaceInner(t,e=!1){const i=this._translations(),r=this._timeOptions(),a=(this.getAttribute("label")||"").trim(),o=p(a),s=p(a||i.selectDate),n=this._pending.date&&this._pending.time?this._formatDisplay(this._pending):"",u=`
|
|
446
462
|
<header class="head">
|
|
447
463
|
<div>
|
|
448
464
|
<p class="head-title" ${a?"":"hidden"}>${o}</p>
|
|
449
|
-
<p class="head-meta">${p(
|
|
465
|
+
<p class="head-meta">${p(n||i.selectDate)}</p>
|
|
450
466
|
</div>
|
|
451
467
|
</header>
|
|
452
468
|
<div class="content">
|
|
@@ -454,9 +470,9 @@
|
|
|
454
470
|
<section class="time-panel" part="time">
|
|
455
471
|
<span class="icon" aria-hidden="true">${P}</span>
|
|
456
472
|
<div class="time-grid" data-meridiem="${this._is12h()?"true":"false"}">
|
|
457
|
-
<div><label>${p(i.hour)}</label><select data-segment="hours">${
|
|
458
|
-
<div><label>${p(i.minute)}</label><select data-segment="minutes">${
|
|
459
|
-
${this._is12h()?`<div><label>${p(i.meridiem)}</label><select data-segment="meridiem"><option value="am" ${
|
|
473
|
+
<div><label>${p(i.hour)}</label><select data-segment="hours">${r.hours}</select></div>
|
|
474
|
+
<div><label>${p(i.minute)}</label><select data-segment="minutes">${r.minutes}</select></div>
|
|
475
|
+
${this._is12h()?`<div><label>${p(i.meridiem)}</label><select data-segment="meridiem"><option value="am" ${r.meridiem==="am"?"selected":""}>${p(i.am)}</option><option value="pm" ${r.meridiem==="pm"?"selected":""}>${p(i.pm)}</option></select></div>`:""}
|
|
460
476
|
</div>
|
|
461
477
|
</section>
|
|
462
478
|
</div>
|
|
@@ -469,8 +485,8 @@
|
|
|
469
485
|
`;return e?u:`
|
|
470
486
|
<style>${J}</style>
|
|
471
487
|
${t?'<div class="sheet-backdrop" data-action="backdrop"></div>':""}
|
|
472
|
-
<section class="${t?"sheet":"panel"}" id="${this._panelId}" role="dialog" aria-modal="${t?"true":"false"}" aria-label="${
|
|
473
|
-
`}_syncCalendar(t){const e=(n,r)=>{if(r==null||r===""){t.hasAttribute(n)&&t.removeAttribute(n);return}t.getAttribute(n)!==r&&t.setAttribute(n,r)},i=(n,r)=>{r?e(n,""):e(n,null)};e("selection","single"),e("value",this._pending.date),e("min",this.getAttribute("min")),e("max",this.getAttribute("max")),e("locale",this.getAttribute("locale")),e("translations",this.getAttribute("translations")),e("week-start",this.getAttribute("week-start"));const a=this.getAttribute("size")||"sm",o=t.classList.contains("dt-calendar-inline");e("size",a==="lg"?"md":"sm"),e("variant",this.getAttribute("variant")),i("readonly",this._isReadonly()),i("disabled",this._isInteractionBlocked()),i("bare",this._isBare()),e("tabindex","-1"),a==="lg"?(t.style.setProperty("--ui-calendar-day-height","1.95em"),t.style.setProperty("--ui-calendar-day-padding-block","0.2em"),t.style.setProperty("--ui-calendar-day-padding-inline","0.26em"),t.style.setProperty("--ui-calendar-gap","0.42em"),t.style.setProperty("--ui-calendar-day-font-size","0.78em"),t.style.setProperty("--ui-calendar-weekday-font-size","0.7em"),t.style.setProperty("--ui-calendar-title-font-size","0.88em")):(t.style.setProperty("--ui-calendar-day-height","2.4em"),t.style.setProperty("--ui-calendar-day-padding-block","0.14em"),t.style.setProperty("--ui-calendar-day-padding-inline","0.22em"),t.style.setProperty("--ui-calendar-gap","0.34em"),t.style.setProperty("--ui-calendar-day-font-size","0.72em"),t.style.setProperty("--ui-calendar-weekday-font-size","0.64em"),t.style.setProperty("--ui-calendar-title-font-size","0.8em")),o?(t.style.setProperty("--ui-calendar-frame-padding","0.32em"),t.style.setProperty("--ui-calendar-week-gap","0.18em"),t.style.setProperty("--ui-calendar-control-height","1.72em"),t.style.setProperty("--ui-calendar-gap","0.24em")):(t.style.removeProperty("--ui-calendar-frame-padding"),t.style.removeProperty("--ui-calendar-week-gap"),t.style.removeProperty("--ui-calendar-control-height")),e("aria-label",this.getAttribute("label")||this._translations().selectDate)}_overlaySignature(t){return[t?"sheet":"popover",this._minuteStep(),this._is12h()?"12h":"24h",this.getAttribute("locale")||"",this.getAttribute("translations")||""].join(":")}_ensureOverlayContent(t){if(!this._overlay)return;const e=this._overlaySignature(t);this._overlayKey===e&&this._overlay.querySelector(".dt-calendar")||(this._overlayKey=e,this._overlay.innerHTML=t?`<div class="sheet-wrap">${this._renderSurfaceInner(!0)}</div>`:`<div class="overlay">${this._renderSurfaceInner(!1)}</div>`)}_setClosestOptionValue(t,e){const i=Array.from(t.options).map(o=>Number(o.value)).filter(o=>Number.isFinite(o));if(!i.length)return;let s=i[0],a=Math.abs(s-e);for(let o=1;o<i.length;o+=1){const n=i[o],r=Math.abs(n-e);r<a&&(s=n,a=r)}t.value=String(s)}_syncOverlayState(){if(!this._overlay)return;this._syncOverlayHostZIndex();const t=this._isMobileSheet();this._ensureOverlayContent(t),this._syncDismissableLayer();const e=this._translations(),i=this._overlay.querySelector(".panel, .sheet"),s=this._overlay.querySelector(".footer");i&&(i.dataset.bare=this._isBare()?"true":"false"),s&&(s.hidden=!this._showFooter());const a=this._overlay.querySelector(".head-title");if(a){const d=(this.getAttribute("label")||"").trim();a.textContent=d,a.hidden=!d}const o=this._overlay.querySelector(".head-meta");o&&(o.textContent=this._pending.date&&this._pending.time?this._formatDisplay(this._pending):e.selectDate);const n=this._overlay.querySelector(".dt-calendar");n&&this._syncCalendar(n);const r=l.parseTimeInput(this._pending.time||"00:00",!0)||{hours:0,minutes:0,seconds:0},u=this._overlay.querySelector('select[data-segment="hours"]'),f=this._overlay.querySelector('select[data-segment="minutes"]'),_=this._overlay.querySelector('select[data-segment="meridiem"]');if(u){const d=this._is12h()?r.hours%12||12:r.hours;this._setClosestOptionValue(u,d),u.disabled=this._isInteractionBlocked()||this._isReadonly()}f&&(this._setClosestOptionValue(f,r.minutes),f.disabled=this._isInteractionBlocked()||this._isReadonly()),_&&(_.value=r.hours>=12?"pm":"am",_.disabled=this._isInteractionBlocked()||this._isReadonly());const x=this._isInteractionBlocked()||this._isReadonly();this._overlay.querySelectorAll(".action").forEach(d=>{d.disabled=x}),t||this._schedulePosition.run()}_renderOverlay(){this._syncOverlayState()}_applyTimeFromSurface(t){const e=t.querySelector('select[data-segment="hours"]'),i=t.querySelector('select[data-segment="minutes"]'),s=t.querySelector('select[data-segment="meridiem"]');if(!e||!i)return;const a=Number(e.value),o=Number(i.value);if(!Number.isFinite(a)||!Number.isFinite(o))return;let n=a;if(this._is12h()){const r=(s==null?void 0:s.value)==="pm"?"pm":"am";r==="pm"&&n<12&&(n+=12),r==="am"&&n===12&&(n=0)}this._pending=this._clampState({date:this._pending.date,time:`${h(n)}:${h(o)}`}),this._emitInput("time")}_onRootClick(t){var s;const e=t.target;if(!e)return;const i=(s=e.closest("[data-action]"))==null?void 0:s.getAttribute("data-action");if(i&&!(this._isInteractionBlocked()||this._isReadonly())){if(i==="toggle"){this._restoreFocusEl=e,this._setOpen(!this._open,"toggle");return}if(i==="clear"){this._isInlineMode()?(this._pending={date:null,time:null},this._emitInput("clear"),this._updateHostState()):this._commit({date:null,time:null},"clear");return}if(this._isInlineMode()&&i==="now"){const a=new Date,o=String(a.getMonth()+1).padStart(2,"0"),n=String(a.getDate()).padStart(2,"0"),r=`${a.getFullYear()}-${o}-${n}`,u=`${h(a.getHours())}:${h(a.getMinutes())}`;this._pending=this._clampState({date:r,time:u}),this._emitInput("now"),this._updateHostState();return}if(this._isInlineMode()&&i==="cancel"){this._pending={...this._value},this._updateHostState();return}this._isInlineMode()&&i==="apply"&&this._commit(this._pending,"apply")}}_onRootChange(t){if(!this._isInlineMode())return;const e=t.target;if(e){if(e.tagName.toLowerCase()==="ui-calendar"){this._onOverlayCalendar(t);return}if(e instanceof HTMLSelectElement&&e.closest(".inline-panel")){if(!e.matches("select[data-segment]")||this._isInteractionBlocked()||this._isReadonly())return;const i=this.root.querySelector(".inline-panel");if(!i)return;if(this._applyTimeFromSurface(i),this._shouldAutoCommit()&&this._pending.date&&this._pending.time){this._commit(this._pending,"time");return}this._updateHostState()}}}_onRootInput(t){const e=t.target;e instanceof HTMLInputElement&&e.classList.contains("input")&&this._allowInput()&&(this._isInteractionBlocked()||(this._draft=e.value,this._inlineError="",this._emitInput("typing")))}_onRootBlur(t){const e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("input")||!this._allowInput()||this._isInteractionBlocked())return;const i=this._draft.trim();if(!i){this._commit({date:null,time:null},"blur");return}const s=/^(.+)\s+(\d{1,2}:\d{2}(?::\d{2})?(?:\s?[ap]m)?)$/i.exec(i);if(!s){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(i,"parse"),this._updateHostState();return}const a=this._parseDateInput(s[1]),o=l.parseTimeInput(s[2],!0)?s[2]:null;if(!a||!o){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(i,"parse"),this._updateHostState();return}this._commit({date:a,time:o},"blur")}_onRootKeyDown(t){const e=t;if(!this._isInteractionBlocked()){if(e.key==="Escape"&&this._open&&!this._isInlineMode()){e.preventDefault(),this._setOpen(!1,"escape");return}e.key==="ArrowDown"&&!this._open&&!this._isInlineMode()&&(e.preventDefault(),this._setOpen(!0,"keyboard"))}}_onOverlayClick(t){var s;const e=t.target;if(!e)return;const i=(s=e.closest("[data-action]"))==null?void 0:s.getAttribute("data-action");if(i&&!this._isInteractionBlocked()&&!(this._isReadonly()&&i!=="toggle")){if(i==="backdrop"){this._setOpen(!1,"outside");return}if(i==="cancel"){this._pending={...this._value},this._setOpen(!1,"cancel");return}if(i==="clear"){this._pending={date:null,time:null},this._emitInput("clear"),this._renderOverlay();return}if(i==="now"){const a=new Date,o=String(a.getMonth()+1).padStart(2,"0"),n=String(a.getDate()).padStart(2,"0"),r=`${a.getFullYear()}-${o}-${n}`,u=`${h(a.getHours())}:${h(a.getMinutes())}`;this._pending=this._clampState({date:r,time:u}),this._emitInput("now"),this._renderOverlay();return}i==="apply"&&(this._commit(this._pending,"apply"),this._setOpen(!1,"apply"))}}_onOverlayChange(t){const e=t.target;e instanceof HTMLSelectElement&&e.matches("select[data-segment]")&&(this._isInteractionBlocked()||this._overlay&&(this._applyTimeFromSurface(this._overlay),this._shouldAutoCommit()&&this._pending.date&&this._pending.time&&(this._commit(this._pending,"time"),this._setOpen(!1,"time"))))}_onOverlayCalendar(t){if(this._isInteractionBlocked()||this._isReadonly())return;const e=t.target;if(!e||e.tagName.toLowerCase()!=="ui-calendar")return;const i=t.type,s=t.detail,a=l.normalizeDateIso(i==="select"?(s==null?void 0:s.value)||null:s==null?void 0:s.value);if(a){if(this._pending=this._clampState({date:a,time:this._pending.time||"09:00"}),this._emitInput("calendar"),this._shouldAutoCommit()&&this._pending.time){this._commit(this._pending,"calendar"),this._setOpen(!1,"calendar");return}this._updateHostState()}}_onDocumentPointerDown(t){if(!this._open||!this._overlay)return;const e=t.composedPath();e.includes(this)||e.includes(this._overlay)||this._setOpen(!1,"outside")}_onDocumentKeyDown(t){this._open&&t.key==="Escape"&&(t.preventDefault(),this._setOpen(!1,"escape"))}_updateHostState(){if(!this._hasView)return;const t=this.getAttribute("label")||"",e=this.getAttribute("hint")||"",i=this.getAttribute("error")||"",s=this._inlineError||i,a=!!y(this._value),o=this.getAttribute("name")||"",n=this._allowInput()?this._draft:this._formatDisplay(this._value),r=this._isInlineMode(),u=this._translations(),f=s?"error":this._state();this._state()==="loading"?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");const _=this.root.querySelector(".label"),x=this.root.querySelector(".label-text"),k=this.root.querySelector(".required"),d=this.root.querySelector(".input"),I=this.root.querySelector('.btn[data-action="clear"]'),g=this.root.querySelector('.btn[data-action="toggle"]'),v=this.root.querySelector(".hint"),S=this.root.querySelector(".error"),w=this.root.querySelector(".hidden-input");if(_&&(_.hidden=!t),_&&(_.id=this._labelId,_.setAttribute("for",this._inputId)),x&&(x.textContent=t),k&&(k.hidden=!this.hasAttribute("required")),d&&(d.value!==n&&(d.value=n),d.id=this._inputId,d.placeholder=u.dateTimePlaceholder,d.readOnly=!this._allowInput()||this._isReadonly(),d.disabled=this._isInteractionBlocked(),d.required=this.hasAttribute("required"),d.autocomplete="off",d.setAttribute("role","combobox"),d.setAttribute("aria-haspopup","dialog"),d.setAttribute("aria-expanded",r?"false":String(this._open)),d.setAttribute("aria-controls",this._panelId),d.setAttribute("aria-invalid",s?"true":"false"),t?d.setAttribute("aria-labelledby",this._labelId):d.removeAttribute("aria-labelledby")),I&&(I.hidden=!(this._clearable()&&a),I.setAttribute("aria-label",u.clear),I.disabled=this._isInteractionBlocked()),g&&(g.hidden=r,g.setAttribute("aria-label",u.toggleCalendar),g.setAttribute("aria-expanded",r?"false":String(this._open)),g.setAttribute("aria-controls",this._panelId),g.disabled=this._isInteractionBlocked()),v&&(v.id=this._hintId,v.hidden=!e,v.textContent=e),S&&(S.id=this._errorId,S.hidden=!s,S.textContent=s),d){const b=[];e&&v&&!v.hidden&&b.push(this._hintId),s&&b.push(this._errorId),b.length?d.setAttribute("aria-describedby",b.join(" ")):d.removeAttribute("aria-describedby")}w&&(w.disabled=!o,w.name=o,w.value=y(this._value)||"");const A=this.root.querySelector(".field");A&&(A.dataset.open=this._open&&!r?"true":"false",A.dataset.invalid=s?"true":"false",A.dataset.state=f);const c=this.root.querySelector(".inline-panel");if(c){c.hidden=!r,c.id=this._panelId,c.dataset.bare=this._isBare()?"true":"false",c.setAttribute("role","dialog"),c.setAttribute("aria-modal","false"),c.setAttribute("aria-label",t||u.selectDate);const b=c.querySelector(".panel-title");b&&(b.textContent=t,b.hidden=!t);const D=c.querySelector(".head-title");D&&(D.textContent=t,D.hidden=!t);const T=c.querySelector(".head-meta");T&&(T.textContent=this._pending.date&&this._pending.time?this._formatDisplay(this._pending):u.selectDate);const L=c.querySelector('[data-action="now"]');L&&(L.textContent=u.now);const q=c.querySelector('[data-action="clear"]');q&&(q.textContent=u.clear);const R=c.querySelector('[data-action="apply"]');R&&(R.textContent=u.apply);const E=c.querySelector(".footer");E&&(E.hidden=!this._showFooter());const M=c.querySelector(".dt-calendar-inline");M&&this._syncCalendar(M);const O=c.querySelector('select[data-segment="hours"]'),$=c.querySelector('select[data-segment="minutes"]'),B=c.querySelector('select[data-segment="meridiem"]'),C=l.parseTimeInput(this._pending.time||"00:00",!0)||{hours:0,minutes:0,seconds:0};if(O){const z=this._is12h()?C.hours%12||12:C.hours;this._setClosestOptionValue(O,z),O.disabled=this._isInteractionBlocked()||this._isReadonly()}$&&(this._setClosestOptionValue($,C.minutes),$.disabled=this._isInteractionBlocked()||this._isReadonly()),B&&(B.value=C.hours>=12?"pm":"am",B.disabled=this._isInteractionBlocked()||this._isReadonly()),c.querySelectorAll(".action").forEach(z=>{z.disabled=this._isInteractionBlocked()||this._isReadonly()})}!r&&this._open&&this._syncOverlayState(),r&&this._destroyOverlay()}render(){if(!this._hasView){const t=this._translations();this.setContent(`
|
|
488
|
+
<section class="${t?"sheet":"panel"}" id="${this._panelId}" role="dialog" aria-modal="${t?"true":"false"}" aria-label="${s}" part="${t?"sheet":"popover"}">${u}</section>
|
|
489
|
+
`}_syncCalendar(t){const e=(s,n)=>{if(n==null||n===""){t.hasAttribute(s)&&t.removeAttribute(s);return}t.getAttribute(s)!==n&&t.setAttribute(s,n)},i=(s,n)=>{n?e(s,""):e(s,null)};e("selection","single"),e("value",this._pending.date),e("min",this.getAttribute("min")),e("max",this.getAttribute("max")),e("locale",this.getAttribute("locale")),e("translations",this.getAttribute("translations")),e("week-start",this.getAttribute("week-start"));const a=this.getAttribute("size")||"sm",o=t.classList.contains("dt-calendar-inline");e("size",a==="lg"?"md":"sm"),e("variant",this.getAttribute("variant")),i("readonly",this._isReadonly()),i("disabled",this._isInteractionBlocked()),i("bare",this._isBare()),e("tabindex","-1"),a==="lg"?(t.style.setProperty("--ui-calendar-day-height","1.95em"),t.style.setProperty("--ui-calendar-day-padding-block","0.2em"),t.style.setProperty("--ui-calendar-day-padding-inline","0.26em"),t.style.setProperty("--ui-calendar-gap","0.42em"),t.style.setProperty("--ui-calendar-day-font-size","0.78em"),t.style.setProperty("--ui-calendar-weekday-font-size","0.7em"),t.style.setProperty("--ui-calendar-title-font-size","0.88em")):(t.style.setProperty("--ui-calendar-day-height","2.4em"),t.style.setProperty("--ui-calendar-day-padding-block","0.14em"),t.style.setProperty("--ui-calendar-day-padding-inline","0.22em"),t.style.setProperty("--ui-calendar-gap","0.34em"),t.style.setProperty("--ui-calendar-day-font-size","0.72em"),t.style.setProperty("--ui-calendar-weekday-font-size","0.64em"),t.style.setProperty("--ui-calendar-title-font-size","0.8em")),o?(t.style.setProperty("--ui-calendar-frame-padding","0.32em"),t.style.setProperty("--ui-calendar-week-gap","0.18em"),t.style.setProperty("--ui-calendar-control-height","1.72em"),t.style.setProperty("--ui-calendar-gap","0.24em")):(t.style.removeProperty("--ui-calendar-frame-padding"),t.style.removeProperty("--ui-calendar-week-gap"),t.style.removeProperty("--ui-calendar-control-height")),e("aria-label",this.getAttribute("label")||this._translations().selectDate)}_overlaySignature(t){return[t?"sheet":"popover",this._minuteStep(),this._is12h()?"12h":"24h",this.getAttribute("locale")||"",this.getAttribute("translations")||""].join(":")}_ensureOverlayContent(t){if(!this._overlay)return;const e=this._overlaySignature(t);this._overlayKey===e&&this._overlay.querySelector(".dt-calendar")||(this._overlayKey=e,this._overlay.innerHTML=t?`<div class="sheet-wrap">${this._renderSurfaceInner(!0)}</div>`:`<div class="overlay">${this._renderSurfaceInner(!1)}</div>`)}_setClosestOptionValue(t,e){const i=Array.from(t.options).map(o=>Number(o.value)).filter(o=>Number.isFinite(o));if(!i.length)return;let r=i[0],a=Math.abs(r-e);for(let o=1;o<i.length;o+=1){const s=i[o],n=Math.abs(s-e);n<a&&(r=s,a=n)}t.value=String(r)}_syncOverlayState(){if(!this._overlay)return;this._syncOverlayHostZIndex();const t=this._isMobileSheet();this._ensureOverlayContent(t),this._syncDismissableLayer();const e=this._translations(),i=this._overlay.querySelector(".panel, .sheet"),r=this._overlay.querySelector(".footer");i&&(i.dataset.bare=this._isBare()?"true":"false"),r&&(r.hidden=!this._showFooter());const a=this._overlay.querySelector(".head-title");if(a){const d=(this.getAttribute("label")||"").trim();a.textContent=d,a.hidden=!d}const o=this._overlay.querySelector(".head-meta");o&&(o.textContent=this._pending.date&&this._pending.time?this._formatDisplay(this._pending):e.selectDate);const s=this._overlay.querySelector(".dt-calendar");s&&this._syncCalendar(s);const n=l.parseTimeInput(this._pending.time||"00:00",!0)||{hours:0,minutes:0,seconds:0},u=this._overlay.querySelector('select[data-segment="hours"]'),b=this._overlay.querySelector('select[data-segment="minutes"]'),_=this._overlay.querySelector('select[data-segment="meridiem"]');if(u){const d=this._is12h()?n.hours%12||12:n.hours;this._setClosestOptionValue(u,d),u.disabled=this._isInteractionBlocked()||this._isReadonly()}b&&(this._setClosestOptionValue(b,n.minutes),b.disabled=this._isInteractionBlocked()||this._isReadonly()),_&&(_.value=n.hours>=12?"pm":"am",_.disabled=this._isInteractionBlocked()||this._isReadonly());const x=this._isInteractionBlocked()||this._isReadonly();this._overlay.querySelectorAll(".action").forEach(d=>{d.disabled=x}),t||this._schedulePosition.run()}_renderOverlay(){this._syncOverlayState()}_applyTimeFromSurface(t){const e=t.querySelector('select[data-segment="hours"]'),i=t.querySelector('select[data-segment="minutes"]'),r=t.querySelector('select[data-segment="meridiem"]');if(!e||!i)return;const a=Number(e.value),o=Number(i.value);if(!Number.isFinite(a)||!Number.isFinite(o))return;let s=a;if(this._is12h()){const n=(r==null?void 0:r.value)==="pm"?"pm":"am";n==="pm"&&s<12&&(s+=12),n==="am"&&s===12&&(s=0)}this._pending=this._clampState({date:this._pending.date,time:`${h(s)}:${h(o)}`}),this._emitInput("time")}_onRootClick(t){var r;const e=t.target;if(!e)return;const i=(r=e.closest("[data-action]"))==null?void 0:r.getAttribute("data-action");if(i&&!(this._isInteractionBlocked()||this._isReadonly())){if(i==="toggle"){this._restoreFocusEl=e,this._setOpen(!this._open,"toggle");return}if(i==="clear"){this._isInlineMode()?(this._pending={date:null,time:null},this._emitInput("clear"),this._updateHostState()):this._commit({date:null,time:null},"clear");return}if(this._isInlineMode()&&i==="now"){const a=new Date,o=String(a.getMonth()+1).padStart(2,"0"),s=String(a.getDate()).padStart(2,"0"),n=`${a.getFullYear()}-${o}-${s}`,u=`${h(a.getHours())}:${h(a.getMinutes())}`;this._pending=this._clampState({date:n,time:u}),this._emitInput("now"),this._updateHostState();return}if(this._isInlineMode()&&i==="cancel"){this._pending={...this._value},this._updateHostState();return}this._isInlineMode()&&i==="apply"&&this._commit(this._pending,"apply")}}_onRootChange(t){if(!this._isInlineMode())return;const e=t.target;if(e){if(e.tagName.toLowerCase()==="ui-calendar"){this._onOverlayCalendar(t);return}if(e instanceof HTMLSelectElement&&e.closest(".inline-panel")){if(!e.matches("select[data-segment]")||this._isInteractionBlocked()||this._isReadonly())return;const i=this.root.querySelector(".inline-panel");if(!i)return;if(this._applyTimeFromSurface(i),this._shouldAutoCommit()&&this._pending.date&&this._pending.time){this._commit(this._pending,"time");return}this._updateHostState()}}}_onRootInput(t){const e=t.target;e instanceof HTMLInputElement&&e.classList.contains("input")&&this._allowInput()&&(this._isInteractionBlocked()||(this._draft=e.value,this._inlineError="",this._emitInput("typing")))}_onRootBlur(t){const e=t.target;if(!(e instanceof HTMLInputElement)||!e.classList.contains("input")||!this._allowInput()||this._isInteractionBlocked())return;const i=this._draft.trim();if(!i){this._commit({date:null,time:null},"blur");return}const r=/^(.+)\s+(\d{1,2}:\d{2}(?::\d{2})?(?:\s?[ap]m)?)$/i.exec(i);if(!r){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(i,"parse"),this._updateHostState();return}const a=this._parseDateInput(r[1]),o=l.parseTimeInput(r[2],!0)?r[2]:null;if(!a||!o){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(i,"parse"),this._updateHostState();return}this._commit({date:a,time:o},"blur")}_onRootKeyDown(t){const e=t;if(!this._isInteractionBlocked()){if(e.key==="Escape"&&this._open&&!this._isInlineMode()){e.preventDefault(),this._setOpen(!1,"escape");return}e.key==="ArrowDown"&&!this._open&&!this._isInlineMode()&&(e.preventDefault(),this._setOpen(!0,"keyboard"))}}_onOverlayClick(t){var r;const e=t.target;if(!e)return;const i=(r=e.closest("[data-action]"))==null?void 0:r.getAttribute("data-action");if(i&&!this._isInteractionBlocked()&&!(this._isReadonly()&&i!=="toggle")){if(i==="backdrop"){this._setOpen(!1,"outside");return}if(i==="cancel"){this._pending={...this._value},this._setOpen(!1,"cancel");return}if(i==="clear"){this._pending={date:null,time:null},this._emitInput("clear"),this._renderOverlay();return}if(i==="now"){const a=new Date,o=String(a.getMonth()+1).padStart(2,"0"),s=String(a.getDate()).padStart(2,"0"),n=`${a.getFullYear()}-${o}-${s}`,u=`${h(a.getHours())}:${h(a.getMinutes())}`;this._pending=this._clampState({date:n,time:u}),this._emitInput("now"),this._renderOverlay();return}i==="apply"&&(this._commit(this._pending,"apply"),this._setOpen(!1,"apply"))}}_onOverlayChange(t){const e=t.target;e instanceof HTMLSelectElement&&e.matches("select[data-segment]")&&(this._isInteractionBlocked()||this._overlay&&(this._applyTimeFromSurface(this._overlay),this._shouldAutoCommit()&&this._pending.date&&this._pending.time&&(this._commit(this._pending,"time"),this._setOpen(!1,"time"))))}_onOverlayCalendar(t){if(this._isInteractionBlocked()||this._isReadonly())return;const e=t.target;if(!e||e.tagName.toLowerCase()!=="ui-calendar")return;const i=t.type,r=t.detail,a=l.normalizeDateIso(i==="select"?(r==null?void 0:r.value)||null:r==null?void 0:r.value);if(a){if(this._pending=this._clampState({date:a,time:this._pending.time||"09:00"}),this._emitInput("calendar"),this._shouldAutoCommit()&&this._pending.time){this._commit(this._pending,"calendar"),this._setOpen(!1,"calendar");return}this._updateHostState()}}_onDocumentPointerDown(t){if(!this._open||!this._overlay)return;const e=t.composedPath();e.includes(this)||e.includes(this._overlay)||this._setOpen(!1,"outside")}_onDocumentKeyDown(t){this._open&&t.key==="Escape"&&(t.preventDefault(),this._setOpen(!1,"escape"))}_updateHostState(){if(!this._hasView)return;const t=this.getAttribute("label")||"",e=this.getAttribute("hint")||"",i=this.getAttribute("error")||"",r=this._inlineError||i,a=!!y(this._value),o=this.getAttribute("name")||"",s=this._allowInput()?this._draft:this._formatDisplay(this._value),n=this._isInlineMode(),u=this._translations(),b=r?"error":this._state();this._state()==="loading"?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");const _=this.root.querySelector(".label"),x=this.root.querySelector(".label-text"),C=this.root.querySelector(".required"),d=this.root.querySelector(".input"),I=this.root.querySelector('.btn[data-action="clear"]'),g=this.root.querySelector('.btn[data-action="toggle"]'),v=this.root.querySelector(".hint"),S=this.root.querySelector(".error"),w=this.root.querySelector(".hidden-input");if(_&&(_.hidden=!t),_&&(_.id=this._labelId,_.setAttribute("for",this._inputId)),x&&(x.textContent=t),C&&(C.hidden=!this.hasAttribute("required")),d&&(d.value!==s&&(d.value=s),d.id=this._inputId,d.placeholder=u.dateTimePlaceholder,d.readOnly=!this._allowInput()||this._isReadonly(),d.disabled=this._isInteractionBlocked(),d.required=this.hasAttribute("required"),d.autocomplete="off",d.setAttribute("role","combobox"),d.setAttribute("aria-haspopup","dialog"),d.setAttribute("aria-expanded",n?"false":String(this._open)),d.setAttribute("aria-controls",this._panelId),d.setAttribute("aria-invalid",r?"true":"false"),t?d.setAttribute("aria-labelledby",this._labelId):d.removeAttribute("aria-labelledby")),I&&(I.hidden=!(this._clearable()&&a),I.setAttribute("aria-label",u.clear),I.disabled=this._isInteractionBlocked()),g&&(g.hidden=n,g.setAttribute("aria-label",u.toggleCalendar),g.setAttribute("aria-expanded",n?"false":String(this._open)),g.setAttribute("aria-controls",this._panelId),g.disabled=this._isInteractionBlocked()),v&&(v.id=this._hintId,v.hidden=!e,v.textContent=e),S&&(S.id=this._errorId,S.hidden=!r,S.textContent=r),d){const f=[];e&&v&&!v.hidden&&f.push(this._hintId),r&&f.push(this._errorId),f.length?d.setAttribute("aria-describedby",f.join(" ")):d.removeAttribute("aria-describedby")}w&&(w.disabled=!o,w.name=o,w.value=y(this._value)||"");const A=this.root.querySelector(".field");A&&(A.dataset.open=this._open&&!n?"true":"false",A.dataset.invalid=r?"true":"false",A.dataset.state=b);const c=this.root.querySelector(".inline-panel");if(c){c.hidden=!n,c.id=this._panelId,c.dataset.bare=this._isBare()?"true":"false",c.setAttribute("role","dialog"),c.setAttribute("aria-modal","false"),c.setAttribute("aria-label",t||u.selectDate);const f=c.querySelector(".panel-title");f&&(f.textContent=t,f.hidden=!t);const D=c.querySelector(".head-title");D&&(D.textContent=t,D.hidden=!t);const T=c.querySelector(".head-meta");T&&(T.textContent=this._pending.date&&this._pending.time?this._formatDisplay(this._pending):u.selectDate);const L=c.querySelector('[data-action="now"]');L&&(L.textContent=u.now);const q=c.querySelector('[data-action="clear"]');q&&(q.textContent=u.clear);const R=c.querySelector('[data-action="apply"]');R&&(R.textContent=u.apply);const E=c.querySelector(".footer");E&&(E.hidden=!this._showFooter());const M=c.querySelector(".dt-calendar-inline");M&&this._syncCalendar(M);const O=c.querySelector('select[data-segment="hours"]'),$=c.querySelector('select[data-segment="minutes"]'),B=c.querySelector('select[data-segment="meridiem"]'),k=l.parseTimeInput(this._pending.time||"00:00",!0)||{hours:0,minutes:0,seconds:0};if(O){const z=this._is12h()?k.hours%12||12:k.hours;this._setClosestOptionValue(O,z),O.disabled=this._isInteractionBlocked()||this._isReadonly()}$&&(this._setClosestOptionValue($,k.minutes),$.disabled=this._isInteractionBlocked()||this._isReadonly()),B&&(B.value=k.hours>=12?"pm":"am",B.disabled=this._isInteractionBlocked()||this._isReadonly()),c.querySelectorAll(".action").forEach(z=>{z.disabled=this._isInteractionBlocked()||this._isReadonly()})}!n&&this._open&&this._syncOverlayState(),n&&this._destroyOverlay()}render(){if(!this._hasView){const t=this._translations();this.setContent(`
|
|
474
490
|
<style>${Y}</style>
|
|
475
491
|
<div class="root">
|
|
476
492
|
<label class="label" part="label" id="${this._labelId}">
|