@wix/bookings 1.0.1753 → 1.0.1755
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/_sdk-exports/context-booking-checkout/runtime.d.ts +750 -143
- package/_sdk-exports/context-booking-checkout/runtime.js +2 -2
- package/_sdk-exports/context-categories/runtime.d.ts +164 -2
- package/_sdk-exports/context-locations/runtime.d.ts +186 -2
- package/_sdk-exports/context-service/runtime.d.ts +1499 -144
- package/_sdk-exports/context-service/runtime.js +2 -2
- package/_sdk-exports/context-service-addons/runtime.d.ts +215 -13
- package/_sdk-exports/context-services/runtime.d.ts +330 -77
- package/_sdk-exports/context-time-slots/runtime.d.ts +841 -72
- package/build/cjs/context-booking-checkout.d.ts +750 -143
- package/build/cjs/context-booking-checkout.js +1823 -1706
- package/build/cjs/context-booking-checkout.js.map +1 -1
- package/build/cjs/context-categories.d.ts +164 -2
- package/build/cjs/context-locations.d.ts +186 -2
- package/build/cjs/context-service-addons.d.ts +215 -13
- package/build/cjs/context-service.d.ts +1499 -144
- package/build/cjs/context-service.js +1234 -1230
- package/build/cjs/context-service.js.map +1 -1
- package/build/cjs/context-services.d.ts +330 -77
- package/build/cjs/context-time-slots.d.ts +841 -72
- package/build/es/context-booking-checkout.d.mts +750 -143
- package/build/es/context-booking-checkout.mjs +1835 -1709
- package/build/es/context-booking-checkout.mjs.map +1 -1
- package/build/es/context-categories.d.mts +164 -2
- package/build/es/context-locations.d.mts +186 -2
- package/build/es/context-service-addons.d.mts +215 -13
- package/build/es/context-service.d.mts +1499 -144
- package/build/es/context-service.mjs +1234 -1230
- package/build/es/context-service.mjs.map +1 -1
- package/build/es/context-services.d.mts +330 -77
- package/build/es/context-time-slots.d.mts +841 -72
- package/build/internal/cjs/context-booking-checkout.d.ts +750 -143
- package/build/internal/cjs/context-categories.d.ts +164 -2
- package/build/internal/cjs/context-locations.d.ts +186 -2
- package/build/internal/cjs/context-service-addons.d.ts +215 -13
- package/build/internal/cjs/context-service.d.ts +1499 -144
- package/build/internal/cjs/context-services.d.ts +330 -77
- package/build/internal/cjs/context-time-slots.d.ts +841 -72
- package/build/internal/es/context-booking-checkout.d.mts +750 -143
- package/build/internal/es/context-categories.d.mts +164 -2
- package/build/internal/es/context-locations.d.mts +186 -2
- package/build/internal/es/context-service-addons.d.mts +215 -13
- package/build/internal/es/context-service.d.mts +1499 -144
- package/build/internal/es/context-services.d.mts +330 -77
- package/build/internal/es/context-time-slots.d.mts +841 -72
- package/package.json +9 -9
|
@@ -65,7 +65,7 @@ declare global {
|
|
|
65
65
|
interface SDKTypeMode {}
|
|
66
66
|
}
|
|
67
67
|
//#endregion
|
|
68
|
-
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-
|
|
68
|
+
//#region ../../node_modules/@wix/auto_sdk_bookings_services/build/es/bookings-services-v2-service-services.universal-oLBaHt-W.d.mts
|
|
69
69
|
/**
|
|
70
70
|
* Money.
|
|
71
71
|
* Default format to use. Sufficiently compliant with majority of standards: w3c, ISO 4217, ISO 20022, ISO 8583:2003.
|
|
@@ -135,7 +135,7 @@ interface BookedAddOn {
|
|
|
135
135
|
nameTranslated?: string | null;
|
|
136
136
|
}
|
|
137
137
|
/** Server-computed datetime adjusted to a requested timezone. */
|
|
138
|
-
interface AddOn
|
|
138
|
+
interface AddOn extends AddOnAddOnInfoOneOf {
|
|
139
139
|
/** Duration in minutes for duration-based add-ons that extend booking service time. */
|
|
140
140
|
durationInMinutes?: number;
|
|
141
141
|
/** Maximum quantity customers can purchase for quantity-based add-ons. */
|
|
@@ -165,7 +165,7 @@ interface AddOnAddOnInfoOneOf {
|
|
|
165
165
|
/** Maximum quantity customers can purchase for quantity-based add-ons. */
|
|
166
166
|
maxQuantity?: number;
|
|
167
167
|
}
|
|
168
|
-
interface AddOnGroupDetail
|
|
168
|
+
interface AddOnGroupDetail {
|
|
169
169
|
/**
|
|
170
170
|
* Group ID.
|
|
171
171
|
* @format GUID
|
|
@@ -182,7 +182,7 @@ interface AddOnGroupDetail$1 {
|
|
|
182
182
|
* Add-ons linked to this group in display order.
|
|
183
183
|
* @maxSize 7
|
|
184
184
|
*/
|
|
185
|
-
addOns?: AddOn
|
|
185
|
+
addOns?: AddOn[];
|
|
186
186
|
/**
|
|
187
187
|
* Instructional prompt displayed to customers. For example, `Choose up to 2 relaxing spa treatments to enhance your experience`. You can also use this field as a group description. For example, `Beginner-friendly rental equipment`.
|
|
188
188
|
* @maxLength 200
|
|
@@ -208,43 +208,239 @@ type AddOn$1 = {
|
|
|
208
208
|
};
|
|
209
209
|
//#endregion
|
|
210
210
|
//#region src/api/adapters/service-addons/service-addons.d.ts
|
|
211
|
-
|
|
212
|
-
type AddOn = AddOn$2;
|
|
211
|
+
/** An add-on the service offers, and whether the site visitor selected it. */
|
|
213
212
|
interface AddOnItem {
|
|
213
|
+
/**
|
|
214
|
+
* Add-on ID. Pass it to `toggleAddOn()` or `setAddOnQuantity()` to select the add-on. To manage
|
|
215
|
+
* add-ons, use the [Add-Ons
|
|
216
|
+
* API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/add-ons/introduction).
|
|
217
|
+
*/
|
|
214
218
|
addOnId: NonNullable<AddOn['addOnId']> | null;
|
|
219
|
+
/** Name of the add-on, translated to the current language when a translation exists. */
|
|
215
220
|
addOnName: NonNullable<AddOn['name']> | null;
|
|
221
|
+
/**
|
|
222
|
+
* Price of the add-on with its currency symbol, formatted for the current locale, such as `$50`
|
|
223
|
+
* or `$49.99`. A whole amount has no decimals.
|
|
224
|
+
*
|
|
225
|
+
* `null` when the add-on has no price, or its price has no currency.
|
|
226
|
+
*/
|
|
216
227
|
addOnPrice: string | null;
|
|
217
|
-
/**
|
|
228
|
+
/**
|
|
229
|
+
* Price of the add-on as a number, in `addOnCurrency`.
|
|
230
|
+
*
|
|
231
|
+
* `null` when the add-on has no price.
|
|
232
|
+
*/
|
|
218
233
|
addOnPriceValue?: number | null;
|
|
219
|
-
/**
|
|
234
|
+
/**
|
|
235
|
+
* Currency of the add-on's price, as an [ISO 4217 currency
|
|
236
|
+
* code](https://en.wikipedia.org/wiki/ISO_4217#Active_codes).
|
|
237
|
+
*
|
|
238
|
+
* `null` when the add-on has no price, or its price has no currency.
|
|
239
|
+
*/
|
|
220
240
|
addOnCurrency?: string | null;
|
|
241
|
+
/**
|
|
242
|
+
* Time the add-on adds to the booking, in minutes.
|
|
243
|
+
*
|
|
244
|
+
* `null` when the add-on doesn't add time.
|
|
245
|
+
*/
|
|
221
246
|
durationInMinutes: NonNullable<AddOn['durationInMinutes']> | null;
|
|
247
|
+
/**
|
|
248
|
+
* Largest quantity of the add-on the site visitor can select.
|
|
249
|
+
*
|
|
250
|
+
* `null` when the add-on has no quantity. The visitor can then only select it or not, so
|
|
251
|
+
* `setAddOnQuantity()` limits its quantity to `1`.
|
|
252
|
+
*/
|
|
222
253
|
maxQuantity: NonNullable<AddOn['maxQuantity']> | null;
|
|
254
|
+
/** Whether the site visitor selected the add-on. */
|
|
223
255
|
isSelected: boolean;
|
|
256
|
+
/**
|
|
257
|
+
* Quantity of the add-on the site visitor selected.
|
|
258
|
+
*
|
|
259
|
+
* `0` when the visitor didn't select it.
|
|
260
|
+
*/
|
|
224
261
|
selectedQuantity: number;
|
|
225
262
|
}
|
|
263
|
+
/** A group of add-ons the service offers, and the site visitor's selections in it. */
|
|
226
264
|
interface AddOnGroupItem {
|
|
265
|
+
/** Add-on group ID. */
|
|
227
266
|
groupId: NonNullable<AddOnGroupDetail['groupId']> | null;
|
|
267
|
+
/** Name of the add-on group, translated to the current language when a translation exists. */
|
|
228
268
|
groupName: NonNullable<AddOnGroupDetail['groupName']> | null;
|
|
269
|
+
/**
|
|
270
|
+
* Text to show the site visitor with the group's add-ons, such as a question about which ones
|
|
271
|
+
* they want. Translated to the current language when a translation exists.
|
|
272
|
+
*
|
|
273
|
+
* `null` when the group has no prompt.
|
|
274
|
+
*/
|
|
229
275
|
prompt: NonNullable<AddOnGroupDetail['prompt']> | null;
|
|
230
|
-
/**
|
|
276
|
+
/**
|
|
277
|
+
* Maximum number of different add-ons the visitor can select in the group. An add-on counts once,
|
|
278
|
+
* whatever its quantity.
|
|
279
|
+
*
|
|
280
|
+
* `null` or `0` when there's no limit.
|
|
281
|
+
*/
|
|
231
282
|
maxNumberOfAddOns: NonNullable<AddOnGroupDetail['maxNumberOfAddOns']> | null;
|
|
283
|
+
/** Add-ons in the group, in display order. */
|
|
232
284
|
addOns: AddOnItem[];
|
|
285
|
+
/**
|
|
286
|
+
* Number of different add-ons the site visitor selected in the group. An add-on counts once,
|
|
287
|
+
* whatever its quantity.
|
|
288
|
+
*
|
|
289
|
+
* An add-on that's in several groups counts only in the first group that offers it, though
|
|
290
|
+
* it shows as selected in each of them.
|
|
291
|
+
*/
|
|
233
292
|
selectedCount: number;
|
|
293
|
+
/**
|
|
294
|
+
* Whether the site visitor can select another add-on in the group.
|
|
295
|
+
*
|
|
296
|
+
* `false` once `selectedCount` reaches the group's `maxNumberOfAddOns`. Always `true` when the
|
|
297
|
+
* group has no limit, meaning `maxNumberOfAddOns` is `null` or `0`.
|
|
298
|
+
*
|
|
299
|
+
* While it's `false`, `toggleAddOn()` and `setAddOnQuantity()` don't add another add-on from the
|
|
300
|
+
* group, but they still change or remove the add-ons already selected. An add-on that's also in
|
|
301
|
+
* an earlier group follows that group's limit instead.
|
|
302
|
+
*/
|
|
234
303
|
canSelectMore: boolean;
|
|
235
304
|
}
|
|
236
305
|
//#endregion
|
|
237
306
|
//#region src/extensions/contexts/service-addons-context/service-addons-context.types.d.ts
|
|
238
307
|
/** The add-ons offered for the current service, the visitor's picks, and the actions to change them. */
|
|
239
308
|
interface ServiceAddOnsContextValue {
|
|
309
|
+
/**
|
|
310
|
+
* Add-on groups the service offers, each with its add-ons and the site visitor's selections. To
|
|
311
|
+
* manage add-ons, use the [Add-Ons
|
|
312
|
+
* API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/add-ons/introduction).
|
|
313
|
+
*
|
|
314
|
+
* Empty while `isLoading` is `true`, when `hasError` is `true`, and when the service offers no
|
|
315
|
+
* add-ons.
|
|
316
|
+
*/
|
|
240
317
|
addOnGroups: AddOnGroupItem[];
|
|
241
|
-
/**
|
|
318
|
+
/**
|
|
319
|
+
* Add-ons the site visitor selected for the service, each with its add-on ID, `id`, and the
|
|
320
|
+
* quantity selected, `quantity`.
|
|
321
|
+
*
|
|
322
|
+
* Holds only add-ons the service offers. A selection of an add-on the service doesn't offer, such
|
|
323
|
+
* as a selection from an old link, doesn't show here. The next call to `toggleAddOn()` or
|
|
324
|
+
* `setAddOnQuantity()` that changes the selections removes it.
|
|
325
|
+
*
|
|
326
|
+
* Empty while `isLoading` or `hasError` is `true`, even when the visitor has selections.
|
|
327
|
+
*/
|
|
242
328
|
selected: AddOn$1[];
|
|
329
|
+
/**
|
|
330
|
+
* Whether the service or its add-ons are still loading.
|
|
331
|
+
*
|
|
332
|
+
* While it's `true`, `addOnGroups` is empty, and `toggleAddOn()` and `setAddOnQuantity()` do
|
|
333
|
+
* nothing.
|
|
334
|
+
*/
|
|
243
335
|
isLoading: boolean;
|
|
336
|
+
/**
|
|
337
|
+
* Whether loading the service's add-ons failed.
|
|
338
|
+
*
|
|
339
|
+
* When it's `true`, `addOnGroups` is empty, and `toggleAddOn()` and `setAddOnQuantity()` do
|
|
340
|
+
* nothing.
|
|
341
|
+
*/
|
|
244
342
|
hasError: boolean;
|
|
245
|
-
/**
|
|
343
|
+
/**
|
|
344
|
+
* Selects an add-on for the site visitor, or removes it when the visitor already selected it.
|
|
345
|
+
*
|
|
346
|
+
* Selecting an add-on gives it a quantity of `1`. Removing it removes it whatever its quantity.
|
|
347
|
+
* The change shows in `selected`, and in the add-on's `isSelected` and `selectedQuantity`.
|
|
348
|
+
*
|
|
349
|
+
* The call does nothing when:
|
|
350
|
+
* - The service doesn't offer the add-on.
|
|
351
|
+
* - The add-on isn't selected yet and its group's `canSelectMore` is `false`. An add-on that's in
|
|
352
|
+
* several groups counts against the first group that offers it.
|
|
353
|
+
* - `isLoading` is `true`.
|
|
354
|
+
* - `hasError` is `true`.
|
|
355
|
+
*
|
|
356
|
+
* @param addOnId - ID of the add-on, from its `addOnId`.
|
|
357
|
+
*
|
|
358
|
+
* @example Show a checkbox for each add-on
|
|
359
|
+
* ```tsx
|
|
360
|
+
* import { useServiceAddOnsContext } from '@wix/bookings/context/service-addons';
|
|
361
|
+
*
|
|
362
|
+
* function AddOnCheckboxes() {
|
|
363
|
+
* const { addOnGroups, toggleAddOn } = useServiceAddOnsContext();
|
|
364
|
+
*
|
|
365
|
+
* return (
|
|
366
|
+
* <>
|
|
367
|
+
* {addOnGroups.map((group) => (
|
|
368
|
+
* <fieldset key={group.groupId}>
|
|
369
|
+
* <legend>{group.groupName}</legend>
|
|
370
|
+
* {group.addOns.map((addOn) => (
|
|
371
|
+
* <label key={addOn.addOnId}>
|
|
372
|
+
* <input
|
|
373
|
+
* type="checkbox"
|
|
374
|
+
* checked={addOn.isSelected}
|
|
375
|
+
* disabled={!addOn.isSelected && !group.canSelectMore}
|
|
376
|
+
* onChange={() => addOn.addOnId && toggleAddOn(addOn.addOnId)}
|
|
377
|
+
* />
|
|
378
|
+
* {addOn.addOnName} {addOn.addOnPrice}
|
|
379
|
+
* </label>
|
|
380
|
+
* ))}
|
|
381
|
+
* </fieldset>
|
|
382
|
+
* ))}
|
|
383
|
+
* </>
|
|
384
|
+
* );
|
|
385
|
+
* }
|
|
386
|
+
* ```
|
|
387
|
+
*/
|
|
246
388
|
toggleAddOn: (addOnId: string) => void;
|
|
247
|
-
/**
|
|
389
|
+
/**
|
|
390
|
+
* Sets the quantity of an add-on the site visitor selects. A quantity of `0` removes the add-on.
|
|
391
|
+
*
|
|
392
|
+
* The call limits the quantity to between `0` and the add-on's `maxQuantity`, or `1` for an
|
|
393
|
+
* add-on with no `maxQuantity`, and drops any decimal part. A quantity that isn't a finite number
|
|
394
|
+
* removes the add-on. The change shows in `selected`, and in the add-on's `isSelected` and
|
|
395
|
+
* `selectedQuantity`.
|
|
396
|
+
*
|
|
397
|
+
* The call does nothing when:
|
|
398
|
+
* - The service doesn't offer the add-on.
|
|
399
|
+
* - The quantity, after these limits, is the one already selected.
|
|
400
|
+
* - The add-on isn't selected yet and its group's `canSelectMore` is `false`. An add-on that's in
|
|
401
|
+
* several groups counts against the first group that offers it.
|
|
402
|
+
* - `isLoading` is `true`.
|
|
403
|
+
* - `hasError` is `true`.
|
|
404
|
+
*
|
|
405
|
+
* @param addOnId - ID of the add-on, from its `addOnId`.
|
|
406
|
+
* @param quantity - Quantity of the add-on to select.
|
|
407
|
+
*
|
|
408
|
+
* @example Add a quantity stepper for an add-on
|
|
409
|
+
* ```tsx
|
|
410
|
+
* import { useServiceAddOnsContext } from '@wix/bookings/context/service-addons';
|
|
411
|
+
*
|
|
412
|
+
* function AddOnStepper({ addOnId }: { addOnId: string }) {
|
|
413
|
+
* const { addOnGroups, setAddOnQuantity } = useServiceAddOnsContext();
|
|
414
|
+
* const addOn = addOnGroups
|
|
415
|
+
* .flatMap((group) => group.addOns)
|
|
416
|
+
* .find((item) => item.addOnId === addOnId);
|
|
417
|
+
*
|
|
418
|
+
* if (!addOn) {
|
|
419
|
+
* return null;
|
|
420
|
+
* }
|
|
421
|
+
*
|
|
422
|
+
* const quantity = addOn.selectedQuantity;
|
|
423
|
+
* return (
|
|
424
|
+
* <div>
|
|
425
|
+
* <span>{addOn.addOnName}</span>
|
|
426
|
+
* <button
|
|
427
|
+
* disabled={quantity === 0}
|
|
428
|
+
* onClick={() => setAddOnQuantity(addOnId, quantity - 1)}
|
|
429
|
+
* >
|
|
430
|
+
* -
|
|
431
|
+
* </button>
|
|
432
|
+
* <span>{quantity}</span>
|
|
433
|
+
* <button
|
|
434
|
+
* disabled={quantity >= (addOn.maxQuantity ?? 1)}
|
|
435
|
+
* onClick={() => setAddOnQuantity(addOnId, quantity + 1)}
|
|
436
|
+
* >
|
|
437
|
+
* +
|
|
438
|
+
* </button>
|
|
439
|
+
* </div>
|
|
440
|
+
* );
|
|
441
|
+
* }
|
|
442
|
+
* ```
|
|
443
|
+
*/
|
|
248
444
|
setAddOnQuantity: (addOnId: string, quantity: number) => void;
|
|
249
445
|
}
|
|
250
446
|
/** Props accepted by {@link ServiceAddOnsContextProvider}. */
|
|
@@ -254,7 +450,13 @@ interface ServiceAddOnsContextProviderProps {
|
|
|
254
450
|
//#endregion
|
|
255
451
|
//#region src/extensions/contexts/service-addons-context/service-addons-context.d.ts
|
|
256
452
|
declare const serviceAddOnsContext: React.Context<ServiceAddOnsContextValue | null>;
|
|
257
|
-
/**
|
|
453
|
+
/**
|
|
454
|
+
* The `useServiceAddOnsContext()` hook provides access to the add-ons a Wix Bookings service offers
|
|
455
|
+
* and the add-ons the site visitor selected for it. Use it to show the service's add-on groups, and
|
|
456
|
+
* to let the visitor select add-ons and their quantities before booking.
|
|
457
|
+
*
|
|
458
|
+
* It throws an error where the context isn't available.
|
|
459
|
+
*/
|
|
258
460
|
declare function useServiceAddOnsContext(): ServiceAddOnsContextValue;
|
|
259
461
|
/** Loads the add-ons offered for the service in the surrounding ServiceContextProvider, and reads and changes the visitor's picks stored there. */
|
|
260
462
|
declare function ServiceAddOnsContextProvider({
|