@wix/headless-bookings 0.0.15 → 0.0.17

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 (39) hide show
  1. package/cjs/dist/api/time-slot-list/index.d.ts +21 -1
  2. package/cjs/dist/api/time-slot-list/index.js +46 -8
  3. package/cjs/dist/react/core/booking/Booking.d.ts +17 -9
  4. package/cjs/dist/react/core/booking/Booking.js +13 -7
  5. package/cjs/dist/react/core/time-slot-list/TimeSlot.d.ts +22 -18
  6. package/cjs/dist/react/core/time-slot-list/TimeSlot.js +41 -28
  7. package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +39 -7
  8. package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +56 -11
  9. package/cjs/dist/react/time-slot-list/TimeSlot.js +3 -3
  10. package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +55 -12
  11. package/cjs/dist/react/time-slot-list/TimeSlotList.js +47 -17
  12. package/cjs/dist/services/booking/booking.d.ts +48 -30
  13. package/cjs/dist/services/booking/booking.js +74 -44
  14. package/cjs/dist/services/index.d.ts +3 -3
  15. package/cjs/dist/services/service/service.js +10 -7
  16. package/cjs/dist/services/time-slot-list/index.d.ts +1 -1
  17. package/cjs/dist/services/time-slot-list/time-slot-list.d.ts +3 -3
  18. package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +23 -4
  19. package/cjs/dist/services/time-slot-list/time-slot-list.js +146 -65
  20. package/dist/api/time-slot-list/index.d.ts +21 -1
  21. package/dist/api/time-slot-list/index.js +46 -8
  22. package/dist/react/core/booking/Booking.d.ts +17 -9
  23. package/dist/react/core/booking/Booking.js +13 -7
  24. package/dist/react/core/time-slot-list/TimeSlot.d.ts +22 -18
  25. package/dist/react/core/time-slot-list/TimeSlot.js +41 -28
  26. package/dist/react/core/time-slot-list/TimeSlotList.d.ts +39 -7
  27. package/dist/react/core/time-slot-list/TimeSlotList.js +56 -11
  28. package/dist/react/time-slot-list/TimeSlot.js +3 -3
  29. package/dist/react/time-slot-list/TimeSlotList.d.ts +55 -12
  30. package/dist/react/time-slot-list/TimeSlotList.js +47 -17
  31. package/dist/services/booking/booking.d.ts +48 -30
  32. package/dist/services/booking/booking.js +74 -44
  33. package/dist/services/index.d.ts +3 -3
  34. package/dist/services/service/service.js +10 -7
  35. package/dist/services/time-slot-list/index.d.ts +1 -1
  36. package/dist/services/time-slot-list/time-slot-list.d.ts +3 -3
  37. package/dist/services/time-slot-list/time-slot-list.def.d.ts +23 -4
  38. package/dist/services/time-slot-list/time-slot-list.js +146 -65
  39. package/package.json +3 -2
@@ -1,4 +1,4 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  /**
3
3
  * TimeSlotList - High-level component for displaying time slot list information
4
4
  * Provides components for displaying timezone and time slot data
@@ -8,7 +8,7 @@ import { GenericList } from '@wix/headless-components/react';
8
8
  import { AsChildSlot } from '@wix/headless-utils/react';
9
9
  import * as CoreTimeSlotList from '../core/time-slot-list/TimeSlotList.js';
10
10
  import { TimeSlotProvider, Info as CoreTimeSlotInfo, } from '../core/time-slot-list/TimeSlot.js';
11
- import { StartDate, EndDate, Duration, Actions as TimeSlotActions, Locations, LocationRepeater, Location, StaffMembers, StaffMemberRepeater, StaffMember, } from './TimeSlot.js';
11
+ import { StartDate as TimeSlotStartDate, EndDate as TimeSlotEndDate, Duration, Actions as TimeSlotActions, Locations, LocationRepeater, Location, StaffMembers, StaffMemberRepeater, StaffMember, } from './TimeSlot.js';
12
12
  /**
13
13
  * TimeSlot with required id field for GenericList
14
14
  */
@@ -19,6 +19,7 @@ var TestIds;
19
19
  TestIds["timeSlotListTimeSlot"] = "time-slot-list-time-slot";
