@wix/bookings 1.0.1781 → 1.0.1783

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 (63) hide show
  1. package/build/cjs/context-booking-checkout.d.ts +32 -0
  2. package/build/cjs/context-booking-checkout.js +2002 -1762
  3. package/build/cjs/context-booking-checkout.js.map +1 -1
  4. package/build/cjs/context-my-booking.d.ts +2832 -0
  5. package/build/cjs/context-my-booking.js +592 -0
  6. package/build/cjs/context-my-booking.js.map +1 -0
  7. package/build/cjs/context-my-bookings.d.ts +2862 -0
  8. package/build/cjs/context-my-bookings.js +12885 -0
  9. package/build/cjs/context-my-bookings.js.map +1 -0
  10. package/build/cjs/context-service-addons.d.ts +54 -3
  11. package/build/cjs/context-service-addons.js +1065 -578
  12. package/build/cjs/context-service-addons.js.map +1 -1
  13. package/build/cjs/context-service.d.ts +35 -24
  14. package/build/cjs/context-service.js +985 -966
  15. package/build/cjs/context-service.js.map +1 -1
  16. package/build/cjs/context-time-slots.d.ts +44 -98
  17. package/build/cjs/context-time-slots.js +456 -474
  18. package/build/cjs/context-time-slots.js.map +1 -1
  19. package/build/es/context-booking-checkout.d.mts +32 -0
  20. package/build/es/context-booking-checkout.mjs +2002 -1762
  21. package/build/es/context-booking-checkout.mjs.map +1 -1
  22. package/build/es/context-my-booking.d.mts +2832 -0
  23. package/build/es/context-my-booking.mjs +562 -0
  24. package/build/es/context-my-booking.mjs.map +1 -0
  25. package/build/es/context-my-bookings.d.mts +2862 -0
  26. package/build/es/context-my-bookings.mjs +12844 -0
  27. package/build/es/context-my-bookings.mjs.map +1 -0
  28. package/build/es/context-service-addons.d.mts +54 -3
  29. package/build/es/context-service-addons.mjs +1061 -574
  30. package/build/es/context-service-addons.mjs.map +1 -1
  31. package/build/es/context-service.d.mts +35 -24
  32. package/build/es/context-service.mjs +985 -966
  33. package/build/es/context-service.mjs.map +1 -1
  34. package/build/es/context-time-slots.d.mts +44 -98
  35. package/build/es/context-time-slots.mjs +456 -474
  36. package/build/es/context-time-slots.mjs.map +1 -1
  37. package/build/internal/cjs/context-booking-checkout.d.ts +32 -0
  38. package/build/internal/cjs/context-my-booking.d.ts +2832 -0
  39. package/build/internal/cjs/context-my-bookings.d.ts +2862 -0
  40. package/build/internal/cjs/context-service-addons.d.ts +54 -3
  41. package/build/internal/cjs/context-service.d.ts +35 -24
  42. package/build/internal/cjs/context-time-slots.d.ts +44 -98
  43. package/build/internal/es/context-booking-checkout.d.mts +32 -0
  44. package/build/internal/es/context-my-booking.d.mts +2832 -0
  45. package/build/internal/es/context-my-bookings.d.mts +2862 -0
  46. package/build/internal/es/context-service-addons.d.mts +54 -3
  47. package/build/internal/es/context-service.d.mts +35 -24
  48. package/build/internal/es/context-time-slots.d.mts +44 -98
  49. package/context/my-booking/package.json +3 -0
  50. package/context/my-bookings/package.json +3 -0
  51. package/context-runtime/context-booking-checkout/runtime.d.ts +32 -0
  52. package/context-runtime/context-booking-checkout/runtime.js +3 -3
  53. package/context-runtime/context-my-booking/runtime.d.ts +2832 -0
  54. package/context-runtime/context-my-booking/runtime.js +2 -0
  55. package/context-runtime/context-my-bookings/runtime.d.ts +2862 -0
  56. package/context-runtime/context-my-bookings/runtime.js +11 -0
  57. package/context-runtime/context-service/runtime.d.ts +35 -24
  58. package/context-runtime/context-service/runtime.js +3 -3
  59. package/context-runtime/context-service-addons/runtime.d.ts +54 -3
  60. package/context-runtime/context-service-addons/runtime.js +2 -2
  61. package/context-runtime/context-time-slots/runtime.d.ts +44 -98
  62. package/context-runtime/context-time-slots/runtime.js +3 -3
  63. package/package.json +20 -4
