@wix/site-service-lightbox 1.0.6 → 2.0.0

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @wix/site-service-lightbox
2
2
 
3
- Opens and closes **lightboxes** (popups) and reads the context the open lightbox was
3
+ Opens and closes **lightboxes** (popups) and reads the payload the open lightbox was
4
4
  opened with. Only one lightbox is open at a time. UI & Viewport category.
5
5
 
6
6
  ## Install
@@ -16,13 +16,13 @@ import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
16
16
 
17
17
  const lightbox = useService(LightboxDefinition)
18
18
 
19
- type SignupContext = { source: string }
19
+ type SignupPayload = { source: string }
20
20
 
21
- // Open a lightbox by its slug, passing it some context:
22
- await lightbox.open<SignupContext>({ slug: 'signup', context: { source: 'signup' } })
21
+ // Open a lightbox by its slug, passing it a payload:
22
+ await lightbox.open<SignupPayload>({ slug: 'signup', payload: { source: 'signup' } })
23
23
 
24
24
  // In a component rendered inside the lightbox:
25
- const context = lightbox.getContext<SignupContext>()
25
+ const payload = lightbox.getPayload<SignupPayload>()
26
26
  lightbox.close()
27
27
  ```
28
28
 
@@ -40,8 +40,8 @@ createServicesMap().addService(LightboxDefinition, LightboxService, {
40
40
  close: () => {
41
41
  /* close the open lightbox */
42
42
  },
43
- getContext: () => {
44
- /* return the open lightbox's context */
43
+ getPayload: () => {
44
+ /* return the open lightbox's payload */
45
45
  },
46
46
  })
47
47
  ```
