@wix/headless-bookings 0.0.55 → 0.0.56

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.
@@ -8,6 +8,7 @@
8
8
  import React from 'react';
9
9
  import { AsChildChildren } from '@wix/headless-utils/react';
10
10
  import type { TimeSlot as TimeSlotType } from '@wix/auto_sdk_bookings_availability-time-slots';
11
+ import * as CoreTimeSlot from '../core/time-slot-list/TimeSlot.js';
11
12
  export type { StaffMemberData } from '../core/time-slot-list/TimeSlot.js';
12
13
  /**
13
14
  * Props for TimeSlot.Root component
@@ -131,6 +132,7 @@ export interface SelectProps {
131
132
  }) => React.ReactNode);
132
133
  className?: string;
133
134
  label?: string;
135
+ onClicked?: (timeSlot: TimeSlotType) => void;
134
136
  }
135
137
  /**
136
138
  * Button to select this time slot.
@@ -150,6 +152,13 @@ export interface SelectProps {
150
152
  * <button className="btn-primary">Book this slot</button>
151
153
  * </TimeSlot.Actions.Select>
152
154
  *
155
+ * // With onClicked callback for navigation
156
+ * <TimeSlot.Actions.Select
157
+ * onClicked={(timeSlot) => {
158
+ * router.push(`/booking/confirm/${timeSlot.localStartDate}`);
159
+ * }}
160
+ * />
161
+ *
153
162
  * // Using render prop pattern
154
163
  * <TimeSlot.Actions.Select>
155
164
  * {({ isSelected, bookable, onClick }) => (
@@ -171,6 +180,7 @@ export interface ClearStaffSelectionProps {
171
180
  }) => React.ReactNode);
172
181
  className?: string;
173
182
  label?: string;
183
+ onClicked?: (timeSlot: TimeSlotType) => void;
174
184
  }
175
185
  /**
176
186
  * Button to clear staff selection while keeping the slot selected.
@@ -191,6 +201,13 @@ export interface ClearStaffSelectionProps {
191
201
  * <button className="btn-secondary">Clear staff</button>
192
202
  * </TimeSlot.Actions.ClearStaffSelection>
193
203
  *
204
+ * // With onClicked callback
205
+ * <TimeSlot.Actions.ClearStaffSelection
206
+ * onClicked={(timeSlot) => {
207
+ * console.log('Staff selection cleared for', timeSlot.localStartDate);
208
+ * }}
209
+ * />
210
+ *
194
211
  * // Using render prop pattern
195
212
  * <TimeSlot.Actions.ClearStaffSelection>
196
213
  * {({ onClick }) => <button onClick={onClick}>Change selection</button>}
@@ -324,6 +341,7 @@ export interface SelectStaffMemberProps {
324
341
  }) => React.ReactNode);
325
342
  className?: string;
326
343
  label?: string;
344
+ onClicked?: (staffMember: CoreTimeSlot.StaffMemberData) => void;
327
345
  }
328
346
  /**
329
347
  * Button to select this staff member.
@@ -343,6 +361,13 @@ export interface SelectStaffMemberProps {
343
361
  * <button className="btn-primary">Choose Staff</button>
344
362
  * </TimeSlot.StaffMember.Actions.Select>
345
363
  *
364
+ * // With onClicked callback
365
+ * <TimeSlot.StaffMember.Actions.Select
366
+ * onClicked={(staffMember) => {
367
+ * console.log('Selected staff:', staffMember.name);
368
+ * }}
369
+ * />
370
+ *
346
371
  * // Using render prop pattern
347
372
  * <TimeSlot.StaffMember.Actions.Select>
348
373
  * {({ isSelected, onClick }) => (
@@ -139,6 +139,13 @@ Duration.displayName = 'TimeSlot.Duration';
139
139
  * <button className="btn-primary">Book this slot</button>
140
140
  * </TimeSlot.Actions.Select>
141
141
  *
142
+ * // With onClicked callback for navigation
143
+ * <TimeSlot.Actions.Select
144
+ * onClicked={(timeSlot) => {
145
+ * router.push(`/booking/confirm/${timeSlot.localStartDate}`);
146
+ * }}
147
+ * />
148
+ *
142
149
  * // Using render prop pattern
143
150
  * <TimeSlot.Actions.Select>
144
151
  * {({ isSelected, bookable, onClick }) => (
@@ -150,14 +157,18 @@ Duration.displayName = 'TimeSlot.Duration';
150
157
  * ```
151
158
  */