@@ -449,7 +449,7 @@ type NextAvailableDateOutcome =
449
449
  * pricing plan, it's also the outcome when the first bookable date is after the plan's last
450
450
  * date.
451
451
  */
452
- | 'none' /** The search failed. `timeSlotsErrorCode` is `'timeSlotsLoadFailed'`. */ | 'error'
452
+ | 'none' /** The search failed. `errorCode` is `'timeSlotsLoadFailed'`. */ | 'error'
453
453
  /**
454
454
  * The search stopped before it ended, because a component called `selectDate()`, or because
455
455
  * the context was still loading its settings or failed to load.
@@ -619,7 +619,7 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
619
619
  */
620
620
  readonly timeSlots: ReadonlyArray<TimeSlotItem>;
621
621
  /**
622
- * Whether `timeSlots` is loading, or waiting to load. The same as `timeSlotsLoading`.
622
+ * Whether `timeSlots` is loading, or waiting to load.
623
623
  *
624
624
  * It's `true`:
625
625
  * - Before the context loads in the visitor's browser.
@@ -738,10 +738,15 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
738
738
  * Starts loading the upcoming time slots, which are the service's time slots from the current
739
739
  * time on, a page at a time. `timeSlots` holds them while no date is selected.
740
740
  *
741
- * Until it's called, `timeSlots` is empty while no date is selected. Calling it again has no
742
- * effect, so every component that shows the upcoming time slots can call it. After the first
743
- * call, the list reloads when the time zone or a filter changes. When the service changes, the
744
- * context starts over and the components inside it mount again, so they call it again.
741
+ * Until it's called, `timeSlots` is empty while no date is selected, and `isLoading` doesn't
742
+ * count the wait for the call. A component renders at least once before its call, so check
743
+ * `upcomingTimeSlotsRequested` too, as in the example, to show a loading state instead of an
744
+ * empty list.
745
+ *
746
+ * Calling it again has no effect, so every component that shows the upcoming time slots can call
747
+ * it. After the first call, the list reloads when the time zone or a filter changes. When the
748
+ * service changes, the context starts over and the components inside it mount again, so they
749
+ * call it again.
745
750
  *
746
751
  * A multi-service appointment, and a course whose last session has ended, have no upcoming
747
752
  * time slots. When the first page fails to load, `errorCode` is `'upcomingSlotsLoadFailed'`.
@@ -754,14 +759,15 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
754
759
  * import { useTimeSlotsContext } from '@wix/bookings/context/time-slots';
755
760
  *
756
761
  * function UpcomingSlots() {
757
- * const { timeSlots, isLoading, hasError, loadUpcomingTimeSlots } = useTimeSlotsContext();
762
+ * const { timeSlots, isLoading, hasError, loadUpcomingTimeSlots, upcomingTimeSlotsRequested } =
763
+ * useTimeSlotsContext();
758
764
  *
759
765
  * useEffect(() => {
760
766
  * void loadUpcomingTimeSlots();
761
767
  * }, [loadUpcomingTimeSlots]);
762
768
  *
763
- * if (isLoading) return <p>Loading times...</p>;
764
769
  * if (hasError && !timeSlots.length) return <p>We couldn't load the times. Try again later.</p>;
770
+ * if (!upcomingTimeSlotsRequested || isLoading) return <p>Loading times...</p>;
765
771
  * if (!timeSlots.length) return <p>No upcoming times.</p>;
766
772
  *
767
773
  * return (
@@ -775,7 +781,18 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
775
781
  * ```
776
782
  */
777
783
  readonly loadUpcomingTimeSlots: () => Promise<void>;
