@wix/headless-bookings 0.0.43 → 0.0.45

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 (53) hide show
  1. package/cjs/dist/__mocks__/booking.d.ts +9 -4
  2. package/cjs/dist/__mocks__/booking.js +48 -3
  3. package/cjs/dist/__mocks__/time-slots.d.ts +28 -0
  4. package/cjs/dist/__mocks__/time-slots.js +116 -0
  5. package/cjs/dist/api/index.d.ts +1 -0
  6. package/cjs/dist/api/index.js +1 -0
  7. package/cjs/dist/api/query-locations/index.d.ts +38 -0
  8. package/cjs/dist/api/query-locations/index.js +30 -0
  9. package/cjs/dist/react/core/location/Location.d.ts +113 -14
  10. package/cjs/dist/react/core/location/Location.js +189 -30
  11. package/cjs/dist/react/core/location-list/LocationList.d.ts +102 -0
  12. package/cjs/dist/react/core/location-list/LocationList.js +71 -0
  13. package/cjs/dist/react/index.d.ts +1 -0
  14. package/cjs/dist/react/index.js +1 -0
  15. package/cjs/dist/react/location/Location.d.ts +211 -41
  16. package/cjs/dist/react/location/Location.js +219 -46
  17. package/cjs/dist/react/location/LocationList.d.ts +98 -0
  18. package/cjs/dist/react/location/LocationList.js +120 -0
  19. package/cjs/dist/react/service/Service.d.ts +17 -24
  20. package/cjs/dist/react/service/Service.js +24 -36
  21. package/cjs/dist/services/index.d.ts +1 -0
  22. package/cjs/dist/services/index.js +1 -0
  23. package/cjs/dist/services/location-list/location-list.d.ts +100 -0
  24. package/cjs/dist/services/location-list/location-list.def.d.ts +62 -0
  25. package/cjs/dist/services/location-list/location-list.def.js +17 -0
  26. package/cjs/dist/services/location-list/location-list.js +212 -0
  27. package/dist/__mocks__/booking.d.ts +9 -4
  28. package/dist/__mocks__/booking.js +48 -3
  29. package/dist/__mocks__/time-slots.d.ts +28 -0
  30. package/dist/__mocks__/time-slots.js +116 -0
  31. package/dist/api/index.d.ts +1 -0
  32. package/dist/api/index.js +1 -0
  33. package/dist/api/query-locations/index.d.ts +38 -0
  34. package/dist/api/query-locations/index.js +30 -0
  35. package/dist/react/core/location/Location.d.ts +113 -14
  36. package/dist/react/core/location/Location.js +189 -30
  37. package/dist/react/core/location-list/LocationList.d.ts +102 -0
  38. package/dist/react/core/location-list/LocationList.js +71 -0
  39. package/dist/react/index.d.ts +1 -0
  40. package/dist/react/index.js +1 -0
  41. package/dist/react/location/Location.d.ts +211 -41
  42. package/dist/react/location/Location.js +219 -46
  43. package/dist/react/location/LocationList.d.ts +98 -0
  44. package/dist/react/location/LocationList.js +120 -0
  45. package/dist/react/service/Service.d.ts +17 -24
  46. package/dist/react/service/Service.js +24 -36
  47. package/dist/services/index.d.ts +1 -0
  48. package/dist/services/index.js +1 -0
  49. package/dist/services/location-list/location-list.d.ts +100 -0
  50. package/dist/services/location-list/location-list.def.d.ts +62 -0
  51. package/dist/services/location-list/location-list.def.js +17 -0
  52. package/dist/services/location-list/location-list.js +212 -0
  53. package/package.json +2 -2
@@ -1,26 +1,30 @@
1
1
  /**
2
2
  * Location - Headless component for displaying service location information
3
- * Provides components for displaying location type and address
3
+ * Provides components for displaying location type, name, address, phone, email
4
+ *
5
+ * @module React/Location
4
6
  */
5
7
  import React from 'react';
