@editora/ui-core 0.1.17 → 0.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/button.cjs.js +4 -4
- package/dist/button.esm.js +2 -0
- package/dist/components/ui-button.d.ts +1 -0
- package/dist/components/ui-button.d.ts.map +1 -1
- package/dist/components/ui-date-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-picker.d.ts.map +1 -1
- package/dist/components/ui-date-range-time-picker.d.ts +1 -0
- package/dist/components/ui-date-range-time-picker.d.ts.map +1 -1
- package/dist/components/ui-date-time-picker.d.ts +1 -0
- package/dist/components/ui-date-time-picker.d.ts.map +1 -1
- package/dist/components/ui-time-picker.d.ts.map +1 -1
- package/dist/date-picker.cjs.js +25 -4
- package/dist/date-picker.esm.js +21 -0
- package/dist/date-range-picker.cjs.js +19 -0
- package/dist/date-range-picker.esm.js +78 -59
- package/dist/date-range-time-picker.cjs.js +26 -10
- package/dist/date-range-time-picker.esm.js +46 -30
- package/dist/date-time-picker.cjs.js +23 -7
- package/dist/date-time-picker.esm.js +64 -48
- package/dist/time-picker.cjs.js +11 -3
- package/dist/time-picker.esm.js +9 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { E as W } from "./ElementBase-909688f3.mjs";
|
|
2
2
|
import { c as Y } from "./dismissable-layer-9c7e6b58.mjs";
|
|
3
3
|
import { r as J } from "./calendar-2c11b824.mjs";
|
|
4
|
-
import { r as G, e as Q, i as v, s as X, b as tt, f as et, t as it, n as R, d as st, p as F, o as N, a as
|
|
4
|
+
import { r as G, e as Q, i as v, s as X, b as tt, f as et, t as it, n as R, d as st, p as F, o as N, a as rt, m as E, j as Z, k as j, q as y, l as nt, c as at } from "./date-time-utils-a2c7af25.mjs";
|
|
5
5
|
import "./scroll-lock-31da444f.mjs";
|
|
6
6
|
import "./positioner-e9770c66.mjs";
|
|
7
7
|
let ot = 0;
|
|
@@ -288,6 +288,22 @@ const lt = `
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
`, pt = `
|
|
291
|
+
.ui-date-time-picker-overlay-host {
|
|
292
|
+
--ui-dtp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
293
|
+
--ui-dtp-surface: linear-gradient(
|
|
294
|
+
180deg,
|
|
295
|
+
color-mix(in srgb, var(--ui-color-surface, #ffffff) 98%, transparent),
|
|
296
|
+
color-mix(in srgb, var(--ui-color-surface, #ffffff) 90%, var(--ui-color-surface-alt, #f8fafc))
|
|
297
|
+
);
|
|
298
|
+
--ui-dtp-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 78%, transparent);
|
|
299
|
+
--ui-dp-text: var(--ui-color-text, #0f172a);
|
|
300
|
+
--ui-dp-muted: var(--ui-color-muted, #64748b);
|
|
301
|
+
--ui-dtp-accent: var(--ui-color-primary, #2563eb);
|
|
302
|
+
--ui-dtp-panel-radius: 14px;
|
|
303
|
+
--ui-dtp-shadow: none;
|
|
304
|
+
--ui-dtp-duration: 160ms;
|
|
305
|
+
--ui-dtp-ease: cubic-bezier(0.2, 0.9, 0.24, 1);
|
|
306
|
+
}
|
|
291
307
|
.overlay { position: fixed; z-index: var(--ui-dtp-z, 1600); pointer-events: none; }
|
|
292
308
|
.panel {
|
|
293
309
|
pointer-events: auto;
|
|
@@ -589,8 +605,8 @@ class ht extends W {
|
|
|
589
605
|
const s = new Date(t);
|
|
590
606
|
if (!Number.isFinite(s.getTime()))
|
|
591
607
|
return null;
|
|
592
|
-
const a = s.getFullYear(), o = String(s.getMonth() + 1).padStart(2, "0"),
|
|
593
|
-
return `${a}-${o}-${
|
|
608
|
+
const a = s.getFullYear(), o = String(s.getMonth() + 1).padStart(2, "0"), r = String(s.getDate()).padStart(2, "0");
|
|
609
|
+
return `${a}-${o}-${r}`;
|
|
594
610
|
}
|
|
595
611
|
_syncOpenAttribute(t) {
|
|
596
612
|
this._syncing = !0;
|
|
@@ -649,15 +665,15 @@ class ht extends W {
|
|
|
649
665
|
_clampState(t) {
|
|
650
666
|
if (!t.date)
|
|
651
667
|
return { date: null, time: t.time };
|
|
652
|
-
const e = this._minDate(), i = this._maxDate(), s =
|
|
653
|
-
let o = this._minDateTime(),
|
|
654
|
-
if (o &&
|
|
655
|
-
const
|
|
656
|
-
o =
|
|
668
|
+
const e = this._minDate(), i = this._maxDate(), s = rt(t.date, e, i), a = t.time || "00:00";
|
|
669
|
+
let o = this._minDateTime(), r = this._maxDateTime();
|
|
670
|
+
if (o && r && E(o, r) > 0) {
|
|
671
|
+
const f = o;
|
|
672
|
+
o = r, r = f;
|
|
657
673
|
}
|
|
658
|
-
let
|
|
659
|
-
o && E(
|
|
660
|
-
const d = j(
|
|
674
|
+
let n = Z(s, a) || `${s}T00:00`;
|
|
675
|
+
o && E(n, o) < 0 && (n = o), r && E(n, r) > 0 && (n = r);
|
|
676
|
+
const d = j(n);
|
|
661
677
|
return d ? { date: d.date, time: d.time } : { date: s, time: a };
|
|
662
678
|
}
|
|
663
679
|
_commit(t, e) {
|
|
@@ -701,7 +717,7 @@ class ht extends W {
|
|
|
701
717
|
if (this._overlay || typeof document > "u")
|
|
702
718
|
return;
|
|
703
719
|
const t = document.createElement("div");
|
|
704
|
-
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 =
|
|
720
|
+
t.className = "ui-date-time-picker-overlay-host", t.style.position = "fixed", t.style.left = "0", t.style.top = "0", t.style.pointerEvents = "none", t.addEventListener("click", this._onOverlayClickBound), t.addEventListener("change", this._onOverlayChangeBound), t.addEventListener("change", this._onOverlayCalendarBound), t.addEventListener("select", this._onOverlayCalendarBound), document.body.appendChild(t), this._overlay = t, this._syncOverlayHostZIndex(), document.addEventListener("pointerdown", this._onDocumentPointerDownBound, !0), document.addEventListener("keydown", this._onDocumentKeyDownBound), window.addEventListener("resize", this._onWindowResizeBound), window.addEventListener("scroll", this._onWindowScrollBound, { passive: !0, capture: !0 }), this._isMobileSheet() && (this._releaseScrollLock = nt());
|
|
705
721
|
}
|
|
706
722
|
_syncOverlayHostZIndex() {
|
|
707
723
|
if (!this._overlay || typeof window > "u")
|
|
@@ -743,21 +759,21 @@ class ht extends W {
|
|
|
743
759
|
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);
|
|
744
760
|
}
|
|
745
761
|
_timeOptions() {
|
|
746
|
-
const t = y(this._pending.time || "00:00", !0) || { hours: 0, minutes: 0, seconds: 0 }, e = this._minuteStep(), i = this._is12h() ? Array.from({ length: 12 }, (o,
|
|
747
|
-
const
|
|
748
|
-
return `<option value="${
|
|
749
|
-
}).join("") : Array.from({ length: 24 }, (o,
|
|
750
|
-
const
|
|
751
|
-
return `<option value="${
|
|
762
|
+
const t = y(this._pending.time || "00:00", !0) || { hours: 0, minutes: 0, seconds: 0 }, e = this._minuteStep(), i = this._is12h() ? Array.from({ length: 12 }, (o, r) => {
|
|
763
|
+
const n = r + 1, d = t.hours % 12 || 12;
|
|
764
|
+
return `<option value="${n}" ${n === d ? "selected" : ""}>${p(n)}</option>`;
|
|
765
|
+
}).join("") : Array.from({ length: 24 }, (o, r) => `<option value="${r}" ${r === t.hours ? "selected" : ""}>${p(r)}</option>`).join(""), s = Array.from({ length: Math.ceil(60 / e) }, (o, r) => {
|
|
766
|
+
const n = Math.min(59, r * e);
|
|
767
|
+
return `<option value="${n}" ${n === t.minutes ? "selected" : ""}>${p(n)}</option>`;
|
|
752
768
|
}).join(""), a = t.hours >= 12 ? "pm" : "am";
|
|
753
769
|
return { hours: i, minutes: s, meridiem: a };
|
|
754
770
|
}
|
|
755
771
|
_renderSurfaceInner(t, e = !1) {
|
|
756
|
-
const i = this._translations(), s = this._timeOptions(), a = (this.getAttribute("label") || "").trim(), o = c(a),
|
|
772
|
+
const i = this._translations(), s = this._timeOptions(), a = (this.getAttribute("label") || "").trim(), o = c(a), r = c(a || i.selectDate), n = this._pending.date && this._pending.time ? this._formatDisplay(this._pending) : "", d = `
|
|
757
773
|
<header class="head">
|
|
758
774
|
<div>
|
|
759
775
|
<p class="head-title" ${a ? "" : "hidden"}>${o}</p>
|
|
760
|
-
<p class="head-meta">${c(
|
|
776
|
+
<p class="head-meta">${c(n || i.selectDate)}</p>
|
|
761
777
|
</div>
|
|
762
778
|
</header>
|
|
763
779
|
<div class="content">
|
|
@@ -781,18 +797,18 @@ class ht extends W {
|
|
|
781
797
|
return e ? d : `
|
|
782
798
|
<style>${pt}</style>
|
|
783
799
|
${t ? '<div class="sheet-backdrop" data-action="backdrop"></div>' : ""}
|
|
784
|
-
<section class="${t ? "sheet" : "panel"}" id="${this._panelId}" role="dialog" aria-modal="${t ? "true" : "false"}" aria-label="${
|
|
800
|
+
<section class="${t ? "sheet" : "panel"}" id="${this._panelId}" role="dialog" aria-modal="${t ? "true" : "false"}" aria-label="${r}" part="${t ? "sheet" : "popover"}">${d}</section>
|
|
785
801
|
`;
|
|
786
802
|
}
|
|
787
803
|
_syncCalendar(t) {
|
|
788
|
-
const e = (
|
|
789
|
-
if (
|
|
790
|
-
t.hasAttribute(
|
|
804
|
+
const e = (r, n) => {
|
|
805
|
+
if (n == null || n === "") {
|
|
806
|
+
t.hasAttribute(r) && t.removeAttribute(r);
|
|
791
807
|
return;
|
|
792
808
|
}
|
|
793
|
-
t.getAttribute(
|
|
794
|
-
}, i = (
|
|
795
|
-
|
|
809
|
+
t.getAttribute(r) !== n && t.setAttribute(r, n);
|
|
810
|
+
}, i = (r, n) => {
|
|
811
|
+
n ? e(r, "") : e(r, null);
|
|
796
812
|
};
|
|
797
813
|
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"));
|
|
798
814
|
const a = this.getAttribute("size") || "sm", o = t.classList.contains("dt-calendar-inline");
|
|
@@ -819,8 +835,8 @@ class ht extends W {
|
|
|
819
835
|
return;
|
|
820
836
|
let s = i[0], a = Math.abs(s - e);
|
|
821
837
|
for (let o = 1; o < i.length; o += 1) {
|
|
822
|
-
const
|
|
823
|
-
|
|
838
|
+
const r = i[o], n = Math.abs(r - e);
|
|
839
|
+
n < a && (s = r, a = n);
|
|
824
840
|
}
|
|
825
841
|
t.value = String(s);
|
|
826
842
|
}
|
|
@@ -839,14 +855,14 @@ class ht extends W {
|
|
|
839
855
|
}
|
|
840
856
|
const o = this._overlay.querySelector(".head-meta");
|
|
841
857
|
o && (o.textContent = this._pending.date && this._pending.time ? this._formatDisplay(this._pending) : e.selectDate);
|
|
842
|
-
const
|
|
843
|
-
|
|
844
|
-
const
|
|
858
|
+
const r = this._overlay.querySelector(".dt-calendar");
|
|
859
|
+
r && this._syncCalendar(r);
|
|
860
|
+
const n = y(this._pending.time || "00:00", !0) || { hours: 0, minutes: 0, seconds: 0 }, d = this._overlay.querySelector('select[data-segment="hours"]'), f = this._overlay.querySelector('select[data-segment="minutes"]'), m = this._overlay.querySelector('select[data-segment="meridiem"]');
|
|
845
861
|
if (d) {
|
|
846
|
-
const l = this._is12h() ?
|
|
862
|
+
const l = this._is12h() ? n.hours % 12 || 12 : n.hours;
|
|
847
863
|
this._setClosestOptionValue(d, l), d.disabled = this._isInteractionBlocked() || this._isReadonly();
|
|
848
864
|
}
|
|
849
|
-
|
|
865
|
+
f && (this._setClosestOptionValue(f, n.minutes), f.disabled = this._isInteractionBlocked() || this._isReadonly()), m && (m.value = n.hours >= 12 ? "pm" : "am", m.disabled = this._isInteractionBlocked() || this._isReadonly());
|
|
850
866
|
const S = this._isInteractionBlocked() || this._isReadonly();
|
|
851
867
|
this._overlay.querySelectorAll(".action").forEach((l) => {
|
|
852
868
|
l.disabled = S;
|
|
@@ -862,14 +878,14 @@ class ht extends W {
|
|
|
862
878
|
const a = Number(e.value), o = Number(i.value);
|
|
863
879
|
if (!Number.isFinite(a) || !Number.isFinite(o))
|
|
864
880
|
return;
|
|
865
|
-
let
|
|
881
|
+
let r = a;
|
|
866
882
|
if (this._is12h()) {
|
|
867
|
-
const
|
|
868
|
-
|
|
883
|
+
const n = (s == null ? void 0 : s.value) === "pm" ? "pm" : "am";
|
|
884
|
+
n === "pm" && r < 12 && (r += 12), n === "am" && r === 12 && (r = 0);
|
|
869
885
|
}
|
|
870
886
|
this._pending = this._clampState({
|
|
871
887
|
date: this._pending.date,
|
|
872
|
-
time: `${p(
|
|
888
|
+
time: `${p(r)}:${p(o)}`
|
|
873
889
|
}), this._emitInput("time");
|
|
874
890
|
}
|
|
875
891
|
_onRootClick(t) {
|
|
@@ -888,8 +904,8 @@ class ht extends W {
|
|
|
888
904
|
return;
|
|
889
905
|
}
|
|
890
906
|
if (this._isInlineMode() && i === "now") {
|
|
891
|
-
const a = /* @__PURE__ */ new Date(), o = String(a.getMonth() + 1).padStart(2, "0"),
|
|
892
|
-
this._pending = this._clampState({ date:
|
|
907
|
+
const a = /* @__PURE__ */ new Date(), o = String(a.getMonth() + 1).padStart(2, "0"), r = String(a.getDate()).padStart(2, "0"), n = `${a.getFullYear()}-${o}-${r}`, d = `${p(a.getHours())}:${p(a.getMinutes())}`;
|
|
908
|
+
this._pending = this._clampState({ date: n, time: d }), this._emitInput("now"), this._updateHostState();
|
|
893
909
|
return;
|
|
894
910
|
}
|
|
895
911
|
if (this._isInlineMode() && i === "cancel") {
|
|
@@ -977,8 +993,8 @@ class ht extends W {
|
|
|
977
993
|
return;
|
|
978
994
|
}
|
|
979
995
|
if (i === "now") {
|
|
980
|
-
const a = /* @__PURE__ */ new Date(), o = String(a.getMonth() + 1).padStart(2, "0"),
|
|
981
|
-
this._pending = this._clampState({ date:
|
|
996
|
+
const a = /* @__PURE__ */ new Date(), o = String(a.getMonth() + 1).padStart(2, "0"), r = String(a.getDate()).padStart(2, "0"), n = `${a.getFullYear()}-${o}-${r}`, d = `${p(a.getHours())}:${p(a.getMinutes())}`;
|
|
997
|
+
this._pending = this._clampState({ date: n, time: d }), this._emitInput("now"), this._renderOverlay();
|
|
982
998
|
return;
|
|
983
999
|
}
|
|
984
1000
|
i === "apply" && (this._commit(this._pending, "apply"), this._setOpen(!1, "apply"));
|
|
@@ -1015,19 +1031,19 @@ class ht extends W {
|
|
|
1015
1031
|
_updateHostState() {
|
|
1016
1032
|
if (!this._hasView)
|
|
1017
1033
|
return;
|
|
1018
|
-
const t = this.getAttribute("label") || "", e = this.getAttribute("hint") || "", i = this.getAttribute("error") || "", s = this._inlineError || i, a = !!x(this._value), o = this.getAttribute("name") || "",
|
|
1034
|
+
const t = this.getAttribute("label") || "", e = this.getAttribute("hint") || "", i = this.getAttribute("error") || "", s = this._inlineError || i, a = !!x(this._value), o = this.getAttribute("name") || "", r = this._allowInput() ? this._draft : this._formatDisplay(this._value), n = this._isInlineMode(), d = this._translations(), f = s ? "error" : this._state();
|
|
1019
1035
|
this._state() === "loading" ? this.setAttribute("aria-busy", "true") : this.removeAttribute("aria-busy");
|
|
1020
|
-
const m = this.root.querySelector(".label"), S = this.root.querySelector(".label-text"), D = this.root.querySelector(".required"), l = this.root.querySelector(".input"),
|
|
1021
|
-
if (m && (m.hidden = !t), m && (m.id = this._labelId, m.setAttribute("for", this._inputId)), S && (S.textContent = t), D && (D.hidden = !this.hasAttribute("required")), l && (l.value !==
|
|
1036
|
+
const m = this.root.querySelector(".label"), S = this.root.querySelector(".label-text"), D = this.root.querySelector(".required"), l = this.root.querySelector(".input"), w = this.root.querySelector('.btn[data-action="clear"]'), b = this.root.querySelector('.btn[data-action="toggle"]'), g = this.root.querySelector(".hint"), I = this.root.querySelector(".error"), k = this.root.querySelector(".hidden-input");
|
|
1037
|
+
if (m && (m.hidden = !t), m && (m.id = this._labelId, m.setAttribute("for", this._inputId)), S && (S.textContent = t), D && (D.hidden = !this.hasAttribute("required")), l && (l.value !== r && (l.value = r), l.id = this._inputId, l.placeholder = d.dateTimePlaceholder, l.readOnly = !this._allowInput() || this._isReadonly(), l.disabled = this._isInteractionBlocked(), l.required = this.hasAttribute("required"), l.autocomplete = "off", l.setAttribute("role", "combobox"), l.setAttribute("aria-haspopup", "dialog"), l.setAttribute("aria-expanded", n ? "false" : String(this._open)), l.setAttribute("aria-controls", this._panelId), l.setAttribute("aria-invalid", s ? "true" : "false"), t ? l.setAttribute("aria-labelledby", this._labelId) : l.removeAttribute("aria-labelledby")), w && (w.hidden = !(this._clearable() && a), w.setAttribute("aria-label", d.clear), w.disabled = this._isInteractionBlocked()), b && (b.hidden = n, b.setAttribute("aria-label", d.toggleCalendar), b.setAttribute("aria-expanded", n ? "false" : String(this._open)), b.setAttribute("aria-controls", this._panelId), b.disabled = this._isInteractionBlocked()), g && (g.id = this._hintId, g.hidden = !e, g.textContent = e), I && (I.id = this._errorId, I.hidden = !s, I.textContent = s), l) {
|
|
1022
1038
|
const _ = [];
|
|
1023
1039
|
e && g && !g.hidden && _.push(this._hintId), s && _.push(this._errorId), _.length ? l.setAttribute("aria-describedby", _.join(" ")) : l.removeAttribute("aria-describedby");
|
|
1024
1040
|
}
|
|
1025
1041
|
k && (k.disabled = !o, k.name = o, k.value = x(this._value) || "");
|
|
1026
1042
|
const A = this.root.querySelector(".field");
|
|
1027
|
-
A && (A.dataset.open = this._open && !
|
|
1043
|
+
A && (A.dataset.open = this._open && !n ? "true" : "false", A.dataset.invalid = s ? "true" : "false", A.dataset.state = f);
|
|
1028
1044
|
const u = this.root.querySelector(".inline-panel");
|
|
1029
1045
|
if (u) {
|
|
1030
|
-
u.hidden = !
|
|
1046
|
+
u.hidden = !n, u.id = this._panelId, u.dataset.bare = this._isBare() ? "true" : "false", u.setAttribute("role", "dialog"), u.setAttribute("aria-modal", "false"), u.setAttribute("aria-label", t || d.selectDate);
|
|
1031
1047
|
const _ = u.querySelector(".panel-title");
|
|
1032
1048
|
_ && (_.textContent = t, _.hidden = !t);
|
|
1033
1049
|
const $ = u.querySelector(".head-title");
|
|
@@ -1053,7 +1069,7 @@ class ht extends W {
|
|
|
1053
1069
|
L.disabled = this._isInteractionBlocked() || this._isReadonly();
|
|
1054
1070
|
});
|
|
1055
1071
|
}
|
|
1056
|
-
!
|
|
1072
|
+
!n && this._open && this._syncOverlayState(), n && this._destroyOverlay();
|
|
1057
1073
|
}
|
|
1058
1074
|
render() {
|
|
1059
1075
|
if (!this._hasView) {
|
package/dist/time-picker.cjs.js
CHANGED
|
@@ -140,6 +140,14 @@
|
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
`,B=`
|
|
143
|
+
.ui-time-picker-overlay-host {
|
|
144
|
+
--ui-dp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
145
|
+
--ui-dp-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 72%, transparent);
|
|
146
|
+
--ui-dp-text: var(--ui-color-text, #0f172a);
|
|
147
|
+
--ui-dp-muted: var(--ui-color-muted, #64748b);
|
|
148
|
+
--ui-dp-accent: var(--ui-color-primary, #2563eb);
|
|
149
|
+
--ui-dp-radius: 12px;
|
|
150
|
+
}
|
|
143
151
|
.overlay { position: fixed; z-index: var(--ui-dp-z, 1600); pointer-events: none; }
|
|
144
152
|
.panel {
|
|
145
153
|
pointer-events: auto;
|
|
@@ -245,11 +253,11 @@
|
|
|
245
253
|
outline-color: Highlight;
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
|
-
`;function p(_){return String(_).padStart(2,"0")}function m(_,t,e,i){const s=p(_),n=p(t);return i?`${s}:${n}:${p(e)}`:`${s}:${n}`}class
|
|
256
|
+
`;function p(_){return String(_).padStart(2,"0")}function m(_,t,e,i){const s=p(_),n=p(t);return i?`${s}:${n}:${p(e)}`:`${s}:${n}`}class f extends g.ElementBase{constructor(){super(...arguments),this._value=null,this._pending=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._fieldEl=null,this._labelEl=null,this._labelTextEl=null,this._requiredEl=null,this._inputEl=null,this._clearBtn=null,this._toggleBtn=null,this._hintEl=null,this._errorEl=null,this._hiddenInputEl=null,this._schedulePosition=a.rafThrottle(()=>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._onOverlayClickBound=t=>this._onOverlayClick(t),this._onOverlayChangeBound=t=>this._onOverlayChange(t),this._onDocumentPointerDownBound=t=>this._onDocumentPointerDown(t),this._onDocumentKeyDownBound=t=>this._onDocumentKeyDown(t),this._onWindowResizeBound=()=>this._schedulePosition.run(),this._onWindowScrollBound=t=>{a.eventOriginatesWithin(t,[this._overlay])||this._schedulePosition.run()}}static get observedAttributes(){return["open","default-open","value","default-value","format","step","seconds","step-seconds","min","max","disabled","readonly","required","name","clearable","allow-input","mode","label","hint","error","translations","locale","variant"]}connectedCallback(){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._hasView&&!this._inputEl&&this._cacheDomRefs(),!this._isInitialized){const t=this._normalizeCanonical(this.getAttribute("value")||this.getAttribute("default-value"));this._value=t,this._pending=t,this._draft=this._formatDisplay(t),this._open=this.hasAttribute("open")||a.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("focusout",this._onRootBlurBound),this.root.removeEventListener("keydown",this._onRootKeyDownBound),this._destroyOverlay(),this._fieldEl=null,this._labelEl=null,this._labelTextEl=null,this._requiredEl=null,this._inputEl=null,this._clearBtn=null,this._toggleBtn=null,this._hintEl=null,this._errorEl=null,this._hiddenInputEl=null,super.disconnectedCallback()}attributeChangedCallback(t,e,i){if(e!==i&&(t==="value"&&!this._syncing&&(this._value=this._normalizeCanonical(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"),!!this.isConnected)){if(!this._hasView){this.requestRender();return}this._updateHostState()}}_isInlineMode(){return(this.getAttribute("mode")||"popover")==="inline"}_isMobileSheet(){return a.shouldUseMobileSheet(this.getAttribute("mode"))}_isDisabled(){return this.hasAttribute("disabled")}_isReadonly(){return this.hasAttribute("readonly")}_allowInput(){return a.isTruthyAttr(this.getAttribute("allow-input"),!0)}_clearable(){return a.isTruthyAttr(this.getAttribute("clearable"),!0)}_withSeconds(){return this.hasAttribute("seconds")}_is12h(){return(this.getAttribute("format")||"24h")==="12h"}_minuteStep(){const t=Number(this.getAttribute("step")||5),e=5;return!Number.isFinite(t)||t<1?e:Math.min(60,Math.trunc(t))}_secondStep(){const t=Number(this.getAttribute("step-seconds")||1);return!Number.isFinite(t)||t<1?1:Math.min(60,Math.trunc(t))}_translations(){return E.resolveDateTimeTranslations(this.getAttribute("locale"),this.getAttribute("translations"))}_normalizeCanonical(t){if(!t)return null;const e=a.parseTimeInput(t,!0);return e?m(e.hours,e.minutes,e.seconds,this._withSeconds()):null}_minTime(){return this._normalizeCanonical(this.getAttribute("min"))}_maxTime(){return this._normalizeCanonical(this.getAttribute("max"))}_formatDisplay(t){return t?this._is12h()?a.to12hDisplay(t,this.getAttribute("locale")||"en-US"):t:""}_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){this._syncing=!0;try{t?this.getAttribute("value")!==t&&this.setAttribute("value",t):this.hasAttribute("value")&&this.removeAttribute("value")}finally{this._syncing=!1}}_emitInput(t){const e={mode:"time",value:this._pending,source:t};this.dispatchEvent(new CustomEvent("input",{detail:e,bubbles:!0,composed:!0}))}_emitChange(t){const e={mode:"time",value:this._value,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}))}_clampToBounds(t){if(!t)return null;const e=this._minTime(),i=this._maxTime();let s=t;return e&&a.compareTimes(s,e)<0&&(s=e),i&&a.compareTimes(s,i)>0&&(s=i),s}_commit(t,e){if(this._isDisabled()||this._isReadonly())return;const i=this._clampToBounds(this._normalizeCanonical(t));this._value=i,this._pending=i,this._draft=this._formatDisplay(i),this._inlineError="",this._syncValueAttribute(i),this._emitInput(e),this._emitChange(e),this._updateHostState()}_setOpen(t,e){this._isDisabled()||this._open!==t&&(this._open=t,this._syncOpenAttribute(t),this._syncOverlay(e),this._updateHostState(),this.dispatchEvent(new CustomEvent(t?"open":"close",{bubbles:!0,composed:!0})))}_syncOverlay(t){if(this._isInlineMode()){this._destroyOverlay();return}if(this._open){this._ensureOverlay(),this._syncOverlayState();return}this._destroyOverlay();const e=this._restoreFocusEl;if(this._restoreFocusEl=null,e&&e.isConnected)try{e.focus()}catch{}}_ensureOverlay(){if(this._overlay||typeof document>"u")return;const t=document.createElement("div");t.className="ui-time-picker-overlay-host",t.style.position="fixed",t.style.left="0",t.style.top="0",t.style.pointerEvents="none",t.addEventListener("click",this._onOverlayClickBound),t.addEventListener("change",this._onOverlayChangeBound),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=a.lockBodyScroll())}_syncOverlayHostZIndex(){if(!this._overlay||typeof window>"u")return;const t=window.getComputedStyle(this).getPropertyValue("--ui-dp-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.parentElement&&this._overlay.parentElement.removeChild(this._overlay),this._overlay=null,this._overlayKey=null,this._releaseScrollLock&&(this._releaseScrollLock(),this._releaseScrollLock=null))}_syncDismissableLayer(){var e;if((e=this._dismissableLayer)==null||e.destroy(),this._dismissableLayer=null,!this._open||!this._overlay)return;const t=this._overlay.querySelector(".panel, .sheet");t&&(this._dismissableLayer=x.createDismissableLayer({node:t,trigger:this._fieldEl,closeOnEscape:!0,closeOnPointerOutside:!0,closeOnFocusOutside:!1,onBeforeDismiss:i=>i==="escape-key"?(this._setOpen(!1,"escape"),!1):(i==="outside-pointer"&&this._setOpen(!1,"outside"),!1)}))}_positionOverlay(){if(!this._overlay||!this._open||this._isMobileSheet())return;const t=this._fieldEl,e=this._overlay.querySelector(".panel");if(!t||!e)return;const i=e.getAttribute("data-placement"),s=a.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)}_timeParts(t){const e=a.parseTimeInput(t||"00:00",!0)||{hours:0,minutes:0,seconds:0},i=e.hours>=12?"pm":"am";return{hours:e.hours,minutes:e.minutes,seconds:e.seconds,meridiem:i}}_buildOverlayContent(t){const e=this._translations(),i=this._timeParts(this._pending),s=this._is12h(),n=this._withSeconds(),r=s?i.hours%12||12:i.hours,o=this._minuteStep(),u=this._secondStep(),l=Array.from({length:s?12:24},(b,h)=>{const d=s?h+1:h;return`<option value="${d}" ${d===r?"selected":""}>${p(d)}</option>`}).join(""),c=Array.from({length:Math.ceil(60/o)},(b,h)=>{const d=Math.min(59,h*o);return`<option value="${d}" ${d===i.minutes?"selected":""}>${p(d)}</option>`}).join(""),v=Array.from({length:Math.ceil(60/u)},(b,h)=>{const d=Math.min(59,h*u);return`<option value="${d}" ${d===i.seconds?"selected":""}>${p(d)}</option>`}).join(""),y=`
|
|
249
257
|
<div class="pickers" data-seconds="${n?"true":"false"}" data-ampm="${s?"true":"false"}">
|
|
250
258
|
<div class="picker"><label>${e.hour}</label><select data-segment="hours">${l}</select></div>
|
|
251
259
|
<div class="picker"><label>${e.minute}</label><select data-segment="minutes">${c}</select></div>
|
|
252
|
-
${n?`<div class="picker"><label>${e.second}</label><select data-segment="seconds">${
|
|
260
|
+
${n?`<div class="picker"><label>${e.second}</label><select data-segment="seconds">${v}</select></div>`:""}
|
|
253
261
|
${s?`<div class="picker"><label>${e.meridiem}</label><select data-segment="meridiem"><option value="am" ${i.meridiem==="am"?"selected":""}>${e.am}</option><option value="pm" ${i.meridiem==="pm"?"selected":""}>${e.pm}</option></select></div>`:""}
|
|
254
262
|
</div>
|
|
255
263
|
`;return`
|
|
@@ -281,4 +289,4 @@
|
|
|
281
289
|
<div class="error" part="error" role="alert"></div>
|
|
282
290
|
<input class="hidden-input" type="hidden" disabled />
|
|
283
291
|
</div>
|
|
284
|
-
`,{force:!0}),this._cacheDomRefs(),this._hasView=!0),this._updateHostState()}shouldRenderOnAttributeChange(t,e,i){return!1}}typeof customElements<"u"&&!customElements.get("ui-time-picker")&&customElements.define("ui-time-picker",
|
|
292
|
+
`,{force:!0}),this._cacheDomRefs(),this._hasView=!0),this._updateHostState()}shouldRenderOnAttributeChange(t,e,i){return!1}}typeof customElements<"u"&&!customElements.get("ui-time-picker")&&customElements.define("ui-time-picker",f);exports.UITimePicker=f;
|
package/dist/time-picker.esm.js
CHANGED
|
@@ -146,6 +146,14 @@ const A = `
|
|
|
146
146
|
}
|
|
147
147
|
}
|
|
148
148
|
`, z = `
|
|
149
|
+
.ui-time-picker-overlay-host {
|
|
150
|
+
--ui-dp-bg: color-mix(in srgb, var(--ui-color-surface, #ffffff) 96%, transparent);
|
|
151
|
+
--ui-dp-border: color-mix(in srgb, var(--ui-color-border, #cbd5e1) 72%, transparent);
|
|
152
|
+
--ui-dp-text: var(--ui-color-text, #0f172a);
|
|
153
|
+
--ui-dp-muted: var(--ui-color-muted, #64748b);
|
|
154
|
+
--ui-dp-accent: var(--ui-color-primary, #2563eb);
|
|
155
|
+
--ui-dp-radius: 12px;
|
|
156
|
+
}
|
|
149
157
|
.overlay { position: fixed; z-index: var(--ui-dp-z, 1600); pointer-events: none; }
|
|
150
158
|
.panel {
|
|
151
159
|
pointer-events: auto;
|
|
@@ -428,7 +436,7 @@ class L extends x {
|
|
|
428
436
|
if (this._overlay || typeof document > "u")
|
|
429
437
|
return;
|
|
430
438
|
const t = document.createElement("div");
|
|
431
|
-
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), 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 = O());
|
|
439
|
+
t.className = "ui-time-picker-overlay-host", t.style.position = "fixed", t.style.left = "0", t.style.top = "0", t.style.pointerEvents = "none", t.addEventListener("click", this._onOverlayClickBound), t.addEventListener("change", this._onOverlayChangeBound), 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 = O());
|
|
432
440
|
}
|
|
433
441
|
_syncOverlayHostZIndex() {
|
|
434
442
|
if (!this._overlay || typeof window > "u")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@editora/ui-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.19",
|
|
4
4
|
"description": "Framework-agnostic Web Components and primitives for the Editora UI ecosystem",
|
|
5
5
|
"main": "dist/index.cjs.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@editora/icons": "^0.1.
|
|
57
|
+
"@editora/icons": "^0.1.10"
|
|
58
58
|
},
|
|
59
59
|
"keywords": [
|
|
60
60
|
"editora",
|