20
20
  TestIds["timeSlotListTimezone"] = "time-slot-list-timezone";
21
21
  TestIds["timeSlotListLoadMore"] = "time-slot-list-load-more";
22
+ TestIds["timeSlotListDateRangeInput"] = "time-slot-list-date-range-input";
22
23
  })(TestIds || (TestIds = {}));
23
24
  /**
24
25
  * Displays the current timezone with customizable rendering.
@@ -26,19 +27,14 @@ var TestIds;
26
27
  * @component
27
28
  * @example
28
29
  * ```tsx
29
- * // Default usage
30
+ * // Default usage - shows display name
30
31
  * <TimeSlotList.Timezone className="text-sm text-gray-600" />
31
32
  *
32
- * // asChild with primitive
33
+ * // asChild with render function for custom formatting
33
34
  * <TimeSlotList.Timezone asChild>
34
- * <span className="font-medium" />
35
- * </TimeSlotList.Timezone>
36
- *
37
- * // asChild with render function
38
- * <TimeSlotList.Timezone asChild>
39
- * {({ timezone }) => (
35
+ * {({ timezone, displayName }) => (
40
36
  * <span className="text-sm">
41
- * Timezone: {timezone || 'Not set'}
37
+ * {displayName} // "Eastern Standard Time"
42
38
  * </span>
43
39
  * )}
44
40
  * </TimeSlotList.Timezone>
@@ -46,7 +42,7 @@ var TestIds;
46
42
  */
47
43
  export const Timezone = React.forwardRef((props, ref) => {
48
44
  const { asChild, children, className } = props;
49
- return (_jsx(CoreTimeSlotList.Timezone, { children: ({ timezone }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotListTimezone, customElement: children, customElementProps: { timezone }, children: _jsx("span", { children: timezone }) })) }));
45
+ return (_jsx(CoreTimeSlotList.Timezone, { children: ({ timezone, displayName }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotListTimezone, customElement: children, customElementProps: { timezone, displayName }, children: _jsx("span", { children: displayName }) })) }));
50
46
  });
51
47
  Timezone.displayName = 'TimeSlotList.Timezone';
52
48
  /**
@@ -107,8 +103,8 @@ TimeSlots.displayName = 'TimeSlotList.TimeSlots';
107
103
  * Internal component that wraps each time slot item with context provider.
108
104
  * This is separate to allow using the service hook within the repeater.
109
105
  */
110
- const TimeSlotItemWrapper = ({ slot, children, }) => {
111
- return (_jsx(TimeSlotProvider, { slot: slot, children: _jsx(CoreTimeSlotInfo, { children: ({ bookable, isSelected }) => (_jsx("div", { "data-testid": TestIds.timeSlotListTimeSlot, "data-slot-start": slot.localStartDate, "data-slot-id": slot.id, "data-bookable": bookable, "data-selected": isSelected, children: children })) }) }));
106
+ const TimeSlotItemWrapper = ({ timeSlot, children, }) => {
107
+ return (_jsx(TimeSlotProvider, { timeSlot: timeSlot, children: _jsx(CoreTimeSlotInfo, { children: ({ bookable, isSelected }) => (_jsx("div", { "data-testid": TestIds.timeSlotListTimeSlot, "data-slot-start": timeSlot.localStartDate, "data-slot-id": timeSlot.id, "data-bookable": bookable, "data-selected": isSelected, children: children })) }) }));
112
108
  };
113
109
  /**
114
110
  * Repeater component that renders each time slot.
@@ -127,7 +123,7 @@ const TimeSlotItemWrapper = ({ slot, children, }) => {
127
123
  */
128
124
  export const TimeSlotRepeater = React.forwardRef((props, ref) => {
129
125
  const { children } = props;
130
- return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: ({ item: slot, children: itemChildren }) => (_jsx(TimeSlotItemWrapper, { slot: slot, children: itemChildren }, slot.id)), children: children }));
126
+ return (_jsx(GenericList.Repeater, { ref: ref, itemWrapper: ({ item: timeSlot, children: itemChildren }) => (_jsx(TimeSlotItemWrapper, { timeSlot: timeSlot, children: itemChildren }, timeSlot.id)), children: children }));
131
127
  });
