@opencitylabs/formio-custom-components 0.6.1 → 0.6.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.
package/dist/index.js CHANGED
@@ -5352,7 +5352,7 @@ var bt = {
5352
5352
  return `${R()}/api/availabilities/${e}/${t}?calendar_ids=${n}&available=true`;
5353
5353
  }
5354
5354
  let I = (e) => {
5355
- D([]), T([]), n({}), e && T(c.filter((t) => t.date.startsWith(e)));
5355
+ D([]), T([]), n({}), e && T((c ?? []).filter((t) => t.date.startsWith(e)));
5356
5356
  }, fe = async (e, t) => {
5357
5357
  let r = JSON.parse(e), i = Ct("SLOTS", r.date, r.calendar_ids);
5358
5358
  if (t === "manual") D([]), M(null), v(null), n({});
@@ -5364,8 +5364,8 @@ var bt = {
5364
5364
  }
5365
5365
  }
5366
5366
  try {
5367
- let e = await window.FormioHelper.anonymousCall(`availabilities/${r.date}?calendar_ids=${r.calendar_ids}`);
5368
- xt("SLOTS", i, e.data), D(e.data);
5367
+ let e = await window.FormioHelper.anonymousCall(`availabilities/${r.date}?calendar_ids=${r.calendar_ids}`), t = Array.isArray(e) ? e : e?.data ?? [];
5368
+ xt("SLOTS", i, t), D(t);
5369
5369
  } catch (e) {
5370
5370
  console.error("Errore nel caricamento degli slot:", e), S.fire({
5371
5371
  icon: "error",
@@ -5601,21 +5601,18 @@ var bt = {
5601
5601
  }, _e = (e) => {
5602
5602
  t?.root?.data?.place && N.current.setOption("eventSources", [{ events: z }]);
5603
5603
  };
5604
- async function z(e, n, r) {
5604
+ async function z(e) {
5605
5605
  try {
5606
5606
  N.current.setOption("events", []);
5607
- let r = p(e.start).format("YYYY-MM-DD"), i = new Date(e.end);
5608
- i.setDate(i.getDate() - 1);
5609
- let a = p(i).format("YYYY-MM-DD"), s = t?.root?.data?.place?.merge_availabilities ? t?.root?.data?.place?.merged_availabilities_link : null, c = s ? F(s, r, a) : de(r, a, null), l = Ct("AVAILABILITY", c), u = St("AVAILABILITY", l), d;
5610
- if (u ? (d = u, g(!1)) : (d = await window.FormioHelper.fetchAPIUrlLimit(c), xt("AVAILABILITY", l, d)), !d?.length) {
5611
- n([]), S.fire({
5612
- icon: "warning",
5613
- title: o.t("warning"),
5614
- html: o.t("no_meetings")
5615
- });
5616
- return;
5617
- }
5618
- let f = d.map((e) => ({
5607
+ let n = p(e.start).format("YYYY-MM-DD"), r = new Date(e.end);
5608
+ r.setDate(r.getDate() - 1);
5609
+ let i = p(r).format("YYYY-MM-DD"), a = t?.root?.data?.place?.merge_availabilities ? t?.root?.data?.place?.merged_availabilities_link : null, s = a ? F(a, n, i) : de(n, i, null), c = Ct("AVAILABILITY", s), l = St("AVAILABILITY", c), u;
5610
+ if (l ? (u = l, g(!1)) : (u = await window.FormioHelper.fetchAPIUrlLimit(s), xt("AVAILABILITY", c, u)), !u?.length) return S.fire({
5611
+ icon: "warning",
5612
+ title: o.t("warning"),
5613
+ html: o.t("no_meetings")
5614
+ }), [];
5615
+ let d = u.map((e) => ({
5619
5616
  id: e.opening_hour_id,
5620
5617
  allDay: !1,
5621
5618
  start: `${e.date}T${e.start_time}:00`,
@@ -5627,12 +5624,12 @@ var bt = {
5627
5624
  textColor: "#000",
5628
5625
  className: "event-slot",
5629
5626
  extendedProps: { ...e }
5630
- })), m = le(d);
5631
- N.current.setOption("slotMinTime", m.earliestStartTime), N.current.setOption("slotMaxTime", m.latestEndTime), P(d), yt(N.current, f), n(f), setTimeout(() => {
5632
- B(f);
5633
- }, 500);
5627
+ })), f = le(u);
5628
+ return N.current.setOption("slotMinTime", f.earliestStartTime), N.current.setOption("slotMaxTime", f.latestEndTime), P(u), yt(N.current, d), setTimeout(() => {
5629
+ B(d);
5630
+ }, 500), d;
5634
5631
  } catch (e) {
5635
- console.error("Errore nel caricamento disponibilità:", e), r?.(e);
5632
+ throw console.error("Errore nel caricamento disponibilità:", e), e;
5636
5633
  }
5637
5634
  }
5638
5635
  s(() => {
@@ -5674,7 +5671,7 @@ var bt = {
5674
5671
  }, []), s(() => {
5675
5672
  ne && setTimeout(() => {
5676
5673
  let e = t?.dataValue ?? t?.getValue();
5677
- console.log("savedValue", e, ne), e && m(e);
5674
+ e && m(e);
5678
5675
  }, 500);
5679
5676
  }, [ne]), /* @__PURE__ */ i(r, { children: ne && f ? /* @__PURE__ */ a("div", {
5680
5677
  className: "mx-2",