@wix/headless-bookings 0.0.12 → 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.
Files changed (77) hide show
  1. package/cjs/dist/api/index.d.ts +1 -0
  2. package/cjs/dist/api/index.js +1 -0
  3. package/cjs/dist/api/query-services/index.d.ts +6 -7
  4. package/cjs/dist/api/query-services/index.js +4 -4
  5. package/cjs/dist/api/time-slot-list/index.d.ts +53 -0
  6. package/cjs/dist/api/time-slot-list/index.js +133 -0
  7. package/cjs/dist/react/core/booking/Booking.d.ts +2 -2
  8. package/cjs/dist/react/core/location/Location.d.ts +3 -3
  9. package/cjs/dist/react/core/location/Location.js +2 -2
  10. package/cjs/dist/react/core/service/Service.d.ts +8 -8
  11. package/cjs/dist/react/core/service-list/ServiceList.d.ts +2 -2
  12. package/cjs/dist/react/core/time-slot-list/TimeSlot.d.ts +368 -0
  13. package/cjs/dist/react/core/time-slot-list/TimeSlot.js +357 -0
  14. package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +84 -0
  15. package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +68 -0
  16. package/cjs/dist/react/index.d.ts +1 -0
  17. package/cjs/dist/react/index.js +1 -0
  18. package/cjs/dist/react/location/Location.d.ts +3 -3
  19. package/cjs/dist/react/service/Service.d.ts +9 -9
  20. package/cjs/dist/react/service/Service.js +5 -5
  21. package/cjs/dist/react/service-list/ServiceList.d.ts +3 -3
  22. package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +438 -0
  23. package/cjs/dist/react/time-slot-list/TimeSlot.js +427 -0
  24. package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +209 -0
  25. package/cjs/dist/react/time-slot-list/TimeSlotList.js +199 -0
  26. package/cjs/dist/services/booking/booking.d.ts +12 -11
  27. package/cjs/dist/services/booking/booking.js +5 -3
  28. package/cjs/dist/services/index.d.ts +1 -0
  29. package/cjs/dist/services/index.js +1 -0
  30. package/cjs/dist/services/service/service.d.ts +5 -5
  31. package/cjs/dist/services/service/service.js +8 -8
  32. package/cjs/dist/services/service-list/service-list.d.ts +3 -3
  33. package/cjs/dist/services/time-slot-list/index.d.ts +6 -0
  34. package/cjs/dist/services/time-slot-list/index.js +6 -0
  35. package/cjs/dist/services/time-slot-list/time-slot-list.d.ts +58 -0
  36. package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +84 -0
  37. package/cjs/dist/services/time-slot-list/time-slot-list.def.js +17 -0
  38. package/cjs/dist/services/time-slot-list/time-slot-list.js +349 -0
  39. package/dist/api/index.d.ts +1 -0
  40. package/dist/api/index.js +1 -0
  41. package/dist/api/query-services/index.d.ts +6 -7
  42. package/dist/api/query-services/index.js +4 -4
  43. package/dist/api/time-slot-list/index.d.ts +53 -0
  44. package/dist/api/time-slot-list/index.js +133 -0
  45. package/dist/react/core/booking/Booking.d.ts +2 -2
  46. package/dist/react/core/location/Location.d.ts +3 -3
  47. package/dist/react/core/location/Location.js +2 -2
  48. package/dist/react/core/service/Service.d.ts +8 -8
  49. package/dist/react/core/service-list/ServiceList.d.ts +2 -2
  50. package/dist/react/core/time-slot-list/TimeSlot.d.ts +368 -0
  51. package/dist/react/core/time-slot-list/TimeSlot.js +357 -0
  52. package/dist/react/core/time-slot-list/TimeSlotList.d.ts +84 -0
  53. package/dist/react/core/time-slot-list/TimeSlotList.js +68 -0
  54. package/dist/react/index.d.ts +1 -0
  55. package/dist/react/index.js +1 -0
  56. package/dist/react/location/Location.d.ts +3 -3
  57. package/dist/react/service/Service.d.ts +9 -9
  58. package/dist/react/service/Service.js +5 -5
  59. package/dist/react/service-list/ServiceList.d.ts +3 -3
  60. package/dist/react/time-slot-list/TimeSlot.d.ts +438 -0
  61. package/dist/react/time-slot-list/TimeSlot.js +427 -0
  62. package/dist/react/time-slot-list/TimeSlotList.d.ts +209 -0
  63. package/dist/react/time-slot-list/TimeSlotList.js +199 -0
  64. package/dist/services/booking/booking.d.ts +12 -11
  65. package/dist/services/booking/booking.js +5 -3
  66. package/dist/services/index.d.ts +1 -0
  67. package/dist/services/index.js +1 -0
  68. package/dist/services/service/service.d.ts +5 -5
  69. package/dist/services/service/service.js +8 -8
  70. package/dist/services/service-list/service-list.d.ts +3 -3
  71. package/dist/services/time-slot-list/index.d.ts +6 -0
  72. package/dist/services/time-slot-list/index.js +6 -0
  73. package/dist/services/time-slot-list/time-slot-list.d.ts +58 -0
  74. package/dist/services/time-slot-list/time-slot-list.def.d.ts +84 -0
  75. package/dist/services/time-slot-list/time-slot-list.def.js +17 -0
  76. package/dist/services/time-slot-list/time-slot-list.js +349 -0
  77. package/package.json +2 -2
