@wix/bookings 1.0.1754 → 1.0.1756

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 (71) hide show
  1. package/_sdk-exports/context-booking-checkout/runtime.d.ts +791 -143
  2. package/_sdk-exports/context-booking-checkout/runtime.js +3 -2
  3. package/_sdk-exports/context-categories/runtime.d.ts +164 -2
  4. package/_sdk-exports/context-categories/runtime.js +2 -1
  5. package/_sdk-exports/context-locations/runtime.d.ts +186 -2
  6. package/_sdk-exports/context-locations/runtime.js +2 -1
  7. package/_sdk-exports/context-service/runtime.d.ts +1540 -144
  8. package/_sdk-exports/context-service/runtime.js +3 -2
  9. package/_sdk-exports/context-service-addons/runtime.d.ts +215 -13
  10. package/_sdk-exports/context-service-addons/runtime.js +2 -1
  11. package/_sdk-exports/context-services/runtime.d.ts +371 -77
  12. package/_sdk-exports/context-services/runtime.js +3 -2
  13. package/_sdk-exports/context-time-slots/runtime.d.ts +854 -72
  14. package/_sdk-exports/context-time-slots/runtime.js +3 -2
  15. package/build/cjs/context-booking-checkout.d.ts +791 -143
  16. package/build/cjs/context-booking-checkout.js +1759 -1640
  17. package/build/cjs/context-booking-checkout.js.map +1 -1
  18. package/build/cjs/context-categories.d.ts +164 -2
  19. package/build/cjs/context-categories.js +116 -114
  20. package/build/cjs/context-categories.js.map +1 -1
  21. package/build/cjs/context-locations.d.ts +186 -2
  22. package/build/cjs/context-locations.js +126 -124
  23. package/build/cjs/context-locations.js.map +1 -1
  24. package/build/cjs/context-service-addons.d.ts +215 -13
  25. package/build/cjs/context-service-addons.js +323 -321
  26. package/build/cjs/context-service-addons.js.map +1 -1
  27. package/build/cjs/context-service.d.ts +1540 -144
  28. package/build/cjs/context-service.js +1622 -1616
  29. package/build/cjs/context-service.js.map +1 -1
  30. package/build/cjs/context-services.d.ts +371 -77
  31. package/build/cjs/context-services.js +460 -458
  32. package/build/cjs/context-services.js.map +1 -1
  33. package/build/cjs/context-time-slots.d.ts +854 -72
  34. package/build/cjs/context-time-slots.js +1033 -1000
  35. package/build/cjs/context-time-slots.js.map +1 -1
  36. package/build/es/context-booking-checkout.d.mts +791 -143
  37. package/build/es/context-booking-checkout.mjs +1778 -1650
  38. package/build/es/context-booking-checkout.mjs.map +1 -1
  39. package/build/es/context-categories.d.mts +164 -2
  40. package/build/es/context-categories.mjs +116 -114
  41. package/build/es/context-categories.mjs.map +1 -1
  42. package/build/es/context-locations.d.mts +186 -2
  43. package/build/es/context-locations.mjs +126 -124
  44. package/build/es/context-locations.mjs.map +1 -1
  45. package/build/es/context-service-addons.d.mts +215 -13
  46. package/build/es/context-service-addons.mjs +323 -321
  47. package/build/es/context-service-addons.mjs.map +1 -1
  48. package/build/es/context-service.d.mts +1540 -144
  49. package/build/es/context-service.mjs +1622 -1616
  50. package/build/es/context-service.mjs.map +1 -1
  51. package/build/es/context-services.d.mts +371 -77
  52. package/build/es/context-services.mjs +460 -458
  53. package/build/es/context-services.mjs.map +1 -1
  54. package/build/es/context-time-slots.d.mts +854 -72
  55. package/build/es/context-time-slots.mjs +1033 -1000
  56. package/build/es/context-time-slots.mjs.map +1 -1
  57. package/build/internal/cjs/context-booking-checkout.d.ts +791 -143
  58. package/build/internal/cjs/context-categories.d.ts +164 -2
  59. package/build/internal/cjs/context-locations.d.ts +186 -2
  60. package/build/internal/cjs/context-service-addons.d.ts +215 -13
  61. package/build/internal/cjs/context-service.d.ts +1540 -144
  62. package/build/internal/cjs/context-services.d.ts +371 -77
  63. package/build/internal/cjs/context-time-slots.d.ts +854 -72
  64. package/build/internal/es/context-booking-checkout.d.mts +791 -143
  65. package/build/internal/es/context-categories.d.mts +164 -2
  66. package/build/internal/es/context-locations.d.mts +186 -2
  67. package/build/internal/es/context-service-addons.d.mts +215 -13
  68. package/build/internal/es/context-service.d.mts +1540 -144
  69. package/build/internal/es/context-services.d.mts +371 -77
  70. package/build/internal/es/context-time-slots.d.mts +854 -72
  71. package/package.json +5 -5
@@ -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-p5eQUd5f.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({