@vtex/ads-stories 0.4.0 → 0.5.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/CHANGELOG.md +67 -0
- package/README.md +260 -28
- package/dist/cdn/vtex-ads-stories.js +1073 -20
- package/dist/cdn/vtex-ads-stories.js.map +1 -1
- package/dist/cjs/index.cjs +4392 -315
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +198 -12
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/cjs/react.d.cts +46 -5
- package/dist/esm/index.d.ts +198 -12
- package/dist/esm/index.js +2819 -291
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.d.ts +46 -5
- package/package.json +21 -4
- package/src/cdn.ts +7 -3
- package/src/components/card/card.ts +101 -111
- package/src/components/card/index.ts +1 -1
- package/src/components/carousel/carousel.ts +670 -0
- package/src/components/carousel/index.ts +15 -0
- package/src/components/events/events-controller.ts +212 -0
- package/src/components/events/index.ts +6 -0
- package/src/components/icons/assets/caret-left-bold.svg +1 -0
- package/src/components/icons/assets/caret-right-bold.svg +1 -0
- package/src/components/icons/assets/caret-up-bold.svg +1 -0
- package/src/components/icons/index.ts +30 -9
- package/src/components/media/index.ts +3 -0
- package/src/components/media/media.ts +70 -0
- package/src/components/media/video-controller.ts +125 -0
- package/src/components/player/index.ts +6 -2
- package/src/components/player/player.ts +946 -134
- package/src/components/product/cta.ts +56 -0
- package/src/components/product/index.ts +20 -0
- package/src/components/product/price.ts +86 -0
- package/src/components/product/product.styles.ts +369 -0
- package/src/components/product/product.ts +235 -0
- package/src/index.ts +9 -1
- package/src/locales/en.ts +29 -0
- package/src/locales/es.ts +30 -0
- package/src/locales/index.ts +36 -0
- package/src/locales/pt.ts +29 -0
- package/src/locales/types.ts +24 -0
- package/src/react.ts +49 -7
- package/src/story/index.ts +5 -1
- package/src/story/story.ts +528 -93
- package/src/tag-name.ts +1 -0
- package/src/types.ts +8 -12
- package/src/utils/fetch-story.ts +113 -0
- package/src/utils/http-url.ts +12 -0
- package/src/utils/hydrate-products.ts +88 -0
- package/src/utils/send-event.ts +71 -0
- package/src/utils/with-timeout.ts +43 -0
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,20 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import * as lit from 'lit';
|
|
2
|
+
import { LitElement, PropertyValues, nothing } from 'lit';
|
|
3
|
+
import { ProductFetcher, Offer, ProductPrice, Channel } from '@vtex/ads-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Where the element gets its products' details: a fetcher and a matcher, as
|
|
7
|
+
* in `@vtex/ads-core`, and a reader for the price of a fetched product.
|
|
8
|
+
*/
|
|
9
|
+
interface StoryHydration<TProduct extends object = object> {
|
|
10
|
+
fetcher: ProductFetcher<TProduct>;
|
|
11
|
+
matcher(product: TProduct, offer: Offer): boolean;
|
|
12
|
+
price(product: TProduct, offer: Offer): ProductPrice | undefined;
|
|
13
|
+
/** Whether the product can be bought. Without it, it isn't checked. */
|
|
14
|
+
available?(product: TProduct, offer: Offer): boolean | undefined;
|
|
15
|
+
}
|
|
16
|
+
interface StoryProductDetails {
|
|
17
|
+
price?: ProductPrice;
|
|
18
|
+
/** Missing when the strategy doesn't say. */
|
|
19
|
+
available?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare const TAG_NAME = "vtex-ads-story-carousel";
|
|
23
|
+
|
|
24
|
+
declare class VtexAdsStoryCarouselElement extends LitElement {
|
|
25
|
+
static readonly properties: {
|
|
26
|
+
publisherId: {
|
|
27
|
+
attribute: string;
|
|
28
|
+
};
|
|
29
|
+
sessionId: {
|
|
30
|
+
attribute: string;
|
|
31
|
+
};
|
|
32
|
+
placement: {};
|
|
33
|
+
userId: {
|
|
34
|
+
attribute: string;
|
|
35
|
+
};
|
|
36
|
+
accountName: {
|
|
37
|
+
attribute: string;
|
|
38
|
+
};
|
|
39
|
+
channel: {
|
|
40
|
+
converter: {
|
|
41
|
+
fromAttribute: (value: string | null) => Channel | undefined;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
timeout: {
|
|
45
|
+
type: NumberConstructor;
|
|
46
|
+
};
|
|
47
|
+
quantity: {
|
|
48
|
+
type: NumberConstructor;
|
|
49
|
+
};
|
|
50
|
+
currency: {};
|
|
51
|
+
labelAddToCart: {
|
|
52
|
+
attribute: string;
|
|
53
|
+
};
|
|
54
|
+
labelViewProduct: {
|
|
55
|
+
attribute: string;
|
|
56
|
+
};
|
|
57
|
+
hydration: {
|
|
58
|
+
converter: {
|
|
59
|
+
fromAttribute: (value: string | null) => "none" | undefined;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
hydrationTimeout: {
|
|
63
|
+
type: NumberConstructor;
|
|
64
|
+
attribute: string;
|
|
65
|
+
};
|
|
66
|
+
inactiveAutoplay: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
attribute: string;
|
|
69
|
+
converter: {
|
|
70
|
+
fromAttribute: (value: string | null) => boolean;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
stories: {
|
|
74
|
+
state: boolean;
|
|
75
|
+
};
|
|
76
|
+
products: {
|
|
77
|
+
state: boolean;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/** Required. The publisher the ads are requested for. */
|
|
81
|
+
publisherId?: string;
|
|
82
|
+
/** Required. The store's session, also used to deduplicate events. */
|
|
83
|
+
sessionId?: string;
|
|
84
|
+
/** Required. The Story placement configured for the publisher. */
|
|
85
|
+
placement?: string;
|
|
86
|
+
userId?: string;
|
|
87
|
+
accountName?: string;
|
|
88
|
+
/** `site` or `app`. Any other attribute value is ignored. */
|
|
89
|
+
channel?: Channel;
|
|
90
|
+
/**
|
|
91
|
+
* Time limit for the ad request, in milliseconds (default 2000). Without a
|
|
92
|
+
* Story by then, the element renders nothing. A change applies to the next
|
|
93
|
+
* request; it doesn't request again.
|
|
94
|
+
*/
|
|
95
|
+
timeout?: number;
|
|
96
|
+
/**
|
|
97
|
+
* How many Stories to ask for: the carousel positions (default 8). Missing,
|
|
98
|
+
* below 1 or not a number: the default.
|
|
99
|
+
*/
|
|
100
|
+
quantity?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Currency of the prices, as an ISO 4217 code ("BRL", "ARS"). Missing or
|
|
103
|
+
* invalid: BRL.
|
|
104
|
+
*/
|
|
105
|
+
currency?: string;
|
|
106
|
+
/**
|
|
107
|
+
* The add to cart button's text. Missing or blank: the default in the
|
|
108
|
+
* element's language ("Adicionar ao carrinho").
|
|
109
|
+
*/
|
|
110
|
+
labelAddToCart?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The view product button's text. Missing or blank: the default in the
|
|
113
|
+
* element's language ("Ver produto").
|
|
114
|
+
*/
|
|
115
|
+
labelViewProduct?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Where the products' details (for now, their prices) come from. A
|
|
118
|
+
* strategy (fetcher, matcher and price reader) is set as a property; the
|
|
119
|
+
* attribute takes only "none", for no product request. Missing:
|
|
120
|
+
* Intelligent Search when `account-name` is set, no product request
|
|
121
|
+
* otherwise.
|
|
122
|
+
*/
|
|
123
|
+
hydration?: StoryHydration | "none";
|
|
124
|
+
/**
|
|
125
|
+
* Time limit for the product request, in milliseconds (default 5000).
|
|
126
|
+
* Without the prices by then, the cards show the ad server's.
|
|
127
|
+
*/
|
|
128
|
+
hydrationTimeout?: number;
|
|
129
|
+
/**
|
|
130
|
+
* With more than one Story, whether the cards without the highlight also
|
|
131
|
+
* play their video, muted. Off by default: they show only their cover, and
|
|
132
|
+
* only the highlighted card plays.
|
|
133
|
+
*/
|
|
134
|
+
inactiveAutoplay: boolean;
|
|
135
|
+
/** The Stories shown: none while loading, on error or with none. */
|
|
136
|
+
private stories;
|
|
137
|
+
/**
|
|
138
|
+
* The fetched products, by Story `ad_id`, or `"loading"` while the product
|
|
139
|
+
* request runs. Undefined without a product request.
|
|
140
|
+
*/
|
|
141
|
+
private products?;
|
|
142
|
+
/**
|
|
143
|
+
* Cancels the request in progress. Kept, already aborted, when leaving the
|
|
144
|
+
* page cancelled it, so connecting again requests once more.
|
|
145
|
+
*/
|
|
146
|
+
private request?;
|
|
147
|
+
static readonly styles: lit.CSSResult[];
|
|
148
|
+
/**
|
|
149
|
+
* One per rendered card, by its key (see Slide): a Story can show in more
|
|
150
|
+
* than one card, each with its own video.
|
|
151
|
+
*/
|
|
152
|
+
private readonly cardVideos;
|
|
153
|
+
/** The sound was on when the highlight moved: the new card turns it on. */
|
|
154
|
+
private soundPending;
|
|
155
|
+
/**
|
|
156
|
+
* What to do once the next render is on screen, when the new highlighted
|
|
157
|
+
* card's video exists (see leaveHighlight and onLayoutChange). A step
|
|
158
|
+
* taken before then replaces it.
|
|
159
|
+
*/
|
|
160
|
+
private afterRender?;
|
|
161
|
+
private readonly carousel;
|
|
162
|
+
private readonly player;
|
|
163
|
+
private readonly events;
|
|
164
|
+
constructor();
|
|
10
165
|
connectedCallback(): void;
|
|
11
166
|
disconnectedCallback(): void;
|
|
167
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
168
|
+
protected updated(): void;
|
|
169
|
+
private get activeHydration();
|
|
170
|
+
/**
|
|
171
|
+
* Requests the Story and shows it, then hydrates its products. Until the
|
|
172
|
+
* Story arrives, and when there is none (see fetchStories), the element
|
|
173
|
+
* renders nothing.
|
|
174
|
+
*/
|
|
175
|
+
private loadStory;
|
|
176
|
+
private showStories;
|
|
177
|
+
/**
|
|
178
|
+
* Where each Story is being watched: the cards on screen (not the hidden
|
|
179
|
+
* ones kept for the slide in) and the open player's video, while their
|
|
180
|
+
* video plays. A card showing only its cover doesn't count. Behind the
|
|
181
|
+
* expanded player, a modal over the page, the cards are covered.
|
|
182
|
+
*/
|
|
183
|
+
private viewTargets;
|
|
184
|
+
private videoFor;
|
|
185
|
+
private get activeVideo();
|
|
186
|
+
private leaveHighlight;
|
|
187
|
+
private stepInPlayer;
|
|
188
|
+
private openPlayer;
|
|
189
|
+
private closePlayer;
|
|
190
|
+
private formatter?;
|
|
191
|
+
private get locale();
|
|
192
|
+
private labelSet?;
|
|
193
|
+
private get labels();
|
|
194
|
+
private get formatPrice();
|
|
195
|
+
private productOf;
|
|
196
|
+
private readonly renderSlide;
|
|
197
|
+
protected render(): typeof nothing | lit.TemplateResult<1>;
|
|
12
198
|
}
|
|
13
199
|
declare global {
|
|
14
200
|
interface HTMLElementTagNameMap {
|
|
15
|
-
|
|
201
|
+
[TAG_NAME]: VtexAdsStoryCarouselElement;
|
|
16
202
|
}
|
|
17
203
|
}
|
|
18
|
-
declare function
|
|
204
|
+
declare function defineVtexAdsStoryCarousel(): void;
|
|
19
205
|
|
|
20
|
-
export { TAG_NAME,
|
|
206
|
+
export { type StoryHydration, type StoryProductDetails, TAG_NAME, VtexAdsStoryCarouselElement, defineVtexAdsStoryCarousel };
|
package/dist/cjs/react.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react.ts"],"sourcesContent":["/**\n * React JSX types for <vtex-ads-story>. Types only: the JS output is empty.\n *\n * Opt in once per project, so non-React projects never need @types/react:\n *\n * import type {} from \"@vtex/ads-stories/react\";\n *\n * or add \"@vtex/ads-stories/react\" to `compilerOptions.types` in tsconfig.\n */\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\nimport type {
|
|
1
|
+
{"version":3,"sources":["../../src/react.ts"],"sourcesContent":["/**\n * React JSX types for <vtex-ads-story-carousel>. Types only: the JS output\n * is empty.\n *\n * Opt in once per project, so non-React projects never need @types/react:\n *\n * import type {} from \"@vtex/ads-stories/react\";\n *\n * or add \"@vtex/ads-stories/react\" to `compilerOptions.types` in tsconfig.\n */\nimport type { DetailedHTMLProps, HTMLAttributes } from \"react\";\nimport type { Channel } from \"@vtex/ads-core\";\nimport type { TAG_NAME, VtexAdsStoryCarouselElement } from \"./story\";\n\n/**\n * The element's own attributes. The required ones match the README: without\n * them, the element requests nothing and renders nothing.\n */\nexport interface VtexAdsStoryCarouselAttributes {\n /** The publisher the ads are requested for. */\n \"publisher-id\": string;\n /** The store's session, also used to deduplicate events. */\n \"session-id\": string;\n /** The Story placement configured for the publisher. */\n placement: string;\n \"user-id\"?: string;\n \"account-name\"?: string;\n /** `site` or `app`. */\n channel?: Channel;\n /** Time limit for the ad request, in milliseconds (default 2000). */\n timeout?: number;\n /** How many Stories to ask for: the carousel positions (default 8). */\n quantity?: number;\n /** Currency of the prices, ISO 4217 (\"BRL\"). Default BRL. */\n currency?: string;\n /** The add to cart button's text. Default in the element's language. */\n \"label-add-to-cart\"?: string;\n /** The view product button's text. Default in the element's language. */\n \"label-view-product\"?: string;\n /**\n * \"none\": no product request. To set a strategy, assign the element's\n * `hydration` property. Missing: Intelligent Search with `account-name`.\n */\n hydration?: \"none\";\n /** Time limit for the product request, in milliseconds (default 5000). */\n \"hydration-timeout\"?: number;\n /**\n * With more than one Story, the cards without the highlight also play\n * their video, muted. Off by default.\n */\n \"inactive-autoplay\"?: boolean;\n}\n\nexport type VtexAdsStoryCarouselProps = DetailedHTMLProps<\n HTMLAttributes<VtexAdsStoryCarouselElement>,\n VtexAdsStoryCarouselElement\n> &\n VtexAdsStoryCarouselAttributes;\n\ndeclare module \"react\" {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n [TAG_NAME]: VtexAdsStoryCarouselProps;\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/dist/cjs/react.d.cts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { Channel } from '@vtex/ads-core';
|
|
3
|
+
import { TAG_NAME, VtexAdsStoryCarouselElement } from './index.cjs';
|
|
4
|
+
import 'lit';
|
|
3
5
|
|
|
4
6
|
/**
|
|
5
|
-
* React JSX types for <vtex-ads-story>. Types only: the JS output
|
|
7
|
+
* React JSX types for <vtex-ads-story-carousel>. Types only: the JS output
|
|
8
|
+
* is empty.
|
|
6
9
|
*
|
|
7
10
|
* Opt in once per project, so non-React projects never need @types/react:
|
|
8
11
|
*
|
|
@@ -11,13 +14,51 @@ import { VtexAdsStoryElement } from './index.cjs';
|
|
|
11
14
|
* or add "@vtex/ads-stories/react" to `compilerOptions.types` in tsconfig.
|
|
12
15
|
*/
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
/**
|
|
18
|
+
* The element's own attributes. The required ones match the README: without
|
|
19
|
+
* them, the element requests nothing and renders nothing.
|
|
20
|
+
*/
|
|
21
|
+
interface VtexAdsStoryCarouselAttributes {
|
|
22
|
+
/** The publisher the ads are requested for. */
|
|
23
|
+
"publisher-id": string;
|
|
24
|
+
/** The store's session, also used to deduplicate events. */
|
|
25
|
+
"session-id": string;
|
|
26
|
+
/** The Story placement configured for the publisher. */
|
|
27
|
+
placement: string;
|
|
28
|
+
"user-id"?: string;
|
|
29
|
+
"account-name"?: string;
|
|
30
|
+
/** `site` or `app`. */
|
|
31
|
+
channel?: Channel;
|
|
32
|
+
/** Time limit for the ad request, in milliseconds (default 2000). */
|
|
33
|
+
timeout?: number;
|
|
34
|
+
/** How many Stories to ask for: the carousel positions (default 8). */
|
|
35
|
+
quantity?: number;
|
|
36
|
+
/** Currency of the prices, ISO 4217 ("BRL"). Default BRL. */
|
|
37
|
+
currency?: string;
|
|
38
|
+
/** The add to cart button's text. Default in the element's language. */
|
|
39
|
+
"label-add-to-cart"?: string;
|
|
40
|
+
/** The view product button's text. Default in the element's language. */
|
|
41
|
+
"label-view-product"?: string;
|
|
42
|
+
/**
|
|
43
|
+
* "none": no product request. To set a strategy, assign the element's
|
|
44
|
+
* `hydration` property. Missing: Intelligent Search with `account-name`.
|
|
45
|
+
*/
|
|
46
|
+
hydration?: "none";
|
|
47
|
+
/** Time limit for the product request, in milliseconds (default 5000). */
|
|
48
|
+
"hydration-timeout"?: number;
|
|
49
|
+
/**
|
|
50
|
+
* With more than one Story, the cards without the highlight also play
|
|
51
|
+
* their video, muted. Off by default.
|
|
52
|
+
*/
|
|
53
|
+
"inactive-autoplay"?: boolean;
|
|
54
|
+
}
|
|
55
|
+
type VtexAdsStoryCarouselProps = DetailedHTMLProps<HTMLAttributes<VtexAdsStoryCarouselElement>, VtexAdsStoryCarouselElement> & VtexAdsStoryCarouselAttributes;
|
|
15
56
|
declare module "react" {
|
|
16
57
|
namespace JSX {
|
|
17
58
|
interface IntrinsicElements {
|
|
18
|
-
|
|
59
|
+
[TAG_NAME]: VtexAdsStoryCarouselProps;
|
|
19
60
|
}
|
|
20
61
|
}
|
|
21
62
|
}
|
|
22
63
|
|
|
23
|
-
export type {
|
|
64
|
+
export type { VtexAdsStoryCarouselAttributes, VtexAdsStoryCarouselProps };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -1,20 +1,206 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import * as lit from 'lit';
|
|
2
|
+
import { LitElement, PropertyValues, nothing } from 'lit';
|
|
3
|
+
import { ProductFetcher, Offer, ProductPrice, Channel } from '@vtex/ads-core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Where the element gets its products' details: a fetcher and a matcher, as
|
|
7
|
+
* in `@vtex/ads-core`, and a reader for the price of a fetched product.
|
|
8
|
+
*/
|
|
9
|
+
interface StoryHydration<TProduct extends object = object> {
|
|
10
|
+
fetcher: ProductFetcher<TProduct>;
|
|
11
|
+
matcher(product: TProduct, offer: Offer): boolean;
|
|
12
|
+
price(product: TProduct, offer: Offer): ProductPrice | undefined;
|
|
13
|
+
/** Whether the product can be bought. Without it, it isn't checked. */
|
|
14
|
+
available?(product: TProduct, offer: Offer): boolean | undefined;
|
|
15
|
+
}
|
|
16
|
+
interface StoryProductDetails {
|
|
17
|
+
price?: ProductPrice;
|
|
18
|
+
/** Missing when the strategy doesn't say. */
|
|
19
|
+
available?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
declare const TAG_NAME = "vtex-ads-story-carousel";
|
|
23
|
+
|
|
24
|
+
declare class VtexAdsStoryCarouselElement extends LitElement {
|
|
25
|
+
static readonly properties: {
|
|
26
|
+
publisherId: {
|
|
27
|
+
attribute: string;
|
|
28
|
+
};
|
|
29
|
+
sessionId: {
|
|
30
|
+
attribute: string;
|
|
31
|
+
};
|
|
32
|
+
placement: {};
|
|
33
|
+
userId: {
|
|
34
|
+
attribute: string;
|
|
35
|
+
};
|
|
36
|
+
accountName: {
|
|
37
|
+
attribute: string;
|
|
38
|
+
};
|
|
39
|
+
channel: {
|
|
40
|
+
converter: {
|
|
41
|
+
fromAttribute: (value: string | null) => Channel | undefined;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
timeout: {
|
|
45
|
+
type: NumberConstructor;
|
|
46
|
+
};
|
|
47
|
+
quantity: {
|
|
48
|
+
type: NumberConstructor;
|
|
49
|
+
};
|
|
50
|
+
currency: {};
|
|
51
|
+
labelAddToCart: {
|
|
52
|
+
attribute: string;
|
|
53
|
+
};
|
|
54
|
+
labelViewProduct: {
|
|
55
|
+
attribute: string;
|
|
56
|
+
};
|
|
57
|
+
hydration: {
|
|
58
|
+
converter: {
|
|
59
|
+
fromAttribute: (value: string | null) => "none" | undefined;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
hydrationTimeout: {
|
|
63
|
+
type: NumberConstructor;
|
|
64
|
+
attribute: string;
|
|
65
|
+
};
|
|
66
|
+
inactiveAutoplay: {
|
|
67
|
+
type: BooleanConstructor;
|
|
68
|
+
attribute: string;
|
|
69
|
+
converter: {
|
|
70
|
+
fromAttribute: (value: string | null) => boolean;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
stories: {
|
|
74
|
+
state: boolean;
|
|
75
|
+
};
|
|
76
|
+
products: {
|
|
77
|
+
state: boolean;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
/** Required. The publisher the ads are requested for. */
|
|
81
|
+
publisherId?: string;
|
|
82
|
+
/** Required. The store's session, also used to deduplicate events. */
|
|
83
|
+
sessionId?: string;
|
|
84
|
+
/** Required. The Story placement configured for the publisher. */
|
|
85
|
+
placement?: string;
|
|
86
|
+
userId?: string;
|
|
87
|
+
accountName?: string;
|
|
88
|
+
/** `site` or `app`. Any other attribute value is ignored. */
|
|
89
|
+
channel?: Channel;
|
|
90
|
+
/**
|
|
91
|
+
* Time limit for the ad request, in milliseconds (default 2000). Without a
|
|
92
|
+
* Story by then, the element renders nothing. A change applies to the next
|
|
93
|
+
* request; it doesn't request again.
|
|
94
|
+
*/
|
|
95
|
+
timeout?: number;
|
|
96
|
+
/**
|
|
97
|
+
* How many Stories to ask for: the carousel positions (default 8). Missing,
|
|
98
|
+
* below 1 or not a number: the default.
|
|
99
|
+
*/
|
|
100
|
+
quantity?: number;
|
|
101
|
+
/**
|
|
102
|
+
* Currency of the prices, as an ISO 4217 code ("BRL", "ARS"). Missing or
|
|
103
|
+
* invalid: BRL.
|
|
104
|
+
*/
|
|
105
|
+
currency?: string;
|
|
106
|
+
/**
|
|
107
|
+
* The add to cart button's text. Missing or blank: the default in the
|
|
108
|
+
* element's language ("Adicionar ao carrinho").
|
|
109
|
+
*/
|
|
110
|
+
labelAddToCart?: string;
|
|
111
|
+
/**
|
|
112
|
+
* The view product button's text. Missing or blank: the default in the
|
|
113
|
+
* element's language ("Ver produto").
|
|
114
|
+
*/
|
|
115
|
+
labelViewProduct?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Where the products' details (for now, their prices) come from. A
|
|
118
|
+
* strategy (fetcher, matcher and price reader) is set as a property; the
|
|
119
|
+
* attribute takes only "none", for no product request. Missing:
|
|
120
|
+
* Intelligent Search when `account-name` is set, no product request
|
|
121
|
+
* otherwise.
|
|
122
|
+
*/
|
|
123
|
+
hydration?: StoryHydration | "none";
|
|
124
|
+
/**
|
|
125
|
+
* Time limit for the product request, in milliseconds (default 5000).
|
|
126
|
+
* Without the prices by then, the cards show the ad server's.
|
|
127
|
+
*/
|
|
128
|
+
hydrationTimeout?: number;
|
|
129
|
+
/**
|
|
130
|
+
* With more than one Story, whether the cards without the highlight also
|
|
131
|
+
* play their video, muted. Off by default: they show only their cover, and
|
|
132
|
+
* only the highlighted card plays.
|
|
133
|
+
*/
|
|
134
|
+
inactiveAutoplay: boolean;
|
|
135
|
+
/** The Stories shown: none while loading, on error or with none. */
|
|
136
|
+
private stories;
|
|
137
|
+
/**
|
|
138
|
+
* The fetched products, by Story `ad_id`, or `"loading"` while the product
|
|
139
|
+
* request runs. Undefined without a product request.
|
|
140
|
+
*/
|
|
141
|
+
private products?;
|
|
142
|
+
/**
|
|
143
|
+
* Cancels the request in progress. Kept, already aborted, when leaving the
|
|
144
|
+
* page cancelled it, so connecting again requests once more.
|
|
145
|
+
*/
|
|
146
|
+
private request?;
|
|
147
|
+
static readonly styles: lit.CSSResult[];
|
|
148
|
+
/**
|
|
149
|
+
* One per rendered card, by its key (see Slide): a Story can show in more
|
|
150
|
+
* than one card, each with its own video.
|
|
151
|
+
*/
|
|
152
|
+
private readonly cardVideos;
|
|
153
|
+
/** The sound was on when the highlight moved: the new card turns it on. */
|
|
154
|
+
private soundPending;
|
|
155
|
+
/**
|
|
156
|
+
* What to do once the next render is on screen, when the new highlighted
|
|
157
|
+
* card's video exists (see leaveHighlight and onLayoutChange). A step
|
|
158
|
+
* taken before then replaces it.
|
|
159
|
+
*/
|
|
160
|
+
private afterRender?;
|
|
161
|
+
private readonly carousel;
|
|
162
|
+
private readonly player;
|
|
163
|
+
private readonly events;
|
|
164
|
+
constructor();
|
|
10
165
|
connectedCallback(): void;
|
|
11
166
|
disconnectedCallback(): void;
|
|
167
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
168
|
+
protected updated(): void;
|
|
169
|
+
private get activeHydration();
|
|
170
|
+
/**
|
|
171
|
+
* Requests the Story and shows it, then hydrates its products. Until the
|
|
172
|
+
* Story arrives, and when there is none (see fetchStories), the element
|
|
173
|
+
* renders nothing.
|
|
174
|
+
*/
|
|
175
|
+
private loadStory;
|
|
176
|
+
private showStories;
|
|
177
|
+
/**
|
|
178
|
+
* Where each Story is being watched: the cards on screen (not the hidden
|
|
179
|
+
* ones kept for the slide in) and the open player's video, while their
|
|
180
|
+
* video plays. A card showing only its cover doesn't count. Behind the
|
|
181
|
+
* expanded player, a modal over the page, the cards are covered.
|
|
182
|
+
*/
|
|
183
|
+
private viewTargets;
|
|
184
|
+
private videoFor;
|
|
185
|
+
private get activeVideo();
|
|
186
|
+
private leaveHighlight;
|
|
187
|
+
private stepInPlayer;
|
|
188
|
+
private openPlayer;
|
|
189
|
+
private closePlayer;
|
|
190
|
+
private formatter?;
|
|
191
|
+
private get locale();
|
|
192
|
+
private labelSet?;
|
|
193
|
+
private get labels();
|
|
194
|
+
private get formatPrice();
|
|
195
|
+
private productOf;
|
|
196
|
+
private readonly renderSlide;
|
|
197
|
+
protected render(): typeof nothing | lit.TemplateResult<1>;
|
|
12
198
|
}
|
|
13
199
|
declare global {
|
|
14
200
|
interface HTMLElementTagNameMap {
|
|
15
|
-
|
|
201
|
+
[TAG_NAME]: VtexAdsStoryCarouselElement;
|
|
16
202
|
}
|
|
17
203
|
}
|
|
18
|
-
declare function
|
|
204
|
+
declare function defineVtexAdsStoryCarousel(): void;
|
|
19
205
|
|
|
20
|
-
export { TAG_NAME,
|
|
206
|
+
export { type StoryHydration, type StoryProductDetails, TAG_NAME, VtexAdsStoryCarouselElement, defineVtexAdsStoryCarousel };
|