@wix/bookings 1.0.1753 → 1.0.1755

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.
Files changed (46) hide show
  1. package/_sdk-exports/context-booking-checkout/runtime.d.ts +750 -143
  2. package/_sdk-exports/context-booking-checkout/runtime.js +2 -2
  3. package/_sdk-exports/context-categories/runtime.d.ts +164 -2
  4. package/_sdk-exports/context-locations/runtime.d.ts +186 -2
  5. package/_sdk-exports/context-service/runtime.d.ts +1499 -144
  6. package/_sdk-exports/context-service/runtime.js +2 -2
  7. package/_sdk-exports/context-service-addons/runtime.d.ts +215 -13
  8. package/_sdk-exports/context-services/runtime.d.ts +330 -77
  9. package/_sdk-exports/context-time-slots/runtime.d.ts +841 -72
  10. package/build/cjs/context-booking-checkout.d.ts +750 -143
  11. package/build/cjs/context-booking-checkout.js +1823 -1706
  12. package/build/cjs/context-booking-checkout.js.map +1 -1
  13. package/build/cjs/context-categories.d.ts +164 -2
  14. package/build/cjs/context-locations.d.ts +186 -2
  15. package/build/cjs/context-service-addons.d.ts +215 -13
  16. package/build/cjs/context-service.d.ts +1499 -144
  17. package/build/cjs/context-service.js +1234 -1230
  18. package/build/cjs/context-service.js.map +1 -1
  19. package/build/cjs/context-services.d.ts +330 -77
  20. package/build/cjs/context-time-slots.d.ts +841 -72
  21. package/build/es/context-booking-checkout.d.mts +750 -143
  22. package/build/es/context-booking-checkout.mjs +1835 -1709
  23. package/build/es/context-booking-checkout.mjs.map +1 -1
  24. package/build/es/context-categories.d.mts +164 -2
  25. package/build/es/context-locations.d.mts +186 -2
  26. package/build/es/context-service-addons.d.mts +215 -13
  27. package/build/es/context-service.d.mts +1499 -144
  28. package/build/es/context-service.mjs +1234 -1230
  29. package/build/es/context-service.mjs.map +1 -1
  30. package/build/es/context-services.d.mts +330 -77
  31. package/build/es/context-time-slots.d.mts +841 -72
  32. package/build/internal/cjs/context-booking-checkout.d.ts +750 -143
  33. package/build/internal/cjs/context-categories.d.ts +164 -2
  34. package/build/internal/cjs/context-locations.d.ts +186 -2
  35. package/build/internal/cjs/context-service-addons.d.ts +215 -13
  36. package/build/internal/cjs/context-service.d.ts +1499 -144
  37. package/build/internal/cjs/context-services.d.ts +330 -77
  38. package/build/internal/cjs/context-time-slots.d.ts +841 -72
  39. package/build/internal/es/context-booking-checkout.d.mts +750 -143
  40. package/build/internal/es/context-categories.d.mts +164 -2
  41. package/build/internal/es/context-locations.d.mts +186 -2
  42. package/build/internal/es/context-service-addons.d.mts +215 -13
  43. package/build/internal/es/context-service.d.mts +1499 -144
  44. package/build/internal/es/context-services.d.mts +330 -77
  45. package/build/internal/es/context-time-slots.d.mts +841 -72
  46. package/package.json +9 -9
@@ -65,7 +65,7 @@ declare global {
65
65
  interface SDKTypeMode {}
66
66
  }
67
67
  //#endregion