778
- /** Whether a component called `loadUpcomingTimeSlots()`. */
784
+ /**
785
+ * Whether a component called `loadUpcomingTimeSlots()`.
786
+ *
787
+ * Until a component calls it, `isLoading` is `false` and `timeSlots` is empty, though the list
788
+ * isn't loaded yet. A component that shows the upcoming time slots treats
789
+ * `!upcomingTimeSlotsRequested` as loading, so it doesn't show an empty list before its call.
790
+ * Once any component calls it, it's `true` for every component in the context, so one that
791
+ * mounts later shows the time slots that already loaded.
792
+ *
793
+ * When the context fails to load, it stays `false` and `hasError` is `true`, so check `hasError`
794
+ * first.
795
+ */
779
796
  readonly upcomingTimeSlotsRequested: boolean;
780
797
  /**
781
798
  * Shows the previous page of upcoming time slots in `timeSlots`, from the pages that already
@@ -902,7 +919,9 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
902
919
  /**
903
920
  * Sends the visitor to the booking form to book the selected time slot.
904
921
  *
905
- * Ignored when no time slot is selected, and while rescheduling a booking.
922
+ * Ignored when no time slot is selected, while rescheduling a booking, and when the selected
923
+ * time slot can't be booked, such as a full class session with an open waitlist (`bookable` is
924
+ * `false`): offer the session's waitlist instead.
906
925
  *
907
926
  * For an appointment whose staff choice is still open, the visitor books the time slot's first
908
927
  * staff member. If your component lets the visitor select a staff member, check `isComplete`
@@ -934,13 +953,6 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
934
953
  * `null` while the context's settings load, and when the context fails to load.
935
954
  */
936
955
  readonly timeSlotLimitPerDay: number | null;
937
- /**
938
- * Dates in the upcoming time slots that show all their time slots, after
939
- * `loadAllTimeSlotsForDay()`. Each is a local date in `YYYY-MM-DD` format.
940
- *
941
- * Empty again when the upcoming time slots reload.
942
- */
943
- readonly expandedDates: ReadonlySet<LocalDate>;
944
956
  /**
945
957
  * Dates in the upcoming time slots that have more time slots than `timeSlotLimitPerDay` shows.
946
958
  * To show all of a date's time slots, call `loadAllTimeSlotsForDay()`.
@@ -953,9 +965,10 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
953
965
  * limit.
954
966
  *
955
967
  * Call it for a date in `daysWithMore`. While the day loads, `loadingDate` is that date. Then
956
- * the date is in `expandedDates`, and `timeSlots` shows the day without the limit.
968
+ * the date leaves `daysWithMore`, and `timeSlots` shows the day without the limit until the
969
+ * upcoming time slots reload.
957
970
  *
958
- * Ignored while a page or another day is loading, and for a date in `expandedDates`.
971
+ * Ignored while a page or another day is loading, and for a date that already shows in full.
959
972
  *
960
973
  * When the day fails to load, `errorCode` is `'upcomingSlotsLoadFailed'`.
961
974
  *
@@ -993,8 +1006,7 @@ interface TimeSlotsContextFields {
993
1006
  * - `'unavailable'`: The date has time slots, and none is bookable.
994
1007
  * - `'none'`: The date has no time slots to show.
995
1008
  *
996
- * Empty until it first loads. To load it, call `setDaysAvailabilityRange()`,
997
- * `nextDaysAvailabilityRange()`, or `previousDaysAvailabilityRange()`.
1009
+ * Empty until it first loads. To load it, call `setDaysAvailabilityRange()`.
998
1010
  *
999
1011
  * Dates before today are `'none'`. When the context's settings show only available time slots,
1000
1012
  * which they do by default, a date with only full time slots is `'none'`. While rescheduling a
@@ -1005,15 +1017,11 @@ interface TimeSlotsContextFields {
1005
1017
  readonly daysAvailabilityLoading: boolean;
1006
1018
  /** The day availability failed to load. */
1007
1019
  readonly daysAvailabilityHasError: boolean;