6
8
  import * as CoreLocation from '../core/location/Location.js';
7
- import { AsChildChildren } from '@wix/headless-utils/react';
8
- import { LocationType, type Service } from '@wix/auto_sdk_bookings_services';
9
- /**
10
- * Re-export AddressData type from core for convenience
11
- */
12
- export type { AddressData } from '../core/location/Location.js';
9
+ import { type AsChildChildren } from '@wix/headless-utils/react';
10
+ import { LocationType } from '../../services/location-list/location-list.def.js';
11
+ export { useLocationContext } from '../core/location/Location.js';
12
+ export type { AddressData, ServiceLocation, SyntheticLocation, LocationInput, LocationRenderProps, } from '../core/location/Location.js';
13
+ export type { DisplayLocation } from '../../services/location-list/location-list.def.js';
13
14
  /**
14
15
  * Props for Location.Root component
15
16
  */
16
- export interface LocationRootProps {
17
- location: NonNullable<Service['locations']>[number];
17
+ export interface RootProps {
18
+ /** Raw location data - accepts Service or Synthetic location */
19
+ location?: CoreLocation.LocationInput;
20
+ /** Use asChild pattern */
18
21
  asChild?: boolean;
19
- children?: React.ReactNode | AsChildChildren<{
20
- locationType: LocationType;
21
- address: CoreLocation.AddressData | null;
22
- }>;
22
+ /** Children - ReactNode or render function with all LocationRenderProps */
23
+ children?: React.ReactNode | AsChildChildren<CoreLocation.LocationRenderProps>;
24
+ /** CSS class name */
23
25
  className?: string;
26
+ /** Data attributes */
27
+ [key: `data-${string}`]: string | undefined;
24
28
  }
25
29
  /**
26
30
  * Root component that provides location context and handles location type detection
@@ -29,49 +33,215 @@ export interface LocationRootProps {
29
33
  * @component
30
34
  * @example
31
35
  * ```tsx
32
- * import { Location } from '@wix/bookings/components';
33
- *
34
- * // Default usage - automatically renders Address.Formatted
35
- * function ServiceLocations({ location }) {
36
- * return (
37
- * <Location.Root location={location} />
38
- * );
39
- * }
36
+ * // With Service location
37
+ * <Location.Root location={serviceLocation}>
38
+ * <Location.Name className="font-bold" />
39
+ * <Location.Address />
40
+ * <Location.Phone />
41
+ * <Location.Email />
42
+ * </Location.Root>
40
43
  * ```
41
44
  *
42
45
  * @example
43
46
  * ```tsx
44
- * // With asChild to access location data
47
+ * // With asChild to access all location data
45
48
  * <Location.Root location={location} asChild>
46
- * {({ locationType, address }) => (
49
+ * {({ name, isCustomerLocation, phone }) => (
47
50
  * <div>
48
- * <span className="badge">{locationType}</span>
49
- * {address && (
50
- * <Address.Root address={address}>
51
- * <Address.Formatted />
52
- * </Address.Root>
53
- * )}
51
+ * <span>{isCustomerLocation ? "Client's Place" : name}</span>
52
+ * {phone && <span>{phone}</span>}
54
53
  * </div>
55
54
  * )}
56
55
  * </Location.Root>
57
56
  * ```
57
+ */
58
+ export declare const Root: React.ForwardRefExoticComponent<RootProps & React.RefAttributes<HTMLElement>>;
59
+ /**
60
+ * Props for Location.Name component
61
+ */
62
+ export interface NameProps {
63
+ asChild?: boolean;
64
+ children?: React.ReactNode | AsChildChildren<{
65
+ name: string;
66
+ }>;
67
+ className?: string;
68
+ }
69
+ /**
70
+ * Displays the location name.
71
+ * - BUSINESS: business.name
72
+ * - CUSTOM from array: addressLine (e.g., "Phone call")
73
+ * - CUSTOM synthetic/CUSTOMER: empty (consumer provides label)
58
74
  *
75
+ * @component
59
76
  * @example
60
77
  * ```tsx
61
- * // Conditional rendering based on location type
62
- * <Location.Root location={location} asChild>
63
- * {({ locationType, address }) => (
64
- * locationType === 'customer' ? (
65
- * <span className="text-primary">At your location</span>
78
+ * <Location.Name className="font-bold" />
79
+ *
80
+ * // With asChild
81
+ * <Location.Name asChild>
82
+ * {({ name }) => <h3>{name || "Client's Place"}</h3>}
83
+ * </Location.Name>
84
+ * ```
85
+ */
86
+ export declare const Name: React.ForwardRefExoticComponent<NameProps & React.RefAttributes<HTMLElement>>;
87
+ /**
88
+ * Props for Location.Type component
89
+ */
90
+ export interface TypeProps {
91
+ asChild?: boolean;
92
+ children?: React.ReactNode | AsChildChildren<{
93
+ locationType: LocationType;
94
+ isCustomerLocation: boolean;
95
+ isCustomLocation: boolean;
96
+ }>;
97
+ className?: string;
98
+ }
99
+ /**
100
+ * Displays the location type.
101
+ *
102
+ * @component
103
+ * @example
104
+ * ```tsx
105
+ * <Location.Type />
106
+ *
107
+ * // With asChild for custom rendering
108
+ * <Location.Type asChild>
109
+ * {({ isCustomerLocation, locationType }) => (
110
+ * <span className={isCustomerLocation ? 'text-primary' : ''}>
111
+ * {isCustomerLocation ? 'At your place' : locationType}
112
+ * </span>
113
+ * )}
114
+ * </Location.Type>
115
+ * ```
116
+ */
117
+ export declare const Type: React.ForwardRefExoticComponent<TypeProps & React.RefAttributes<HTMLElement>>;
118
+ /**
119
+ * Props for Location.Address component
120
+ */
121
+ export interface AddressProps {
122
+ asChild?: boolean;
123
+ children?: React.ReactNode | AsChildChildren<{
124
+ address: CoreLocation.AddressData | null;
125
+ }>;
126
+ className?: string;
127
+ }
128
+ /**
129
+ * Displays the location address.
130
+ * Returns null for CUSTOMER locations (consumer provides label).
131
+ *
132
+ * @component
133
+ * @example
134
+ * ```tsx
135
+ * <Location.Address />
136
+ *
137
+ * // With asChild
138
+ * <Location.Address asChild>
139
+ * {({ address }) => (
140
+ * address ? (
141
+ * <Address.Root address={address}>
142
+ * <Address.Formatted />
143
+ * </Address.Root>
66
144
  * ) : (
67
- * address && (
68
- * <Address.Root address={address}>
69
- * <Address.Formatted />
70
- * </Address.Root>
71
- * )
145
+ * <span>Client's Place</span>
72
146
  * )
73
147
  * )}
74
- * </Location.Root>
148
+ * </Location.Address>
149
+ * ```
150
+ */
151
+ export declare const LocationAddress: React.ForwardRefExoticComponent<AddressProps & React.RefAttributes<HTMLElement>>;
152
+ export { LocationAddress as Address };
153
+ /**
154
+ * Props for Location.Phone component
155
+ */
156
+ export interface PhoneProps {
157
+ asChild?: boolean;
158
+ children?: React.ReactNode | AsChildChildren<{
159
+ phone: string | undefined;
160
+ }>;
161
+ className?: string;
162
+ }
163
+ /**
164
+ * Displays the location phone number.
165
+ * Only renders for BUSINESS locations (phone only exists on BusinessLocationOptions).
166
+ *
167
+ * @component
168
+ * @example
169
+ * ```tsx
170
+ * <Location.Phone />
171
+ *
172
+ * // With asChild
173
+ * <Location.Phone asChild>
174
+ * {({ phone }) => phone && <a href={`tel:${phone}`}>{phone}</a>}
175
+ * </Location.Phone>
176
+ * ```
177
+ */
178
+ export declare const Phone: React.ForwardRefExoticComponent<PhoneProps & React.RefAttributes<HTMLElement>>;
179
+ /**
180
+ * Props for Location.Email component
181
+ */
182
+ export interface EmailProps {
183
+ asChild?: boolean;
184
+ children?: React.ReactNode | AsChildChildren<{
185
+ email: string | undefined;
186
+ }>;
187
+ className?: string;
188
+ }
189
+ /**
190
+ * Displays the location email address.
191
+ * Only renders for BUSINESS locations (email only exists on BusinessLocationOptions).
192
+ *
193
+ * @component
194
+ * @example
195
+ * ```tsx
196
+ * <Location.Email />
197
+ *
198
+ * // With asChild
199
+ * <Location.Email asChild>
200
+ * {({ email }) => email && <a href={`mailto:${email}`}>{email}</a>}
201
+ * </Location.Email>
202
+ * ```
203
+ */
204
+ export declare const Email: React.ForwardRefExoticComponent<EmailProps & React.RefAttributes<HTMLElement>>;
205
+ /**
206
+ * Props for Location.Raw component
207
+ */
208
+ export interface RawProps {
209
+ children: (props: CoreLocation.LocationRenderProps) => React.ReactNode;
210
+ }
211
+ /**
212
+ * Exposes all raw location data via render prop.
213
+ * Use only when you need full access to location data.
214
+ *
215
+ * @component
216
+ * @example
217
+ * ```tsx
218
+ * <Location.Raw>
219
+ * {({ rawLocation, locationType, phone, email }) => (
220
+ * <pre>{JSON.stringify(rawLocation, null, 2)}</pre>
221
+ * )}
222
+ * </Location.Raw>
75
223
  * ```
76
224
  */
77
- export declare const Root: React.ForwardRefExoticComponent<LocationRootProps & React.RefAttributes<HTMLElement>>;
225
+ export declare const Raw: React.FC<RawProps>;
226
+ /**
227
+ * Props for Location.Actions.Select component
228
+ */
229
+ export interface SelectProps {
230
+ asChild?: boolean;
231
+ children?: React.ReactNode | AsChildChildren<{
232
+ onClick: () => void;
233
+ selected: boolean;
234
+ location: CoreLocation.LocationInput | null;
235
+ }>;
236
+ /** Callback fired after location is selected - receives the location */
237
+ onClicked?: (location: CoreLocation.LocationInput) => void;
238
+ /** Label for the button */
239
+ label?: string;
240
+ className?: string;
241
+ }
242
+ /**
243
+ * Actions namespace for location-related actions
244
+ */
245
+ export declare const Actions: {
246
+ Select: React.ForwardRefExoticComponent<SelectProps & React.RefAttributes<HTMLButtonElement>>;
247
+ };
@@ -1,21 +1,37 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
2
2
  /**
3
3
  * Location - Headless component for displaying service location information
4
- * Provides components for displaying location type and address
4
+ * Provides components for displaying location type, name, address, phone, email
5
+ *
6
+ * @module React/Location
5
7
  */
6
8
  import React from 'react';
7
9
  import * as CoreLocation from '../core/location/Location.js';
8
10
  import { AsChildSlot } from '@wix/headless-utils/react';
9
11
  import { Address } from '@wix/headless-components/react';
12
+ // Re-export useLocationContext from core
13
+ export { useLocationContext } from '../core/location/Location.js';
10
14
  // ==========================================
11
15
  // TestIds Enum
12
16
  // ==========================================
13
17
  var TestIds;
14
18
  (function (TestIds) {
15
19
  TestIds["locationRoot"] = "location-root";
20
+ TestIds["locationName"] = "location-name";
21
+ TestIds["locationType"] = "location-type";
22
+ TestIds["locationAddress"] = "location-address";
23
+ TestIds["locationPhone"] = "location-phone";
24
+ TestIds["locationEmail"] = "location-email";
25
+ TestIds["locationRaw"] = "location-raw";
26
+ TestIds["locationActionSelect"] = "location-action-select";
16
27
  })(TestIds || (TestIds = {}));
17
28
  // ==========================================
18
- // Components
29
+ // Type Definitions
30
+ // ==========================================
31
+ // Use the core's context hook
32
+ const useLocationContext = CoreLocation.useLocationContext;
33
+ // ==========================================
34
+ // Root Component
19
35
  // ==========================================
20
36
  /**
21
37
  * Root component that provides location context and handles location type detection
@@ -24,66 +40,223 @@ var TestIds;
24
40
  * @component
25
41
  * @example
26
42
  * ```tsx
27
- * import { Location } from '@wix/bookings/components';
28
- *
29
- * // Default usage - automatically renders Address.Formatted
30
- * function ServiceLocations({ location }) {
31
- * return (
32
- * <Location.Root location={location} />
33
- * );
34
- * }
43
+ * // With Service location
44
+ * <Location.Root location={serviceLocation}>
45
+ * <Location.Name className="font-bold" />
46
+ * <Location.Address />
47
+ * <Location.Phone />
48
+ * <Location.Email />
49
+ * </Location.Root>
35
50
  * ```
36
51
  *
37
52
  * @example
38
53
  * ```tsx
39
- * // With asChild to access location data
54
+ * // With asChild to access all location data
40
55
  * <Location.Root location={location} asChild>
41
- * {({ locationType, address }) => (
56
+ * {({ name, isCustomerLocation, phone }) => (
42
57
  * <div>
43
- * <span className="badge">{locationType}</span>
44
- * {address && (
45
- * <Address.Root address={address}>
46
- * <Address.Formatted />
47
- * </Address.Root>
48
- * )}
58
+ * <span>{isCustomerLocation ? "Client's Place" : name}</span>
59
+ * {phone && <span>{phone}</span>}
49
60
  * </div>
50
61
  * )}
51
62
  * </Location.Root>
52
63
  * ```
64
+ */
65
+ export const Root = React.forwardRef((props, ref) => {
66
+ const { location, asChild, children, className, ...attrs } = props;
67
+ // Extract data-* attributes
68
+ const dataAttrs = Object.fromEntries(Object.entries(attrs).filter(([key]) => key.startsWith('data-')));
69
+ return (_jsx(CoreLocation.Root, { location: location, children: _jsx(CoreLocation.Data, { children: (renderProps) => (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationRoot, "data-location-type": renderProps.locationType, customElement: children, customElementProps: renderProps, ...dataAttrs, children: children })) }) }));
70
+ });
71
+ Root.displayName = 'Location.Root';
72
+ /**
73
+ * Displays the location name.
74
+ * - BUSINESS: business.name
75
+ * - CUSTOM from array: addressLine (e.g., "Phone call")
76
+ * - CUSTOM synthetic/CUSTOMER: empty (consumer provides label)
53
77
  *
78
+ * @component
54
79
  * @example
55
80
  * ```tsx
56
- * // Conditional rendering based on location type
57
- * <Location.Root location={location} asChild>
58
- * {({ locationType, address }) => (
59
- * locationType === 'customer' ? (
60
- * <span className="text-primary">At your location</span>
81
+ * <Location.Name className="font-bold" />
82
+ *
83
+ * // With asChild
84
+ * <Location.Name asChild>
85
+ * {({ name }) => <h3>{name || "Client's Place"}</h3>}
86
+ * </Location.Name>
87
+ * ```
88
+ */
89
+ export const Name = React.forwardRef((props, ref) => {
90
+ const { asChild, children, className, ...attrs } = props;
91
+ const { name } = useLocationContext();
92
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationName, customElement: children, customElementProps: { name: name ?? '' }, ...attrs, children: _jsx("span", { children: name }) }));
93
+ });
94
+ Name.displayName = 'Location.Name';
95
+ /**
96
+ * Displays the location type.
97
+ *
98
+ * @component
99
+ * @example
100
+ * ```tsx
101
+ * <Location.Type />
102
+ *
103
+ * // With asChild for custom rendering
104
+ * <Location.Type asChild>
105
+ * {({ isCustomerLocation, locationType }) => (
106
+ * <span className={isCustomerLocation ? 'text-primary' : ''}>
107
+ * {isCustomerLocation ? 'At your place' : locationType}
108
+ * </span>
109
+ * )}
110
+ * </Location.Type>
111
+ * ```
112
+ */
113
+ export const Type = React.forwardRef((props, ref) => {
114
+ const { asChild, children, className, ...attrs } = props;
115
+ const { locationType, isCustomerLocation, isCustomLocation } = useLocationContext();
116
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationType, customElement: children, customElementProps: {
117
+ locationType,
118
+ isCustomerLocation,
119
+ isCustomLocation,
120
+ }, ...attrs, children: _jsx("span", { children: locationType }) }));
121
+ });
122
+ Type.displayName = 'Location.Type';
123
+ /**
124
+ * Displays the location address.
125
+ * Returns null for CUSTOMER locations (consumer provides label).
126
+ *
127
+ * @component
128
+ * @example
129
+ * ```tsx
130
+ * <Location.Address />
131
+ *
132
+ * // With asChild
133
+ * <Location.Address asChild>
134
+ * {({ address }) => (
135
+ * address ? (
136
+ * <Address.Root address={address}>
137
+ * <Address.Formatted />
138
+ * </Address.Root>
61
139
  * ) : (
62
- * address && (
63
- * <Address.Root address={address}>
64
- * <Address.Formatted />
65
- * </Address.Root>
66
- * )
140
+ * <span>Client's Place</span>
67
141
  * )
68
142
  * )}
69
- * </Location.Root>
143
+ * </Location.Address>
70
144
  * ```
71
145
  */