152
159
  export const Select = React.forwardRef((props, ref) => {
153
- const { asChild, children, className, label = 'Select' } = props;
154
- return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, isSelected, bookable }) => {
160
+ const { asChild, children, className, label = 'Select', onClicked } = props;
161
+ return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, isSelected, bookable, timeSlot }) => {
162
+ const handleClick = () => {
163
+ selectTimeSlot();
164
+ onClicked?.(timeSlot);
165
+ };
155
166
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionSelect, "data-selected": isSelected, "data-bookable": bookable, customElement: children, customElementProps: {
156
- onClick: selectTimeSlot,
167
+ onClick: handleClick,
157
168
  disabled: !bookable,
158
169
  isSelected,
159
170
  bookable,
160
- }, children: _jsx("button", { onClick: selectTimeSlot, disabled: !bookable, children: label }) }));
171
+ }, children: _jsx("button", { onClick: handleClick, disabled: !bookable, children: label }) }));
161
172
  } }));
162
173
  });
163
174
  Select.displayName = 'TimeSlot.Actions.Select';
@@ -180,6 +191,13 @@ Select.displayName = 'TimeSlot.Actions.Select';
180
191
  * <button className="btn-secondary">Clear staff</button>
181
192
  * </TimeSlot.Actions.ClearStaffSelection>
182
193
  *
194
+ * // With onClicked callback
195
+ * <TimeSlot.Actions.ClearStaffSelection
196
+ * onClicked={(timeSlot) => {
197
+ * console.log('Staff selection cleared for', timeSlot.localStartDate);
198
+ * }}
199
+ * />
200
+ *
183
201
  * // Using render prop pattern
184
202
  * <TimeSlot.Actions.ClearStaffSelection>
185
203
  * {({ onClick }) => <button onClick={onClick}>Change selection</button>}
@@ -187,14 +205,18 @@ Select.displayName = 'TimeSlot.Actions.Select';
187
205
  * ```
188
206
  */
189
207
  export const ClearStaffSelection = React.forwardRef((props, ref) => {
190
- const { asChild, children, className, label = 'Change' } = props;
191
- return (_jsx(CoreTimeSlot.Actions, { children: ({ clearStaffSelection }) => {
208
+ const { asChild, children, className, label = 'Change', onClicked } = props;
209
+ return (_jsx(CoreTimeSlot.Actions, { children: ({ clearStaffSelection, timeSlot }) => {
192
210
  if (!clearStaffSelection) {
193
211
  return null;
194
212
  }
213
+ const handleClick = () => {
214
+ clearStaffSelection();
215
+ onClicked?.(timeSlot);
216
+ };
195
217
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionClearStaffSelection, customElement: children, customElementProps: {
196
- onClick: clearStaffSelection,
197
- }, children: _jsx("button", { onClick: clearStaffSelection, children: label }) }));
218
+ onClick: handleClick,
219
+ }, children: _jsx("button", { onClick: handleClick, children: label }) }));
198
220
  } }));
199
221
  });
200
222
  ClearStaffSelection.displayName = 'TimeSlot.Actions.ClearStaffSelection';
@@ -324,6 +346,13 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
324
346
  * <button className="btn-primary">Choose Staff</button>
325
347
  * </TimeSlot.StaffMember.Actions.Select>
326
348
  *
349
+ * // With onClicked callback
350
+ * <TimeSlot.StaffMember.Actions.Select
351
+ * onClicked={(staffMember) => {
352
+ * console.log('Selected staff:', staffMember.name);
353
+ * }}
354
+ * />
355
+ *
327
356
  * // Using render prop pattern
328
357
  * <TimeSlot.StaffMember.Actions.Select>
329
358
  * {({ isSelected, onClick }) => (
@@ -335,11 +364,17 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
335
364
  * ```
336
365
  */
337
366
  export const SelectStaffMember = React.forwardRef((props, ref) => {
338
- const { asChild, children, className, label = 'Select' } = props;
339
- return (_jsx(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
340
- onClick: selectStaffMember,
341
- isSelected,
342
- }, children: _jsx("button", { onClick: selectStaffMember, children: label }) })) }));
367
+ const { asChild, children, className, label = 'Select', onClicked } = props;
368
+ return (_jsx(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected, staffMember }) => {
369
+ const handleClick = () => {
370
+ selectStaffMember();
371
+ onClicked?.(staffMember);
372
+ };
373
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
374
+ onClick: handleClick,
375
+ isSelected,
376
+ }, children: _jsx("button", { onClick: handleClick, children: label }) }));
377
+ } }));
343
378
  });
344
379
  SelectStaffMember.displayName = 'TimeSlot.StaffMember.Actions.Select';
