@wix/bookings 1.0.1780 → 1.0.1782

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 (31) hide show
  1. package/build/cjs/context-service-addons.d.ts +54 -3
  2. package/build/cjs/context-service-addons.js +1065 -578
  3. package/build/cjs/context-service-addons.js.map +1 -1
  4. package/build/cjs/context-service.d.ts +17 -0
  5. package/build/cjs/context-service.js +975 -963
  6. package/build/cjs/context-service.js.map +1 -1
  7. package/build/cjs/context-time-slots.d.ts +20 -91
  8. package/build/cjs/context-time-slots.js +456 -475
  9. package/build/cjs/context-time-slots.js.map +1 -1
  10. package/build/es/context-service-addons.d.mts +54 -3
  11. package/build/es/context-service-addons.mjs +1061 -574
  12. package/build/es/context-service-addons.mjs.map +1 -1
  13. package/build/es/context-service.d.mts +17 -0
  14. package/build/es/context-service.mjs +975 -963
  15. package/build/es/context-service.mjs.map +1 -1
  16. package/build/es/context-time-slots.d.mts +20 -91
  17. package/build/es/context-time-slots.mjs +456 -475
  18. package/build/es/context-time-slots.mjs.map +1 -1
  19. package/build/internal/cjs/context-service-addons.d.ts +54 -3
  20. package/build/internal/cjs/context-service.d.ts +17 -0
  21. package/build/internal/cjs/context-time-slots.d.ts +20 -91
  22. package/build/internal/es/context-service-addons.d.mts +54 -3
  23. package/build/internal/es/context-service.d.mts +17 -0
  24. package/build/internal/es/context-time-slots.d.mts +20 -91
  25. package/context-runtime/context-service/runtime.d.ts +17 -0
  26. package/context-runtime/context-service/runtime.js +3 -3
  27. package/context-runtime/context-service-addons/runtime.d.ts +54 -3
  28. package/context-runtime/context-service-addons/runtime.js +2 -2
  29. package/context-runtime/context-time-slots/runtime.d.ts +20 -91
  30. package/context-runtime/context-time-slots/runtime.js +3 -3
  31. package/package.json +3 -3
@@ -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.
@@ -902,7 +902,9 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
902
902
  /**
903
903
  * Sends the visitor to the booking form to book the selected time slot.
904
904
  *
905
- * Ignored when no time slot is selected, and while rescheduling a booking.
905
+ * Ignored when no time slot is selected, while rescheduling a booking, and when the selected
906
+ * time slot can't be booked, such as a full class session with an open waitlist (`bookable` is
907
+ * `false`): offer the session's waitlist instead.
906
908
  *
907
909
  * For an appointment whose staff choice is still open, the visitor books the time slot's first
908
910
  * staff member. If your component lets the visitor select a staff member, check `isComplete`
@@ -934,13 +936,6 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
934
936
  * `null` while the context's settings load, and when the context fails to load.
935
937
  */
936
938
  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
939
  /**
945
940
  * Dates in the upcoming time slots that have more time slots than `timeSlotLimitPerDay` shows.
946
941
  * To show all of a date's time slots, call `loadAllTimeSlotsForDay()`.
@@ -953,9 +948,10 @@ interface TimeSlotsContextValue extends TimeSlotsContextFields {
953
948
  * limit.
954
949
  *
955
950
  * 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.
951
+ * the date leaves `daysWithMore`, and `timeSlots` shows the day without the limit until the
952
+ * upcoming time slots reload.
957
953
  *
958
- * Ignored while a page or another day is loading, and for a date in `expandedDates`.
954
+ * Ignored while a page or another day is loading, and for a date that already shows in full.
959
955
  *
960
956
  * When the day fails to load, `errorCode` is `'upcomingSlotsLoadFailed'`.
961
957
  *
@@ -993,8 +989,7 @@ interface TimeSlotsContextFields {
993
989
  * - `'unavailable'`: The date has time slots, and none is bookable.
994
990
  * - `'none'`: The date has no time slots to show.
995
991
  *
996
- * Empty until it first loads. To load it, call `setDaysAvailabilityRange()`,
997
- * `nextDaysAvailabilityRange()`, or `previousDaysAvailabilityRange()`.
992
+ * Empty until it first loads. To load it, call `setDaysAvailabilityRange()`.
998
993
  *
999
994
  * Dates before today are `'none'`. When the context's settings show only available time slots,
1000
995
  * which they do by default, a date with only full time slots is `'none'`. While rescheduling a
@@ -1005,15 +1000,11 @@ interface TimeSlotsContextFields {
1005
1000
  readonly daysAvailabilityLoading: boolean;
1006
1001
  /** The day availability failed to load. */
1007
1002
  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