68
- //#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-Bf4TC5aj.d.mts
68
+ //#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-oLBaHt-W.d.mts
69
69
  interface V2Category {
70
70
  /**
71
71
  * Category ID.
@@ -101,22 +101,178 @@ interface CategoriesPickerFilter {
101
101
  //#region src/extensions/contexts/categories-context/categories-context.d.ts
102
102
  /** A service category as shown in a category list, with its selected state. */
103
103
  interface CategoryItem {
104
+ /**
105
+ * Category ID. Pass it to `selectCategory()` to select the category.
106
+ *
107
+ * `null` when the category has no ID. A category with no ID can't be selected, because passing
108
+ * `null` to `selectCategory()` clears the selection. Leave these items out of a category filter.
109
+ */
104
110
  categoryId: string | null;
111
+ /**
112
+ * Category name.
113
+ *
114
+ * `null` when the category has no name.
115
+ */
105
116
  categoryName: string | null;
117
+ /**
118
+ * Whether the category is selected, meaning its ID is in the page URL's `category` query
119
+ * parameter.
120
+ */
106
121
  isSelected: boolean;
107
122
  }
108
123
  /** The business service categories, the selected category, the loading and error state, and the actions to change or reload them. */
109
124
  interface CategoriesContextValue {
125
+ /**
126
+ * Service categories, sorted by their sort order. Each category holds its details, such as its
127
+ * ID, name, and sort order. To manage categories, use the
128
+ * [Categories V2
129
+ * API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/categories-v2/introduction).
130
+ *
131
+ * Holds only the categories that have bookable services. When the Data Source's settings pick
132
+ * categories, it holds only the picked categories.
133
+ *
134
+ * Empty while the categories load, and when they fail to load.
135
+ *
136
+ * Don't change the array or its items, for example by sorting the array in place. Every
137
+ * component that uses the context gets the same array.
138
+ */
110
139
  categories: Category[];
140
+ /**
141
+ * Service categories as list items, each with its ID, name, and whether it's selected. Use them
142
+ * to render a list of categories that site visitors select from.
143
+ *
144
+ * Holds the same categories as `categories`, in the same order.
145
+ */
111
146
  categoryItems: CategoryItem[];
147
+ /**
148
+ * ID of the selected category, from the page URL's `category` query parameter.
149
+ *
150
+ * It already holds the URL's category while the categories load, before `categories` fills. It
151
+ * can hold an ID that isn't in `categories`, such as an ID from an outdated link.
152
+ * `selectedCategory` is then `null`.
153
+ *
154
+ * `null` when no category is selected.
155
+ */
112
156
  selectedCategoryId: string | null;
157
+ /**
158
+ * Position of the selected category in `categories`, starting at `0`.
159
+ *
160
+ * `-1` when no category is selected, when `selectedCategoryId` isn't in `categories`, and while
161
+ * the categories load.
162
+ */
113
163
  selectedCategoryIndex: number;
164
+ /**
165
+ * Selected category, with its details, such as its ID, name, and sort order.
166
+ *
167
+ * `null` when no category is selected, when `selectedCategoryId` isn't in `categories`, and
168
+ * while the categories load.
169
+ */
114
170
  selectedCategory: Category | null;
171
+ /**
172
+ * Name of the selected category.
173
+ *
174
+ * `null` when `selectedCategory` is `null`, or when the category has no name.
175
+ */
115
176
  selectedCategoryName: string | null;
177
+ /**
178
+ * Whether `categories` holds multiple categories with an ID. Use it to hide a category filter
179
+ * when there's nothing to choose between.
180
+ *
181
+ * `false` while the categories load, and when they fail to load.
182
+ */
116
183
  hasMultipleCategories: boolean;
184
+ /**
185
+ * Whether the categories are loading. It's `true` during the first load, and while `refetch()`
186
+ * reloads them.
187
+ *
188
+ * While it's `true`, `categories` and `categoryItems` are empty, and `selectCategory()` does
189
+ * nothing.
190
+ */
117
191
  isLoading: boolean;
192
+ /**
193
+ * Whether the categories failed to load.
194
+ *
195
+ * When it's `true`, `categories` and `categoryItems` are empty. To try again, call `refetch()`.
196
+ *
197
+ * It's also `true`, with the same empty values, after a component under the context fails to
198
+ * render. Then it stays `true` until the page reloads: `refetch()` doesn't clear it, and
199
+ * `selectCategory()` does nothing.
200
+ */
118
201
  hasError: boolean;
202
+ /**
203
+ * Reloads the service categories.
204
+ *
205
+ * While they reload, `isLoading` is `true`, and `categories` and `categoryItems` are empty. The
206
+ * selected category doesn't change.
207
+ *
208
+ * Use it to try again after the categories fail to load, when `hasError` is `true`. It doesn't
209
+ * clear `hasError` when a component under the context failed to render.
210
+ *
211
+ * @example Retry loading the categories after a failure
212
+ * ```tsx
213
+ * import { useCategoriesContext } from '@wix/bookings/context/categories';
214
+ *
215
+ * function CategoriesErrorMessage() {
216
+ * const { hasError, refetch } = useCategoriesContext();
217
+ *
218
+ * if (!hasError) {
219
+ * return null;
220
+ * }
221
+ *
222
+ * return (
223
+ * <p>
224
+ * We couldn't load the service categories.{' '}
225
+ * <button onClick={() => refetch()}>Try again</button>
226
+ * </p>
227
+ * );
228
+ * }
229
+ * ```
230
+ */
119
231
  refetch: () => void;
232
+ /**
233
+ * Selects a category, or clears the selection.
234
+ *
235
+ * Selecting a category sets the page URL's `category` query parameter, which updates
236
+ * `selectedCategoryId` and the other properties about the selected category. When it changes
237
+ * the selection, `selectCategory()`:
238
+ * - Adds an entry to the browser history, so the browser's Back button returns to the previous
239
+ * selection.
240
+ * - Removes the URL's `page` query parameter, so a list of services on the page starts again
241
+ * from its first page.
242
+ * - Keeps the page's scroll position.
243
+ *
244
+ * It doesn't check that the ID is in `categories`.
245
+ *
246
+ * Does nothing while `isLoading` is `true`.
247
+ *
248
+ * @param categoryId - ID of the category to select. Pass `null` to clear the selection, such as
249
+ * for an "All services" option.
250
+ *
251
+ * @example Select a category from a dropdown
252
+ * ```tsx
253
+ * import { useCategoriesContext } from '@wix/bookings/context/categories';
254
+ *
255
+ * function CategoryDropdown() {
256
+ * const { categoryItems, selectedCategoryId, selectCategory } = useCategoriesContext();
257
+ *
258
+ * return (
259
+ * <select
260
+ * value={selectedCategoryId ?? ''}
261
+ * onChange={(event) => selectCategory(event.target.value || null)}
262
+ * >
263
+ * <option value="">All services</option>
264
+ * {categoryItems
265
+ * .filter((item) => item.categoryId)
266
+ * .map((item) => (
267
+ * <option key={item.categoryId} value={item.categoryId ?? ''}>
268
+ * {item.categoryName}
269
+ * </option>
270
+ * ))}
271
+ * </select>
272
+ * );
273
+ * }
274
+ * ```
275
+ */
120
276
  selectCategory: (categoryId: string | null) => void;
121
277
  }
122
278
  /** Props accepted by {@link CategoriesContextProvider}. */
@@ -131,7 +287,13 @@ interface CategoriesContextProviderProps {
131
287
  }
132
288
  declare const categoriesContext: React.Context<CategoriesContextValue | null>;
133
289
  declare const CATEGORIES_CONTEXT_MISSING_PROVIDER_ERROR = "useCategoriesContext must be used within CategoriesContextProvider";
134
- /** Reads the categories state; throws when no CategoriesContextProvider is above. */
290
+ /**
291
+ * The `useCategoriesContext()` hook provides access to the business's service categories and the
292
+ * category a site visitor selected. Use it to show the categories and let site visitors select one
293
+ * to filter the services on the page.
294
+ *
295
+ * It throws an error where the context isn't available.
296
+ */
135
297
  declare function useCategoriesContext(): CategoriesContextValue;
136
298
  /** Loads the business service categories and tracks the selected category in the page URL. */
137
299
  declare function CategoriesContextProvider({
@@ -65,7 +65,7 @@ declare global {
65
65
  interface SDKTypeMode {}
66
66
  }
67
67
  //#endregion
68
- //#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-Bf4TC5aj.d.mts
68
+ //#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-oLBaHt-W.d.mts
69
69
  interface V2Location extends V2LocationOptionsOneOf {
70
70
  /** Information about business locations. Required when `type` is `BUSINESS`. */
71
71
  business?: BusinessLocationOptions;
@@ -244,23 +244,200 @@ type BusinessLocation = V2Location;
244
244
  //#region src/extensions/contexts/locations-context/locations-context.d.ts
245
245
  /** A business location as shown in a location list, with its selected state. */
246
246
  interface LocationItem {
247
+ /**
248
+ * ID of the business location. Pass it to `selectLocation()` to select the location. To get or
249
+ * update the location's details, use the
250
+ * [Locations
251
+ * API](https://dev.wix.com/docs/api-reference/business-management/locations/introduction).
252
+ *
253
+ * `null` when the location has no ID.
254
+ */
247
255
  locationId: string | null;
256
+ /**
257
+ * Name of the business location.
258
+ *
259
+ * `null` when the location has no name.
260
+ */
248
261
  locationName: string | null;
262
+ /**
263
+ * Whether this is the selected location, the one whose ID is `selectedLocationId`.
264
+ *
265
+ * Always `false` when `locationId` is `null`.
266
+ */
249
267
  isSelected: boolean;
250
268
  }
251
269
  /** The bookable business locations, whether services also run at other locations, the selected location, the loading and error state, and the actions to change or reload them. */
252
270
  interface LocationsContextValue {
271
+ /**
272
+ * Business locations where the site's visible Wix Bookings services take place, sorted by name.
273
+ *
274
+ * Each item is a service location object from the
275
+ * [Services V2
276
+ * API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/introduction).
277
+ * Its `business` field holds the location's ID and name. To render a list of the locations, use
278
+ * `locationItems`, which holds the same locations in the same order.
279
+ *
280
+ * Empty while `isLoading` is `true`, and when the locations fail to load.
281
+ */
253
282
  locations: BusinessLocation[];
283
+ /**
284
+ * Locations to list, an item for each location in `locations`, in the same order.
285
+ *
286
+ * Empty while `isLoading` is `true`, and when the locations fail to load.
287
+ */
254
288
  locationItems: LocationItem[];
289
+ /**
290
+ * ID of the selected location, from the `location` query parameter in the page URL.
291
+ *
292
+ * When the page opens with the parameter, it's set right away, even while `isLoading` is
293
+ * `true`. It changes after each call to `selectLocation()`. It isn't checked against
294
+ * `locations`, so it can be an ID that matches no location. It's `'OTHER_LOCATIONS'` when the
295
+ * services at custom addresses or at customers' locations are selected, as `hasOtherLocations`
296
+ * describes.
297
+ *
298
+ * `null` when no location is selected.
299
+ */
255
300
  selectedLocationId: string | null;
301
+ /**
302
+ * Index in `locations` of the selected location.
303
+ *
304
+ * `-1` when no location in `locations` is selected. For example, when no location is selected,
305
+ * when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
306
+ */
256
307
  selectedLocationIndex: number;
308
+ /**
309
+ * Item in `locations` whose ID is `selectedLocationId`.
310
+ *
311
+ * `null` when no location in `locations` is selected. For example, when no location is
312
+ * selected, when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
313
+ */
257
314
  selectedLocation: BusinessLocation | null;
315
+ /**
316
+ * Name of the selected location.
317
+ *
318
+ * `null` when `selectedLocation` is `null`, or when the location has no name.
319
+ */
258
320
  selectedLocationName: string | null;
321
+ /**
322
+ * Whether any of the site's visible Wix Bookings services takes place at a custom address or at
323
+ * the customer's location.
324
+ *
325
+ * Use it to offer an option for those services beside the business locations. To select that
326
+ * option, pass `'OTHER_LOCATIONS'` to `selectLocation()`.
327
+ *
328
+ * `false` while `isLoading` is `true`, and when the locations fail to load.
329
+ */
259
330
  hasOtherLocations: boolean;
331
+ /**
332
+ * Whether site visitors have more than 1 location to choose from.
333
+ *
334
+ * `true` when there are at least 2 choices: each location in `locations` that has an ID, plus
335
+ * 1 more when `hasOtherLocations` is `true`. Use it to hide a location filter that has
336
+ * nothing to filter.
337
+ *
338
+ * `false` while `isLoading` is `true`, and when the locations fail to load.
339
+ */
260
340
  hasMultipleLocations: boolean;
341
+ /**
342
+ * Whether the locations are loading.
343
+ *
344
+ * `true` while the locations load when the page opens, and while `refetch()` loads them again.
345
+ * Meanwhile, `locations` and `locationItems` are empty, the values that depend on them are
346
+ * `null`, `false`, or `-1`, and `selectLocation()` does nothing. `selectedLocationId` already
347
+ * holds the location from the page URL.
348
+ */
261
349
  isLoading: boolean;
350
+ /**
351
+ * Whether the locations failed to load.
352
+ *
353
+ * When it's `true`, `isLoading` is `false`, `locations` and `locationItems` are empty, and
354
+ * `hasOtherLocations` and `hasMultipleLocations` are `false`. To try again, call `refetch()`.
355
+ *
356
+ * It's also `true`, with the same empty values, after a component under the context fails to
357
+ * render. Then it stays `true` until the page reloads: `refetch()` doesn't clear it, and
358
+ * `selectLocation()` does nothing.
359
+ */
262
360
  hasError: boolean;
361
+ /**
362
+ * Loads the locations again.
363
+ *
364
+ * While they load, `isLoading` is `true`, `locations` and `locationItems` are empty, and
365
+ * `selectLocation()` does nothing. The selected location stays the same, because it's kept in
366
+ * the page URL.
367
+ *
368
+ * Use it to try again after the locations fail to load, when `hasError` is `true`. It doesn't
369
+ * clear `hasError` when a component under the context failed to render.
370
+ *
371
+ * @example Try again after the locations fail to load
372
+ * ```tsx
373
+ * import { useLocationsContext } from '@wix/bookings/context/locations';
374
+ *
375
+ * function LocationsErrorMessage() {
376
+ * const { hasError, refetch } = useLocationsContext();
377
+ *
378
+ * if (!hasError) {
379
+ * return null;
380
+ * }
381
+ *
382
+ * return (
383
+ * <p>
384
+ * Locations couldn't load.
385
+ * <button onClick={() => refetch()}>Try again</button>
386
+ * </p>
387
+ * );
388
+ * }
389
+ * ```
390
+ */
263
391
  refetch: () => void;
392
+ /**
393
+ * Selects a location, or clears the selection.
394
+ *
395
+ * It sets the `location` query parameter in the page URL and keeps the URL's other parameters,
396
+ * except `page`, which it removes so a paged list starts again from its first page. It adds an
397
+ * entry to the browser history and doesn't scroll to the top of the page. `selectedLocationId`
398
+ * and the other selection values then update. A Services context on the same page reads the
399
+ * same parameter, so it lists the services at the new selection.
400
+ *
401
+ * Does nothing while `isLoading` is `true`, or after a component under the context fails to
402
+ * render.
403
+ *
404
+ * @param locationId - ID of the location to select, such as an item's `locationId` from
405
+ * `locationItems`. It isn't checked against `locations`.
406
+ *
407
+ * To select the services at a custom address or at the customer's location, pass
408
+ * `'OTHER_LOCATIONS'`. Offer that option only when `hasOtherLocations` is `true`.
409
+ *
410
+ * To clear the selection, pass `null` or an empty string. Either removes the `location`
411
+ * parameter.
412
+ *
413
+ * @example Choose a location from a dropdown
414
+ * ```tsx
415
+ * import { useLocationsContext } from '@wix/bookings/context/locations';
416
+ *
417
+ * function LocationDropdown() {
418
+ * const { locationItems, selectedLocationId, hasOtherLocations, isLoading, selectLocation } =
419
+ * useLocationsContext();
420
+ *
421
+ * return (
422
+ * <select
423
+ * value={selectedLocationId ?? ''}
424
+ * disabled={isLoading}
425
+ * onChange={(event) => selectLocation(event.target.value || null)}
426
+ * >
427
+ * <option value="">All locations</option>
428
+ * {locationItems.map(({ locationId, locationName }) =>
429
+ * locationId ? (
430
+ * <option key={locationId} value={locationId}>
431
+ * {locationName ?? locationId}
432
+ * </option>
433
+ * ) : null,
434
+ * )}
435
+ * {hasOtherLocations && <option value="OTHER_LOCATIONS">Other locations</option>}
436
+ * </select>
437
+ * );
438
+ * }
439
+ * ```
440
+ */
264
441
  selectLocation: (locationId: string | null) => void;
265
442
  }
266
443
  /** Props accepted by {@link LocationsContextProvider}. */
@@ -271,7 +448,14 @@ interface LocationsContextProviderProps {
271
448
  }
272
449
  declare const locationsContext: React.Context<LocationsContextValue | null>;
273
450
  declare const LOCATIONS_CONTEXT_MISSING_PROVIDER_ERROR = "useLocationsContext must be used within LocationsContextProvider";
274
- /** Reads the locations state; throws when no LocationsContextProvider is above. */
451
+ /**
452
+ * The `useLocationsContext()` hook provides access to the business locations where the site's Wix
453
+ * Bookings services take place, and to the location a site visitor selected. Use it to list the
454
+ * locations, let site visitors select a location to filter services by, and show the list's loading
455
+ * and error states.
456
+ *
457
+ * It throws an error where the context isn't available.
458
+ */
275
459
  declare function useLocationsContext(): LocationsContextValue;
276
460
  /** Loads the business locations that host bookable services, checks for services at other locations, and tracks the selected location in the page URL. */
277
461
  declare function LocationsContextProvider({