@@ -0,0 +1,438 @@
1
+ /**
2
+ * TimeSlot - Headless components for displaying time slot information within TimeSlotList
3
+ * Provides components for displaying start/end times, duration, and selection actions
4
+ *
5
+ * Note: These components must be used within TimeSlotList.TimeSlotRepeater which provides
6
+ * the necessary context. There is no public TimeSlot.Root - context is managed internally.
7
+ */
8
+ import React from 'react';
9
+ import { AsChildChildren } from '@wix/headless-utils/react';
10
+ export { TimeSlotProvider } from '../core/time-slot-list/TimeSlot.js';
11
+ export type { TimeSlotProviderProps } from '../core/time-slot-list/TimeSlot.js';
12
+ export type { LocationData, StaffMemberData, } from '../core/time-slot-list/TimeSlot.js';
13
+ /**
14
+ * Props for TimeSlot.StartDate component
15
+ */
16
+ export interface StartDateProps {
17
+ asChild?: boolean;
18
+ children?: AsChildChildren<{
19
+ startDate: string | undefined;
20
+ }>;
21
+ className?: string;
22
+ }
23
+ /**
24
+ * Displays the time slot start date/time as a raw string.
25
+ * Consumer is responsible for formatting.
26
+ *
27
+ * @component
28
+ * @example
29
+ * ```tsx
30
+ * // Default usage - displays raw localStartDate string
31
+ * <TimeSlot.StartDate className="text-foreground" />
32
+ *
33
+ * // With custom formatting
34
+ * <TimeSlot.StartDate asChild>
35
+ * {({ startDate }) => (
36
+ * <span>{formatTime(startDate)}</span>
37
+ * )}
38
+ * </TimeSlot.StartDate>
39
+ * ```
40
+ */
41
+ export declare const StartDate: React.ForwardRefExoticComponent<StartDateProps & React.RefAttributes<HTMLElement>>;
42
+ /**
43
+ * Props for TimeSlot.EndDate component
44
+ */
45
+ export interface EndDateProps {
46
+ asChild?: boolean;
47
+ children?: AsChildChildren<{
48
+ endDate: string | undefined;
49
+ }>;
50
+ className?: string;
51
+ }
52
+ /**
53
+ * Displays the time slot end date/time as a raw string.
54
+ * Consumer is responsible for formatting.
55
+ *
56
+ * @component
57
+ * @example
58
+ * ```tsx
59
+ * // Default usage - displays raw localEndDate string
60
+ * <TimeSlot.EndDate className="text-foreground" />
61
+ *
62
+ * // With custom formatting
63
+ * <TimeSlot.EndDate asChild>
64
+ * {({ endDate }) => (
65
+ * <span>{formatTime(endDate)}</span>
66
+ * )}
67
+ * </TimeSlot.EndDate>
68
+ * ```
69
+ */
70
+ export declare const EndDate: React.ForwardRefExoticComponent<EndDateProps & React.RefAttributes<HTMLElement>>;
71
+ /**
72
+ * Props for TimeSlot.Duration component
73
+ */
74
+ export interface DurationProps {
75
+ asChild?: boolean;
76
+ children?: AsChildChildren<{
77
+ durationInMinutes: number | null;
78
+ }>;
79
+ className?: string;
80
+ }
81
+ /**
82
+ * Calculates and displays the duration between start and end times in minutes.
83
+ * Returns null if start/end dates are not available.
84
+ *
85
+ * @component
86
+ * @example
87
+ * ```tsx
88
+ * // Default usage - displays raw minutes number
89
+ * <TimeSlot.Duration className="text-foreground" />
90
+ *
91
+ * // With custom formatting
92
+ * <TimeSlot.Duration asChild>
93
+ * {({ durationInMinutes }) => (
94
+ * <span>{durationInMinutes} min</span>
95
+ * )}
96
+ * </TimeSlot.Duration>
97
+ * ```
98
+ */
99
+ export declare const Duration: React.ForwardRefExoticComponent<DurationProps & React.RefAttributes<HTMLElement>>;
100
+ /**
101
+ * Props for TimeSlot.Actions.Select component
102
+ */
103
+ export interface SelectProps {
104
+ asChild?: boolean;
105
+ children?: React.ReactNode | ((props: {
106
+ isSelected: boolean;
107
+ bookable: boolean;
108
+ onClick: () => void;
109
+ }) => React.ReactNode);
110
+ className?: string;
111
+ label?: string;
112
+ }
113
+ /**
114
+ * Button to select this time slot.
115
+ *
116
+ * @component
117
+ * @example
118
+ * ```tsx
119
+ * // Default button
120
+ * <TimeSlot.Actions.Select label="Select" />
121
+ *
122
+ * // With asChild
123
+ * <TimeSlot.Actions.Select asChild>
124
+ * <button className="btn-primary">Book this slot</button>
125
+ * </TimeSlot.Actions.Select>
126
+ *
127
+ * // Using render prop pattern
128
+ * <TimeSlot.Actions.Select>
129
+ * {({ isSelected, bookable, onClick }) => (
130
+ * <button onClick={onClick} disabled={!bookable}>
131
+ * {isSelected ? 'Selected' : 'Select'}
132
+ * </button>
133
+ * )}
134
+ * </TimeSlot.Actions.Select>
135
+ * ```
136
+ */
137
+ export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
138
+ /**
139
+ * Props for TimeSlot.Actions.ClearPreferences component
140
+ */
141
+ export interface ClearPreferencesProps {
142
+ asChild?: boolean;
143
+ children?: React.ReactNode | ((props: {
144
+ onClick: () => void;
145
+ }) => React.ReactNode);
146
+ className?: string;
147
+ label?: string;
148
+ }
149
+ /**
150
+ * Button to clear location and staff preferences while keeping the slot selected.
151
+ * Only renders when at least one preference is selected AND there are multiple options.
152
+ * If it renders, clicking it will clear the preferences.
153
+ *
154
+ * @component
155
+ * @example
156
+ * ```tsx
157
+ * // Default button - only shows when there's something to clear
158
+ * <TimeSlot.Actions.ClearPreferences label="Change" />
159
+ *
160
+ * // With asChild
161
+ * <TimeSlot.Actions.ClearPreferences asChild>
162
+ * <button className="btn-secondary">Clear preferences</button>
163
+ * </TimeSlot.Actions.ClearPreferences>
164
+ *
165
+ * // Using render prop pattern
166
+ * <TimeSlot.Actions.ClearPreferences>
167
+ * {({ onClick }) => <button onClick={onClick}>Change selection</button>}
168
+ * </TimeSlot.Actions.ClearPreferences>
169
+ * ```
170
+ */
171
+ export declare const ClearPreferences: React.ForwardRefExoticComponent<ClearPreferencesProps & React.RefAttributes<HTMLButtonElement>>;
172
+ /**
173
+ * Actions namespace for TimeSlot
174
+ */
175
+ export declare const Actions: {
176
+ Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
177
+ ClearPreferences: React.ForwardRefExoticComponent<ClearPreferencesProps & React.RefAttributes<HTMLButtonElement>>;
178
+ };
179
+ /**
180
+ * Props for TimeSlot.Locations component
181
+ */
182
+ export interface LocationsProps {
183
+ children: React.ReactNode;
184
+ className?: string;
185
+ }
186
+ /**
187
+ * Container for the locations list within a time slot.
188
+ * Uses GenericList.Root to manage the locations list.
189
+ *
190
+ * @component
191
+ * @example
192
+ * ```tsx
193
+ * <TimeSlot.Locations>
194
+ * <TimeSlot.LocationRepeater>
195
+ * <TimeSlot.Location.Name />
196
+ * <TimeSlot.Location.Actions.Select />
197
+ * </TimeSlot.LocationRepeater>
198
+ * </TimeSlot.Locations>
199
+ * ```
200
+ */
201
+ export declare const Locations: React.ForwardRefExoticComponent<LocationsProps & React.RefAttributes<HTMLElement>>;
202
+ /**
203
+ * Props for TimeSlot.LocationRepeater component
204
+ */
205
+ export interface LocationRepeaterProps {
206
+ children: React.ReactNode;
207
+ }
208
+ /**
209
+ * Repeater component that renders each location.
210
+ * Follows Repeater Level pattern and uses GenericList.Repeater for consistency.
211
+ * Automatically provides Location context to children.
212
+ *
213
+ * @component
214
+ * @example
215
+ * ```tsx
216
+ * <TimeSlot.LocationRepeater>
217
+ * <div className="data-[selectable=false]:opacity-50 data-[selected=true]:bg-primary">
218
+ * <TimeSlot.Location.Name />
219
+ * <TimeSlot.Location.Actions.Select />
220
+ * </div>
221
+ * </TimeSlot.LocationRepeater>
222
+ * ```
223
+ */
224
+ export declare const LocationRepeater: React.ForwardRefExoticComponent<LocationRepeaterProps & React.RefAttributes<HTMLElement>>;
225
+ /**
226
+ * Props for TimeSlot.Location.Name component
227
+ */
228
+ export interface LocationNameProps {
229
+ asChild?: boolean;
230
+ children?: AsChildChildren<{
231
+ name: string;
232
+ }>;
233
+ className?: string;
234
+ }
235
+ /**
236
+ * Displays the location name.
237
+ *
238
+ * @component
239
+ * @example
240
+ * ```tsx
241
+ * // Default usage
242
+ * <TimeSlot.Location.Name className="text-foreground" />
243
+ *
244
+ * // With custom formatting
245
+ * <TimeSlot.Location.Name asChild>
246
+ * {({ name }) => (
247
+ * <span className="font-bold">{name || 'Unknown Location'}</span>
248
+ * )}
249
+ * </TimeSlot.Location.Name>
250
+ * ```
251
+ */
252
+ export declare const LocationName: React.ForwardRefExoticComponent<LocationNameProps & React.RefAttributes<HTMLElement>>;
253
+ /**
254
+ * Props for TimeSlot.Location.Actions.Select component
255
+ */
256
+ export interface SelectLocationProps {
257
+ asChild?: boolean;
258
+ children?: React.ReactNode | ((props: {
259
+ isSelected: boolean;
260
+ isSelectable: boolean;
261
+ onClick: () => void;
262
+ }) => React.ReactNode);
263
+ className?: string;
264
+ label?: string;
265
+ }
266
+ /**
267
+ * Button to select this location.
268
+ *
269
+ * @component
270
+ * @example
271
+ * ```tsx
272
+ * // Default button
273
+ * <TimeSlot.Location.Actions.Select label="Select" />
274
+ *
275
+ * // With asChild
276
+ * <TimeSlot.Location.Actions.Select asChild>
277
+ * <button className="btn-primary">Choose Location</button>
278
+ * </TimeSlot.Location.Actions.Select>
279
+ *
280
+ * // Using render prop pattern
281
+ * <TimeSlot.Location.Actions.Select>
282
+ * {({ isSelected, isSelectable, onClick }) => (
283
+ * <button onClick={onClick} disabled={!isSelectable}>
284
+ * {isSelected ? 'Selected' : 'Select'}
285
+ * </button>
286
+ * )}
287
+ * </TimeSlot.Location.Actions.Select>
288
+ * ```
289
+ */
290
+ export declare const SelectLocation: React.ForwardRefExoticComponent<SelectLocationProps & React.RefAttributes<HTMLButtonElement>>;
291
+ /**
292
+ * Location namespace containing components for displaying individual location data.
293
+ * These components must be used within TimeSlot.LocationRepeater.
294
+ *
295
+ * @example
296
+ * ```tsx
297
+ * <TimeSlot.LocationRepeater>
298
+ * <TimeSlot.Location.Name />
299
+ * <TimeSlot.Location.Actions.Select />
300
+ * </TimeSlot.LocationRepeater>
301
+ * ```
302
+ */
303
+ export declare const Location: {
304
+ Name: React.ForwardRefExoticComponent<LocationNameProps & React.RefAttributes<HTMLElement>>;
305
+ Actions: {
306
+ Select: React.ForwardRefExoticComponent<SelectLocationProps & React.RefAttributes<HTMLButtonElement>>;
307
+ };
308
+ };
309
+ /**
310
+ * Props for TimeSlot.StaffMembers component
311
+ */
312
+ export interface StaffMembersProps {
313
+ children: React.ReactNode;
314
+ className?: string;
315
+ }
316
+ /**
317
+ * Container for the staff members list within a time slot.
318
+ * Uses GenericList.Root to manage the staff members list.
319
+ *
320
+ * @component
321
+ * @example
322
+ * ```tsx
323
+ * <TimeSlot.StaffMembers>
324
+ * <TimeSlot.StaffMemberRepeater>
325
+ * <TimeSlot.StaffMember.Name />
326
+ * <TimeSlot.StaffMember.Actions.Select />
327
+ * </TimeSlot.StaffMemberRepeater>
328
+ * </TimeSlot.StaffMembers>
329
+ * ```
330
+ */
331
+ export declare const StaffMembers: React.ForwardRefExoticComponent<StaffMembersProps & React.RefAttributes<HTMLElement>>;
332
+ /**
333
+ * Props for TimeSlot.StaffMemberRepeater component
334
+ */
335
+ export interface StaffMemberRepeaterProps {
336
+ children: React.ReactNode;
337
+ }
338
+ /**
339
+ * Repeater component that renders each staff member.
340
+ * Follows Repeater Level pattern and uses GenericList.Repeater for consistency.
341
+ * Automatically provides StaffMember context to children.
342
+ *
343
+ * @component
344
+ * @example
345
+ * ```tsx
346
+ * <TimeSlot.StaffMemberRepeater>
347
+ * <div className="data-[selectable=false]:opacity-50 data-[selected=true]:bg-primary">
348
+ * <TimeSlot.StaffMember.Name />
349
+ * <TimeSlot.StaffMember.Actions.Select />
350
+ * </div>
351
+ * </TimeSlot.StaffMemberRepeater>
352
+ * ```
353
+ */
354
+ export declare const StaffMemberRepeater: React.ForwardRefExoticComponent<StaffMemberRepeaterProps & React.RefAttributes<HTMLElement>>;
355
+ /**
356
+ * Props for TimeSlot.StaffMember.Name component
357
+ */
358
+ export interface StaffMemberNameProps {
359
+ asChild?: boolean;
360
+ children?: AsChildChildren<{
361
+ name: string;
362
+ }>;
363
+ className?: string;
364
+ }
365
+ /**
366
+ * Displays the staff member name.
367
+ *
368
+ * @component
369
+ * @example
370
+ * ```tsx
371
+ * // Default usage
372
+ * <TimeSlot.StaffMember.Name className="text-foreground" />
373
+ *
374
+ * // With custom formatting
375
+ * <TimeSlot.StaffMember.Name asChild>
376
+ * {({ name }) => (
377
+ * <span className="font-bold">{name || 'Any Staff'}</span>
378
+ * )}
379
+ * </TimeSlot.StaffMember.Name>
380
+ * ```
381
+ */
382
+ export declare const StaffMemberName: React.ForwardRefExoticComponent<StaffMemberNameProps & React.RefAttributes<HTMLElement>>;
383
+ /**
384
+ * Props for TimeSlot.StaffMember.Actions.Select component
385
+ */
386
+ export interface SelectStaffMemberProps {
387
+ asChild?: boolean;
388
+ children?: React.ReactNode | ((props: {
389
+ isSelected: boolean;
390
+ isSelectable: boolean;
391
+ onClick: () => void;
392
+ }) => React.ReactNode);
393
+ className?: string;
394
+ label?: string;
395
+ }
396
+ /**
397
+ * Button to select this staff member.
398
+ *
399
+ * @component
400
+ * @example
401
+ * ```tsx
402
+ * // Default button
403
+ * <TimeSlot.StaffMember.Actions.Select label="Select" />
404
+ *
405
+ * // With asChild
406
+ * <TimeSlot.StaffMember.Actions.Select asChild>
407
+ * <button className="btn-primary">Choose Staff</button>
408
+ * </TimeSlot.StaffMember.Actions.Select>
409
+ *
410
+ * // Using render prop pattern
411
+ * <TimeSlot.StaffMember.Actions.Select>
412
+ * {({ isSelected, isSelectable, onClick }) => (
413
+ * <button onClick={onClick} disabled={!isSelectable}>
414
+ * {isSelected ? 'Selected' : 'Select'}
415
+ * </button>
416
+ * )}
417
+ * </TimeSlot.StaffMember.Actions.Select>
418
+ * ```
419
+ */
420
+ export declare const SelectStaffMember: React.ForwardRefExoticComponent<SelectStaffMemberProps & React.RefAttributes<HTMLButtonElement>>;
421
+ /**
422
+ * StaffMember namespace containing components for displaying individual staff member data.
423
+ * These components must be used within TimeSlot.StaffMemberRepeater.
424
+ *
425
+ * @example
426
+ * ```tsx
427
+ * <TimeSlot.StaffMemberRepeater>
428
+ * <TimeSlot.StaffMember.Name />
429
+ * <TimeSlot.StaffMember.Actions.Select />
430
+ * </TimeSlot.StaffMemberRepeater>
431
+ * ```
432
+ */
433
+ export declare const StaffMember: {
434
+ Name: React.ForwardRefExoticComponent<StaffMemberNameProps & React.RefAttributes<HTMLElement>>;
435
+ Actions: {
436
+ Select: React.ForwardRefExoticComponent<SelectStaffMemberProps & React.RefAttributes<HTMLButtonElement>>;
437
+ };
438
+ };