cally 0.9.0 → 0.9.2
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/cally.d.ts +3 -466
- package/dist/cally.js +211 -204
- package/package.json +10 -20
package/dist/cally.js
CHANGED
|
@@ -32,10 +32,10 @@ class le {
|
|
|
32
32
|
const Rt = (e) => new le(e), st = Symbol.for("atomico.hooks");
|
|
33
33
|
globalThis[st] = globalThis[st] || {};
|
|
34
34
|
let A = globalThis[st];
|
|
35
|
-
const ue = Symbol.for("Atomico.suspense"), Yt = Symbol.for("Atomico.effect"), fe = Symbol.for("Atomico.layoutEffect"), Ft = Symbol.for("Atomico.insertionEffect"),
|
|
35
|
+
const ue = Symbol.for("Atomico.suspense"), Yt = Symbol.for("Atomico.effect"), fe = Symbol.for("Atomico.layoutEffect"), Ft = Symbol.for("Atomico.insertionEffect"), R = (e, t, n) => {
|
|
36
36
|
const { i: s, hooks: o } = A.c, r = o[s] = o[s] || {};
|
|
37
37
|
return r.value = e(r.value), r.effect = t, r.tag = n, A.c.i++, o[s].value;
|
|
38
|
-
}, It = (e) =>
|
|
38
|
+
}, It = (e) => R((t = Rt(e)) => t), W = () => R((e = Rt(A.c.host)) => e), Lt = () => A.c.update, de = (e, t, n = 0) => {
|
|
39
39
|
let s = {}, o = !1;
|
|
40
40
|
const r = () => o, a = (l, c) => {
|
|
41
41
|
for (const d in s) {
|
|
@@ -58,7 +58,7 @@ const ue = Symbol.for("Atomico.suspense"), Yt = Symbol.for("Atomico.effect"), fe
|
|
|
58
58
|
}, cleanEffects: (l) => (a(Ft, l), () => (a(fe, l), () => {
|
|
59
59
|
a(Yt, l);
|
|
60
60
|
})), isSuspense: r };
|
|
61
|
-
},
|
|
61
|
+
}, x = Symbol.for;
|
|
62
62
|
function xt(e, t) {
|
|
63
63
|
const n = e.length;
|
|
64
64
|
if (n !== t.length) return !1;
|
|
@@ -68,7 +68,7 @@ function xt(e, t) {
|
|
|
68
68
|
}
|
|
69
69
|
return !0;
|
|
70
70
|
}
|
|
71
|
-
const
|
|
71
|
+
const M = (e) => typeof e == "function", F = (e) => typeof e == "object", { isArray: he } = Array, ot = (e, t) => (t ? e instanceof HTMLStyleElement : !0) && "hydrate" in (e?.dataset || {});
|
|
72
72
|
function _t(e, t) {
|
|
73
73
|
let n;
|
|
74
74
|
const s = (o) => {
|
|
@@ -103,15 +103,15 @@ class qt extends Bt {
|
|
|
103
103
|
}
|
|
104
104
|
class me extends Bt {
|
|
105
105
|
}
|
|
106
|
-
const
|
|
107
|
-
function
|
|
106
|
+
const z = "Custom", ye = null, pe = { true: 1, "": 1, 1: 1 };
|
|
107
|
+
function ge(e, t, n, s, o) {
|
|
108
108
|
const {
|
|
109
109
|
type: r,
|
|
110
110
|
reflect: a,
|
|
111
111
|
event: u,
|
|
112
112
|
value: f,
|
|
113
|
-
attr: l =
|
|
114
|
-
} = n?.name !=
|
|
113
|
+
attr: l = be(t)
|
|
114
|
+
} = n?.name != z && F(n) && n != ye ? n : { type: n }, c = r?.name === z && r.map, d = f != null ? r == Function || !M(f) ? () => f : f : null;
|
|
115
115
|
Object.defineProperty(e, t, {
|
|
116
116
|
configurable: !0,
|
|
117
117
|
/**
|
|
@@ -121,17 +121,17 @@ function be(e, t, n, s, o) {
|
|
|
121
121
|
set(i) {
|
|
122
122
|
const m = this[t];
|
|
123
123
|
d && r != Boolean && i == null && (i = d());
|
|
124
|
-
const { error:
|
|
124
|
+
const { error: g, value: b } = (c ? Te : Ee)(
|
|
125
125
|
r,
|
|
126
126
|
i
|
|
127
127
|
);
|
|
128
|
-
if (
|
|
128
|
+
if (g && b != null)
|
|
129
129
|
throw new qt(
|
|
130
130
|
this,
|
|
131
131
|
`The value defined for prop '${t}' must be of type '${r.name}'`,
|
|
132
|
-
|
|
132
|
+
b
|
|
133
133
|
);
|
|
134
|
-
m !=
|
|
134
|
+
m != b && (this._props[t] = b ?? void 0, this.update(), u && zt(this, u), this.updated.then(() => {
|
|
135
135
|
a && (this._ignoreAttr = l, De(this, r, l, this[t]), this._ignoreAttr = null);
|
|
136
136
|
}));
|
|
137
137
|
},
|
|
@@ -143,19 +143,19 @@ function be(e, t, n, s, o) {
|
|
|
143
143
|
}
|
|
144
144
|
}), d && (o[t] = d()), s[l] = { prop: t, type: r };
|
|
145
145
|
}
|
|
146
|
-
const zt = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)),
|
|
146
|
+
const zt = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new n(t, s)), be = (e) => e.replace(/([A-Z])/g, "-$1").toLowerCase(), De = (e, t, n, s) => s == null || t == Boolean && !s ? e.removeAttribute(n) : e.setAttribute(
|
|
147
147
|
n,
|
|
148
|
-
t?.name ===
|
|
149
|
-
), Ce = (e, t) => e == Boolean ? !!pe[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name ==
|
|
148
|
+
t?.name === z && t?.serialize ? t?.serialize(s) : F(s) ? JSON.stringify(s) : t == Boolean ? "" : s
|
|
149
|
+
), Ce = (e, t) => e == Boolean ? !!pe[t] : e == Number ? Number(t) : e == String ? t : e == Array || e == Object ? JSON.parse(t) : e.name == z ? t : (
|
|
150
150
|
// TODO: If when defining reflect the prop can also be of type string?
|
|
151
151
|
new e(t)
|
|
152
|
-
),
|
|
152
|
+
), Te = ({ map: e }, t) => {
|
|
153
153
|
try {
|
|
154
154
|
return { value: e(t), error: !1 };
|
|
155
155
|
} catch {
|
|
156
156
|
return { value: t, error: !0 };
|
|
157
157
|
}
|
|
158
|
-
},
|
|
158
|
+
}, Ee = (e, t) => e == null || t == null ? { value: t, error: !1 } : e != String && t === "" ? { value: void 0, error: !1 } : e == Object || e == Array || e == Symbol ? {
|
|
159
159
|
value: t,
|
|
160
160
|
error: {}.toString.call(t) !== `[object ${e.name}]`
|
|
161
161
|
} : t instanceof e ? {
|
|
@@ -166,7 +166,7 @@ const zt = (e, { type: t, base: n = CustomEvent, ...s }) => e.dispatchEvent(new
|
|
|
166
166
|
error: e == Number ? typeof t != "number" ? !0 : Number.isNaN(t) : e == String ? typeof t != "string" : typeof t != "boolean"
|
|
167
167
|
} : { value: t, error: !0 };
|
|
168
168
|
let ve = 0;
|
|
169
|
-
const
|
|
169
|
+
const we = (e) => {
|
|
170
170
|
const t = (e?.dataset || {})?.hydrate || "";
|
|
171
171
|
return t || "c" + ve++;
|
|
172
172
|
}, k = (e, t = HTMLElement) => {
|
|
@@ -198,15 +198,15 @@ const Se = (e) => {
|
|
|
198
198
|
const i = de(
|
|
199
199
|
() => this.update(),
|
|
200
200
|
this,
|
|
201
|
-
|
|
201
|
+
we(this)
|
|
202
202
|
);
|
|
203
|
-
let m,
|
|
204
|
-
const
|
|
203
|
+
let m, g = !0;
|
|
204
|
+
const b = ot(this);
|
|
205
205
|
this.update = () => (m || (m = !0, this.updated = (this.updated || this.mounted).then(() => {
|
|
206
206
|
try {
|
|
207
207
|
const y = i.load(this._render), p = i.cleanEffects();
|
|
208
208
|
return y && //@ts-ignore
|
|
209
|
-
y.render(this, this.symbolId,
|
|
209
|
+
y.render(this, this.symbolId, b), m = !1, g && !i.isSuspense() && (g = !1, !b && Se(this)), p();
|
|
210
210
|
} finally {
|
|
211
211
|
m = !1;
|
|
212
212
|
}
|
|
@@ -234,13 +234,13 @@ const Se = (e) => {
|
|
|
234
234
|
attributeChangedCallback(c, d, i) {
|
|
235
235
|
if (n[c]) {
|
|
236
236
|
if (c === this._ignoreAttr || d === i) return;
|
|
237
|
-
const { prop: m, type:
|
|
237
|
+
const { prop: m, type: g } = n[c];
|
|
238
238
|
try {
|
|
239
|
-
this[m] = Ce(
|
|
239
|
+
this[m] = Ce(g, i);
|
|
240
240
|
} catch {
|
|
241
241
|
throw new me(
|
|
242
242
|
this,
|
|
243
|
-
`The value defined as attr '${c}' cannot be parsed by type '${
|
|
243
|
+
`The value defined as attr '${c}' cannot be parsed by type '${g.name}'`,
|
|
244
244
|
i
|
|
245
245
|
);
|
|
246
246
|
}
|
|
@@ -253,13 +253,13 @@ const Se = (e) => {
|
|
|
253
253
|
static get observedAttributes() {
|
|
254
254
|
const c = super.observedAttributes || [];
|
|
255
255
|
for (const d in a)
|
|
256
|
-
|
|
256
|
+
ge(this.prototype, d, a[d], n, s);
|
|
257
257
|
return Object.keys(n).concat(c);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
260
|
return f;
|
|
261
261
|
};
|
|
262
|
-
function
|
|
262
|
+
function Se(e) {
|
|
263
263
|
const { styles: t } = e.constructor, { shadowRoot: n } = e;
|
|
264
264
|
if (n && t.length) {
|
|
265
265
|
const s = [];
|
|
@@ -269,19 +269,19 @@ function Te(e) {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
const Ht = (e) => (t, n) => {
|
|
272
|
-
|
|
272
|
+
R(
|
|
273
273
|
/**
|
|
274
274
|
* Clean the effect hook
|
|
275
275
|
* @type {import("internal/hooks.js").CollectorEffect}
|
|
276
276
|
*/
|
|
277
|
-
([s, o] = []) => ((o || !o) && (o && xt(o, n) ? s = s || !0 : (
|
|
277
|
+
([s, o] = []) => ((o || !o) && (o && xt(o, n) ? s = s || !0 : (M(s) && s(), s = null)), [s, n]),
|
|
278
278
|
/**
|
|
279
279
|
* @returns {any}
|
|
280
280
|
*/
|
|
281
|
-
([s, o], r) => r ? (
|
|
281
|
+
([s, o], r) => r ? (M(s) && s(), []) : [s || t(), o],
|
|
282
282
|
e
|
|
283
283
|
);
|
|
284
|
-
},
|
|
284
|
+
}, L = Ht(Yt), Me = Ht(Ft);
|
|
285
285
|
class Wt extends Array {
|
|
286
286
|
/**
|
|
287
287
|
*
|
|
@@ -314,41 +314,41 @@ class Wt extends Array {
|
|
|
314
314
|
}
|
|
315
315
|
const it = (e) => {
|
|
316
316
|
const t = Lt();
|
|
317
|
-
return
|
|
317
|
+
return R(
|
|
318
318
|
(n = new Wt(e, (s, o, r) => {
|
|
319
|
-
s =
|
|
319
|
+
s = M(s) ? s(o[0]) : s, s !== o[0] && (o[0] = s, r || t());
|
|
320
320
|
})) => n
|
|
321
321
|
);
|
|
322
|
-
},
|
|
323
|
-
const [n] =
|
|
322
|
+
}, w = (e, t) => {
|
|
323
|
+
const [n] = R(([s, o, r = 0] = []) => ((!o || o && !xt(o, t)) && (s = e()), [s, t, r]));
|
|
324
324
|
return n;
|
|
325
325
|
}, lt = (e) => {
|
|
326
|
-
const { current: t } =
|
|
326
|
+
const { current: t } = W();
|
|
327
327
|
if (!(e in t))
|
|
328
328
|
throw new qt(
|
|
329
329
|
t,
|
|
330
330
|
`For useProp("${e}"), the prop does not exist on the host.`,
|
|
331
331
|
e
|
|
332
332
|
);
|
|
333
|
-
return
|
|
333
|
+
return R(
|
|
334
334
|
(n = new Wt(t[e], (s, o) => {
|
|
335
|
-
s =
|
|
335
|
+
s = M(s) ? s(t[e]) : s, t[e] = s;
|
|
336
336
|
})) => (n[0] = t[e], n)
|
|
337
337
|
);
|
|
338
|
-
},
|
|
339
|
-
const n =
|
|
338
|
+
}, N = (e, t = {}) => {
|
|
339
|
+
const n = W();
|
|
340
340
|
return n[e] || (n[e] = (s = t.detail) => zt(n.current, {
|
|
341
341
|
type: e,
|
|
342
342
|
...t,
|
|
343
343
|
detail: s
|
|
344
344
|
})), n[e];
|
|
345
|
-
}, rt =
|
|
345
|
+
}, rt = x("atomico/options");
|
|
346
346
|
globalThis[rt] = globalThis[rt] || {
|
|
347
347
|
sheet: !!document.adoptedStyleSheets
|
|
348
348
|
};
|
|
349
|
-
const
|
|
350
|
-
|
|
351
|
-
}),
|
|
349
|
+
const K = globalThis[rt], Ne = new Promise((e) => {
|
|
350
|
+
K.ssr || (document.readyState === "loading" ? jt(document, "DOMContentLoaded", e) : e());
|
|
351
|
+
}), Pe = {
|
|
352
352
|
checked: 1,
|
|
353
353
|
value: 1,
|
|
354
354
|
selected: 1
|
|
@@ -368,16 +368,16 @@ const W = globalThis[rt], Me = new Promise((e) => {
|
|
|
368
368
|
cloneNode: 1,
|
|
369
369
|
children: 1,
|
|
370
370
|
key: 1
|
|
371
|
-
},
|
|
371
|
+
}, q = {}, at = [];
|
|
372
372
|
class ct extends Text {
|
|
373
373
|
}
|
|
374
|
-
const Ae =
|
|
374
|
+
const Ae = x("atomico/id"), I = x("atomico/type"), Q = x("atomico/ref"), Kt = x("atomico/vnode"), Jt = () => {
|
|
375
375
|
};
|
|
376
|
-
function
|
|
376
|
+
function Ue(e, t, n) {
|
|
377
377
|
return Xt(this, e, t, n);
|
|
378
378
|
}
|
|
379
379
|
const Zt = (e, t, ...n) => {
|
|
380
|
-
const s = t ||
|
|
380
|
+
const s = t || q;
|
|
381
381
|
let { children: o } = s;
|
|
382
382
|
if (o = o ?? (n.length ? n : at), e === Jt)
|
|
383
383
|
return o;
|
|
@@ -389,9 +389,9 @@ const Zt = (e, t, ...n) => {
|
|
|
389
389
|
return e(
|
|
390
390
|
o != at ? { children: o, ...s } : s
|
|
391
391
|
);
|
|
392
|
-
const a =
|
|
392
|
+
const a = K.render || Ue;
|
|
393
393
|
return {
|
|
394
|
-
[
|
|
394
|
+
[I]: Kt,
|
|
395
395
|
type: e,
|
|
396
396
|
props: s,
|
|
397
397
|
children: o,
|
|
@@ -412,7 +412,7 @@ const Zt = (e, t, ...n) => {
|
|
|
412
412
|
};
|
|
413
413
|
function Xt(e, t, n = Ae, s, o) {
|
|
414
414
|
let r;
|
|
415
|
-
if (t && t[n] && t[n].vnode == e || e[
|
|
415
|
+
if (t && t[n] && t[n].vnode == e || e[I] != Kt)
|
|
416
416
|
return t;
|
|
417
417
|
(e || !t) && (o = o || e.type == "svg", r = e.type != "host" && (e.raw == 1 ? (t && e.clone ? t[Q] : t) != e.type : e.raw == 2 ? !(t instanceof e.type) : t ? t[Q] || t.localName != e.type : !t), r && e.type != null && (e.raw == 1 && e.clone ? (s = !0, t = e.type.cloneNode(!0), t[Q] = e.type) : t = e.raw == 1 ? e.type : e.raw == 2 ? new e.type() : o ? document.createElementNS(
|
|
418
418
|
"http://www.w3.org/2000/svg",
|
|
@@ -421,9 +421,9 @@ function Xt(e, t, n = Ae, s, o) {
|
|
|
421
421
|
e.type,
|
|
422
422
|
e.is ? { is: e.is } : void 0
|
|
423
423
|
)));
|
|
424
|
-
const a = t[n] ? t[n] :
|
|
424
|
+
const a = t[n] ? t[n] : q, { vnode: u = q, cycle: f = 0 } = a;
|
|
425
425
|
let { fragment: l, handlers: c } = a;
|
|
426
|
-
const { children: d = at, props: i =
|
|
426
|
+
const { children: d = at, props: i = q } = u;
|
|
427
427
|
if (c = r ? {} : c || {}, e.static && !r) return t;
|
|
428
428
|
if (e.shadow && !t.shadowRoot && // @ts-ignore
|
|
429
429
|
t.attachShadow({ mode: "open", ...e.shadow }), e.props != i && Ye(t, i, e.props, c, o), e.children !== d) {
|
|
@@ -443,7 +443,7 @@ function Xt(e, t, n = Ae, s, o) {
|
|
|
443
443
|
}
|
|
444
444
|
return t[n] = { vnode: e, handlers: c, fragment: l, cycle: f + 1 }, t;
|
|
445
445
|
}
|
|
446
|
-
function
|
|
446
|
+
function $e(e, t) {
|
|
447
447
|
const n = new ct(""), s = new ct("");
|
|
448
448
|
let o;
|
|
449
449
|
if (e[t ? "prepend" : "append"](n), t) {
|
|
@@ -464,24 +464,24 @@ function Ue(e, t) {
|
|
|
464
464
|
}
|
|
465
465
|
function Re(e, t, n, s, o, r) {
|
|
466
466
|
e = e == null ? null : he(e) ? e : [e];
|
|
467
|
-
const a = t ||
|
|
467
|
+
const a = t || $e(n, o), { markStart: u, markEnd: f, keyes: l } = a;
|
|
468
468
|
let c;
|
|
469
469
|
const d = l && /* @__PURE__ */ new Set();
|
|
470
470
|
let i = u;
|
|
471
471
|
if (e && _t(e, (m) => {
|
|
472
|
-
if (typeof m == "object" && !m[
|
|
472
|
+
if (typeof m == "object" && !m[I])
|
|
473
473
|
return;
|
|
474
|
-
const
|
|
475
|
-
i != f && i ===
|
|
476
|
-
const y = l ?
|
|
474
|
+
const g = m[I] && m.key, b = l && g != null && l.get(g);
|
|
475
|
+
i != f && i === b ? d.delete(i) : i = i == f ? f : i.nextSibling;
|
|
476
|
+
const y = l ? b : i;
|
|
477
477
|
let p = y;
|
|
478
|
-
if (m[
|
|
478
|
+
if (m[I])
|
|
479
479
|
p = Xt(m, y, s, o, r);
|
|
480
480
|
else {
|
|
481
481
|
const v = m + "";
|
|
482
482
|
!(p instanceof Text) || p instanceof ct ? p = new Text(v) : p.data != v && (p.data = v);
|
|
483
483
|
}
|
|
484
|
-
p != i && (l && d.delete(p), !y || l ? (n.insertBefore(p, i), l && i != f && d.add(i)) : y == f ? n.insertBefore(p, f) : (n.replaceChild(p, y), i = p)),
|
|
484
|
+
p != i && (l && d.delete(p), !y || l ? (n.insertBefore(p, i), l && i != f && d.add(i)) : y == f ? n.insertBefore(p, f) : (n.replaceChild(p, y), i = p)), g != null && (c = c || /* @__PURE__ */ new Map(), c.set(g, p));
|
|
485
485
|
}), i = i == f ? f : i.nextSibling, t && i != f)
|
|
486
486
|
for (; i != f; ) {
|
|
487
487
|
const m = i;
|
|
@@ -491,40 +491,40 @@ function Re(e, t, n, s, o, r) {
|
|
|
491
491
|
}
|
|
492
492
|
function Ye(e, t, n, s, o) {
|
|
493
493
|
for (const r in t)
|
|
494
|
-
!(r in n) &&
|
|
494
|
+
!(r in n) && St(e, r, t[r], null, o, s);
|
|
495
495
|
for (const r in n)
|
|
496
|
-
|
|
496
|
+
St(e, r, t[r], n[r], o, s);
|
|
497
497
|
}
|
|
498
|
-
function
|
|
499
|
-
if (t = t == "class" && !o ? "className" : t, n = n ?? null, s = s ?? null, t in e &&
|
|
498
|
+
function St(e, t, n, s, o, r) {
|
|
499
|
+
if (t = t == "class" && !o ? "className" : t, n = n ?? null, s = s ?? null, t in e && Pe[t] && (n = e[t]), !(s === n || Oe[t] || t[0] == "_"))
|
|
500
500
|
if (e.localName === "slot" && t === "assignNode" && "assign" in e)
|
|
501
501
|
e.assign(s);
|
|
502
|
-
else if (t[0] == "o" && t[1] == "n" && (
|
|
502
|
+
else if (t[0] == "o" && t[1] == "n" && (M(s) || M(n)))
|
|
503
503
|
Fe(e, t.slice(2), s, r);
|
|
504
504
|
else if (t == "ref")
|
|
505
|
-
s && (
|
|
505
|
+
s && (M(s) ? s(e) : s.current = e);
|
|
506
506
|
else if (t == "style") {
|
|
507
507
|
const { style: a } = e;
|
|
508
508
|
n = n || "", s = s || "";
|
|
509
|
-
const u =
|
|
509
|
+
const u = F(n), f = F(s);
|
|
510
510
|
if (u)
|
|
511
511
|
for (const l in n)
|
|
512
512
|
if (f)
|
|
513
|
-
!(l in s) &&
|
|
513
|
+
!(l in s) && Mt(a, l, null);
|
|
514
514
|
else
|
|
515
515
|
break;
|
|
516
516
|
if (f)
|
|
517
517
|
for (const l in s) {
|
|
518
518
|
const c = s[l];
|
|
519
|
-
u && n[l] === c ||
|
|
519
|
+
u && n[l] === c || Mt(a, l, c);
|
|
520
520
|
}
|
|
521
521
|
else
|
|
522
522
|
a.cssText = s;
|
|
523
523
|
} else {
|
|
524
524
|
const a = t[0] == "$" ? t.slice(1) : t;
|
|
525
|
-
a === t && (!o && !ke[t] && t in e ||
|
|
525
|
+
a === t && (!o && !ke[t] && t in e || M(s) || M(n)) ? e[t] = s ?? "" : s == null ? e.removeAttribute(a) : e.setAttribute(
|
|
526
526
|
a,
|
|
527
|
-
|
|
527
|
+
F(s) ? JSON.stringify(s) : s
|
|
528
528
|
);
|
|
529
529
|
}
|
|
530
530
|
}
|
|
@@ -538,13 +538,13 @@ function Fe(e, t, n, s) {
|
|
|
538
538
|
} else
|
|
539
539
|
s[t] && (e.removeEventListener(t, s), delete s[t]);
|
|
540
540
|
}
|
|
541
|
-
function
|
|
541
|
+
function Mt(e, t, n) {
|
|
542
542
|
let s = "setProperty";
|
|
543
543
|
n == null && (s = "removeProperty", n = null), ~t.indexOf("-") ? e[s](t, n) : e[t] = n;
|
|
544
544
|
}
|
|
545
545
|
const Ie = Zt("host", { style: "display: contents" }), Gt = "value", Le = (e, t) => {
|
|
546
|
-
const n =
|
|
547
|
-
|
|
546
|
+
const n = W(), s = It();
|
|
547
|
+
Me(
|
|
548
548
|
() => jt(
|
|
549
549
|
n.current,
|
|
550
550
|
"ConnectContext",
|
|
@@ -558,11 +558,11 @@ const Ie = Zt("host", { style: "display: contents" }), Gt = "value", Le = (e, t)
|
|
|
558
558
|
[e]
|
|
559
559
|
), s.current = t;
|
|
560
560
|
}, ut = (e) => {
|
|
561
|
-
const t =
|
|
561
|
+
const t = N("ConnectContext", {
|
|
562
562
|
bubbles: !0,
|
|
563
563
|
composed: !0
|
|
564
564
|
}), [n, s] = it(() => {
|
|
565
|
-
if (
|
|
565
|
+
if (K.ssr) return;
|
|
566
566
|
let r;
|
|
567
567
|
return t({
|
|
568
568
|
id: e,
|
|
@@ -574,14 +574,14 @@ const Ie = Zt("host", { style: "display: contents" }), Gt = "value", Le = (e, t)
|
|
|
574
574
|
}
|
|
575
575
|
}), r;
|
|
576
576
|
}), o = Lt();
|
|
577
|
-
return
|
|
578
|
-
|
|
577
|
+
return L(() => {
|
|
578
|
+
Ne.then(
|
|
579
579
|
() => t({
|
|
580
580
|
id: e,
|
|
581
581
|
connect: s
|
|
582
582
|
})
|
|
583
583
|
);
|
|
584
|
-
}, [e]),
|
|
584
|
+
}, [e]), L(() => {
|
|
585
585
|
if (n)
|
|
586
586
|
return n.on(o);
|
|
587
587
|
}, [n]), n?.current || e[Gt];
|
|
@@ -608,16 +608,16 @@ Qt({
|
|
|
608
608
|
dispatch(e, t) {
|
|
609
609
|
}
|
|
610
610
|
});
|
|
611
|
-
const
|
|
612
|
-
function
|
|
611
|
+
const Nt = {};
|
|
612
|
+
function J(e, ...t) {
|
|
613
613
|
const n = (e.raw || e).reduce(
|
|
614
614
|
(s, o, r) => s + o + (t[r] || ""),
|
|
615
615
|
""
|
|
616
616
|
);
|
|
617
|
-
return
|
|
617
|
+
return Nt[n] = Nt[n] || xe(n);
|
|
618
618
|
}
|
|
619
619
|
function xe(e) {
|
|
620
|
-
if (
|
|
620
|
+
if (K.sheet) {
|
|
621
621
|
const t = new CSSStyleSheet();
|
|
622
622
|
return t.replaceSync(e), t;
|
|
623
623
|
} else {
|
|
@@ -625,22 +625,22 @@ function xe(e) {
|
|
|
625
625
|
return t.textContent = e, t;
|
|
626
626
|
}
|
|
627
627
|
}
|
|
628
|
-
const h = (e, t, n) => (t == null ? t = { key: n } : t.key = n, Zt(e, t)),
|
|
628
|
+
const h = (e, t, n) => (t == null ? t = { key: n } : t.key = n, Zt(e, t)), S = h, ft = J`*,*:before,*:after{box-sizing:border-box}button{padding:0;touch-action:manipulation;cursor:pointer;user-select:none}`, dt = J`.vh{position:absolute;transform:scale(0)}`;
|
|
629
629
|
function ht() {
|
|
630
630
|
const e = /* @__PURE__ */ new Date();
|
|
631
631
|
return new C(e.getFullYear(), e.getMonth() + 1, e.getDate());
|
|
632
632
|
}
|
|
633
633
|
const _e = 864e5;
|
|
634
634
|
function je(e) {
|
|
635
|
-
const t =
|
|
636
|
-
t.
|
|
637
|
-
const n = new Date(t.getUTCFullYear(), 0, 4);
|
|
635
|
+
const t = E(e);
|
|
636
|
+
t.setUTCDate(t.getUTCDate() + 3 - (t.getUTCDay() + 6) % 7);
|
|
637
|
+
const n = new Date(Date.UTC(t.getUTCFullYear(), 0, 4));
|
|
638
638
|
return 1 + Math.round(
|
|
639
639
|
((t.getTime() - n.getTime()) / _e - 3 + (n.getUTCDay() + 6) % 7) / 7
|
|
640
640
|
);
|
|
641
641
|
}
|
|
642
642
|
function mt(e, t = 0) {
|
|
643
|
-
const n =
|
|
643
|
+
const n = E(e), s = n.getUTCDay(), o = (s < t ? 7 : 0) + s - t;
|
|
644
644
|
return n.setUTCDate(n.getUTCDate() - o), C.from(n);
|
|
645
645
|
}
|
|
646
646
|
function Vt(e, t = 0) {
|
|
@@ -649,7 +649,7 @@ function Vt(e, t = 0) {
|
|
|
649
649
|
function te(e) {
|
|
650
650
|
return C.from(new Date(Date.UTC(e.year, e.month, 0)));
|
|
651
651
|
}
|
|
652
|
-
function
|
|
652
|
+
function Z(e, t, n) {
|
|
653
653
|
return t && C.compare(e, t) < 0 ? t : n && C.compare(e, n) > 0 ? n : e;
|
|
654
654
|
}
|
|
655
655
|
const Be = { days: 1 };
|
|
@@ -664,7 +664,7 @@ function qe(e, t = 0) {
|
|
|
664
664
|
}
|
|
665
665
|
return o;
|
|
666
666
|
}
|
|
667
|
-
function
|
|
667
|
+
function E(e) {
|
|
668
668
|
return new Date(Date.UTC(e.year, e.month - 1, e.day ?? 1));
|
|
669
669
|
}
|
|
670
670
|
const ze = /^(\d{4})-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[0-1])$/, V = (e, t) => e.toString().padStart(t, "0");
|
|
@@ -676,19 +676,19 @@ class C {
|
|
|
676
676
|
// i didn't want to get into more complex arithmetic since it get tricky fast
|
|
677
677
|
// this is enough to serve my needs and will still be a drop-in replacement when actual Temporal API lands
|
|
678
678
|
add(t) {
|
|
679
|
-
const n =
|
|
679
|
+
const n = E(this);
|
|
680
680
|
if ("days" in t)
|
|
681
681
|
return n.setUTCDate(this.day + t.days), C.from(n);
|
|
682
682
|
let { year: s, month: o } = this;
|
|
683
683
|
"months" in t ? (o = this.month + t.months, n.setUTCMonth(o - 1)) : (s = this.year + t.years, n.setUTCFullYear(s));
|
|
684
|
-
const r = C.from(
|
|
685
|
-
return
|
|
684
|
+
const r = C.from(E({ year: s, month: o, day: 1 }));
|
|
685
|
+
return Z(C.from(n), r, te(r));
|
|
686
686
|
}
|
|
687
687
|
toString() {
|
|
688
688
|
return `${V(this.year, 4)}-${V(this.month, 2)}-${V(this.day, 2)}`;
|
|
689
689
|
}
|
|
690
690
|
toPlainYearMonth() {
|
|
691
|
-
return new
|
|
691
|
+
return new U(this.year, this.month);
|
|
692
692
|
}
|
|
693
693
|
equals(t) {
|
|
694
694
|
return C.compare(this, t) === 0;
|
|
@@ -715,13 +715,13 @@ class C {
|
|
|
715
715
|
);
|
|
716
716
|
}
|
|
717
717
|
}
|
|
718
|
-
class
|
|
718
|
+
class U {
|
|
719
719
|
constructor(t, n) {
|
|
720
720
|
this.year = t, this.month = n;
|
|
721
721
|
}
|
|
722
722
|
add(t) {
|
|
723
|
-
const n =
|
|
724
|
-
return n.setUTCMonth(n.getUTCMonth() + s), new
|
|
723
|
+
const n = E(this), s = (t.months ?? 0) + (t.years ?? 0) * 12;
|
|
724
|
+
return n.setUTCMonth(n.getUTCMonth() + s), new U(n.getUTCFullYear(), n.getUTCMonth() + 1);
|
|
725
725
|
}
|
|
726
726
|
equals(t) {
|
|
727
727
|
return this.year === t.year && this.month === t.month;
|
|
@@ -729,45 +729,48 @@ class Z {
|
|
|
729
729
|
toPlainDate() {
|
|
730
730
|
return new C(this.year, this.month, 1);
|
|
731
731
|
}
|
|
732
|
+
static compare(t, n) {
|
|
733
|
+
return t.year < n.year ? -1 : t.year > n.year ? 1 : t.month < n.month ? -1 : t.month > n.month ? 1 : 0;
|
|
734
|
+
}
|
|
732
735
|
}
|
|
733
|
-
function
|
|
736
|
+
function H(e, t) {
|
|
734
737
|
if (t)
|
|
735
738
|
try {
|
|
736
739
|
return e.from(t);
|
|
737
740
|
} catch {
|
|
738
741
|
}
|
|
739
742
|
}
|
|
740
|
-
function
|
|
743
|
+
function P(e) {
|
|
741
744
|
const [t, n] = lt(e);
|
|
742
|
-
return [
|
|
745
|
+
return [w(() => H(C, t), [t]), (r) => n(r?.toString())];
|
|
743
746
|
}
|
|
744
747
|
function He(e) {
|
|
745
748
|
const [t = "", n] = lt(e);
|
|
746
|
-
return [
|
|
747
|
-
const [r, a] = t.split("/"), u =
|
|
749
|
+
return [w(() => {
|
|
750
|
+
const [r, a] = t.split("/"), u = H(C, r), f = H(C, a);
|
|
748
751
|
return u && f ? [u, f] : [];
|
|
749
752
|
}, [t]), (r) => n(`${r[0]}/${r[1]}`)];
|
|
750
753
|
}
|
|
751
754
|
function We(e) {
|
|
752
755
|
const [t = "", n] = lt(e);
|
|
753
|
-
return [
|
|
756
|
+
return [w(() => {
|
|
754
757
|
const r = [];
|
|
755
758
|
for (const a of t.trim().split(/\s+/)) {
|
|
756
|
-
const u =
|
|
759
|
+
const u = H(C, a);
|
|
757
760
|
u && r.push(u);
|
|
758
761
|
}
|
|
759
762
|
return r;
|
|
760
763
|
}, [t]), (r) => n(r.join(" "))];
|
|
761
764
|
}
|
|
762
765
|
function $(e, t) {
|
|
763
|
-
return
|
|
766
|
+
return w(
|
|
764
767
|
() => new Intl.DateTimeFormat(t, { timeZone: "UTC", ...e }),
|
|
765
768
|
[t, e]
|
|
766
769
|
);
|
|
767
770
|
}
|
|
768
|
-
function
|
|
771
|
+
function Pt(e, t, n) {
|
|
769
772
|
const s = $(e, n);
|
|
770
|
-
return
|
|
773
|
+
return w(() => {
|
|
771
774
|
const o = [], r = /* @__PURE__ */ new Date();
|
|
772
775
|
for (var a = 0; a < 7; a++) {
|
|
773
776
|
const u = (r.getUTCDay() - t + 7) % 7;
|
|
@@ -776,7 +779,7 @@ function Nt(e, t, n) {
|
|
|
776
779
|
return o;
|
|
777
780
|
}, [t, s]);
|
|
778
781
|
}
|
|
779
|
-
const kt = (e, t, n) =>
|
|
782
|
+
const kt = (e, t, n) => Z(e, t, n) === e, Ot = (e) => e.target.matches(":dir(ltr)"), Ke = { month: "long", day: "numeric" }, Je = { month: "long" }, Ze = { weekday: "long" }, tt = { bubbles: !0 };
|
|
780
783
|
function Xe({ props: e, context: t }) {
|
|
781
784
|
const { offset: n } = e, {
|
|
782
785
|
firstDayOfWeek: s,
|
|
@@ -788,76 +791,76 @@ function Xe({ props: e, context: t }) {
|
|
|
788
791
|
locale: l,
|
|
789
792
|
focusedDate: c,
|
|
790
793
|
formatWeekday: d
|
|
791
|
-
} = t, i = u ?? ht(), m =
|
|
794
|
+
} = t, i = u ?? ht(), m = Pt(Ze, s, l), g = w(
|
|
792
795
|
() => ({ weekday: d }),
|
|
793
796
|
[d]
|
|
794
|
-
),
|
|
797
|
+
), b = Pt(g, s, l), y = $(Ke, l), p = $(Je, l), v = w(
|
|
795
798
|
() => f.start.add({ months: n }),
|
|
796
799
|
[f, n]
|
|
797
|
-
), X =
|
|
800
|
+
), X = w(
|
|
798
801
|
() => qe(v, s),
|
|
799
802
|
[v, s]
|
|
800
|
-
), se =
|
|
803
|
+
), se = N("focusday", tt), oe = N("selectday", tt), re = N("hoverday", tt);
|
|
801
804
|
function Dt(D) {
|
|
802
|
-
se(
|
|
805
|
+
se(Z(D, r, a));
|
|
803
806
|
}
|
|
804
807
|
function ae(D) {
|
|
805
|
-
let
|
|
808
|
+
let T;
|
|
806
809
|
switch (D.key) {
|
|
807
810
|
case "ArrowRight":
|
|
808
|
-
|
|
811
|
+
T = c.add({ days: Ot(D) ? 1 : -1 });
|
|
809
812
|
break;
|
|
810
813
|
case "ArrowLeft":
|
|
811
|
-
|
|
814
|
+
T = c.add({ days: Ot(D) ? -1 : 1 });
|
|
812
815
|
break;
|
|
813
816
|
case "ArrowDown":
|
|
814
|
-
|
|
817
|
+
T = c.add({ days: 7 });
|
|
815
818
|
break;
|
|
816
819
|
case "ArrowUp":
|
|
817
|
-
|
|
820
|
+
T = c.add({ days: -7 });
|
|
818
821
|
break;
|
|
819
822
|
case "PageUp":
|
|
820
|
-
|
|
823
|
+
T = c.add(D.shiftKey ? { years: -1 } : { months: -1 });
|
|
821
824
|
break;
|
|
822
825
|
case "PageDown":
|
|
823
|
-
|
|
826
|
+
T = c.add(D.shiftKey ? { years: 1 } : { months: 1 });
|
|
824
827
|
break;
|
|
825
828
|
case "Home":
|
|
826
|
-
|
|
829
|
+
T = mt(c, s);
|
|
827
830
|
break;
|
|
828
831
|
case "End":
|
|
829
|
-
|
|
832
|
+
T = Vt(c, s);
|
|
830
833
|
break;
|
|
831
834
|
default:
|
|
832
835
|
return;
|
|
833
836
|
}
|
|
834
|
-
Dt(
|
|
837
|
+
Dt(T), D.preventDefault();
|
|
835
838
|
}
|
|
836
839
|
function ce(D) {
|
|
837
|
-
const
|
|
838
|
-
if (!t.showOutsideDays && !
|
|
840
|
+
const T = v.equals(D);
|
|
841
|
+
if (!t.showOutsideDays && !T)
|
|
839
842
|
return;
|
|
840
|
-
const ie = D.equals(c), Ct = D.equals(i),
|
|
841
|
-
let
|
|
843
|
+
const ie = D.equals(c), Ct = D.equals(i), j = E(D), B = o?.(j), Tt = !kt(D, r, a);
|
|
844
|
+
let Et = "", O;
|
|
842
845
|
if (t.type === "range") {
|
|
843
|
-
const [
|
|
844
|
-
O =
|
|
845
|
-
} else t.type === "multi" ? O = t.value.some((
|
|
846
|
+
const [Y, G] = t.value, vt = Y?.equals(D), wt = G?.equals(D);
|
|
847
|
+
O = Y && G && kt(D, Y, G), Et = `${vt ? "range-start" : ""} ${wt ? "range-end" : ""} ${O && !vt && !wt ? "range-inner" : ""}`;
|
|
848
|
+
} else t.type === "multi" ? O = t.value.some((Y) => Y.equals(D)) : O = t.value?.equals(D);
|
|
846
849
|
return {
|
|
847
|
-
part: `${`button day day-${
|
|
848
|
-
|
|
849
|
-
tabindex:
|
|
850
|
-
disabled:
|
|
851
|
-
"aria-disabled":
|
|
852
|
-
"aria-pressed":
|
|
850
|
+
part: `${`button day day-${j.getUTCDay()} ${// we don't want outside days to ever be shown as selected
|
|
851
|
+
T ? O ? "selected" : "" : "outside"} ${B ? "disallowed" : ""} ${Ct ? "today" : ""} ${t.getDayParts?.(j) ?? ""}`} ${Et}`,
|
|
852
|
+
tabindex: T && ie ? 0 : -1,
|
|
853
|
+
disabled: Tt,
|
|
854
|
+
"aria-disabled": B ? "true" : void 0,
|
|
855
|
+
"aria-pressed": T && O,
|
|
853
856
|
"aria-current": Ct ? "date" : void 0,
|
|
854
|
-
"aria-label": y.format(
|
|
857
|
+
"aria-label": y.format(j),
|
|
855
858
|
onkeydown: ae,
|
|
856
859
|
onclick() {
|
|
857
|
-
|
|
860
|
+
B || oe(D), Dt(D);
|
|
858
861
|
},
|
|
859
862
|
onmouseover() {
|
|
860
|
-
!
|
|
863
|
+
!B && !Tt && re(D);
|
|
861
864
|
}
|
|
862
865
|
};
|
|
863
866
|
}
|
|
@@ -865,28 +868,28 @@ function Xe({ props: e, context: t }) {
|
|
|
865
868
|
weeks: X,
|
|
866
869
|
yearMonth: v,
|
|
867
870
|
daysLong: m,
|
|
868
|
-
daysVisible:
|
|
871
|
+
daysVisible: b,
|
|
869
872
|
formatter: p,
|
|
870
873
|
getDayProps: ce
|
|
871
874
|
};
|
|
872
875
|
}
|
|
873
|
-
const et = ht(),
|
|
876
|
+
const et = ht(), _ = Qt({
|
|
874
877
|
type: "date",
|
|
875
878
|
firstDayOfWeek: 1,
|
|
876
879
|
focusedDate: et,
|
|
877
880
|
page: { start: et.toPlainYearMonth(), end: et.toPlainYearMonth() }
|
|
878
881
|
});
|
|
879
|
-
customElements.define("calendar-ctx",
|
|
882
|
+
customElements.define("calendar-ctx", _);
|
|
880
883
|
const Ge = (e, t) => (t + e) % 7, Qe = k(
|
|
881
884
|
(e) => {
|
|
882
|
-
const t = ut(
|
|
885
|
+
const t = ut(_), n = It(), s = Xe({ props: e, context: t });
|
|
883
886
|
function o() {
|
|
884
887
|
n.current.querySelector("button[tabindex='0']")?.focus();
|
|
885
888
|
}
|
|
886
|
-
return /* @__PURE__ */
|
|
887
|
-
/* @__PURE__ */ h("div", { id: "h", part: "heading", children: s.formatter.format(
|
|
888
|
-
/* @__PURE__ */
|
|
889
|
-
/* @__PURE__ */
|
|
889
|
+
return /* @__PURE__ */ S("host", { shadowDom: !0, focus: o, children: [
|
|
890
|
+
/* @__PURE__ */ h("div", { id: "h", part: "heading", children: s.formatter.format(E(s.yearMonth)) }),
|
|
891
|
+
/* @__PURE__ */ S("table", { ref: n, "aria-labelledby": "h", part: "table", children: [
|
|
892
|
+
/* @__PURE__ */ S("colgroup", { children: [
|
|
890
893
|
t.showWeekNumbers && /* @__PURE__ */ h("col", { part: "col-weeknumber" }),
|
|
891
894
|
/* @__PURE__ */ h("col", { part: "col-1" }),
|
|
892
895
|
/* @__PURE__ */ h("col", { part: "col-2" }),
|
|
@@ -896,9 +899,12 @@ const Ge = (e, t) => (t + e) % 7, Qe = k(
|
|
|
896
899
|
/* @__PURE__ */ h("col", { part: "col-6" }),
|
|
897
900
|
/* @__PURE__ */ h("col", { part: "col-7" })
|
|
898
901
|
] }),
|
|
899
|
-
/* @__PURE__ */ h("thead", { children: /* @__PURE__ */
|
|
900
|
-
t.showWeekNumbers && /* @__PURE__ */ h("th", { part: "th weeknumber", children: /* @__PURE__ */
|
|
901
|
-
|
|
902
|
+
/* @__PURE__ */ h("thead", { children: /* @__PURE__ */ S("tr", { part: "tr head", children: [
|
|
903
|
+
t.showWeekNumbers && /* @__PURE__ */ h("th", { part: "th weeknumber", children: /* @__PURE__ */ S("slot", { name: "weeknumber", children: [
|
|
904
|
+
/* @__PURE__ */ h("span", { class: "vh", children: "Week" }),
|
|
905
|
+
/* @__PURE__ */ h("span", { "aria-hidden": "true", children: "#" })
|
|
906
|
+
] }) }),
|
|
907
|
+
s.daysLong.map((r, a) => /* @__PURE__ */ S(
|
|
902
908
|
"th",
|
|
903
909
|
{
|
|
904
910
|
part: `th day day-${Ge(t.firstDayOfWeek, a)}`,
|
|
@@ -910,7 +916,7 @@ const Ge = (e, t) => (t + e) % 7, Qe = k(
|
|
|
910
916
|
}
|
|
911
917
|
))
|
|
912
918
|
] }) }),
|
|
913
|
-
/* @__PURE__ */ h("tbody", { children: s.weeks.map((r, a) => /* @__PURE__ */
|
|
919
|
+
/* @__PURE__ */ h("tbody", { children: s.weeks.map((r, a) => /* @__PURE__ */ S("tr", { part: "tr week", children: [
|
|
914
920
|
t.showWeekNumbers && /* @__PURE__ */ h("th", { class: "num", part: "th weeknumber", scope: "row", children: je(r[0]) }),
|
|
915
921
|
r.map((u, f) => {
|
|
916
922
|
const l = s.getDayProps(u);
|
|
@@ -930,7 +936,7 @@ const Ge = (e, t) => (t + e) % 7, Qe = k(
|
|
|
930
936
|
styles: [
|
|
931
937
|
ft,
|
|
932
938
|
dt,
|
|
933
|
-
|
|
939
|
+
J`:host{--color-accent: black;--color-text-on-accent: white;display:flex;flex-direction:column;gap:.25rem;text-align:center;inline-size:fit-content}table{border-collapse:collapse;font-size:.875rem}th{inline-size:2.25rem;block-size:2.25rem}td{padding-inline:0}.num{font-variant-numeric:tabular-nums}button{color:inherit;font-size:inherit;background:transparent;border:0;block-size:2.25rem;inline-size:2.25rem}button:hover:where(:not(:disabled,[aria-disabled])){background:#0000000d}button:is([aria-pressed=true],:focus-visible){background:var(--color-accent);color:var(--color-text-on-accent)}button:focus-visible{outline:1px solid var(--color-text-on-accent);outline-offset:-2px}button:disabled,:host::part(outside),:host::part(disallowed){cursor:default;opacity:.5}`
|
|
934
940
|
]
|
|
935
941
|
}
|
|
936
942
|
);
|
|
@@ -947,17 +953,17 @@ function At(e) {
|
|
|
947
953
|
);
|
|
948
954
|
}
|
|
949
955
|
function yt(e) {
|
|
950
|
-
const t =
|
|
956
|
+
const t = E(e.page.start), n = E(e.page.end);
|
|
951
957
|
return /* @__PURE__ */ h(
|
|
952
|
-
|
|
958
|
+
_,
|
|
953
959
|
{
|
|
954
960
|
value: e,
|
|
955
961
|
onselectday: e.onSelect,
|
|
956
962
|
onfocusday: e.onFocus,
|
|
957
963
|
onhoverday: e.onHover,
|
|
958
|
-
children: /* @__PURE__ */
|
|
964
|
+
children: /* @__PURE__ */ S("div", { role: "group", "aria-labelledby": "h", part: "container", children: [
|
|
959
965
|
/* @__PURE__ */ h("div", { id: "h", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, n) }),
|
|
960
|
-
/* @__PURE__ */
|
|
966
|
+
/* @__PURE__ */ S("div", { part: "header", children: [
|
|
961
967
|
/* @__PURE__ */ h(At, { name: "previous", onclick: e.previous, children: "Previous" }),
|
|
962
968
|
/* @__PURE__ */ h("slot", { part: "heading", name: "heading", children: /* @__PURE__ */ h("div", { "aria-hidden": "true", children: e.format.formatRange(t, n) }) }),
|
|
963
969
|
/* @__PURE__ */ h(At, { name: "next", onclick: e.next, children: "Next" })
|
|
@@ -1026,15 +1032,15 @@ const pt = {
|
|
|
1026
1032
|
type: Boolean,
|
|
1027
1033
|
value: !1
|
|
1028
1034
|
}
|
|
1029
|
-
},
|
|
1035
|
+
}, gt = [
|
|
1030
1036
|
ft,
|
|
1031
1037
|
dt,
|
|
1032
|
-
|
|
1038
|
+
J`:host{display:block;inline-size:fit-content}:host::part(container){display:flex;flex-direction:column;gap:1em}:host::part(header){display:flex;align-items:center;justify-content:space-between}:host::part(heading){font-weight:700;font-size:1.25em}:host::part(button){display:flex;align-items:center;justify-content:center}:host::part(button disabled){cursor:default;opacity:.5}`
|
|
1033
1039
|
], Ve = { year: "numeric" }, tn = { year: "numeric", month: "long" };
|
|
1034
1040
|
function nt(e, t) {
|
|
1035
1041
|
return (t.year - e.year) * 12 + t.month - e.month;
|
|
1036
1042
|
}
|
|
1037
|
-
const
|
|
1043
|
+
const Ut = (e, t) => (e = t === 12 ? new U(e.year, 1) : e, {
|
|
1038
1044
|
start: e,
|
|
1039
1045
|
end: e.add({ months: t - 1 })
|
|
1040
1046
|
});
|
|
@@ -1047,17 +1053,17 @@ function en({
|
|
|
1047
1053
|
goto: r
|
|
1048
1054
|
}) {
|
|
1049
1055
|
const a = e === "single" ? 1 : n, [u, f] = it(
|
|
1050
|
-
() =>
|
|
1051
|
-
), l = (d) => f(
|
|
1056
|
+
() => Ut(t.toPlainYearMonth(), n)
|
|
1057
|
+
), l = (d) => f(Ut(u.start.add({ months: d }), n)), c = (d) => {
|
|
1052
1058
|
const i = nt(u.start, d.toPlainYearMonth());
|
|
1053
1059
|
return i >= 0 && i < n;
|
|
1054
1060
|
};
|
|
1055
|
-
return
|
|
1061
|
+
return L(() => {
|
|
1056
1062
|
if (c(t))
|
|
1057
1063
|
return;
|
|
1058
1064
|
const d = nt(t.toPlainYearMonth(), u.start);
|
|
1059
1065
|
r(t.add({ months: d }));
|
|
1060
|
-
}, [u.start]),
|
|
1066
|
+
}, [u.start]), L(() => {
|
|
1061
1067
|
if (c(t))
|
|
1062
1068
|
return;
|
|
1063
1069
|
const d = nt(u.start, t.toPlainYearMonth());
|
|
@@ -1068,36 +1074,36 @@ function en({
|
|
|
1068
1074
|
next: !s || !c(s) ? () => l(a) : void 0
|
|
1069
1075
|
};
|
|
1070
1076
|
}
|
|
1071
|
-
function
|
|
1077
|
+
function bt({
|
|
1072
1078
|
months: e,
|
|
1073
1079
|
pageBy: t,
|
|
1074
1080
|
locale: n,
|
|
1075
1081
|
focusedDate: s,
|
|
1076
1082
|
setFocusedDate: o
|
|
1077
1083
|
}) {
|
|
1078
|
-
const [r] =
|
|
1079
|
-
() =>
|
|
1084
|
+
const [r] = P("min"), [a] = P("max"), [u] = P("today"), f = N("focusday"), l = N("change"), c = w(
|
|
1085
|
+
() => Z(s ?? u ?? ht(), r, a),
|
|
1080
1086
|
[s, u, r, a]
|
|
1081
1087
|
);
|
|
1082
1088
|
function d(p) {
|
|
1083
|
-
o(p), f(
|
|
1089
|
+
o(p), f(E(p));
|
|
1084
1090
|
}
|
|
1085
|
-
const { next: i, previous: m, page:
|
|
1091
|
+
const { next: i, previous: m, page: g } = en({
|
|
1086
1092
|
pageBy: t,
|
|
1087
1093
|
focusedDate: c,
|
|
1088
1094
|
months: e,
|
|
1089
1095
|
min: r,
|
|
1090
1096
|
max: a,
|
|
1091
1097
|
goto: d
|
|
1092
|
-
}),
|
|
1098
|
+
}), b = W();
|
|
1093
1099
|
function y(p) {
|
|
1094
1100
|
const v = p?.target ?? "day";
|
|
1095
|
-
v === "day" ?
|
|
1101
|
+
v === "day" ? b.current.querySelectorAll("calendar-month").forEach((X) => X.focus(p)) : b.current.shadowRoot.querySelector(`[part~='${v}']`).focus(p);
|
|
1096
1102
|
}
|
|
1097
1103
|
return {
|
|
1098
1104
|
format: $(Ve, n),
|
|
1099
1105
|
formatVerbose: $(tn, n),
|
|
1100
|
-
page:
|
|
1106
|
+
page: g,
|
|
1101
1107
|
focusedDate: c,
|
|
1102
1108
|
dispatch: l,
|
|
1103
1109
|
onFocus(p) {
|
|
@@ -1113,7 +1119,7 @@ function gt({
|
|
|
1113
1119
|
}
|
|
1114
1120
|
const nn = k(
|
|
1115
1121
|
(e) => {
|
|
1116
|
-
const [t, n] =
|
|
1122
|
+
const [t, n] = P("value"), [s = t, o] = P("focusedDate"), r = bt({
|
|
1117
1123
|
...e,
|
|
1118
1124
|
focusedDate: s,
|
|
1119
1125
|
setFocusedDate: o
|
|
@@ -1132,11 +1138,11 @@ const nn = k(
|
|
|
1132
1138
|
}
|
|
1133
1139
|
) });
|
|
1134
1140
|
},
|
|
1135
|
-
{ props: pt, styles:
|
|
1141
|
+
{ props: pt, styles: gt }
|
|
1136
1142
|
);
|
|
1137
1143
|
customElements.define("calendar-date", nn);
|
|
1138
1144
|
function ee(e) {
|
|
1139
|
-
return /* @__PURE__ */
|
|
1145
|
+
return /* @__PURE__ */ S(Jt, { children: [
|
|
1140
1146
|
/* @__PURE__ */ h("label", { part: "label", for: "s", children: /* @__PURE__ */ h("slot", { name: "label", children: e.label }) }),
|
|
1141
1147
|
/* @__PURE__ */ h("select", { id: "s", part: "select", onchange: e.onChange, children: e.options.map((t) => /* @__PURE__ */ h("option", { part: "option", ...t })) })
|
|
1142
1148
|
] });
|
|
@@ -1146,16 +1152,16 @@ function sn(e, t) {
|
|
|
1146
1152
|
return Array.from({ length: e }, (n, s) => t(s));
|
|
1147
1153
|
}
|
|
1148
1154
|
function on(e) {
|
|
1149
|
-
const { min: t, max: n, focusedDate: s } = ut(
|
|
1150
|
-
const
|
|
1155
|
+
const { min: t, max: n, focusedDate: s } = ut(_), o = N("focusday", { bubbles: !0 }), r = s.toPlainYearMonth(), a = r.year, u = Math.floor(e.maxYears / 2), f = a - u, l = a + (e.maxYears - u - 1), c = Math.max(f, t?.year ?? -1 / 0), d = Math.min(l, n?.year ?? 1 / 0), i = sn(d - c + 1, (g) => {
|
|
1156
|
+
const b = c + g;
|
|
1151
1157
|
return {
|
|
1152
|
-
label: `${
|
|
1153
|
-
value: `${
|
|
1154
|
-
selected:
|
|
1158
|
+
label: `${b}`,
|
|
1159
|
+
value: `${b}`,
|
|
1160
|
+
selected: b === r.year
|
|
1155
1161
|
};
|
|
1156
1162
|
});
|
|
1157
|
-
function m(
|
|
1158
|
-
const y = parseInt(
|
|
1163
|
+
function m(g) {
|
|
1164
|
+
const y = parseInt(g.currentTarget.value) - r.year;
|
|
1159
1165
|
o(s.add({ years: y }));
|
|
1160
1166
|
}
|
|
1161
1167
|
return { options: i, onChange: m };
|
|
@@ -1174,28 +1180,29 @@ const rn = k(
|
|
|
1174
1180
|
);
|
|
1175
1181
|
customElements.define("calendar-select-year", rn);
|
|
1176
1182
|
function an(e) {
|
|
1177
|
-
const { min: t, max: n, focusedDate: s, locale: o } = ut(
|
|
1183
|
+
const { min: t, max: n, focusedDate: s, locale: o } = ut(_), r = N("focusday", { bubbles: !0 }), a = w(
|
|
1178
1184
|
() => ({ month: e.formatMonth }),
|
|
1179
1185
|
[e.formatMonth]
|
|
1180
|
-
), u = $(a, o), f =
|
|
1186
|
+
), u = $(a, o), f = w(() => {
|
|
1181
1187
|
const i = [], m = /* @__PURE__ */ new Date();
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1188
|
+
m.setUTCDate(1);
|
|
1189
|
+
for (var g = 0; g < 12; g++) {
|
|
1190
|
+
const b = (m.getUTCMonth() + 12) % 12;
|
|
1191
|
+
i[b] = u.format(m), m.setUTCMonth(m.getUTCMonth() + 1);
|
|
1185
1192
|
}
|
|
1186
1193
|
return i;
|
|
1187
1194
|
}, [u]), l = s.toPlainYearMonth(), c = f.map((i, m) => {
|
|
1188
|
-
const
|
|
1195
|
+
const g = m + 1, b = l.add({ months: g - l.month }), y = t != null && U.compare(b, t) < 0 || n != null && U.compare(b, n) > 0;
|
|
1189
1196
|
return {
|
|
1190
1197
|
label: i,
|
|
1191
|
-
value: `${
|
|
1198
|
+
value: `${g}`,
|
|
1192
1199
|
disabled: y,
|
|
1193
|
-
selected:
|
|
1200
|
+
selected: g === l.month
|
|
1194
1201
|
};
|
|
1195
1202
|
});
|
|
1196
1203
|
function d(i) {
|
|
1197
|
-
const
|
|
1198
|
-
r(s.add({ months:
|
|
1204
|
+
const g = parseInt(i.currentTarget.value) - l.month;
|
|
1205
|
+
r(s.add({ months: g }));
|
|
1199
1206
|
}
|
|
1200
1207
|
return { options: c, onChange: d };
|
|
1201
1208
|
}
|
|
@@ -1215,37 +1222,37 @@ const cn = k(
|
|
|
1215
1222
|
}
|
|
1216
1223
|
);
|
|
1217
1224
|
customElements.define("calendar-select-month", cn);
|
|
1218
|
-
const
|
|
1225
|
+
const $t = (e, t) => C.compare(e, t) < 0 ? [e, t] : [t, e], ln = k(
|
|
1219
1226
|
(e) => {
|
|
1220
|
-
const [t, n] = He("value"), [s = t[0], o] =
|
|
1227
|
+
const [t, n] = He("value"), [s = t[0], o] = P("focusedDate"), r = bt({
|
|
1221
1228
|
...e,
|
|
1222
1229
|
focusedDate: s,
|
|
1223
1230
|
setFocusedDate: o
|
|
1224
|
-
}), a =
|
|
1231
|
+
}), a = N("rangestart"), u = N("rangeend"), [f, l] = P(
|
|
1225
1232
|
"tentative"
|
|
1226
1233
|
), [c, d] = it();
|
|
1227
|
-
|
|
1234
|
+
L(() => d(void 0), [f]);
|
|
1228
1235
|
function i(y) {
|
|
1229
1236
|
r.onFocus(y), m(y);
|
|
1230
1237
|
}
|
|
1231
1238
|
function m(y) {
|
|
1232
1239
|
y.stopPropagation(), f && d(y.detail);
|
|
1233
1240
|
}
|
|
1234
|
-
function
|
|
1241
|
+
function g(y) {
|
|
1235
1242
|
const p = y.detail;
|
|
1236
|
-
y.stopPropagation(), f ? (n(
|
|
1243
|
+
y.stopPropagation(), f ? (n($t(f, p)), l(void 0), u(E(p)), r.dispatch()) : (l(p), a(E(p)));
|
|
1237
1244
|
}
|
|
1238
|
-
const
|
|
1245
|
+
const b = f ? $t(f, c ?? f) : t;
|
|
1239
1246
|
return /* @__PURE__ */ h("host", { shadowDom: !0, focus: r.focus, children: /* @__PURE__ */ h(
|
|
1240
1247
|
yt,
|
|
1241
1248
|
{
|
|
1242
1249
|
...e,
|
|
1243
1250
|
...r,
|
|
1244
1251
|
type: "range",
|
|
1245
|
-
value:
|
|
1252
|
+
value: b,
|
|
1246
1253
|
onFocus: i,
|
|
1247
1254
|
onHover: m,
|
|
1248
|
-
onSelect:
|
|
1255
|
+
onSelect: g
|
|
1249
1256
|
}
|
|
1250
1257
|
) });
|
|
1251
1258
|
},
|
|
@@ -1257,13 +1264,13 @@ const Ut = (e, t) => C.compare(e, t) < 0 ? [e, t] : [t, e], ln = k(
|
|
|
1257
1264
|
value: ""
|
|
1258
1265
|
}
|
|
1259
1266
|
},
|
|
1260
|
-
styles:
|
|
1267
|
+
styles: gt
|
|
1261
1268
|
}
|
|
1262
1269
|
);
|
|
1263
1270
|
customElements.define("calendar-range", ln);
|
|
1264
1271
|
const un = k(
|
|
1265
1272
|
(e) => {
|
|
1266
|
-
const [t, n] = We("value"), [s = t[0], o] =
|
|
1273
|
+
const [t, n] = We("value"), [s = t[0], o] = P("focusedDate"), r = bt({
|
|
1267
1274
|
...e,
|
|
1268
1275
|
focusedDate: s,
|
|
1269
1276
|
setFocusedDate: o
|
|
@@ -1283,7 +1290,7 @@ const un = k(
|
|
|
1283
1290
|
}
|
|
1284
1291
|
) });
|
|
1285
1292
|
},
|
|
1286
|
-
{ props: pt, styles:
|
|
1293
|
+
{ props: pt, styles: gt }
|
|
1287
1294
|
);
|
|
1288
1295
|
customElements.define("calendar-multi", un);
|
|
1289
1296
|
export {
|