1003
  /**
1013
1004
  * Selects a date and replaces `timeSlots` with that date's time slots.
1014
1005
  *
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
1006
+ * While they load, `isLoading` is `true`. When they fail to load, `errorCode` is
1007
+ * `'timeSlotsLoadFailed'`. Today's time slots start from the current time. Selecting the
1017
1008
  * selected date again reloads its time slots.
1018
1009
  *
1019
1010
  * Ignored for a malformed date, a date before today, and a course, which has no time slots per
@@ -1025,18 +1016,18 @@ interface TimeSlotsContextFields {
1025
1016
  *
1026
1017
  * @param date - Date to select, as a local date in `YYYY-MM-DD` format.
1027
1018
  * @returns Promise that resolves once the date is selected, before its time slots load. To
1028
- * know when they load, use `timeSlotsLoading`.
1019
+ * know when they load, use `isLoading`.
1029
1020
  * @example Select a date with a date input
1030
1021
  * ```tsx
1031
1022
  * import { useTimeSlotsContext } from '@wix/bookings/context/time-slots';
1032
1023
  *
1033
1024
  * function DateInput() {
1034
- * const { selectedDate, timeSlots, timeSlotsLoading, selectDate } = useTimeSlotsContext();
1025
+ * const { selectedDate, timeSlots, isLoading, selectDate } = useTimeSlotsContext();
1035
1026
  *
1036
1027
  * return (
1037
1028
  * <div>
1038
1029
  * <input type="date" value={selectedDate ?? ''} onChange={(event) => selectDate(event.target.value)} />
1039
- * {selectedDate && <p>{timeSlotsLoading ? 'Loading times...' : `${timeSlots.length} times`}</p>}
1030
+ * {selectedDate && <p>{isLoading ? 'Loading times...' : `${timeSlots.length} times`}</p>}
1040
1031
  * </div>
1041
1032
  * );
1042
1033
  * }
@@ -1052,8 +1043,7 @@ interface TimeSlotsContextFields {
1052
1043
  *
1053
1044
  * Ignored for a malformed range, and a range that ends before it starts.
1054
1045
  *
1055
- * @param range - Dates to cover, including both ends. A range that's a calendar month moves by
1056
- * month with `nextDaysAvailabilityRange()` and `previousDaysAvailabilityRange()`.
1046
+ * @param range - Dates to cover, including both ends.
1057
1047
  * @returns Promise that resolves once the range is set, before its availability loads.
1058
1048
  * @example Show the next 7 days' availability
1059
1049
  * ```tsx
@@ -1085,64 +1075,12 @@ interface TimeSlotsContextFields {
1085
1075
  * ```
1086
1076
  */
1087
1077
  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
1078
  /**
1141
1079
  * Selects the first date with a bookable time slot, starting from the selected date, or from
1142
1080
  * today when no date is selected.
1143
1081
  *
1144
1082
  * When that date is outside `daysAvailabilityRange`, the range moves to the date's month. While
1145
- * it searches, `timeSlotsLoading` is `true`.
1083
+ * it searches, `isLoading` is `true`.
1146
1084
  *
1147
1085
  * You can call it before the context loads, such as when your component mounts. The search
1148
1086
  * waits until the service and the time zone are known. Calling `selectDate()` before the
@@ -1188,18 +1126,10 @@ interface TimeSlotsContextFields {
1188
1126
  * 2 or more services that the visitor selected.
1189
1127
  *
1190
1128
  * `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`.
1129
+ * appointment isn't valid. To check that there's availability to request, check that
1130
+ * `availabilityRequestKey` isn't `null`.
1193
1131
  */
1194
1132
  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
1133
  /**
1204
1134
  * Key that changes whenever the availability request's target changes: the service, or a
1205
1135
  * multi-service appointment's services, staff members, choices, or location. Selecting a time
@@ -1208,7 +1138,8 @@ interface TimeSlotsContextFields {
1208
1138
  * A multi-service appointment can change while your component stays on the page. To reset
1209
1139
  * state you keep about a search, such as a "no availability" message, compare this key.
1210
1140
  *
1211
- * `null` when `hasValidSchedulingInput` is `false`.
1141
+ * `null` when there's no service or valid multi-service appointment to request availability
1142
+ * for, such as when the service can't be booked online.
1212
1143
  */
1213
1144
  readonly availabilityRequestKey: string | null;
1214
1145
  /**
@@ -1420,8 +1351,6 @@ interface TimeSlotsContextFields {
1420
1351
  * For a multi-service appointment, a selected time slot is enough.
1421
1352
  */
1422
1353
  readonly isComplete: boolean;
1423
- /** Whether the selected time slot is confirmed to still be available. Always `false`. */
1424
- readonly isSelectionValidated: boolean;
1425
1354
  /** The calendar moves an existing booking (`bookingId` or `token` in its URL). */
1426
1355
  readonly isRescheduling: boolean;
1427
1356
  /**