132
128
  TimeSlotRepeater.displayName = 'TimeSlotList.TimeSlotRepeater';
133
129
  /**
@@ -153,6 +149,40 @@ LoadMore.displayName = 'TimeSlotList.Actions.LoadMore';
153
149
  export const Actions = {
154
150
  LoadMore,
155
151
  };
152
+ /**
153
+ * Date range input for setting the start and end date filter.
154
+ * Uses the core DateRange component to access service data.
155
+ * Both dates are set together and trigger a single fetch.
156
+ *
157
+ * @component
158
+ * @example
159
+ * ```tsx
160
+ * <TimeSlotList.DateRange.Input asChild>
161
+ * {({ startDate, endDate, onChange }) => (
162
+ * <MyDateRangePicker
163
+ * start={startDate}
164
+ * end={endDate}
165
+ * onRangeChange={(start, end) => onChange(start, end)}
166
+ * />
167
+ * )}
168
+ * </TimeSlotList.DateRange.Input>
169
+ * ```
170
+ */
171
+ export const DateRangeInput = React.forwardRef((props, ref) => {
172
+ const { asChild, children, className, ...otherProps } = props;
173
+ return (_jsx(CoreTimeSlotList.DateRange, { children: ({ startDate, endDate, setDateRange }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotListDateRangeInput, customElement: children, customElementProps: {
174
+ startDate,
175
+ endDate,
176
+ onChange: setDateRange,
177
+ }, ...otherProps, children: _jsxs("div", { children: [startDate.toLocaleDateString(), " - ", endDate.toLocaleDateString()] }) })) }));
178
+ });
179
+ DateRangeInput.displayName = 'TimeSlotList.DateRange.Input';
180
+ /**
181
+ * DateRange namespace for TimeSlotList date range filter
182
+ */
183
+ export const DateRange = {
184
+ Input: DateRangeInput,
185
+ };
156
186
  // ============================================================================
157
187
  // TimeSlot Entity Components (re-exported)
158
188
  // ============================================================================
