@wix/bookings 1.0.1776 → 1.0.1778

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 (71) hide show
  1. package/build/cjs/context-booking-checkout.d.ts +243 -108
  2. package/build/cjs/context-booking-checkout.js +177 -183
  3. package/build/cjs/context-booking-checkout.js.map +1 -1
  4. package/build/cjs/context-categories.d.ts +16 -143
  5. package/build/cjs/context-categories.js +412 -412
  6. package/build/cjs/context-categories.js.map +1 -1
  7. package/build/cjs/context-locations.d.ts +16 -287
  8. package/build/cjs/context-locations.js +336 -336
  9. package/build/cjs/context-locations.js.map +1 -1
  10. package/build/cjs/context-service-addons.d.ts +2 -2
  11. package/build/cjs/context-service-addons.js +1 -1
  12. package/build/cjs/context-service-addons.js.map +1 -1
  13. package/build/cjs/context-service.d.ts +71 -33
  14. package/build/cjs/context-service.js +98 -96
  15. package/build/cjs/context-service.js.map +1 -1
  16. package/build/cjs/context-services.js +1 -1
  17. package/build/cjs/context-services.js.map +1 -1
  18. package/build/cjs/context-time-slots.d.ts +10 -0
  19. package/build/cjs/context-time-slots.js +2 -2
  20. package/build/cjs/context-time-slots.js.map +1 -1
  21. package/build/es/context-booking-checkout.d.mts +243 -108
  22. package/build/es/context-booking-checkout.mjs +177 -180
  23. package/build/es/context-booking-checkout.mjs.map +1 -1
  24. package/build/es/context-categories.d.mts +16 -143
  25. package/build/es/context-categories.mjs +412 -412
  26. package/build/es/context-categories.mjs.map +1 -1
  27. package/build/es/context-locations.d.mts +16 -287
  28. package/build/es/context-locations.mjs +336 -336
  29. package/build/es/context-locations.mjs.map +1 -1
  30. package/build/es/context-service-addons.d.mts +2 -2
  31. package/build/es/context-service-addons.mjs +1 -1
  32. package/build/es/context-service-addons.mjs.map +1 -1
  33. package/build/es/context-service.d.mts +71 -33
  34. package/build/es/context-service.mjs +98 -96
  35. package/build/es/context-service.mjs.map +1 -1
  36. package/build/es/context-services.mjs +1 -1
  37. package/build/es/context-services.mjs.map +1 -1
  38. package/build/es/context-time-slots.d.mts +10 -0
  39. package/build/es/context-time-slots.mjs +2 -2
  40. package/build/es/context-time-slots.mjs.map +1 -1
  41. package/build/internal/cjs/context-booking-checkout.d.ts +243 -108
  42. package/build/internal/cjs/context-categories.d.ts +16 -143
  43. package/build/internal/cjs/context-locations.d.ts +16 -287
  44. package/build/internal/cjs/context-service-addons.d.ts +2 -2
  45. package/build/internal/cjs/context-service.d.ts +71 -33
  46. package/build/internal/cjs/context-time-slots.d.ts +10 -0
  47. package/build/internal/es/context-booking-checkout.d.mts +243 -108
  48. package/build/internal/es/context-categories.d.mts +16 -143
  49. package/build/internal/es/context-locations.d.mts +16 -287
  50. package/build/internal/es/context-service-addons.d.mts +2 -2
  51. package/build/internal/es/context-service.d.mts +71 -33
  52. package/build/internal/es/context-time-slots.d.mts +10 -0
  53. package/{_sdk-exports → context-runtime}/context-booking-checkout/runtime.d.ts +243 -108
  54. package/context-runtime/context-booking-checkout/runtime.js +3 -0
  55. package/{_sdk-exports → context-runtime}/context-categories/runtime.d.ts +16 -143
  56. package/context-runtime/context-categories/runtime.js +2 -0
  57. package/context-runtime/context-locations/runtime.d.ts +195 -0
  58. package/context-runtime/context-locations/runtime.js +2 -0
  59. package/{_sdk-exports → context-runtime}/context-service/runtime.d.ts +71 -33
  60. package/{_sdk-exports → context-runtime}/context-service/runtime.js +3 -3
  61. package/{_sdk-exports → context-runtime}/context-service-addons/runtime.d.ts +2 -2
  62. package/{_sdk-exports → context-runtime}/context-time-slots/runtime.d.ts +10 -0
  63. package/{_sdk-exports → context-runtime}/context-time-slots/runtime.js +2 -2
  64. package/package.json +8 -8
  65. package/_sdk-exports/context-booking-checkout/runtime.js +0 -3
  66. package/_sdk-exports/context-categories/runtime.js +0 -2
  67. package/_sdk-exports/context-locations/runtime.d.ts +0 -466
  68. package/_sdk-exports/context-locations/runtime.js +0 -2
  69. /package/{_sdk-exports → context-runtime}/context-service-addons/runtime.js +0 -0
  70. /package/{_sdk-exports → context-runtime}/context-services/runtime.d.ts +0 -0
  71. /package/{_sdk-exports → context-runtime}/context-services/runtime.js +0 -0
