@vtex/ads-stories 0.5.0 → 0.8.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 +33 -0
- package/README.md +29 -297
- package/dist/cdn/vtex-ads-stories.js +438 -113
- package/dist/cdn/vtex-ads-stories.js.map +1 -1
- package/dist/cjs/index.cjs +932 -189
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/index.d.cts +42 -196
- package/dist/cjs/react.cjs.map +1 -1
- package/dist/cjs/react.d.cts +13 -3
- package/dist/cjs/story-Ba9J0rbL.d.cts +276 -0
- package/dist/esm/index.d.ts +42 -196
- package/dist/esm/index.js +956 -212
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.d.ts +13 -3
- package/dist/esm/story-Ba9J0rbL.d.ts +276 -0
- package/package.json +1 -1
- package/src/commerce-events.ts +93 -0
- package/src/components/card/card.ts +16 -3
- package/src/components/carousel/carousel-skeleton.ts +113 -0
- package/src/components/carousel/carousel.ts +53 -8
- package/src/components/carousel/index.ts +7 -0
- package/src/components/events/events-controller.ts +23 -13
- package/src/components/icons/assets/minus.svg +1 -0
- package/src/components/icons/assets/plus.svg +1 -0
- package/src/components/icons/assets/trash.svg +1 -0
- package/src/components/icons/assets/warning-circle-fill.svg +1 -0
- package/src/components/icons/index.ts +8 -0
- package/src/components/media/index.ts +7 -1
- package/src/components/media/media.styles.ts +113 -0
- package/src/components/media/media.ts +108 -11
- package/src/components/media/video-controller.ts +80 -6
- package/src/components/player/player.ts +42 -17
- package/src/components/product/cta.ts +3 -3
- package/src/components/product/index.ts +2 -0
- package/src/components/product/product.styles.ts +63 -6
- package/src/components/product/product.ts +130 -29
- package/src/index.ts +8 -0
- package/src/locales/en.ts +13 -3
- package/src/locales/es.ts +13 -3
- package/src/locales/index.ts +6 -0
- package/src/locales/pt.ts +13 -3
- package/src/locales/types.ts +22 -2
- package/src/react.ts +12 -2
- package/src/story/story.ts +218 -20
- package/src/utils/hydrate-products.ts +30 -6
- package/src/utils/media-ready.ts +58 -0
- package/src/utils/safe-url.ts +36 -0
- package/src/utils/send-event.ts +1 -1
- package/src/utils/http-url.ts +0 -12
package/dist/cjs/index.d.cts
CHANGED
|
@@ -1,206 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
export { S as StoryHydration, a as StoryProductDetails, T as TAG_NAME, V as VtexAdsStoryCarouselElement, d as defineVtexAdsStoryCarousel } from './story-Ba9J0rbL.cjs';
|
|
2
|
+
import 'lit';
|
|
3
|
+
import '@vtex/ads-core';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
6
|
+
* The commerce events the element hands to the store: it has no cart of its
|
|
7
|
+
* own. They bubble and cross shadow roots, so the store can listen on the
|
|
8
|
+
* element, the document or any ancestor.
|
|
8
9
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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();
|
|
165
|
-
connectedCallback(): void;
|
|
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;
|
|
10
|
+
/**
|
|
11
|
+
* Add to cart, or the stepper's plus, was clicked in the player. No default
|
|
12
|
+
* action.
|
|
13
|
+
*/
|
|
14
|
+
declare const ADD_TO_CART_EVENT = "vtex-ads-story:add-to-cart";
|
|
15
|
+
/**
|
|
16
|
+
* The stepper's minus, or its trash with one left, was clicked in the
|
|
17
|
+
* player. No default action.
|
|
18
|
+
*/
|
|
19
|
+
declare const REMOVE_FROM_CART_EVENT = "vtex-ads-story:remove-from-cart";
|
|
20
|
+
interface StoryCartEventDetail {
|
|
21
|
+
/** The Story product's SKU, from the ad API (`product.product_sku`). */
|
|
22
|
+
sku: string;
|
|
177
23
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
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.
|
|
24
|
+
* The product's seller, from the ad API (`product.seller_id`). Missing
|
|
25
|
+
* when the ad API doesn't send one.
|
|
182
26
|
*/
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
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>;
|
|
27
|
+
seller?: string;
|
|
28
|
+
/** How many to add (or, removing, to remove). Always 1 for now. */
|
|
29
|
+
quantity: number;
|
|
198
30
|
}
|
|
31
|
+
/** The detail of the add to cart event: `quantity` is how many to add. */
|
|
32
|
+
type StoryAddToCartDetail = StoryCartEventDetail;
|
|
33
|
+
/** The detail of remove from cart: `quantity` is how many to remove. */
|
|
34
|
+
type StoryRemoveFromCartDetail = StoryCartEventDetail;
|
|
35
|
+
type StoryAddToCartEvent = CustomEvent<StoryAddToCartDetail>;
|
|
36
|
+
type StoryRemoveFromCartEvent = CustomEvent<StoryRemoveFromCartDetail>;
|
|
199
37
|
declare global {
|
|
200
|
-
interface
|
|
201
|
-
[
|
|
38
|
+
interface HTMLElementEventMap {
|
|
39
|
+
[ADD_TO_CART_EVENT]: StoryAddToCartEvent;
|
|
40
|
+
[REMOVE_FROM_CART_EVENT]: StoryRemoveFromCartEvent;
|
|
41
|
+
}
|
|
42
|
+
interface DocumentEventMap {
|
|
43
|
+
[ADD_TO_CART_EVENT]: StoryAddToCartEvent;
|
|
44
|
+
[REMOVE_FROM_CART_EVENT]: StoryRemoveFromCartEvent;
|
|
45
|
+
}
|
|
46
|
+
interface WindowEventMap {
|
|
47
|
+
[ADD_TO_CART_EVENT]: StoryAddToCartEvent;
|
|
48
|
+
[REMOVE_FROM_CART_EVENT]: StoryRemoveFromCartEvent;
|
|
202
49
|
}
|
|
203
50
|
}
|
|
204
|
-
declare function defineVtexAdsStoryCarousel(): void;
|
|
205
51
|
|
|
206
|
-
export {
|
|
52
|
+
export { ADD_TO_CART_EVENT, REMOVE_FROM_CART_EVENT, type StoryAddToCartDetail, type StoryAddToCartEvent, type StoryRemoveFromCartDetail, type StoryRemoveFromCartEvent };
|
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-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 /**
|
|
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 /** Add to cart button's text. Default in the element's language. */\n \"label-add-to-cart\"?: string;\n /** View product button's text. Default in the element's language. */\n \"label-view-product\"?: string;\n /** Unavailable product button's text. Default in the element's language. */\n \"label-unavailable\"?: string;\n /** Sold out text. Default in the element's language. */\n \"label-sold-out\"?: 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 * With more than one Story, how long each one stays highlighted, in\n * milliseconds (default 5000). 0: no automatic advance. Never advances on\n * its own for people who prefer reduced motion.\n */\n \"slide-duration\"?: number;\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,6 +1,6 @@
|
|
|
1
1
|
import { DetailedHTMLProps, HTMLAttributes } from 'react';
|
|
2
2
|
import { Channel } from '@vtex/ads-core';
|
|
3
|
-
import { TAG_NAME, VtexAdsStoryCarouselElement } from './
|
|
3
|
+
import { T as TAG_NAME, V as VtexAdsStoryCarouselElement } from './story-Ba9J0rbL.cjs';
|
|
4
4
|
import 'lit';
|
|
5
5
|
|
|
6
6
|
/**
|
|
@@ -35,10 +35,14 @@ interface VtexAdsStoryCarouselAttributes {
|
|
|
35
35
|
quantity?: number;
|
|
36
36
|
/** Currency of the prices, ISO 4217 ("BRL"). Default BRL. */
|
|
37
37
|
currency?: string;
|
|
38
|
-
/**
|
|
38
|
+
/** Add to cart button's text. Default in the element's language. */
|
|
39
39
|
"label-add-to-cart"?: string;
|
|
40
|
-
/**
|
|
40
|
+
/** View product button's text. Default in the element's language. */
|
|
41
41
|
"label-view-product"?: string;
|
|
42
|
+
/** Unavailable product button's text. Default in the element's language. */
|
|
43
|
+
"label-unavailable"?: string;
|
|
44
|
+
/** Sold out text. Default in the element's language. */
|
|
45
|
+
"label-sold-out"?: string;
|
|
42
46
|
/**
|
|
43
47
|
* "none": no product request. To set a strategy, assign the element's
|
|
44
48
|
* `hydration` property. Missing: Intelligent Search with `account-name`.
|
|
@@ -51,6 +55,12 @@ interface VtexAdsStoryCarouselAttributes {
|
|
|
51
55
|
* their video, muted. Off by default.
|
|
52
56
|
*/
|
|
53
57
|
"inactive-autoplay"?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* With more than one Story, how long each one stays highlighted, in
|
|
60
|
+
* milliseconds (default 5000). 0: no automatic advance. Never advances on
|
|
61
|
+
* its own for people who prefer reduced motion.
|
|
62
|
+
*/
|
|
63
|
+
"slide-duration"?: number;
|
|
54
64
|
}
|
|
55
65
|
type VtexAdsStoryCarouselProps = DetailedHTMLProps<HTMLAttributes<VtexAdsStoryCarouselElement>, VtexAdsStoryCarouselElement> & VtexAdsStoryCarouselAttributes;
|
|
56
66
|
declare module "react" {
|
|
@@ -0,0 +1,276 @@
|
|
|
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
|
+
labelUnavailable: {
|
|
58
|
+
attribute: string;
|
|
59
|
+
};
|
|
60
|
+
labelSoldOut: {
|
|
61
|
+
attribute: string;
|
|
62
|
+
};
|
|
63
|
+
hydration: {
|
|
64
|
+
converter: {
|
|
65
|
+
fromAttribute: (value: string | null) => "none" | undefined;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
hydrationTimeout: {
|
|
69
|
+
type: NumberConstructor;
|
|
70
|
+
attribute: string;
|
|
71
|
+
};
|
|
72
|
+
slideDuration: {
|
|
73
|
+
type: NumberConstructor;
|
|
74
|
+
attribute: string;
|
|
75
|
+
};
|
|
76
|
+
inactiveAutoplay: {
|
|
77
|
+
type: BooleanConstructor;
|
|
78
|
+
attribute: string;
|
|
79
|
+
converter: {
|
|
80
|
+
fromAttribute: (value: string | null) => boolean;
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
stories: {
|
|
84
|
+
state: boolean;
|
|
85
|
+
};
|
|
86
|
+
products: {
|
|
87
|
+
state: boolean;
|
|
88
|
+
};
|
|
89
|
+
requesting: {
|
|
90
|
+
state: boolean;
|
|
91
|
+
};
|
|
92
|
+
mediaLoading: {
|
|
93
|
+
state: boolean;
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
/** Required. The publisher the ads are requested for. */
|
|
97
|
+
publisherId?: string;
|
|
98
|
+
/** Required. The store's session, also used to deduplicate events. */
|
|
99
|
+
sessionId?: string;
|
|
100
|
+
/** Required. The Story placement configured for the publisher. */
|
|
101
|
+
placement?: string;
|
|
102
|
+
userId?: string;
|
|
103
|
+
accountName?: string;
|
|
104
|
+
/** `site` or `app`. Any other attribute value is ignored. */
|
|
105
|
+
channel?: Channel;
|
|
106
|
+
/**
|
|
107
|
+
* Time limit for the ad request, in milliseconds (default 2000). Without a
|
|
108
|
+
* Story by then, the element renders nothing. A change applies to the next
|
|
109
|
+
* request; it doesn't request again.
|
|
110
|
+
*/
|
|
111
|
+
timeout?: number;
|
|
112
|
+
/**
|
|
113
|
+
* How many Stories to ask for: the carousel positions (default 8). Missing,
|
|
114
|
+
* below 1 or not a number: the default.
|
|
115
|
+
*/
|
|
116
|
+
quantity?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Currency of the prices, as an ISO 4217 code ("BRL", "ARS"). Missing or
|
|
119
|
+
* invalid: BRL.
|
|
120
|
+
*/
|
|
121
|
+
currency?: string;
|
|
122
|
+
/**
|
|
123
|
+
* The add to cart button's text. Missing or blank: the default in the
|
|
124
|
+
* element's language.
|
|
125
|
+
*/
|
|
126
|
+
labelAddToCart?: string;
|
|
127
|
+
/**
|
|
128
|
+
* The view product button's text. Missing or blank: the default in the
|
|
129
|
+
* element's language.
|
|
130
|
+
*/
|
|
131
|
+
labelViewProduct?: string;
|
|
132
|
+
/**
|
|
133
|
+
* The text of the disabled button for a product that can't be bought.
|
|
134
|
+
* Missing or blank: the default in the element's language.
|
|
135
|
+
*/
|
|
136
|
+
labelUnavailable?: string;
|
|
137
|
+
/**
|
|
138
|
+
* The sold out text, shown with the price and read by screen readers.
|
|
139
|
+
* Missing or blank: the default in the element's language.
|
|
140
|
+
*/
|
|
141
|
+
labelSoldOut?: string;
|
|
142
|
+
/**
|
|
143
|
+
* Where the products' details (for now, their prices) come from. A
|
|
144
|
+
* strategy (fetcher, matcher and price reader) is set as a property; the
|
|
145
|
+
* attribute takes only "none", for no product request. Missing:
|
|
146
|
+
* Intelligent Search when `account-name` is set, no product request
|
|
147
|
+
* otherwise.
|
|
148
|
+
*/
|
|
149
|
+
hydration?: StoryHydration | "none";
|
|
150
|
+
/**
|
|
151
|
+
* Time limit for the product request, in milliseconds (default 5000).
|
|
152
|
+
* Without the prices by then, the cards show the ad server's.
|
|
153
|
+
*/
|
|
154
|
+
hydrationTimeout?: number;
|
|
155
|
+
/**
|
|
156
|
+
* With more than one Story, whether the cards without the highlight also
|
|
157
|
+
* play their video, muted. Off by default: they show only their cover, and
|
|
158
|
+
* only the highlighted card plays.
|
|
159
|
+
*/
|
|
160
|
+
inactiveAutoplay: boolean;
|
|
161
|
+
/**
|
|
162
|
+
* With more than one Story, how long each one stays highlighted before the
|
|
163
|
+
* next, in milliseconds (default 5000). Zero: the highlight moves only by
|
|
164
|
+
* hand. A change starts the time over; it doesn't request again.
|
|
165
|
+
*/
|
|
166
|
+
slideDuration?: number;
|
|
167
|
+
/** The Stories shown: none while loading, on error or with none. */
|
|
168
|
+
private stories;
|
|
169
|
+
/**
|
|
170
|
+
* The fetched products, by Story `ad_id`, or `"loading"` while the product
|
|
171
|
+
* request runs. Undefined without a product request.
|
|
172
|
+
*/
|
|
173
|
+
private products?;
|
|
174
|
+
/**
|
|
175
|
+
* The ad request is pending (and has what it needs to go out): a skeleton
|
|
176
|
+
* stands in for the carousel until the Stories arrive.
|
|
177
|
+
*/
|
|
178
|
+
private requesting;
|
|
179
|
+
/**
|
|
180
|
+
* The first Story's media is still loading: a skeleton covers the cards
|
|
181
|
+
* until its cover or its video is ready (or MEDIA_TIMEOUT passes), so the
|
|
182
|
+
* first card doesn't show up piece by piece. Meanwhile, the cards load
|
|
183
|
+
* underneath, their videos without playing, and no event goes out.
|
|
184
|
+
*/
|
|
185
|
+
private mediaLoading;
|
|
186
|
+
/**
|
|
187
|
+
* Cancels the wait for the media in progress: when other Stories replace
|
|
188
|
+
* its Stories, or the element leaves the page.
|
|
189
|
+
*/
|
|
190
|
+
private mediaWait?;
|
|
191
|
+
/**
|
|
192
|
+
* Cancels the request in progress. Kept, already aborted, when leaving the
|
|
193
|
+
* page cancelled it, so connecting again requests once more.
|
|
194
|
+
*/
|
|
195
|
+
private request?;
|
|
196
|
+
static readonly styles: lit.CSSResult[];
|
|
197
|
+
/**
|
|
198
|
+
* How many of each SKU, from each seller (see cartKey), were added since
|
|
199
|
+
* the player opened, for its stepper. It doesn't read the store's cart: it
|
|
200
|
+
* counts the add and remove events sent, and starts over each time the
|
|
201
|
+
* player opens, as the cart may have changed meanwhile.
|
|
202
|
+
*/
|
|
203
|
+
private readonly cartQuantities;
|
|
204
|
+
/**
|
|
205
|
+
* One per rendered card, by its key (see Slide): a Story can show in more
|
|
206
|
+
* than one card, each with its own video.
|
|
207
|
+
*/
|
|
208
|
+
private readonly cardVideos;
|
|
209
|
+
/** The sound was on when the highlight moved: the new card turns it on. */
|
|
210
|
+
private soundPending;
|
|
211
|
+
/**
|
|
212
|
+
* What to do once the next render is on screen, when the new highlighted
|
|
213
|
+
* card's video exists (see leaveHighlight and onLayoutChange). A step
|
|
214
|
+
* taken before then replaces it.
|
|
215
|
+
*/
|
|
216
|
+
private afterRender?;
|
|
217
|
+
private readonly carousel;
|
|
218
|
+
private readonly player;
|
|
219
|
+
private readonly events;
|
|
220
|
+
constructor();
|
|
221
|
+
connectedCallback(): void;
|
|
222
|
+
disconnectedCallback(): void;
|
|
223
|
+
protected willUpdate(changed: PropertyValues<this>): void;
|
|
224
|
+
protected updated(): void;
|
|
225
|
+
private get activeHydration();
|
|
226
|
+
/**
|
|
227
|
+
* Requests the Story and shows it, then hydrates its products. Until the
|
|
228
|
+
* Story arrives, and when there is none (see fetchStories), the element
|
|
229
|
+
* renders nothing.
|
|
230
|
+
*/
|
|
231
|
+
private loadStory;
|
|
232
|
+
private showStories;
|
|
233
|
+
/**
|
|
234
|
+
* Shows the cards once the first Story's cover or video is ready: whichever
|
|
235
|
+
* loads first, or once both failed. Only then are the Stories impressed
|
|
236
|
+
* and do their videos play, from the start.
|
|
237
|
+
*/
|
|
238
|
+
private waitForFirstMedia;
|
|
239
|
+
/**
|
|
240
|
+
* Where each Story is being watched: the cards on screen (not the hidden
|
|
241
|
+
* ones kept for the slide in) and the open player's video, while their
|
|
242
|
+
* video plays. A card showing only its cover doesn't count. Behind the
|
|
243
|
+
* expanded player, a modal over the page, the cards are covered.
|
|
244
|
+
*/
|
|
245
|
+
private viewTargets;
|
|
246
|
+
private videoFor;
|
|
247
|
+
private get activeVideo();
|
|
248
|
+
private leaveHighlight;
|
|
249
|
+
private stepInPlayer;
|
|
250
|
+
private openPlayer;
|
|
251
|
+
private closePlayer;
|
|
252
|
+
private formatter?;
|
|
253
|
+
private get locale();
|
|
254
|
+
private labelSet?;
|
|
255
|
+
private get labels();
|
|
256
|
+
private get formatPrice();
|
|
257
|
+
private productOf;
|
|
258
|
+
private readonly renderSlide;
|
|
259
|
+
protected render(): typeof nothing | lit.TemplateResult<1>;
|
|
260
|
+
private renderPlayer;
|
|
261
|
+
private cartActionsFor;
|
|
262
|
+
/**
|
|
263
|
+
* Adds one of `item` to the stepper's count, or removes one, and tells the
|
|
264
|
+
* store, which changes its cart: the element has none. When add to cart
|
|
265
|
+
* and the stepper swap places, the focus moves to the one now shown.
|
|
266
|
+
*/
|
|
267
|
+
private changeCart;
|
|
268
|
+
}
|
|
269
|
+
declare global {
|
|
270
|
+
interface HTMLElementTagNameMap {
|
|
271
|
+
[TAG_NAME]: VtexAdsStoryCarouselElement;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
declare function defineVtexAdsStoryCarousel(): void;
|
|
275
|
+
|
|
276
|
+
export { type StoryHydration as S, TAG_NAME as T, VtexAdsStoryCarouselElement as V, type StoryProductDetails as a, defineVtexAdsStoryCarousel as d };
|