@wix/headless-bookings 0.0.27 → 0.0.28
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.
- package/cjs/dist/api/fetch-availability/index.d.ts +4 -4
- package/cjs/dist/api/fetch-availability/index.js +3 -47
- package/cjs/dist/react/core/time-slot-list/TimeSlot.d.ts +9 -143
- package/cjs/dist/react/core/time-slot-list/TimeSlot.js +32 -167
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +3 -2
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +1 -1
- package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +15 -113
- package/cjs/dist/react/time-slot-list/TimeSlot.js +26 -125
- package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +5 -34
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +12 -5
- package/cjs/dist/services/index.d.ts +1 -1
- package/cjs/dist/services/time-slot-list/index.d.ts +1 -1
- package/cjs/dist/services/time-slot-list/time-slot-list.d.ts +4 -4
- package/cjs/dist/services/time-slot-list/time-slot-list.def.d.ts +5 -40
- package/cjs/dist/services/time-slot-list/time-slot-list.js +38 -167
- package/dist/api/fetch-availability/index.d.ts +4 -4
- package/dist/api/fetch-availability/index.js +3 -47
- package/dist/react/core/time-slot-list/TimeSlot.d.ts +9 -143
- package/dist/react/core/time-slot-list/TimeSlot.js +32 -167
- package/dist/react/core/time-slot-list/TimeSlotList.d.ts +3 -2
- package/dist/react/core/time-slot-list/TimeSlotList.js +1 -1
- package/dist/react/time-slot-list/TimeSlot.d.ts +15 -113
- package/dist/react/time-slot-list/TimeSlot.js +26 -125
- package/dist/react/time-slot-list/TimeSlotList.d.ts +5 -34
- package/dist/react/time-slot-list/TimeSlotList.js +12 -5
- package/dist/services/index.d.ts +1 -1
- package/dist/services/time-slot-list/index.d.ts +1 -1
- package/dist/services/time-slot-list/time-slot-list.d.ts +4 -4
- package/dist/services/time-slot-list/time-slot-list.def.d.ts +5 -40
- package/dist/services/time-slot-list/time-slot-list.js +38 -167
- package/package.json +2 -2
|
@@ -8,8 +8,8 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
8
8
|
*/
|
|
9
9
|
import React from 'react';
|
|
10
10
|
import { useService } from '@wix/services-manager-react';
|
|
11
|
-
import { TimeSlotListServiceDefinition
|
|
12
|
-
import { ANY_STAFF_MEMBER_ID } from '../../../services/booking/booking.js';
|
|
11
|
+
import { TimeSlotListServiceDefinition } from '../../../services/time-slot-list/time-slot-list.def.js';
|
|
12
|
+
import { ANY_STAFF_MEMBER_ID, BookingServiceDefinition, } from '../../../services/booking/booking.js';
|
|
13
13
|
const TimeSlotContext = React.createContext(null);
|
|
14
14
|
/**
|
|
15
15
|
* Hook to access TimeSlot context
|
|
@@ -29,8 +29,11 @@ export function useTimeSlotContext() {
|
|
|
29
29
|
export function TimeSlotProvider(props) {
|
|
30
30
|
const { children, timeSlot } = props;
|
|
31
31
|
const service = useService(TimeSlotListServiceDefinition);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
32
|
+
const bookingService = useService(BookingServiceDefinition);
|
|
33
|
+
const selectedTimeSlot = bookingService.serviceSelections.get()[0]?.timeSlot;
|
|
34
|
+
const selectedLocationId = bookingService.location.get()?.id;
|
|
35
|
+
const isSelected = selectedTimeSlot?.startDate === timeSlot.localStartDate &&
|
|
36
|
+
selectedLocationId === timeSlot.location?._id;
|
|
34
37
|
const selectTimeSlot = () => {
|
|
35
38
|
service.actions.selectSlot(timeSlot);
|
|
36
39
|
};
|
|
@@ -41,34 +44,6 @@ export function TimeSlotProvider(props) {
|
|
|
41
44
|
};
|
|
42
45
|
return (_jsx(TimeSlotContext.Provider, { value: contextValue, children: children }));
|
|
43
46
|
}
|
|
44
|
-
const LocationContext = React.createContext(null);
|
|
45
|
-
/**
|
|
46
|
-
* Hook to access Location context
|
|
47
|
-
* @throws Error if used outside of LocationProvider
|
|
48
|
-
*/
|
|
49
|
-
export function useLocationContext() {
|
|
50
|
-
const context = React.useContext(LocationContext);
|
|
51
|
-
if (!context) {
|
|
52
|
-
throw new Error('Location components must be used within LocationProvider');
|
|
53
|
-
}
|
|
54
|
-
return context;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Provider component used by LocationRepeater to provide context.
|
|
58
|
-
* Not used directly by consumers - only by TimeSlot.LocationRepeater.
|
|
59
|
-
*/
|
|
60
|
-
export function LocationProvider(props) {
|
|
61
|
-
const { children, location } = props;
|
|
62
|
-
const service = useService(TimeSlotListServiceDefinition);
|
|
63
|
-
const selectLocation = () => {
|
|
64
|
-
service.actions.selectLocation(location.id);
|
|
65
|
-
};
|
|
66
|
-
const contextValue = {
|
|
67
|
-
location,
|
|
68
|
-
selectLocation,
|
|
69
|
-
};
|
|
70
|
-
return (_jsx(LocationContext.Provider, { value: contextValue, children: children }));
|
|
71
|
-
}
|
|
72
47
|
const StaffMemberContext = React.createContext(null);
|
|
73
48
|
/**
|
|
74
49
|
* Hook to access StaffMember context
|
|
@@ -118,6 +93,7 @@ export function Info(props) {
|
|
|
118
93
|
const { timeSlot, isSelected } = useTimeSlotContext();
|
|
119
94
|
const startDate = new Date(timeSlot.localStartDate);
|
|
120
95
|
const endDate = new Date(timeSlot.localEndDate);
|
|
96
|
+
const locationName = timeSlot.location?.name ?? '';
|
|
121
97
|
const bookable = timeSlot.bookable ?? false;
|
|
122
98
|
// Calculate duration from start and end dates
|
|
123
99
|
const durationInMinutes = Math.round((endDate.getTime() - startDate.getTime()) / (1000 * 60));
|
|
@@ -125,6 +101,7 @@ export function Info(props) {
|
|
|
125
101
|
startDate,
|
|
126
102
|
endDate,
|
|
127
103
|
durationInMinutes,
|
|
104
|
+
locationName,
|
|
128
105
|
bookable,
|
|
129
106
|
isSelected,
|
|
130
107
|
timeSlot,
|
|
@@ -153,128 +130,26 @@ export function Info(props) {
|
|
|
153
130
|
export function Actions(props) {
|
|
154
131
|
const { selectTimeSlot, timeSlot, isSelected } = useTimeSlotContext();
|
|
155
132
|
const service = useService(TimeSlotListServiceDefinition);
|
|
156
|
-
const
|
|
133
|
+
const bookingService = useService(BookingServiceDefinition);
|
|
157
134
|
const bookable = timeSlot.bookable ?? false;
|
|
158
|
-
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
const
|
|
162
|
-
|
|
163
|
-
const hasMultipleOptions = locationCount > 1 || staffCount > 1;
|
|
164
|
-
const shouldShowClearPreferences = hasPreferenceSelected && hasMultipleOptions;
|
|
165
|
-
const clearPreferences = shouldShowClearPreferences
|
|
166
|
-
? service.actions.clearPreferences
|
|
135
|
+
const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.resources?.[0]?._id;
|
|
136
|
+
const staffFromSlot = timeSlot.availableResources[0].resources.map((r) => r._id);
|
|
137
|
+
const shouldShowClearStaffSelection = !!selectedStaffMemberId && staffFromSlot.length > 1;
|
|
138
|
+
const clearStaffSelection = shouldShowClearStaffSelection
|
|
139
|
+
? service.actions.clearStaffSelection
|
|
167
140
|
: undefined;
|
|
168
141
|
return props.children({
|
|
169
142
|
selectTimeSlot,
|
|
170
|
-
|
|
143
|
+
clearStaffSelection,
|
|
171
144
|
timeSlot,
|
|
172
145
|
bookable,
|
|
173
146
|
isSelected,
|
|
174
147
|
});
|
|
175
148
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Core component that provides access to time slot locations via render props.
|
|
178
|
-
* Extracts locations from slot.staffByLocation and enriches with name from originalSlots.
|
|
179
|
-
* Each location includes isSelected and isSelectable based on current selection state.
|
|
180
|
-
*
|
|
181
|
-
* Returns null if there's only 1 location (nothing to choose from).
|
|
182
|
-
*
|
|
183
|
-
* @component
|
|
184
|
-
* @example
|
|
185
|
-
* ```tsx
|
|
186
|
-
* <CoreTimeSlot.Locations>
|
|
187
|
-
* {({ locations, locationsCount, selectLocation }) => (
|
|
188
|
-
* <GenericList.Root items={locations}>
|
|
189
|
-
* {children}
|
|
190
|
-
* </GenericList.Root>
|
|
191
|
-
* )}
|
|
192
|
-
* </CoreTimeSlot.Locations>
|
|
193
|
-
* ```
|
|
194
|
-
*/
|
|
195
|
-
export function Locations(props) {
|
|
196
|
-
const { timeSlot } = useTimeSlotContext();
|
|
197
|
-
const service = useService(TimeSlotListServiceDefinition);
|
|
198
|
-
const selection = service.selection.get();
|
|
199
|
-
const selectedLocationId = selection?.locationId ?? null;
|
|
200
|
-
const selectedStaffMemberId = selection?.staffMemberId ?? null;
|
|
201
|
-
const isAnyStaffMemberSelected = selectedStaffMemberId === ANY_STAFF_MEMBER_ID;
|
|
202
|
-
// Build locations array from staffByLocation (names already included)
|
|
203
|
-
const locations = timeSlot.staffByLocation.map(({ location, staffMembers }) => {
|
|
204
|
-
// Check if this location is selectable based on selected staff
|
|
205
|
-
// If no staff selected, all locations are selectable
|
|
206
|
-
// If staff selected, only locations where that staff works are selectable
|
|
207
|
-
const isSelectable = !isAnyStaffMemberSelected && selectedStaffMemberId
|
|
208
|
-
? staffMembers.some((s) => s.id === selectedStaffMemberId)
|
|
209
|
-
: true;
|
|
210
|
-
return {
|
|
211
|
-
id: location.id,
|
|
212
|
-
name: location.name,
|
|
213
|
-
isSelected: selectedLocationId === location.id,
|
|
214
|
-
isSelectable,
|
|
215
|
-
};
|
|
216
|
-
});
|
|
217
|
-
// Return null if only 1 location - nothing to choose from
|
|
218
|
-
if (locations.length <= 1) {
|
|
219
|
-
return null;
|
|
220
|
-
}
|
|
221
|
-
return props.children({
|
|
222
|
-
locations,
|
|
223
|
-
selectLocation: service.actions.selectLocation,
|
|
224
|
-
});
|
|
225
|
-
}
|
|
226
|
-
/**
|
|
227
|
-
* Core component that provides access to location info via render props.
|
|
228
|
-
* Must be used within LocationProvider.
|
|
229
|
-
*
|
|
230
|
-
* @component
|
|
231
|
-
* @example
|
|
232
|
-
* ```tsx
|
|
233
|
-
* <LocationInfo>
|
|
234
|
-
* {({ name, isSelected, isSelectable }) => (
|
|
235
|
-
* <span>{name}</span>
|
|
236
|
-
* )}
|
|
237
|
-
* </LocationInfo>
|
|
238
|
-
* ```
|
|
239
|
-
*/
|
|
240
|
-
export function LocationInfo(props) {
|
|
241
|
-
const { location } = useLocationContext();
|
|
242
|
-
return props.children({
|
|
243
|
-
name: location.name,
|
|
244
|
-
isSelected: location.isSelected,
|
|
245
|
-
isSelectable: location.isSelectable,
|
|
246
|
-
location,
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Core component that provides location actions via render props.
|
|
251
|
-
* Must be used within LocationProvider.
|
|
252
|
-
*
|
|
253
|
-
* @component
|
|
254
|
-
* @example
|
|
255
|
-
* ```tsx
|
|
256
|
-
* <LocationActions>
|
|
257
|
-
* {({ selectLocation, isSelected, isSelectable }) => (
|
|
258
|
-
* <button onClick={selectLocation} disabled={!isSelectable}>
|
|
259
|
-
* {isSelected ? 'Selected' : 'Select'}
|
|
260
|
-
* </button>
|
|
261
|
-
* )}
|
|
262
|
-
* </LocationActions>
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
export function LocationActions(props) {
|
|
266
|
-
const { location, selectLocation } = useLocationContext();
|
|
267
|
-
return props.children({
|
|
268
|
-
selectLocation,
|
|
269
|
-
isSelected: location.isSelected,
|
|
270
|
-
isSelectable: location.isSelectable,
|
|
271
|
-
location,
|
|
272
|
-
});
|
|
273
|
-
}
|
|
274
149
|
/**
|
|
275
150
|
* Core component that provides access to time slot staff members via render props.
|
|
276
151
|
* Extracts unique staff members from slot.staffByLocation (names already included).
|
|
277
|
-
* Each staff member includes isSelected
|
|
152
|
+
* Each staff member includes isSelected based on current selection state.
|
|
278
153
|
*
|
|
279
154
|
* Returns null if there's only 1 staff member (nothing to choose from).
|
|
280
155
|
*
|
|
@@ -293,33 +168,25 @@ export function LocationActions(props) {
|
|
|
293
168
|
export function StaffMembers(props) {
|
|
294
169
|
const { timeSlot } = useTimeSlotContext();
|
|
295
170
|
const service = useService(TimeSlotListServiceDefinition);
|
|
296
|
-
const
|
|
297
|
-
const selectedStaffMemberId =
|
|
298
|
-
const
|
|
299
|
-
//
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
isSelected: selectedStaffMemberId === id,
|
|
308
|
-
isSelectable: !selectedLocationId ||
|
|
309
|
-
entries.some((e) => e.locationId === selectedLocationId),
|
|
171
|
+
const bookingService = useService(BookingServiceDefinition);
|
|
172
|
+
const selectedStaffMemberId = bookingService.serviceSelections.get()[0]?.resources?.[0]?._id;
|
|
173
|
+
const staffMembers = timeSlot.availableResources[0].resources;
|
|
174
|
+
// Return null if only 1 staff member - nothing to choose from
|
|
175
|
+
if (staffMembers.length <= 1) {
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
const staffMembersData = staffMembers.map((s) => ({
|
|
179
|
+
id: s._id,
|
|
180
|
+
name: s.name,
|
|
181
|
+
isSelected: selectedStaffMemberId === s._id,
|
|
310
182
|
}));
|
|
311
183
|
const anyStaffOption = {
|
|
312
184
|
id: ANY_STAFF_MEMBER_ID,
|
|
313
185
|
name: 'Any staff member',
|
|
314
186
|
isSelected: selectedStaffMemberId === ANY_STAFF_MEMBER_ID,
|
|
315
|
-
isSelectable: true,
|
|
316
187
|
};
|
|
317
|
-
// Return null if only 1 staff member - nothing to choose from
|
|
318
|
-
if (staffMembers.length <= 1) {
|
|
319
|
-
return null;
|
|
320
|
-
}
|
|
321
188
|
return props.children({
|
|
322
|
-
staffMembers: [anyStaffOption, ...
|
|
189
|
+
staffMembers: [anyStaffOption, ...staffMembersData],
|
|
323
190
|
selectStaffMember: service.actions.selectStaffMember,
|
|
324
191
|
});
|
|
325
192
|
}
|
|
@@ -331,7 +198,7 @@ export function StaffMembers(props) {
|
|
|
331
198
|
* @example
|
|
332
199
|
* ```tsx
|
|
333
200
|
* <StaffMemberInfo>
|
|
334
|
-
* {({ name, isSelected
|
|
201
|
+
* {({ name, isSelected }) => (
|
|
335
202
|
* <span>{name}</span>
|
|
336
203
|
* )}
|
|
337
204
|
* </StaffMemberInfo>
|
|
@@ -342,7 +209,6 @@ export function StaffMemberInfo(props) {
|
|
|
342
209
|
return props.children({
|
|
343
210
|
name: staffMember.name,
|
|
344
211
|
isSelected: staffMember.isSelected,
|
|
345
|
-
isSelectable: staffMember.isSelectable,
|
|
346
212
|
staffMember,
|
|
347
213
|
});
|
|
348
214
|
}
|
|
@@ -354,8 +220,8 @@ export function StaffMemberInfo(props) {
|
|
|
354
220
|
* @example
|
|
355
221
|
* ```tsx
|
|
356
222
|
* <StaffMemberActions>
|
|
357
|
-
* {({ selectStaffMember, isSelected
|
|
358
|
-
* <button onClick={selectStaffMember}
|
|
223
|
+
* {({ selectStaffMember, isSelected }) => (
|
|
224
|
+
* <button onClick={selectStaffMember}>
|
|
359
225
|
* {isSelected ? 'Selected' : 'Select'}
|
|
360
226
|
* </button>
|
|
361
227
|
* )}
|
|
@@ -367,7 +233,6 @@ export function StaffMemberActions(props) {
|
|
|
367
233
|
return props.children({
|
|
368
234
|
selectStaffMember,
|
|
369
235
|
isSelected: staffMember.isSelected,
|
|
370
|
-
isSelectable: staffMember.isSelectable,
|
|
371
236
|
staffMember,
|
|
372
237
|
});
|
|
373
238
|
}
|
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
* Provides low-level access to TimeSlotListService via render props
|
|
4
4
|
*/
|
|
5
5
|
import React from 'react';
|
|
6
|
-
import { type TimeSlotListServiceConfig
|
|
6
|
+
import { type TimeSlotListServiceConfig } from '../../../services/time-slot-list/index.js';
|
|
7
|
+
import type { TimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
7
8
|
/**
|
|
8
9
|
* Props for Root component
|
|
9
10
|
*/
|
|
10
11
|
export interface RootProps {
|
|
11
12
|
children: React.ReactNode;
|
|
12
|
-
config
|
|
13
|
+
config: TimeSlotListServiceConfig;
|
|
13
14
|
}
|
|
14
15
|
/**
|
|
15
16
|
* Root component that provides TimeSlotListService context to its children.
|
|
@@ -15,7 +15,7 @@ import { BookingServiceDefinition } from '../../../services/booking/booking.js';
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
export function Root(props) {
|
|
18
|
-
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(TimeSlotListServiceDefinition, TimeSlotListService, props.config
|
|
18
|
+
return (_jsx(WixServices, { servicesMap: createServicesMap().addService(TimeSlotListServiceDefinition, TimeSlotListService, props.config), children: props.children }));
|
|
19
19
|
}
|
|
20
20
|
// ============================================================================
|
|
21
21
|
// Timezone Component
|
|
@@ -9,7 +9,7 @@ import React from 'react';
|
|
|
9
9
|
import { AsChildChildren } from '@wix/headless-utils/react';
|
|
10
10
|
export { TimeSlotProvider } from '../core/time-slot-list/TimeSlot.js';
|
|
11
11
|
export type { TimeSlotProviderProps } from '../core/time-slot-list/TimeSlot.js';
|
|
12
|
-
export type {
|
|
12
|
+
export type { StaffMemberData } from '../core/time-slot-list/TimeSlot.js';
|
|
13
13
|
/**
|
|
14
14
|
* Props for TimeSlot.StartDate component
|
|
15
15
|
*/
|
|
@@ -136,9 +136,9 @@ export interface SelectProps {
|
|
|
136
136
|
*/
|
|
137
137
|
export declare const Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
138
138
|
/**
|
|
139
|
-
* Props for TimeSlot.Actions.
|
|
139
|
+
* Props for TimeSlot.Actions.ClearStaffSelection component
|
|
140
140
|
*/
|
|
141
|
-
export interface
|
|
141
|
+
export interface ClearStaffSelectionProps {
|
|
142
142
|
asChild?: boolean;
|
|
143
143
|
children?: React.ReactNode | ((props: {
|
|
144
144
|
onClick: () => void;
|
|
@@ -147,81 +147,34 @@ export interface ClearPreferencesProps {
|
|
|
147
147
|
label?: string;
|
|
148
148
|
}
|
|
149
149
|
/**
|
|
150
|
-
* Button to clear
|
|
151
|
-
* Only renders when
|
|
152
|
-
* If it renders, clicking it will clear the preferences.
|
|
150
|
+
* Button to clear staff selection while keeping the slot selected.
|
|
151
|
+
* Only renders when a staff member is selected and there are multiple staff options.
|
|
153
152
|
*
|
|
154
153
|
* @component
|
|
155
154
|
* @example
|
|
156
155
|
* ```tsx
|
|
157
156
|
* // Default button - only shows when there's something to clear
|
|
158
|
-
* <TimeSlot.Actions.
|
|
157
|
+
* <TimeSlot.Actions.ClearStaffSelection label="Change staff" />
|
|
159
158
|
*
|
|
160
159
|
* // With asChild
|
|
161
|
-
* <TimeSlot.Actions.
|
|
162
|
-
* <button className="btn-secondary">Clear
|
|
163
|
-
* </TimeSlot.Actions.
|
|
160
|
+
* <TimeSlot.Actions.ClearStaffSelection asChild>
|
|
161
|
+
* <button className="btn-secondary">Clear staff</button>
|
|
162
|
+
* </TimeSlot.Actions.ClearStaffSelection>
|
|
164
163
|
*
|
|
165
164
|
* // Using render prop pattern
|
|
166
|
-
* <TimeSlot.Actions.
|
|
165
|
+
* <TimeSlot.Actions.ClearStaffSelection>
|
|
167
166
|
* {({ onClick }) => <button onClick={onClick}>Change selection</button>}
|
|
168
|
-
* </TimeSlot.Actions.
|
|
167
|
+
* </TimeSlot.Actions.ClearStaffSelection>
|
|
169
168
|
* ```
|
|
170
169
|
*/
|
|
171
|
-
export declare const
|
|
170
|
+
export declare const ClearStaffSelection: React.ForwardRefExoticComponent<ClearStaffSelectionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
172
171
|
/**
|
|
173
172
|
* Actions namespace for TimeSlot
|
|
174
173
|
*/
|
|
175
174
|
export declare const Actions: {
|
|
176
175
|
Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
|
|
177
|
-
|
|
176
|
+
ClearStaffSelection: React.ForwardRefExoticComponent<ClearStaffSelectionProps & React.RefAttributes<HTMLButtonElement>>;
|
|
178
177
|
};
|
|
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
178
|
/**
|
|
226
179
|
* Props for TimeSlot.Location.Name component
|
|
227
180
|
*/
|
|
@@ -250,61 +203,11 @@ export interface LocationNameProps {
|
|
|
250
203
|
* ```
|
|
251
204
|
*/
|
|
252
205
|
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
206
|
/**
|
|
292
207
|
* 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
208
|
*/
|
|
303
209
|
export declare const Location: {
|
|
304
210
|
Name: React.ForwardRefExoticComponent<LocationNameProps & React.RefAttributes<HTMLElement>>;
|
|
305
|
-
Actions: {
|
|
306
|
-
Select: React.ForwardRefExoticComponent<SelectLocationProps & React.RefAttributes<HTMLButtonElement>>;
|
|
307
|
-
};
|
|
308
211
|
};
|
|
309
212
|
/**
|
|
310
213
|
* Props for TimeSlot.StaffMembers component
|
|
@@ -387,7 +290,6 @@ export interface SelectStaffMemberProps {
|
|
|
387
290
|
asChild?: boolean;
|
|
388
291
|
children?: React.ReactNode | ((props: {
|
|
389
292
|
isSelected: boolean;
|
|
390
|
-
isSelectable: boolean;
|
|
391
293
|
onClick: () => void;
|
|
392
294
|
}) => React.ReactNode);
|
|
393
295
|
className?: string;
|
|
@@ -409,8 +311,8 @@ export interface SelectStaffMemberProps {
|
|
|
409
311
|
*
|
|
410
312
|
* // Using render prop pattern
|
|
411
313
|
* <TimeSlot.StaffMember.Actions.Select>
|
|
412
|
-
* {({ isSelected,
|
|
413
|
-
* <button onClick={onClick}
|
|
314
|
+
* {({ isSelected, onClick }) => (
|
|
315
|
+
* <button onClick={onClick}>
|
|
414
316
|
* {isSelected ? 'Selected' : 'Select'}
|
|
415
317
|
* </button>
|
|
416
318
|
* )}
|