@@ -186,8 +216,8 @@ export const Actions = {
186
216
  * ```
187
217
  */
188
218
  export const TimeSlot = {
189
- StartDate,
190
- EndDate,
219
+ StartDate: TimeSlotStartDate,
220
+ EndDate: TimeSlotEndDate,
191
221
  Duration,
192
222
  Actions: TimeSlotActions,
193
223
  Locations,
@@ -5,19 +5,31 @@
5
5
  */
6
6
  import { type Signal } from '@wix/services-definitions/core-services/signals';
7
7
  import type { Service } from '@wix/auto_sdk_bookings_services';
8
- import type { TimeSlot, Resource, NestedTimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
8
+ import type { Resource, EventInfo } from '@wix/auto_sdk_bookings_availability-time-slots';
9
9
  import type { FormValues } from '@wix/form-public';
10
10
  /**
11
- * BookingSelection contains the service AND its related selections
11
+ * Minimal time slot data for booking items
12
12
  */
13
- export interface BookingSelection {
13
+ export interface BookingItemTimeSlot {
14
+ startDate: string;
15
+ endDate: string;
16
+ totalCapacity?: number;
17
+ remainingCapacity?: number;
18
+ scheduleId?: string;
19
+ eventInfo?: EventInfo;
20
+ }
21
+ /**
22
+ * BookingItem contains the service AND its related selections
23
+ */
24
+ export interface BookingItem {
14
25
  /** Unique identifier for this booking instance (allows same service multiple times) */
15
26
  instanceId: string;
27
+ /** The selected service */
16
28
  service: Service;
17
29
  /** Selected resources (staff members, rooms, etc.) */
18
- staff?: Resource;
19
- /** Per-service slot data from nested slots (for multi-service bookings) */
20
- nestedSlotData?: NestedTimeSlot;
30
+ resources: Resource[];
31
+ /** Per-item time slot data */
32
+ timeSlot?: BookingItemTimeSlot;
21
33
  }
22
34
  export interface Location {
23
35
  id: string;
@@ -27,21 +39,25 @@ export interface Location {
27
39
  * BookingService actions - setters only, no API calls
28
40
  */
29
41
  export interface BookingServiceActions {
30
- /** Clears all booking selections and sets a single service (instanceId is auto-generated) */
31
- setService(service: Omit<BookingSelection, 'instanceId'>): string;
32
- /** Adds a service and returns the generated instanceId */
33
- addService(service: Omit<BookingSelection, 'instanceId'>): string;
34
- /** Updates a booking selection. If no instanceId provided, updates the first selection. */
35
- updateBookingSelection(updates: Partial<Omit<BookingSelection, 'instanceId'>>, instanceId?: string): void;
36
- /** Removes a booking selection. If no instanceId provided, removes the first selection. */
37
- removeBookingSelection(instanceId?: string): void;
38
- clearServices(): void;
39
- setTimeSlot(slot: TimeSlot | null): void;
40
- clearTimeSlot(): void;
42
+ /** Clears all booking items and sets a single item (instanceId is auto-generated) */
43
+ setItem(item: Omit<BookingItem, 'instanceId'>): string;
44
+ /** Adds an item and returns the generated instanceId */
45
+ addItem(item: Omit<BookingItem, 'instanceId'>): string;
46
+ /** Updates a booking item. If no instanceId provided, updates the first item. */
47
+ updateItem(updates: Partial<Omit<BookingItem, 'instanceId'>>, instanceId?: string): void;
48
+ /** Removes a booking item. If no instanceId provided, removes the first item. */
49
+ removeItem(instanceId?: string): void;
50
+ /** Clears all booking items */
51
+ clearItems(): void;
52
+ /** Sets a resource by ID within a booking item. If no instanceId provided, uses the first item. */
53
+ setResourceById(resourceId: string, resource: Resource, instanceId?: string): void;
54
+ /** Gets a resource by ID from a booking item. If no instanceId provided, uses the first item. */
55
+ getResourceById(resourceId: string, instanceId?: string): Resource | undefined;
41
56
  setLocation(location: Location | null): void;
42
57
  clearLocation(): void;
43
58
  setFormValues(values: FormValues | null): void;
44
59
  clearFormValues(): void;
60
+ setNumberOfParticipants(count: number): void;
45
61
  clearAll(): void;
46
62
  }
47
63
  /**
@@ -49,14 +65,14 @@ export interface BookingServiceActions {
49
65
  * Pure state management - no API calls
50
66
  */
51
67
  export interface BookingService {
52
- /** Signal containing the booking selections (services with their related data) */
53
- bookingSelections: Signal<BookingSelection[]>;
54
- /** Signal containing the currently selected time slot */
55
- timeSlot: Signal<TimeSlot | null>;
56
- /** Signal containing the selected location (derived from timeSlot) */
68
+ /** Signal containing the booking items (services with their related data) */
69
+ bookingItems: Signal<BookingItem[]>;
70
+ /** Signal containing the selected location */
57
71
  location: Signal<Location | null>;
58
72
  /** Signal containing the form values */
59
73
  formValues: Signal<FormValues | null>;
74
+ /** Signal containing the number of participants */
75
+ numberOfParticipants: Signal<number>;
60
76
  /** Actions for modifying booking state */
61
77
  actions: BookingServiceActions;
62
78
  }
@@ -70,15 +86,17 @@ export declare const BookingServiceDefinition: string & {
70
86
  } & BookingService;
71
87
  /**
72
88
  * Configuration interface for BookingService
73
- * Note: location is NOT in config - it's derived internally from timeSlot
89
+ * Mirrors BookingService structure (without actions and Signal wrappers)
74
90
  */
75
91
  export interface BookingServiceConfig {
76
- /** Optional initial booking selections to pre-populate */
77
- initialBookingSelections?: BookingSelection[];
78
- /** Optional initial time slot to pre-populate */
79
- initialTimeSlot?: TimeSlot | null;
92
+ /** Optional initial booking items to pre-populate */
93
+ bookingItems?: BookingItem[];
94
+ /** Optional initial location */
95
+ location?: Location | null;
80
96
  /** Optional initial form values */
81
- initialFormValues?: FormValues | null;
97
+ formValues?: FormValues | null;
98
+ /** Optional initial number of participants (defaults to 1) */
99
+ numberOfParticipants?: number;
82
100
  }
83
101
  /**
84
102
  * Implementation of BookingService
@@ -98,8 +116,8 @@ export interface BookingServiceConfig {
98
116
  *
99
117
  * // In any page - access booking data
100
118
  * <Booking.Data>
101
- * {({ services, timeSlot, location, formValues, actions }) => (
102
- * <div>{services.map(s => s.service.name).join(', ')}</div>
119
+ * {({ bookingItems, location, formValues, actions }) => (
120
+ * <div>{bookingItems.map(item => item.service.name).join(', ')}</div>
103
121
  * )}
104
122
  * </Booking.Data>
105
123
  * ```
@@ -9,7 +9,7 @@ import { SignalsServiceDefinition, } from '@wix/services-definitions/core-servic
9
9
  // Types
10
10
  // ============================================================================
11
11
  /**
12
- * Generates a unique instance ID for service selections
12
+ * Generates a unique instance ID for booking items
13
13
  */
14
14
  function generateInstanceId() {
15
15
  return crypto.randomUUID();
@@ -39,8 +39,8 @@ export const BookingServiceDefinition = defineService('booking');
39
39
  *
40
40
  * // In any page - access booking data
41
41
  * <Booking.Data>
42
- * {({ services, timeSlot, location, formValues, actions }) => (
43
- * <div>{services.map(s => s.service.name).join(', ')}</div>
42
+ * {({ bookingItems, location, formValues, actions }) => (
43
+ * <div>{bookingItems.map(item => item.service.name).join(', ')}</div>
44
44
  * )}
45
45
  * </Booking.Data>
46
46
  * ```
@@ -48,67 +48,93 @@ export const BookingServiceDefinition = defineService('booking');
48
48
  export const BookingService = implementService.withConfig()(BookingServiceDefinition, ({ getService, config }) => {
49
49
  const signalsService = getService(SignalsServiceDefinition);
50
50
  // Initialize signals with config values
51
- // Ensure all initial booking selections have instanceIds
52
- const initialSelectionsWithIds = (config.initialBookingSelections || []).map((s) => ({
53
- ...s,
54
- instanceId: s.instanceId || generateInstanceId(),
51
+ // Ensure all initial booking items have instanceIds
52
+ const initialItemsWithIds = (config.bookingItems || []).map((item) => ({
53
+ ...item,
54
+ instanceId: item.instanceId || generateInstanceId(),
55
55
  }));
56
- const bookingSelectionsSignal = signalsService.signal(initialSelectionsWithIds);
57
- const timeSlotSignal = signalsService.signal(config.initialTimeSlot || null);
58
- // Location is derived internally - initialize as null
59
- const locationSignal = signalsService.signal(null);
60
- const formValuesSignal = signalsService.signal(config.initialFormValues || null);
56
+ const bookingItemsSignal = signalsService.signal(initialItemsWithIds);
57
+ const locationSignal = signalsService.signal(config.location || null);
58
+ const formValuesSignal = signalsService.signal(config.formValues || null);
59
+ const numberOfParticipantsSignal = signalsService.signal(config.numberOfParticipants ?? 1);
61
60
  // ========================================================================
62
61
  // Actions Implementation
63
62
  // ========================================================================
64
63
  const actions = {
65
- // Services actions
66
- setService(service) {
64
+ // Item management actions
65
+ setItem(item) {
67
66
  const instanceId = generateInstanceId();
68
- const newSelection = {
69
- ...service,
67
+ const newItem = {
68
+ ...item,
70
69
  instanceId,
71
70
  };
72
- bookingSelectionsSignal.set([newSelection]);
71
+ bookingItemsSignal.set([newItem]);
73
72
  return instanceId;
74
73
  },
75
- addService(service) {
74
+ addItem(item) {
76
75
  const instanceId = generateInstanceId();
77
- const current = bookingSelectionsSignal.get();
78
- const newSelection = {
79
- ...service,
76
+ const current = bookingItemsSignal.get();
77
+ const newItem = {
78
+ ...item,
80
79
  instanceId,
81
80
  };
82
- bookingSelectionsSignal.set([...current, newSelection]);
81
+ bookingItemsSignal.set([...current, newItem]);
83
82
  return instanceId;
84
83
  },
85
- updateBookingSelection(updates, instanceId) {
86
- const current = bookingSelectionsSignal.get();
87
- // If no instanceId provided, update the first selection (index 0)
84
+ updateItem(updates, instanceId) {
85
+ const current = bookingItemsSignal.get();
86
+ // If no instanceId provided, update the first item (index 0)
88
87
  const targetId = instanceId ?? current[0]?.instanceId;
89
- const updated = current.map((s) => s.instanceId === targetId ? { ...s, ...updates } : s);
90
- bookingSelectionsSignal.set(updated);
88
+ const updated = current.map((item) => item.instanceId === targetId ? { ...item, ...updates } : item);
89
+ bookingItemsSignal.set(updated);
91
90
  },
92
- removeBookingSelection(instanceId) {
93
- const current = bookingSelectionsSignal.get();
91
+ removeItem(instanceId) {
92
+ const current = bookingItemsSignal.get();
94
93
  if (!instanceId) {
95
- // Remove first selection if no instanceId provided
96
- bookingSelectionsSignal.set(current.slice(1));
94
+ // Remove first item if no instanceId provided
95
+ bookingItemsSignal.set(current.slice(1));
97
96
  }
98
97
  else {
99
- const filtered = current.filter((s) => s.instanceId !== instanceId);
100
- bookingSelectionsSignal.set(filtered);
98
+ const filtered = current.filter((item) => item.instanceId !== instanceId);
99
+ bookingItemsSignal.set(filtered);
101
100
  }
102
101
  },
103
- clearServices() {
104
- bookingSelectionsSignal.set([]);
102
+ clearItems() {
103
+ bookingItemsSignal.set([]);
105
104
  },
106
- // Time Slot actions
107
- setTimeSlot(slot) {
108
- timeSlotSignal.set(slot);
105
+ // Resource helpers
106
+ setResourceById(resourceId, resource, instanceId) {
107
+ const current = bookingItemsSignal.get();
108
+ // If no instanceId provided, use the first item
109
+ const targetId = instanceId ?? current[0]?.instanceId;
110
+ if (!targetId)
111
+ return;
112
+ const updated = current.map((item) => {
113
+ if (item.instanceId !== targetId)
114
+ return item;
115
+ // Find and replace resource by ID, or add if not found
116
+ const existingIndex = item.resources.findIndex((r) => r._id === resourceId);
117
+ const newResources = [...item.resources];
118
+ if (existingIndex >= 0) {
119
+ newResources[existingIndex] = resource;
120
+ }
121
+ else {
122
+ newResources.push(resource);
123
+ }
124
+ return { ...item, resources: newResources };
125
+ });
126
+ bookingItemsSignal.set(updated);
109
127
  },
110
- clearTimeSlot() {
111
- timeSlotSignal.set(null);
128
+ getResourceById(resourceId, instanceId) {
129
+ const current = bookingItemsSignal.get();
130
+ // If no instanceId provided, use the first item
131
+ const targetId = instanceId ?? current[0]?.instanceId;
132
+ if (!targetId)
133
+ return undefined;
134
+ const targetItem = current.find((item) => item.instanceId === targetId);
135
+ if (!targetItem)
136
+ return undefined;
137
+ return targetItem.resources.find((r) => r._id === resourceId);
112
138
  },
113
139
  // Location actions
114
140
  setLocation(location) {
@@ -124,19 +150,23 @@ export const BookingService = implementService.withConfig()(BookingServiceDefini
124
150
  clearFormValues() {
125
151
  formValuesSignal.set(null);
126
152
  },
153
+ // Number of Participants actions
154
+ setNumberOfParticipants(count) {
155
+ numberOfParticipantsSignal.set(count);
156
+ },
127
157
  // Clear all
128
158
  clearAll() {
129
- bookingSelectionsSignal.set([]);
130
- timeSlotSignal.set(null);
159
+ bookingItemsSignal.set([]);
131
160
  locationSignal.set(null);
132
161
  formValuesSignal.set(null);
162
+ numberOfParticipantsSignal.set(1);
133
163
  },
134
164
  };
135
165
  return {
136
- bookingSelections: bookingSelectionsSignal,
137
- timeSlot: timeSlotSignal,
166
+ bookingItems: bookingItemsSignal,
138
167
  location: locationSignal,
139
168
  formValues: formValuesSignal,
169
+ numberOfParticipants: numberOfParticipantsSignal,
140
170
  actions,
141
171
  };
142
172
  });
@@ -3,6 +3,6 @@
3
3
  * Main export file for all service definitions and implementations
4
4
  */
5
5
  export { ServiceService, ServiceServiceDefinition, type ServiceServiceAPI, type ServiceServiceConfig, type ServiceActions, type ServicePaymentData, loadServiceServiceInitialData, type SuccessServiceServiceConfigResult, type NotFoundServiceServiceConfigResult, } from './service/service.js';
6
- export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type BookingSelection, type Location, type BookingServiceActions, } from './booking/booking.js';
7
- export { TimeSlotListService, TimeSlotListServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type SlotSelection, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
8
- export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
6
+ export { BookingService, BookingServiceDefinition, type BookingServiceConfig, type Location, type BookingServiceActions, } from './booking/booking.js';
7
+ export { TimeSlotListService, TimeSlotListServiceDefinition, ViewMode, loadTimeSlotListConfig, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type SlotSelection, type TimeSlot, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list/index.js';
8
+ export { ServiceListService, ServiceListServiceDefinition, type ServiceListServiceAPI, type ServiceListServiceConfig, type ServiceListFilters, type ServiceListActions, type QueryOptions, loadServiceListServiceInitialData, type SuccessServiceListServiceConfigResult, type ErrorServiceListServiceConfigResult, } from './service-list/service-list.js';
@@ -81,8 +81,8 @@ export const ServiceService = implementService.withConfig()(ServiceServiceDefini
81
81
  const currentService = serviceSignal.get();
82
82
  if (!currentService._id)
83
83
  return false;
84
- const selections = bookingService.bookingSelections.get();
85
- return selections.some((selection) => selection.service._id === currentService._id);
84
+ const bookingItems = bookingService.bookingItems.get();
85
+ return bookingItems.some(({ service }) => service._id === currentService._id);
86
86
  });
87
87
  // requiresAvailability signal - true for APPOINTMENT and CLASS types
88
88
  const requiresAvailabilitySignal = signalsService.computed(() => {
@@ -185,25 +185,28 @@ export const ServiceService = implementService.withConfig()(ServiceServiceDefini
185
185
  if (!bookableSignal.get() || !bookingService)
186
186
  return;
187
187
  const currentService = serviceSignal.get();
188
- bookingService.actions.setService({ service: currentService });
188
+ bookingService.actions.updateItem({ service: currentService });
189
189
  },
190
190
  add: () => {
191
191
  if (!bookableSignal.get() || !bookingService)
192
192
  return;
193
193
  const currentService = serviceSignal.get();
194
- bookingService.actions.addService({ service: currentService });
194
+ bookingService.actions.addItem({
195
+ service: currentService,
196
+ resources: [],
197
+ });
195
198
  },
196
199
  remove: () => {
197
200
  if (!bookableSignal.get() || !bookingService)
198
201
  return;
199
202
  const currentService = serviceSignal.get();
200
203
  // Remove all instances of this service (by serviceId)
201
- const selections = bookingService.bookingSelections.get();
202
- const instancesToRemove = selections
204
+ const bookingItems = bookingService.bookingItems.get();
205
+ const instancesToRemove = bookingItems
203
206
  .filter((s) => s.service._id === currentService._id)
204
207
  .map((s) => s.instanceId);
205
208
  instancesToRemove.forEach((instanceId) => {
206
- bookingService.actions.removeBookingSelection(instanceId);
209
+ bookingService.actions.removeItem(instanceId);
207
210
  });
208
211
  },
209
212
  };
@@ -2,5 +2,5 @@
2
2
  * TimeSlotList Service
3
3
  * Main export file for time slot list service
4
4
  */
5
- export { TimeSlotListServiceDefinition, ViewMode, type TimeSlot, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type SlotSelection, } from './time-slot-list.def.js';
5
+ export { TimeSlotListServiceDefinition, ViewMode, type TimeSlot, type TimeSlotListServiceAPI, type TimeSlotListServiceActions, type TimeSlotListServiceConfig, type TimeSlotsFilters, type SlotSelection, } from './time-slot-list.def.js';
6
6
  export { TimeSlotListService, loadTimeSlotListConfig, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list.js';
@@ -3,7 +3,7 @@
3
3
  * Manages time slot fetching, selection, and state
4
4
  */
5
5
  import type { Service } from '@wix/auto_sdk_bookings_services';
6
- import { type TimeSlotListServiceConfig, ViewMode } from './time-slot-list.def.js';
6
+ import { type TimeSlotListServiceConfig, type TimeSlotsFilters } from './time-slot-list.def.js';
7
7
  export declare const TimeSlotListService: import("@wix/services-definitions").ServiceFactory<string & {
8
8
  __api: import("./time-slot-list.def.js").TimeSlotListServiceAPI;
9
9
  __config: {};
@@ -21,8 +21,8 @@ export interface LoadTimeSlotListConfigOptions {
21
21
  endDate?: Date;
22
22
  /** Timezone for formatting (defaults to UTC) */
23
23
  timezone?: string;
24
- /** View mode (defaults to CLASSIC) */
25
- viewMode?: ViewMode;
24
+ /** Filters for narrowing down time slots */
25
+ filters?: TimeSlotsFilters;
26
26
  }
27
27
  /**
28
28
  * Result type for SSR loader - either success with config or error
@@ -3,7 +3,7 @@
3
3
  * Defines interfaces and service contract for time slot management
4
4
  */
5
5
  import type { Signal } from '@wix/services-definitions/core-services/signals';
6
- import type { TimeSlot as ApiTimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
6
+ import type { TimeSlot as ApiTimeSlot, Location } from '@wix/auto_sdk_bookings_availability-time-slots';
7
7
  import type { Service } from '@wix/auto_sdk_bookings_services';
8
8
  export declare enum ViewMode {
9
9
  CLASSIC = "classic",
@@ -42,6 +42,26 @@ export interface SlotSelection {
42
42
  locationId: string | null;
43
43
  staffMemberId: string | null;
44
44
  }
45
+ /**
46
+ * Filters for narrowing down available time slots
47
+ * Matches Wix Bookings API filter parameters
48
+ */
49
+ export interface TimeSlotsFilters {
50
+ /** Filter by specific locations */
51
+ locations?: Location[];
52
+ /** Filter by specific staff member IDs */
53
+ staffMemberIds?: string[];
54
+ /** Maximum slots to return per day (useful for calendar views) */
55
+ slotsPerDay?: number;
56
+ /** Filter by bookable status. If undefined, returns both bookable and non-bookable */
57
+ bookable?: boolean;
58
+ /** Filter by booking policy violations */
59
+ bookingPolicyViolations?: {
60
+ tooEarlyToBook?: boolean;
61
+ tooLateToBook?: boolean;
62
+ bookOnlineDisabled?: boolean;
63
+ };
64
+ }
45
65
  export interface TimeSlotListServiceConfig {
46
66
  /** Services to fetch time slots for */
47
67
  services?: Service[];
@@ -53,8 +73,8 @@ export interface TimeSlotListServiceConfig {
53
73
  endDate?: Date;
54
74
  /** Timezone for formatting */
55
75
  timezone?: string;
56
- /** View mode */
57
- viewMode?: ViewMode;
76
+ /** Filters for narrowing down time slots */
77
+ filters?: TimeSlotsFilters;
58
78
  }
59
79
  export interface TimeSlotListServiceActions {
60
80
  selectSlot: (slot: TimeSlot) => void;
@@ -71,7 +91,6 @@ export interface TimeSlotListServiceAPI {
71
91
  isLoading: Signal<boolean>;
72
92
  error: Signal<string | null>;
73
93
  hasMore: Signal<boolean>;
74
- viewMode: Signal<ViewMode>;
75
94
  startDate: Signal<Date>;
76
95
  endDate: Signal<Date>;
77
96
  timezone: Signal<string | undefined>;