@@ -50,17 +50,26 @@ createServicesMap().addService(LightboxDefinition, LightboxService, {
50
50
 
51
51
  | Member | Type | Description |
52
52
  |---|---|---|
53
- | `open` | `<TContext = LightboxContext>(options: { slug: string; context?: TContext } \| { pageId: string; context?: TContext }) => Promise<void>` | Opens the lightbox with `context`. Pass `slug` (the lightbox page's `pageUriSEO`), or the deprecated `pageId`, not both. Returns the host's promise. |
53
+ | `open` | `<TPayload = LightboxPayload>(options: { slug: string; payload?: TPayload } \| { pageId: string; payload?: TPayload }) => Promise<void>` | Opens the lightbox with `payload`. Pass `slug` (the lightbox page's `pageUriSEO`), or the deprecated `pageId`, not both. Returns the host's promise. |
54
54
  | `close` | `() => void` | Closes the currently open lightbox. Fire-and-forget: returns nothing, even if the host's close is async. |
55
- | `getContext` | `<TContext = LightboxContext>() => TContext` | Returns the context the open lightbox was opened with. |
55
+ | `getPayload` | `<TPayload = LightboxPayload>() => TPayload` | Returns the payload the open lightbox was opened with. |
56
56
 
57
57
  All three are plain methods — this service exposes no property getters.
58
58
 
59
- The context is opaque to the service: it passes the value through unchanged and never reads it
60
- (`LightboxContext` is `unknown`).
61
- `TContext` types it for the caller, but nothing checks that `getContext<TContext>()` asks for
59
+ The payload is opaque to the service: it passes the value through unchanged and never reads it
60
+ (`LightboxPayload` is `unknown`).
61
+ `TPayload` types it for the caller, but nothing checks that `getPayload<TPayload>()` asks for
62
62
  the same type the lightbox was opened with; that is the caller's assertion.
63
63
 
64
+ ## Migrating from 1.x
65
+
66
+ 2.0.0 renames the value you pass to a lightbox from "context" to "payload", with no aliases:
67
+
68
+ - `open({ slug, context })` becomes `open({ slug, payload })`.
69
+ - `getContext()` becomes `getPayload()`.
70
+ - `LightboxContext` becomes `LightboxPayload`, and the `TContext` type parameter becomes `TPayload`.
71
+ - The host config's `getContext` becomes `getPayload`, and `open` reads `options.payload`.
72
+
64
73
  ## Configuration
65
74
 
66
75
  `ILightboxServiceConfig`:
@@ -69,11 +78,11 @@ the same type the lightbox was opened with; that is the caller's assertion.
69
78
  export type ILightboxServiceConfig = {
70
79
  open: (options: LightboxOpenOptions) => Promise<void>
71
80
  close: () => void
72
- getContext: () => LightboxContext
81
+ getPayload: () => LightboxPayload
73
82
  }
74
83
  ```
75
84
 
76
- - `open`, `close`, `getContext` — the host's implementations. The service calls them on each use.
85
+ - `open`, `close`, `getPayload` — the host's implementations. The service calls them on each use.
77
86
  All three are required; the service has no fallback behavior.
78
87
  - `open` receives the options unchanged, with either `slug` or `pageId`, and must handle both. It should
79
88
  reject when no lightbox has the slug.
@@ -3,11 +3,11 @@ import type { ServiceDefinition } from '@wix/services-definitions';
3
3
  * Value you specify when you open a popup. It can be any value. The service passes it through without
4
4
  * reading or copying it.
5
5
  */
6
- export type LightboxContext = unknown;
6
+ export type LightboxPayload = unknown;
7
7
  /**
8
8
  * Options for `open()` that identify the popup by its slug.
9
9
  */
10
- export type LightboxOpenBySlugOptions<TContext = LightboxContext> = {
10
+ export type LightboxOpenBySlugOptions<TPayload = LightboxPayload> = {
11
11
  /**
12
12
  * Slug of the popup to open, the `pageUriSEO` of the popup page. It's the popup's `slug` in
13
13
  * `@wix/site-service-pages`.
@@ -17,16 +17,16 @@ export type LightboxOpenBySlugOptions<TContext = LightboxContext> = {
17
17
  slug: string;
18
18
  pageId?: never;
19
19
  /**
20
- * Information to pass to the popup. Components inside the popup read it with `getContext()`.
20
+ * Information to pass to the popup. Components inside the popup read it with `getPayload()`.
21
21
  *
22
22
  * @exampleValue `{ "productId": "spring-jacket" }`
23
23
  */
24
- context?: TContext;
24
+ payload?: TPayload;
25
25
  };
26
26
  /**
27
27
  * Options for `open()` that identify the popup by its page ID.
28
28
  */
29
- export type LightboxOpenByPageIdOptions<TContext = LightboxContext> = {
29
+ export type LightboxOpenByPageIdOptions<TPayload = LightboxPayload> = {
30
30
  /**
31
31
  * Page ID of the popup to open.
32
32
  *
@@ -42,17 +42,17 @@ export type LightboxOpenByPageIdOptions<TContext = LightboxContext> = {
42
42
  pageId: string;
43
43
  slug?: never;
44
44
  /**
45
- * Information to pass to the popup. Components inside the popup read it with `getContext()`.
45
+ * Information to pass to the popup. Components inside the popup read it with `getPayload()`.
46
46
  *
47
47
  * @exampleValue `{ "productId": "spring-jacket" }`
48
48
  */
49
- context?: TContext;
49
+ payload?: TPayload;
50
50
  };
51
51
  /**
52
52
  * Options for `open()`, with the popup to open and the value to open it with. Specify the popup by
53
53
  * `slug`. Specifying it by `pageId` still works, but is deprecated.
54
54
  */
55
- export type LightboxOpenOptions<TContext = LightboxContext> = LightboxOpenBySlugOptions<TContext> | LightboxOpenByPageIdOptions<TContext>;
55
+ export type LightboxOpenOptions<TPayload = LightboxPayload> = LightboxOpenBySlugOptions<TPayload> | LightboxOpenByPageIdOptions<TPayload>;
56
56
  /**
57
57
  * Values the host supplies when it creates the service.
58
58
  */
@@ -60,7 +60,7 @@ export type ILightboxServiceConfig = {
60
60
  /** Opens the popup with the slug or the page ID, and rejects when no popup has that slug. */
61
61
  open: (options: LightboxOpenOptions) => Promise<void>;
62
62
  close: () => void;
63
- getContext: () => LightboxContext;
63
+ getPayload: () => LightboxPayload;
64
64
  };
65
65
  /**
66
66
  * Opens and closes popups on a Wix site, and passes data to the popup that opens.
@@ -70,8 +70,8 @@ export interface ILightboxService {
70
70
  * Opens a popup over the current page.
71
71
  *
72
72
  * Opening a popup closes any popup that's already open. If the popup is already open, it stays open,
73
- * and its context is replaced with the `context` you specify, or with `undefined` if you omit
74
- * `context`.
73
+ * and its payload is replaced with the `payload` you specify, or with `undefined` if you omit
74
+ * `payload`.
75
75
  *
76
76
  * Specify the popup by `slug`. Specifying it by `pageId` is deprecated, but still works.
77
77
  *
@@ -85,7 +85,7 @@ export interface ILightboxService {
85
85
  * import { useService } from '@wix/services-manager-react'
86
86
  * import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
87
87
  *
88
- * type QuickViewContext = { productId: string }
88
+ * type QuickViewPayload = { productId: string }
89
89
  *
90
90
  * function QuickViewButton({ productId }: { productId: string }) {
91
91
  * const lightboxService = useService(LightboxDefinition)
@@ -94,7 +94,7 @@ export interface ILightboxService {
94
94
  * const openQuickView = () => {
95
95
  * setFailed(false)
96
96
  * lightboxService
97
- * .open<QuickViewContext>({ slug: 'quick-view', context: { productId } })
97
+ * .open<QuickViewPayload>({ slug: 'quick-view', payload: { productId } })
98
98
  * .catch(() => setFailed(true))
99
99
  * }
100
100
  *
@@ -107,7 +107,7 @@ export interface ILightboxService {
107
107
  * }
108
108
  * ```
109
109
  */
110
- open<TContext = LightboxContext>(options: LightboxOpenOptions<TContext>): Promise<void>;
110
+ open<TPayload = LightboxPayload>(options: LightboxOpenOptions<TPayload>): Promise<void>;
111
111
  /**
112
112
  * Closes the open popup.
113
113
  *
@@ -154,17 +154,17 @@ export interface ILightboxService {
154
154
  */
155
155
  close(): void;
156
156
  /**
157
- * Retrieves the context of the open popup.
157
+ * Retrieves the payload of the open popup.
158
158
  *
159
- * It returns the context of whichever popup is open, regardless of the component that calls it, so call
159
+ * It returns the payload of whichever popup is open, regardless of the component that calls it, so call
160
160
  * it from a component inside the popup.
161
161
  *
162
- * It takes no arguments. In TypeScript, you can specify the context's type in angle brackets, as in
163
- * `getContext<QuickViewContext | undefined>()`. Use the type you specified for `context` in `open()`,
162
+ * It takes no arguments. In TypeScript, you can specify the payload's type in angle brackets, as in
163
+ * `getPayload<QuickViewPayload | undefined>()`. Use the type you specified for `payload` in `open()`,
164
164
  * plus `undefined`. TypeScript doesn't check that the two match, so a different type gives you wrong
165
165
  * types without an error. Without a type, the return type is `unknown`.
166
166
  *
167
- * @returns Context of the open popup.
167
+ * @returns Payload of the open popup.
168
168
  *
169
169
  * `undefined` when no popup is open.
170
170
  *
@@ -175,21 +175,21 @@ export interface ILightboxService {
175
175
  * import { useService } from '@wix/services-manager-react'
176
176
  * import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
177
177
  *
178
- * type QuickViewContext = { productId: string }
178
+ * type QuickViewPayload = { productId: string }
179
179
  *
180
180
  * function QuickViewDetails() {
181
181
  * const lightboxService = useService(LightboxDefinition)
182
- * const context = lightboxService.getContext<QuickViewContext | undefined>()
182
+ * const payload = lightboxService.getPayload<QuickViewPayload | undefined>()
183
183
  *
184
- * if (!context) {
184
+ * if (!payload) {
185
185
  * return <p>Choose a product to see its details.</p>
186
186
  * }
187
187
  *
188
- * return <ProductSummary productId={context.productId} />
188
+ * return <ProductSummary productId={payload.productId} />
189
189
  * }
190
190
  * ```
191
191
  */
192
- getContext<TContext = LightboxContext>(): TContext;
192
+ getPayload<TPayload = LightboxPayload>(): TPayload;
193
193
  }
194
194
  export type ILightboxDefinition = ServiceDefinition<ILightboxService, ILightboxServiceConfig>;
195
195
  export declare const LightboxDefinition: string & {
@@ -9,7 +9,7 @@ exports.LightboxService = (0, services_definitions_1.implementService)(definitio
9
9
  close: () => {
10
10
  config.close();
11
11
  },
12
- getContext: () => config.getContext(),
12
+ getPayload: () => config.getPayload(),
13
13
  };
14
14
  });
15
15
  //# sourceMappingURL=lightboxService.js.map
@@ -1 +1 @@
1
- export type { ILightboxService, ILightboxServiceConfig, ILightboxDefinition, LightboxContext, LightboxOpenOptions, LightboxOpenBySlugOptions, LightboxOpenByPageIdOptions, } from '../definition';
1
+ export type { ILightboxService, ILightboxServiceConfig, ILightboxDefinition, LightboxPayload, LightboxOpenOptions, LightboxOpenBySlugOptions, LightboxOpenByPageIdOptions, } from '../definition';
@@ -3,11 +3,11 @@ import type { ServiceDefinition } from '@wix/services-definitions';
3
3
  * Value you specify when you open a popup. It can be any value. The service passes it through without
4
4
  * reading or copying it.
5
5
  */
6
- export type LightboxContext = unknown;
6
+ export type LightboxPayload = unknown;
7
7
  /**
8
8
  * Options for `open()` that identify the popup by its slug.
9
9
  */
10
- export type LightboxOpenBySlugOptions<TContext = LightboxContext> = {
10
+ export type LightboxOpenBySlugOptions<TPayload = LightboxPayload> = {
11
11
  /**
12
12
  * Slug of the popup to open, the `pageUriSEO` of the popup page. It's the popup's `slug` in
13
13
  * `@wix/site-service-pages`.
@@ -17,16 +17,16 @@ export type LightboxOpenBySlugOptions<TContext = LightboxContext> = {
17
17
  slug: string;
18
18
  pageId?: never;
19
19
  /**
20
- * Information to pass to the popup. Components inside the popup read it with `getContext()`.
20
+ * Information to pass to the popup. Components inside the popup read it with `getPayload()`.
21
21
  *
22
22
  * @exampleValue `{ "productId": "spring-jacket" }`
23
23
  */
24
- context?: TContext;
24
+ payload?: TPayload;
25
25
  };
26
26
  /**
27
27
  * Options for `open()` that identify the popup by its page ID.
28
28
  */
29
- export type LightboxOpenByPageIdOptions<TContext = LightboxContext> = {
29
+ export type LightboxOpenByPageIdOptions<TPayload = LightboxPayload> = {
30
30
  /**
31
31
  * Page ID of the popup to open.
32
32
  *
@@ -42,17 +42,17 @@ export type LightboxOpenByPageIdOptions<TContext = LightboxContext> = {
42
42
  pageId: string;
43
43
  slug?: never;
44
44
  /**
45
- * Information to pass to the popup. Components inside the popup read it with `getContext()`.
45
+ * Information to pass to the popup. Components inside the popup read it with `getPayload()`.
46
46
  *
47
47
  * @exampleValue `{ "productId": "spring-jacket" }`
48
48
  */
49
- context?: TContext;
49
+ payload?: TPayload;
50
50
  };
51
51
  /**
52
52
  * Options for `open()`, with the popup to open and the value to open it with. Specify the popup by
53
53
  * `slug`. Specifying it by `pageId` still works, but is deprecated.
54
54
  */
55
- export type LightboxOpenOptions<TContext = LightboxContext> = LightboxOpenBySlugOptions<TContext> | LightboxOpenByPageIdOptions<TContext>;
55
+ export type LightboxOpenOptions<TPayload = LightboxPayload> = LightboxOpenBySlugOptions<TPayload> | LightboxOpenByPageIdOptions<TPayload>;
56
56
  /**
57
57
  * Values the host supplies when it creates the service.
58
58
  */
@@ -60,7 +60,7 @@ export type ILightboxServiceConfig = {
60
60
  /** Opens the popup with the slug or the page ID, and rejects when no popup has that slug. */
61
61
  open: (options: LightboxOpenOptions) => Promise<void>;
62
62
  close: () => void;
63
- getContext: () => LightboxContext;
63
+ getPayload: () => LightboxPayload;
64
64
  };
65
65
  /**
66
66
  * Opens and closes popups on a Wix site, and passes data to the popup that opens.
@@ -70,8 +70,8 @@ export interface ILightboxService {
70
70
  * Opens a popup over the current page.
71
71
  *
72
72
  * Opening a popup closes any popup that's already open. If the popup is already open, it stays open,
73
- * and its context is replaced with the `context` you specify, or with `undefined` if you omit
74
- * `context`.
73
+ * and its payload is replaced with the `payload` you specify, or with `undefined` if you omit
74
+ * `payload`.
75
75
  *
76
76
  * Specify the popup by `slug`. Specifying it by `pageId` is deprecated, but still works.
77
77
  *
@@ -85,7 +85,7 @@ export interface ILightboxService {
85
85
  * import { useService } from '@wix/services-manager-react'
86
86
  * import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
87
87
  *
88
- * type QuickViewContext = { productId: string }
88
+ * type QuickViewPayload = { productId: string }
89
89
  *
90
90
  * function QuickViewButton({ productId }: { productId: string }) {
91
91
  * const lightboxService = useService(LightboxDefinition)
@@ -94,7 +94,7 @@ export interface ILightboxService {
94
94
  * const openQuickView = () => {
95
95
  * setFailed(false)
96
96
  * lightboxService
97
- * .open<QuickViewContext>({ slug: 'quick-view', context: { productId } })
97
+ * .open<QuickViewPayload>({ slug: 'quick-view', payload: { productId } })
98
98
  * .catch(() => setFailed(true))
99
99
  * }
100
100
  *
@@ -107,7 +107,7 @@ export interface ILightboxService {
107
107
  * }
108
108
  * ```
109
109
  */
110
- open<TContext = LightboxContext>(options: LightboxOpenOptions<TContext>): Promise<void>;
110
+ open<TPayload = LightboxPayload>(options: LightboxOpenOptions<TPayload>): Promise<void>;
111
111
  /**
112
112
  * Closes the open popup.
113
113
  *
@@ -154,17 +154,17 @@ export interface ILightboxService {
154
154
  */
155
155
  close(): void;
156
156
  /**
157
- * Retrieves the context of the open popup.
157
+ * Retrieves the payload of the open popup.
158
158
  *
159
- * It returns the context of whichever popup is open, regardless of the component that calls it, so call
159
+ * It returns the payload of whichever popup is open, regardless of the component that calls it, so call
160
160
  * it from a component inside the popup.
161
161
  *
162
- * It takes no arguments. In TypeScript, you can specify the context's type in angle brackets, as in
163
- * `getContext<QuickViewContext | undefined>()`. Use the type you specified for `context` in `open()`,
162
+ * It takes no arguments. In TypeScript, you can specify the payload's type in angle brackets, as in
163
+ * `getPayload<QuickViewPayload | undefined>()`. Use the type you specified for `payload` in `open()`,
164
164
  * plus `undefined`. TypeScript doesn't check that the two match, so a different type gives you wrong
165
165
  * types without an error. Without a type, the return type is `unknown`.
166
166
  *
167
- * @returns Context of the open popup.
167
+ * @returns Payload of the open popup.
168
168
  *
169
169
  * `undefined` when no popup is open.
170
170
  *
@@ -175,21 +175,21 @@ export interface ILightboxService {
175
175
  * import { useService } from '@wix/services-manager-react'
176
176
  * import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
177
177
  *
178
- * type QuickViewContext = { productId: string }
178
+ * type QuickViewPayload = { productId: string }
179
179
  *
180
180
  * function QuickViewDetails() {
181
181
  * const lightboxService = useService(LightboxDefinition)
182
- * const context = lightboxService.getContext<QuickViewContext | undefined>()
182
+ * const payload = lightboxService.getPayload<QuickViewPayload | undefined>()
183
183
  *
184
- * if (!context) {
184
+ * if (!payload) {
185
185
  * return <p>Choose a product to see its details.</p>
186
186
  * }
187
187
  *
188
- * return <ProductSummary productId={context.productId} />
188
+ * return <ProductSummary productId={payload.productId} />
189
189
  * }
190
190
  * ```
191
191
  */
192
- getContext<TContext = LightboxContext>(): TContext;
192
+ getPayload<TPayload = LightboxPayload>(): TPayload;
193
193
  }
194
194
  export type ILightboxDefinition = ServiceDefinition<ILightboxService, ILightboxServiceConfig>;
195
195
  export declare const LightboxDefinition: string & {
@@ -6,7 +6,7 @@ export const LightboxService = implementService(LightboxDefinition, ({ config })
6
6
  close: () => {
7
7
  config.close();
8
8
  },
9
- getContext: () => config.getContext(),
9
+ getPayload: () => config.getPayload(),
10
10
  };
11
11
  });
12
12
  //# sourceMappingURL=lightboxService.js.map
@@ -1 +1 @@
1
- export type { ILightboxService, ILightboxServiceConfig, ILightboxDefinition, LightboxContext, LightboxOpenOptions, LightboxOpenBySlugOptions, LightboxOpenByPageIdOptions, } from '../definition';
1
+ export type { ILightboxService, ILightboxServiceConfig, ILightboxDefinition, LightboxPayload, LightboxOpenOptions, LightboxOpenBySlugOptions, LightboxOpenByPageIdOptions, } from '../definition';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/site-service-lightbox",
3
- "version": "1.0.6",
3
+ "version": "2.0.0",
4
4
  "license": "UNLICENSED",
5
5
  "files": [
6
6
  "dist",
@@ -77,5 +77,5 @@
77
77
  ]
78
78
  }
79
79
  },