345
380
  /**
@@ -8,6 +8,7 @@
8
8
  import React from 'react';
9
9
  import { AsChildChildren } from '@wix/headless-utils/react';
10
10
  import type { TimeSlot as TimeSlotType } from '@wix/auto_sdk_bookings_availability-time-slots';
11
+ import * as CoreTimeSlot from '../core/time-slot-list/TimeSlot.js';
11
12
  export type { StaffMemberData } from '../core/time-slot-list/TimeSlot.js';
12
13
  /**
13
14
  * Props for TimeSlot.Root component
@@ -131,6 +132,7 @@ export interface SelectProps {
131
132
  }) => React.ReactNode);
132
133
  className?: string;
133
134
  label?: string;
135
+ onClicked?: (timeSlot: TimeSlotType) => void;
134
136
  }
135
137
  /**
136
138
  * Button to select this time slot.
@@ -150,6 +152,13 @@ export interface SelectProps {
150
152
  * <button className="btn-primary">Book this slot</button>
151
153
  * </TimeSlot.Actions.Select>
152
154
  *
155
+ * // With onClicked callback for navigation
156
+ * <TimeSlot.Actions.Select
157
+ * onClicked={(timeSlot) => {
158
+ * router.push(`/booking/confirm/${timeSlot.localStartDate}`);
159
+ * }}
160
+ * />
161
+ *
153
162
  * // Using render prop pattern
154
163
  * <TimeSlot.Actions.Select>
155
164
  * {({ isSelected, bookable, onClick }) => (
@@ -171,6 +180,7 @@ export interface ClearStaffSelectionProps {
171
180
  }) => React.ReactNode);
172
181
  className?: string;
173
182
  label?: string;
183
+ onClicked?: (timeSlot: TimeSlotType) => void;
174
184
  }
175
185
  /**
176
186
  * Button to clear staff selection while keeping the slot selected.
@@ -191,6 +201,13 @@ export interface ClearStaffSelectionProps {
191
201
  * <button className="btn-secondary">Clear staff</button>
192
202
  * </TimeSlot.Actions.ClearStaffSelection>
193
203
  *
204
+ * // With onClicked callback
205
+ * <TimeSlot.Actions.ClearStaffSelection
206
+ * onClicked={(timeSlot) => {
207
+ * console.log('Staff selection cleared for', timeSlot.localStartDate);
208
+ * }}
209
+ * />
210
+ *
194
211
  * // Using render prop pattern
195
212
  * <TimeSlot.Actions.ClearStaffSelection>
196
213
  * {({ onClick }) => <button onClick={onClick}>Change selection</button>}
@@ -324,6 +341,7 @@ export interface SelectStaffMemberProps {
324
341
  }) => React.ReactNode);
325
342
  className?: string;
326
343
  label?: string;
344
+ onClicked?: (staffMember: CoreTimeSlot.StaffMemberData) => void;
327
345
  }
328
346
  /**
329
347
  * Button to select this staff member.
@@ -343,6 +361,13 @@ export interface SelectStaffMemberProps {
343
361
  * <button className="btn-primary">Choose Staff</button>
344
362
  * </TimeSlot.StaffMember.Actions.Select>
345
363
  *
364
+ * // With onClicked callback
365
+ * <TimeSlot.StaffMember.Actions.Select
366
+ * onClicked={(staffMember) => {
367
+ * console.log('Selected staff:', staffMember.name);
368
+ * }}
369
+ * />
370
+ *
346
371
  * // Using render prop pattern
347
372
  * <TimeSlot.StaffMember.Actions.Select>
348
373
  * {({ isSelected, onClick }) => (
@@ -139,6 +139,13 @@ Duration.displayName = 'TimeSlot.Duration';
139
139
  * <button className="btn-primary">Book this slot</button>
140
140
  * </TimeSlot.Actions.Select>
141
141
  *
142
+ * // With onClicked callback for navigation
143
+ * <TimeSlot.Actions.Select
144
+ * onClicked={(timeSlot) => {
145
+ * router.push(`/booking/confirm/${timeSlot.localStartDate}`);
146
+ * }}
147
+ * />
148
+ *
142
149
  * // Using render prop pattern
143
150
  * <TimeSlot.Actions.Select>
144
151
  * {({ isSelected, bookable, onClick }) => (
@@ -150,14 +157,18 @@ Duration.displayName = 'TimeSlot.Duration';
150
157
  * ```
151
158
  */
152
159
  export const Select = React.forwardRef((props, ref) => {
153
- const { asChild, children, className, label = 'Select' } = props;
154
- return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, isSelected, bookable }) => {
160
+ const { asChild, children, className, label = 'Select', onClicked } = props;
161
+ return (_jsx(CoreTimeSlot.Actions, { children: ({ selectTimeSlot, isSelected, bookable, timeSlot }) => {
162
+ const handleClick = () => {
163
+ selectTimeSlot();
164
+ onClicked?.(timeSlot);
165
+ };
155
166
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionSelect, "data-selected": isSelected, "data-bookable": bookable, customElement: children, customElementProps: {
156
- onClick: selectTimeSlot,
167
+ onClick: handleClick,
157
168
  disabled: !bookable,
158
169
  isSelected,
159
170
  bookable,
160
- }, children: _jsx("button", { onClick: selectTimeSlot, disabled: !bookable, children: label }) }));
171
+ }, children: _jsx("button", { onClick: handleClick, disabled: !bookable, children: label }) }));
161
172
  } }));