1008
- /** Whether `timeSlots` is loading. The same as `isLoading`. */
1009
- readonly timeSlotsLoading: boolean;
1010
- /** The same as `errorCode`. */
1011
- readonly timeSlotsErrorCode: TimeSlotsErrorCode | null;
1012
1020
  /**
1013
1021
  * Selects a date and replaces `timeSlots` with that date's time slots.
1014
1022
  *
1015
- * While they load, `timeSlotsLoading` is `true`. When they fail to load, `timeSlotsErrorCode`
1016
- * is `'timeSlotsLoadFailed'`. Today's time slots start from the current time. Selecting the
1023
+ * While they load, `isLoading` is `true`. When they fail to load, `errorCode` is
1024
+ * `'timeSlotsLoadFailed'`. Today's time slots start from the current time. Selecting the
1017
1025
  * selected date again reloads its time slots.
1018
1026
  *
1019
1027
  * Ignored for a malformed date, a date before today, and a course, which has no time slots per
@@ -1025,18 +1033,18 @@ interface TimeSlotsContextFields {
1025
1033
  *
1026
1034
  * @param date - Date to select, as a local date in `YYYY-MM-DD` format.
1027
1035
  * @returns Promise that resolves once the date is selected, before its time slots load. To
1028
- * know when they load, use `timeSlotsLoading`.
1036
+ * know when they load, use `isLoading`.
1029
1037
  * @example Select a date with a date input
1030
1038
  * ```tsx
1031
1039
  * import { useTimeSlotsContext } from '@wix/bookings/context/time-slots';
1032
1040
  *
1033
1041
  * function DateInput() {
1034
- * const { selectedDate, timeSlots, timeSlotsLoading, selectDate } = useTimeSlotsContext();
1042
+ * const { selectedDate, timeSlots, isLoading, selectDate } = useTimeSlotsContext();
1035
1043
  *
1036
1044
  * return (
1037
1045
  * <div>
1038
1046
  * <input type="date" value={selectedDate ?? ''} onChange={(event) => selectDate(event.target.value)} />
1039
- * {selectedDate && <p>{timeSlotsLoading ? 'Loading times...' : `${timeSlots.length} times`}</p>}
1047
+ * {selectedDate && <p>{isLoading ? 'Loading times...' : `${timeSlots.length} times`}</p>}
1040
1048
  * </div>
1041
1049
  * );
1042
1050
  * }
@@ -1052,8 +1060,7 @@ interface TimeSlotsContextFields {
1052
1060
  *
1053
1061
  * Ignored for a malformed range, and a range that ends before it starts.
1054
1062
  *
1055
- * @param range - Dates to cover, including both ends. A range that's a calendar month moves by
1056
- * month with `nextDaysAvailabilityRange()` and `previousDaysAvailabilityRange()`.
1063
+ * @param range - Dates to cover, including both ends.
1057
1064
  * @returns Promise that resolves once the range is set, before its availability loads.
1058
1065
  * @example Show the next 7 days' availability
1059
1066
  * ```tsx
@@ -1085,64 +1092,12 @@ interface TimeSlotsContextFields {
1085
1092
  * ```
1086
1093
  */
1087
1094
  readonly setDaysAvailabilityRange: (range: LocalDateRange) => Promise<void>;