80
- "falconPackageHash": "6db91e0225dc0f16a3b6d10c58de136f4ee33567d86e83fda05a4172"
80
+ "falconPackageHash": "b35a9b392c11fd370d1fe4bfd7ebab689a58367c71709783ddd00835"
81
81
  }
@@ -5,12 +5,12 @@ import type { ServiceDefinition } from '@wix/services-definitions'
5
5
  * Value you specify when you open a popup. It can be any value. The service passes it through without
6
6
  * reading or copying it.
7
7
  */
8
- export type LightboxContext = unknown
8
+ export type LightboxPayload = unknown
9
9
 
10
10
  /**
11
11
  * Options for `open()` that identify the popup by its slug.
12
12
  */
13
- export type LightboxOpenBySlugOptions<TContext = LightboxContext> = {
13
+ export type LightboxOpenBySlugOptions<TPayload = LightboxPayload> = {
14
14
  /**
15
15
  * Slug of the popup to open, the `pageUriSEO` of the popup page. It's the popup's `slug` in
16
16
  * `@wix/site-service-pages`.
@@ -20,17 +20,17 @@ export type LightboxOpenBySlugOptions<TContext = LightboxContext> = {
20
20
  slug: string
21
21
  pageId?: never
22
22
  /**
23
- * Information to pass to the popup. Components inside the popup read it with `getContext()`.
23
+ * Information to pass to the popup. Components inside the popup read it with `getPayload()`.
24
24
  *
25
25
  * @exampleValue `{ "productId": "spring-jacket" }`
26
26
  */
27
- context?: TContext
27
+ payload?: TPayload
28
28
  }
29
29
 
30
30
  /**
31
31
  * Options for `open()` that identify the popup by its page ID.
32
32
  */
33
- export type LightboxOpenByPageIdOptions<TContext = LightboxContext> = {
33
+ export type LightboxOpenByPageIdOptions<TPayload = LightboxPayload> = {
34
34
  /**
35
35
  * Page ID of the popup to open.
36
36
  *
@@ -46,20 +46,20 @@ export type LightboxOpenByPageIdOptions<TContext = LightboxContext> = {
46
46
  pageId: string
47
47
  slug?: never
48
48
  /**
49
- * Information to pass to the popup. Components inside the popup read it with `getContext()`.
49
+ * Information to pass to the popup. Components inside the popup read it with `getPayload()`.
50
50
  *
51
51
  * @exampleValue `{ "productId": "spring-jacket" }`
52
52
  */
53
- context?: TContext
53
+ payload?: TPayload
54
54
  }
55
55
 
56
56
  /**
57
57
  * Options for `open()`, with the popup to open and the value to open it with. Specify the popup by
58
58
  * `slug`. Specifying it by `pageId` still works, but is deprecated.
59
59
  */
60
- export type LightboxOpenOptions<TContext = LightboxContext> =
61
- | LightboxOpenBySlugOptions<TContext>
62
- | LightboxOpenByPageIdOptions<TContext>
60
+ export type LightboxOpenOptions<TPayload = LightboxPayload> =
61
+ | LightboxOpenBySlugOptions<TPayload>
62
+ | LightboxOpenByPageIdOptions<TPayload>
63
63
 
64
64
  /**
65
65
  * Values the host supplies when it creates the service.
@@ -68,7 +68,7 @@ export type ILightboxServiceConfig = {
68
68
  /** Opens the popup with the slug or the page ID, and rejects when no popup has that slug. */
69
69
  open: (options: LightboxOpenOptions) => Promise<void>
70
70
  close: () => void
71
- getContext: () => LightboxContext
71
+ getPayload: () => LightboxPayload
72
72
  }
73
73
 
74
74
  /**
@@ -79,8 +79,8 @@ export interface ILightboxService {
79
79
  * Opens a popup over the current page.
80
80
  *
81
81
  * Opening a popup closes any popup that's already open. If the popup is already open, it stays open,
82
- * and its context is replaced with the `context` you specify, or with `undefined` if you omit
83
- * `context`.
82
+ * and its payload is replaced with the `payload` you specify, or with `undefined` if you omit
83
+ * `payload`.
84
84
  *
85
85
  * Specify the popup by `slug`. Specifying it by `pageId` is deprecated, but still works.
86
86
  *
@@ -94,7 +94,7 @@ export interface ILightboxService {
94
94
  * import { useService } from '@wix/services-manager-react'
95
95
  * import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
96
96
  *
97
- * type QuickViewContext = { productId: string }
97
+ * type QuickViewPayload = { productId: string }
98
98
  *
99
99
  * function QuickViewButton({ productId }: { productId: string }) {
100
100
  * const lightboxService = useService(LightboxDefinition)
@@ -103,7 +103,7 @@ export interface ILightboxService {
103
103
  * const openQuickView = () => {
104
104
  * setFailed(false)
105
105
  * lightboxService
106
- * .open<QuickViewContext>({ slug: 'quick-view', context: { productId } })
106
+ * .open<QuickViewPayload>({ slug: 'quick-view', payload: { productId } })
107
107
  * .catch(() => setFailed(true))
108
108
  * }
109
109
  *
@@ -116,7 +116,7 @@ export interface ILightboxService {
116
116
  * }
117
117
  * ```
118
118
  */
119
- open<TContext = LightboxContext>(options: LightboxOpenOptions<TContext>): Promise<void>
119
+ open<TPayload = LightboxPayload>(options: LightboxOpenOptions<TPayload>): Promise<void>
120
120
  /**
121
121
  * Closes the open popup.
122
122
  *
@@ -163,17 +163,17 @@ export interface ILightboxService {
163
163
  */
164
164
  close(): void
165
165
  /**
166
- * Retrieves the context of the open popup.
166
+ * Retrieves the payload of the open popup.
167
167
  *
168
- * It returns the context of whichever popup is open, regardless of the component that calls it, so call
168
+ * It returns the payload of whichever popup is open, regardless of the component that calls it, so call
169
169
  * it from a component inside the popup.
170
170
  *
171
- * It takes no arguments. In TypeScript, you can specify the context's type in angle brackets, as in
172
- * `getContext<QuickViewContext | undefined>()`. Use the type you specified for `context` in `open()`,
171
+ * It takes no arguments. In TypeScript, you can specify the payload's type in angle brackets, as in
172
+ * `getPayload<QuickViewPayload | undefined>()`. Use the type you specified for `payload` in `open()`,
173
173
  * plus `undefined`. TypeScript doesn't check that the two match, so a different type gives you wrong
174
174
  * types without an error. Without a type, the return type is `unknown`.
175
175
  *
176
- * @returns Context of the open popup.
176
+ * @returns Payload of the open popup.
177
177
  *
178
178
  * `undefined` when no popup is open.
179
179
  *
@@ -184,21 +184,21 @@ export interface ILightboxService {
184
184
  * import { useService } from '@wix/services-manager-react'
185
185
  * import { LightboxDefinition } from '@wix/site-service-lightbox/definition'
186
186
  *
187
- * type QuickViewContext = { productId: string }
187
+ * type QuickViewPayload = { productId: string }
188
188
  *
189
189
  * function QuickViewDetails() {
190
190
  * const lightboxService = useService(LightboxDefinition)
191
- * const context = lightboxService.getContext<QuickViewContext | undefined>()
191
+ * const payload = lightboxService.getPayload<QuickViewPayload | undefined>()
192
192
  *
193
- * if (!context) {
193
+ * if (!payload) {
194
194
  * return <p>Choose a product to see its details.</p>
195
195
  * }
196
196
  *
197
- * return <ProductSummary productId={context.productId} />
197
+ * return <ProductSummary productId={payload.productId} />
198
198
  * }
199
199
  * ```
200
200
  */
201
- getContext<TContext = LightboxContext>(): TContext
201
+ getPayload<TPayload = LightboxPayload>(): TPayload
202
202
  }
203
203
 
204
204
  export type ILightboxDefinition = ServiceDefinition<ILightboxService, ILightboxServiceConfig>
@@ -11,7 +11,7 @@ export const LightboxService = implementService(
11
11
  close: () => {
12
12
  config.close()
13
13
  },
14
- getContext: <TContext>() => config.getContext() as TContext,
14
+ getPayload: <TPayload>() => config.getPayload() as TPayload,
15
15
  }
16
16
  }
17
17
  )
@@ -2,7 +2,7 @@ export type {
2
2
  ILightboxService,
3
3
  ILightboxServiceConfig,
4
4
  ILightboxDefinition,
5
- LightboxContext,
5
+ LightboxPayload,
6
6
  LightboxOpenOptions,
7
7
  LightboxOpenBySlugOptions,
8
8
  LightboxOpenByPageIdOptions,