162
173
  });
163
174
  Select.displayName = 'TimeSlot.Actions.Select';
@@ -180,6 +191,13 @@ Select.displayName = 'TimeSlot.Actions.Select';
180
191
  * <button className="btn-secondary">Clear staff</button>
181
192
  * </TimeSlot.Actions.ClearStaffSelection>
182
193
  *
194
+ * // With onClicked callback
195
+ * <TimeSlot.Actions.ClearStaffSelection
196
+ * onClicked={(timeSlot) => {
197
+ * console.log('Staff selection cleared for', timeSlot.localStartDate);
198
+ * }}
199
+ * />
200
+ *
183
201
  * // Using render prop pattern
184
202
  * <TimeSlot.Actions.ClearStaffSelection>
185
203
  * {({ onClick }) => <button onClick={onClick}>Change selection</button>}
@@ -187,14 +205,18 @@ Select.displayName = 'TimeSlot.Actions.Select';
187
205
  * ```
188
206
  */
189
207
  export const ClearStaffSelection = React.forwardRef((props, ref) => {
190
- const { asChild, children, className, label = 'Change' } = props;
191
- return (_jsx(CoreTimeSlot.Actions, { children: ({ clearStaffSelection }) => {
208
+ const { asChild, children, className, label = 'Change', onClicked } = props;
209
+ return (_jsx(CoreTimeSlot.Actions, { children: ({ clearStaffSelection, timeSlot }) => {
192
210
  if (!clearStaffSelection) {
193
211
  return null;
194
212
  }
213
+ const handleClick = () => {
214
+ clearStaffSelection();
215
+ onClicked?.(timeSlot);
216
+ };
195
217
  return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotActionClearStaffSelection, customElement: children, customElementProps: {
196
- onClick: clearStaffSelection,
197
- }, children: _jsx("button", { onClick: clearStaffSelection, children: label }) }));
218
+ onClick: handleClick,
219
+ }, children: _jsx("button", { onClick: handleClick, children: label }) }));
198
220
  } }));
199
221
  });
200
222
  ClearStaffSelection.displayName = 'TimeSlot.Actions.ClearStaffSelection';
@@ -324,6 +346,13 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
324
346
  * <button className="btn-primary">Choose Staff</button>
325
347
  * </TimeSlot.StaffMember.Actions.Select>
326
348
  *
349
+ * // With onClicked callback
350
+ * <TimeSlot.StaffMember.Actions.Select
351
+ * onClicked={(staffMember) => {
352
+ * console.log('Selected staff:', staffMember.name);
353
+ * }}
354
+ * />
355
+ *
327
356
  * // Using render prop pattern
328
357
  * <TimeSlot.StaffMember.Actions.Select>
329
358
  * {({ isSelected, onClick }) => (
@@ -335,11 +364,17 @@ StaffMemberName.displayName = 'TimeSlot.StaffMember.Name';
335
364
  * ```
336
365
  */
337
366
  export const SelectStaffMember = React.forwardRef((props, ref) => {
338
- const { asChild, children, className, label = 'Select' } = props;
339
- return (_jsx(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected }) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
340
- onClick: selectStaffMember,
341
- isSelected,
342
- }, children: _jsx("button", { onClick: selectStaffMember, children: label }) })) }));
367
+ const { asChild, children, className, label = 'Select', onClicked } = props;
368
+ return (_jsx(CoreTimeSlot.StaffMemberActions, { children: ({ selectStaffMember, isSelected, staffMember }) => {
369
+ const handleClick = () => {
370
+ selectStaffMember();
371
+ onClicked?.(staffMember);
372
+ };
373
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.timeSlotStaffMemberActionSelect, "data-selected": isSelected, customElement: children, customElementProps: {
374
+ onClick: handleClick,
375
+ isSelected,
376
+ }, children: _jsx("button", { onClick: handleClick, children: label }) }));
377
+ } }));
343
378
  });
344
379
  SelectStaffMember.displayName = 'TimeSlot.StaffMember.Actions.Select';
345
380
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "0.0.55",
3
+ "version": "0.0.56",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -72,5 +72,5 @@
72
72
  "groupId": "com.wixpress.headless-components"
73
73
  }
74
74
  },
75
- "falconPackageHash": "c5880314a94c61f704a825c22cc865fced4f6e19015c4e1abeeaf365"
75
+ "falconPackageHash": "8792da90af7c78ece12ac4244e507751fbe186381decf6b266bee92a"
76
76
  }