@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.
- package/cjs/dist/__mocks__/booking.d.ts +9 -4
- package/cjs/dist/__mocks__/booking.js +48 -3
- package/cjs/dist/__mocks__/time-slots.d.ts +28 -0
- package/cjs/dist/__mocks__/time-slots.js +116 -0
- package/cjs/dist/api/index.d.ts +1 -0
- package/cjs/dist/api/index.js +1 -0
- package/cjs/dist/api/query-locations/index.d.ts +38 -0
- package/cjs/dist/api/query-locations/index.js +30 -0
- package/cjs/dist/react/core/location/Location.d.ts +113 -14
- package/cjs/dist/react/core/location/Location.js +189 -30
- package/cjs/dist/react/core/location-list/LocationList.d.ts +102 -0
- package/cjs/dist/react/core/location-list/LocationList.js +71 -0
- package/cjs/dist/react/index.d.ts +1 -0
- package/cjs/dist/react/index.js +1 -0
- package/cjs/dist/react/location/Location.d.ts +211 -41
- package/cjs/dist/react/location/Location.js +219 -46
- package/cjs/dist/react/location/LocationList.d.ts +98 -0
- package/cjs/dist/react/location/LocationList.js +120 -0
- package/cjs/dist/react/service/Service.d.ts +17 -24
- package/cjs/dist/react/service/Service.js +24 -36
- package/cjs/dist/services/index.d.ts +1 -0
- package/cjs/dist/services/index.js +1 -0
- package/cjs/dist/services/location-list/location-list.d.ts +100 -0
- package/cjs/dist/services/location-list/location-list.def.d.ts +62 -0
- package/cjs/dist/services/location-list/location-list.def.js +17 -0
- package/cjs/dist/services/location-list/location-list.js +212 -0
- package/dist/__mocks__/booking.d.ts +9 -4
- package/dist/__mocks__/booking.js +48 -3
- package/dist/__mocks__/time-slots.d.ts +28 -0
- package/dist/__mocks__/time-slots.js +116 -0
- package/dist/api/index.d.ts +1 -0
- package/dist/api/index.js +1 -0
- package/dist/api/query-locations/index.d.ts +38 -0
- package/dist/api/query-locations/index.js +30 -0
- package/dist/react/core/location/Location.d.ts +113 -14
- package/dist/react/core/location/Location.js +189 -30
- package/dist/react/core/location-list/LocationList.d.ts +102 -0
- package/dist/react/core/location-list/LocationList.js +71 -0
- package/dist/react/index.d.ts +1 -0
- package/dist/react/index.js +1 -0
- package/dist/react/location/Location.d.ts +211 -41
- package/dist/react/location/Location.js +219 -46
- package/dist/react/location/LocationList.d.ts +98 -0
- package/dist/react/location/LocationList.js +120 -0
- package/dist/react/service/Service.d.ts +17 -24
- package/dist/react/service/Service.js +24 -36
- package/dist/services/index.d.ts +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/location-list/location-list.d.ts +100 -0
- package/dist/services/location-list/location-list.def.d.ts +62 -0
- package/dist/services/location-list/location-list.def.js +17 -0
- package/dist/services/location-list/location-list.js +212 -0
- package/package.json +2 -2
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared mock data for booking service tests
|
|
3
|
-
*/
|
|
4
1
|
import type { Resource } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
5
2
|
import type { FormValues } from '@wix/form-public';
|
|
6
|
-
import type { ServiceSelection, ServiceSelectionTimeSlot, BookingServiceConfig } from '../services/booking/booking.js';
|
|
3
|
+
import type { ServiceSelection, ServiceSelectionTimeSlot, BookingServiceConfig, BookingService } from '../services/booking/booking.js';
|
|
4
|
+
import type { Signal } from '@wix/services-definitions/core-services/signals';
|
|
5
|
+
export declare function mockSignal<T>(initialValue: T): Signal<T>;
|
|
6
|
+
export declare function createMockSignalsService(): {
|
|
7
|
+
signal: typeof mockSignal;
|
|
8
|
+
computed: <T>(fn: () => T) => Signal<T>;
|
|
9
|
+
effect: (fn: () => void) => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function createMockBookingService(initialSelections?: ServiceSelection[]): BookingService;
|
|
7
12
|
/**
|
|
8
13
|
* Mock resource (staff member)
|
|
9
14
|
*/
|
|
@@ -1,7 +1,52 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared mock data for booking service tests
|
|
3
|
-
*/
|
|
4
1
|
import { mockService, mockServiceClass } from './services.js';
|
|
2
|
+
import { vi } from 'vitest';
|
|
3
|
+
export function mockSignal(initialValue) {
|
|
4
|
+
let value = initialValue;
|
|
5
|
+
return {
|
|
6
|
+
get: () => value,
|
|
7
|
+
peek: () => value,
|
|
8
|
+
set: (newValue) => {
|
|
9
|
+
value = newValue;
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export function createMockSignalsService() {
|
|
14
|
+
return {
|
|
15
|
+
signal: mockSignal,
|
|
16
|
+
computed: (fn) => mockSignal(fn()),
|
|
17
|
+
effect: vi.fn((fn) => {
|
|
18
|
+
fn();
|
|
19
|
+
}),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export function createMockBookingService(initialSelections = []) {
|
|
23
|
+
const serviceSelectionsSignal = mockSignal(initialSelections);
|
|
24
|
+
const locationSignal = mockSignal(null);
|
|
25
|
+
const timezoneSignal = mockSignal('UTC');
|
|
26
|
+
const formSubmissionSignal = mockSignal(null);
|
|
27
|
+
return {
|
|
28
|
+
serviceSelections: serviceSelectionsSignal,
|
|
29
|
+
location: locationSignal,
|
|
30
|
+
timezone: timezoneSignal,
|
|
31
|
+
formSubmission: formSubmissionSignal,
|
|
32
|
+
actions: {
|
|
33
|
+
updateItem: vi.fn(),
|
|
34
|
+
setItem: vi.fn(),
|
|
35
|
+
addItem: vi.fn(),
|
|
36
|
+
removeItem: vi.fn(),
|
|
37
|
+
clearItems: vi.fn(),
|
|
38
|
+
setResourceById: vi.fn(),
|
|
39
|
+
getResourceById: vi.fn(),
|
|
40
|
+
setLocation: vi.fn(),
|
|
41
|
+
clearLocation: vi.fn(),
|
|
42
|
+
setTimezone: vi.fn(),
|
|
43
|
+
setFormSubmission: vi.fn(),
|
|
44
|
+
clearFormSubmission: vi.fn(),
|
|
45
|
+
clearAll: vi.fn(),
|
|
46
|
+
book: vi.fn(),
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
}
|
|
5
50
|
/**
|
|
6
51
|
* Mock resource (staff member)
|
|
7
52
|
*/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TimeSlot } from '@wix/auto_sdk_bookings_availability-time-slots';
|
|
2
|
+
import type { TimeSlotListServiceConfig, TimeSlotListServiceAPI } from '../services/time-slot-list/time-slot-list.def.js';
|
|
3
|
+
import type { BookingService } from '../services/booking/booking.js';
|
|
4
|
+
export declare function createTimeSlotListService(overrides?: Partial<TimeSlotListServiceConfig>): {
|
|
5
|
+
service: TimeSlotListServiceAPI;
|
|
6
|
+
bookingService: BookingService;
|
|
7
|
+
};
|
|
8
|
+
export declare function createTimeSlot(overrides?: Partial<TimeSlot>): TimeSlot;
|
|
9
|
+
export declare function createTimeSlots(count: number): TimeSlot[];
|
|
10
|
+
export declare function createTimeSlotListConfig(overrides?: Partial<TimeSlotListServiceConfig>): TimeSlotListServiceConfig;
|
|
11
|
+
export declare const mockTimeSlot: TimeSlot;
|
|
12
|
+
export declare const mockTimeSlotMultipleStaff: TimeSlot;
|
|
13
|
+
export declare const mockTimeSlotNotBookable: TimeSlot;
|
|
14
|
+
export declare const mockTimeSlots: TimeSlot[];
|
|
15
|
+
export declare const mockStartDate: Date;
|
|
16
|
+
export declare const mockEndDate: Date;
|
|
17
|
+
export declare const mockTimezone = "America/New_York";
|
|
18
|
+
export declare const mockTimeSlotListConfig: TimeSlotListServiceConfig;
|
|
19
|
+
export declare const mockEmptyTimeSlotListConfig: TimeSlotListServiceConfig;
|
|
20
|
+
export declare const mockCursorPagingMetadataWithMore: {
|
|
21
|
+
cursors: {
|
|
22
|
+
next: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export declare const mockCursorPagingMetadataNoMore: {
|
|
26
|
+
cursors: {};
|
|
27
|
+
};
|
|
28
|
+
export declare function createMockTimeSlotListService(config?: Partial<TimeSlotListServiceConfig>): TimeSlotListServiceAPI;
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { vi } from 'vitest';
|
|
2
|
+
import { TimeSlotListService } from '../services/time-slot-list/time-slot-list.js';
|
|
3
|
+
import { createMockBookingService, createMockSignalsService, mockSignal, } from './booking.js';
|
|
4
|
+
export function createTimeSlotListService(overrides = {}) {
|
|
5
|
+
const config = createTimeSlotListConfig(overrides);
|
|
6
|
+
const mockBookingService = createMockBookingService();
|
|
7
|
+
const mockSignalsService = createMockSignalsService();
|
|
8
|
+
const getService = (definition) => {
|
|
9
|
+
const def = definition;
|
|
10
|
+
if (def.name === 'signals') {
|
|
11
|
+
return mockSignalsService;
|
|
12
|
+
}
|
|
13
|
+
if (def.name === 'booking') {
|
|
14
|
+
return mockBookingService;
|
|
15
|
+
}
|
|
16
|
+
throw new Error(`Unknown service: ${def.name}`);
|
|
17
|
+
};
|
|
18
|
+
const service = TimeSlotListService({
|
|
19
|
+
getService,
|
|
20
|
+
config,
|
|
21
|
+
});
|
|
22
|
+
return {
|
|
23
|
+
service,
|
|
24
|
+
bookingService: mockBookingService,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
export function createTimeSlot(overrides = {}) {
|
|
28
|
+
return {
|
|
29
|
+
localStartDate: '2024-01-15T10:00:00',
|
|
30
|
+
localEndDate: '2024-01-15T11:00:00',
|
|
31
|
+
bookable: true,
|
|
32
|
+
totalCapacity: 10,
|
|
33
|
+
remainingCapacity: 5,
|
|
34
|
+
scheduleId: 'schedule-1',
|
|
35
|
+
location: { _id: 'loc-1', name: 'Main Office' },
|
|
36
|
+
availableResources: [{ resources: [{ _id: 'staff-1', name: 'John Doe' }] }],
|
|
37
|
+
...overrides,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export function createTimeSlots(count) {
|
|
41
|
+
return Array.from({ length: count }, (_, i) => createTimeSlot({
|
|
42
|
+
localStartDate: `2024-01-15T${String(9 + (i % 8)).padStart(2, '0')}:00:00`,
|
|
43
|
+
localEndDate: `2024-01-15T${String(10 + (i % 8)).padStart(2, '0')}:00:00`,
|
|
44
|
+
scheduleId: `schedule-${i}`,
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
export function createTimeSlotListConfig(overrides = {}) {
|
|
48
|
+
const { startDate = new Date('2024-01-15T00:00:00'), endDate = new Date('2024-01-22T00:00:00'), timezone = 'America/New_York', timeSlots, ...rest } = overrides;
|
|
49
|
+
return {
|
|
50
|
+
startDate,
|
|
51
|
+
endDate,
|
|
52
|
+
timezone,
|
|
53
|
+
...rest,
|
|
54
|
+
...(timeSlots !== undefined ? { timeSlots } : {}),
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export const mockTimeSlot = createTimeSlot();
|
|
58
|
+
export const mockTimeSlotMultipleStaff = createTimeSlot({
|
|
59
|
+
availableResources: [
|
|
60
|
+
{
|
|
61
|
+
resources: [
|
|
62
|
+
{ _id: 'staff-1', name: 'John Doe' },
|
|
63
|
+
{ _id: 'staff-2', name: 'Jane Smith' },
|
|
64
|
+
],
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
});
|
|
68
|
+
export const mockTimeSlotNotBookable = createTimeSlot({
|
|
69
|
+
localStartDate: '2024-01-15T14:00:00',
|
|
70
|
+
localEndDate: '2024-01-15T15:00:00',
|
|
71
|
+
bookable: false,
|
|
72
|
+
remainingCapacity: 0,
|
|
73
|
+
location: { _id: 'loc-2', name: 'Downtown Branch' },
|
|
74
|
+
});
|
|
75
|
+
export const mockTimeSlots = [
|
|
76
|
+
mockTimeSlot,
|
|
77
|
+
mockTimeSlotMultipleStaff,
|
|
78
|
+
mockTimeSlotNotBookable,
|
|
79
|
+
];
|
|
80
|
+
export const mockStartDate = new Date('2024-01-15T00:00:00');
|
|
81
|
+
export const mockEndDate = new Date('2024-01-22T00:00:00');
|
|
82
|
+
export const mockTimezone = 'America/New_York';
|
|
83
|
+
export const mockTimeSlotListConfig = createTimeSlotListConfig({
|
|
84
|
+
timeSlots: mockTimeSlots,
|
|
85
|
+
});
|
|
86
|
+
export const mockEmptyTimeSlotListConfig = createTimeSlotListConfig();
|
|
87
|
+
export const mockCursorPagingMetadataWithMore = {
|
|
88
|
+
cursors: { next: 'next-cursor-token' },
|
|
89
|
+
};
|
|
90
|
+
export const mockCursorPagingMetadataNoMore = { cursors: {} };
|
|
91
|
+
export function createMockTimeSlotListService(config = {}) {
|
|
92
|
+
const timeSlotsSignal = mockSignal(config.timeSlots || []);
|
|
93
|
+
const isLoadingSignal = mockSignal(false);
|
|
94
|
+
const errorSignal = mockSignal(null);
|
|
95
|
+
const hasMoreSignal = mockSignal(false);
|
|
96
|
+
const dateRangeSignal = mockSignal({
|
|
97
|
+
start: config.startDate || mockStartDate,
|
|
98
|
+
end: config.endDate || mockEndDate,
|
|
99
|
+
});
|
|
100
|
+
return {
|
|
101
|
+
timeSlots: timeSlotsSignal,
|
|
102
|
+
isLoading: isLoadingSignal,
|
|
103
|
+
error: errorSignal,
|
|
104
|
+
hasMore: hasMoreSignal,
|
|
105
|
+
dateRange: dateRangeSignal,
|
|
106
|
+
actions: {
|
|
107
|
+
selectSlot: vi.fn(),
|
|
108
|
+
selectStaffMember: vi.fn(),
|
|
109
|
+
clearStaffSelection: vi.fn(),
|
|
110
|
+
loadMore: vi.fn(),
|
|
111
|
+
setDateRange: vi.fn((start, end) => {
|
|
112
|
+
dateRangeSignal.set({ start, end });
|
|
113
|
+
}),
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}
|
package/cjs/dist/api/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export { getServiceById, getServiceBySlug, queryServices, type PagingMetadata, t
|
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
9
|
export { createBooking, type CreateBookingOptions, type Booking, type CreateBookingRequest, type CreateBookingResponse, type ParticipantNotification, type ContactDetails, } from './create-booking/index.js';
|
|
10
10
|
export { createCheckout, ChannelType, type CreateCheckoutRequest, type CreateCheckoutResponse, } from './create-checkout/index.js';
|
|
11
|
+
export { queryLocations, type QueryLocationsResult, type LocationData, } from './query-locations/index.js';
|
|
11
12
|
/**
|
|
12
13
|
* PagingMetadata includes:
|
|
13
14
|
* - limit: Number of items per page
|
package/cjs/dist/api/index.js
CHANGED
|
@@ -8,6 +8,7 @@ export { getServiceById, getServiceBySlug, queryServices, } from './query-servic
|
|
|
8
8
|
export { fetchAvailability } from './fetch-availability/index.js';
|
|
9
9
|
export { createBooking, } from './create-booking/index.js';
|
|
10
10
|
export { createCheckout, ChannelType, } from './create-checkout/index.js';
|
|
11
|
+
export { queryLocations, } from './query-locations/index.js';
|
|
11
12
|
/**
|
|
12
13
|
* PagingMetadata includes:
|
|
13
14
|
* - limit: Number of items per page
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Locations API
|
|
3
|
+
* Fetches business locations from Wix Bookings Services
|
|
4
|
+
*
|
|
5
|
+
* @module API/QueryLocations
|
|
6
|
+
*/
|
|
7
|
+
import type { Service } from '@wix/auto_sdk_bookings_services';
|
|
8
|
+
/**
|
|
9
|
+
* LocationData type - from Service['locations'][number]
|
|
10
|
+
*/
|
|
11
|
+
export type LocationData = NonNullable<Service['locations']>[number];
|
|
12
|
+
/**
|
|
13
|
+
* Result from querying locations
|
|
14
|
+
*/
|
|
15
|
+
export interface QueryLocationsResult {
|
|
16
|
+
/** Business locations array */
|
|
17
|
+
locations: LocationData[];
|
|
18
|
+
/** Whether custom locations exist for any service */
|
|
19
|
+
hasCustomLocations: boolean;
|
|
20
|
+
/** Whether customer locations (at customer's place) exist for any service */
|
|
21
|
+
hasCustomerLocations: boolean;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Query all locations connected to services.
|
|
25
|
+
* Returns business locations array and existence flags for custom/customer locations.
|
|
26
|
+
*
|
|
27
|
+
* @returns Promise resolving to locations and existence flags
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* ```ts
|
|
31
|
+
* const { locations, hasCustomLocations, hasCustomerLocations } = await queryLocations();
|
|
32
|
+
*
|
|
33
|
+
* // locations contains all business locations
|
|
34
|
+
* // hasCustomLocations indicates if any service uses custom locations
|
|
35
|
+
* // hasCustomerLocations indicates if any service is at customer's place
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare function queryLocations(): Promise<QueryLocationsResult>;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query Locations API
|
|
3
|
+
* Fetches business locations from Wix Bookings Services
|
|
4
|
+
*
|
|
5
|
+
* @module API/QueryLocations
|
|
6
|
+
*/
|
|
7
|
+
import { queryLocations as queryLocationsApi, } from '@wix/auto_sdk_bookings_services';
|
|
8
|
+
/**
|
|
9
|
+
* Query all locations connected to services.
|
|
10
|
+
* Returns business locations array and existence flags for custom/customer locations.
|
|
11
|
+
*
|
|
12
|
+
* @returns Promise resolving to locations and existence flags
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* const { locations, hasCustomLocations, hasCustomerLocations } = await queryLocations();
|
|
17
|
+
*
|
|
18
|
+
* // locations contains all business locations
|
|
19
|
+
* // hasCustomLocations indicates if any service uses custom locations
|
|
20
|
+
* // hasCustomerLocations indicates if any service is at customer's place
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export async function queryLocations() {
|
|
24
|
+
const response = await queryLocationsApi();
|
|
25
|
+
return {
|
|
26
|
+
locations: (response.businessLocations?.locations || []),
|
|
27
|
+
hasCustomLocations: response.customLocations?.exists || false,
|
|
28
|
+
hasCustomerLocations: response.customerLocations?.exists || false,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
* Core Location Component - Parses service location data
|
|
3
3
|
* Handles business, custom, and customer location types
|
|
4
4
|
* Converts location data to Address component format
|
|
5
|
+
*
|
|
6
|
+
* @module Core/Location
|
|
5
7
|
*/
|
|
6
8
|
import React from 'react';
|
|
7
9
|
import { LocationType, type Service } from '@wix/auto_sdk_bookings_services';
|
|
@@ -10,35 +12,132 @@ import type { AddressData as AddressDataType } from '@wix/headless-components/re
|
|
|
10
12
|
* Re-export AddressData type from Address component for convenience
|
|
11
13
|
*/
|
|
12
14
|
export type AddressData = AddressDataType;
|
|
15
|
+
/**
|
|
16
|
+
* Service location type - from Service['locations'][number]
|
|
17
|
+
*/
|
|
18
|
+
export type ServiceLocation = NonNullable<Service['locations']>[number];
|
|
19
|
+
/**
|
|
20
|
+
* Synthetic location - represents a location type without real data
|
|
21
|
+
* Used for CUSTOMER or CUSTOM locations when no real location data exists
|
|
22
|
+
*/
|
|
23
|
+
export interface SyntheticLocation {
|
|
24
|
+
/** Location type */
|
|
25
|
+
locationType: LocationType.CUSTOMER | LocationType.CUSTOM;
|
|
26
|
+
/** Marker to identify synthetic locations */
|
|
27
|
+
synthetic: true;
|
|
28
|
+
/** Optional ID for tracking */
|
|
29
|
+
id?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Union type - location prop accepts Service or Synthetic location
|
|
33
|
+
*/
|
|
34
|
+
export type LocationInput = ServiceLocation | SyntheticLocation;
|
|
13
35
|
/**
|
|
14
36
|
* Location render props passed to children
|
|
15
37
|
*/
|
|
16
38
|
export interface LocationRenderProps {
|
|
39
|
+
/** Location type */
|
|
17
40
|
locationType: LocationType;
|
|
41
|
+
/** Parsed address data compatible with Address.Root, null if not available */
|
|
18
42
|
address: AddressData | null;
|
|
43
|
+
/** Location name (business.name or custom name) */
|
|
44
|
+
name: string | undefined;
|
|
45
|
+
/** Location ID */
|
|
46
|
+
locationId: string | undefined;
|
|
47
|
+
/** Whether this is a customer location */
|
|
48
|
+
isCustomerLocation: boolean;
|
|
49
|
+
/** Whether this is a custom location */
|
|
50
|
+
isCustomLocation: boolean;
|
|
51
|
+
/** Whether this is a synthetic entry (not from array) */
|
|
52
|
+
isSynthetic: boolean;
|
|
53
|
+
/** Phone number (only for BUSINESS ServiceLocations) */
|
|
54
|
+
phone: string | undefined;
|
|
55
|
+
/** Email address (only for BUSINESS ServiceLocations) */
|
|
56
|
+
email: string | undefined;
|
|
57
|
+
/** Raw location object (Service or Synthetic location) */
|
|
58
|
+
rawLocation: LocationInput | null;
|
|
19
59
|
}
|
|
20
60
|
/**
|
|
21
|
-
* Props for the
|
|
61
|
+
* Props for the Core Location Root component
|
|
22
62
|
*/
|
|
23
|
-
export interface
|
|
24
|
-
location
|
|
63
|
+
export interface RootProps {
|
|
64
|
+
/** Raw location data - accepts Service or Synthetic location */
|
|
65
|
+
location?: LocationInput;
|
|
66
|
+
/** Children */
|
|
67
|
+
children: React.ReactNode;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Props for the Core Location Data component
|
|
71
|
+
*/
|
|
72
|
+
export interface DataProps {
|
|
73
|
+
/** Children render prop that receives location data */
|
|
25
74
|
children: (props: LocationRenderProps) => React.ReactNode;
|
|
26
75
|
}
|
|
27
76
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
77
|
+
* Hook to access location context from CoreLocation.Root
|
|
78
|
+
* @throws Error if used outside of CoreLocation.Root
|
|
79
|
+
*/
|
|
80
|
+
export declare function useLocationContext(): LocationRenderProps;
|
|
81
|
+
/**
|
|
82
|
+
* Core Location Root component that provides location context.
|
|
83
|
+
* Parses location data and makes it available to all child components via context.
|
|
84
|
+
*
|
|
85
|
+
* @component
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* <CoreLocation.Root location={serviceLocation}>
|
|
89
|
+
* <Location.Name />
|
|
90
|
+
* <Location.Address />
|
|
91
|
+
* </CoreLocation.Root>
|
|
92
|
+
* ```
|
|
93
|
+
*/
|
|
94
|
+
export declare function Root(props: RootProps): React.ReactNode;
|
|
95
|
+
/**
|
|
96
|
+
* Core Location Data component that exposes location data via render props.
|
|
97
|
+
* Must be used within a CoreLocation.Root component.
|
|
98
|
+
*
|
|
99
|
+
* @component
|
|
100
|
+
* @example
|
|
101
|
+
* ```tsx
|
|
102
|
+
* <CoreLocation.Root location={serviceLocation}>
|
|
103
|
+
* <CoreLocation.Data>
|
|
104
|
+
* {({ displayName, address }) => (
|
|
105
|
+
* <div>
|
|
106
|
+
* <span>{displayName}</span>
|
|
107
|
+
* {address && <Address.Formatted address={address} />}
|
|
108
|
+
* </div>
|
|
109
|
+
* )}
|
|
110
|
+
* </CoreLocation.Data>
|
|
111
|
+
* </CoreLocation.Root>
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
export declare function Data(props: DataProps): React.ReactNode;
|
|
115
|
+
/**
|
|
116
|
+
* Props for Actions render prop component
|
|
117
|
+
*/
|
|
118
|
+
export interface ActionsProps {
|
|
119
|
+
children: (actions: {
|
|
120
|
+
select: () => void;
|
|
121
|
+
rawLocation: LocationInput | null;
|
|
122
|
+
selected: boolean;
|
|
123
|
+
}) => React.ReactNode;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Core component that provides location selection actions via render props.
|
|
127
|
+
* Sets the location in BookingService when select is called.
|
|
30
128
|
*
|
|
31
129
|
* @component
|
|
32
130
|
* @example
|
|
33
131
|
* ```tsx
|
|
34
|
-
* <CoreLocation location={serviceLocation}>
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* <
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
132
|
+
* <CoreLocation.Root location={serviceLocation}>
|
|
133
|
+
* <CoreLocation.Actions>
|
|
134
|
+
* {({ select, selected, rawLocation }) => (
|
|
135
|
+
* <button onClick={select}>
|
|
136
|
+
* {selected ? 'Selected' : 'Select'}
|
|
137
|
+
* </button>
|
|
138
|
+
* )}
|
|
139
|
+
* </CoreLocation.Actions>
|
|
140
|
+
* </CoreLocation.Root>
|
|
42
141
|
* ```
|
|
43
142
|
*/
|
|
44
|
-
export declare function
|
|
143
|
+
export declare function Actions(props: ActionsProps): React.ReactNode;
|