@wix/headless-bookings 0.0.13 → 0.0.15
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/react/core/service-list/ServiceList.d.ts +4 -0
- package/cjs/dist/react/core/service-list/ServiceList.js +4 -0
- package/cjs/dist/react/core/time-slot-list/TimeSlot.d.ts +368 -0
- package/cjs/dist/react/core/time-slot-list/TimeSlot.js +357 -0
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.d.ts +84 -0
- package/cjs/dist/react/core/time-slot-list/TimeSlotList.js +68 -0
- package/cjs/dist/react/index.d.ts +1 -0
- package/cjs/dist/react/index.js +1 -0
- package/cjs/dist/react/service/Service.js +1 -11
- package/cjs/dist/react/service-list/ServiceList.d.ts +2 -0
- package/cjs/dist/react/service-list/ServiceList.js +23 -35
- package/cjs/dist/react/time-slot-list/TimeSlot.d.ts +438 -0
- package/cjs/dist/react/time-slot-list/TimeSlot.js +427 -0
- package/cjs/dist/react/time-slot-list/TimeSlotList.d.ts +209 -0
- package/cjs/dist/react/time-slot-list/TimeSlotList.js +199 -0
- package/cjs/dist/services/time-slot-list/index.d.ts +1 -1
- package/dist/react/core/service-list/ServiceList.d.ts +4 -0
- package/dist/react/core/service-list/ServiceList.js +4 -0
- package/dist/react/core/time-slot-list/TimeSlot.d.ts +368 -0
- package/dist/react/core/time-slot-list/TimeSlot.js +357 -0
- package/dist/react/core/time-slot-list/TimeSlotList.d.ts +84 -0
- package/dist/react/core/time-slot-list/TimeSlotList.js +68 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/service/Service.js +1 -11
- package/dist/react/service-list/ServiceList.d.ts +2 -0
- package/dist/react/service-list/ServiceList.js +23 -35
- package/dist/react/time-slot-list/TimeSlot.d.ts +438 -0
- package/dist/react/time-slot-list/TimeSlot.js +427 -0
- package/dist/react/time-slot-list/TimeSlotList.d.ts +209 -0
- package/dist/react/time-slot-list/TimeSlotList.js +199 -0
- package/dist/services/time-slot-list/index.d.ts +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* TimeSlotList - High-level component for displaying time slot list information
|
|
4
|
+
* Provides components for displaying timezone and time slot data
|
|
5
|
+
*/
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { GenericList } from '@wix/headless-components/react';
|
|
8
|
+
import { AsChildSlot } from '@wix/headless-utils/react';
|
|
9
|
+
import * as CoreTimeSlotList from '../core/time-slot-list/TimeSlotList.js';
|
|
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';
|
|
12
|
+
/**
|
|
13
|
+
* TimeSlot with required id field for GenericList
|
|
14
|
+
*/
|
|
15
|
+
var TestIds;
|
|
16
|
+
(function (TestIds) {
|
|
17
|
+
TestIds["timeSlotListRoot"] = "time-slot-list-root";
|
|
18
|
+
TestIds["timeSlotListTimeSlots"] = "time-slot-list-time-slots";
|
|
19
|
+
TestIds["timeSlotListTimeSlot"] = "time-slot-list-time-slot";
|
|
20
|
+
TestIds["timeSlotListTimezone"] = "time-slot-list-timezone";
|
|
21
|
+
TestIds["timeSlotListLoadMore"] = "time-slot-list-load-more";
|
|
22
|
+
})(TestIds || (TestIds = {}));
|
|
23
|
+
/**
|
|
24
|
+
* Displays the current timezone with customizable rendering.
|
|
25
|
+
*
|
|
26
|
+
* @component
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* // Default usage
|
|
30
|
+
* <TimeSlotList.Timezone className="text-sm text-gray-600" />
|
|
31
|
+
*
|
|
32
|
+
* // asChild with primitive
|
|
33
|
+
* <TimeSlotList.Timezone asChild>
|
|
34
|
+
* <span className="font-medium" />
|
|
35
|
+
* </TimeSlotList.Timezone>
|
|
36
|
+
*
|
|
37
|
+
* // asChild with render function
|
|
38
|
+
* <TimeSlotList.Timezone asChild>
|
|
39
|
+
* {({ timezone }) => (
|
|
40
|
+
* <span className="text-sm">
|
|
41
|
+
* Timezone: {timezone || 'Not set'}
|
|
42
|
+
* </span>
|
|
43
|
+
* )}
|
|
44
|
+
* </TimeSlotList.Timezone>
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
export const Timezone = React.forwardRef((props, ref) => {
|
|
48
|
+
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 }) })) }));
|
|
50
|
+
});
|
|
51
|
+
Timezone.displayName = 'TimeSlotList.Timezone';
|
|
52
|
+
/**
|
|
53
|
+
* Root component that provides the TimeSlotList service context.
|
|
54
|
+
*
|
|
55
|
+
* @order 1
|
|
56
|
+
* @component
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* import { TimeSlotList } from '@wix/bookings/components';
|
|
60
|
+
*
|
|
61
|
+
* function TimeSlotsPage({ config }) {
|
|
62
|
+
* return (
|
|
63
|
+
* <TimeSlotList.Root config={config}>
|
|
64
|
+
* <TimeSlotList.TimeSlots>
|
|
65
|
+
* <TimeSlotList.TimeSlotRepeater>
|
|
66
|
+
* {children}
|
|
67
|
+
* </TimeSlotList.TimeSlotRepeater>
|
|
68
|
+
* </TimeSlotList.TimeSlots>
|
|
69
|
+
* </TimeSlotList.Root>
|
|
70
|
+
* );
|
|
71
|
+
* }
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export const Root = React.forwardRef((props, ref) => {
|
|
75
|
+
const { children, config, className, variant } = props;
|
|
76
|
+
return (_jsx(CoreTimeSlotList.Root, { config: config, children: _jsx(RootContent, { className: className, ref: ref, variant: variant, children: children }) }));
|
|
77
|
+
});
|
|
78
|
+
Root.displayName = 'TimeSlotList.Root';
|
|
79
|
+
/**
|
|
80
|
+
* Internal component to handle the Root content with core layer access
|
|
81
|
+
*/
|
|
82
|
+
const RootContent = React.forwardRef((props, ref) => {
|
|
83
|
+
const { children, className, variant } = props;
|
|
84
|
+
return (_jsx(CoreTimeSlotList.ListData, { children: ({ timeSlots, hasMore, isLoading, loadMore }) => (_jsx(GenericList.Root, { items: timeSlots, loadMore: loadMore, hasMore: hasMore, isLoading: isLoading, className: className, ref: ref, "data-testid": TestIds.timeSlotListRoot, variant: variant, children: children })) }));
|
|
85
|
+
});
|
|
86
|
+
RootContent.displayName = 'TimeSlotList.RootContent';
|
|
87
|
+
/**
|
|
88
|
+
* Container for the time slots list with empty state support.
|
|
89
|
+
* Wraps GenericList.Items. Follows List Container Level pattern.
|
|
90
|
+
*
|
|
91
|
+
* @component
|
|
92
|
+
* @example
|
|
93
|
+
* ```tsx
|
|
94
|
+
* <TimeSlotList.TimeSlots emptyState={<div>No slots available</div>}>
|
|
95
|
+
* <TimeSlotList.TimeSlotRepeater>
|
|
96
|
+
* {children}
|
|
97
|
+
* </TimeSlotList.TimeSlotRepeater>
|
|
98
|
+
* </TimeSlotList.TimeSlots>
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export const TimeSlots = React.forwardRef((props, ref) => {
|
|
102
|
+
const { children, ...otherProps } = props;
|
|
103
|
+
return (_jsx(GenericList.Items, { ref: ref, "data-testid": TestIds.timeSlotListTimeSlots, ...otherProps, children: children }));
|
|
104
|
+
});
|
|
105
|
+
TimeSlots.displayName = 'TimeSlotList.TimeSlots';
|
|
106
|
+
/**
|
|
107
|
+
* Internal component that wraps each time slot item with context provider.
|
|
108
|
+
* This is separate to allow using the service hook within the repeater.
|
|
109
|
+
*/
|
|
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 })) }) }));
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Repeater component that renders each time slot.
|
|
115
|
+
* Follows Repeater Level pattern and uses GenericList.Repeater for consistency.
|
|
116
|
+
* Automatically provides TimeSlot context to children.
|
|
117
|
+
*
|
|
118
|
+
* @component
|
|
119
|
+
* @example
|
|
120
|
+
* ```tsx
|
|
121
|
+
* <TimeSlotList.TimeSlotRepeater>
|
|
122
|
+
* <TimeSlot.StartDate />
|
|
123
|
+
* <TimeSlot.Duration />
|
|
124
|
+
* <TimeSlot.Actions.Select />
|
|
125
|
+
* </TimeSlotList.TimeSlotRepeater>
|
|
126
|
+
* ```
|
|
127
|
+
*/
|
|
128
|
+
export const TimeSlotRepeater = React.forwardRef((props, ref) => {
|
|
129
|
+
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 }));
|
|
131
|
+
});
|
|
132
|
+
TimeSlotRepeater.displayName = 'TimeSlotList.TimeSlotRepeater';
|
|
133
|
+
/**
|
|
134
|
+
* Displays a button to load more time slots. Not rendered if no more slots are left to load.
|
|
135
|
+
* Follows the architecture rules - does not support asChild as it's a simple trigger component.
|
|
136
|
+
*
|
|
137
|
+
* @component
|
|
138
|
+
* @example
|
|
139
|
+
* ```tsx
|
|
140
|
+
* <TimeSlotList.Actions.LoadMore asChild>
|
|
141
|
+
* <button>Load More</button>
|
|
142
|
+
* </TimeSlotList.Actions.LoadMore>
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
export const LoadMore = React.forwardRef((props, ref) => {
|
|
146
|
+
const { children = _jsx("button", {}), ...otherProps } = props;
|
|
147
|
+
return (_jsx(GenericList.Actions.LoadMore, { ref: ref, "data-testid": TestIds.timeSlotListLoadMore, ...otherProps, children: children }));
|
|
148
|
+
});
|
|
149
|
+
LoadMore.displayName = 'TimeSlotList.Actions.LoadMore';
|
|
150
|
+
/**
|
|
151
|
+
* Actions namespace for TimeSlotList
|
|
152
|
+
*/
|
|
153
|
+
export const Actions = {
|
|
154
|
+
LoadMore,
|
|
155
|
+
};
|
|
156
|
+
// ============================================================================
|
|
157
|
+
// TimeSlot Entity Components (re-exported)
|
|
158
|
+
// ============================================================================
|
|
159
|
+
/**
|
|
160
|
+
* TimeSlot namespace containing components for displaying individual time slot data.
|
|
161
|
+
* These components must be used within TimeSlotList.TimeSlotRepeater.
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```tsx
|
|
165
|
+
* <TimeSlotList.TimeSlotRepeater>
|
|
166
|
+
* <TimeSlot.StartDate />
|
|
167
|
+
* <TimeSlot.Duration />
|
|
168
|
+
* <TimeSlot.Actions.Select />
|
|
169
|
+
*
|
|
170
|
+
* // Location selection - visible when slot is selected
|
|
171
|
+
* <TimeSlot.Locations>
|
|
172
|
+
* <TimeSlot.LocationRepeater>
|
|
173
|
+
* <TimeSlot.Location.Name />
|
|
174
|
+
* <TimeSlot.Location.Actions.Select />
|
|
175
|
+
* </TimeSlot.LocationRepeater>
|
|
176
|
+
* </TimeSlot.Locations>
|
|
177
|
+
*
|
|
178
|
+
* // Staff member selection - visible when slot is selected
|
|
179
|
+
* <TimeSlot.StaffMembers>
|
|
180
|
+
* <TimeSlot.StaffMemberRepeater>
|
|
181
|
+
* <TimeSlot.StaffMember.Name />
|
|
182
|
+
* <TimeSlot.StaffMember.Actions.Select />
|
|
183
|
+
* </TimeSlot.StaffMemberRepeater>
|
|
184
|
+
* </TimeSlot.StaffMembers>
|
|
185
|
+
* </TimeSlotList.TimeSlotRepeater>
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
export const TimeSlot = {
|
|
189
|
+
StartDate,
|
|
190
|
+
EndDate,
|
|
191
|
+
Duration,
|
|
192
|
+
Actions: TimeSlotActions,
|
|
193
|
+
Locations,
|
|
194
|
+
LocationRepeater,
|
|
195
|
+
Location,
|
|
196
|
+
StaffMembers,
|
|
197
|
+
StaffMemberRepeater,
|
|
198
|
+
StaffMember,
|
|
199
|
+
};
|
|
@@ -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 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 SlotSelection, } from './time-slot-list.def.js';
|
|
6
6
|
export { TimeSlotListService, loadTimeSlotListConfig, type LoadTimeSlotListConfigOptions, type LoadTimeSlotListConfigResult, } from './time-slot-list.js';
|
|
@@ -46,6 +46,10 @@ export interface ServicesRenderProps {
|
|
|
46
46
|
queryOptions: QueryOptions;
|
|
47
47
|
/** Pagination metadata (limit, offset, count, hasNext) */
|
|
48
48
|
pagingMetadata: PagingMetadata;
|
|
49
|
+
/** Whether more services can be loaded */
|
|
50
|
+
hasMore: boolean;
|
|
51
|
+
/** Function to load more services */
|
|
52
|
+
loadMore: (count: number) => Promise<void>;
|
|
49
53
|
}
|
|
50
54
|
/**
|
|
51
55
|
* Component that provides services list data through render props.
|
|
@@ -48,11 +48,15 @@ export function Services(props) {
|
|
|
48
48
|
const error = serviceListService.errorSignal.get();
|
|
49
49
|
const queryOptions = serviceListService.queryOptionsSignal.get();
|
|
50
50
|
const pagingMetadata = serviceListService.pagingMetadataSignal.get();
|
|
51
|
+
const hasMore = serviceListService.hasMoreServicesSignal.get();
|
|
52
|
+
const loadMore = serviceListService.actions.loadMore;
|
|
51
53
|
return props.children({
|
|
52
54
|
services,
|
|
53
55
|
isLoading,
|
|
54
56
|
error,
|
|
55
57
|
queryOptions,
|
|
56
58
|
pagingMetadata,
|
|
59
|
+
hasMore,
|
|
60
|
+
loadMore,
|
|
57
61
|
});
|
|
58
62
|
}
|
|
@@ -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;
|