@ohhwells/bridge 0.1.21 → 0.1.23

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.d.cts CHANGED
@@ -27,6 +27,6 @@ declare function SchedulingWidget({ notifyOnConnect, initialScheduleId, insertAf
27
27
  notifyOnConnect?: boolean;
28
28
  initialScheduleId?: string | null;
29
29
  insertAfter: string;
30
- }): react_jsx_runtime.JSX.Element;
30
+ }): react_jsx_runtime.JSX.Element | null;
31
31
 
32
32
  export { OhhwellsBridge, SchedulingWidget, Toggle, ToggleGroup, ToggleGroupItem, toggleVariants };
package/dist/index.d.ts CHANGED
@@ -27,6 +27,6 @@ declare function SchedulingWidget({ notifyOnConnect, initialScheduleId, insertAf
27
27
  notifyOnConnect?: boolean;
28
28
  initialScheduleId?: string | null;
29
29
  insertAfter: string;
30
- }): react_jsx_runtime.JSX.Element;
30
+ }): react_jsx_runtime.JSX.Element | null;
31
31
 
32
32
  export { OhhwellsBridge, SchedulingWidget, Toggle, ToggleGroup, ToggleGroupItem, toggleVariants };
package/dist/index.js CHANGED
@@ -216,10 +216,10 @@ function buildTimezoneLabel(tz) {
216
216
  return tz;
217
217
  }
218
218
  }
