@editora/ui-core 0.1.10 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/dist/alert-dialog.cjs.js +18 -18
- package/dist/alert-dialog.esm.js +130 -117
- package/dist/app-header.cjs.js +22 -2
- package/dist/app-header.esm.js +22 -2
- package/dist/badge.cjs.js +5 -5
- package/dist/badge.esm.js +9 -8
- package/dist/color-picker.cjs.js +4 -4
- package/dist/color-picker.esm.js +39 -31
- package/dist/combobox.cjs.js +21 -21
- package/dist/combobox.esm.js +79 -40
- package/dist/command-palette.cjs.js +1 -1
- package/dist/command-palette.esm.js +2 -2
- package/dist/components/date-time-utils.d.ts +2 -1
- package/dist/components/date-time-utils.d.ts.map +1 -1
- package/dist/components/ui-alert-dialog.d.ts +2 -0
- package/dist/components/ui-alert-dialog.d.ts.map +1 -1
- package/dist/components/ui-app-header.d.ts.map +1 -1
- package/dist/components/ui-badge.d.ts.map +1 -1
- package/dist/components/ui-color-picker.d.ts.map +1 -1
- package/dist/components/ui-combobox.d.ts +4 -1
- package/dist/components/ui-combobox.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts +3 -0
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts +3 -0
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +3 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +3 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-dialog.d.ts +3 -0
- package/dist/components/ui-dialog.d.ts.map +1 -1
- package/dist/components/ui-drawer.d.ts +14 -0
- package/dist/components/ui-drawer.d.ts.map +1 -1
- package/dist/components/ui-floating-toolbar.d.ts.map +1 -1
- package/dist/components/ui-icon.d.ts.map +1 -1
- package/dist/components/ui-menu.d.ts +1 -0
- package/dist/components/ui-menu.d.ts.map +1 -1
- package/dist/components/ui-menubar.d.ts +1 -0
- package/dist/components/ui-menubar.d.ts.map +1 -1
- package/dist/components/ui-quick-actions.d.ts.map +1 -1
- package/dist/components/ui-radio.d.ts +47 -0
- package/dist/components/ui-radio.d.ts.map +1 -0
- package/dist/components/ui-select.d.ts +8 -0
- package/dist/components/ui-select.d.ts.map +1 -1
- package/dist/components/ui-selection-popup.d.ts.map +1 -1
- package/dist/components/ui-split-button.d.ts +2 -0
- package/dist/components/ui-split-button.d.ts.map +1 -1
- package/dist/components/ui-stepper.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts +3 -0
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/context-menu.cjs.js +2 -2
- package/dist/context-menu.esm.js +2 -2
- package/dist/date-field.cjs.js +1 -1
- package/dist/date-field.esm.js +2 -2
- package/dist/date-picker.cjs.js +13 -13
- package/dist/date-picker.esm.js +100 -67
- package/dist/date-range-picker.cjs.js +14 -14
- package/dist/date-range-picker.esm.js +98 -65
- package/dist/date-range-time-picker.cjs.js +13 -13
- package/dist/date-range-time-picker.esm.js +76 -45
- package/dist/date-time-picker.cjs.js +13 -13
- package/dist/date-time-picker.esm.js +132 -101
- package/dist/date-time-utils-378ecc21.js +1 -0
- package/dist/{date-time-utils-bdceb7af.mjs → date-time-utils-a8b17ea7.mjs} +128 -102
- package/dist/dialog.cjs.js +29 -20
- package/dist/dialog.esm.js +90 -70
- package/dist/drawer.cjs.js +16 -16
- package/dist/drawer.esm.js +216 -98
- package/dist/floating-toolbar.cjs.js +3 -13
- package/dist/floating-toolbar.esm.js +17 -27
- package/dist/hover-card.cjs.js +1 -1
- package/dist/hover-card.esm.js +1 -1
- package/dist/{icon-eaa486b3.js → icon-9e9da03b.js} +4 -4
- package/dist/{icon-9ed13093.mjs → icon-e2a85cc1.mjs} +22 -18
- package/dist/icon.cjs.js +1 -1
- package/dist/icon.esm.js +1 -1
- package/dist/icons.d.ts +1 -1
- package/dist/icons.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +246 -244
- package/dist/menu.cjs.js +2 -2
- package/dist/menu.esm.js +118 -110
- package/dist/menubar.cjs.js +5 -5
- package/dist/menubar.esm.js +83 -78
- package/dist/{overlayManager-ece06517.js → overlayManager-0eda4e08.js} +1 -1
- package/dist/{overlayManager-86454af7.mjs → overlayManager-5bbd4dc3.mjs} +1 -1
- package/dist/popover.cjs.js +1 -1
- package/dist/popover.esm.js +2 -2
- package/dist/{portal-1cf392ca.mjs → portal-9060f7a6.mjs} +7 -7
- package/dist/portal-d9bae456.js +1 -0
- package/dist/{positioner-fbd61bf1.mjs → positioner-16f3cca1.mjs} +16 -16
- package/dist/positioner-43b1c75a.js +1 -0
- package/dist/positioner.cjs.js +1 -1
- package/dist/positioner.esm.js +1 -1
- package/dist/quick-actions.cjs.js +10 -4
- package/dist/quick-actions.esm.js +27 -21
- package/dist/radio.cjs.js +259 -0
- package/dist/radio.esm.js +455 -0
- package/dist/{runtime-5f282bc8.js → runtime-668914fe.js} +1 -1
- package/dist/{runtime-4ac0107b.mjs → runtime-864efe2f.mjs} +1 -1
- package/dist/runtime.cjs.js +1 -1
- package/dist/runtime.esm.js +2 -2
- package/dist/scroll-lock-31da444f.mjs +56 -0
- package/dist/scroll-lock-d7b0df21.js +1 -0
- package/dist/scroll-lock.d.ts.map +1 -1
- package/dist/select.cjs.js +14 -15
- package/dist/select.esm.js +117 -97
- package/dist/selection-popup.cjs.js +4 -7
- package/dist/selection-popup.esm.js +8 -11
- package/dist/split-button.cjs.js +137 -62
- package/dist/split-button.esm.js +235 -145
- package/dist/standalone/radio.d.ts +2 -0
- package/dist/standalone/radio.d.ts.map +1 -0
- package/dist/stepper.cjs.js +19 -50
- package/dist/stepper.esm.js +17 -48
- package/dist/time-field.cjs.js +1 -1
- package/dist/time-field.esm.js +14 -14
- package/dist/time-picker.cjs.js +15 -15
- package/dist/time-picker.esm.js +99 -68
- package/dist/tooltip.cjs.js +1 -1
- package/dist/tooltip.esm.js +1 -1
- package/package.json +2 -2
- package/dist/date-time-utils-5cf58cd0.js +0 -1
- package/dist/portal-d8d7fbca.js +0 -1
- package/dist/positioner-accc6e5f.js +0 -1
- package/dist/scroll-lock-48793569.js +0 -1
- package/dist/scroll-lock-9de6d328.mjs +0 -53
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { E as tt } from "./ElementBase-909688f3.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { r as it
|
|
4
|
-
import "./
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
import { c as et } from "./dismissable-layer-9c7e6b58.mjs";
|
|
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 A, g as ut, h as ct } from "./date-time-utils-a8b17ea7.mjs";
|
|
5
|
+
import "./scroll-lock-31da444f.mjs";
|
|
6
|
+
let pt = 0;
|
|
7
|
+
const ht = `
|
|
7
8
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
8
9
|
<path d="M6 2a1 1 0 0 1 1 1v1h6V3a1 1 0 1 1 2 0v1h.5A2.5 2.5 0 0 1 18 6.5v9A2.5 2.5 0 0 1 15.5 18h-11A2.5 2.5 0 0 1 2 15.5v-9A2.5 2.5 0 0 1 4.5 4H5V3a1 1 0 0 1 1-1Zm10 7H4v6.5c0 .276.224.5.5.5h11a.5.5 0 0 0 .5-.5V9ZM4.5 6a.5.5 0 0 0-.5.5V7h12v-.5a.5.5 0 0 0-.5-.5h-11Z" fill="currentColor"/>
|
|
9
10
|
</svg>
|
|
10
|
-
`,
|
|
11
|
+
`, mt = `
|
|
11
12
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
12
13
|
<path d="M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.12l3.71-3.9a.75.75 0 1 1 1.08 1.04l-4.25 4.47a.75.75 0 0 1-1.08 0L5.2 8.27a.75.75 0 0 1 .02-1.06Z" fill="currentColor"/>
|
|
13
14
|
</svg>
|
|
14
|
-
`,
|
|
15
|
+
`, bt = `
|
|
15
16
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
16
17
|
<path d="M5.22 5.22a.75.75 0 0 1 1.06 0L10 8.94l3.72-3.72a.75.75 0 1 1 1.06 1.06L11.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06L10 11.06l-3.72 3.72a.75.75 0 1 1-1.06-1.06L8.94 10 5.22 6.28a.75.75 0 0 1 0-1.06Z" fill="currentColor"/>
|
|
17
18
|
</svg>
|
|
@@ -19,7 +20,7 @@ const ct = `
|
|
|
19
20
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
20
21
|
<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"/>
|
|
21
22
|
</svg>
|
|
22
|
-
`,
|
|
23
|
+
`, gt = `
|
|
23
24
|
:host {
|
|
24
25
|
--ui-drtp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
25
26
|
--ui-drtp-surface: linear-gradient(
|
|
@@ -270,7 +271,7 @@ const ct = `
|
|
|
270
271
|
outline-color: Highlight;
|
|
271
272
|
}
|
|
272
273
|
}
|
|
273
|
-
`,
|
|
274
|
+
`, ft = `
|
|
274
275
|
.overlay { position: fixed; z-index: var(--ui-drtp-z, 1600); pointer-events: none; }
|
|
275
276
|
.panel {
|
|
276
277
|
pointer-events: auto;
|
|
@@ -532,7 +533,7 @@ function c(h) {
|
|
|
532
533
|
}
|
|
533
534
|
function w(h) {
|
|
534
535
|
var n, s;
|
|
535
|
-
const t = /* @__PURE__ */ new Date(), e = `${S(t.getHours())}:${S(t.getMinutes())}`, i = `${S((t.getHours() + 1) % 24)}:${S(t.getMinutes())}`, r =
|
|
536
|
+
const t = /* @__PURE__ */ new Date(), e = `${S(t.getHours())}:${S(t.getMinutes())}`, i = `${S((t.getHours() + 1) % 24)}:${S(t.getMinutes())}`, r = k(h.start || null), o = k(h.end || null);
|
|
536
537
|
return {
|
|
537
538
|
startDate: (r == null ? void 0 : r.date) || null,
|
|
538
539
|
endDate: (o == null ? void 0 : o.date) || null,
|
|
@@ -540,9 +541,11 @@ function w(h) {
|
|
|
540
541
|
endTime: ((s = o == null ? void 0 : o.time) == null ? void 0 : s.slice(0, 5)) || i
|
|
541
542
|
};
|
|
542
543
|
}
|
|
543
|
-
class
|
|
544
|
+
class _t extends tt {
|
|
544
545
|
constructor() {
|
|
545
|
-
super(...arguments), this._value = { start: null, end: null }, this._pending = w({ start: null, end: null }), this._display = "", this._inlineError = "", this._open = !1, this._syncing = !1, this._overlay = null, this._releaseScrollLock = null, this._isInitialized = !1, this._hasView = !1, this._restoreFocusEl = null, this._overlayKey = null, this._uid = `ui-drtp-${++
|
|
546
|
+
super(...arguments), this._value = { start: null, end: null }, this._pending = w({ start: null, end: null }), this._display = "", 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-drtp-${++pt}`, 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 = rt(() => this._positionOverlay()), this._onRootClickBound = (t) => this._onRootClick(t), this._onRootChangeBound = (t) => this._onRootChange(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) => {
|
|
547
|
+
st(t, [this._overlay]) || this._schedulePosition.run();
|
|
548
|
+
};
|
|
546
549
|
}
|
|
547
550
|
static get observedAttributes() {
|
|
548
551
|
return [
|
|
@@ -599,7 +602,7 @@ class gt extends tt {
|
|
|
599
602
|
return (this.getAttribute("mode") || "popover") === "inline";
|
|
600
603
|
}
|
|
601
604
|
_isMobileSheet() {
|
|
602
|
-
return
|
|
605
|
+
return nt(this.getAttribute("mode"));
|
|
603
606
|
}
|
|
604
607
|
_isDisabled() {
|
|
605
608
|
return this.hasAttribute("disabled");
|
|
@@ -612,7 +615,7 @@ class gt extends tt {
|
|
|
612
615
|
return this._isDisabled() || this._state() === "loading";
|
|
613
616
|
}
|
|
614
617
|
_locale() {
|
|
615
|
-
return
|
|
618
|
+
return at(this.getAttribute("locale"));
|
|
616
619
|
}
|
|
617
620
|
_isReadonly() {
|
|
618
621
|
return this.hasAttribute("readonly");
|
|
@@ -640,7 +643,7 @@ class gt extends tt {
|
|
|
640
643
|
return !Number.isFinite(t) || t < 1 ? 5 : Math.min(60, Math.trunc(t));
|
|
641
644
|
}
|
|
642
645
|
_translations() {
|
|
643
|
-
return
|
|
646
|
+
return it(
|
|
644
647
|
this.getAttribute("locale"),
|
|
645
648
|
this.getAttribute("translations")
|
|
646
649
|
);
|
|
@@ -687,13 +690,13 @@ class gt extends tt {
|
|
|
687
690
|
}
|
|
688
691
|
_valueFromPending() {
|
|
689
692
|
return {
|
|
690
|
-
start:
|
|
691
|
-
end:
|
|
693
|
+
start: D(this._pending.startDate, this._pending.startTime),
|
|
694
|
+
end: D(this._pending.endDate, this._pending.endTime)
|
|
692
695
|
};
|
|
693
696
|
}
|
|
694
697
|
_formatDateTimeDisplay(t) {
|
|
695
|
-
const e =
|
|
696
|
-
return e ? `${
|
|
698
|
+
const e = k(t);
|
|
699
|
+
return e ? `${ot(e.date, this._locale(), "locale", null)} ${e.time}` : t || "";
|
|
697
700
|
}
|
|
698
701
|
_formatDisplay() {
|
|
699
702
|
const t = this._value.start, e = this._value.end;
|
|
@@ -701,7 +704,7 @@ class gt extends tt {
|
|
|
701
704
|
}
|
|
702
705
|
_normalizePendingState(t) {
|
|
703
706
|
var p, m;
|
|
704
|
-
let e =
|
|
707
|
+
let e = D(t.startDate, t.startTime), i = D(t.endDate, t.endTime);
|
|
705
708
|
if (e && i && I(e, i) > 0 && this._autoNormalize()) {
|
|
706
709
|
const g = e;
|
|
707
710
|
e = i, i = g;
|
|
@@ -713,7 +716,7 @@ class gt extends tt {
|
|
|
713
716
|
n = s, s = g;
|
|
714
717
|
}
|
|
715
718
|
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);
|
|
716
|
-
const a =
|
|
719
|
+
const a = k(e || ""), l = k(i || "");
|
|
717
720
|
return {
|
|
718
721
|
startDate: (a == null ? void 0 : a.date) || null,
|
|
719
722
|
endDate: (l == null ? void 0 : l.date) || null,
|
|
@@ -725,8 +728,8 @@ class gt extends tt {
|
|
|
725
728
|
if (this._isInteractionBlocked() || this._isReadonly())
|
|
726
729
|
return;
|
|
727
730
|
const i = this._normalizePendingState(t), r = {
|
|
728
|
-
start:
|
|
729
|
-
end:
|
|
731
|
+
start: D(i.startDate, i.startTime),
|
|
732
|
+
end: D(i.endDate, i.endTime)
|
|
730
733
|
};
|
|
731
734
|
if (!this._allowPartial() && (!r.start || !r.end)) {
|
|
732
735
|
this._inlineError = this.getAttribute("error") || this._translations().rangeIncomplete, this._emitInvalid(JSON.stringify(r), "partial"), this._updateHostState();
|
|
@@ -762,10 +765,31 @@ class gt extends tt {
|
|
|
762
765
|
if (this._overlay || typeof document > "u")
|
|
763
766
|
return;
|
|
764
767
|
const t = document.createElement("div");
|
|
765
|
-
t.style.position = "fixed", t.style.left = "0", t.style.top = "0", t.style.
|
|
768
|
+
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());
|
|
769
|
+
}
|
|
770
|
+
_syncOverlayHostZIndex() {
|
|
771
|
+
if (!this._overlay || typeof window > "u")
|
|
772
|
+
return;
|
|
773
|
+
const t = window.getComputedStyle(this).getPropertyValue("--ui-drtp-z").trim();
|
|
774
|
+
this._overlay.style.zIndex = t || "1600";
|
|
766
775
|
}
|
|
767
776
|
_destroyOverlay() {
|
|
768
|
-
|
|
777
|
+
var t;
|
|
778
|
+
(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.parentElement && this._overlay.parentElement.removeChild(this._overlay), this._overlay = null, this._overlayKey = null, this._releaseScrollLock && (this._releaseScrollLock(), this._releaseScrollLock = null));
|
|
779
|
+
}
|
|
780
|
+
_syncDismissableLayer() {
|
|
781
|
+
var i;
|
|
782
|
+
if ((i = this._dismissableLayer) == null || i.destroy(), this._dismissableLayer = null, !this._open || !this._overlay)
|
|
783
|
+
return;
|
|
784
|
+
const t = this._overlay.querySelector(".panel, .sheet"), e = this.root.querySelector(".field");
|
|
785
|
+
t && (this._dismissableLayer = et({
|
|
786
|
+
node: t,
|
|
787
|
+
trigger: e,
|
|
788
|
+
closeOnEscape: !0,
|
|
789
|
+
closeOnPointerOutside: !0,
|
|
790
|
+
closeOnFocusOutside: !1,
|
|
791
|
+
onBeforeDismiss: (r) => r === "escape-key" ? (this._setOpen(!1, "escape"), !1) : (r === "outside-pointer" && this._setOpen(!1, "outside"), !1)
|
|
792
|
+
}));
|
|
769
793
|
}
|
|
770
794
|
_positionOverlay() {
|
|
771
795
|
if (!this._overlay || !this._open || this._isMobileSheet())
|
|
@@ -773,11 +797,17 @@ class gt extends tt {
|
|
|
773
797
|
const t = this.root.querySelector(".field"), e = this._overlay.querySelector(".panel");
|
|
774
798
|
if (!t || !e)
|
|
775
799
|
return;
|
|
776
|
-
const i =
|
|
777
|
-
|
|
800
|
+
const i = e.getAttribute("data-placement"), r = dt(
|
|
801
|
+
t.getBoundingClientRect(),
|
|
802
|
+
e.getBoundingClientRect(),
|
|
803
|
+
8,
|
|
804
|
+
8,
|
|
805
|
+
i === "top" ? "top" : i === "bottom" ? "bottom" : null
|
|
806
|
+
);
|
|
807
|
+
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);
|
|
778
808
|
}
|
|
779
809
|
_timeOptions(t) {
|
|
780
|
-
const e =
|
|
810
|
+
const e = A(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) => {
|
|
781
811
|
const a = Math.min(59, s * i);
|
|
782
812
|
return `<option value="${a}" ${a === e.minutes ? "selected" : ""}>${S(a)}</option>`;
|
|
783
813
|
}).join("");
|
|
@@ -828,7 +858,7 @@ class gt extends tt {
|
|
|
828
858
|
</footer>
|
|
829
859
|
`;
|
|
830
860
|
return e ? f : `
|
|
831
|
-
<style>${
|
|
861
|
+
<style>${ft}</style>
|
|
832
862
|
${t ? '<div class="sheet-backdrop" data-action="backdrop"></div>' : ""}
|
|
833
863
|
<section class="${t ? "sheet" : "panel"}" id="${this._panelId}" role="dialog" aria-modal="${t ? "true" : "false"}" aria-label="${a}" part="${t ? "sheet" : "popover"}">${f}</section>
|
|
834
864
|
`;
|
|
@@ -881,8 +911,9 @@ class gt extends tt {
|
|
|
881
911
|
_syncOverlayState() {
|
|
882
912
|
if (!this._overlay)
|
|
883
913
|
return;
|
|
914
|
+
this._syncOverlayHostZIndex();
|
|
884
915
|
const t = this._isMobileSheet();
|
|
885
|
-
this._ensureOverlayContent(t);
|
|
916
|
+
this._ensureOverlayContent(t), this._syncDismissableLayer();
|
|
886
917
|
const e = this._translations(), i = this._overlay.querySelector(".panel, .sheet"), r = this._overlay.querySelector(".presets"), o = this._overlay.querySelector(".footer");
|
|
887
918
|
i && (i.dataset.bare = this._isBare() ? "true" : "false");
|
|
888
919
|
const n = this._showFooter();
|
|
@@ -896,7 +927,7 @@ class gt extends tt {
|
|
|
896
927
|
a && (a.textContent = l.start && l.end ? `${this._formatDateTimeDisplay(l.start)} — ${this._formatDateTimeDisplay(l.end)}` : e.selectDateRange);
|
|
897
928
|
const p = this._overlay.querySelector(".drtp-calendar");
|
|
898
929
|
p && this._syncCalendar(p);
|
|
899
|
-
const m =
|
|
930
|
+
const m = A(this._pending.startTime, !0) || { hours: 0, minutes: 0, seconds: 0 }, g = A(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"]'), f = this._overlay.querySelector('select[data-time="end"][data-segment="hours"]'), _ = this._overlay.querySelector('select[data-time="end"][data-segment="minutes"]');
|
|
900
931
|
v && this._setClosestOptionValue(v, m.hours), d && this._setClosestOptionValue(d, m.minutes), f && this._setClosestOptionValue(f, g.hours), _ && this._setClosestOptionValue(_, g.minutes);
|
|
901
932
|
const y = this._isInteractionBlocked() || this._isReadonly();
|
|
902
933
|
[v, d, f, _].forEach((b) => {
|
|
@@ -930,11 +961,11 @@ class gt extends tt {
|
|
|
930
961
|
return;
|
|
931
962
|
}
|
|
932
963
|
if (t === "preset-last7") {
|
|
933
|
-
const r =
|
|
964
|
+
const r = ut(e, 7);
|
|
934
965
|
this._pending.startDate = r.start, this._pending.endDate = r.end, this._pending = this._normalizePendingState(this._pending), this._emitInput("preset-last7");
|
|
935
966
|
return;
|
|
936
967
|
}
|
|
937
|
-
const i =
|
|
968
|
+
const i = ct(e);
|
|
938
969
|
this._pending.startDate = i.start, this._pending.endDate = i.end, this._pending = this._normalizePendingState(this._pending), this._emitInput("preset-month");
|
|
939
970
|
}
|
|
940
971
|
_onRootClick(t) {
|
|
@@ -1077,18 +1108,18 @@ class gt extends tt {
|
|
|
1077
1108
|
H && (H.textContent = T.start && T.end ? `${this._formatDateTimeDisplay(T.start)} — ${this._formatDateTimeDisplay(T.end)}` : a.selectDateRange);
|
|
1078
1109
|
const V = u.querySelector(".drtp-calendar-inline");
|
|
1079
1110
|
V && this._syncCalendar(V);
|
|
1080
|
-
const
|
|
1081
|
-
|
|
1111
|
+
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 = A(this._pending.startTime, !0) || { hours: 0, minutes: 0, seconds: 0 }, N = A(this._pending.endTime, !0) || { hours: 0, minutes: 0, seconds: 0 };
|
|
1112
|
+
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((z) => {
|
|
1082
1113
|
z && (z.disabled = this._isInteractionBlocked() || this._isReadonly());
|
|
1083
1114
|
});
|
|
1084
1115
|
const K = u.querySelector('[data-action="preset-today"]');
|
|
1085
1116
|
K && (K.textContent = a.today);
|
|
1086
1117
|
const U = u.querySelector('[data-action="preset-last7"]');
|
|
1087
1118
|
U && (U.textContent = a.last7Days);
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1119
|
+
const Z = u.querySelector('[data-action="preset-month"]');
|
|
1120
|
+
Z && (Z.textContent = a.thisMonth);
|
|
1121
|
+
const j = u.querySelector('[data-action="clear"]');
|
|
1122
|
+
j && (j.textContent = a.clear);
|
|
1092
1123
|
const W = u.querySelector('[data-action="apply"]');
|
|
1093
1124
|
W && (W.textContent = a.apply);
|
|
1094
1125
|
const J = u.querySelector(".presets"), Y = u.querySelector(".footer"), G = this._showFooter();
|
|
@@ -1102,18 +1133,18 @@ class gt extends tt {
|
|
|
1102
1133
|
if (!this._hasView) {
|
|
1103
1134
|
const t = this._translations();
|
|
1104
1135
|
this.setContent(`
|
|
1105
|
-
<style>${
|
|
1136
|
+
<style>${gt}</style>
|
|
1106
1137
|
<div class="root">
|
|
1107
1138
|
<label class="label" part="label" id="${this._labelId}">
|
|
1108
1139
|
<span class="label-text"></span>
|
|
1109
1140
|
<span class="required">*</span>
|
|
1110
1141
|
</label>
|
|
1111
1142
|
<div class="field" part="field input">
|
|
1112
|
-
<span class="icon" part="icon">${
|
|
1143
|
+
<span class="icon" part="icon">${ht}</span>
|
|
1113
1144
|
<input class="input" id="${this._inputId}" part="input" readonly />
|
|
1114
1145
|
<span class="icon" part="icon">${B}</span>
|
|
1115
|
-
<button type="button" class="btn" part="clear" data-action="clear">${
|
|
1116
|
-
<button type="button" class="btn" part="toggle" data-action="toggle">${
|
|
1146
|
+
<button type="button" class="btn" part="clear" data-action="clear">${bt}</button>
|
|
1147
|
+
<button type="button" class="btn" part="toggle" data-action="toggle">${mt}</button>
|
|
1117
1148
|
</div>
|
|
1118
1149
|
<div class="hint" id="${this._hintId}" part="hint"></div>
|
|
1119
1150
|
<div class="error" id="${this._errorId}" part="error" role="alert"></div>
|
|
@@ -1131,7 +1162,7 @@ class gt extends tt {
|
|
|
1131
1162
|
return !1;
|
|
1132
1163
|
}
|
|
1133
1164
|
}
|
|
1134
|
-
typeof customElements < "u" && !customElements.get("ui-date-range-time-picker") && customElements.define("ui-date-range-time-picker",
|
|
1165
|
+
typeof customElements < "u" && !customElements.get("ui-date-range-time-picker") && customElements.define("ui-date-range-time-picker", _t);
|
|
1135
1166
|
export {
|
|
1136
|
-
|
|
1167
|
+
_t as UIDateRangeTimePicker
|
|
1137
1168
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F=require("./ElementBase-1b301e7f.js"),N=require("./calendar-a8735e40.js"),l=require("./date-time-utils-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F=require("./ElementBase-1b301e7f.js"),N=require("./dismissable-layer-193e3bed.js"),K=require("./calendar-a8735e40.js"),l=require("./date-time-utils-378ecc21.js");require("./scroll-lock-d7b0df21.js");let U=0;const Z=`
|
|
2
2
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
3
3
|
<path d="M6 2a1 1 0 0 1 1 1v1h6V3a1 1 0 1 1 2 0v1h.5A2.5 2.5 0 0 1 18 6.5v9A2.5 2.5 0 0 1 15.5 18h-11A2.5 2.5 0 0 1 2 15.5v-9A2.5 2.5 0 0 1 4.5 4H5V3a1 1 0 0 1 1-1Zm10 7H4v6.5c0 .276.224.5.5.5h11a.5.5 0 0 0 .5-.5V9ZM4.5 6a.5.5 0 0 0-.5.5V7h12v-.5a.5.5 0 0 0-.5-.5h-11Z" fill="currentColor"/>
|
|
4
4
|
</svg>
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
7
7
|
<path d="M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.12l3.71-3.9a.75.75 0 1 1 1.08 1.04l-4.25 4.47a.75.75 0 0 1-1.08 0L5.2 8.27a.75.75 0 0 1 .02-1.06Z" fill="currentColor"/>
|
|
8
8
|
</svg>
|
|
9
|
-
`,
|
|
9
|
+
`,W=`
|
|
10
10
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
11
11
|
<path d="M5.22 5.22a.75.75 0 0 1 1.06 0L10 8.94l3.72-3.72a.75.75 0 1 1 1.06 1.06L11.06 10l3.72 3.72a.75.75 0 1 1-1.06 1.06L10 11.06l-3.72 3.72a.75.75 0 1 1-1.06-1.06L8.94 10 5.22 6.28a.75.75 0 0 1 0-1.06Z" fill="currentColor"/>
|
|
12
12
|
</svg>
|
|
@@ -280,7 +280,7 @@
|
|
|
280
280
|
outline-color: Highlight;
|
|
281
281
|
}
|
|
282
282
|
}
|
|
283
|
-
`,
|
|
283
|
+
`,J=`
|
|
284
284
|
.overlay { position: fixed; z-index: var(--ui-dtp-z, 1600); pointer-events: none; }
|
|
285
285
|
.panel {
|
|
286
286
|
pointer-events: auto;
|
|
@@ -442,11 +442,11 @@
|
|
|
442
442
|
from { opacity: 0; transform: translateY(6px) scale(0.985); }
|
|
443
443
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
444
444
|
}
|
|
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._releaseScrollLock=null,this._isInitialized=!1,this._hasView=!1,this._restoreFocusEl=null,this._overlayKey=null,this._uid=`ui-dtp-${++K}`,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=()=>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 N.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 n=new Date(t);if(!Number.isFinite(n.getTime()))return null;const a=n.getFullYear(),o=String(n.getMonth()+1).padStart(2,"0"),r=String(n.getDate()).padStart(2,"0");return`${a}-${o}-${r}`}_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(),n=l.clampDateIso(t.date,e,i),a=t.time||"00:00";let o=this._minDateTime(),r=this._maxDateTime();if(o&&r&&l.compareDateTimes(o,r)>0){const f=o;o=r,r=f}let s=l.combineDateTime(n,a)||`${n}T00:00`;o&&l.compareDateTimes(s,o)<0&&(s=o),r&&l.compareDateTimes(s,r)>0&&(s=r);const u=l.splitDateTime(s);return u?{date:u.date,time:u.time}:{date:n,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),n=this._clampState({date:l.normalizeDateIso(t.date),time:i?`${h(i.hours)}:${h(i.minutes)}`:null});if(!n.date||!n.time){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(JSON.stringify(t),"parse"),this._updateHostState();return}this._value=n,this._pending={...n},this._draft=this._formatDisplay(n),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.zIndex="1100",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,document.addEventListener("pointerdown",this._onDocumentPointerDownBound,!0),document.addEventListener("keydown",this._onDocumentKeyDownBound),window.addEventListener("resize",this._onWindowResizeBound),window.addEventListener("scroll",this._onWindowScrollBound,!0),this._isMobileSheet()&&(this._releaseScrollLock=l.lockBodyScroll())}_destroyOverlay(){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))}_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=l.computePopoverPosition(t.getBoundingClientRect(),e.getBoundingClientRect());e.style.position="absolute",e.style.top=`${Math.round(i.top)}px`,e.style.left=`${Math.round(i.left)}px`}_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,r)=>{const s=r+1,u=t.hours%12||12;return`<option value="${s}" ${s===u?"selected":""}>${h(s)}</option>`}).join(""):Array.from({length:24},(o,r)=>`<option value="${r}" ${r===t.hours?"selected":""}>${h(r)}</option>`).join(""),n=Array.from({length:Math.ceil(60/e)},(o,r)=>{const s=Math.min(59,r*e);return`<option value="${s}" ${s===t.minutes?"selected":""}>${h(s)}</option>`}).join(""),a=t.hours>=12?"pm":"am";return{hours:i,minutes:n,meridiem:a}}_renderSurfaceInner(t,e=!1){const i=this._translations(),n=this._timeOptions(),a=(this.getAttribute("label")||"").trim(),o=p(a),r=p(a||i.selectDate),s=this._pending.date&&this._pending.time?this._formatDisplay(this._pending):"",u=`
|
|
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=`
|
|
446
446
|
<header class="head">
|
|
447
447
|
<div>
|
|
448
448
|
<p class="head-title" ${a?"":"hidden"}>${o}</p>
|
|
449
|
-
<p class="head-meta">${p(
|
|
449
|
+
<p class="head-meta">${p(r||i.selectDate)}</p>
|
|
450
450
|
</div>
|
|
451
451
|
</header>
|
|
452
452
|
<div class="content">
|
|
@@ -454,9 +454,9 @@
|
|
|
454
454
|
<section class="time-panel" part="time">
|
|
455
455
|
<span class="icon" aria-hidden="true">${P}</span>
|
|
456
456
|
<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" ${
|
|
457
|
+
<div><label>${p(i.hour)}</label><select data-segment="hours">${s.hours}</select></div>
|
|
458
|
+
<div><label>${p(i.minute)}</label><select data-segment="minutes">${s.minutes}</select></div>
|
|
459
|
+
${this._is12h()?`<div><label>${p(i.meridiem)}</label><select data-segment="meridiem"><option value="am" ${s.meridiem==="am"?"selected":""}>${p(i.am)}</option><option value="pm" ${s.meridiem==="pm"?"selected":""}>${p(i.pm)}</option></select></div>`:""}
|
|
460
460
|
</div>
|
|
461
461
|
</section>
|
|
462
462
|
</div>
|
|
@@ -467,10 +467,10 @@
|
|
|
467
467
|
<button type="button" class="action" data-action="apply" data-tone="primary">${p(i.apply)}</button>
|
|
468
468
|
</footer>
|
|
469
469
|
`;return e?u:`
|
|
470
|
-
<style>${
|
|
470
|
+
<style>${J}</style>
|
|
471
471
|
${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=(r,s)=>{if(s==null||s===""){t.hasAttribute(r)&&t.removeAttribute(r);return}t.getAttribute(r)!==s&&t.setAttribute(r,s)},i=(r,s)=>{s?e(r,""):e(r,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 n=i[0],a=Math.abs(n-e);for(let o=1;o<i.length;o+=1){const r=i[o],s=Math.abs(r-e);s<a&&(n=r,a=s)}t.value=String(n)}_syncOverlayState(){if(!this._overlay)return;const t=this._isMobileSheet();this._ensureOverlayContent(t);const e=this._translations(),i=this._overlay.querySelector(".panel, .sheet"),n=this._overlay.querySelector(".footer");i&&(i.dataset.bare=this._isBare()?"true":"false"),n&&(n.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 r=this._overlay.querySelector(".dt-calendar");r&&this._syncCalendar(r);const s=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()?s.hours%12||12:s.hours;this._setClosestOptionValue(u,d),u.disabled=this._isInteractionBlocked()||this._isReadonly()}f&&(this._setClosestOptionValue(f,s.minutes),f.disabled=this._isInteractionBlocked()||this._isReadonly()),_&&(_.value=s.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"]'),n=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 r=a;if(this._is12h()){const s=(n==null?void 0:n.value)==="pm"?"pm":"am";s==="pm"&&r<12&&(r+=12),s==="am"&&r===12&&(r=0)}this._pending=this._clampState({date:this._pending.date,time:`${h(r)}:${h(o)}`}),this._emitInput("time")}_onRootClick(t){var n;const e=t.target;if(!e)return;const i=(n=e.closest("[data-action]"))==null?void 0:n.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"),r=String(a.getDate()).padStart(2,"0"),s=`${a.getFullYear()}-${o}-${r}`,u=`${h(a.getHours())}:${h(a.getMinutes())}`;this._pending=this._clampState({date:s,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 n=/^(.+)\s+(\d{1,2}:\d{2}(?::\d{2})?(?:\s?[ap]m)?)$/i.exec(i);if(!n){this._inlineError=this.getAttribute("error")||this._translations().invalidDateTime,this._emitInvalid(i,"parse"),this._updateHostState();return}const a=this._parseDateInput(n[1]),o=l.parseTimeInput(n[2],!0)?n[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 n;const e=t.target;if(!e)return;const i=(n=e.closest("[data-action]"))==null?void 0:n.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"),r=String(a.getDate()).padStart(2,"0"),s=`${a.getFullYear()}-${o}-${r}`,u=`${h(a.getHours())}:${h(a.getMinutes())}`;this._pending=this._clampState({date:s,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,n=t.detail,a=l.normalizeDateIso(i==="select"?(n==null?void 0:n.value)||null:n==null?void 0:n.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")||"",n=this._inlineError||i,a=!!y(this._value),o=this.getAttribute("name")||"",r=this._allowInput()?this._draft:this._formatDisplay(this._value),s=this._isInlineMode(),u=this._translations(),f=n?"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!==r&&(d.value=r),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",s?"false":String(this._open)),d.setAttribute("aria-controls",this._panelId),d.setAttribute("aria-invalid",n?"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=s,g.setAttribute("aria-label",u.toggleCalendar),g.setAttribute("aria-expanded",s?"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=!n,S.textContent=n),d){const b=[];e&&v&&!v.hidden&&b.push(this._hintId),n&&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&&!s?"true":"false",A.dataset.invalid=n?"true":"false",A.dataset.state=f);const c=this.root.querySelector(".inline-panel");if(c){c.hidden=!s,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 R=c.querySelector('[data-action="now"]');R&&(R.textContent=u.now);const E=c.querySelector('[data-action="clear"]');E&&(E.textContent=u.clear);const L=c.querySelector('[data-action="apply"]');L&&(L.textContent=u.apply);const q=c.querySelector(".footer");q&&(q.hidden=!this._showFooter());const M=c.querySelector(".dt-calendar-inline");M&&this._syncCalendar(M);const $=c.querySelector('select[data-segment="hours"]'),B=c.querySelector('select[data-segment="minutes"]'),O=c.querySelector('select[data-segment="meridiem"]'),C=l.parseTimeInput(this._pending.time||"00:00",!0)||{hours:0,minutes:0,seconds:0};if($){const z=this._is12h()?C.hours%12||12:C.hours;this._setClosestOptionValue($,z),$.disabled=this._isInteractionBlocked()||this._isReadonly()}B&&(this._setClosestOptionValue(B,C.minutes),B.disabled=this._isInteractionBlocked()||this._isReadonly()),O&&(O.value=C.hours>=12?"pm":"am",O.disabled=this._isInteractionBlocked()||this._isReadonly()),c.querySelectorAll(".action").forEach(z=>{z.disabled=this._isInteractionBlocked()||this._isReadonly()})}!s&&this._open&&this._syncOverlayState(),s&&this._destroyOverlay()}render(){if(!this._hasView){const t=this._translations();this.setContent(`
|
|
472
|
+
<section class="${t?"sheet":"panel"}" id="${this._panelId}" role="dialog" aria-modal="${t?"true":"false"}" aria-label="${n}" part="${t?"sheet":"popover"}">${u}</section>
|
|
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 R=c.querySelector('[data-action="clear"]');R&&(R.textContent=u.clear);const q=c.querySelector('[data-action="apply"]');q&&(q.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(`
|
|
474
474
|
<style>${Y}</style>
|
|
475
475
|
<div class="root">
|
|
476
476
|
<label class="label" part="label" id="${this._labelId}">
|
|
@@ -478,10 +478,10 @@
|
|
|
478
478
|
<span class="required">*</span>
|
|
479
479
|
</label>
|
|
480
480
|
<div class="field" part="field input">
|
|
481
|
-
<span class="icon" part="icon">${
|
|
481
|
+
<span class="icon" part="icon">${Z}</span>
|
|
482
482
|
<input class="input" id="${this._inputId}" part="input" />
|
|
483
483
|
<span class="icon" part="icon">${P}</span>
|
|
484
|
-
<button type="button" class="btn" part="clear" data-action="clear">${
|
|
484
|
+
<button type="button" class="btn" part="clear" data-action="clear">${W}</button>
|
|
485
485
|
<button type="button" class="btn" part="toggle" data-action="toggle">${j}</button>
|
|
486
486
|
</div>
|
|
487
487
|
<div class="hint" id="${this._hintId}" part="hint"></div>
|