cally 0.4.2 → 0.4.3

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.
Files changed (2) hide show
  1. package/dist/cally.js +177 -179
  2. package/package.json +1 -1
package/dist/cally.js CHANGED
@@ -29,13 +29,13 @@ class oe {
29
29
  return this.#e.add(t), () => this.#e.delete(t);
30
30
  }
31
31
  }
32
- const Nt = (e) => new oe(e), tt = Symbol.for("atomico.hooks");
33
- globalThis[tt] = globalThis[tt] || {};
34
- let N = globalThis[tt];
32
+ const Nt = (e) => new oe(e), Q = Symbol.for("atomico.hooks");
33
+ globalThis[Q] = globalThis[Q] || {};
34
+ let N = globalThis[Q];
35
35
  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) => {
36
36
  const { i: n, hooks: o } = N.c, r = o[n] = o[n] || {};
37
37
  return r.value = e(r.value), r.effect = t, r.tag = s, N.c.i++, o[n].value;
38
- }, ae = (e) => O((t = Nt(e)) => t), U = () => O((e = Nt(N.c.host)) => e), Ft = () => N.c.update, ce = (e, t, s = 0) => {
38
+ }, ae = (e) => O((t = Nt(e)) => t), U = () => O((e = Nt(N.c.host)) => e), kt = () => N.c.update, ce = (e, t, s = 0) => {
39
39
  let n = {}, o = !1;
40
40
  const r = () => o, i = (l, c) => {
41
41
  for (const h in n) {
@@ -59,7 +59,7 @@ const re = Symbol.for("Atomico.suspense"), Pt = Symbol.for("Atomico.effect"), ie
59
59
  }, cleanEffects: (l) => (i(Ot, l), () => (i(ie, l), () => {
60
60
  i(Pt, l);
61
61
  })), isSuspense: r };
62
- }, F = Symbol.for;
62
+ }, k = Symbol.for;
63
63
  function Mt(e, t) {
64
64
  const s = e.length;
65
65
  if (s !== t.length)
@@ -71,8 +71,8 @@ function Mt(e, t) {
71
71
  }
72
72
  return !0;
73
73
  }
