@wix/bookings 1.0.1777 → 1.0.1779
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/build/cjs/context-booking-checkout.d.ts +243 -108
- package/build/cjs/context-booking-checkout.js +176 -182
- package/build/cjs/context-booking-checkout.js.map +1 -1
- package/build/cjs/context-categories.d.ts +16 -143
- package/build/cjs/context-categories.js +411 -411
- package/build/cjs/context-categories.js.map +1 -1
- package/build/cjs/context-locations.d.ts +16 -287
- package/build/cjs/context-locations.js +335 -335
- package/build/cjs/context-locations.js.map +1 -1
- package/build/cjs/context-service-addons.d.ts +2 -2
- package/build/cjs/context-service.d.ts +71 -33
- package/build/cjs/context-service.js +97 -95
- package/build/cjs/context-service.js.map +1 -1
- package/build/cjs/context-time-slots.d.ts +10 -0
- package/build/cjs/context-time-slots.js +1 -1
- package/build/cjs/context-time-slots.js.map +1 -1
- package/build/es/context-booking-checkout.d.mts +243 -108
- package/build/es/context-booking-checkout.mjs +176 -179
- package/build/es/context-booking-checkout.mjs.map +1 -1
- package/build/es/context-categories.d.mts +16 -143
- package/build/es/context-categories.mjs +411 -411
- package/build/es/context-categories.mjs.map +1 -1
- package/build/es/context-locations.d.mts +16 -287
- package/build/es/context-locations.mjs +335 -335
- package/build/es/context-locations.mjs.map +1 -1
- package/build/es/context-service-addons.d.mts +2 -2
- package/build/es/context-service.d.mts +71 -33
- package/build/es/context-service.mjs +97 -95
- package/build/es/context-service.mjs.map +1 -1
- package/build/es/context-time-slots.d.mts +10 -0
- package/build/es/context-time-slots.mjs +1 -1
- package/build/es/context-time-slots.mjs.map +1 -1
- package/build/internal/cjs/context-booking-checkout.d.ts +243 -108
- package/build/internal/cjs/context-categories.d.ts +16 -143
- package/build/internal/cjs/context-locations.d.ts +16 -287
- package/build/internal/cjs/context-service-addons.d.ts +2 -2
- package/build/internal/cjs/context-service.d.ts +71 -33
- package/build/internal/cjs/context-time-slots.d.ts +10 -0
- package/build/internal/es/context-booking-checkout.d.mts +243 -108
- package/build/internal/es/context-categories.d.mts +16 -143
- package/build/internal/es/context-locations.d.mts +16 -287
- package/build/internal/es/context-service-addons.d.mts +2 -2
- package/build/internal/es/context-service.d.mts +71 -33
- package/build/internal/es/context-time-slots.d.mts +10 -0
- package/context-runtime/context-booking-checkout/runtime.d.ts +243 -108
- package/context-runtime/context-booking-checkout/runtime.js +3 -3
- package/context-runtime/context-categories/runtime.d.ts +16 -143
- package/context-runtime/context-categories/runtime.js +2 -2
- package/context-runtime/context-locations/runtime.d.ts +16 -287
- package/context-runtime/context-locations/runtime.js +2 -2
- package/context-runtime/context-service/runtime.d.ts +71 -33
- package/context-runtime/context-service/runtime.js +3 -3
- package/context-runtime/context-service-addons/runtime.d.ts +2 -2
- package/context-runtime/context-time-slots/runtime.d.ts +10 -0
- package/context-runtime/context-time-slots/runtime.js +2 -2
- package/package.json +7 -7
|
@@ -1,93 +1,5 @@
|
|
|
1
1
|
import React, { ReactNode } from 'react';
|
|
2
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 V2Category {
|
|
70
|
-
/**
|
|
71
|
-
* Category ID.
|
|
72
|
-
* @format GUID
|
|
73
|
-
*/
|
|
74
|
-
_id?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Category name.
|
|
77
|
-
* @maxLength 500
|
|
78
|
-
* @readonly
|
|
79
|
-
*/
|
|
80
|
-
name?: string | null;
|
|
81
|
-
/**
|
|
82
|
-
* Order of a category within a category list.
|
|
83
|
-
* @readonly
|
|
84
|
-
*/
|
|
85
|
-
sortOrder?: number | null;
|
|
86
|
-
}
|
|
87
|
-
//#endregion
|
|
88
|
-
//#region src/api/adapters/category/category.d.ts
|
|
89
|
-
type Category = V2Category;
|
|
90
|
-
//#endregion
|
|
91
3
|
//#region src/lib/picker-filter.d.ts
|
|
92
4
|
/** One field of a panel filter backed by an Items Selection provider (`$in`, or `$eq` after an operator switch). */
|
|
93
5
|
interface PickerRule {
|
|
@@ -117,14 +29,18 @@ interface CategoryItem {
|
|
|
117
29
|
/**
|
|
118
30
|
* Whether the category is selected, meaning its ID is in the page URL's `category` query
|
|
119
31
|
* parameter.
|
|
32
|
+
*
|
|
33
|
+
* Use it to mark the selected option in a category filter. When no item is selected, no
|
|
34
|
+
* category is selected, such as for an "All services" option.
|
|
120
35
|
*/
|
|
121
36
|
isSelected: boolean;
|
|
122
37
|
}
|
|
123
38
|
/** The business service categories, the selected category, the loading and error state, and the actions to change or reload them. */
|
|
124
39
|
interface CategoriesContextValue {
|
|
125
40
|
/**
|
|
126
|
-
* Service categories,
|
|
127
|
-
*
|
|
41
|
+
* Service categories, each with its ID, name, and whether it's selected, sorted by their sort
|
|
42
|
+
* order. Use them to render a list of categories that site visitors select from. To manage
|
|
43
|
+
* categories, use the
|
|
128
44
|
* [Categories V2
|
|
129
45
|
* API](https://dev.wix.com/docs/api-reference/business-solutions/bookings/services/categories-v2/introduction).
|
|
130
46
|
*
|
|
@@ -132,50 +48,10 @@ interface CategoriesContextValue {
|
|
|
132
48
|
* categories, it holds only the picked categories.
|
|
133
49
|
*
|
|
134
50
|
* Empty while the categories load, and when they fail to load.
|
|
135
|
-
*
|
|
136
|
-
* Don't change the array or its items, for example by sorting the array in place. Every
|
|
137
|
-
* component that uses the context gets the same array.
|
|
138
|
-
*/
|
|
139
|
-
categories: Category[];
|
|
140
|
-
/**
|
|
141
|
-
* Service categories as list items, each with its ID, name, and whether it's selected. Use them
|
|
142
|
-
* to render a list of categories that site visitors select from.
|
|
143
|
-
*
|
|
144
|
-
* Holds the same categories as `categories`, in the same order.
|
|
145
51
|
*/
|
|
146
52
|
categoryItems: CategoryItem[];
|
|
147
53
|
/**
|
|
148
|
-
*
|
|
149
|
-
*
|
|
150
|
-
* It already holds the URL's category while the categories load, before `categories` fills. It
|
|
151
|
-
* can hold an ID that isn't in `categories`, such as an ID from an outdated link.
|
|
152
|
-
* `selectedCategory` is then `null`.
|
|
153
|
-
*
|
|
154
|
-
* `null` when no category is selected.
|
|
155
|
-
*/
|
|
156
|
-
selectedCategoryId: string | null;
|
|
157
|
-
/**
|
|
158
|
-
* Position of the selected category in `categories`, starting at `0`.
|
|
159
|
-
*
|
|
160
|
-
* `-1` when no category is selected, when `selectedCategoryId` isn't in `categories`, and while
|
|
161
|
-
* the categories load.
|
|
162
|
-
*/
|
|
163
|
-
selectedCategoryIndex: number;
|
|
164
|
-
/**
|
|
165
|
-
* Selected category, with its details, such as its ID, name, and sort order.
|
|
166
|
-
*
|
|
167
|
-
* `null` when no category is selected, when `selectedCategoryId` isn't in `categories`, and
|
|
168
|
-
* while the categories load.
|
|
169
|
-
*/
|
|
170
|
-
selectedCategory: Category | null;
|
|
171
|
-
/**
|
|
172
|
-
* Name of the selected category.
|
|
173
|
-
*
|
|
174
|
-
* `null` when `selectedCategory` is `null`, or when the category has no name.
|
|
175
|
-
*/
|
|
176
|
-
selectedCategoryName: string | null;
|
|
177
|
-
/**
|
|
178
|
-
* Whether `categories` holds multiple categories with an ID. Use it to hide a category filter
|
|
54
|
+
* Whether `categoryItems` holds multiple categories with an ID. Use it to hide a category filter
|
|
179
55
|
* when there's nothing to choose between.
|
|
180
56
|
*
|
|
181
57
|
* `false` while the categories load, and when they fail to load.
|
|
@@ -185,14 +61,14 @@ interface CategoriesContextValue {
|
|
|
185
61
|
* Whether the categories are loading. It's `true` during the first load, and while `refetch()`
|
|
186
62
|
* reloads them.
|
|
187
63
|
*
|
|
188
|
-
* While it's `true`, `
|
|
64
|
+
* While it's `true`, `categoryItems` is empty, and `selectCategory()` does
|
|
189
65
|
* nothing.
|
|
190
66
|
*/
|
|
191
67
|
isLoading: boolean;
|
|
192
68
|
/**
|
|
193
69
|
* Whether the categories failed to load.
|
|
194
70
|
*
|
|
195
|
-
* When it's `true`, `
|
|
71
|
+
* When it's `true`, `categoryItems` is empty. To try again, call `refetch()`.
|
|
196
72
|
*
|
|
197
73
|
* It's also `true`, with the same empty values, after a component under the context fails to
|
|
198
74
|
* render. Then it stays `true` until the page reloads: `refetch()` doesn't clear it, and
|
|
@@ -202,7 +78,7 @@ interface CategoriesContextValue {
|
|
|
202
78
|
/**
|
|
203
79
|
* Reloads the service categories.
|
|
204
80
|
*
|
|
205
|
-
* While they reload, `isLoading` is `true`, and `
|
|
81
|
+
* While they reload, `isLoading` is `true`, and `categoryItems` is empty. The
|
|
206
82
|
* selected category doesn't change.
|
|
207
83
|
*
|
|
208
84
|
* Use it to try again after the categories fail to load, when `hasError` is `true`. It doesn't
|
|
@@ -232,16 +108,15 @@ interface CategoriesContextValue {
|
|
|
232
108
|
/**
|
|
233
109
|
* Selects a category, or clears the selection.
|
|
234
110
|
*
|
|
235
|
-
* Selecting a category sets the page URL's `category` query parameter, which updates
|
|
236
|
-
* `
|
|
237
|
-
* the selection, `selectCategory()`:
|
|
111
|
+
* Selecting a category sets the page URL's `category` query parameter, which updates each
|
|
112
|
+
* item's `isSelected`. When it changes the selection, `selectCategory()`:
|
|
238
113
|
* - Adds an entry to the browser history, so the browser's Back button returns to the previous
|
|
239
114
|
* selection.
|
|
240
115
|
* - Removes the URL's `page` query parameter, so a list of services on the page starts again
|
|
241
116
|
* from its first page.
|
|
242
117
|
* - Keeps the page's scroll position.
|
|
243
118
|
*
|
|
244
|
-
* It doesn't check that the ID is in `
|
|
119
|
+
* It doesn't check that the ID is in `categoryItems`.
|
|
245
120
|
*
|
|
246
121
|
* Does nothing while `isLoading` is `true`.
|
|
247
122
|
*
|
|
@@ -253,11 +128,12 @@ interface CategoriesContextValue {
|
|
|
253
128
|
* import { useCategoriesContext } from '@wix/bookings/context/categories';
|
|
254
129
|
*
|
|
255
130
|
* function CategoryDropdown() {
|
|
256
|
-
* const { categoryItems,
|
|
131
|
+
* const { categoryItems, selectCategory } = useCategoriesContext();
|
|
132
|
+
* const selected = categoryItems.find((item) => item.isSelected);
|
|
257
133
|
*
|
|
258
134
|
* return (
|
|
259
135
|
* <select
|
|
260
|
-
* value={
|
|
136
|
+
* value={selected?.categoryId ?? ''}
|
|
261
137
|
* onChange={(event) => selectCategory(event.target.value || null)}
|
|
262
138
|
* >
|
|
263
139
|
* <option value="">All services</option>
|
|
@@ -277,8 +153,6 @@ interface CategoriesContextValue {
|
|
|
277
153
|
}
|
|
278
154
|
/** Props accepted by {@link CategoriesContextProvider}. */
|
|
279
155
|
interface CategoriesContextProviderProps {
|
|
280
|
-
/** Selected on load when the page URL names no category. */
|
|
281
|
-
initialCategoryId?: string;
|
|
282
156
|
/** Shows only the picked categories. */
|
|
283
157
|
categoriesPicker?: CategoriesPickerFilter;
|
|
284
158
|
/** Bumped by the editor bundle on realtime data-changes; non-zero refetches, bypassing warmup. */
|
|
@@ -297,7 +171,6 @@ declare const CATEGORIES_CONTEXT_MISSING_PROVIDER_ERROR = "useCategoriesContext
|
|
|
297
171
|
declare function useCategoriesContext(): CategoriesContextValue;
|
|
298
172
|
/** Loads the business service categories and tracks the selected category in the page URL. */
|
|
299
173
|
declare function CategoriesContextProvider({
|
|
300
|
-
initialCategoryId,
|
|
301
174
|
categoriesPicker,
|
|
302
175
|
refreshSignal,
|
|
303
176
|
children
|