@ohhwells/bridge 0.1.29-next.20 → 0.1.29-next.24

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/README.md CHANGED
@@ -184,6 +184,64 @@ Add `data-ohw-editable` and `data-ohw-key` to any element the studio owner shoul
184
184
 
185
185
  ---
186
186
 
187
+ ## SchedulingWidget (vibe-coder placement)
188
+
189
+ `SchedulingWidget` lets a template builder embed a scheduling/booking section directly in their template JSX, without going through the "Add Section" flow. The canvas editor treats it exactly like a dynamically-inserted scheduling widget — the studio owner can connect a schedule, switch it, and clear it.
190
+
191
+ ### Basic usage
192
+
193
+ ```tsx
194
+ import { SchedulingWidget } from '@ohhwells/bridge'
195
+
196
+ export default function ClassesPage() {
197
+ return (
198
+ <>
199
+ <PageHeader ... />
200
+ <ClassLibrary ... />
201
+ <SchedulingWidget />
202
+ <WordmarkBand ... />
203
+ </>
204
+ )
205
+ }
206
+ ```
207
+
208
+ No props are required. The widget auto-generates a stable identity via React's `useId()` so the bridge can track which schedule is connected to it across saves.
209
+
210
+ ### Props
211
+
212
+ | Prop | Type | Default | Description |
213
+ |---|---|---|---|
214
+ | `insertAfter` | `string` | auto | Stable identifier used as the tracker key. Only set this manually if you need two `SchedulingWidget`s on the same page. |
215
+ | `initialScheduleId` | `string \| null` | `undefined` | Set by the bridge internally after hydration. Do not pass this yourself. |
216
+ | `notifyOnConnect` | `boolean` | `false` | Set by the bridge internally. Do not pass this yourself. |
217
+
218
+ ### How it works
219
+
220
+ 1. The widget renders immediately with a loading skeleton.
221
+ 2. It sends `ow:request-schedule-config` to the bridge (running in the same window).
222
+ 3. The bridge looks up the tracker for a saved `scheduleId` for this widget:
223
+ - **Found** → responds with `ow:schedule-config { scheduleId }` → widget loads that schedule.
224
+ - **Not found (first time)** → bridge adopts the widget (adds it to the tracker, notifies the canvas editor), responds with `scheduleId: null` → widget shows empty state with an "Add Schedule" button.
225
+ 4. In the canvas editor, the studio owner clicks "Add Schedule" → selects a schedule → the widget updates and the connection is saved.
226
+ 5. On the live site, the widget fetches the saved schedule by ID and renders it.
227
+
228
+ ### Multiple widgets on one page
229
+
230
+ Each `SchedulingWidget` must have a unique `insertAfter` to be tracked independently:
231
+
232
+ ```tsx
233
+ <SchedulingWidget insertAfter="classes-morning" />
234
+ <SchedulingWidget insertAfter="classes-evening" />
235
+ ```
236
+
237
+ If you omit `insertAfter` on both, `useId()` auto-generates different stable IDs for each, so they are tracked separately anyway.
238
+
239
+ ### Empty state on live site
240
+
241
+ If the studio owner has never connected a schedule to this widget, it renders nothing on the live site (no empty placeholder is shown to visitors).
242
+
243
+ ---
244
+
187
245
  ## Editable states (advanced)
188
246
 
189
247
  For elements with multiple display states (e.g. a contact form with default/success/error views), wrap each state in a `data-ohw-state-view` and mark the container with `data-ohw-editable-state`: