@webority/ui-elements 0.35.2 → 0.36.0

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.
@@ -9574,7 +9574,7 @@ function kf(e, t) {
9574
9574
  }
9575
9575
  //#endregion
9576
9576
  //#region src/elementBase.js
9577
- var Af = typeof HTMLElement > "u" ? class {} : HTMLElement, jf = "wui-csrf", Mf = Object.freeze({
9577
+ var Af = typeof HTMLElement > "u" ? class {} : HTMLElement, jf = "wui-csrf", Mf = "X-Wui-Request", Nf = Object.freeze({
9578
9578
  fragment: "X-Wui-Fragment",
9579
9579
  message: "X-Wui-Message",
9580
9580
  redirect: "X-Wui-Redirect",
@@ -9593,33 +9593,34 @@ Object.freeze([
9593
9593
  "stale",
9594
9594
  "session"
9595
9595
  ]);
9596
- var Nf = /* @__PURE__ */ new Set(["GET", "HEAD"]);
9597
- function Pf(e = document) {
9596
+ var Pf = /* @__PURE__ */ new Set(["GET", "HEAD"]);
9597
+ function Ff(e = document) {
9598
9598
  let t = e.querySelector(`meta[name="${jf}"]`), n = t?.getAttribute("content");
9599
9599
  return n ? {
9600
9600
  header: t.getAttribute("data-header") || "RequestVerificationToken",
9601
9601
  token: n
9602
9602
  } : null;
9603
9603
  }
9604
- var Ff = (e) => {
9604
+ var If = (e) => {
9605
9605
  try {
9606
9606
  return new URL(e, window.location.href).origin === window.location.origin;
9607
9607
  } catch {
9608
9608
  return !1;
9609
9609
  }
9610
9610
  };
9611
- function If(e) {
9611
+ function Lf(e) {
9612
9612
  return e >= 200 && e < 300 ? "ok" : e === 401 ? "session" : e === 403 ? "forbidden" : e === 422 ? "validation" : e >= 400 && e < 500 ? "client" : "server";
9613
9613
  }
9614
- var Lf = (e) => e?.name === "AbortError";
9615
- async function Rf(e, t = {}) {
9614
+ var Rf = (e) => e?.name === "AbortError";
9615
+ async function zf(e, t = {}) {
9616
9616
  let n = (t.method || "GET").toUpperCase(), r = t.navigate || ((e) => window.location.assign(e)), i = {
9617
9617
  Accept: "text/html",
9618
9618
  "X-Requested-With": "XMLHttpRequest",
9619
+ [Mf]: "1",
9619
9620
  ...t.headers
9620
9621
  };
9621
- if (!Nf.has(n) && Ff(e)) {
9622
- let e = Pf();
9622
+ if (!Pf.has(n) && If(e)) {
9623
+ let e = Ff();
9623
9624
  e && (i[e.header] = e.token);
9624
9625
  }
9625
9626
  let a = (e) => {
@@ -9637,12 +9638,12 @@ async function Rf(e, t = {}) {
9637
9638
  status: t?.status ?? 0,
9638
9639
  html: n,
9639
9640
  response: t,
9640
- message: a(r(Mf.message)),
9641
- redirect: r(Mf.redirect),
9642
- result: r(Mf.result),
9643
- keepOpen: r(Mf.keepOpen) === "1",
9644
- toastVariant: r(Mf.toastVariant),
9645
- fragment: r(Mf.fragment) === "1"
9641
+ message: a(r(Nf.message)),
9642
+ redirect: r(Nf.redirect),
9643
+ result: r(Nf.result),
9644
+ keepOpen: r(Nf.keepOpen) === "1",
9645
+ toastVariant: r(Nf.toastVariant),
9646
+ fragment: r(Nf.fragment) === "1"
9646
9647
  };
9647
9648
  }, s;
9648
9649
  try {
@@ -9654,19 +9655,19 @@ async function Rf(e, t = {}) {
9654
9655
  credentials: "same-origin"
9655
9656
  });
9656
9657
  } catch (e) {
9657
- return o(Lf(e) || t.signal?.aborted ? "aborted" : "network");
9658
+ return o(Rf(e) || t.signal?.aborted ? "aborted" : "network");
9658
9659
  }
9659
- let c = If(s.status);
9660
- if (c === "ok" && s.redirected && s.headers.get(Mf.fragment) !== "1" && (c = "session"), c === "session") return r(s.status === 401 ? s.headers.get("Location") || window.location.href : s.url), o(c, s);
9660
+ let c = Lf(s.status);
9661
+ if (c === "ok" && s.redirected && s.headers.get(Nf.fragment) !== "1" && (c = "session"), c === "session") return r(s.status === 401 ? s.headers.get("Location") || window.location.href : s.url), o(c, s);
9661
9662
  let l = "";
9662
9663
  if (c === "ok" || c === "validation") try {
9663
9664
  l = await s.text();
9664
9665
  } catch (e) {
9665
- return o(Lf(e) || t.signal?.aborted ? "aborted" : "network", s);
9666
+ return o(Rf(e) || t.signal?.aborted ? "aborted" : "network", s);
9666
9667
  }
9667
9668
  return o(c, s, l);
9668
9669
  }
9669
- function zf() {
9670
+ function Bf() {
9670
9671
  let e = null, t = 0;
9671
9672
  return {
9672
9673
  async run(n, r = {}) {
@@ -9675,7 +9676,7 @@ function zf() {
9675
9676
  e = i;
9676
9677
  let a = ++t, o = r.signal;
9677
9678
  o && (o.aborted ? i.abort() : o.addEventListener("abort", () => i.abort(), { once: !0 }));
9678
- let s = await Rf(n, {
9679
+ let s = await zf(n, {
9679
9680
  ...r,
9680
9681
  signal: i.signal
9681
9682
  });
@@ -9692,18 +9693,18 @@ function zf() {
9692
9693
  }
9693
9694
  //#endregion
9694
9695
  //#region src/WuiCalendar.js
9695
- var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-calendar:range-change", Uf = {
9696
+ var Vf = "wui-calendar:event-click", Hf = "wui-calendar:date-click", Uf = "wui-calendar:range-change", Wf = {
9696
9697
  month: "Month",
9697
9698
  week: "Week",
9698
9699
  day: "Day",
9699
9700
  list: "List"
9700
- }, Wf = "Calendar", Gf = "Nothing scheduled in this period.", Kf = "The events couldn't load. Try again in a moment.", qf = (e) => `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="${e}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>`, Jf = (e, t, n) => {
9701
+ }, Gf = "Calendar", Kf = "Nothing scheduled in this period.", qf = "The events couldn't load. Try again in a moment.", Jf = (e) => `<svg viewBox="0 0 16 16" width="16" height="16" aria-hidden="true" focusable="false"><path d="${e}" fill="none" stroke="currentColor" stroke-width="1.75" stroke-linecap="round" stroke-linejoin="round"/></svg>`, Yf = (e, t, n) => {
9701
9702
  let r = document.createElement(e);
9702
9703
  return t && (r.className = t), n != null && (r.textContent = n), r;
9703
- }, Yf = (e, t, n) => {
9704
- let r = Jf("button", e, t);
9704
+ }, Xf = (e, t, n) => {
9705
+ let r = Yf("button", e, t);
9705
9706
  return r.type = "button", r.dataset.act = n, r;
9706
- }, Xf = class extends Af {
9707
+ }, Zf = class extends Af {
9707
9708
  static get observedAttributes() {
9708
9709
  return [
9709
9710
  "view",
@@ -9713,7 +9714,7 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9713
9714
  ];
9714
9715
  }
9715
9716
  constructor() {
9716
- super(), this._events = null, this._view = null, this._queue = zf(), this._pendingFocus = null, this._announced = !1;
9717
+ super(), this._events = null, this._view = null, this._queue = Bf(), this._pendingFocus = null, this._announced = !1;
9717
9718
  }
9718
9719
  get events() {
9719
9720
  return this._events;
@@ -9744,7 +9745,7 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9744
9745
  this._events ??= this._readScript(), this._build(), this._view = this._initialView(), this._engine = kf(this._parts.surface, {
9745
9746
  view: this._view,
9746
9747
  date: this._initialDate(),
9747
- emptyText: this.getAttribute("empty-text") || Gf,
9748
+ emptyText: this.getAttribute("empty-text") || Kf,
9748
9749
  fetchEvents: (e) => this._load(e),
9749
9750
  onEventClick: (e) => this._eventClick(e),
9750
9751
  onDateClick: (e) => this._dateClick(e),
@@ -9762,7 +9763,7 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9762
9763
  else if (e === "date") {
9763
9764
  if (!nf(n)) return;
9764
9765
  this._engine.setCursor(n), this._engine.gotoDate(n);
9765
- } else e === "events-url" ? this._engine.refetch() : e === "label" && this.setAttribute("aria-label", n || Wf);
9766
+ } else e === "events-url" ? this._engine.refetch() : e === "label" && this.setAttribute("aria-label", n || Gf);
9766
9767
  }
9767
9768
  _readScript() {
9768
9769
  let e = this.querySelector(":scope > script[type=\"application/json\"]");
@@ -9789,28 +9790,28 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9789
9790
  return nf(e) ? e : $d();
9790
9791
  }
9791
9792
  _build() {
9792
- let e = Yf("wui-calendar-nav-btn", null, "prev");
9793
- e.setAttribute("aria-label", "Previous"), e.innerHTML = qf("M10 3 5 8l5 5");
9794
- let t = Yf("wui-calendar-nav-btn", null, "next");
9795
- t.setAttribute("aria-label", "Next"), t.innerHTML = qf("m6 3 5 5-5 5");
9796
- let n = Jf("div", "wui-calendar-nav");
9797
- n.setAttribute("role", "group"), n.setAttribute("aria-label", "Move through the calendar"), n.append(Yf("wui-calendar-today-btn", "Today", "today"), e, t);
9798
- let r = Jf("h2", "wui-calendar-title");
9793
+ let e = Xf("wui-calendar-nav-btn", null, "prev");
9794
+ e.setAttribute("aria-label", "Previous"), e.innerHTML = Jf("M10 3 5 8l5 5");
9795
+ let t = Xf("wui-calendar-nav-btn", null, "next");
9796
+ t.setAttribute("aria-label", "Next"), t.innerHTML = Jf("m6 3 5 5-5 5");
9797
+ let n = Yf("div", "wui-calendar-nav");
9798
+ n.setAttribute("role", "group"), n.setAttribute("aria-label", "Move through the calendar"), n.append(Xf("wui-calendar-today-btn", "Today", "today"), e, t);
9799
+ let r = Yf("h2", "wui-calendar-title");
9799
9800
  r.setAttribute("aria-live", "polite");
9800
- let i = Jf("div", "wui-calendar-views");
9801
+ let i = Yf("div", "wui-calendar-views");
9801
9802
  i.setAttribute("role", "group"), i.setAttribute("aria-label", "Calendar view");
9802
9803
  for (let e of Vd) {
9803
- let t = Yf("wui-calendar-view-btn", Uf[e], "view");
9804
+ let t = Xf("wui-calendar-view-btn", Wf[e], "view");
9804
9805
  t.dataset.view = e, i.append(t);
9805
9806
  }
9806
- let a = Jf("div", "wui-calendar-toolbar");
9807
+ let a = Yf("div", "wui-calendar-toolbar");
9807
9808
  a.append(n, r, i), a.addEventListener("click", (e) => this._onToolbar(e));
9808
- let o = Jf("div", "wui-calendar-status");
9809
- o.setAttribute("role", "alert"), o.hidden = !0, o.append(Jf("p", "wui-calendar-status-text"), Yf("btn btn-sm btn-secondary", "Try again", "retry")), o.addEventListener("click", (e) => {
9809
+ let o = Yf("div", "wui-calendar-status");
9810
+ o.setAttribute("role", "alert"), o.hidden = !0, o.append(Yf("p", "wui-calendar-status-text"), Xf("btn btn-sm btn-secondary", "Try again", "retry")), o.addEventListener("click", (e) => {
9810
9811
  e.target.closest?.("[data-act=\"retry\"]") && (this._setError(!1), this._engine?.refetch());
9811
9812
  });
9812
- let s = Jf("div", "wui-calendar-surface");
9813
- s.addEventListener("keydown", (e) => this._onKey(e)), this.replaceChildren(a, o, s), this.setAttribute("role", "region"), this.setAttribute("aria-label", this.getAttribute("label") || Wf), this._parts = {
9813
+ let s = Yf("div", "wui-calendar-surface");
9814
+ s.addEventListener("keydown", (e) => this._onKey(e)), this.replaceChildren(a, o, s), this.setAttribute("role", "region"), this.setAttribute("aria-label", this.getAttribute("label") || Gf), this._parts = {
9814
9815
  toolbar: a,
9815
9816
  title: r,
9816
9817
  views: i,
@@ -9835,7 +9836,7 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9835
9836
  _setError(e) {
9836
9837
  if (!this._parts) return;
9837
9838
  let { status: t } = this._parts;
9838
- t.hidden = !e, e && (t.querySelector(".wui-calendar-status-text").textContent = this.getAttribute("error-text") || Kf);
9839
+ t.hidden = !e, e && (t.querySelector(".wui-calendar-status-text").textContent = this.getAttribute("error-text") || qf);
9839
9840
  }
9840
9841
  _loading(e) {
9841
9842
  e ? this.setAttribute("aria-busy", "true") : this.removeAttribute("aria-busy");
@@ -9846,7 +9847,7 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9846
9847
  let { title: t, views: n } = this._parts;
9847
9848
  t.textContent !== e.title && (t.textContent = e.title);
9848
9849
  for (let t of n.children) t.setAttribute("aria-pressed", String(t.dataset.view === e.view));
9849
- this._engine.labelDays(sf, $d()), this._pendingFocus &&= (this._engine.focusDay(this._pendingFocus), null), this._announced && this.dispatchEvent(new CustomEvent(Hf, {
9850
+ this._engine.labelDays(sf, $d()), this._pendingFocus &&= (this._engine.focusDay(this._pendingFocus), null), this._announced && this.dispatchEvent(new CustomEvent(Uf, {
9850
9851
  bubbles: !0,
9851
9852
  detail: { ...e }
9852
9853
  })), this._announced = !0;
@@ -9858,7 +9859,7 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9858
9859
  n === "today" ? this._engine.today() : n === "prev" ? this._engine.prev() : n === "next" ? this._engine.next() : n === "view" && r !== this._view && this._engine.setView(r);
9859
9860
  }
9860
9861
  _eventClick(e) {
9861
- let t = new CustomEvent(Bf, {
9862
+ let t = new CustomEvent(Vf, {
9862
9863
  bubbles: !0,
9863
9864
  cancelable: !0,
9864
9865
  detail: yf(e)
@@ -9866,7 +9867,7 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9866
9867
  return this.dispatchEvent(t), t.defaultPrevented;
9867
9868
  }
9868
9869
  _dateClick(e) {
9869
- this._engine?.setCursor(e.date), this.dispatchEvent(new CustomEvent(Vf, {
9870
+ this._engine?.setCursor(e.date), this.dispatchEvent(new CustomEvent(Hf, {
9870
9871
  bubbles: !0,
9871
9872
  detail: e
9872
9873
  }));
@@ -9899,6 +9900,6 @@ var Bf = "wui-calendar:event-click", Vf = "wui-calendar:date-click", Hf = "wui-c
9899
9900
  };
9900
9901
  //#endregion
9901
9902
  //#region src/calendar.js
9902
- typeof customElements < "u" && !customElements.get("wui-calendar") && customElements.define("wui-calendar", Xf);
9903
+ typeof customElements < "u" && !customElements.get("wui-calendar") && customElements.define("wui-calendar", Zf);
9903
9904
  //#endregion
9904
- export { Hd as CALENDAR_TONES, Vd as CALENDAR_VIEWS, Xf as WuiCalendar };
9905
+ export { Hd as CALENDAR_TONES, Vd as CALENDAR_VIEWS, Zf as WuiCalendar };