@@ -1,466 +0,0 @@
1
- import React, { ReactNode } from "react";
2
-
3
- //#region ../../node_modules/type-fest/source/observable-like.d.ts
4
- declare global {
5
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
6
- interface SymbolConstructor {
7
- readonly observable: symbol;
8
- }
9
- }
10
- /**
11
- @remarks
12
- The TC39 observable proposal defines a `closed` property, but some implementations (such as xstream) do not as of 10/08/2021.
13
- As well, some guidance on making an `Observable` to not include `closed` property.
14
- @see https://github.com/tc39/proposal-observable/blob/master/src/Observable.js#L129-L130
15
- @see https://github.com/staltz/xstream/blob/6c22580c1d84d69773ee4b0905df44ad464955b3/src/index.ts#L79-L85
16
- @see https://github.com/benlesh/symbol-observable#making-an-object-observable
17
-
18
- @category Observable
19
- */
20
- //#endregion
21
- //#region ../../node_modules/@wix/sdk-types/internal/build/index.d.ts
22
- declare global {
23
- interface ContextualClient {}
24
- }
25
- /**
26
- * Creates concrete types from SDK descriptors when a contextual client is
27
- * available.
28
- *
29
- * For a REST descriptor the built (bound) API is intersected with the original
30
- * descriptor, matching what `contextualizeRESTModuleV2` returns at runtime — a
31
- * value callable as the bound API and still usable as a descriptor. Keeping the
32
- * descriptor half lets contextual modules be passed to descriptor-constrained
33
- * helpers such as `elevate` from `@wix/sdk/context` (FEDINF-14092).
34
- *
35
- * The `& T` is scoped to REST descriptors — the only shape codegen wraps in
36
- * `MaybeContext` — so `BuildDescriptors` (used by `createClient().use`) is left
37
- * unchanged and stays bound-only. The fix lives here rather than in `elevate`,
38
- * which is kept strict on purpose (see #941) so it still rejects bound-only
39
- * functions that are unsafe through `createRESTModule`.
40
- */
41
- declare global {
42
- /**
43
- * A global interface to set the exposure toggle for the SDK.
44
- * @example
45
- * ```ts
46
- * declare global {
47
- * interface SDKExposureToggle {
48
- * alpha: true;
49
- * }
50
- * }
51
- */
52
- interface SDKExposureToggle {}
53
- }
54
- declare global {
55
- /**
56
- * A global interface to set the type mode for the SDK.
57
- * @example
58
- * ```ts
59
- * declare global {
60
- * interface SDKTypeMode {
61
- * strict: true;
62
- * }
63
- * }
64
- */
65
- interface SDKTypeMode {}
66
- }
67
- //#endregion
68
- //#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-p5eQUd5f.d.mts
69
- interface V2Location extends V2LocationOptionsOneOf {
70
- /** Information about business locations. Required when `type` is `BUSINESS`. */
71
- business?: BusinessLocationOptions;
72
- /** Information about custom locations. Required when `type` is `CUSTOM`. */
73
- custom?: CustomLocationOptions;
74
- /**
75
- * Location ID.
76
- * @format GUID
77
- * @readonly
78
- */
79
- _id?: string;
80
- /**
81
- * Location type.
82
- *
83
- * Default: `CUSTOM`
84
- */
85
- type?: LocationTypeEnumLocationTypeWithLiterals;
86
- /**
87
- * Location address. Empty for `{"type": "CUSTOMER"}`.
88
- * @readonly
89
- */
90
- calculatedAddress?: CommonAddress;
91
- }
92
- /** @oneof */
93
- interface V2LocationOptionsOneOf {
94
- /** Information about business locations. Required when `type` is `BUSINESS`. */
95
- business?: BusinessLocationOptions;
96
- /** Information about custom locations. Required when `type` is `CUSTOM`. */
97
- custom?: CustomLocationOptions;
98
- }
99
- declare enum LocationTypeEnumLocationType {
100
- /** Location set by the business that is not a standard business [location](https://dev.wix.com/docs/api-reference/business-management/locations/introduction). */
101
- CUSTOM = "CUSTOM",
102
- /** Business [location](https://dev.wix.com/docs/api-reference/business-management/locations/introduction). */
103
- BUSINESS = "BUSINESS",
104
- /**
105
- * The customer specifies any address when booking. Available only for
106
- * appointment-based services.
107
- */
108
- CUSTOMER = "CUSTOMER"
109
- }
110
- /** @enumType */
111
- type LocationTypeEnumLocationTypeWithLiterals = LocationTypeEnumLocationType | 'CUSTOM' | 'BUSINESS' | 'CUSTOMER';
112
- interface CommonAddress extends CommonAddressStreetOneOf {
113
- /** Street name and number. */
114
- streetAddress?: CommonStreetAddress;
115
- /** @maxLength 255 */
116
- addressLine1?: string | null;
117
- /**
118
- * 2-letter country code in an [ISO-3166 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) format.
119
- * @format COUNTRY
120
- */
121
- country?: string | null;
122
- /**
123
- * Code for a subdivision (such as state, prefecture, or province) in [ISO 3166-2](https://en.wikipedia.org/wiki/ISO_3166-2) format.
124
- * @maxLength 255
125
- */
126
- subdivision?: string | null;
127
- /**
128
- * City name.
129
- * @maxLength 255
130
- */
131
- city?: string | null;
132
- /**
133
- * Postal or zip code.
134
- * @maxLength 255
135
- */
136
- postalCode?: string | null;
137
- /**
138
- * Full address of the location.
139
- * @maxLength 512
140
- */
141
- formatted?: string | null;
142
- }
143
- /** @oneof */
144
- interface CommonAddressStreetOneOf {
145
- /** Street name and number. */
146
- streetAddress?: CommonStreetAddress;
147
- /** @maxLength 255 */
148
- addressLine?: string | null;
149
- }
150
- /** Street address. Includes street name, number, and apartment number in separate fields. */
151
- interface CommonStreetAddress {
152
- /**
153
- * Street number.
154
- * @maxLength 255
155
- */
156
- number?: string;
157
- /**
158
- * Street name.
159
- * @maxLength 255
160
- */
161
- name?: string;
162
- /**
163
- * Apartment number.
164
- * @maxLength 255
165
- */
166
- apt?: string;
167
- }
168
- interface BusinessLocationOptions {
169
- /**
170
- * ID of the business [location](https://dev.wix.com/docs/api-reference/business-management/locations/introduction).
171
- * When setting a business location, specify only the location ID. Other location details are overwritten.
172
- * @format GUID
173
- */
174
- _id?: string;
175
- /**
176
- * Business location name.
177
- * @readonly
178
- * @maxLength 150
179
- */
180
- name?: string;
181
- /**
182
- * Whether this is the default location. There can only be a single default location per site.
183
- * @readonly
184
- */
185
- default?: boolean | null;
186
- /**
187
- * Business location address.
188
- * @readonly
189
- */
190
- address?: CommonAddress;
191
- /**
192
- * Business location email.
193
- * @format EMAIL
194
- * @readonly
195
- */
196
- email?: string | null;
197
- /**
198
- * Business location phone.
199
- * @format PHONE
200
- * @readonly
201
- */
202
- phone?: string | null;
203
- }
204
- interface CustomLocationOptions {
205
- /**
206
- * ID of the custom location.
207
- * @format GUID
208
- * @readonly
209
- */
210
- _id?: string;
211
- /** Address of the custom location. */
212
- address?: CommonAddress;
213
- }
214
- /**
215
- * `BookingPolicy` is the main entity of `BookingPolicyService` and specifies a set of rules for booking a service
216
- * by visitors and members.
217
- *
218
- * Each `BookingPolicy` consists of a number of sub-policies. When the Bookings App is provisioned to a meta site then a
219
- * default `BookingPolicy` will be created with defaults for each of these sub-policies. This also applies when a request
220
- * is received to create a new `BookingPolicy` and one or more of these sub-policies are not provided.
221
- *
222
- * Sub-policies are defined in separate objects as specified below.
223
- *
224
- * - The `LimitEarlyBookingPolicy` object defines the policy for limiting early bookings.
225
- * - The `LimitLateBookingPolicy` object defines the policy for limiting late bookings.
226
- * - The `BookAfterStartPolicy` object defines the policy for booking after the start of the schedule.
227
- * - The `CancellationPolicy` object defines the policy for canceling a booked entity.
228
- * - The `ReschedulePolicy` object defines the policy for rescheduling booked entity.
229
- * - The `WaitlistPolicy` object defines the policy for a waitlist.
230
- * - The `ParticipantsPolicy` object defines the policy regarding the participants per booking.
231
- * - The `ResourcesPolicy` object defines the policy regarding the resources per booking.
232
- * - The `CancellationFeePolicy` object defines the policy regarding cancellation fees.
233
- * - The `SaveCreditCardPolicy` object defines the policy for saving credit card details.
234
- *
235
- * By default each sub-policy is disabled. A more detailed specification of the default settings of each sub-policy
236
- * can be found in the description of the corresponding object.
237
- *
238
- * Partial updates are supported on the main entity level, however in order to update a sub-policy the client needs to provide the whole sub-policy object.
239
- */
240
- //#endregion
241
- //#region src/api/adapters/location/location.d.ts
242
- type BusinessLocation = V2Location;
243
- //#endregion
244
- //#region src/extensions/contexts/locations-context/locations-context.d.ts
245
- /** A business location as shown in a location list, with its selected state. */
246
- interface LocationItem {
247
- /**
248
- * ID of the business location. Pass it to `selectLocation()` to select the location. To get or
249
- * update the location's details, use the
250
- * [Locations
251
- * API](https://dev.wix.com/docs/api-reference/business-management/locations/introduction).
252
- *
253
- * `null` when the location has no ID.
254
- */
255
- locationId: string | null;
256
- /**
257
- * Name of the business location.
258
- *
259
- * `null` when the location has no name.
260
- */
261
- locationName: string | null;
262
- /**
263
- * Whether this is the selected location, the one whose ID is `selectedLocationId`.
264
- *
265
- * Always `false` when `locationId` is `null`.
266
- */
267
- isSelected: boolean;
268
- }
269
- /** The bookable business locations, whether services also run at other locations, the selected location, the loading and error state, and the actions to change or reload them. */
270
- interface LocationsContextValue {
271
- /**
272
- * Business locations where the site's visible Wix Bookings services take place, sorted by name.
273
- *
274
- * Each item is a service location object from the
275
- * [Services V2
276
- * API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/services-v2/introduction).
277
- * Its `business` field holds the location's ID and name. To render a list of the locations, use
278
- * `locationItems`, which holds the same locations in the same order.
279
- *
280
- * Empty while `isLoading` is `true`, and when the locations fail to load.
281
- */
282
- locations: BusinessLocation[];
283
- /**
284
- * Locations to list, an item for each location in `locations`, in the same order.
285
- *
286
- * Empty while `isLoading` is `true`, and when the locations fail to load.
287
- */
288
- locationItems: LocationItem[];
289
- /**
290
- * ID of the selected location, from the `location` query parameter in the page URL.
291
- *
292
- * When the page opens with the parameter, it's set right away, even while `isLoading` is
293
- * `true`. It changes after each call to `selectLocation()`. It isn't checked against
294
- * `locations`, so it can be an ID that matches no location. It's `'OTHER_LOCATIONS'` when the
295
- * services at custom addresses or at customers' locations are selected, as `hasOtherLocations`
296
- * describes.
297
- *
298
- * `null` when no location is selected.
299
- */
300
- selectedLocationId: string | null;
301
- /**
302
- * Index in `locations` of the selected location.
303
- *
304
- * `-1` when no location in `locations` is selected. For example, when no location is selected,
305
- * when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
306
- */
307
- selectedLocationIndex: number;
308
- /**
309
- * Item in `locations` whose ID is `selectedLocationId`.
310
- *
311
- * `null` when no location in `locations` is selected. For example, when no location is
312
- * selected, when `'OTHER_LOCATIONS'` is selected, or while `isLoading` is `true`.
313
- */
314
- selectedLocation: BusinessLocation | null;
315
- /**
316
- * Name of the selected location.
317
- *
318
- * `null` when `selectedLocation` is `null`, or when the location has no name.
319
- */
320
- selectedLocationName: string | null;
321
- /**
322
- * Whether any of the site's visible Wix Bookings services takes place at a custom address or at
323
- * the customer's location.
324
- *
325
- * Use it to offer an option for those services beside the business locations. To select that
326
- * option, pass `'OTHER_LOCATIONS'` to `selectLocation()`.
327
- *
328
- * `false` while `isLoading` is `true`, and when the locations fail to load.
329
- */
330
- hasOtherLocations: boolean;
331
- /**
332
- * Whether site visitors have more than 1 location to choose from.
333
- *
334
- * `true` when there are at least 2 choices: each location in `locations` that has an ID, plus
335
- * 1 more when `hasOtherLocations` is `true`. Use it to hide a location filter that has
336
- * nothing to filter.
337
- *
338
- * `false` while `isLoading` is `true`, and when the locations fail to load.
339
- */
340
- hasMultipleLocations: boolean;
341
- /**
342
- * Whether the locations are loading.
343
- *
344
- * `true` while the locations load when the page opens, and while `refetch()` loads them again.
345
- * Meanwhile, `locations` and `locationItems` are empty, the values that depend on them are
346
- * `null`, `false`, or `-1`, and `selectLocation()` does nothing. `selectedLocationId` already
347
- * holds the location from the page URL.
348
- */
349
- isLoading: boolean;
350
- /**
351
- * Whether the locations failed to load.
352
- *
353
- * When it's `true`, `isLoading` is `false`, `locations` and `locationItems` are empty, and
354
- * `hasOtherLocations` and `hasMultipleLocations` are `false`. To try again, call `refetch()`.
355
- *
356
- * It's also `true`, with the same empty values, after a component under the context fails to
357
- * render. Then it stays `true` until the page reloads: `refetch()` doesn't clear it, and
358
- * `selectLocation()` does nothing.
359
- */
360
- hasError: boolean;
361
- /**
362
- * Loads the locations again.
363
- *
364
- * While they load, `isLoading` is `true`, `locations` and `locationItems` are empty, and
365
- * `selectLocation()` does nothing. The selected location stays the same, because it's kept in
366
- * the page URL.
367
- *
368
- * Use it to try again after the locations fail to load, when `hasError` is `true`. It doesn't
369
- * clear `hasError` when a component under the context failed to render.
370
- *
371
- * @example Try again after the locations fail to load
372
- * ```tsx
373
- * import { useLocationsContext } from '@wix/bookings/context/locations';
374
- *
375
- * function LocationsErrorMessage() {
376
- * const { hasError, refetch } = useLocationsContext();
377
- *
378
- * if (!hasError) {
379
- * return null;
380
- * }
381
- *
382
- * return (
383
- * <p>
384
- * Locations couldn't load.
385
- * <button onClick={() => refetch()}>Try again</button>
386
- * </p>
387
- * );
388
- * }
389
- * ```
390
- */
391
- refetch: () => void;
392
- /**
393
- * Selects a location, or clears the selection.
394
- *
395
- * It sets the `location` query parameter in the page URL and keeps the URL's other parameters,
396
- * except `page`, which it removes so a paged list starts again from its first page. It adds an
397
- * entry to the browser history and doesn't scroll to the top of the page. `selectedLocationId`
398
- * and the other selection values then update. A Services context on the same page reads the
399
- * same parameter, so it lists the services at the new selection.
400
- *
401
- * Does nothing while `isLoading` is `true`, or after a component under the context fails to
402
- * render.
403
- *
404
- * @param locationId - ID of the location to select, such as an item's `locationId` from
405
- * `locationItems`. It isn't checked against `locations`.
406
- *
407
- * To select the services at a custom address or at the customer's location, pass
408
- * `'OTHER_LOCATIONS'`. Offer that option only when `hasOtherLocations` is `true`.
409
- *
410
- * To clear the selection, pass `null` or an empty string. Either removes the `location`
411
- * parameter.
412
- *
413
- * @example Choose a location from a dropdown
414
- * ```tsx
415
- * import { useLocationsContext } from '@wix/bookings/context/locations';
416
- *
417
- * function LocationDropdown() {
418
- * const { locationItems, selectedLocationId, hasOtherLocations, isLoading, selectLocation } =
419
- * useLocationsContext();
420
- *
421
- * return (
422
- * <select
423
- * value={selectedLocationId ?? ''}
424
- * disabled={isLoading}
425
- * onChange={(event) => selectLocation(event.target.value || null)}
426
- * >
427
- * <option value="">All locations</option>
428
- * {locationItems.map(({ locationId, locationName }) =>
429
- * locationId ? (
430
- * <option key={locationId} value={locationId}>
431
- * {locationName ?? locationId}
432
- * </option>
433
- * ) : null,
434
- * )}
435
- * {hasOtherLocations && <option value="OTHER_LOCATIONS">Other locations</option>}
436
- * </select>
437
- * );
438
- * }
439
- * ```
440
- */
441
- selectLocation: (locationId: string | null) => void;
442
- }
443
- /** Props accepted by {@link LocationsContextProvider}. */
444
- interface LocationsContextProviderProps {
445
- /** Selected on load when the page URL names no location. */
446
- initialLocationId?: string;
447
- children: ReactNode;
448
- }
449
- declare const locationsContext: React.Context<LocationsContextValue | null>;
450
- declare const LOCATIONS_CONTEXT_MISSING_PROVIDER_ERROR = "useLocationsContext must be used within LocationsContextProvider";
451
- /**
452
- * The `useLocationsContext()` hook provides access to the business locations where the site's Wix
453
- * Bookings services take place, and to the location a site visitor selected. Use it to list the
454
- * locations, let site visitors select a location to filter services by, and show the list's loading
455
- * and error states.
456
- *
457
- * It throws an error where the context isn't available.
458
- */
459
- declare function useLocationsContext(): LocationsContextValue;
460
- /** Loads the business locations that host bookable services, checks for services at other locations, and tracks the selected location in the page URL. */
461
- declare function LocationsContextProvider({
462
- initialLocationId,
463
- children
464
- }: LocationsContextProviderProps): React.JSX.Element;
465
- //#endregion
466
- export { LOCATIONS_CONTEXT_MISSING_PROVIDER_ERROR, LocationItem, LocationsContextProviderProps, LocationsContextValue, LocationsContextProvider as default, locationsContext, useLocationsContext };