@vtex/ads-stories 0.7.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.
@@ -1,6 +1,6 @@
1
1
  import { DetailedHTMLProps, HTMLAttributes } from 'react';
2
2
  import { Channel } from '@vtex/ads-core';
3
- import { T as TAG_NAME, V as VtexAdsStoryCarouselElement } from './story-DAiAN9v-.js';
3
+ import { T as TAG_NAME, V as VtexAdsStoryCarouselElement } from './story-Ba9J0rbL.js';
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
- /** The add to cart button's text. Default in the element's language. */
38
+ /** Add to cart button's text. Default in the element's language. */
39
39
  "label-add-to-cart"?: string;
40
- /** The view product button's text. Default in the element's language. */
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`.
@@ -54,6 +54,12 @@ declare class VtexAdsStoryCarouselElement extends LitElement {
54
54
  labelViewProduct: {
55
55
  attribute: string;
56
56
  };
57
+ labelUnavailable: {
58
+ attribute: string;
59
+ };
60
+ labelSoldOut: {
61
+ attribute: string;
62
+ };
57
63
  hydration: {
58
64
  converter: {
59
65
  fromAttribute: (value: string | null) => "none" | undefined;
@@ -115,14 +121,24 @@ declare class VtexAdsStoryCarouselElement extends LitElement {
115
121
  currency?: string;
116
122
  /**
117
123
  * The add to cart button's text. Missing or blank: the default in the
118
- * element's language ("Adicionar ao carrinho").
124
+ * element's language.
119
125
  */
120
126
  labelAddToCart?: string;
121
127
  /**
122
128
  * The view product button's text. Missing or blank: the default in the
123
- * element's language ("Ver produto").
129
+ * element's language.
124
130
  */
125
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;
126
142
  /**
127
143
  * Where the products' details (for now, their prices) come from. A
128
144
  * strategy (fetcher, matcher and price reader) is set as a property; the
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vtex/ads-stories",
3
3
  "type": "module",
4
- "version": "0.7.0",
4
+ "version": "0.8.0",
5
5
  "description": "VTEX Ads Stories web component",
6
6
  "main": "dist/cjs/index.cjs",
7
7
  "module": "dist/esm/index.js",
@@ -11,6 +11,8 @@ export { pt } from "./pt";
11
11
  export interface StoryLabelOverrides {
12
12
  addToCart?: string;
13
13
  viewProduct?: string;
14
+ unavailable?: string;
15
+ soldOut?: string;
14
16
  }
15
17
 
16
18
  const BY_LANGUAGE = new Map<string, StoryLabels>([
@@ -27,10 +29,14 @@ export function labelsFor(
27
29
  const labels = BY_LANGUAGE.get(language) ?? pt;
28
30
  const addToCart = overrides.addToCart?.trim();
29
31
  const viewProduct = overrides.viewProduct?.trim();
32
+ const unavailable = overrides.unavailable?.trim();
33
+ const soldOut = overrides.soldOut?.trim();
30
34
 
31
35
  return {
32
36
  ...labels,
33
37
  ...(addToCart && { addToCart }),
34
38
  ...(viewProduct && { viewProduct }),
39
+ ...(unavailable && { unavailable }),
40
+ ...(soldOut && { soldOut }),
35
41
  };
36
42
  }
package/src/react.ts CHANGED
@@ -33,10 +33,14 @@ export interface VtexAdsStoryCarouselAttributes {
33
33
  quantity?: number;
34
34
  /** Currency of the prices, ISO 4217 ("BRL"). Default BRL. */
35
35
  currency?: string;
36
- /** The add to cart button's text. Default in the element's language. */
36
+ /** Add to cart button's text. Default in the element's language. */
37
37
  "label-add-to-cart"?: string;
38
- /** The view product button's text. Default in the element's language. */
38
+ /** View product button's text. Default in the element's language. */
39
39
  "label-view-product"?: string;
40
+ /** Unavailable product button's text. Default in the element's language. */
41
+ "label-unavailable"?: string;
42
+ /** Sold out text. Default in the element's language. */
43
+ "label-sold-out"?: string;
40
44
  /**
41
45
  * "none": no product request. To set a strategy, assign the element's
42
46
  * `hydration` property. Missing: Intelligent Search with `account-name`.
@@ -112,6 +112,8 @@ export class VtexAdsStoryCarouselElement extends LitElement {
112
112
  currency: {},
113
113
  labelAddToCart: { attribute: "label-add-to-cart" },
114
114
  labelViewProduct: { attribute: "label-view-product" },
115
+ labelUnavailable: { attribute: "label-unavailable" },
116
+ labelSoldOut: { attribute: "label-sold-out" },
115
117
  hydration: { converter: hydrationConverter },
116
118
  hydrationTimeout: { type: Number, attribute: "hydration-timeout" },
117
119
  slideDuration: { type: Number, attribute: "slide-duration" },
@@ -154,14 +156,24 @@ export class VtexAdsStoryCarouselElement extends LitElement {
154
156
  declare currency?: string;
155
157
  /**
156
158
  * The add to cart button's text. Missing or blank: the default in the
157
- * element's language ("Adicionar ao carrinho").
159
+ * element's language.
158
160
  */
159
161
  declare labelAddToCart?: string;
160
162
  /**
161
163
  * The view product button's text. Missing or blank: the default in the
162
- * element's language ("Ver produto").
164
+ * element's language.
163
165
  */
164
166
  declare labelViewProduct?: string;
167
+ /**
168
+ * The text of the disabled button for a product that can't be bought.
169
+ * Missing or blank: the default in the element's language.
170
+ */
171
+ declare labelUnavailable?: string;
172
+ /**
173
+ * The sold out text, shown with the price and read by screen readers.
174
+ * Missing or blank: the default in the element's language.
175
+ */
176
+ declare labelSoldOut?: string;
165
177
  /**
166
178
  * Where the products' details (for now, their prices) come from. A
167
179
  * strategy (fetcher, matcher and price reader) is set as a property; the
@@ -574,14 +586,28 @@ export class VtexAdsStoryCarouselElement extends LitElement {
574
586
  private labelSet?: { key: string; labels: StoryLabels };
575
587
 
576
588
  private get labels() {
577
- const { locale, labelAddToCart = "", labelViewProduct = "" } = this;
578
- const key = JSON.stringify([locale, labelAddToCart, labelViewProduct]);
589
+ const {
590
+ locale,
591
+ labelAddToCart = "",
592
+ labelViewProduct = "",
593
+ labelUnavailable = "",
594
+ labelSoldOut = "",
595
+ } = this;
596
+ const key = JSON.stringify([
597
+ locale,
598
+ labelAddToCart,
599
+ labelViewProduct,
600
+ labelUnavailable,
601
+ labelSoldOut,
602
+ ]);
579
603
  if (this.labelSet?.key !== key) {
580
604
  this.labelSet = {
581
605
  key,
582
606
  labels: labelsFor(locale, {
583
607
  addToCart: labelAddToCart,
584
608
  viewProduct: labelViewProduct,
609
+ unavailable: labelUnavailable,
610
+ soldOut: labelSoldOut,
585
611
  }),
586
612
  };
587
613
  }