@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,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';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/headless-bookings",
3
- "version": "0.0.13",
3
+ "version": "0.0.14",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -68,5 +68,5 @@
68
68
  "groupId": "com.wixpress.headless-components"
69
69
  }
70
70
  },
71
- "falconPackageHash": "fb9d6c4ddf1f28c1393d4c042861417e97c5e95f9ab301c1f5faaabe"
71
+ "falconPackageHash": "e3681a6dd045861d1cb7cefbdc04f1ad9e3eb62094bb6a8970b90cd2"
72
72
  }