72
- export const Root = React.forwardRef((props, ref) => {
73
- const { location, asChild, children, className, ...attrs } = props;
74
- return (_jsx(CoreLocation.Location, { location: location, children: ({ locationType, address }) => {
75
- // If asChild is used with custom children, always pass location data to children
76
- if (asChild && children) {
77
- return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationRoot, "data-location-type": locationType, customElement: children, customElementProps: { locationType, address }, ...attrs, children: address ? (_jsx(Address.Root, { address: address, children: _jsx(Address.Formatted, {}) })) : null }));
78
- }
79
- // Default rendering: return null if no address data
80
- if (!address) {
81
- return null;
82
- }
83
- // Default rendering with Address.Formatted and optional children
84
- return (_jsxs("span", { ref: ref, "data-testid": TestIds.locationRoot, "data-location-type": locationType, className: className, ...attrs, children: [_jsx(Address.Root, { address: address, children: _jsx(Address.Formatted, {}) }), typeof children !== 'function'
85
- ? children
86
- : null] }));
146
+ export const LocationAddress = React.forwardRef((props, ref) => {
147
+ const { asChild, children, className, ...attrs } = props;
148
+ const { address } = useLocationContext();
149
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationAddress, customElement: children, customElementProps: { address }, ...attrs, children: address ? (_jsx("span", { children: _jsx(Address.Root, { address: address, children: _jsx(Address.Formatted, {}) }) })) : null }));
150
+ });
151
+ LocationAddress.displayName = 'Location.Address';
152
+ // Export as Address (avoiding name collision with imported Address)
153
+ export { LocationAddress as Address };
154
+ /**
155
+ * Displays the location phone number.
156
+ * Only renders for BUSINESS locations (phone only exists on BusinessLocationOptions).
157
+ *
158
+ * @component
159
+ * @example
160
+ * ```tsx
161
+ * <Location.Phone />
162
+ *
163
+ * // With asChild
164
+ * <Location.Phone asChild>
165
+ * {({ phone }) => phone && <a href={`tel:${phone}`}>{phone}</a>}
166
+ * </Location.Phone>
167
+ * ```
168
+ */
169
+ export const Phone = React.forwardRef((props, ref) => {
170
+ const { asChild, children, className, ...attrs } = props;
171
+ const { phone } = useLocationContext();
172
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationPhone, customElement: children, customElementProps: { phone }, ...attrs, children: phone ? _jsx("span", { children: phone }) : null }));
173
+ });
174
+ Phone.displayName = 'Location.Phone';
175
+ /**
176
+ * Displays the location email address.
177
+ * Only renders for BUSINESS locations (email only exists on BusinessLocationOptions).
178
+ *
179
+ * @component
180
+ * @example
181
+ * ```tsx
182
+ * <Location.Email />
183
+ *
184
+ * // With asChild
185
+ * <Location.Email asChild>
186
+ * {({ email }) => email && <a href={`mailto:${email}`}>{email}</a>}
187
+ * </Location.Email>
188
+ * ```
189
+ */
190
+ export const Email = React.forwardRef((props, ref) => {
191
+ const { asChild, children, className, ...attrs } = props;
192
+ const { email } = useLocationContext();
193
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationEmail, customElement: children, customElementProps: { email }, ...attrs, children: email ? _jsx("span", { children: email }) : null }));
194
+ });
195
+ Email.displayName = 'Location.Email';
196
+ /**
197
+ * Exposes all raw location data via render prop.
198
+ * Use only when you need full access to location data.
199
+ *
200
+ * @component
201
+ * @example
202
+ * ```tsx
203
+ * <Location.Raw>
204
+ * {({ rawLocation, locationType, phone, email }) => (
205
+ * <pre>{JSON.stringify(rawLocation, null, 2)}</pre>
206
+ * )}
207
+ * </Location.Raw>
208
+ * ```
209
+ */
210
+ export const Raw = (props) => {
211
+ const context = useLocationContext();
212
+ return _jsx(_Fragment, { children: props.children(context) });
213
+ };
214
+ Raw.displayName = 'Location.Raw';
215
+ /**
216
+ * Selection action component for choosing a location.
217
+ * Sets the location in BookingService when clicked (like Service.Actions.Select).
218
+ *
219
+ * @component
220
+ * @example
221
+ * ```tsx
222
+ * <Location.Actions.Select label="Choose Location" />
223
+ *
224
+ * // With onClicked callback for navigation
225
+ * <Location.Actions.Select
226
+ * label="Select"
227
+ * onClicked={(location) => navigate('/time-slots')}
228
+ * />
229
+ *
230
+ * // With asChild
231
+ * <Location.Actions.Select asChild>
232
+ * {({ onClick, selected }) => (
233
+ * <Button onClick={onClick} variant={selected ? 'primary' : 'outline'}>
234
+ * {selected ? 'Selected' : 'Select'}
235
+ * </Button>
236
+ * )}
237
+ * </Location.Actions.Select>
238
+ * ```
239
+ */
240
+ const Select = React.forwardRef((props, ref) => {
241
+ const { asChild, children, onClicked, label = 'Select', className, ...attrs } = props;
242
+ return (_jsx(CoreLocation.Actions, { children: ({ select, selected, rawLocation }) => {
243
+ const handleClick = () => {
244
+ select();
245
+ if (onClicked && rawLocation) {
246
+ onClicked(rawLocation);
247
+ }
248
+ };
249
+ return (_jsx(AsChildSlot, { ref: ref, asChild: asChild, className: className, "data-testid": TestIds.locationActionSelect, "data-selected": selected, customElement: children, customElementProps: {
250
+ onClick: handleClick,
251
+ selected,
252
+ location: rawLocation,
253
+ }, ...attrs, children: _jsx("button", { type: "button", onClick: handleClick, children: label }) }));
87
254
  } }));
88
255
  });
89
- Root.displayName = 'Location.Root';
256
+ Select.displayName = 'Location.Actions.Select';
257
+ /**
258
+ * Actions namespace for location-related actions
259
+ */
260
+ export const Actions = {
261
+ Select,
262
+ };