Comparing version 0.4.2 to 0.4.3
@@ -32,9 +32,9 @@ class oe { | ||
} | ||
const Nt = (e) => new oe(e), tt = Symbol.for("atomico.hooks"); | ||
globalThis[tt] = globalThis[tt] || {}; | ||
let N = globalThis[tt]; | ||
const Nt = (e) => new oe(e), Q = Symbol.for("atomico.hooks"); | ||
globalThis[Q] = globalThis[Q] || {}; | ||
let N = globalThis[Q]; | ||
const re = Symbol.for("Atomico.suspense"), Pt = Symbol.for("Atomico.effect"), ie = Symbol.for("Atomico.layoutEffect"), Ot = Symbol.for("Atomico.insertionEffect"), O = (e, t, s) => { | ||
const { i: n, hooks: o } = N.c, r = o[n] = o[n] || {}; | ||
return r.value = e(r.value), r.effect = t, r.tag = s, N.c.i++, o[n].value; | ||
}, ae = (e) => O((t = Nt(e)) => t), U = () => O((e = Nt(N.c.host)) => e), Ft = () => N.c.update, ce = (e, t, s = 0) => { | ||
}, ae = (e) => O((t = Nt(e)) => t), U = () => O((e = Nt(N.c.host)) => e), kt = () => N.c.update, ce = (e, t, s = 0) => { | ||
let n = {}, o = !1; | ||
@@ -63,3 +63,3 @@ const r = () => o, i = (l, c) => { | ||
})), isSuspense: r }; | ||
}, F = Symbol.for; | ||
}, k = Symbol.for; | ||
function Mt(e, t) { | ||
@@ -76,4 +76,4 @@ const s = e.length; | ||
} | ||
const S = (e) => typeof e == "function", A = (e) => typeof e == "object", { isArray: ue } = Array, et = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {}); | ||
function kt(e, t) { | ||
const S = (e) => typeof e == "function", R = (e) => typeof e == "object", { isArray: ue } = Array, V = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {}); | ||
function At(e, t) { | ||
let s; | ||
@@ -96,4 +96,4 @@ const n = (o) => { | ||
} | ||
const At = (e, t, s) => (e.addEventListener(t, s), () => e.removeEventListener(t, s)); | ||
class Rt { | ||
const Rt = (e, t, s) => (e.addEventListener(t, s), () => e.removeEventListener(t, s)); | ||
class Ft { | ||
/** | ||
@@ -109,7 +109,7 @@ * | ||
} | ||
class It extends Rt { | ||
class It extends Ft { | ||
} | ||
class le extends Rt { | ||
class le extends Ft { | ||
} | ||
const L = "Custom", fe = null, de = { true: 1, "": 1, 1: 1 }; | ||
const Y = "Custom", fe = null, de = { true: 1, "": 1, 1: 1 }; | ||
function he(e, t, s, n, o) { | ||
@@ -122,3 +122,3 @@ const { | ||
attr: l = me(t) | ||
} = s?.name != L && A(s) && s != fe ? s : { type: s }, c = r?.name === L && r.map, h = u != null ? r == Function || !S(u) ? () => u : u : null; | ||
} = s?.name != Y && R(s) && s != fe ? s : { type: s }, c = r?.name === Y && r.map, h = u != null ? r == Function || !S(u) ? () => u : u : null; | ||
Object.defineProperty(e, t, { | ||
@@ -133,3 +133,3 @@ configurable: !0, | ||
h && r != Boolean && a == null && (a = h()); | ||
const { error: y, value: D } = (c ? pe : ge)( | ||
const { error: y, value: D } = (c ? be : ge)( | ||
r, | ||
@@ -144,3 +144,3 @@ a | ||
); | ||
d != D && (this._props[t] = D ?? void 0, this.update(), f && Ut(this, f), this.updated.then(() => { | ||
d != D && (this._props[t] = D ?? void 0, this.update(), f && xt(this, f), this.updated.then(() => { | ||
i && (this._ignoreAttr = l, ye(this, r, l, this[t]), this._ignoreAttr = null); | ||
@@ -157,9 +157,9 @@ })); | ||
} | ||
const Ut = (e, { type: t, base: s = CustomEvent, ...n }) => e.dispatchEvent(new s(t, n)), me = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), ye = (e, t, s, n) => n == null || t == Boolean && !n ? e.removeAttribute(s) : e.setAttribute( | ||
const xt = (e, { type: t, base: s = CustomEvent, ...n }) => e.dispatchEvent(new s(t, n)), me = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), ye = (e, t, s, n) => n == null || t == Boolean && !n ? e.removeAttribute(s) : e.setAttribute( | ||
s, | ||
t?.name === L && t?.serialize ? t?.serialize(n) : A(n) ? JSON.stringify(n) : t == Boolean ? "" : n | ||
), be = (e, t) => e == Boolean ? !!de[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == L ? t : ( | ||
t?.name === Y && t?.serialize ? t?.serialize(n) : R(n) ? JSON.stringify(n) : t == Boolean ? "" : n | ||
), pe = (e, t) => e == Boolean ? !!de[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == Y ? t : ( | ||
// TODO: If when defining reflect the prop can also be of type string? | ||
new e(t) | ||
), pe = ({ map: e }, t) => { | ||
), be = ({ map: e }, t) => { | ||
try { | ||
@@ -218,3 +218,3 @@ return { value: e(t), error: !1 }; | ||
let d, y = !0; | ||
const D = et(this); | ||
const D = V(this); | ||
this.update = () => (d || (d = !0, this.updated = (this.updated || this.mounted).then(() => { | ||
@@ -255,3 +255,3 @@ try { | ||
try { | ||
this[d] = be(y, a); | ||
this[d] = pe(y, a); | ||
} catch { | ||
@@ -283,3 +283,3 @@ throw new le( | ||
const n = []; | ||
kt(t, (o) => { | ||
At(t, (o) => { | ||
o && (o instanceof Element ? s.appendChild(o.cloneNode(!0)) : n.push(o)); | ||
@@ -289,3 +289,3 @@ }), n.length && (s.adoptedStyleSheets = n); | ||
} | ||
const xt = (e) => (t, s) => { | ||
const Ut = (e) => (t, s) => { | ||
O( | ||
@@ -303,3 +303,3 @@ /** | ||
); | ||
}, j = xt(Pt), Se = xt(Ot); | ||
}, j = Ut(Pt), Se = Ut(Ot); | ||
class _t extends Array { | ||
@@ -335,4 +335,4 @@ /** | ||
} | ||
const ct = (e) => { | ||
const t = Ft(); | ||
const it = (e) => { | ||
const t = kt(); | ||
return O( | ||
@@ -361,3 +361,3 @@ (s = new _t(e, (n, o, r) => { | ||
const s = U(); | ||
return s[e] || (s[e] = (n = t.detail) => Ut(s.current, { | ||
return s[e] || (s[e] = (n = t.detail) => xt(s.current, { | ||
type: e, | ||
@@ -367,7 +367,7 @@ ...t, | ||
})), s[e]; | ||
}, nt = F("atomico/options"); | ||
globalThis[nt] = globalThis[nt] || { | ||
}, tt = k("atomico/options"); | ||
globalThis[tt] = globalThis[tt] || { | ||
sheet: !!document.adoptedStyleSheets | ||
}; | ||
const Yt = globalThis[nt], ve = { | ||
const Yt = globalThis[tt], ve = { | ||
checked: 1, | ||
@@ -392,6 +392,6 @@ value: 1, | ||
key: 1 | ||
}, _ = {}, st = []; | ||
class ot extends Text { | ||
}, L = {}, et = []; | ||
class nt extends Text { | ||
} | ||
const Ne = F("atomico/id"), R = F("atomico/type"), X = F("atomico/ref"), $t = F("atomico/vnode"), Pe = () => { | ||
const Ne = k("atomico/id"), F = k("atomico/type"), J = k("atomico/ref"), $t = k("atomico/vnode"), Pe = () => { | ||
}; | ||
@@ -402,5 +402,5 @@ function Oe(e, t, s) { | ||
const jt = (e, t, ...s) => { | ||
const n = t || _; | ||
const n = t || L; | ||
let { children: o } = n; | ||
if (o = o ?? (s.length ? s : st), e === Pe) | ||
if (o = o ?? (s.length ? s : et), e === Pe) | ||
return o; | ||
@@ -413,7 +413,7 @@ const r = e ? e instanceof Node ? 1 : ( | ||
return e( | ||
o != st ? { children: o, ...n } : n | ||
o != et ? { children: o, ...n } : n | ||
); | ||
const i = Yt.render || Oe; | ||
return { | ||
[R]: $t, | ||
[F]: $t, | ||
type: e, | ||
@@ -439,5 +439,5 @@ props: n, | ||
let r; | ||
if (t && t[s] && t[s].vnode == e || e[R] != $t) | ||
if (t && t[s] && t[s].vnode == e || e[F] != $t) | ||
return t; | ||
(e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[X] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[X] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (n = !0, t = e.type.cloneNode(!0), t[X] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS( | ||
(e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[J] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[J] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (n = !0, t = e.type.cloneNode(!0), t[J] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS( | ||
"http://www.w3.org/2000/svg", | ||
@@ -449,9 +449,9 @@ e.type | ||
))); | ||
const i = t[s] ? t[s] : _, { vnode: f = _, cycle: u = 0 } = i; | ||
const i = t[s] ? t[s] : L, { vnode: f = L, cycle: u = 0 } = i; | ||
let { fragment: l, handlers: c } = i; | ||
const { children: h = st, props: a = _ } = f; | ||
const { children: h = et, props: a = L } = f; | ||
if (c = r ? {} : c || {}, e.static && !r) | ||
return t; | ||
if (e.shadow && !t.shadowRoot && // @ts-ignore | ||
t.attachShadow({ mode: "open", ...e.shadow }), e.props != a && ke(t, a, e.props, c, o), e.children !== h) { | ||
t.attachShadow({ mode: "open", ...e.shadow }), e.props != a && Ae(t, a, e.props, c, o), e.children !== h) { | ||
const d = e.shadow ? t.shadowRoot : t; | ||
@@ -473,4 +473,4 @@ l = Me( | ||
} | ||
function Fe(e, t) { | ||
const s = new ot(""), n = new ot(""); | ||
function ke(e, t) { | ||
const s = new nt(""), n = new nt(""); | ||
let o; | ||
@@ -481,3 +481,3 @@ if (e[t ? "prepend" : "append"](s), t) { | ||
const { previousElementSibling: i } = r; | ||
if (et(r, !0) && !et(i, !0)) { | ||
if (V(r, !0) && !V(i, !0)) { | ||
o = r; | ||
@@ -496,18 +496,18 @@ break; | ||
e = e == null ? null : ue(e) ? e : [e]; | ||
const i = t || Fe(s, o), { markStart: f, markEnd: u, keyes: l } = i; | ||
const i = t || ke(s, o), { markStart: f, markEnd: u, keyes: l } = i; | ||
let c; | ||
const h = l && /* @__PURE__ */ new Set(); | ||
let a = f; | ||
if (e && kt(e, (d) => { | ||
if (typeof d == "object" && !d[R]) | ||
if (e && At(e, (d) => { | ||
if (typeof d == "object" && !d[F]) | ||
return; | ||
const y = d[R] && d.key, D = l && y != null && l.get(y); | ||
const y = d[F] && d.key, D = l && y != null && l.get(y); | ||
a != u && a === D ? h.delete(a) : a = a == u ? u : a.nextSibling; | ||
const m = l ? D : a; | ||
let w = m; | ||
if (d[R]) | ||
if (d[F]) | ||
w = qt(d, m, n, o, r); | ||
else { | ||
const M = d + ""; | ||
!(w instanceof Text) || w instanceof ot ? w = new Text(M) : w.data != M && (w.data = M); | ||
!(w instanceof Text) || w instanceof nt ? w = new Text(M) : w.data != M && (w.data = M); | ||
} | ||
@@ -522,12 +522,12 @@ w != a && (l && h.delete(w), !m || l ? (s.insertBefore(w, a), l && a != u && h.add(a)) : m == u ? s.insertBefore(w, u) : (s.replaceChild(w, m), a = w)), y != null && (c = c || /* @__PURE__ */ new Map(), c.set(y, w)); | ||
} | ||
function ke(e, t, s, n, o) { | ||
function Ae(e, t, s, n, o) { | ||
for (const r in t) | ||
!(r in s) && bt(e, r, t[r], null, o, n); | ||
!(r in s) && pt(e, r, t[r], null, o, n); | ||
for (const r in s) | ||
bt(e, r, t[r], s[r], o, n); | ||
pt(e, r, t[r], s[r], o, n); | ||
} | ||
function bt(e, t, s, n, o, r) { | ||
function pt(e, t, s, n, o, r) { | ||
if (t = t == "class" && !o ? "className" : t, s = s ?? null, n = n ?? null, t in e && ve[t] && (s = e[t]), !(n === s || Ce[t] || t[0] == "_")) | ||
if (t[0] == "o" && t[1] == "n" && (S(n) || S(s))) | ||
Ae(e, t.slice(2), n, r); | ||
Re(e, t.slice(2), n, r); | ||
else if (t == "ref") | ||
@@ -538,7 +538,7 @@ n && (S(n) ? n(e) : n.current = e); | ||
s = s || "", n = n || ""; | ||
const f = A(s), u = A(n); | ||
const f = R(s), u = R(n); | ||
if (f) | ||
for (const l in s) | ||
if (u) | ||
!(l in n) && pt(i, l, null); | ||
!(l in n) && bt(i, l, null); | ||
else | ||
@@ -549,3 +549,3 @@ break; | ||
const c = n[l]; | ||
f && s[l] === c || pt(i, l, c); | ||
f && s[l] === c || bt(i, l, c); | ||
} | ||
@@ -558,7 +558,7 @@ else | ||
i, | ||
A(n) ? JSON.stringify(n) : n | ||
R(n) ? JSON.stringify(n) : n | ||
); | ||
} | ||
} | ||
function Ae(e, t, s, n) { | ||
function Re(e, t, s, n) { | ||
if (n.handleEvent || (n.handleEvent = (o) => n[o.type].call(e, o)), s) { | ||
@@ -573,3 +573,3 @@ if (!n[t]) { | ||
} | ||
function pt(e, t, s) { | ||
function bt(e, t, s) { | ||
let n = "setProperty"; | ||
@@ -584,5 +584,5 @@ s == null && (n = "removeProperty", s = null), ~t.indexOf("-") ? e[n](t, s) : e[t] = s; | ||
); | ||
return gt[s] = gt[s] || Re(s); | ||
return gt[s] = gt[s] || Fe(s); | ||
} | ||
function Re(e) { | ||
function Fe(e) { | ||
if (Yt.sheet) { | ||
@@ -596,6 +596,6 @@ const t = new CSSStyleSheet(); | ||
} | ||
const Ie = jt("host", { style: "display: contents" }), G = F("atomico/context"), Ue = (e, t) => { | ||
const Ie = jt("host", { style: "display: contents" }), Z = k("atomico/context"), xe = (e, t) => { | ||
const s = U(); | ||
Se( | ||
() => At( | ||
() => Rt( | ||
s.current, | ||
@@ -612,3 +612,3 @@ "ConnectContext", | ||
); | ||
}, xe = (e) => { | ||
}, Ue = (e) => { | ||
const t = v("ConnectContext", { | ||
@@ -625,9 +625,9 @@ bubbles: !0, | ||
}), r; | ||
}, [n, o] = ct( | ||
}, [n, o] = it( | ||
s | ||
); | ||
return j(() => { | ||
n || (e[G] || (e[G] = customElements.whenDefined( | ||
n || (e[Z] || (e[Z] = customElements.whenDefined( | ||
new e().localName | ||
)), e[G].then( | ||
)), e[Z].then( | ||
() => o(s) | ||
@@ -637,10 +637,10 @@ )); | ||
}, _e = (e) => { | ||
const t = xe(e), s = Ft(); | ||
const t = Ue(e), s = kt(); | ||
return j(() => { | ||
if (t) | ||
return At(t, "UpdatedValue", s); | ||
return Rt(t, "UpdatedValue", s); | ||
}, [t]), (t || e).value; | ||
}, Le = (e) => { | ||
const t = $( | ||
() => (Ue(t, U().current), Ie), | ||
() => (xe(t, U().current), Ie), | ||
{ | ||
@@ -657,8 +657,7 @@ props: { | ||
return t.value = e, t; | ||
}, b = (e, t, s) => (t == null ? t = { key: s } : t.key = s, jt(e, t)), I = b, zt = q`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation}`, Bt = q`.vh{position:absolute;transform:scale(0)}`; | ||
function z() { | ||
const e = new Date(Date.now()); | ||
return new g(e.getUTCFullYear(), e.getUTCMonth() + 1, e.getUTCDate()); | ||
}, p = (e, t, s) => (t == null ? t = { key: s } : t.key = s, jt(e, t)), I = p, zt = q`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation}`, Bt = q`.vh{position:absolute;transform:scale(0)}`; | ||
function at() { | ||
return g.from(/* @__PURE__ */ new Date()); | ||
} | ||
function B(e, t = 0) { | ||
function ct(e, t = 0) { | ||
const s = e.toDate(), n = s.getUTCDay(), o = (n < t ? 7 : 0) + n - t; | ||
@@ -668,3 +667,3 @@ return s.setUTCDate(s.getUTCDate() - o), g.from(s); | ||
function Ht(e, t = 0) { | ||
return B(e, t).add({ days: 6 }); | ||
return ct(e, t).add({ days: 6 }); | ||
} | ||
@@ -678,7 +677,7 @@ function ut(e) { | ||
} | ||
function H(e, t, s) { | ||
function z(e, t, s) { | ||
return t && g.compare(e, t) < 0 ? t : s && g.compare(e, s) > 0 ? s : e; | ||
} | ||
function rt(e, t, s) { | ||
return H(e, t, s) === e; | ||
function st(e, t, s) { | ||
return z(e, t, s) === e; | ||
} | ||
@@ -698,13 +697,7 @@ function Ye(e, t) { | ||
function je(e, t = 0) { | ||
const s = B(e.toPlainDate(), t), n = Ht(ut(e), t); | ||
const s = ct(e.toPlainDate(), t), n = Ht(ut(e), t); | ||
return $e(Ye(s, n), 7); | ||
} | ||
function qe(e, t, s) { | ||
const n = [], o = { weekday: e }, r = B(z(), t).toDate(), i = new Intl.DateTimeFormat(s, o); | ||
for (let f = 0; f < 7; f++) | ||
n[f] = i.format(r), r.setDate(r.getDate() + 1); | ||
return n; | ||
} | ||
const ze = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, Kt = "years", Jt = "months", Zt = "days"; | ||
function Be(e) { | ||
const qe = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, Kt = "years", Jt = "months", Zt = "days"; | ||
function ze(e) { | ||
if (Kt in e) | ||
@@ -718,17 +711,17 @@ return { years: -e.years }; | ||
} | ||
function He(e, t) { | ||
function Be(e, t) { | ||
return g.from(new Date(Date.UTC(e.year, e.month - 1, t))); | ||
} | ||
function We(e, t) { | ||
function He(e, t) { | ||
const s = new g(t, e.month, 1), n = ut(s), o = e.toDate(); | ||
return o.setUTCFullYear(t), H(g.from(o), s, n); | ||
return o.setUTCFullYear(t), z(g.from(o), s, n); | ||
} | ||
function Ke(e, t) { | ||
function We(e, t) { | ||
const s = new g(e.year, t, 1), n = ut(s), o = e.toDate(); | ||
return o.setUTCMonth(t - 1), H(g.from(o), s, n); | ||
return o.setUTCMonth(t - 1), z(g.from(o), s, n); | ||
} | ||
function Dt(e, t) { | ||
return Zt in t ? He(e, e.day + t.days) : Jt in t ? Ke(e, e.month + t.months) : Kt in t ? We(e, e.year + t.years) : e; | ||
return Zt in t ? Be(e, e.day + t.days) : Jt in t ? We(e, e.month + t.months) : Kt in t ? He(e, e.year + t.years) : e; | ||
} | ||
const Q = (e, t) => e.toString().padStart(t, "0"); | ||
const X = (e, t) => e.toString().padStart(t, "0"); | ||
class g { | ||
@@ -742,6 +735,6 @@ constructor(t, s, n) { | ||
subtract(t) { | ||
return Dt(this, Be(t)); | ||
return Dt(this, ze(t)); | ||
} | ||
toString() { | ||
return `${Q(this.year, 4)}-${Q(this.month, 2)}-${Q(this.day, 2)}`; | ||
return `${X(this.year, 4)}-${X(this.month, 2)}-${X(this.day, 2)}`; | ||
} | ||
@@ -764,3 +757,3 @@ toDate() { | ||
static fromString(t) { | ||
const s = t.match(ze); | ||
const s = t.match(qe); | ||
if (!s) | ||
@@ -814,3 +807,3 @@ throw new TypeError(t); | ||
} | ||
function it(e, t) { | ||
function ot(e, t) { | ||
if (t) | ||
@@ -822,9 +815,9 @@ try { | ||
} | ||
function at(e) { | ||
function rt(e) { | ||
const [t, s] = Lt(e); | ||
return [P(() => it(g, t), [t]), (r) => s(r.toString())]; | ||
return [P(() => ot(g, t), [t]), (r) => s(r.toString())]; | ||
} | ||
function Je(e) { | ||
function Ke(e) { | ||
if (e) { | ||
const [t, s] = e.split("/"), n = it(g, t), o = it(g, s); | ||
const [t, s] = e.split("/"), n = ot(g, t), o = ot(g, s); | ||
if (n && o) | ||
@@ -835,10 +828,10 @@ return [n, o]; | ||
} | ||
function Ze(e, t) { | ||
function Je(e, t) { | ||
return `${e}/${t}`; | ||
} | ||
function Xe(e) { | ||
function Ze(e) { | ||
const [t, s] = Lt(e); | ||
return [P(() => Je(t), [t]), (r) => s(Ze(r[0], r[1]))]; | ||
return [P(() => Ke(t), [t]), (r) => s(Je(r[0], r[1]))]; | ||
} | ||
function Y(e, t) { | ||
function x(e, t) { | ||
return P( | ||
@@ -850,8 +843,13 @@ () => new Intl.DateTimeFormat(t, { timeZone: "UTC", ...e }), | ||
function St(e, t, s) { | ||
return P( | ||
() => qe(e, t, s), | ||
[e, t, s] | ||
); | ||
const n = x(e, s); | ||
return P(() => { | ||
const o = [], r = /* @__PURE__ */ new Date(); | ||
for (var i = 0; i < 7; i++) { | ||
const f = (r.getDay() - t + 7) % 7; | ||
o[f] = n.format(r), r.setDate(r.getDate() + 1); | ||
} | ||
return o; | ||
}, [t, n]); | ||
} | ||
function Ge(e) { | ||
function Xe(e) { | ||
let t = ""; | ||
@@ -862,5 +860,5 @@ for (const s in e) | ||
} | ||
const vt = (e) => e.target.matches(":dir(ltr)"), Qe = { month: "long", day: "numeric" }, Ve = { month: "long" }, V = { bubbles: !0 }; | ||
function tn({ props: e, context: t }) { | ||
const { offset: s } = e, { firstDayOfWeek: n, isDateDisallowed: o, min: r, max: i, dateWindow: f, locale: u } = t, l = z(), c = St("long", n, u), h = St("narrow", n, u), a = Y(Qe, u), d = Y(Ve, u), { focusedDate: y } = f, D = P( | ||
const vt = (e) => e.target.matches(":dir(ltr)"), Ge = { month: "long", day: "numeric" }, Qe = { month: "long" }, Ve = { weekday: "narrow" }, tn = { weekday: "long" }, G = { bubbles: !0 }; | ||
function en({ props: e, context: t }) { | ||
const { offset: s } = e, { firstDayOfWeek: n, isDateDisallowed: o, min: r, max: i, dateWindow: f, locale: u } = t, l = at(), c = St(tn, n, u), h = St(Ve, n, u), a = x(Ge, u), d = x(Qe, u), { focusedDate: y } = f, D = P( | ||
() => f.start.add({ months: s }), | ||
@@ -871,14 +869,14 @@ [f, s] | ||
[D, n] | ||
), w = v("focusday", V), M = v("selectday", V), te = v("hoverday", V); | ||
function ft(p) { | ||
w(H(p, r, i)); | ||
), w = v("focusday", G), M = v("selectday", G), te = v("hoverday", G); | ||
function ft(b) { | ||
w(z(b, r, i)); | ||
} | ||
function ee(p) { | ||
function ee(b) { | ||
let E; | ||
switch (p.key) { | ||
switch (b.key) { | ||
case "ArrowRight": | ||
E = y.add({ days: vt(p) ? 1 : -1 }); | ||
E = y.add({ days: vt(b) ? 1 : -1 }); | ||
break; | ||
case "ArrowLeft": | ||
E = y.add({ days: vt(p) ? -1 : 1 }); | ||
E = y.add({ days: vt(b) ? -1 : 1 }); | ||
break; | ||
@@ -892,9 +890,9 @@ case "ArrowDown": | ||
case "PageUp": | ||
E = y.add(p.shiftKey ? { years: -1 } : { months: -1 }); | ||
E = y.add(b.shiftKey ? { years: -1 } : { months: -1 }); | ||
break; | ||
case "PageDown": | ||
E = y.add(p.shiftKey ? { years: 1 } : { months: 1 }); | ||
E = y.add(b.shiftKey ? { years: 1 } : { months: 1 }); | ||
break; | ||
case "Home": | ||
E = B(y, n); | ||
E = ct(y, n); | ||
break; | ||
@@ -907,28 +905,28 @@ case "End": | ||
} | ||
ft(E), p.preventDefault(); | ||
ft(E), b.preventDefault(); | ||
} | ||
function ne(p) { | ||
const E = D.equals(p), se = p.equals(y), dt = p.equals(l), ht = p.toDate(), x = o?.(ht), mt = !rt(p, r, i); | ||
let k = !1, yt = !1, W = !1, K = !1; | ||
function ne(b) { | ||
const E = D.equals(b), se = b.equals(y), dt = b.equals(l), ht = b.toDate(), _ = o?.(ht), mt = !st(b, r, i); | ||
let A = !1, yt = !1, B = !1, H = !1; | ||
if ("highlightedRange" in t) { | ||
const [J, Z] = t.highlightedRange; | ||
yt = !0, W = J?.equals(p) ?? !1, K = Z?.equals(p) ?? !1, k = J && Z ? rt(p, J, Z) : !1; | ||
const [W, K] = t.highlightedRange; | ||
yt = !0, B = W?.equals(b) ?? !1, H = K?.equals(b) ?? !1, A = W && K ? st(b, W, K) : !1; | ||
} else | ||
"value" in t && (k = t.value?.equals(p) ?? !1); | ||
"value" in t && (A = t.value?.equals(b) ?? !1); | ||
return { | ||
part: Ge({ | ||
part: Xe({ | ||
button: !0, | ||
day: !0, | ||
selected: E && k, | ||
selected: E && A, | ||
today: dt, | ||
disallowed: x, | ||
disallowed: _, | ||
outside: !E, | ||
"range-start": W, | ||
"range-end": K, | ||
"range-inner": yt && k && !W && !K | ||
"range-start": B, | ||
"range-end": H, | ||
"range-inner": yt && A && !B && !H | ||
}), | ||
tabindex: E && se ? 0 : -1, | ||
disabled: mt, | ||
"aria-disabled": x ? "true" : void 0, | ||
"aria-pressed": E && k, | ||
"aria-disabled": _ ? "true" : void 0, | ||
"aria-pressed": E && A, | ||
"aria-current": dt ? "date" : void 0, | ||
@@ -938,6 +936,6 @@ "aria-label": a.format(ht), | ||
onclick() { | ||
x || M(p), ft(p); | ||
_ || M(b), ft(b); | ||
}, | ||
onmouseover() { | ||
!x && !mt && te(p); | ||
!_ && !mt && te(b); | ||
} | ||
@@ -989,3 +987,3 @@ }; | ||
} | ||
const Tt = z(), lt = Le({ | ||
const Tt = at(), lt = Le({ | ||
firstDayOfWeek: 0, | ||
@@ -996,5 +994,5 @@ isDateDisallowed: () => !1, | ||
customElements.define("calendar-month-ctx", lt); | ||
const en = $( | ||
const nn = $( | ||
(e) => { | ||
const t = _e(lt), s = ae(), n = tn({ props: e, context: t }); | ||
const t = _e(lt), s = ae(), n = en({ props: e, context: t }); | ||
function o() { | ||
@@ -1004,11 +1002,11 @@ s.current.querySelector("button[tabindex='0']")?.focus(); | ||
return /* @__PURE__ */ I("host", { shadowDom: !0, focus: o, children: [ | ||
/* @__PURE__ */ b("div", { id: "heading", part: "heading", children: n.monthFormatter.format(n.yearMonth.toDate()) }), | ||
/* @__PURE__ */ p("div", { id: "heading", part: "heading", children: n.monthFormatter.format(n.yearMonth.toDate()) }), | ||
/* @__PURE__ */ I("table", { ref: s, "aria-labelledby": "heading", part: "table", children: [ | ||
/* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { part: "tr head", children: n.dayNamesLong.map((r, i) => /* @__PURE__ */ I("th", { part: "th", scope: "col", children: [ | ||
/* @__PURE__ */ b("span", { class: "vh", children: r }), | ||
/* @__PURE__ */ b("span", { "aria-hidden": "true", children: n.dayNamesShort[i] }) | ||
/* @__PURE__ */ p("thead", { children: /* @__PURE__ */ p("tr", { part: "tr head", children: n.dayNamesLong.map((r, i) => /* @__PURE__ */ I("th", { part: "th", scope: "col", children: [ | ||
/* @__PURE__ */ p("span", { class: "vh", children: r }), | ||
/* @__PURE__ */ p("span", { "aria-hidden": "true", children: n.dayNamesShort[i] }) | ||
] })) }) }), | ||
/* @__PURE__ */ b("tbody", { children: n.weeks.map((r, i) => /* @__PURE__ */ b("tr", { part: "tr week", children: r.map((f, u) => { | ||
/* @__PURE__ */ p("tbody", { children: n.weeks.map((r, i) => /* @__PURE__ */ p("tr", { part: "tr week", children: r.map((f, u) => { | ||
const l = n.yearMonth.equals(f), c = t.showOutsideDays || l; | ||
return /* @__PURE__ */ b("td", { part: "td", children: c && /* @__PURE__ */ b("button", { ...n.getDayProps(f), children: f.day }) }, u); | ||
return /* @__PURE__ */ p("td", { part: "td", children: c && /* @__PURE__ */ p("button", { ...n.getDayProps(f), children: f.day }) }, u); | ||
}) }, i)) }) | ||
@@ -1032,9 +1030,9 @@ ] }) | ||
); | ||
customElements.define("calendar-month", en); | ||
customElements.define("calendar-month", nn); | ||
function Xt(e) { | ||
const t = e.dateWindow.start.toDate(), s = e.dateWindow.end.toDate(); | ||
return /* @__PURE__ */ I("div", { role: "group", "aria-labelledby": "label", part: "container", children: [ | ||
/* @__PURE__ */ b("div", { id: "label", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, s) }), | ||
/* @__PURE__ */ p("div", { id: "label", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, s) }), | ||
/* @__PURE__ */ I("div", { class: "header", part: "header", children: [ | ||
/* @__PURE__ */ b( | ||
/* @__PURE__ */ p( | ||
"button", | ||
@@ -1045,7 +1043,7 @@ { | ||
"aria-disabled": e.previous ? null : "true", | ||
children: /* @__PURE__ */ b("slot", { name: "previous", children: "Previous" }) | ||
children: /* @__PURE__ */ p("slot", { name: "previous", children: "Previous" }) | ||
} | ||
), | ||
/* @__PURE__ */ b("div", { id: "heading", part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, s) }), | ||
/* @__PURE__ */ b( | ||
/* @__PURE__ */ p("div", { id: "heading", part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, s) }), | ||
/* @__PURE__ */ p( | ||
"button", | ||
@@ -1056,7 +1054,7 @@ { | ||
"aria-disabled": e.next ? null : "true", | ||
children: /* @__PURE__ */ b("slot", { name: "next", children: "Next" }) | ||
children: /* @__PURE__ */ p("slot", { name: "next", children: "Next" }) | ||
} | ||
) | ||
] }), | ||
/* @__PURE__ */ b( | ||
/* @__PURE__ */ p( | ||
lt, | ||
@@ -1068,3 +1066,3 @@ { | ||
onhoverday: e.onHover, | ||
children: /* @__PURE__ */ b("slot", {}) | ||
children: /* @__PURE__ */ p("slot", {}) | ||
} | ||
@@ -1112,6 +1110,6 @@ ) | ||
q`:host{display:block;inline-size:fit-content}[role=group]{display:flex;flex-direction:column;gap:1em}.header{display:flex;align-items:center;justify-content:space-between}#heading{font-weight:700;font-size:1.25em}button{cursor:pointer;user-select:none;display:flex;align-items:center;justify-content:center}button[aria-disabled]{cursor:default;opacity:.4}` | ||
], nn = { year: "numeric" }, sn = { year: "numeric", month: "long" }; | ||
], sn = { year: "numeric" }, on = { year: "numeric", month: "long" }; | ||
function Vt({ months: e, locale: t }) { | ||
const [s] = at("min"), [n] = at("max"), o = v("focusday"), r = v("change"), [i, f] = ct(() => { | ||
const m = z(), w = e === 12 ? new C(m.year, 1) : m.toPlainYearMonth(); | ||
const [s] = rt("min"), [n] = rt("max"), o = v("focusday"), r = v("change"), [i, f] = it(() => { | ||
const m = at(), w = e === 12 ? new C(m.year, 1) : m.toPlainYearMonth(); | ||
return new T(w, { months: e }, m); | ||
@@ -1129,3 +1127,3 @@ }); | ||
} | ||
const a = Y(nn, t), d = Y(sn, t), y = n == null || !i.contains(n), D = s == null || !i.contains(s); | ||
const a = x(sn, t), d = x(on, t), y = n == null || !i.contains(n), D = s == null || !i.contains(s); | ||
return { | ||
@@ -1147,5 +1145,5 @@ format: a, | ||
} | ||
const on = $( | ||
const rn = $( | ||
(e) => { | ||
const [t, s] = at("value"), n = Vt(e); | ||
const [t, s] = rt("value"), n = Vt(e); | ||
j(() => { | ||
@@ -1157,3 +1155,3 @@ t && n.setFocusedDate(t); | ||
} | ||
return /* @__PURE__ */ b("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ b( | ||
return /* @__PURE__ */ p("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ p( | ||
Xt, | ||
@@ -1171,8 +1169,8 @@ { | ||
); | ||
customElements.define("calendar-date", on); | ||
const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], rn = $( | ||
customElements.define("calendar-date", rn); | ||
const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], an = $( | ||
(e) => { | ||
const [t, s] = Xe("value"), n = Vt(e), o = v("rangestart"), r = v("rangeend"), [i, f] = ct(); | ||
const [t, s] = Ze("value"), n = Vt(e), o = v("rangestart"), r = v("rangeend"), [i, f] = it(); | ||
j(() => { | ||
t.length && !rt(n.dateWindow.focusedDate, t[0], t[1]) && n.setFocusedDate(t[1]); | ||
t.length && !st(n.dateWindow.focusedDate, t[0], t[1]) && n.setFocusedDate(t[1]); | ||
}, [t]); | ||
@@ -1190,3 +1188,3 @@ async function u(a) { | ||
const h = i ? Ct(i.first, i.second) : t; | ||
return /* @__PURE__ */ b("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ b( | ||
return /* @__PURE__ */ p("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ p( | ||
Xt, | ||
@@ -1205,7 +1203,7 @@ { | ||
); | ||
customElements.define("calendar-range", rn); | ||
customElements.define("calendar-range", an); | ||
export { | ||
on as CalendarDate, | ||
en as CalendarMonth, | ||
rn as CalendarRange | ||
rn as CalendarDate, | ||
nn as CalendarMonth, | ||
an as CalendarRange | ||
}; |
{ | ||
"name": "cally", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"description": "small, feature-rich calendar components", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
51254
1651