@wix/headless-bookings 0.0.13 → 0.0.14

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.
@@ -0,0 +1,368 @@
1
+ /**
2
+ * Core TimeSlot Components
3
+ * Provides low-level access to TimeSlot data via render props
4
+ *
5
+ * Note: These components must be used within TimeSlotList.TimeSlotRepeater
6
+ * which provides the TimeSlotProvider context.
7
+ */
8
+ import React from 'react';
9
+ import type { TimeSlot as TimeSlotType } from '../../../services/time-slot-list/time-slot-list.def.js';
10
+ /**
11
+ * Context value for TimeSlot components
12
+ */
13
+ export interface TimeSlotContextValue {
14
+ /** The current time slot data */
15
+ slot: TimeSlotType;
16
+ /** Whether this slot is currently selected */
17
+ isSelected: boolean;
18
+ /** Action to select this slot */
19
+ selectSlot: () => void;
20
+ }
21
+ /**
22
+ * Hook to access TimeSlot context
23
+ * @throws Error if used outside of TimeSlotProvider
24
+ */
25
+ export declare function useTimeSlotContext(): TimeSlotContextValue;
26
+ /**
27
+ * Props for TimeSlotProvider
28
+ */
29
+ export interface TimeSlotProviderProps {
30
+ children: React.ReactNode;
31
+ slot: TimeSlotType;
32
+ }
33
+ /**
34
+ * Provider component used by TimeSlotRepeater to provide context.
35
+ * Not used directly by consumers - only by TimeSlotList.TimeSlotRepeater.
36
+ */
37
+ export declare function TimeSlotProvider(props: TimeSlotProviderProps): React.ReactNode;
38
+ /**
39
+ * Context value for Location components
40
+ */
41
+ export interface LocationContextValue {
42
+ location: LocationData;
43
+ selectLocation: () => void;
44
+ }
45
+ /**
46
+ * Hook to access Location context
47
+ * @throws Error if used outside of LocationProvider
48
+ */
49
+ export declare function useLocationContext(): LocationContextValue;
50
+ /**
51
+ * Props for LocationProvider
52
+ */
53
+ export interface LocationProviderProps {
54
+ children: React.ReactNode;
55
+ location: LocationData;
56
+ }
57
+ /**
58
+ * Provider component used by LocationRepeater to provide context.
59
+ * Not used directly by consumers - only by TimeSlot.LocationRepeater.
60
+ */
61
+ export declare function LocationProvider(props: LocationProviderProps): React.ReactNode;
62
+ /**
63
+ * Context value for StaffMember components
64
+ */
65
+ export interface StaffMemberContextValue {
66
+ staffMember: StaffMemberData;
67
+ selectStaffMember: () => void;
68
+ }
69
+ /**
70
+ * Hook to access StaffMember context
71
+ * @throws Error if used outside of StaffMemberProvider
72
+ */
73
+ export declare function useStaffMemberContext(): StaffMemberContextValue;
74
+ /**
75
+ * Props for StaffMemberProvider
76
+ */
77
+ export interface StaffMemberProviderProps {
78
+ children: React.ReactNode;
79
+ staffMember: StaffMemberData;
80
+ }
81
+ /**
82
+ * Provider component used by StaffMemberRepeater to provide context.
83
+ * Not used directly by consumers - only by TimeSlot.StaffMemberRepeater.
84
+ */
85
+ export declare function StaffMemberProvider(props: StaffMemberProviderProps): React.ReactNode;
86
+ /**
87
+ * Props for Info render prop component
88
+ */
89
+ export interface InfoProps {
90
+ children: (data: {
91
+ /** Raw localStartDate string from slot */
92
+ startDate: string | undefined;
93
+ /** Raw localEndDate string from slot */
94
+ endDate: string | undefined;
95
+ /** Calculated duration in minutes (null if dates unavailable) */
96
+ durationInMinutes: number | null;
97
+ /** Whether the slot is bookable */
98
+ bookable: boolean;
99
+ /** Whether this slot is currently selected */
100
+ isSelected: boolean;
101
+ /** The raw slot object for advanced use cases */
102
+ slot: TimeSlotType;
103
+ }) => React.ReactNode;
104
+ }
105
+ /**
106
+ * Core component that provides access to time slot info via render props.
107
+ * Includes start/end dates, duration, bookable status, and selection state.
108
+ *
109
+ * @component
110
+ * @example
111
+ * ```tsx
112
+ * <TimeSlot.Info>
113
+ * {({ startDate, endDate, durationInMinutes, bookable, isSelected }) => (
114
+ * <div>
115
+ * <span>{startDate}</span>
116
+ * <span>{durationInMinutes} min</span>
117
+ * </div>
118
+ * )}
119
+ * </TimeSlot.Info>
120
+ * ```
121
+ */
122
+ export declare function Info(props: InfoProps): React.ReactNode;
123
+ /**
124
+ * Props for Actions render prop component
125
+ */
126
+ export interface ActionsProps {
127
+ children: (data: {
128
+ /** Action to select this slot */
129
+ selectSlot: () => void;
130
+ /** Action to clear preferences */
131
+ clearPreferences?: () => void;
132
+ /** The raw slot object */
133
+ slot: TimeSlotType;
134
+ /** Whether the slot is bookable */
135
+ bookable: boolean;
136
+ /** Whether this slot is currently selected */
137
+ isSelected: boolean;
138
+ }) => React.ReactNode;
139
+ }
140
+ /**
141
+ * Core component that provides slot actions via render props.
142
+ *
143
+ * @component
144
+ * @example
145
+ * ```tsx
146
+ * <TimeSlot.Actions>
147
+ * {({ selectSlot, isSelected, bookable, clearPreferences, shouldShowClearPreferences }) => (
148
+ * <div>
149
+ * <button onClick={selectSlot} disabled={!bookable}>
150
+ * {isSelected ? 'Selected' : 'Select'}
151
+ * </button>
152
+ * {shouldShowClearPreferences && (
153
+ * <button onClick={clearPreferences}>Change</button>
154
+ * )}
155
+ * </div>
156
+ * )}
157
+ * </TimeSlot.Actions>
158
+ * ```
159
+ */
160
+ export declare function Actions(props: ActionsProps): React.ReactNode;
161
+ /**
162
+ * Location data with selection state
163
+ */
164
+ export interface LocationData {
165
+ /** Location ID */
166
+ id: string;
167
+ /** Location name */
168
+ name: string;
169
+ /** Whether this location is currently selected */
170
+ isSelected: boolean;
171
+ /** Whether this location is selectable (compatible with selected staff, or no staff selected) */
172
+ isSelectable: boolean;
173
+ }
174
+ /**
175
+ * Props for Locations render prop component
176
+ */
177
+ export interface LocationsProps {
178
+ children: (data: {
179
+ /** Array of locations with selection state */
180
+ locations: LocationData[];
181
+ /** Action to select a location */
182
+ selectLocation: (locationId: string) => void;
183
+ }) => React.ReactNode;
184
+ }
185
+ /**
186
+ * Core component that provides access to time slot locations via render props.
187
+ * Extracts locations from slot.staffByLocation and enriches with name from originalSlots.
188
+ * Each location includes isSelected and isSelectable based on current selection state.
189
+ *
190
+ * @component
191
+ * @example
192
+ * ```tsx
193
+ * <CoreTimeSlot.Locations>
194
+ * {({ locations, locationsCount, selectLocation }) => (
195
+ * <GenericList.Root items={locations}>
196
+ * {children}
197
+ * </GenericList.Root>
198
+ * )}
199
+ * </CoreTimeSlot.Locations>
200
+ * ```
201
+ */
202
+ export declare function Locations(props: LocationsProps): React.ReactNode;
203
+ /**
204
+ * Props for LocationInfo render prop component
205
+ */
206
+ export interface LocationInfoProps {
207
+ children: (data: {
208
+ /** Location name */
209
+ name: string;
210
+ /** Whether this location is currently selected */
211
+ isSelected: boolean;
212
+ /** Whether this location is selectable */
213
+ isSelectable: boolean;
214
+ /** The raw location object */
215
+ location: LocationData;
216
+ }) => React.ReactNode;
217
+ }
218
+ /**
219
+ * Core component that provides access to location info via render props.
220
+ * Must be used within LocationProvider.
221
+ *
222
+ * @component
223
+ * @example
224
+ * ```tsx
225
+ * <LocationInfo>
226
+ * {({ name, isSelected, isSelectable }) => (
227
+ * <span>{name}</span>
228
+ * )}
229
+ * </LocationInfo>
230
+ * ```
231
+ */
232
+ export declare function LocationInfo(props: LocationInfoProps): React.ReactNode;
233
+ /**
234
+ * Props for LocationActions render prop component
235
+ */
236
+ export interface LocationActionsProps {
237
+ children: (data: {
238
+ /** Action to select this location */
239
+ selectLocation: () => void;
240
+ /** Whether this location is currently selected */
241
+ isSelected: boolean;
242
+ /** Whether this location is selectable */
243
+ isSelectable: boolean;
244
+ /** The raw location object */
245
+ location: LocationData;
246
+ }) => React.ReactNode;
247
+ }
248
+ /**
249
+ * Core component that provides location actions via render props.
250
+ * Must be used within LocationProvider.
251
+ *
252
+ * @component
253
+ * @example
254
+ * ```tsx
255
+ * <LocationActions>
256
+ * {({ selectLocation, isSelected, isSelectable }) => (
257
+ * <button onClick={selectLocation} disabled={!isSelectable}>
258
+ * {isSelected ? 'Selected' : 'Select'}
259
+ * </button>
260
+ * )}
261
+ * </LocationActions>
262
+ * ```
263
+ */
264
+ export declare function LocationActions(props: LocationActionsProps): React.ReactNode;
265
+ /**
266
+ * Staff member data with selection state
267
+ */
268
+ export interface StaffMemberData {
269
+ /** Staff member ID */
270
+ id: string;
271
+ /** Staff member name */
272
+ name: string;
273
+ /** Whether this staff member is currently selected */
274
+ isSelected: boolean;
275
+ /** Whether this staff member is selectable (works at selected location, or no location selected) */
276
+ isSelectable: boolean;
277
+ }
278
+ /**
279
+ * Props for StaffMembers render prop component
280
+ */
281
+ export interface StaffMembersProps {
282
+ children: (data: {
283
+ /** Array of staff members with selection state */
284
+ staffMembers: StaffMemberData[];
285
+ /** Action to select a staff member */
286
+ selectStaffMember: (staffMemberId: string) => void;
287
+ }) => React.ReactNode;
288
+ }
289
+ /**
290
+ * Core component that provides access to time slot staff members via render props.
291
+ * Extracts unique staff members from slot.staffByLocation (names already included).
292
+ * Each staff member includes isSelected and isSelectable based on current selection state.
293
+ *
294
+ * @component
295
+ * @example
296
+ * ```tsx
297
+ * <CoreTimeSlot.StaffMembers>
298
+ * {({ staffMembers, selectStaffMember }) => (
299
+ * <GenericList.Root items={staffMembers}>
300
+ * {children}
301
+ * </GenericList.Root>
302
+ * )}
303
+ * </CoreTimeSlot.StaffMembers>
304
+ * ```
305
+ */
306
+ export declare function StaffMembers(props: StaffMembersProps): React.ReactNode;
307
+ /**
308
+ * Props for StaffMemberInfo render prop component
309
+ */
310
+ export interface StaffMemberInfoProps {
311
+ children: (data: {
312
+ /** Staff member name */
313
+ name: string;
314
+ /** Whether this staff member is currently selected */
315
+ isSelected: boolean;
316
+ /** Whether this staff member is selectable */
317
+ isSelectable: boolean;
318
+ /** The raw staff member object */
319
+ staffMember: StaffMemberData;
320
+ }) => React.ReactNode;
321
+ }
322
+ /**
323
+ * Core component that provides access to staff member info via render props.
324
+ * Must be used within StaffMemberProvider.
325
+ *
326
+ * @component
327
+ * @example
328
+ * ```tsx
329
+ * <StaffMemberInfo>
330
+ * {({ name, isSelected, isSelectable }) => (
331
+ * <span>{name}</span>
332
+ * )}
333
+ * </StaffMemberInfo>
334
+ * ```
335
+ */
336
+ export declare function StaffMemberInfo(props: StaffMemberInfoProps): React.ReactNode;
337
+ /**
338
+ * Props for StaffMemberActions render prop component
339
+ */
340
+ export interface StaffMemberActionsProps {
341
+ children: (data: {
342
+ /** Action to select this staff member */
343
+ selectStaffMember: () => void;
344
+ /** Whether this staff member is currently selected */
345
+ isSelected: boolean;
346
+ /** Whether this staff member is selectable */
347
+ isSelectable: boolean;
348
+ /** The raw staff member object */
349
+ staffMember: StaffMemberData;
350
+ }) => React.ReactNode;
351
+ }
352
+ /**
353
+ * Core component that provides staff member actions via render props.
354
+ * Must be used within StaffMemberProvider.
355
+ *
356
+ * @component
357
+ * @example
358
+ * ```tsx
359
+ * <StaffMemberActions>
360
+ * {({ selectStaffMember, isSelected, isSelectable }) => (
361
+ * <button onClick={selectStaffMember} disabled={!isSelectable}>
362
+ * {isSelected ? 'Selected' : 'Select'}
363
+ * </button>
364
+ * )}
365
+ * </StaffMemberActions>
366
+ * ```
367
+ */
368
+ export declare function StaffMemberActions(props: StaffMemberActionsProps): React.ReactNode;