@ohhwells/bridge 0.1.21 → 0.1.22

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: [
@@ -674,6 +674,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
674
674
  window.parent.postMessage({ type: "ow:scheduling-not-connected", insertAfter }, "*");
675
675
  }
676
676
  };
677
+ if (!inEditor && !loading && !schedule) return null;
677
678
  const sectionId = `scheduling-${insertAfter}`;
678
679
  return /* @__PURE__ */ jsxs2(
679
680
  "section",
@@ -719,7 +720,7 @@ function SchedulingWidget({ notifyOnConnect = false, initialScheduleId, insertAf
719
720
  ] }),
720
721
  /* @__PURE__ */ jsxs2("div", { className: "w-full flex flex-col items-end gap-3", children: [
721
722
  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(
723
+ /* @__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
724
  ScheduleView,
724
725
  {
725
726
  schedule,
@@ -4338,9 +4339,10 @@ function initSectionsFromContent(content, removeExisting = false) {
4338
4339
  const inEditor = typeof window !== "undefined" && window.self !== window.top;
4339
4340
  if (inEditor) getSectionsTracker().textContent = raw;
4340
4341
  const pageEntries = getPageSchedulingEntries(raw);
4341
- mountSchedulingEntries(pageEntries, false);
4342
- requestAnimationFrame(() => retryMissingSchedulingMounts(pageEntries, false));
4343
- setTimeout(() => retryMissingSchedulingMounts(pageEntries, false), 250);
4342
+ const notifyForEntry = inEditor ? (e) => !e.scheduleId : false;
4343
+ mountSchedulingEntries(pageEntries, notifyForEntry);
4344
+ requestAnimationFrame(() => retryMissingSchedulingMounts(pageEntries, notifyForEntry));
4345
+ setTimeout(() => retryMissingSchedulingMounts(pageEntries, notifyForEntry), 250);
4344
4346
  } catch {
4345
4347
  }
4346
4348
  }
@@ -4399,8 +4401,9 @@ function mountSchedulingEntries(entries, notifyOnConnect = false) {
4399
4401
  const pending = entries.filter((e) => e.type === "scheduling").sort((a, b) => schedulingMountDepth(a.insertAfter) - schedulingMountDepth(b.insertAfter));
4400
4402
  for (let attempt = 0; attempt < pending.length + 1 && pending.length > 0; attempt++) {
4401
4403
  for (let i = pending.length - 1; i >= 0; i--) {
4402
- const { insertAfter, scheduleId } = pending[i];
4403
- if (mountSchedulingWidget(insertAfter, notifyOnConnect, scheduleId)) {
4404
+ const entry = pending[i];
4405
+ const shouldNotify = typeof notifyOnConnect === "function" ? notifyOnConnect(entry) : notifyOnConnect;
4406
+ if (mountSchedulingWidget(entry.insertAfter, shouldNotify, entry.scheduleId)) {
4404
4407
  pending.splice(i, 1);
4405
4408
  }
4406
4409
  }