219
- function EmptyState({ inEditor }) {
219
+ function EmptyState({ inEditor, insertAfter }) {
220
220
  const handleAddSchedule = () => {
221
221
  if (inEditor) {
222
- window.parent.postMessage({ type: "ow:scheduling-not-connected" }, "*");
222
+ window.parent.postMessage({ type: "ow:scheduling-not-connected", insertAfter }, "*");
223
223
  }
224
224
  };
225
225
  return /* @__PURE__ */ jsxs2("div", { className: "flex flex-col items-center justify-center gap-6 p-12 bg-[#FAFAF9] border-2 border-dashed border-[#E7E5E4] rounded-[10px] h-[264px] w-full box-border", children: [
@@ -444,18 +444,21 @@ function ScheduleView({ schedule, dates, selectedIdx, onSelectDate, onOpenModal
444
444
  const booked = getBookingsOnDate(cls, selectedDate);
445
445
  const available = cls.maxParticipants - booked;
446
446
  const isFull = available <= 0;
447
+ const isPrivate = cls.maxParticipants === 1;
447
448
  return /* @__PURE__ */ jsxs2("div", { children: [
448
449
  /* @__PURE__ */ jsxs2("div", { className: "flex gap-4 py-4 sm:items-center sm:gap-[60px] box-border", children: [
449
450
  /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-2 shrink-0 sm:contents", children: [
450
- /* @__PURE__ */ jsx2("div", { className: "sm:w-[120px] sm:shrink-0", children: /* @__PURE__ */ jsx2("span", { className: "font-body text-base font-bold text-(--color-dark,#200C02) block", children: formatClassTime(cls) }) }),
451
- /* @__PURE__ */ jsx2(
452
- "span",
453
- {
454
- className: "inline-flex items-center px-2 py-0.5 rounded-full border text-xs font-medium sm:hidden",
455
- style: { borderColor: "#0885FE", color: "#0885FE" },
456
- children: "GROUP"
457
- }
458
- ),
451
+ /* @__PURE__ */ jsxs2("div", { className: "flex flex-col gap-2 sm:w-[120px] sm:shrink-0", children: [
452
+ /* @__PURE__ */ jsx2("span", { className: "font-body text-base font-bold text-(--color-dark,#200C02) block", children: formatClassTime(cls) }),
453
+ /* @__PURE__ */ jsx2(
454
+ "span",
455
+ {
456
+ className: "inline-flex items-center px-2 py-0.5 rounded-full text-xs font-medium w-fit",
457
+ style: isPrivate ? { background: "#DDFBE3", color: "#199130", border: "1px solid #199130", fontWeight: 500 } : { background: "#EEEDFF", color: "#5953FF", border: "1px solid #5953FF", fontWeight: 500 },
458
+ children: isPrivate ? "PRIVATE" : "GROUP"
459
+ }
460
+ )
461
+ ] }),
459
462
  /* @__PURE__ */ jsx2("div", { className: "sm:hidden flex flex-col gap-px", children: isFull ? /* @__PURE__ */ jsx2("span", { className: "font-body text-sm text-(--color-dark,#200C02) opacity-80", children: "Full" }) : /* @__PURE__ */ jsxs2(Fragment, { children: [
460
463
  /* @__PURE__ */ jsxs2("span", { className: "font-body text-sm text-(--color-dark,#200C02) opacity-80", children: [
461
464
  available,
@@ -674,6 +677,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
674
677
  window.parent.postMessage({ type: "ow:scheduling-not-connected", insertAfter }, "*");
675
678
  }
676
679
  };
680
+ if (!inEditor && !loading && !schedule) return null;
677
681
  const sectionId = `scheduling-${insertAfter}`;
678
682
  return /* @__PURE__ */ jsxs2(
679
683
  "section",
@@ -719,7 +723,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
719
723
  ] }),
720
724
  /* @__PURE__ */ jsxs2("div", { className: "w-full flex flex-col items-end gap-3", children: [
721
725
  timezoneLabel && /* @__PURE__ */ jsx2("span", { className: "font-body text-sm font-normal text-(--color-accent,#A89B83)", children: timezoneLabel }),
722
- /* @__PURE__ */ jsx2("div", { className: "w-full p-0 sm:p-10 box-border", children: loading ? /* @__PURE__ */ jsx2(LoadingSkeleton, {}) : !schedule ? /* @__PURE__ */ jsx2(EmptyState, { inEditor }) : /* @__PURE__ */ jsx2(
726
+ /* @__PURE__ */ jsx2("div", { className: "w-full p-0 sm:p-10 box-border", children: loading ? /* @__PURE__ */ jsx2(LoadingSkeleton, {}) : !schedule ? /* @__PURE__ */ jsx2(EmptyState, { inEditor, insertAfter }) : /* @__PURE__ */ jsx2(
723
727
  ScheduleView,
724
728
  {
725
729
  schedule,
@@ -4338,9 +4342,10 @@ function initSectionsFromContent(content, removeExisting = false) {
4338
4342
  const inEditor = typeof window !== "undefined" && window.self !== window.top;
4339
4343
  if (inEditor) getSectionsTracker().textContent = raw;
4340
4344
  const pageEntries = getPageSchedulingEntries(raw);
4341
- mountSchedulingEntries(pageEntries, false);
4342
- requestAnimationFrame(() => retryMissingSchedulingMounts(pageEntries, false));
4343
- setTimeout(() => retryMissingSchedulingMounts(pageEntries, false), 250);
4345
+ const notifyForEntry = inEditor ? (e) => !e.scheduleId : false;
4346
+ mountSchedulingEntries(pageEntries, notifyForEntry);
4347
+ requestAnimationFrame(() => retryMissingSchedulingMounts(pageEntries, notifyForEntry));
4348
+ setTimeout(() => retryMissingSchedulingMounts(pageEntries, notifyForEntry), 250);
4344
4349
  } catch {
4345
4350
  }
4346
4351
  }
@@ -4399,8 +4404,9 @@ function mountSchedulingEntries(entries, notifyOnConnect = false) {
4399
4404
  const pending = entries.filter((e) => e.type === "scheduling").sort((a, b) => schedulingMountDepth(a.insertAfter) - schedulingMountDepth(b.insertAfter));
4400
4405
  for (let attempt = 0; attempt < pending.length + 1 && pending.length > 0; attempt++) {
4401
4406
  for (let i = pending.length - 1; i >= 0; i--) {
4402
- const { insertAfter, scheduleId } = pending[i];
4403
- if (mountSchedulingWidget(insertAfter, notifyOnConnect, scheduleId)) {
4407
+ const entry = pending[i];
4408
+ const shouldNotify = typeof notifyOnConnect === "function" ? notifyOnConnect(entry) : notifyOnConnect;
4409
+ if (mountSchedulingWidget(entry.insertAfter, shouldNotify, entry.scheduleId)) {
4404
4410
  pending.splice(i, 1);
4405
4411
  }
4406
4412
  }