1088
- /**
1089
- * Moves `daysAvailabilityRange` forward and loads the new dates' availability.
1090
- *
1091
- * A range that's a calendar month moves to the next month. Any other range moves forward by
1092
- * its own length. Does nothing to the range while `daysAvailabilityRange` is `null`.
1093
- *
1094
- * @returns Promise that resolves once the range moves, before its availability loads.
1095
- * @example Move to the next month
1096
- * ```tsx
1097
- * import { useTimeSlotsContext } from '@wix/bookings/context/time-slots';
1098
- *
1099
- * function NextMonthButton() {
1100
- * const { daysAvailabilityRange, daysAvailabilityLoading, nextDaysAvailabilityRange } =
1101
- * useTimeSlotsContext();
1102
- *
1103
- * if (!daysAvailabilityRange) return null;
1104
- *
1105
- * return (
1106
- * <button disabled={daysAvailabilityLoading} onClick={() => nextDaysAvailabilityRange()}>
1107
- * Next month
1108
- * </button>
1109
- * );
1110
- * }
1111
- * ```
1112
- */
1113
- readonly nextDaysAvailabilityRange: () => Promise<void>;
1114
- /**
1115
- * Moves `daysAvailabilityRange` back and loads the new dates' availability.
1116
- *
1117
- * A range that's a calendar month moves to the previous month. Any other range moves back by
1118
- * its own length. Does nothing to the range while `daysAvailabilityRange` is `null`.
1119
- *
1120
- * @returns Promise that resolves once the range moves, before its availability loads.
1121
- * @example Move to the previous month
1122
- * ```tsx
1123
- * import { useTimeSlotsContext } from '@wix/bookings/context/time-slots';
1124
- *
1125
- * function PreviousMonthButton() {
1126
- * const { daysAvailabilityRange, daysAvailabilityLoading, previousDaysAvailabilityRange } =
1127
- * useTimeSlotsContext();
1128
- *
1129
- * if (!daysAvailabilityRange) return null;
1130
- *
1131
- * return (
1132
- * <button disabled={daysAvailabilityLoading} onClick={() => previousDaysAvailabilityRange()}>
1133
- * Previous month
1134
- * </button>
1135
- * );
1136
- * }
1137
- * ```
1138
- */
1139
- readonly previousDaysAvailabilityRange: () => Promise<void>;
1140
1095
  /**
1141
1096
  * Selects the first date with a bookable time slot, starting from the selected date, or from
1142
1097
  * today when no date is selected.
1143
1098
  *
1144
1099
  * When that date is outside `daysAvailabilityRange`, the range moves to the date's month. While
1145
- * it searches, `timeSlotsLoading` is `true`.
1100
+ * it searches, `isLoading` is `true`.
1146
1101
  *
1147
1102
  * You can call it before the context loads, such as when your component mounts. The search
1148
1103
  * waits until the service and the time zone are known. Calling `selectDate()` before the
@@ -1188,18 +1143,10 @@ interface TimeSlotsContextFields {
1188
1143
  * 2 or more services that the visitor selected.
1189
1144
  *
1190
1145
  * `false` while the Service context loads, and when it fails to load. `true` even when the
1191
- * appointment isn't valid. To check that there's availability to request, use
1192
- * `hasValidSchedulingInput`.
1146
+ * appointment isn't valid. To check that there's availability to request, check that
1147
+ * `availabilityRequestKey` isn't `null`.
1193
1148
  */
1194
1149
  readonly isMultiService: boolean;
1195
- /**
1196
- * Whether the context has a service or a valid multi-service appointment to request
1197
- * availability for.
1198
- *
1199
- * `false` when the service can't be booked online, and while a booking to reschedule loads or
1200
- * can't be rescheduled.
1201
- */
1202
- readonly hasValidSchedulingInput: boolean;
1203
1150
  /**
1204
1151
  * Key that changes whenever the availability request's target changes: the service, or a
1205
1152
  * multi-service appointment's services, staff members, choices, or location. Selecting a time
@@ -1208,7 +1155,8 @@ interface TimeSlotsContextFields {
1208
1155
  * A multi-service appointment can change while your component stays on the page. To reset
1209
1156
  * state you keep about a search, such as a "no availability" message, compare this key.
1210
1157
  *
1211
- * `null` when `hasValidSchedulingInput` is `false`.
1158
+ * `null` when there's no service or valid multi-service appointment to request availability
1159
+ * for, such as when the service can't be booked online.
1212
1160
  */
1213
1161
  readonly availabilityRequestKey: string | null;
1214
1162
  /**
@@ -1420,8 +1368,6 @@ interface TimeSlotsContextFields {
1420
1368
  * For a multi-service appointment, a selected time slot is enough.
1421
1369
  */
1422
1370
  readonly isComplete: boolean;
1423
- /** Whether the selected time slot is confirmed to still be available. Always `false`. */
1424
- readonly isSelectionValidated: boolean;
1425
1371
  /** The calendar moves an existing booking (`bookingId` or `token` in its URL). */
1426
1372
  readonly isRescheduling: boolean;
1427
1373
  /**