@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,21 +1,22 @@
|
|
|
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, c as N } from "./calendar-2c11b824.mjs";
|
|
4
|
+
import { r as nt, e as rt, i as m, s as st, b as at, p as K, f as Z, a as j, l as W, c as ot, d as w, g as lt, h as dt, n as L } from "./date-time-utils-a8b17ea7.mjs";
|
|
5
|
+
import "./scroll-lock-31da444f.mjs";
|
|
6
|
+
let ut = 0;
|
|
7
|
+
const ct = `
|
|
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
|
+
`, pt = `
|
|
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
|
+
`, ht = `
|
|
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>
|
|
18
|
-
`,
|
|
19
|
+
`, ft = `
|
|
19
20
|
:host {
|
|
20
21
|
--ui-dp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
21
22
|
--ui-dp-surface: linear-gradient(
|
|
@@ -321,7 +322,7 @@ const dt = `
|
|
|
321
322
|
transform: rotate(360deg);
|
|
322
323
|
}
|
|
323
324
|
}
|
|
324
|
-
`,
|
|
325
|
+
`, _t = `
|
|
325
326
|
.overlay { position: fixed; z-index: var(--ui-dp-z, 1600); pointer-events: none; }
|
|
326
327
|
.panel {
|
|
327
328
|
pointer-events: auto;
|
|
@@ -401,39 +402,41 @@ const dt = `
|
|
|
401
402
|
to { opacity: 1; transform: translateY(0); }
|
|
402
403
|
}
|
|
403
404
|
`;
|
|
404
|
-
function
|
|
405
|
-
if (!
|
|
405
|
+
function Y(c) {
|
|
406
|
+
if (!c)
|
|
406
407
|
return { start: null, end: null };
|
|
407
408
|
try {
|
|
408
|
-
const t = JSON.parse(
|
|
409
|
+
const t = JSON.parse(c), e = L((t == null ? void 0 : t.start) || null), i = L((t == null ? void 0 : t.end) || null);
|
|
409
410
|
return { start: e, end: i };
|
|
410
411
|
} catch {
|
|
411
412
|
return { start: null, end: null };
|
|
412
413
|
}
|
|
413
414
|
}
|
|
414
|
-
function J(
|
|
415
|
-
return !
|
|
416
|
-
...
|
|
417
|
-
...
|
|
415
|
+
function J(c) {
|
|
416
|
+
return !c.start && !c.end ? null : JSON.stringify({
|
|
417
|
+
...c.start ? { start: c.start } : {},
|
|
418
|
+
...c.end ? { end: c.end } : {}
|
|
418
419
|
});
|
|
419
420
|
}
|
|
420
|
-
function _(
|
|
421
|
-
return
|
|
421
|
+
function _(c) {
|
|
422
|
+
return c.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
422
423
|
}
|
|
423
|
-
function
|
|
424
|
-
const e =
|
|
424
|
+
function bt(c, t) {
|
|
425
|
+
const e = c.trim();
|
|
425
426
|
if (!e)
|
|
426
427
|
return { start: null, end: null };
|
|
427
428
|
const i = e.split(/\s(?:—|–|to)\s/i).map((r) => r.trim()).filter(Boolean);
|
|
428
429
|
if (i.length > 1) {
|
|
429
|
-
const r = w(i[0] || "", t),
|
|
430
|
-
return { start: r, end:
|
|
430
|
+
const r = w(i[0] || "", t), d = w(i[1] || "", t);
|
|
431
|
+
return { start: r, end: d };
|
|
431
432
|
}
|
|
432
433
|
return { start: w(e, t), end: null };
|
|
433
434
|
}
|
|
434
|
-
class
|
|
435
|
+
class yt extends tt {
|
|
435
436
|
constructor() {
|
|
436
|
-
super(...arguments), this._value = { start: null, end: null }, this._pending = { start: null, end: null }, this._draftStart = "", this._draftEnd = "", this._draftSingle = "", this._inlineError = "", this._open = !1, this._syncing = !1, this._overlay = null, this._releaseScrollLock = null, this._isInitialized = !1, this._hasView = !1, this._restoreFocusEl = null, this._overlayMode = null, this._uid = `ui-drp-${++
|
|
437
|
+
super(...arguments), this._value = { start: null, end: null }, this._pending = { start: null, end: null }, this._draftStart = "", this._draftEnd = "", this._draftSingle = "", 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._overlayMode = null, this._uid = `ui-drp-${++ut}`, this._singleId = `${this._uid}-single`, this._startId = `${this._uid}-start`, this._endId = `${this._uid}-end`, this._labelId = `${this._uid}-label`, this._hintId = `${this._uid}-hint`, this._errorId = `${this._uid}-error`, this._panelId = `${this._uid}-panel`, this._panelTitleId = `${this._uid}-panel-title`, this._overlayFocusedOnOpen = !1, this._inlineCalendarFramePending = !1, this._inlineCalendarUpgradePending = !1, this._schedulePosition = nt(() => this._positionOverlay()), this._onRootClickBound = (t) => this._onRootClick(t), this._onRootInputBound = (t) => this._onRootInput(t), this._onRootBlurBound = (t) => this._onRootBlur(t), this._onRootKeyDownBound = (t) => this._onRootKeyDown(t), this._onDocumentPointerDownBound = (t) => this._onDocumentPointerDown(t), this._onDocumentKeyDownBound = (t) => this._onDocumentKeyDown(t), this._onWindowResizeBound = () => this._schedulePosition.run(), this._onWindowScrollBound = (t) => {
|
|
438
|
+
rt(t, [this._overlay]) || this._schedulePosition.run();
|
|
439
|
+
}, this._onOverlayClickBound = (t) => this._onOverlayClick(t), this._onOverlayCalendarBound = (t) => this._onOverlayCalendarChange(t);
|
|
437
440
|
}
|
|
438
441
|
static get observedAttributes() {
|
|
439
442
|
return [
|
|
@@ -471,7 +474,7 @@ class _t extends tt {
|
|
|
471
474
|
}
|
|
472
475
|
connectedCallback() {
|
|
473
476
|
if (super.connectedCallback(), this.root.addEventListener("click", this._onRootClickBound), this.root.addEventListener("input", this._onRootInputBound), this.root.addEventListener("focusout", this._onRootBlurBound), this.root.addEventListener("keydown", this._onRootKeyDownBound), !this._isInitialized) {
|
|
474
|
-
const t =
|
|
477
|
+
const t = Y(this.getAttribute("value") || this.getAttribute("default-value")), e = this._normalizePending(t);
|
|
475
478
|
this._value = e, this._pending = { ...e }, this._refreshDraftFromValue(), this._open = this.hasAttribute("open") || m(this.getAttribute("default-open")), this._isInitialized = !0;
|
|
476
479
|
}
|
|
477
480
|
this._open && !this._isInlineMode() && this._ensureOverlay(), this._isInlineMode() && this._scheduleInlineCalendarSync();
|
|
@@ -480,7 +483,7 @@ class _t extends tt {
|
|
|
480
483
|
this.root.removeEventListener("click", this._onRootClickBound), this.root.removeEventListener("input", this._onRootInputBound), this.root.removeEventListener("focusout", this._onRootBlurBound), this.root.removeEventListener("keydown", this._onRootKeyDownBound), this._destroyOverlay(), super.disconnectedCallback();
|
|
481
484
|
}
|
|
482
485
|
attributeChangedCallback(t, e, i) {
|
|
483
|
-
if (e !== i && (t === "value" && !this._syncing && (this._value = this._normalizePending(
|
|
486
|
+
if (e !== i && (t === "value" && !this._syncing && (this._value = this._normalizePending(Y(i)), this._pending = { ...this._value }, this._refreshDraftFromValue(), this._inlineError = "", this._syncValueAttribute(this._value)), 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 === "min" || t === "max") && !this._syncing && (this._value = this._normalizePending(this._value), this._pending = this._normalizePending(this._pending), this._syncValueAttribute(this._value), this._refreshDraftFromValue()), t === "state" && this._state() === "loading" && this._setOpen(!1, "outside"), !!this.isConnected)) {
|
|
484
487
|
if (!this._hasView) {
|
|
485
488
|
this.requestRender();
|
|
486
489
|
return;
|
|
@@ -492,7 +495,7 @@ class _t extends tt {
|
|
|
492
495
|
return (this.getAttribute("mode") || "popover") === "inline";
|
|
493
496
|
}
|
|
494
497
|
_isMobileSheet() {
|
|
495
|
-
return
|
|
498
|
+
return st(this.getAttribute("mode"));
|
|
496
499
|
}
|
|
497
500
|
_isDisabled() {
|
|
498
501
|
return this.hasAttribute("disabled");
|
|
@@ -529,10 +532,10 @@ class _t extends tt {
|
|
|
529
532
|
return m(this.getAttribute("allow-same-day"), !0);
|
|
530
533
|
}
|
|
531
534
|
_locale() {
|
|
532
|
-
return
|
|
535
|
+
return at(this.getAttribute("locale"));
|
|
533
536
|
}
|
|
534
537
|
_translations() {
|
|
535
|
-
return
|
|
538
|
+
return it(
|
|
536
539
|
this.getAttribute("locale"),
|
|
537
540
|
this.getAttribute("translations")
|
|
538
541
|
);
|
|
@@ -559,7 +562,7 @@ class _t extends tt {
|
|
|
559
562
|
return { min: t, max: e };
|
|
560
563
|
}
|
|
561
564
|
_refreshDraftFromValue() {
|
|
562
|
-
const t =
|
|
565
|
+
const t = Z(this._value.start, this._locale(), "locale", null), e = Z(this._value.end, this._locale(), "locale", null);
|
|
563
566
|
this._draftStart = t, this._draftEnd = e, this._draftSingle = [t, e].filter(Boolean).join(" — ");
|
|
564
567
|
}
|
|
565
568
|
_syncOpenAttribute(t) {
|
|
@@ -603,7 +606,7 @@ class _t extends tt {
|
|
|
603
606
|
this.dispatchEvent(new CustomEvent("invalid", { detail: { raw: t, reason: e }, bubbles: !0, composed: !0 }));
|
|
604
607
|
}
|
|
605
608
|
_normalizePending(t) {
|
|
606
|
-
const { min: e, max: i } = this._resolvedBounds(), n = t.start ?
|
|
609
|
+
const { min: e, max: i } = this._resolvedBounds(), n = t.start ? j(t.start, e, i) : null, r = t.end ? j(t.end, e, i) : null;
|
|
607
610
|
return !n || !r ? { start: n, end: r } : N(n, r) > 0 ? { start: r, end: n } : { start: n, end: r };
|
|
608
611
|
}
|
|
609
612
|
_canCommit(t) {
|
|
@@ -643,10 +646,31 @@ class _t extends tt {
|
|
|
643
646
|
if (this._overlay || typeof document > "u")
|
|
644
647
|
return;
|
|
645
648
|
const t = document.createElement("div");
|
|
646
|
-
t.className = "ui-date-range-picker-overlay-host", t.style.position = "fixed", t.style.left = "0", t.style.top = "0", t.style.
|
|
649
|
+
t.className = "ui-date-range-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("select", this._onOverlayCalendarBound), 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 = W());
|
|
650
|
+
}
|
|
651
|
+
_syncOverlayHostZIndex() {
|
|
652
|
+
if (!this._overlay || typeof window > "u")
|
|
653
|
+
return;
|
|
654
|
+
const t = window.getComputedStyle(this).getPropertyValue("--ui-dp-z").trim();
|
|
655
|
+
this._overlay.style.zIndex = t || "1600";
|
|
647
656
|
}
|
|
648
657
|
_destroyOverlay() {
|
|
649
|
-
|
|
658
|
+
var t;
|
|
659
|
+
(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("select", this._onOverlayCalendarBound), this._overlay.removeEventListener("change", this._onOverlayCalendarBound), this._overlay.parentElement && this._overlay.parentElement.removeChild(this._overlay), this._overlay = null, this._overlayMode = null, this._releaseScrollLock && (this._releaseScrollLock(), this._releaseScrollLock = null));
|
|
660
|
+
}
|
|
661
|
+
_syncDismissableLayer() {
|
|
662
|
+
var i;
|
|
663
|
+
if ((i = this._dismissableLayer) == null || i.destroy(), this._dismissableLayer = null, !this._open || !this._overlay)
|
|
664
|
+
return;
|
|
665
|
+
const t = this._overlay.querySelector(".panel, .sheet"), e = this.root.querySelector(".fields");
|
|
666
|
+
t && (this._dismissableLayer = et({
|
|
667
|
+
node: t,
|
|
668
|
+
trigger: e,
|
|
669
|
+
closeOnEscape: !0,
|
|
670
|
+
closeOnPointerOutside: !0,
|
|
671
|
+
closeOnFocusOutside: !1,
|
|
672
|
+
onBeforeDismiss: (n) => n === "escape-key" ? (this._setOpen(!1, "escape"), !1) : (n === "outside-pointer" && this._setOpen(!1, "outside"), !1)
|
|
673
|
+
}));
|
|
650
674
|
}
|
|
651
675
|
_positionOverlay() {
|
|
652
676
|
if (!this._overlay || !this._open || this._isMobileSheet())
|
|
@@ -656,11 +680,17 @@ class _t extends tt {
|
|
|
656
680
|
return;
|
|
657
681
|
const i = t.getBoundingClientRect();
|
|
658
682
|
e.style.setProperty("--ui-drp-panel-width", `${Math.round(i.width)}px`);
|
|
659
|
-
const n = e.getBoundingClientRect(), r =
|
|
660
|
-
|
|
683
|
+
const n = e.getBoundingClientRect(), r = e.getAttribute("data-placement"), d = ot(
|
|
684
|
+
i,
|
|
685
|
+
n,
|
|
686
|
+
8,
|
|
687
|
+
8,
|
|
688
|
+
r === "top" ? "top" : r === "bottom" ? "bottom" : null
|
|
689
|
+
);
|
|
690
|
+
e.style.position = "absolute", e.style.top = `${Math.round(d.top)}px`, e.style.left = `${Math.round(d.left)}px`, e.setAttribute("data-placement", d.placement);
|
|
661
691
|
}
|
|
662
692
|
_renderPanelInner(t) {
|
|
663
|
-
const e = this._translations(), i = (this.getAttribute("label") || "").trim(), n = !!i || t, r = t ? "true" : "false",
|
|
693
|
+
const e = this._translations(), i = (this.getAttribute("label") || "").trim(), n = !!i || t, r = t ? "true" : "false", d = `
|
|
664
694
|
<header class="header" part="header" ${n ? "" : "hidden"}>
|
|
665
695
|
<p class="title" id="${this._panelTitleId}" ${i ? "" : "hidden"}>${_(i)}</p>
|
|
666
696
|
${t ? `<button type="button" class="action" data-action="cancel">${_(e.cancel)}</button>` : ""}
|
|
@@ -678,18 +708,18 @@ class _t extends tt {
|
|
|
678
708
|
</footer>
|
|
679
709
|
`;
|
|
680
710
|
return `
|
|
681
|
-
<style>${
|
|
711
|
+
<style>${_t}</style>
|
|
682
712
|
${t ? '<div class="sheet-backdrop" data-action="backdrop"></div>' : ""}
|
|
683
|
-
<section class="${t ? "sheet" : "panel"}" id="${this._panelId}" role="dialog" aria-modal="${r}" aria-labelledby="${this._panelTitleId}" part="${t ? "sheet" : "popover"}">${
|
|
713
|
+
<section class="${t ? "sheet" : "panel"}" id="${this._panelId}" role="dialog" aria-modal="${r}" aria-labelledby="${this._panelTitleId}" part="${t ? "sheet" : "popover"}">${d}</section>
|
|
684
714
|
`;
|
|
685
715
|
}
|
|
686
716
|
_syncCalendar(t) {
|
|
687
|
-
const e = (h,
|
|
688
|
-
if (
|
|
717
|
+
const e = (h, u) => {
|
|
718
|
+
if (u == null || u === "") {
|
|
689
719
|
t.hasAttribute(h) && t.removeAttribute(h);
|
|
690
720
|
return;
|
|
691
721
|
}
|
|
692
|
-
t.getAttribute(h) !==
|
|
722
|
+
t.getAttribute(h) !== u && t.setAttribute(h, u);
|
|
693
723
|
}, i = J(this._pending), { min: n, max: r } = this._resolvedBounds();
|
|
694
724
|
e("selection", "range"), e("value", i), e("min", n), e("max", r), e("locale", this.getAttribute("locale")), e("translations", this.getAttribute("translations")), e("week-start", this.getAttribute("week-start"));
|
|
695
725
|
const l = this.getAttribute("size") || "sm";
|
|
@@ -706,19 +736,22 @@ class _t extends tt {
|
|
|
706
736
|
_syncOverlayState() {
|
|
707
737
|
if (!this._overlay)
|
|
708
738
|
return;
|
|
739
|
+
this._syncOverlayHostZIndex();
|
|
709
740
|
const t = this._isMobileSheet();
|
|
710
741
|
t && !this._releaseScrollLock ? this._releaseScrollLock = W() : !t && this._releaseScrollLock && (this._releaseScrollLock(), this._releaseScrollLock = null), this._ensureOverlayContent(t);
|
|
711
|
-
const e = this._overlay.querySelector(".title"), i = this._overlay.querySelector(".panel, .sheet")
|
|
742
|
+
const e = this._overlay.querySelector(".title"), i = this._overlay.querySelector(".panel, .sheet");
|
|
743
|
+
this._syncDismissableLayer();
|
|
744
|
+
const n = this._overlay.querySelector(".header"), r = this._overlay.querySelector(".presets"), d = this._overlay.querySelector(".footer"), l = this._translations();
|
|
712
745
|
i && (i.dataset.bare = this._isBare() ? "true" : "false"), n && (n.hidden = !(this.getAttribute("label") || "").trim() && !t);
|
|
713
746
|
const p = this._showFooter();
|
|
714
|
-
if (r && (r.hidden = !p),
|
|
747
|
+
if (r && (r.hidden = !p), d && (d.hidden = !p), e) {
|
|
715
748
|
const y = (this.getAttribute("label") || "").trim();
|
|
716
749
|
e.textContent = y, e.hidden = !y;
|
|
717
750
|
}
|
|
718
751
|
const h = this._overlay.querySelector('[data-action="preset-today"]');
|
|
719
752
|
h && (h.textContent = l.today);
|
|
720
|
-
const
|
|
721
|
-
|
|
753
|
+
const u = this._overlay.querySelector('[data-action="preset-last7"]');
|
|
754
|
+
u && (u.textContent = l.last7Days);
|
|
722
755
|
const b = this._overlay.querySelector('[data-action="preset-month"]');
|
|
723
756
|
b && (b.textContent = l.thisMonth);
|
|
724
757
|
const A = this._overlay.querySelector('[data-action="clear"]');
|
|
@@ -762,15 +795,15 @@ class _t extends tt {
|
|
|
762
795
|
_updateHostState() {
|
|
763
796
|
if (!this._hasView)
|
|
764
797
|
return;
|
|
765
|
-
const t = this.getAttribute("label") || "", e = this.getAttribute("hint") || "", i = this.getAttribute("error") || "", n = this._inlineError || i, r = this._translations(),
|
|
766
|
-
b && (b.hidden = !t, b.id = this._labelId, b.setAttribute("for", l === "single-field" ? this._singleId : this._startId)), A && (A.textContent = t), I && (I.hidden = !this.hasAttribute("required")), f && (f.dataset.single = l === "single-field" ? "true" : "false", f.dataset.invalid = n ? "true" : "false", f.dataset.open = this._open && !p ? "true" : "false", f.dataset.state =
|
|
767
|
-
const
|
|
768
|
-
e && x && !x.hidden &&
|
|
769
|
-
const S =
|
|
798
|
+
const t = this.getAttribute("label") || "", e = this.getAttribute("hint") || "", i = this.getAttribute("error") || "", n = this._inlineError || i, r = this._translations(), d = n ? "error" : this._state(), l = this._rangeVariant(), p = this._isInlineMode(), h = !!(this._value.start || this._value.end || this._pending.start || this._pending.end), u = this._isInteractionBlocked(), b = this.root.querySelector(".label"), A = this.root.querySelector(".label-text"), I = this.root.querySelector(".required"), f = this.root.querySelector(".fields"), a = this.root.querySelector(".single"), o = this.root.querySelector(".start"), s = this.root.querySelector(".end"), y = this.root.querySelector(".sep"), k = this.root.querySelector('.btn[data-action="clear"]'), v = this.root.querySelector('.btn[data-action="toggle"]'), x = this.root.querySelector(".hint"), C = this.root.querySelector(".error"), g = this.root.querySelector(".inline-panel"), q = this.root.querySelector(".inline-panel .presets"), R = this.root.querySelector(".inline-panel .footer"), O = this.root.querySelector(".hidden-range"), z = this.root.querySelector(".hidden-start"), P = this.root.querySelector(".hidden-end"), G = this.root.querySelectorAll(".inline-panel .action");
|
|
799
|
+
b && (b.hidden = !t, b.id = this._labelId, b.setAttribute("for", l === "single-field" ? this._singleId : this._startId)), A && (A.textContent = t), I && (I.hidden = !this.hasAttribute("required")), f && (f.dataset.single = l === "single-field" ? "true" : "false", f.dataset.invalid = n ? "true" : "false", f.dataset.open = this._open && !p ? "true" : "false", f.dataset.state = d, f.setAttribute("aria-disabled", u ? "true" : "false")), a && (a.value !== this._draftSingle && (a.value = this._draftSingle), a.id = this._singleId, a.hidden = l !== "single-field", a.readOnly = this._isReadonly() || u, a.disabled = u, a.required = this.hasAttribute("required"), a.placeholder = r.startEnd, a.autocomplete = "off", a.setAttribute("role", "combobox"), a.setAttribute("aria-haspopup", "dialog"), a.setAttribute("aria-controls", this._panelId), a.setAttribute("aria-expanded", p ? "false" : String(this._open)), a.setAttribute("aria-invalid", n ? "true" : "false"), t ? a.setAttribute("aria-labelledby", this._labelId) : a.removeAttribute("aria-labelledby")), o && (o.value !== this._draftStart && (o.value = this._draftStart), o.id = this._startId, o.hidden = l === "single-field", o.readOnly = this._isReadonly() || u, o.disabled = u, o.required = this.hasAttribute("required"), o.placeholder = r.startDate, o.autocomplete = "off", o.setAttribute("role", "combobox"), o.setAttribute("aria-haspopup", "dialog"), o.setAttribute("aria-controls", this._panelId), o.setAttribute("aria-expanded", p ? "false" : String(this._open)), o.setAttribute("aria-invalid", n ? "true" : "false"), t ? o.setAttribute("aria-labelledby", this._labelId) : o.removeAttribute("aria-labelledby")), s && (s.value !== this._draftEnd && (s.value = this._draftEnd), s.id = this._endId, s.hidden = l === "single-field", s.readOnly = this._isReadonly() || u, s.disabled = u, s.required = this.hasAttribute("required"), s.placeholder = r.endDate, s.autocomplete = "off", s.setAttribute("role", "combobox"), s.setAttribute("aria-haspopup", "dialog"), s.setAttribute("aria-controls", this._panelId), s.setAttribute("aria-expanded", p ? "false" : String(this._open)), s.setAttribute("aria-invalid", n ? "true" : "false"), t ? s.setAttribute("aria-labelledby", this._labelId) : s.removeAttribute("aria-labelledby")), y && (y.hidden = l === "single-field"), k && (k.hidden = !(this._clearable() && h), k.disabled = u, k.setAttribute("aria-label", r.clearDateRange)), v && (v.hidden = p, v.disabled = u, v.setAttribute("aria-expanded", p ? "false" : String(this._open)), v.setAttribute("aria-controls", this._panelId), v.setAttribute("aria-label", r.toggleCalendar)), x && (x.id = this._hintId, x.hidden = !e, x.textContent = e), C && (C.id = this._errorId, C.hidden = !n, C.textContent = n);
|
|
800
|
+
const D = [];
|
|
801
|
+
e && x && !x.hidden && D.push(this._hintId), n && D.push(this._errorId);
|
|
802
|
+
const S = D.join(" ");
|
|
770
803
|
a && (S ? a.setAttribute("aria-describedby", S) : a.removeAttribute("aria-describedby")), o && (S ? o.setAttribute("aria-describedby", S) : o.removeAttribute("aria-describedby")), s && (S ? s.setAttribute("aria-describedby", S) : s.removeAttribute("aria-describedby")), g && (g.hidden = !p, g.id = this._panelId, g.dataset.bare = this._isBare() ? "true" : "false", g.setAttribute("role", "dialog"), g.setAttribute("aria-modal", "false"), g.setAttribute("aria-label", t || r.selectDateRange));
|
|
771
804
|
const E = this._showFooter();
|
|
772
805
|
q && (q.hidden = !E), R && (R.hidden = !E), G.forEach((X) => {
|
|
773
|
-
X.disabled =
|
|
806
|
+
X.disabled = u || this._isReadonly();
|
|
774
807
|
});
|
|
775
808
|
const $ = this.root.querySelector('.inline-panel [data-action="preset-today"]');
|
|
776
809
|
$ && ($.textContent = r.today);
|
|
@@ -782,8 +815,8 @@ class _t extends tt {
|
|
|
782
815
|
V && (V.textContent = r.clear);
|
|
783
816
|
const H = this.root.querySelector('.inline-panel [data-action="apply"]');
|
|
784
817
|
H && (H.textContent = r.apply);
|
|
785
|
-
const
|
|
786
|
-
if (
|
|
818
|
+
const B = this.getAttribute("name") || "", T = this.getAttribute("name-start") || "", U = this.getAttribute("name-end") || "", Q = this._value.start && this._value.end ? `${this._value.start}..${this._value.end}` : "";
|
|
819
|
+
if (O && (O.disabled = !B, O.name = B, O.value = Q), z && (z.disabled = !!B || !T, z.name = T, z.value = this._value.start || ""), P && (P.disabled = !!B || !U, P.name = U, P.value = this._value.end || ""), p) {
|
|
787
820
|
this._scheduleInlineCalendarSync(), this._destroyOverlay();
|
|
788
821
|
return;
|
|
789
822
|
}
|
|
@@ -825,8 +858,8 @@ class _t extends tt {
|
|
|
825
858
|
const r = this._draftSingle.trim();
|
|
826
859
|
if (!r)
|
|
827
860
|
return this._pending = { start: null, end: null }, this._commit(this._pending, t), !0;
|
|
828
|
-
const
|
|
829
|
-
return !
|
|
861
|
+
const d = bt(r, this._locale());
|
|
862
|
+
return !d.start || !d.end && !this._allowPartial() ? (this._inlineError = this.getAttribute("error") || this._translations().invalidRange, this._emitInvalid(r, "parse"), this._updateHostState(), !1) : (this._pending = this._normalizePending({ start: d.start, end: d.end || null }), this._commit(this._pending, t), !0);
|
|
830
863
|
}
|
|
831
864
|
const i = this._draftStart ? w(this._draftStart, this._locale()) : null, n = this._draftEnd ? w(this._draftEnd, this._locale()) : null;
|
|
832
865
|
return this._draftStart && !i || this._draftEnd && !n ? (this._inlineError = this.getAttribute("error") || this._translations().invalidRange, this._emitInvalid(`${this._draftStart} ${this._draftEnd}`.trim(), "parse"), this._updateHostState(), !1) : (this._pending = this._normalizePending({ start: i, end: n }), this._commit(this._pending, t), !0);
|
|
@@ -896,12 +929,12 @@ class _t extends tt {
|
|
|
896
929
|
}
|
|
897
930
|
if (n === "preset-last7") {
|
|
898
931
|
const r = this._todayIso();
|
|
899
|
-
this._pending = this._normalizePending(
|
|
932
|
+
this._pending = this._normalizePending(lt(r, 7)), this._emitInput("preset-last7"), this._renderOverlay();
|
|
900
933
|
return;
|
|
901
934
|
}
|
|
902
935
|
if (n === "preset-month") {
|
|
903
936
|
const r = this._todayIso();
|
|
904
|
-
this._pending = this._normalizePending(
|
|
937
|
+
this._pending = this._normalizePending(dt(r)), this._emitInput("preset-month"), this._renderOverlay();
|
|
905
938
|
}
|
|
906
939
|
}
|
|
907
940
|
}
|
|
@@ -914,8 +947,8 @@ class _t extends tt {
|
|
|
914
947
|
const i = t.detail;
|
|
915
948
|
if (!(!i || i.mode !== "range")) {
|
|
916
949
|
if (this._pending = this._normalizePending({
|
|
917
|
-
start:
|
|
918
|
-
end:
|
|
950
|
+
start: L(i.start || null),
|
|
951
|
+
end: L(i.end || null)
|
|
919
952
|
}), this._emitInput("calendar"), this._shouldAutoCommit() && this._pending.start && this._pending.end) {
|
|
920
953
|
this._commit(this._pending, "calendar"), this._isInlineMode() || this._setOpen(!1, "calendar");
|
|
921
954
|
return;
|
|
@@ -925,21 +958,21 @@ class _t extends tt {
|
|
|
925
958
|
}
|
|
926
959
|
render() {
|
|
927
960
|
this._hasView || (this.setContent(`
|
|
928
|
-
<style>${
|
|
961
|
+
<style>${ft}</style>
|
|
929
962
|
<div class="root">
|
|
930
963
|
<label class="label" part="label" id="${this._labelId}">
|
|
931
964
|
<span class="label-text"></span>
|
|
932
965
|
<span class="required">*</span>
|
|
933
966
|
</label>
|
|
934
967
|
<div class="fields" part="field input" data-single="false">
|
|
935
|
-
<span class="icon" part="icon" aria-hidden="true">${
|
|
968
|
+
<span class="icon" part="icon" aria-hidden="true">${ct}</span>
|
|
936
969
|
<input class="input single" id="${this._singleId}" part="input" />
|
|
937
970
|
<input class="input start" id="${this._startId}" part="input" />
|
|
938
971
|
<span class="sep">—</span>
|
|
939
972
|
<input class="input end" id="${this._endId}" part="input" />
|
|
940
|
-
<button type="button" class="btn" part="clear" data-action="clear">${
|
|
973
|
+
<button type="button" class="btn" part="clear" data-action="clear">${ht}</button>
|
|
941
974
|
<button type="button" class="btn" part="toggle" data-action="toggle">
|
|
942
|
-
<span class="toggle-icon">${
|
|
975
|
+
<span class="toggle-icon">${pt}</span>
|
|
943
976
|
<span class="spinner" aria-hidden="true"></span>
|
|
944
977
|
</button>
|
|
945
978
|
</div>
|
|
@@ -967,7 +1000,7 @@ class _t extends tt {
|
|
|
967
1000
|
return !1;
|
|
968
1001
|
}
|
|
969
1002
|
}
|
|
970
|
-
typeof customElements < "u" && !customElements.get("ui-date-range-picker") && customElements.define("ui-date-range-picker",
|
|
1003
|
+
typeof customElements < "u" && !customElements.get("ui-date-range-picker") && customElements.define("ui-date-range-picker", yt);
|
|
971
1004
|
export {
|
|
972
|
-
|
|
1005
|
+
yt as UIDateRangePicker
|
|
973
1006
|
};
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Y=require("./ElementBase-1b301e7f.js"),G=require("./calendar-a8735e40.js"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const Y=require("./ElementBase-1b301e7f.js"),G=require("./dismissable-layer-193e3bed.js"),Q=require("./calendar-a8735e40.js"),s=require("./date-time-utils-378ecc21.js");require("./scroll-lock-d7b0df21.js");let X=0;const tt=`
|
|
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>
|
|
5
|
-
`,
|
|
5
|
+
`,et=`
|
|
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
|
+
`,it=`
|
|
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>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
<svg viewBox="0 0 20 20" class="icon-svg" aria-hidden="true" focusable="false">
|
|
15
15
|
<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"/>
|
|
16
16
|
</svg>
|
|
17
|
-
`,
|
|
17
|
+
`,rt=`
|
|
18
18
|
:host {
|
|
19
19
|
--ui-drtp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
20
20
|
--ui-drtp-surface: linear-gradient(
|
|
@@ -265,7 +265,7 @@
|
|
|
265
265
|
outline-color: Highlight;
|
|
266
266
|
}
|
|
267
267
|
}
|
|
268
|
-
`,
|
|
268
|
+
`,st=`
|
|
269
269
|
.overlay { position: fixed; z-index: var(--ui-drtp-z, 1600); pointer-events: none; }
|
|
270
270
|
.panel {
|
|
271
271
|
pointer-events: auto;
|
|
@@ -502,10 +502,10 @@
|
|
|
502
502
|
from { opacity: 0; transform: translateY(6px) scale(0.985); }
|
|
503
503
|
to { opacity: 1; transform: translateY(0) scale(1); }
|
|
504
504
|
}
|
|
505
|
-
`;function Z(m){if(!m)return{start:null,end:null};try{const t=JSON.parse(m),e=typeof(t==null?void 0:t.start)=="string"?t.start:null,i=typeof(t==null?void 0:t.end)=="string"?t.end:null;return{start:e,end:i}}catch{return{start:null,end:null}}}function W(m){return!m.start&&!m.end?null:JSON.stringify({...m.start?{start:m.start}:{},...m.end?{end:m.end}:{}})}function S(m){return String(m).padStart(2,"0")}function p(m){return m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(m){var a,s;const t=new Date,e=`${S(t.getHours())}:${S(t.getMinutes())}`,i=`${S((t.getHours()+1)%24)}:${S(t.getMinutes())}`,r=n.splitDateTime(m.start||null),l=n.splitDateTime(m.end||null);return{startDate:(r==null?void 0:r.date)||null,endDate:(l==null?void 0:l.date)||null,startTime:((a=r==null?void 0:r.time)==null?void 0:a.slice(0,5))||e,endTime:((s=l==null?void 0:l.time)==null?void 0:s.slice(0,5))||i}}class J extends Y.ElementBase{constructor(){super(...arguments),this._value={start:null,end:null},this._pending=D({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-${++Q}`,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=n.rafThrottle(()=>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=()=>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","auto-normalize","allow-partial","disabled","readonly","required","name","close-on-select","clearable","mode","label","hint","error","show-footer"]}connectedCallback(){if(super.connectedCallback(),this.root.addEventListener("click",this._onRootClickBound),this.root.addEventListener("change",this._onRootChangeBound),this.root.addEventListener("keydown",this._onRootKeyDownBound),!this._isInitialized){const t=Z(this.getAttribute("value")||this.getAttribute("default-value"));this._value=t,this._pending=D(t),this._display=this._formatDisplay(),this._open=this.hasAttribute("open")||n.isTruthyAttr(this.getAttribute("default-open")),this._isInitialized=!0}this._open&&!this._isInlineMode()&&this._ensureOverlay()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClickBound),this.root.removeEventListener("change",this._onRootChangeBound),this.root.removeEventListener("keydown",this._onRootKeyDownBound),this._destroyOverlay(),super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e!==i&&(t==="value"&&!this._syncing&&(this._value=Z(i),this._pending=D(this._value),this._display=this._formatDisplay(),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 n.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"}_locale(){return n.normalizeLocale(this.getAttribute("locale"))}_isReadonly(){return this.hasAttribute("readonly")}_clearable(){return n.isTruthyAttr(this.getAttribute("clearable"),!0)}_showFooter(){return n.isTruthyAttr(this.getAttribute("show-footer"),!0)}_shouldAutoCommit(){return n.isTruthyAttr(this.getAttribute("close-on-select"),!1)||!this._showFooter()}_isBare(){return n.isTruthyAttr(this.getAttribute("bare"),!1)}_allowPartial(){return n.isTruthyAttr(this.getAttribute("allow-partial"),!0)}_autoNormalize(){return n.isTruthyAttr(this.getAttribute("auto-normalize"),!0)}_step(){const t=Number(this.getAttribute("step")||5);return!Number.isFinite(t)||t<1?5:Math.min(60,Math.trunc(t))}_translations(){return G.resolveDateTimeTranslations(this.getAttribute("locale"),this.getAttribute("translations"))}_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=W(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=this._valueFromPending(),i={mode:"datetimerange",start:e.start,end:e.end,value:e.start&&e.end?{start:e.start,end:e.end}:null,source:t};this.dispatchEvent(new CustomEvent("input",{detail:i,bubbles:!0,composed:!0}))}_emitChange(t){const e={mode:"datetimerange",start:this._value.start,end:this._value.end,value:this._value.start&&this._value.end?{start:this._value.start,end:this._value.end}:null,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}))}_valueFromPending(){return{start:n.combineDateTime(this._pending.startDate,this._pending.startTime),end:n.combineDateTime(this._pending.endDate,this._pending.endTime)}}_formatDateTimeDisplay(t){const e=n.splitDateTime(t);return e?`${n.formatDateForDisplay(e.date,this._locale(),"locale",null)} ${e.time}`:t||""}_formatDisplay(){const t=this._value.start,e=this._value.end;return!t&&!e?"":t&&e?`${this._formatDateTimeDisplay(t)} — ${this._formatDateTimeDisplay(e)}`:this._formatDateTimeDisplay(t||e)}_normalizePendingState(t){var h,b;let e=n.combineDateTime(t.startDate,t.startTime),i=n.combineDateTime(t.endDate,t.endTime);if(e&&i&&n.compareDateTimes(e,i)>0&&this._autoNormalize()){const _=e;e=i,i=_}const r=n.parseConstraintDateTime(this.getAttribute("min")),l=n.parseConstraintDateTime(this.getAttribute("max"));let a=r?`${r.date}T${r.time}`:null,s=l?`${l.date}T${l.time}`:null;if(a&&s&&n.compareDateTimes(a,s)>0){const _=a;a=s,s=_}e&&a&&n.compareDateTimes(e,a)<0&&(e=a),e&&s&&n.compareDateTimes(e,s)>0&&(e=s),i&&a&&n.compareDateTimes(i,a)<0&&(i=a),i&&s&&n.compareDateTimes(i,s)>0&&(i=s);const o=n.splitDateTime(e||""),d=n.splitDateTime(i||"");return{startDate:(o==null?void 0:o.date)||null,endDate:(d==null?void 0:d.date)||null,startTime:((h=o==null?void 0:o.time)==null?void 0:h.slice(0,5))||t.startTime,endTime:((b=d==null?void 0:d.time)==null?void 0:b.slice(0,5))||t.endTime}}_commit(t,e){if(this._isInteractionBlocked()||this._isReadonly())return;const i=this._normalizePendingState(t),r={start:n.combineDateTime(i.startDate,i.startTime),end:n.combineDateTime(i.endDate,i.endTime)};if(!this._allowPartial()&&(!r.start||!r.end)){this._inlineError=this.getAttribute("error")||this._translations().rangeIncomplete,this._emitInvalid(JSON.stringify(r),"partial"),this._updateHostState();return}if(r.start&&r.end&&n.compareDateTimes(r.start,r.end)>0){this._inlineError=this.getAttribute("error")||this._translations().invalidRangeOrder,this._emitInvalid(JSON.stringify(r),"order"),this._updateHostState();return}this._value=r,this._pending=i,this._display=this._formatDisplay(),this._inlineError="",this._syncValueAttribute(r),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),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=n.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.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=n.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(t){const e=n.parseTimeInput(t,!0)||{hours:0,minutes:0,seconds:0},i=this._step(),r=Array.from({length:24},(a,s)=>`<option value="${s}" ${s===e.hours?"selected":""}>${S(s)}</option>`).join(""),l=Array.from({length:Math.ceil(60/i)},(a,s)=>{const o=Math.min(59,s*i);return`<option value="${o}" ${o===e.minutes?"selected":""}>${S(o)}</option>`}).join("");return{hours:r,minutes:l}}_renderSurfaceInner(t,e=!1){const i=this._translations(),r=this._timeOptions(this._pending.startTime),l=this._timeOptions(this._pending.endTime),a=(this.getAttribute("label")||"").trim(),s=p(a),o=p(a||i.selectDateRange),d=this._valueFromPending(),h=d.start&&d.end?`${this._formatDateTimeDisplay(d.start)} — ${this._formatDateTimeDisplay(d.end)}`:i.selectDateRange,b=p(`${i.startTime} ${i.hour}`),_=p(`${i.startTime} ${i.minute}`),x=p(`${i.endTime} ${i.hour}`),u=p(`${i.endTime} ${i.minute}`),f=`
|
|
505
|
+
`;function j(m){if(!m)return{start:null,end:null};try{const t=JSON.parse(m),e=typeof(t==null?void 0:t.start)=="string"?t.start:null,i=typeof(t==null?void 0:t.end)=="string"?t.end:null;return{start:e,end:i}}catch{return{start:null,end:null}}}function W(m){return!m.start&&!m.end?null:JSON.stringify({...m.start?{start:m.start}:{},...m.end?{end:m.end}:{}})}function S(m){return String(m).padStart(2,"0")}function p(m){return m.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function D(m){var a,n;const t=new Date,e=`${S(t.getHours())}:${S(t.getMinutes())}`,i=`${S((t.getHours()+1)%24)}:${S(t.getMinutes())}`,r=s.splitDateTime(m.start||null),l=s.splitDateTime(m.end||null);return{startDate:(r==null?void 0:r.date)||null,endDate:(l==null?void 0:l.date)||null,startTime:((a=r==null?void 0:r.time)==null?void 0:a.slice(0,5))||e,endTime:((n=l==null?void 0:l.time)==null?void 0:n.slice(0,5))||i}}class J extends Y.ElementBase{constructor(){super(...arguments),this._value={start:null,end:null},this._pending=D({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-${++X}`,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=s.rafThrottle(()=>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=>{s.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","auto-normalize","allow-partial","disabled","readonly","required","name","close-on-select","clearable","mode","label","hint","error","show-footer"]}connectedCallback(){if(super.connectedCallback(),this.root.addEventListener("click",this._onRootClickBound),this.root.addEventListener("change",this._onRootChangeBound),this.root.addEventListener("keydown",this._onRootKeyDownBound),!this._isInitialized){const t=j(this.getAttribute("value")||this.getAttribute("default-value"));this._value=t,this._pending=D(t),this._display=this._formatDisplay(),this._open=this.hasAttribute("open")||s.isTruthyAttr(this.getAttribute("default-open")),this._isInitialized=!0}this._open&&!this._isInlineMode()&&this._ensureOverlay()}disconnectedCallback(){this.root.removeEventListener("click",this._onRootClickBound),this.root.removeEventListener("change",this._onRootChangeBound),this.root.removeEventListener("keydown",this._onRootKeyDownBound),this._destroyOverlay(),super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e!==i&&(t==="value"&&!this._syncing&&(this._value=j(i),this._pending=D(this._value),this._display=this._formatDisplay(),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 s.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"}_locale(){return s.normalizeLocale(this.getAttribute("locale"))}_isReadonly(){return this.hasAttribute("readonly")}_clearable(){return s.isTruthyAttr(this.getAttribute("clearable"),!0)}_showFooter(){return s.isTruthyAttr(this.getAttribute("show-footer"),!0)}_shouldAutoCommit(){return s.isTruthyAttr(this.getAttribute("close-on-select"),!1)||!this._showFooter()}_isBare(){return s.isTruthyAttr(this.getAttribute("bare"),!1)}_allowPartial(){return s.isTruthyAttr(this.getAttribute("allow-partial"),!0)}_autoNormalize(){return s.isTruthyAttr(this.getAttribute("auto-normalize"),!0)}_step(){const t=Number(this.getAttribute("step")||5);return!Number.isFinite(t)||t<1?5:Math.min(60,Math.trunc(t))}_translations(){return Q.resolveDateTimeTranslations(this.getAttribute("locale"),this.getAttribute("translations"))}_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=W(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=this._valueFromPending(),i={mode:"datetimerange",start:e.start,end:e.end,value:e.start&&e.end?{start:e.start,end:e.end}:null,source:t};this.dispatchEvent(new CustomEvent("input",{detail:i,bubbles:!0,composed:!0}))}_emitChange(t){const e={mode:"datetimerange",start:this._value.start,end:this._value.end,value:this._value.start&&this._value.end?{start:this._value.start,end:this._value.end}:null,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}))}_valueFromPending(){return{start:s.combineDateTime(this._pending.startDate,this._pending.startTime),end:s.combineDateTime(this._pending.endDate,this._pending.endTime)}}_formatDateTimeDisplay(t){const e=s.splitDateTime(t);return e?`${s.formatDateForDisplay(e.date,this._locale(),"locale",null)} ${e.time}`:t||""}_formatDisplay(){const t=this._value.start,e=this._value.end;return!t&&!e?"":t&&e?`${this._formatDateTimeDisplay(t)} — ${this._formatDateTimeDisplay(e)}`:this._formatDateTimeDisplay(t||e)}_normalizePendingState(t){var h,b;let e=s.combineDateTime(t.startDate,t.startTime),i=s.combineDateTime(t.endDate,t.endTime);if(e&&i&&s.compareDateTimes(e,i)>0&&this._autoNormalize()){const _=e;e=i,i=_}const r=s.parseConstraintDateTime(this.getAttribute("min")),l=s.parseConstraintDateTime(this.getAttribute("max"));let a=r?`${r.date}T${r.time}`:null,n=l?`${l.date}T${l.time}`:null;if(a&&n&&s.compareDateTimes(a,n)>0){const _=a;a=n,n=_}e&&a&&s.compareDateTimes(e,a)<0&&(e=a),e&&n&&s.compareDateTimes(e,n)>0&&(e=n),i&&a&&s.compareDateTimes(i,a)<0&&(i=a),i&&n&&s.compareDateTimes(i,n)>0&&(i=n);const o=s.splitDateTime(e||""),d=s.splitDateTime(i||"");return{startDate:(o==null?void 0:o.date)||null,endDate:(d==null?void 0:d.date)||null,startTime:((h=o==null?void 0:o.time)==null?void 0:h.slice(0,5))||t.startTime,endTime:((b=d==null?void 0:d.time)==null?void 0:b.slice(0,5))||t.endTime}}_commit(t,e){if(this._isInteractionBlocked()||this._isReadonly())return;const i=this._normalizePendingState(t),r={start:s.combineDateTime(i.startDate,i.startTime),end:s.combineDateTime(i.endDate,i.endTime)};if(!this._allowPartial()&&(!r.start||!r.end)){this._inlineError=this.getAttribute("error")||this._translations().rangeIncomplete,this._emitInvalid(JSON.stringify(r),"partial"),this._updateHostState();return}if(r.start&&r.end&&s.compareDateTimes(r.start,r.end)>0){this._inlineError=this.getAttribute("error")||this._translations().invalidRangeOrder,this._emitInvalid(JSON.stringify(r),"order"),this._updateHostState();return}this._value=r,this._pending=i,this._display=this._formatDisplay(),this._inlineError="",this._syncValueAttribute(r),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),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=s.lockBodyScroll())}_syncOverlayHostZIndex(){if(!this._overlay||typeof window>"u")return;const t=window.getComputedStyle(this).getPropertyValue("--ui-drtp-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.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=G.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=s.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(t){const e=s.parseTimeInput(t,!0)||{hours:0,minutes:0,seconds:0},i=this._step(),r=Array.from({length:24},(a,n)=>`<option value="${n}" ${n===e.hours?"selected":""}>${S(n)}</option>`).join(""),l=Array.from({length:Math.ceil(60/i)},(a,n)=>{const o=Math.min(59,n*i);return`<option value="${o}" ${o===e.minutes?"selected":""}>${S(o)}</option>`}).join("");return{hours:r,minutes:l}}_renderSurfaceInner(t,e=!1){const i=this._translations(),r=this._timeOptions(this._pending.startTime),l=this._timeOptions(this._pending.endTime),a=(this.getAttribute("label")||"").trim(),n=p(a),o=p(a||i.selectDateRange),d=this._valueFromPending(),h=d.start&&d.end?`${this._formatDateTimeDisplay(d.start)} — ${this._formatDateTimeDisplay(d.end)}`:i.selectDateRange,b=p(`${i.startTime} ${i.hour}`),_=p(`${i.startTime} ${i.minute}`),x=p(`${i.endTime} ${i.hour}`),u=p(`${i.endTime} ${i.minute}`),f=`
|
|
506
506
|
<header class="head">
|
|
507
507
|
<div>
|
|
508
|
-
<p class="head-title" ${a?"":"hidden"}>${
|
|
508
|
+
<p class="head-title" ${a?"":"hidden"}>${n}</p>
|
|
509
509
|
<p class="head-meta">${p(h)}</p>
|
|
510
510
|
</div>
|
|
511
511
|
</header>
|
|
@@ -545,22 +545,22 @@
|
|
|
545
545
|
<button type="button" class="action" data-action="apply" data-tone="primary">${p(i.apply)}</button>
|
|
546
546
|
</footer>
|
|
547
547
|
`;return e?f:`
|
|
548
|
-
<style>${
|
|
548
|
+
<style>${st}</style>
|
|
549
549
|
${t?'<div class="sheet-backdrop" data-action="backdrop"></div>':""}
|
|
550
550
|
<section class="${t?"sheet":"panel"}" id="${this._panelId}" role="dialog" aria-modal="${t?"true":"false"}" aria-label="${o}" part="${t?"sheet":"popover"}">${f}</section>
|
|
551
|
-
`}_syncCalendar(t){const e=(d,h)=>{if(h==null||h===""){t.hasAttribute(d)&&t.removeAttribute(d);return}t.getAttribute(d)!==h&&t.setAttribute(d,h)},i=(d,h)=>{h?e(d,""):e(d,null)};e("selection","range"),e("value",JSON.stringify({...this._pending.startDate?{start:this._pending.startDate}:{},...this._pending.endDate?{end:this._pending.endDate}:{}}));const r=n.parseConstraintDateTime(this.getAttribute("min")),l=n.parseConstraintDateTime(this.getAttribute("max"));e("min",(r==null?void 0:r.date)||null),e("max",(l==null?void 0:l.date)||null),e("locale",this.getAttribute("locale")),e("translations",this.getAttribute("translations")),e("week-start",this.getAttribute("week-start"));const s=this.getAttribute("size")||"sm",o=t.classList.contains("drtp-calendar-inline");e("size",s==="lg"?"md":"sm"),e("variant",this.getAttribute("variant")),i("readonly",this._isReadonly()),i("disabled",this._isInteractionBlocked()),i("bare",this._isBare()),e("tabindex","-1"),s==="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().selectDateRange)}_overlaySignature(t){return[t?"sheet":"popover",this._step(),this.getAttribute("locale")||"",this.getAttribute("label")||"",this.getAttribute("translations")||""].join(":")}_ensureOverlayContent(t){if(!this._overlay)return;const e=this._overlaySignature(t);this._overlayKey===e&&this._overlay.querySelector(".drtp-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(a=>Number(a.value)).filter(a=>Number.isFinite(a));if(!i.length)return;let r=i[0],l=Math.abs(r-e);for(let a=1;a<i.length;a+=1){const s=i[a],o=Math.abs(s-e);o<l&&(r=s,l=o)}t.value=String(r)}_syncOverlayState(){if(!this._overlay)return;const t=this._isMobileSheet();this._ensureOverlayContent(t);const e=this._translations(),i=this._overlay.querySelector(".panel, .sheet"),r=this._overlay.querySelector(".presets"),l=this._overlay.querySelector(".footer");i&&(i.dataset.bare=this._isBare()?"true":"false");const a=this._showFooter();r&&(r.hidden=!a),l&&(l.hidden=!a);const s=this._overlay.querySelector(".head-title");if(s){const g=(this.getAttribute("label")||"").trim();s.textContent=g,s.hidden=!g}const o=this._overlay.querySelector(".head-meta"),d=this._valueFromPending();o&&(o.textContent=d.start&&d.end?`${this._formatDateTimeDisplay(d.start)} — ${this._formatDateTimeDisplay(d.end)}`:e.selectDateRange);const h=this._overlay.querySelector(".drtp-calendar");h&&this._syncCalendar(h);const b=n.parseTimeInput(this._pending.startTime,!0)||{hours:0,minutes:0,seconds:0},_=n.parseTimeInput(this._pending.endTime,!0)||{hours:0,minutes:0,seconds:0},x=this._overlay.querySelector('select[data-time="start"][data-segment="hours"]'),u=this._overlay.querySelector('select[data-time="start"][data-segment="minutes"]'),f=this._overlay.querySelector('select[data-time="end"][data-segment="hours"]'),y=this._overlay.querySelector('select[data-time="end"][data-segment="minutes"]');x&&this._setClosestOptionValue(x,b.hours),u&&this._setClosestOptionValue(u,b.minutes),f&&this._setClosestOptionValue(f,_.hours),y&&this._setClosestOptionValue(y,_.minutes);const v=this._isInteractionBlocked()||this._isReadonly();[x,u,f,y].forEach(g=>{g&&(g.disabled=v)}),this._overlay.querySelectorAll(".action, .preset").forEach(g=>{g.disabled=v}),t||this._schedulePosition.run()}_renderOverlay(){this._syncOverlayState()}_applyTimeFromOverlay(t){var o,d;const e=t.getAttribute("data-time"),i=(o=this._overlay)==null?void 0:o.querySelector(`select[data-time="${e}"][data-segment="hours"]`),r=(d=this._overlay)==null?void 0:d.querySelector(`select[data-time="${e}"][data-segment="minutes"]`);if(!e||!i||!r)return;const l=Number(i.value),a=Number(r.value);if(!Number.isFinite(l)||!Number.isFinite(a))return;const s=`${S(l)}:${S(a)}`;e==="start"&&(this._pending.startTime=s),e==="end"&&(this._pending.endTime=s),this._pending=this._normalizePendingState(this._pending),this._emitInput("time")}_todayIso(){const t=new Date,e=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${e}-${i}`}_applyPreset(t){const e=this._todayIso();if(t==="preset-today"){this._pending.startDate=e,this._pending.endDate=e,this._pending=this._normalizePendingState(this._pending),this._emitInput("preset-today");return}if(t==="preset-last7"){const r=n.computeLastDaysRange(e,7);this._pending.startDate=r.start,this._pending.endDate=r.end,this._pending=this._normalizePendingState(this._pending),this._emitInput("preset-last7");return}const i=n.computeMonthRange(e);this._pending.startDate=i.start,this._pending.endDate=i.end,this._pending=this._normalizePendingState(this._pending),this._emitInput("preset-month")}_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()&&i!=="toggle")){if(i==="toggle"){this._restoreFocusEl=e,this._setOpen(!this._open,"toggle");return}if(i==="clear"){this._isInlineMode()?(this._pending=D({start:null,end:null}),this._emitInput("clear"),this._updateHostState()):(this._pending=D({start:null,end:null}),this._commit(this._pending,"clear"));return}if(this._isInlineMode()&&(i==="preset-today"||i==="preset-last7"||i==="preset-month")){this._applyPreset(i),this._updateHostState();return}if(this._isInlineMode()&&i==="cancel"){this._pending=D(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-time][data-segment]")||this._isInteractionBlocked()||this._isReadonly())return;if(this._applyTimeFromOverlay(e),this._shouldAutoCommit()){const i=this._valueFromPending();if(i.start&&i.end){this._commit(this._pending,"time");return}}this._updateHostState()}}}_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())){if(i==="backdrop"){this._setOpen(!1,"outside");return}if(i==="cancel"){this._pending=D(this._value),this._setOpen(!1,"cancel");return}if(i==="clear"){this._pending=D({start:null,end:null}),this._emitInput("clear"),this._renderOverlay();return}if(i==="preset-today"||i==="preset-last7"||i==="preset-month"){this._applyPreset(i),this._renderOverlay();return}i==="apply"&&(this._commit(this._pending,"apply"),this._setOpen(!1,"apply"))}}_onOverlayChange(t){const e=t.target;if(e instanceof HTMLSelectElement&&e.matches("select[data-time][data-segment]")&&!(this._isInteractionBlocked()||this._isReadonly())&&(this._applyTimeFromOverlay(e),this._shouldAutoCommit())){const i=this._valueFromPending();i.start&&i.end&&(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.detail;if(!(!i||i.mode!=="range")){if(this._pending.startDate=i.start||null,this._pending.endDate=i.end||null,this._pending=this._normalizePendingState(this._pending),this._emitInput("calendar"),this._shouldAutoCommit()&&this._pending.startDate&&this._pending.endDate){this._commit(this._pending,"calendar"),this._setOpen(!1,"calendar");return}this._isInlineMode()?this._updateHostState():this._renderOverlay()}}_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,l=!!(this._value.start||this._value.end),a=this.getAttribute("name")||"",s=this._isInlineMode(),o=this._translations(),d=r?"error":this._state(),h=this._formatDisplay();this._display=h,this._state()==="loading"?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");const b=this.root.querySelector(".label"),_=this.root.querySelector(".label-text"),x=this.root.querySelector(".required"),u=this.root.querySelector(".input"),f=this.root.querySelector('.btn[data-action="clear"]'),y=this.root.querySelector('.btn[data-action="toggle"]'),v=this.root.querySelector(".hint"),g=this.root.querySelector(".error"),C=this.root.querySelector(".hidden-input");if(b&&(b.hidden=!t,b.id=this._labelId,b.setAttribute("for",this._inputId)),_&&(_.textContent=t),x&&(x.hidden=!this.hasAttribute("required")),u&&(u.value!==h&&(u.value=h),u.id=this._inputId,u.placeholder=o.dateRangeTimePlaceholder,u.readOnly=!0,u.disabled=this._isInteractionBlocked(),u.required=this.hasAttribute("required"),u.autocomplete="off",u.setAttribute("role","combobox"),u.setAttribute("aria-haspopup","dialog"),u.setAttribute("aria-expanded",s?"false":String(this._open)),u.setAttribute("aria-controls",this._panelId),u.setAttribute("aria-invalid",r?"true":"false"),t?u.setAttribute("aria-labelledby",this._labelId):u.removeAttribute("aria-labelledby")),f&&(f.hidden=!(this._clearable()&&l),f.setAttribute("aria-label",o.clearDateRange),f.disabled=this._isInteractionBlocked()),y&&(y.hidden=s,y.setAttribute("aria-label",o.toggleCalendar),y.setAttribute("aria-expanded",s?"false":String(this._open)),y.setAttribute("aria-controls",this._panelId),y.disabled=this._isInteractionBlocked()),v&&(v.id=this._hintId,v.hidden=!e,v.textContent=e),g&&(g.id=this._errorId,g.hidden=!r,g.textContent=r),u){const w=[];e&&v&&!v.hidden&&w.push(this._hintId),r&&w.push(this._errorId),w.length?u.setAttribute("aria-describedby",w.join(" ")):u.removeAttribute("aria-describedby")}C&&(C.disabled=!a,C.name=a,C.value=W(this._value)||"");const A=this.root.querySelector(".field");A&&(A.dataset.open=this._open&&!s?"true":"false",A.dataset.invalid=r?"true":"false",A.dataset.state=d);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||o.selectDateRange);const w=c.querySelector(".panel-title");w&&(w.textContent=t,w.hidden=!t);const $=c.querySelector(".head-title");$&&($.textContent=t,$.hidden=!t);const R=c.querySelector(".head-meta"),I=this._valueFromPending();R&&(R.textContent=I.start&&I.end?`${this._formatDateTimeDisplay(I.start)} — ${this._formatDateTimeDisplay(I.end)}`:o.selectDateRange);const q=c.querySelector(".drtp-calendar-inline");q&&this._syncCalendar(q);const O=c.querySelector('select[data-time="start"][data-segment="hours"]'),z=c.querySelector('select[data-time="start"][data-segment="minutes"]'),P=c.querySelector('select[data-time="end"][data-segment="hours"]'),B=c.querySelector('select[data-time="end"][data-segment="minutes"]'),L=n.parseTimeInput(this._pending.startTime,!0)||{hours:0,minutes:0,seconds:0},M=n.parseTimeInput(this._pending.endTime,!0)||{hours:0,minutes:0,seconds:0};O&&this._setClosestOptionValue(O,L.hours),z&&this._setClosestOptionValue(z,L.minutes),P&&this._setClosestOptionValue(P,M.hours),B&&this._setClosestOptionValue(B,M.minutes),[O,z,P,B].forEach(T=>{T&&(T.disabled=this._isInteractionBlocked()||this._isReadonly())});const E=c.querySelector('[data-action="preset-today"]');E&&(E.textContent=o.today);const H=c.querySelector('[data-action="preset-last7"]');H&&(H.textContent=o.last7Days);const V=c.querySelector('[data-action="preset-month"]');V&&(V.textContent=o.thisMonth);const F=c.querySelector('[data-action="clear"]');F&&(F.textContent=o.clear);const N=c.querySelector('[data-action="apply"]');N&&(N.textContent=o.apply);const K=c.querySelector(".presets"),U=c.querySelector(".footer"),j=this._showFooter();K&&(K.hidden=!j),U&&(U.hidden=!j),c.querySelectorAll(".action, .preset").forEach(T=>{T.disabled=this._isInteractionBlocked()||this._isReadonly()})}!s&&this._open&&this._syncOverlayState(),s&&this._destroyOverlay()}render(){if(!this._hasView){const t=this._translations();this.setContent(`
|
|
552
|
-
<style>${
|
|
551
|
+
`}_syncCalendar(t){const e=(d,h)=>{if(h==null||h===""){t.hasAttribute(d)&&t.removeAttribute(d);return}t.getAttribute(d)!==h&&t.setAttribute(d,h)},i=(d,h)=>{h?e(d,""):e(d,null)};e("selection","range"),e("value",JSON.stringify({...this._pending.startDate?{start:this._pending.startDate}:{},...this._pending.endDate?{end:this._pending.endDate}:{}}));const r=s.parseConstraintDateTime(this.getAttribute("min")),l=s.parseConstraintDateTime(this.getAttribute("max"));e("min",(r==null?void 0:r.date)||null),e("max",(l==null?void 0:l.date)||null),e("locale",this.getAttribute("locale")),e("translations",this.getAttribute("translations")),e("week-start",this.getAttribute("week-start"));const n=this.getAttribute("size")||"sm",o=t.classList.contains("drtp-calendar-inline");e("size",n==="lg"?"md":"sm"),e("variant",this.getAttribute("variant")),i("readonly",this._isReadonly()),i("disabled",this._isInteractionBlocked()),i("bare",this._isBare()),e("tabindex","-1"),n==="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().selectDateRange)}_overlaySignature(t){return[t?"sheet":"popover",this._step(),this.getAttribute("locale")||"",this.getAttribute("label")||"",this.getAttribute("translations")||""].join(":")}_ensureOverlayContent(t){if(!this._overlay)return;const e=this._overlaySignature(t);this._overlayKey===e&&this._overlay.querySelector(".drtp-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(a=>Number(a.value)).filter(a=>Number.isFinite(a));if(!i.length)return;let r=i[0],l=Math.abs(r-e);for(let a=1;a<i.length;a+=1){const n=i[a],o=Math.abs(n-e);o<l&&(r=n,l=o)}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(".presets"),l=this._overlay.querySelector(".footer");i&&(i.dataset.bare=this._isBare()?"true":"false");const a=this._showFooter();r&&(r.hidden=!a),l&&(l.hidden=!a);const n=this._overlay.querySelector(".head-title");if(n){const g=(this.getAttribute("label")||"").trim();n.textContent=g,n.hidden=!g}const o=this._overlay.querySelector(".head-meta"),d=this._valueFromPending();o&&(o.textContent=d.start&&d.end?`${this._formatDateTimeDisplay(d.start)} — ${this._formatDateTimeDisplay(d.end)}`:e.selectDateRange);const h=this._overlay.querySelector(".drtp-calendar");h&&this._syncCalendar(h);const b=s.parseTimeInput(this._pending.startTime,!0)||{hours:0,minutes:0,seconds:0},_=s.parseTimeInput(this._pending.endTime,!0)||{hours:0,minutes:0,seconds:0},x=this._overlay.querySelector('select[data-time="start"][data-segment="hours"]'),u=this._overlay.querySelector('select[data-time="start"][data-segment="minutes"]'),f=this._overlay.querySelector('select[data-time="end"][data-segment="hours"]'),y=this._overlay.querySelector('select[data-time="end"][data-segment="minutes"]');x&&this._setClosestOptionValue(x,b.hours),u&&this._setClosestOptionValue(u,b.minutes),f&&this._setClosestOptionValue(f,_.hours),y&&this._setClosestOptionValue(y,_.minutes);const v=this._isInteractionBlocked()||this._isReadonly();[x,u,f,y].forEach(g=>{g&&(g.disabled=v)}),this._overlay.querySelectorAll(".action, .preset").forEach(g=>{g.disabled=v}),t||this._schedulePosition.run()}_renderOverlay(){this._syncOverlayState()}_applyTimeFromOverlay(t){var o,d;const e=t.getAttribute("data-time"),i=(o=this._overlay)==null?void 0:o.querySelector(`select[data-time="${e}"][data-segment="hours"]`),r=(d=this._overlay)==null?void 0:d.querySelector(`select[data-time="${e}"][data-segment="minutes"]`);if(!e||!i||!r)return;const l=Number(i.value),a=Number(r.value);if(!Number.isFinite(l)||!Number.isFinite(a))return;const n=`${S(l)}:${S(a)}`;e==="start"&&(this._pending.startTime=n),e==="end"&&(this._pending.endTime=n),this._pending=this._normalizePendingState(this._pending),this._emitInput("time")}_todayIso(){const t=new Date,e=String(t.getMonth()+1).padStart(2,"0"),i=String(t.getDate()).padStart(2,"0");return`${t.getFullYear()}-${e}-${i}`}_applyPreset(t){const e=this._todayIso();if(t==="preset-today"){this._pending.startDate=e,this._pending.endDate=e,this._pending=this._normalizePendingState(this._pending),this._emitInput("preset-today");return}if(t==="preset-last7"){const r=s.computeLastDaysRange(e,7);this._pending.startDate=r.start,this._pending.endDate=r.end,this._pending=this._normalizePendingState(this._pending),this._emitInput("preset-last7");return}const i=s.computeMonthRange(e);this._pending.startDate=i.start,this._pending.endDate=i.end,this._pending=this._normalizePendingState(this._pending),this._emitInput("preset-month")}_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()&&i!=="toggle")){if(i==="toggle"){this._restoreFocusEl=e,this._setOpen(!this._open,"toggle");return}if(i==="clear"){this._isInlineMode()?(this._pending=D({start:null,end:null}),this._emitInput("clear"),this._updateHostState()):(this._pending=D({start:null,end:null}),this._commit(this._pending,"clear"));return}if(this._isInlineMode()&&(i==="preset-today"||i==="preset-last7"||i==="preset-month")){this._applyPreset(i),this._updateHostState();return}if(this._isInlineMode()&&i==="cancel"){this._pending=D(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-time][data-segment]")||this._isInteractionBlocked()||this._isReadonly())return;if(this._applyTimeFromOverlay(e),this._shouldAutoCommit()){const i=this._valueFromPending();if(i.start&&i.end){this._commit(this._pending,"time");return}}this._updateHostState()}}}_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())){if(i==="backdrop"){this._setOpen(!1,"outside");return}if(i==="cancel"){this._pending=D(this._value),this._setOpen(!1,"cancel");return}if(i==="clear"){this._pending=D({start:null,end:null}),this._emitInput("clear"),this._renderOverlay();return}if(i==="preset-today"||i==="preset-last7"||i==="preset-month"){this._applyPreset(i),this._renderOverlay();return}i==="apply"&&(this._commit(this._pending,"apply"),this._setOpen(!1,"apply"))}}_onOverlayChange(t){const e=t.target;if(e instanceof HTMLSelectElement&&e.matches("select[data-time][data-segment]")&&!(this._isInteractionBlocked()||this._isReadonly())&&(this._applyTimeFromOverlay(e),this._shouldAutoCommit())){const i=this._valueFromPending();i.start&&i.end&&(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.detail;if(!(!i||i.mode!=="range")){if(this._pending.startDate=i.start||null,this._pending.endDate=i.end||null,this._pending=this._normalizePendingState(this._pending),this._emitInput("calendar"),this._shouldAutoCommit()&&this._pending.startDate&&this._pending.endDate){this._commit(this._pending,"calendar"),this._setOpen(!1,"calendar");return}this._isInlineMode()?this._updateHostState():this._renderOverlay()}}_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,l=!!(this._value.start||this._value.end),a=this.getAttribute("name")||"",n=this._isInlineMode(),o=this._translations(),d=r?"error":this._state(),h=this._formatDisplay();this._display=h,this._state()==="loading"?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy");const b=this.root.querySelector(".label"),_=this.root.querySelector(".label-text"),x=this.root.querySelector(".required"),u=this.root.querySelector(".input"),f=this.root.querySelector('.btn[data-action="clear"]'),y=this.root.querySelector('.btn[data-action="toggle"]'),v=this.root.querySelector(".hint"),g=this.root.querySelector(".error"),C=this.root.querySelector(".hidden-input");if(b&&(b.hidden=!t,b.id=this._labelId,b.setAttribute("for",this._inputId)),_&&(_.textContent=t),x&&(x.hidden=!this.hasAttribute("required")),u&&(u.value!==h&&(u.value=h),u.id=this._inputId,u.placeholder=o.dateRangeTimePlaceholder,u.readOnly=!0,u.disabled=this._isInteractionBlocked(),u.required=this.hasAttribute("required"),u.autocomplete="off",u.setAttribute("role","combobox"),u.setAttribute("aria-haspopup","dialog"),u.setAttribute("aria-expanded",n?"false":String(this._open)),u.setAttribute("aria-controls",this._panelId),u.setAttribute("aria-invalid",r?"true":"false"),t?u.setAttribute("aria-labelledby",this._labelId):u.removeAttribute("aria-labelledby")),f&&(f.hidden=!(this._clearable()&&l),f.setAttribute("aria-label",o.clearDateRange),f.disabled=this._isInteractionBlocked()),y&&(y.hidden=n,y.setAttribute("aria-label",o.toggleCalendar),y.setAttribute("aria-expanded",n?"false":String(this._open)),y.setAttribute("aria-controls",this._panelId),y.disabled=this._isInteractionBlocked()),v&&(v.id=this._hintId,v.hidden=!e,v.textContent=e),g&&(g.id=this._errorId,g.hidden=!r,g.textContent=r),u){const w=[];e&&v&&!v.hidden&&w.push(this._hintId),r&&w.push(this._errorId),w.length?u.setAttribute("aria-describedby",w.join(" ")):u.removeAttribute("aria-describedby")}C&&(C.disabled=!a,C.name=a,C.value=W(this._value)||"");const I=this.root.querySelector(".field");I&&(I.dataset.open=this._open&&!n?"true":"false",I.dataset.invalid=r?"true":"false",I.dataset.state=d);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||o.selectDateRange);const w=c.querySelector(".panel-title");w&&(w.textContent=t,w.hidden=!t);const $=c.querySelector(".head-title");$&&($.textContent=t,$.hidden=!t);const R=c.querySelector(".head-meta"),A=this._valueFromPending();R&&(R.textContent=A.start&&A.end?`${this._formatDateTimeDisplay(A.start)} — ${this._formatDateTimeDisplay(A.end)}`:o.selectDateRange);const q=c.querySelector(".drtp-calendar-inline");q&&this._syncCalendar(q);const O=c.querySelector('select[data-time="start"][data-segment="hours"]'),z=c.querySelector('select[data-time="start"][data-segment="minutes"]'),P=c.querySelector('select[data-time="end"][data-segment="hours"]'),B=c.querySelector('select[data-time="end"][data-segment="minutes"]'),L=s.parseTimeInput(this._pending.startTime,!0)||{hours:0,minutes:0,seconds:0},M=s.parseTimeInput(this._pending.endTime,!0)||{hours:0,minutes:0,seconds:0};O&&this._setClosestOptionValue(O,L.hours),z&&this._setClosestOptionValue(z,L.minutes),P&&this._setClosestOptionValue(P,M.hours),B&&this._setClosestOptionValue(B,M.minutes),[O,z,P,B].forEach(T=>{T&&(T.disabled=this._isInteractionBlocked()||this._isReadonly())});const E=c.querySelector('[data-action="preset-today"]');E&&(E.textContent=o.today);const H=c.querySelector('[data-action="preset-last7"]');H&&(H.textContent=o.last7Days);const V=c.querySelector('[data-action="preset-month"]');V&&(V.textContent=o.thisMonth);const F=c.querySelector('[data-action="clear"]');F&&(F.textContent=o.clear);const N=c.querySelector('[data-action="apply"]');N&&(N.textContent=o.apply);const K=c.querySelector(".presets"),U=c.querySelector(".footer"),Z=this._showFooter();K&&(K.hidden=!Z),U&&(U.hidden=!Z),c.querySelectorAll(".action, .preset").forEach(T=>{T.disabled=this._isInteractionBlocked()||this._isReadonly()})}!n&&this._open&&this._syncOverlayState(),n&&this._destroyOverlay()}render(){if(!this._hasView){const t=this._translations();this.setContent(`
|
|
552
|
+
<style>${rt}</style>
|
|
553
553
|
<div class="root">
|
|
554
554
|
<label class="label" part="label" id="${this._labelId}">
|
|
555
555
|
<span class="label-text"></span>
|
|
556
556
|
<span class="required">*</span>
|
|
557
557
|
</label>
|
|
558
558
|
<div class="field" part="field input">
|
|
559
|
-
<span class="icon" part="icon">${
|
|
559
|
+
<span class="icon" part="icon">${tt}</span>
|
|
560
560
|
<input class="input" id="${this._inputId}" part="input" readonly />
|
|
561
561
|
<span class="icon" part="icon">${k}</span>
|
|
562
|
-
<button type="button" class="btn" part="clear" data-action="clear">${
|
|
563
|
-
<button type="button" class="btn" part="toggle" data-action="toggle">${
|
|
562
|
+
<button type="button" class="btn" part="clear" data-action="clear">${it}</button>
|
|
563
|
+
<button type="button" class="btn" part="toggle" data-action="toggle">${et}</button>
|
|
564
564
|
</div>
|
|
565
565
|
<div class="hint" id="${this._hintId}" part="hint"></div>
|
|
566
566
|
<div class="error" id="${this._errorId}" part="error" role="alert"></div>
|