74
- 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 || {});
75
- function kt(e, t) {
74
+ 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 || {});
75
+ function At(e, t) {
76
76
  let s;
77
77
  const n = (o) => {
78
78
  let { length: r } = o;
@@ -90,8 +90,8 @@ function kt(e, t) {
90
90
  };
91
91
  n(e), s != null && t(s);
92
92
  }
93
- const At = (e, t, s) => (e.addEventListener(t, s), () => e.removeEventListener(t, s));
94
- class Rt {
93
+ const Rt = (e, t, s) => (e.addEventListener(t, s), () => e.removeEventListener(t, s));
94
+ class Ft {
95
95
  /**
96
96
  *
97
97
  * @param {HTMLElement} target
@@ -102,11 +102,11 @@ class Rt {
102
102
  this.message = s, this.target = t, this.value = n;
103
103
  }
104
104
  }
105
- class It extends Rt {
105
+ class It extends Ft {
106
106
  }
107
- class le extends Rt {
107
+ class le extends Ft {
108
108
  }
109
- const L = "Custom", fe = null, de = { true: 1, "": 1, 1: 1 };
109
+ const Y = "Custom", fe = null, de = { true: 1, "": 1, 1: 1 };
110
110
  function he(e, t, s, n, o) {
111
111
  const {
112
112
  type: r,
@@ -114,7 +114,7 @@ function he(e, t, s, n, o) {
114
114
  event: f,
115
115
  value: u,
116
116
  attr: l = me(t)
117
- } = 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;
117
+ } = 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;
118
118
  Object.defineProperty(e, t, {
119
119
  configurable: !0,
120
120
  /**
@@ -124,7 +124,7 @@ function he(e, t, s, n, o) {
124
124
  set(a) {
125
125
  const d = this[t];
126
126
  h && r != Boolean && a == null && (a = h());
127
- const { error: y, value: D } = (c ? pe : ge)(
127
+ const { error: y, value: D } = (c ? be : ge)(
128
128
  r,
129
129
  a
130
130
  );
@@ -134,7 +134,7 @@ function he(e, t, s, n, o) {
134
134
  `The value defined for prop '${t}' must be of type '${r.name}'`,
135
135
  D
136
136
  );
137
- d != D && (this._props[t] = D ?? void 0, this.update(), f && Ut(this, f), this.updated.then(() => {
137
+ d != D && (this._props[t] = D ?? void 0, this.update(), f && xt(this, f), this.updated.then(() => {
138
138
  i && (this._ignoreAttr = l, ye(this, r, l, this[t]), this._ignoreAttr = null);
139
139
  }));
140
140
  },
@@ -146,13 +146,13 @@ function he(e, t, s, n, o) {
146
146
  }
147
147
  }), h && (o[t] = h()), n[l] = { prop: t, type: r };
148
148
  }
149
- 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(
149
+ 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(
150
150
  s,
151
- t?.name === L && t?.serialize ? t?.serialize(n) : A(n) ? JSON.stringify(n) : t == Boolean ? "" : n
152
- ), 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 : (
151
+ t?.name === Y && t?.serialize ? t?.serialize(n) : R(n) ? JSON.stringify(n) : t == Boolean ? "" : n
152
+ ), 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 : (
153
153
  // TODO: If when defining reflect the prop can also be of type string?
154
154
  new e(t)
155
- ), pe = ({ map: e }, t) => {
155
+ ), be = ({ map: e }, t) => {
156
156
  try {
157
157
  return { value: e(t), error: !1 };
158
158
  } catch {
@@ -206,7 +206,7 @@ const we = (e) => {
206
206
  we(this)
207
207
  );
208
208
  let d, y = !0;
209
- const D = et(this);
209
+ const D = V(this);
210
210
  this.update = () => (d || (d = !0, this.updated = (this.updated || this.mounted).then(() => {
211
211
  try {
212
212
  const m = a.load(this._render), w = a.cleanEffects();
@@ -242,7 +242,7 @@ const we = (e) => {
242
242
  return;
243
243
  const { prop: d, type: y } = s[c];
244
244
  try {
245
- this[d] = be(y, a);
245
+ this[d] = pe(y, a);
246
246
  } catch {
247
247
  throw new le(
248
248
  this,
@@ -269,12 +269,12 @@ function Ee(e) {
269
269
  const { styles: t } = e.constructor, { shadowRoot: s } = e;
270
270
  if (s && t.length) {
271
271
  const n = [];
272
- kt(t, (o) => {
272
+ At(t, (o) => {
273
273
  o && (o instanceof Element ? s.appendChild(o.cloneNode(!0)) : n.push(o));
274
274
  }), n.length && (s.adoptedStyleSheets = n);
275
275
  }
276
276
  }
277
- const xt = (e) => (t, s) => {
277
+ const Ut = (e) => (t, s) => {
278
278
  O(
279
279
  /**
280
280
  * Clean the effect hook
@@ -287,7 +287,7 @@ const xt = (e) => (t, s) => {
287
287
  ([n, o], r) => r ? (S(n) && n(), []) : [n || t(), o],
288
288
  e
289
289
  );
290
- }, j = xt(Pt), Se = xt(Ot);
290
+ }, j = Ut(Pt), Se = Ut(Ot);
291
291
  class _t extends Array {
292
292
  /**
293
293
  *
@@ -318,8 +318,8 @@ class _t extends Array {
318
318
  // this[2](nextState, this);
319
319
  // }
320
320
  }
321
- const ct = (e) => {
322
- const t = Ft();
321
+ const it = (e) => {
322
+ const t = kt();
323
323
  return O(
324
324
  (s = new _t(e, (n, o, r) => {
325
325
  n = S(n) ? n(o[0]) : n, n !== o[0] && (o[0] = n, r || t());
@@ -343,16 +343,16 @@ const ct = (e) => {
343
343
  );
344
344
  }, v = (e, t = {}) => {
345
345
  const s = U();
346
- return s[e] || (s[e] = (n = t.detail) => Ut(s.current, {
346
+ return s[e] || (s[e] = (n = t.detail) => xt(s.current, {
347
347
  type: e,
348
348
  ...t,
349
349
  detail: n
350
350
  })), s[e];
351
- }, nt = F("atomico/options");
352
- globalThis[nt] = globalThis[nt] || {
351
+ }, tt = k("atomico/options");
352
+ globalThis[tt] = globalThis[tt] || {
353
353
  sheet: !!document.adoptedStyleSheets
354
354
  };
355
- const Yt = globalThis[nt], ve = {
355
+ const Yt = globalThis[tt], ve = {
356
356
  checked: 1,
357
357
  value: 1,
358
358
  selected: 1
@@ -372,18 +372,18 @@ const Yt = globalThis[nt], ve = {
372
372
  cloneNode: 1,
373
373
  children: 1,
374
374
  key: 1
375
- }, _ = {}, st = [];
376
- class ot extends Text {
375
+ }, L = {}, et = [];
376
+ class nt extends Text {
377
377
  }
378
- const Ne = F("atomico/id"), R = F("atomico/type"), X = F("atomico/ref"), $t = F("atomico/vnode"), Pe = () => {
378
+ const Ne = k("atomico/id"), F = k("atomico/type"), J = k("atomico/ref"), $t = k("atomico/vnode"), Pe = () => {
379
379
  };
380
380
  function Oe(e, t, s) {
381
381
  return qt(this, e, t, s);
382
382
  }
383
383
  const jt = (e, t, ...s) => {
384
- const n = t || _;
384
+ const n = t || L;
385
385
  let { children: o } = n;
386
- if (o = o ?? (s.length ? s : st), e === Pe)
386
+ if (o = o ?? (s.length ? s : et), e === Pe)
387
387
  return o;
388
388
  const r = e ? e instanceof Node ? 1 : (
389
389
  //@ts-ignore
@@ -391,11 +391,11 @@ const jt = (e, t, ...s) => {
391
391
  ) : 0;
392
392
  if (r === !1 && e instanceof Function)
393
393
  return e(
394
- o != st ? { children: o, ...n } : n
394
+ o != et ? { children: o, ...n } : n
395
395
  );
396
396
  const i = Yt.render || Oe;
397
397
  return {
398
- [R]: $t,
398
+ [F]: $t,
399
399
  type: e,
400
400
  props: n,
401
401
  children: o,
@@ -416,22 +416,22 @@ const jt = (e, t, ...s) => {
416
416
  };
417
417
  function qt(e, t, s = Ne, n, o) {
418
418
  let r;
419
- if (t && t[s] && t[s].vnode == e || e[R] != $t)
419
+ if (t && t[s] && t[s].vnode == e || e[F] != $t)
420
420
  return t;
421
- (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(
421
+ (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(
422
422
  "http://www.w3.org/2000/svg",
423
423
  e.type
424
424
  ) : document.createElement(
425
425
  e.type,
426
426
  e.is ? { is: e.is } : void 0
427
427
  )));
428
- const i = t[s] ? t[s] : _, { vnode: f = _, cycle: u = 0 } = i;
428
+ const i = t[s] ? t[s] : L, { vnode: f = L, cycle: u = 0 } = i;
429
429
  let { fragment: l, handlers: c } = i;
430
- const { children: h = st, props: a = _ } = f;
430
+ const { children: h = et, props: a = L } = f;
431
431
  if (c = r ? {} : c || {}, e.static && !r)
432
432
  return t;
433
433
  if (e.shadow && !t.shadowRoot && // @ts-ignore
434
- t.attachShadow({ mode: "open", ...e.shadow }), e.props != a && ke(t, a, e.props, c, o), e.children !== h) {
434
+ t.attachShadow({ mode: "open", ...e.shadow }), e.props != a && Ae(t, a, e.props, c, o), e.children !== h) {
435
435
  const d = e.shadow ? t.shadowRoot : t;
436
436
  l = Me(
437
437
  e.children,
@@ -448,14 +448,14 @@ function qt(e, t, s = Ne, n, o) {
448
448
  }
449
449
  return t[s] = { vnode: e, handlers: c, fragment: l, cycle: u + 1 }, t;
450
450
  }
451
- function Fe(e, t) {
452
- const s = new ot(""), n = new ot("");
451
+ function ke(e, t) {
452
+ const s = new nt(""), n = new nt("");
453
453
  let o;
454
454
  if (e[t ? "prepend" : "append"](s), t) {
455
455
  let { lastElementChild: r } = e;
456
456
  for (; r; ) {
457
457
  const { previousElementSibling: i } = r;
458
- if (et(r, !0) && !et(i, !0)) {
458
+ if (V(r, !0) && !V(i, !0)) {
459
459
  o = r;
460
460
  break;
461
461
  }
@@ -469,22 +469,22 @@ function Fe(e, t) {
469
469
  }
470
470
  function Me(e, t, s, n, o, r) {
471
471
  e = e == null ? null : ue(e) ? e : [e];
472
- const i = t || Fe(s, o), { markStart: f, markEnd: u, keyes: l } = i;
472
+ const i = t || ke(s, o), { markStart: f, markEnd: u, keyes: l } = i;
473
473
  let c;
474
474
  const h = l && /* @__PURE__ */ new Set();
475
475
  let a = f;
476
- if (e && kt(e, (d) => {
477
- if (typeof d == "object" && !d[R])
476
+ if (e && At(e, (d) => {
477
+ if (typeof d == "object" && !d[F])
478
478
  return;
479
- const y = d[R] && d.key, D = l && y != null && l.get(y);
479
+ const y = d[F] && d.key, D = l && y != null && l.get(y);
480
480
  a != u && a === D ? h.delete(a) : a = a == u ? u : a.nextSibling;
481
481
  const m = l ? D : a;
482
482
  let w = m;
483
- if (d[R])
483
+ if (d[F])
484
484
  w = qt(d, m, n, o, r);
485
485
  else {
486
486
  const M = d + "";
487
- !(w instanceof Text) || w instanceof ot ? w = new Text(M) : w.data != M && (w.data = M);
487
+ !(w instanceof Text) || w instanceof nt ? w = new Text(M) : w.data != M && (w.data = M);
488
488
  }
489
489
  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));
490
490
  }), a = a == u ? u : a.nextSibling, t && a != u)
@@ -494,32 +494,32 @@ function Me(e, t, s, n, o, r) {
494
494
  }
495
495
  return h && h.forEach((d) => d.remove()), i.keyes = c, i;
496
496
  }
497
- function ke(e, t, s, n, o) {
497
+ function Ae(e, t, s, n, o) {
498
498
  for (const r in t)
499
- !(r in s) && bt(e, r, t[r], null, o, n);
499
+ !(r in s) && pt(e, r, t[r], null, o, n);
500
500
  for (const r in s)
501
- bt(e, r, t[r], s[r], o, n);
501
+ pt(e, r, t[r], s[r], o, n);
502
502
  }
503
- function bt(e, t, s, n, o, r) {
503
+ function pt(e, t, s, n, o, r) {
504
504
  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] == "_"))
505
505
  if (t[0] == "o" && t[1] == "n" && (S(n) || S(s)))
506
- Ae(e, t.slice(2), n, r);
506
+ Re(e, t.slice(2), n, r);
507
507
  else if (t == "ref")
508
508
  n && (S(n) ? n(e) : n.current = e);
509
509
  else if (t == "style") {
510
510
  const { style: i } = e;
511
511
  s = s || "", n = n || "";
512
- const f = A(s), u = A(n);
512
+ const f = R(s), u = R(n);
513
513
  if (f)
514
514
  for (const l in s)
515
515
  if (u)
516
- !(l in n) && pt(i, l, null);
516
+ !(l in n) && bt(i, l, null);
517
517
  else
518
518
  break;
519
519
  if (u)
520
520
  for (const l in n) {
521
521
  const c = n[l];
522
- f && s[l] === c || pt(i, l, c);
522
+ f && s[l] === c || bt(i, l, c);
523
523
  }
524
524
  else
525
525
  i.cssText = n;
@@ -527,11 +527,11 @@ function bt(e, t, s, n, o, r) {
527
527
  const i = t[0] == "$" ? t.slice(1) : t;
528
528
  i === t && (!o && !Te[t] && t in e || S(n) || S(s)) ? e[t] = n ?? "" : n == null ? e.removeAttribute(i) : e.setAttribute(
529
529
  i,
530
- A(n) ? JSON.stringify(n) : n
530
+ R(n) ? JSON.stringify(n) : n
531
531
  );
532
532
  }
533
533
  }
534
- function Ae(e, t, s, n) {
534
+ function Re(e, t, s, n) {
535
535
  if (n.handleEvent || (n.handleEvent = (o) => n[o.type].call(e, o)), s) {
536
536
  if (!n[t]) {
537
537
  const o = s.capture || s.once || s.passive ? Object.assign({}, s) : null;
@@ -541,7 +541,7 @@ function Ae(e, t, s, n) {
541
541
  } else
542
542
  n[t] && (e.removeEventListener(t, n), delete n[t]);
543
543
  }
544
- function pt(e, t, s) {
544
+ function bt(e, t, s) {
545
545
  let n = "setProperty";
546
546
  s == null && (n = "removeProperty", s = null), ~t.indexOf("-") ? e[n](t, s) : e[t] = s;
547
547
  }
@@ -551,9 +551,9 @@ function q(e, ...t) {
551
551
  (n, o, r) => n + o + (t[r] || ""),
552
552
  ""
553
553
  );
554
- return gt[s] = gt[s] || Re(s);
554
+ return gt[s] = gt[s] || Fe(s);
555
555
  }
556
- function Re(e) {
556
+ function Fe(e) {
557
557
  if (Yt.sheet) {
558
558
  const t = new CSSStyleSheet();
559
559
  return t.replaceSync(e), t;
@@ -562,10 +562,10 @@ function Re(e) {
562
562
  return t.textContent = e, t;
563
563
  }
564
564
  }
565
- const Ie = jt("host", { style: "display: contents" }), G = F("atomico/context"), Ue = (e, t) => {
565
+ const Ie = jt("host", { style: "display: contents" }), Z = k("atomico/context"), xe = (e, t) => {
566
566
  const s = U();
567
567
  Se(
568
- () => At(
568
+ () => Rt(
569
569
  s.current,
570
570
  "ConnectContext",
571
571
  /**
@@ -577,7 +577,7 @@ const Ie = jt("host", { style: "display: contents" }), G = F("atomico/context"),
577
577
  ),
578
578
  [e]
579
579
  );
580
- }, xe = (e) => {
580
+ }, Ue = (e) => {
581
581
  const t = v("ConnectContext", {
582
582
  bubbles: !0,
583
583
  composed: !0
@@ -589,25 +589,25 @@ const Ie = jt("host", { style: "display: contents" }), G = F("atomico/context"),
589
589
  r = i;
590
590
  }
591
591
  }), r;
592
- }, [n, o] = ct(
592
+ }, [n, o] = it(
593
593
  s
594
594
  );
595
595
  return j(() => {
596
- n || (e[G] || (e[G] = customElements.whenDefined(
596
+ n || (e[Z] || (e[Z] = customElements.whenDefined(
597
597
  new e().localName
598
- )), e[G].then(
598
+ )), e[Z].then(
599
599
  () => o(s)
600
600
  ));
601
601
  }, [e]), n;
602
602
  }, _e = (e) => {
603
- const t = xe(e), s = Ft();
603
+ const t = Ue(e), s = kt();
604
604
  return j(() => {
605
605
  if (t)
606
- return At(t, "UpdatedValue", s);
606
+ return Rt(t, "UpdatedValue", s);
607
607
  }, [t]), (t || e).value;
608
608
  }, Le = (e) => {
609
609
  const t = $(
610
- () => (Ue(t, U().current), Ie),
610
+ () => (xe(t, U().current), Ie),
611
611
  {
612
612
  props: {
613
613
  value: {
@@ -619,17 +619,16 @@ const Ie = jt("host", { style: "display: contents" }), G = F("atomico/context"),
619
619
  }
620
620
  );
621
621
  return t.value = e, t;
622
- }, 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)}`;
623
- function z() {
624
- const e = new Date(Date.now());
625
- return new g(e.getUTCFullYear(), e.getUTCMonth() + 1, e.getUTCDate());
622
+ }, 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)}`;
623
+ function at() {
624
+ return g.from(/* @__PURE__ */ new Date());
626
625
  }
627
- function B(e, t = 0) {
626
+ function ct(e, t = 0) {
628
627
  const s = e.toDate(), n = s.getUTCDay(), o = (n < t ? 7 : 0) + n - t;
629
628
  return s.setUTCDate(s.getUTCDate() - o), g.from(s);
630
629
  }
631
630
  function Ht(e, t = 0) {
632
- return B(e, t).add({ days: 6 });
631
+ return ct(e, t).add({ days: 6 });
633
632
  }
634
633
  function ut(e) {
635
634
  return g.from(new Date(Date.UTC(e.year, e.month, 0)));
@@ -638,11 +637,11 @@ function Wt(e, t) {
638
637
  const s = e.toDate(), n = t.toDate();
639
638
  return s < n ? -1 : s > n ? 1 : 0;
640
639
  }
641
- function H(e, t, s) {
640
+ function z(e, t, s) {
642
641
  return t && g.compare(e, t) < 0 ? t : s && g.compare(e, s) > 0 ? s : e;
643
642
  }
644
- function rt(e, t, s) {
645
- return H(e, t, s) === e;
643
+ function st(e, t, s) {
644
+ return z(e, t, s) === e;
646
645
  }
647
646
  function Ye(e, t) {
648
647
  const s = { days: 1 }, n = [e];
@@ -657,17 +656,11 @@ function $e(e, t) {
657
656
  return s;
658
657
  }
659
658
  function je(e, t = 0) {
660
- const s = B(e.toPlainDate(), t), n = Ht(ut(e), t);
659
+ const s = ct(e.toPlainDate(), t), n = Ht(ut(e), t);
661
660
  return $e(Ye(s, n), 7);
662
661
  }
663
- function qe(e, t, s) {
664
- const n = [], o = { weekday: e }, r = B(z(), t).toDate(), i = new Intl.DateTimeFormat(s, o);
665
- for (let f = 0; f < 7; f++)
666
- n[f] = i.format(r), r.setDate(r.getDate() + 1);
667
- return n;
668
- }
669
- 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";
670
- function Be(e) {
662
+ 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";
663
+ function ze(e) {
671
664
  if (Kt in e)
672
665
  return { years: -e.years };
673
666
  if (Jt in e)
@@ -676,21 +669,21 @@ function Be(e) {
676
669
  return { days: -e.days };
677
670
  throw new TypeError();
678
671
  }
679
- function He(e, t) {
672
+ function Be(e, t) {
680
673
  return g.from(new Date(Date.UTC(e.year, e.month - 1, t)));
681
674
  }
682
- function We(e, t) {
675
+ function He(e, t) {
683
676
  const s = new g(t, e.month, 1), n = ut(s), o = e.toDate();
684
- return o.setUTCFullYear(t), H(g.from(o), s, n);
677
+ return o.setUTCFullYear(t), z(g.from(o), s, n);
685
678
  }
686
- function Ke(e, t) {
679
+ function We(e, t) {
687
680
  const s = new g(e.year, t, 1), n = ut(s), o = e.toDate();
688
- return o.setUTCMonth(t - 1), H(g.from(o), s, n);
681
+ return o.setUTCMonth(t - 1), z(g.from(o), s, n);
689
682
  }
690
683
  function Dt(e, t) {
691
- 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;
684
+ 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;
692
685
  }
693
- const Q = (e, t) => e.toString().padStart(t, "0");
686
+ const X = (e, t) => e.toString().padStart(t, "0");
694
687
  class g {
695
688
  constructor(t, s, n) {
696
689
  this.year = t, this.month = s, this.day = n;
@@ -699,10 +692,10 @@ class g {
699
692
  return Dt(this, t);
700
693
  }
701
694
  subtract(t) {
702
- return Dt(this, Be(t));
695
+ return Dt(this, ze(t));
703
696
  }
704
697
  toString() {
705
- return `${Q(this.year, 4)}-${Q(this.month, 2)}-${Q(this.day, 2)}`;
698
+ return `${X(this.year, 4)}-${X(this.month, 2)}-${X(this.day, 2)}`;
706
699
  }
707
700
  toDate() {
708
701
  return new Date(Date.UTC(this.year, this.month - 1, this.day, 0, 0, 0));
@@ -720,7 +713,7 @@ class g {
720
713
  return typeof t == "string" ? this.fromString(t) : this.fromDate(t);
721
714
  }
722
715
  static fromString(t) {
723
- const s = t.match(ze);
716
+ const s = t.match(qe);
724
717
  if (!s)
725
718
  throw new TypeError(t);
726
719
  const [, n, o, r] = s;
@@ -769,70 +762,75 @@ class C {
769
762
  return Wt(n, o);
770
763
  }
771
764
  }
772
- function it(e, t) {
765
+ function ot(e, t) {
773
766
  if (t)
774
767
  try {
775
768
  return e.from(t);
776
769
  } catch {
777
770
  }
778
771
  }
779
- function at(e) {
772
+ function rt(e) {
780
773
  const [t, s] = Lt(e);
781
- return [P(() => it(g, t), [t]), (r) => s(r.toString())];
774
+ return [P(() => ot(g, t), [t]), (r) => s(r.toString())];
782
775
  }
783
- function Je(e) {
776
+ function Ke(e) {
784
777
  if (e) {
785
- const [t, s] = e.split("/"), n = it(g, t), o = it(g, s);
778
+ const [t, s] = e.split("/"), n = ot(g, t), o = ot(g, s);
786
779
  if (n && o)
787
780
  return [n, o];
788
781
  }
789
782
  return [];
790
783
  }
791
- function Ze(e, t) {
784
+ function Je(e, t) {
792
785
  return `${e}/${t}`;
793
786
  }
794
- function Xe(e) {
787
+ function Ze(e) {
795
788
  const [t, s] = Lt(e);
796
- return [P(() => Je(t), [t]), (r) => s(Ze(r[0], r[1]))];
789
+ return [P(() => Ke(t), [t]), (r) => s(Je(r[0], r[1]))];
797
790
  }
798
- function Y(e, t) {
791
+ function x(e, t) {
799
792
  return P(
800
793
  () => new Intl.DateTimeFormat(t, { timeZone: "UTC", ...e }),
801
794
  [t, e]
802
795
  );
803
796
  }
804
797
  function St(e, t, s) {
805
- return P(
806
- () => qe(e, t, s),
807
- [e, t, s]
808
- );
798
+ const n = x(e, s);
799
+ return P(() => {
800
+ const o = [], r = /* @__PURE__ */ new Date();
801
+ for (var i = 0; i < 7; i++) {
802
+ const f = (r.getDay() - t + 7) % 7;
803
+ o[f] = n.format(r), r.setDate(r.getDate() + 1);
804
+ }
805
+ return o;
806
+ }, [t, n]);
809
807
  }
810
- function Ge(e) {
808
+ function Xe(e) {
811
809
  let t = "";
812
810
  for (const s in e)
813
811
  e[s] && (t += ` ${s}`);
814
812
  return t;
815
813
  }
816
- const vt = (e) => e.target.matches(":dir(ltr)"), Qe = { month: "long", day: "numeric" }, Ve = { month: "long" }, V = { bubbles: !0 };
817
- function tn({ props: e, context: t }) {
818
- 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(
814
+ 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 };
815
+ function en({ props: e, context: t }) {
816
+ 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(
819
817
  () => f.start.add({ months: s }),
820
818
  [f, s]
821
819
  ), m = P(
822
820
  () => je(D, n),
823
821
  [D, n]
824
- ), w = v("focusday", V), M = v("selectday", V), te = v("hoverday", V);
825
- function ft(p) {
826
- w(H(p, r, i));
822
+ ), w = v("focusday", G), M = v("selectday", G), te = v("hoverday", G);
823
+ function ft(b) {
824
+ w(z(b, r, i));
827
825
  }
828
- function ee(p) {
826
+ function ee(b) {
829
827
  let E;
830
- switch (p.key) {
828
+ switch (b.key) {
831
829
  case "ArrowRight":
832
- E = y.add({ days: vt(p) ? 1 : -1 });
830
+ E = y.add({ days: vt(b) ? 1 : -1 });
833
831
  break;
834
832
  case "ArrowLeft":
835
- E = y.add({ days: vt(p) ? -1 : 1 });
833
+ E = y.add({ days: vt(b) ? -1 : 1 });
836
834
  break;
837
835
  case "ArrowDown":
838
836
  E = y.add({ days: 7 });
@@ -841,13 +839,13 @@ function tn({ props: e, context: t }) {
841
839
  E = y.add({ days: -7 });
842
840
  break;
843
841
  case "PageUp":
844
- E = y.add(p.shiftKey ? { years: -1 } : { months: -1 });
842
+ E = y.add(b.shiftKey ? { years: -1 } : { months: -1 });
845
843
  break;
846
844
  case "PageDown":
847
- E = y.add(p.shiftKey ? { years: 1 } : { months: 1 });
845
+ E = y.add(b.shiftKey ? { years: 1 } : { months: 1 });
848
846
  break;
849
847
  case "Home":
850
- E = B(y, n);
848
+ E = ct(y, n);
851
849
  break;
852
850
  case "End":
853
851
  E = Ht(y, n);
@@ -855,40 +853,40 @@ function tn({ props: e, context: t }) {
855
853
  default:
856
854
  return;
857
855
  }
858
- ft(E), p.preventDefault();
856
+ ft(E), b.preventDefault();
859
857
  }
860
- function ne(p) {
861
- const E = D.equals(p), se = p.equals(y), dt = p.equals(l), ht = p.toDate(), x = o?.(ht), mt = !rt(p, r, i);
862
- let k = !1, yt = !1, W = !1, K = !1;
858
+ function ne(b) {
859
+ const E = D.equals(b), se = b.equals(y), dt = b.equals(l), ht = b.toDate(), _ = o?.(ht), mt = !st(b, r, i);
860
+ let A = !1, yt = !1, B = !1, H = !1;
863
861
  if ("highlightedRange" in t) {
864
- const [J, Z] = t.highlightedRange;
865
- yt = !0, W = J?.equals(p) ?? !1, K = Z?.equals(p) ?? !1, k = J && Z ? rt(p, J, Z) : !1;
862
+ const [W, K] = t.highlightedRange;
863
+ yt = !0, B = W?.equals(b) ?? !1, H = K?.equals(b) ?? !1, A = W && K ? st(b, W, K) : !1;
866
864
  } else
867
- "value" in t && (k = t.value?.equals(p) ?? !1);
865
+ "value" in t && (A = t.value?.equals(b) ?? !1);
868
866
  return {
869
- part: Ge({
867
+ part: Xe({
870
868
  button: !0,
871
869
  day: !0,
872
- selected: E && k,
870
+ selected: E && A,
873
871
  today: dt,
874
- disallowed: x,
872
+ disallowed: _,
875
873
  outside: !E,
876
- "range-start": W,
877
- "range-end": K,
878
- "range-inner": yt && k && !W && !K
874
+ "range-start": B,
875
+ "range-end": H,
876
+ "range-inner": yt && A && !B && !H
879
877
  }),
880
878
  tabindex: E && se ? 0 : -1,
881
879
  disabled: mt,
882
- "aria-disabled": x ? "true" : void 0,
883
- "aria-pressed": E && k,
880
+ "aria-disabled": _ ? "true" : void 0,
881
+ "aria-pressed": E && A,
884
882
  "aria-current": dt ? "date" : void 0,
885
883
  "aria-label": a.format(ht),
886
884
  onkeydown: ee,
887
885
  onclick() {
888
- x || M(p), ft(p);
886
+ _ || M(b), ft(b);
889
887
  },
890
888
  onmouseover() {
891
- !x && !mt && te(p);
889
+ !_ && !mt && te(b);
892
890
  }
893
891
  };
894
892
  }
@@ -935,28 +933,28 @@ class T {
935
933
  );
936
934
  }
937
935
  }
938
- const Tt = z(), lt = Le({
936
+ const Tt = at(), lt = Le({
939
937
  firstDayOfWeek: 0,
940
938
  isDateDisallowed: () => !1,
941
939
  dateWindow: new T(Tt.toPlainYearMonth(), { months: 1 }, Tt)
942
940
  });
943
941
  customElements.define("calendar-month-ctx", lt);
944
- const en = $(
942
+ const nn = $(
945
943
  (e) => {
946
- const t = _e(lt), s = ae(), n = tn({ props: e, context: t });
944
+ const t = _e(lt), s = ae(), n = en({ props: e, context: t });
947
945
  function o() {
948
946
  s.current.querySelector("button[tabindex='0']")?.focus();
949
947
  }
950
948
  return /* @__PURE__ */ I("host", { shadowDom: !0, focus: o, children: [
951
- /* @__PURE__ */ b("div", { id: "heading", part: "heading", children: n.monthFormatter.format(n.yearMonth.toDate()) }),
949
+ /* @__PURE__ */ p("div", { id: "heading", part: "heading", children: n.monthFormatter.format(n.yearMonth.toDate()) }),
952
950
  /* @__PURE__ */ I("table", { ref: s, "aria-labelledby": "heading", part: "table", children: [
953
- /* @__PURE__ */ b("thead", { children: /* @__PURE__ */ b("tr", { part: "tr head", children: n.dayNamesLong.map((r, i) => /* @__PURE__ */ I("th", { part: "th", scope: "col", children: [
954
- /* @__PURE__ */ b("span", { class: "vh", children: r }),
955
- /* @__PURE__ */ b("span", { "aria-hidden": "true", children: n.dayNamesShort[i] })
951
+ /* @__PURE__ */ p("thead", { children: /* @__PURE__ */ p("tr", { part: "tr head", children: n.dayNamesLong.map((r, i) => /* @__PURE__ */ I("th", { part: "th", scope: "col", children: [
952
+ /* @__PURE__ */ p("span", { class: "vh", children: r }),
953
+ /* @__PURE__ */ p("span", { "aria-hidden": "true", children: n.dayNamesShort[i] })
956
954
  ] })) }) }),
957
- /* @__PURE__ */ b("tbody", { children: n.weeks.map((r, i) => /* @__PURE__ */ b("tr", { part: "tr week", children: r.map((f, u) => {
955
+ /* @__PURE__ */ p("tbody", { children: n.weeks.map((r, i) => /* @__PURE__ */ p("tr", { part: "tr week", children: r.map((f, u) => {
958
956
  const l = n.yearMonth.equals(f), c = t.showOutsideDays || l;
959
- return /* @__PURE__ */ b("td", { part: "td", children: c && /* @__PURE__ */ b("button", { ...n.getDayProps(f), children: f.day }) }, u);
957
+ return /* @__PURE__ */ p("td", { part: "td", children: c && /* @__PURE__ */ p("button", { ...n.getDayProps(f), children: f.day }) }, u);
960
958
  }) }, i)) })
961
959
  ] })
962
960
  ] });
@@ -975,40 +973,40 @@ const en = $(
975
973
  ]
976
974
  }
977
975
  );
978
- customElements.define("calendar-month", en);
976
+ customElements.define("calendar-month", nn);
979
977
  function Xt(e) {
980
978
  const t = e.dateWindow.start.toDate(), s = e.dateWindow.end.toDate();
981
979
  return /* @__PURE__ */ I("div", { role: "group", "aria-labelledby": "label", part: "container", children: [
982
- /* @__PURE__ */ b("div", { id: "label", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, s) }),
980
+ /* @__PURE__ */ p("div", { id: "label", class: "vh", "aria-live": "polite", "aria-atomic": "true", children: e.formatVerbose.formatRange(t, s) }),
983
981
  /* @__PURE__ */ I("div", { class: "header", part: "header", children: [
984
- /* @__PURE__ */ b(
982
+ /* @__PURE__ */ p(
985
983
  "button",
986
984
  {
987
985
  part: `button previous ${e.previous ? "" : "disabled"}`,
988
986
  onclick: e.previous,
989
987
  "aria-disabled": e.previous ? null : "true",
990
- children: /* @__PURE__ */ b("slot", { name: "previous", children: "Previous" })
988
+ children: /* @__PURE__ */ p("slot", { name: "previous", children: "Previous" })
991
989
  }
992
990
  ),
993
- /* @__PURE__ */ b("div", { id: "heading", part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, s) }),
994
- /* @__PURE__ */ b(
991
+ /* @__PURE__ */ p("div", { id: "heading", part: "heading", "aria-hidden": "true", children: e.format.formatRange(t, s) }),
992
+ /* @__PURE__ */ p(
995
993
  "button",
996
994
  {
997
995
  part: `button next ${e.next ? "" : "disabled"}`,
998
996
  onclick: e.next,
999
997
  "aria-disabled": e.next ? null : "true",
1000
- children: /* @__PURE__ */ b("slot", { name: "next", children: "Next" })
998
+ children: /* @__PURE__ */ p("slot", { name: "next", children: "Next" })
1001
999
  }
1002
1000
  )
1003
1001
  ] }),
1004
- /* @__PURE__ */ b(
1002
+ /* @__PURE__ */ p(
1005
1003
  lt,
1006
1004
  {
1007
1005
  value: e,
1008
1006
  onselectday: e.onSelect,
1009
1007
  onfocusday: e.onFocus,
1010
1008
  onhoverday: e.onHover,
1011
- children: /* @__PURE__ */ b("slot", {})
1009
+ children: /* @__PURE__ */ p("slot", {})
1012
1010
  }
1013
1011
  )
1014
1012
  ] });
@@ -1051,10 +1049,10 @@ const Gt = {
1051
1049
  zt,
1052
1050
  Bt,
1053
1051
  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}`
1054
- ], nn = { year: "numeric" }, sn = { year: "numeric", month: "long" };
1052
+ ], sn = { year: "numeric" }, on = { year: "numeric", month: "long" };
1055
1053
  function Vt({ months: e, locale: t }) {
1056
- const [s] = at("min"), [n] = at("max"), o = v("focusday"), r = v("change"), [i, f] = ct(() => {
1057
- const m = z(), w = e === 12 ? new C(m.year, 1) : m.toPlainYearMonth();
1054
+ const [s] = rt("min"), [n] = rt("max"), o = v("focusday"), r = v("change"), [i, f] = it(() => {
1055
+ const m = at(), w = e === 12 ? new C(m.year, 1) : m.toPlainYearMonth();
1058
1056
  return new T(w, { months: e }, m);
1059
1057
  });
1060
1058
  function u(m) {
@@ -1067,7 +1065,7 @@ function Vt({ months: e, locale: t }) {
1067
1065
  function h() {
1068
1066
  c.current.querySelectorAll("calendar-month").forEach((m) => m.focus());
1069
1067
  }
1070
- const a = Y(nn, t), d = Y(sn, t), y = n == null || !i.contains(n), D = s == null || !i.contains(s);
1068
+ const a = x(sn, t), d = x(on, t), y = n == null || !i.contains(n), D = s == null || !i.contains(s);
1071
1069
  return {
1072
1070
  format: a,
1073
1071
  formatVerbose: d,
@@ -1084,16 +1082,16 @@ function Vt({ months: e, locale: t }) {
1084
1082
  focus: h
1085
1083
  };
1086
1084
  }
1087
- const on = $(
1085
+ const rn = $(
1088
1086
  (e) => {
1089
- const [t, s] = at("value"), n = Vt(e);
1087
+ const [t, s] = rt("value"), n = Vt(e);
1090
1088
  j(() => {
1091
1089
  t && n.setFocusedDate(t);
1092
1090
  }, [t]);
1093
1091
  function o(r) {
1094
1092
  s(r.detail), n.dispatch();
1095
1093
  }
1096
- return /* @__PURE__ */ b("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ b(
1094
+ return /* @__PURE__ */ p("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ p(
1097
1095
  Xt,
1098
1096
  {
1099
1097
  ...e,
@@ -1106,12 +1104,12 @@ const on = $(
1106
1104
  },
1107
1105
  { props: Gt, styles: Qt }
1108
1106
  );
1109
- customElements.define("calendar-date", on);
1110
- const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], rn = $(
1107
+ customElements.define("calendar-date", rn);
1108
+ const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], an = $(
1111
1109
  (e) => {
1112
- const [t, s] = Xe("value"), n = Vt(e), o = v("rangestart"), r = v("rangeend"), [i, f] = ct();
1110
+ const [t, s] = Ze("value"), n = Vt(e), o = v("rangestart"), r = v("rangeend"), [i, f] = it();
1113
1111
  j(() => {
1114
- t.length && !rt(n.dateWindow.focusedDate, t[0], t[1]) && n.setFocusedDate(t[1]);
1112
+ t.length && !st(n.dateWindow.focusedDate, t[0], t[1]) && n.setFocusedDate(t[1]);
1115
1113
  }, [t]);
1116
1114
  async function u(a) {
1117
1115
  n.handleFocus(a), l(a);
@@ -1124,7 +1122,7 @@ const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], rn = $(
1124
1122
  a.stopPropagation(), i ? (s(Ct(i.first, d)), f(void 0), r(d.toDate()), n.dispatch()) : (f({ first: d, second: d }), o(d.toDate()));
1125
1123
  }
1126
1124
  const h = i ? Ct(i.first, i.second) : t;
1127
- return /* @__PURE__ */ b("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ b(
1125
+ return /* @__PURE__ */ p("host", { shadowDom: !0, focus: n.focus, children: /* @__PURE__ */ p(
1128
1126
  Xt,
1129
1127
  {
1130
1128
  ...e,
@@ -1138,9 +1136,9 @@ const Ct = (e, t) => g.compare(e, t) < 0 ? [e, t] : [t, e], rn = $(
1138
1136
  },
1139
1137
  { props: Gt, styles: Qt }
1140
1138
  );
1141
- customElements.define("calendar-range", rn);
1139
+ customElements.define("calendar-range", an);
1142
1140
  export {
1143
- on as CalendarDate,
1144
- en as CalendarMonth,
1145
- rn as CalendarRange
1141
+ rn as CalendarDate,
1142
+ nn as CalendarMonth,
1143
+ an as CalendarRange
1146
1144
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cally",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "small, feature-rich calendar components",
5
5
  "license": "MIT",
6
6
  "type": "module",