@vtex/ads-stories 0.5.0 → 0.7.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 +27 -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 +909 -186
- 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 +7 -1
- package/dist/cjs/story-DAiAN9v-.d.cts +260 -0
- package/dist/esm/index.d.ts +42 -196
- package/dist/esm/index.js +933 -209
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/react.d.ts +7 -1
- package/dist/esm/story-DAiAN9v-.d.ts +260 -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/pt.ts +13 -3
- package/src/locales/types.ts +22 -2
- package/src/react.ts +6 -0
- package/src/story/story.ts +188 -16
- 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.cjs
CHANGED
|
@@ -20,6 +20,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ADD_TO_CART_EVENT: () => ADD_TO_CART_EVENT,
|
|
24
|
+
REMOVE_FROM_CART_EVENT: () => REMOVE_FROM_CART_EVENT,
|
|
23
25
|
TAG_NAME: () => TAG_NAME,
|
|
24
26
|
VtexAdsStoryCarouselElement: () => VtexAdsStoryCarouselElement,
|
|
25
27
|
defineVtexAdsStoryCarousel: () => defineVtexAdsStoryCarousel
|
|
@@ -244,7 +246,7 @@ Object.defineProperties(EventShim.prototype, {
|
|
|
244
246
|
stopPropagation: enumerableProperty,
|
|
245
247
|
isTrusted: enumerableProperty
|
|
246
248
|
});
|
|
247
|
-
var CustomEventShim = (_b = class
|
|
249
|
+
var CustomEventShim = (_b = class CustomEvent2 extends EventShim {
|
|
248
250
|
constructor(type, options = {}) {
|
|
249
251
|
var _a13;
|
|
250
252
|
super(type, options);
|
|
@@ -1487,30 +1489,46 @@ var collapse_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256
|
|
|
1487
1489
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/expand.svg
|
|
1488
1490
|
var expand_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V88a8,8,0,0,1-16,0V56H168a8,8,0,0,1,0-16h40A8,8,0,0,1,216,48ZM88,200H56V168a8,8,0,0,0-16,0v40a8,8,0,0,0,8,8H88a8,8,0,0,0,0-16Zm120-40a8,8,0,0,0-8,8v32H168a8,8,0,0,0,0,16h40a8,8,0,0,0,8-8V168A8,8,0,0,0,208,160ZM88,40H48a8,8,0,0,0-8,8V88a8,8,0,0,0,16,0V56H88a8,8,0,0,0,0-16Z"/></svg>\n';
|
|
1489
1491
|
|
|
1492
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/minus.svg
|
|
1493
|
+
var minus_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M224,128a8,8,0,0,1-8,8H40a8,8,0,0,1,0-16H216A8,8,0,0,1,224,128Z"/></svg>';
|
|
1494
|
+
|
|
1490
1495
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/pause-fill.svg
|
|
1491
1496
|
var pause_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48V208a16,16,0,0,1-16,16H160a16,16,0,0,1-16-16V48a16,16,0,0,1,16-16h40A16,16,0,0,1,216,48ZM96,32H56A16,16,0,0,0,40,48V208a16,16,0,0,0,16,16H96a16,16,0,0,0,16-16V48A16,16,0,0,0,96,32Z"/></svg>\n';
|
|
1492
1497
|
|
|
1493
1498
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/play-fill.svg
|
|
1494
1499
|
var play_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M240,128a15.74,15.74,0,0,1-7.6,13.51L88.32,229.65a16,16,0,0,1-16.2.3A15.86,15.86,0,0,1,64,216.13V39.87a15.86,15.86,0,0,1,8.12-13.82,16,16,0,0,1,16.2.3L232.4,114.49A15.74,15.74,0,0,1,240,128Z"/></svg>\n';
|
|
1495
1500
|
|
|
1501
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/plus.svg
|
|
1502
|
+
var plus_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M224,128a8,8,0,0,1-8,8H136v80a8,8,0,0,1-16,0V136H40a8,8,0,0,1,0-16h80V40a8,8,0,0,1,16,0v80h80A8,8,0,0,1,224,128Z"/></svg>';
|
|
1503
|
+
|
|
1496
1504
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-x-fill.svg
|
|
1497
1505
|
var speaker_x_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M245.66,146.34a8,8,0,0,1-11.32,11.32L216,139.31l-18.34,18.35a8,8,0,0,1-11.32-11.32L204.69,128l-18.35-18.34a8,8,0,0,1,11.32-11.32L216,116.69l18.34-18.35a8,8,0,0,1,11.32,11.32L227.31,128ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm97.15-54.15a8,8,0,0,0-10-.16l-65.57,51A4,4,0,0,0,80,79.84v96.32a4,4,0,0,0,1.55,3.15l65.57,51a8,8,0,0,0,9,.56,8.29,8.29,0,0,0,3.91-7.18V32.25A8.27,8.27,0,0,0,157.12,25.85Z"/></svg>\n';
|
|
1498
1506
|
|
|
1499
1507
|
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/speaker-high-fill.svg
|
|
1500
1508
|
var speaker_high_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M160,32.25V223.69a8.29,8.29,0,0,1-3.91,7.18,8,8,0,0,1-9-.56l-65.57-51A4,4,0,0,1,80,176.16V79.84a4,4,0,0,1,1.55-3.15l65.57-51a8,8,0,0,1,10,.16A8.27,8.27,0,0,1,160,32.25ZM60,80H32A16,16,0,0,0,16,96v64a16,16,0,0,0,16,16H60a4,4,0,0,0,4-4V84A4,4,0,0,0,60,80Zm126.77,20.84a8,8,0,0,0-.72,11.3,24,24,0,0,1,0,31.72,8,8,0,1,0,12,10.58,40,40,0,0,0,0-52.88A8,8,0,0,0,186.74,100.84Zm40.89-26.17a8,8,0,1,0-11.92,10.66,64,64,0,0,1,0,85.34,8,8,0,1,0,11.92,10.66,80,80,0,0,0,0-106.66Z"/></svg>\n';
|
|
1501
1509
|
|
|
1510
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/trash.svg
|
|
1511
|
+
var trash_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M216,48H176V40a24,24,0,0,0-24-24H104A24,24,0,0,0,80,40v8H40a8,8,0,0,0,0,16h8V208a16,16,0,0,0,16,16H192a16,16,0,0,0,16-16V64h8a8,8,0,0,0,0-16ZM96,40a8,8,0,0,1,8-8h48a8,8,0,0,1,8,8v8H96Zm96,168H64V64H192ZM112,104v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Zm48,0v64a8,8,0,0,1-16,0V104a8,8,0,0,1,16,0Z"/></svg>';
|
|
1512
|
+
|
|
1513
|
+
// raw:/workspace/source/ads-js/packages/ads-stories/src/components/icons/assets/warning-circle-fill.svg
|
|
1514
|
+
var warning_circle_fill_default = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256" fill="currentColor"><path d="M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm-8,56a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0Zm8,104a12,12,0,1,1,12-12A12,12,0,0,1,128,184Z"/></svg>\n';
|
|
1515
|
+
|
|
1502
1516
|
// src/components/icons/index.ts
|
|
1503
1517
|
var icons = {
|
|
1504
1518
|
caretUp: caret_up_bold_default,
|
|
1505
1519
|
close: close_default,
|
|
1506
1520
|
collapse: collapse_default,
|
|
1507
1521
|
expand: expand_default,
|
|
1522
|
+
minus: minus_default,
|
|
1508
1523
|
next: caret_right_bold_default,
|
|
1509
1524
|
pause: pause_fill_default,
|
|
1510
1525
|
play: play_fill_default,
|
|
1526
|
+
plus: plus_default,
|
|
1511
1527
|
previous: caret_left_bold_default,
|
|
1512
1528
|
soundOff: speaker_x_fill_default,
|
|
1513
|
-
soundOn: speaker_high_fill_default
|
|
1529
|
+
soundOn: speaker_high_fill_default,
|
|
1530
|
+
trash: trash_default,
|
|
1531
|
+
warning: warning_circle_fill_default
|
|
1514
1532
|
};
|
|
1515
1533
|
var markup = Object.fromEntries(
|
|
1516
1534
|
Object.entries(icons).map(([name, svg]) => [
|
|
@@ -1525,7 +1543,138 @@ function icon(name) {
|
|
|
1525
1543
|
return o7(markup[name]);
|
|
1526
1544
|
}
|
|
1527
1545
|
|
|
1528
|
-
// src/
|
|
1546
|
+
// src/locales/en.ts
|
|
1547
|
+
var en = {
|
|
1548
|
+
watch: "Watch video",
|
|
1549
|
+
show: "Show video",
|
|
1550
|
+
carousel: "Videos",
|
|
1551
|
+
carouselRole: "carousel",
|
|
1552
|
+
previous: "Previous video",
|
|
1553
|
+
next: "Next video",
|
|
1554
|
+
player: "Video",
|
|
1555
|
+
expand: "Expand video",
|
|
1556
|
+
collapse: "Collapse video",
|
|
1557
|
+
close: "Close video",
|
|
1558
|
+
play: "Play video",
|
|
1559
|
+
pause: "Pause video",
|
|
1560
|
+
soundOn: "Turn sound on",
|
|
1561
|
+
soundOff: "Turn sound off",
|
|
1562
|
+
addToCart: "Add to cart",
|
|
1563
|
+
cartQuantity: "Quantity in cart",
|
|
1564
|
+
decreaseQuantity: "Decrease quantity",
|
|
1565
|
+
removeFromCart: "Remove from cart",
|
|
1566
|
+
increaseQuantity: "Increase quantity",
|
|
1567
|
+
unavailable: "Product unavailable",
|
|
1568
|
+
soldOut: "Sold out",
|
|
1569
|
+
viewProduct: "View product",
|
|
1570
|
+
videoUnavailable: "Video unavailable",
|
|
1571
|
+
videoFailed: "Couldn't load the video",
|
|
1572
|
+
retry: "Try again",
|
|
1573
|
+
videoLoading: "Loading video",
|
|
1574
|
+
product: (name, price, listPrice, soldOut) => {
|
|
1575
|
+
let text = name;
|
|
1576
|
+
if (price && listPrice) text = `${name}, was ${listPrice}, now ${price}`;
|
|
1577
|
+
else if (price) text = `${name}, ${price}`;
|
|
1578
|
+
return soldOut ? `${text}, ${soldOut}` : text;
|
|
1579
|
+
},
|
|
1580
|
+
position: (label, index, count) => count > 1 ? `${label} ${index + 1} of ${count}` : label
|
|
1581
|
+
};
|
|
1582
|
+
|
|
1583
|
+
// src/locales/es.ts
|
|
1584
|
+
var es = {
|
|
1585
|
+
watch: "Ver video",
|
|
1586
|
+
show: "Mostrar video",
|
|
1587
|
+
carousel: "Videos",
|
|
1588
|
+
carouselRole: "carrusel",
|
|
1589
|
+
previous: "Video anterior",
|
|
1590
|
+
next: "Video siguiente",
|
|
1591
|
+
player: "Video",
|
|
1592
|
+
expand: "Ampliar video",
|
|
1593
|
+
collapse: "Reducir video",
|
|
1594
|
+
close: "Cerrar video",
|
|
1595
|
+
play: "Reproducir video",
|
|
1596
|
+
pause: "Pausar video",
|
|
1597
|
+
soundOn: "Activar sonido",
|
|
1598
|
+
soundOff: "Desactivar sonido",
|
|
1599
|
+
addToCart: "Agregar al carrito",
|
|
1600
|
+
cartQuantity: "Cantidad en el carrito",
|
|
1601
|
+
decreaseQuantity: "Disminuir cantidad",
|
|
1602
|
+
removeFromCart: "Quitar del carrito",
|
|
1603
|
+
increaseQuantity: "Aumentar cantidad",
|
|
1604
|
+
unavailable: "Producto no disponible",
|
|
1605
|
+
soldOut: "Agotado",
|
|
1606
|
+
viewProduct: "Ver producto",
|
|
1607
|
+
videoUnavailable: "Video no disponible",
|
|
1608
|
+
videoFailed: "No se pudo cargar el video",
|
|
1609
|
+
retry: "Intentar de nuevo",
|
|
1610
|
+
videoLoading: "Cargando video",
|
|
1611
|
+
product: (name, price, listPrice, soldOut) => {
|
|
1612
|
+
let text = name;
|
|
1613
|
+
if (price && listPrice)
|
|
1614
|
+
text = `${name}, antes ${listPrice}, ahora ${price}`;
|
|
1615
|
+
else if (price) text = `${name}, ${price}`;
|
|
1616
|
+
return soldOut ? `${text}, ${soldOut}` : text;
|
|
1617
|
+
},
|
|
1618
|
+
position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
|
|
1619
|
+
};
|
|
1620
|
+
|
|
1621
|
+
// src/locales/pt.ts
|
|
1622
|
+
var pt = {
|
|
1623
|
+
watch: "Assistir v\xEDdeo",
|
|
1624
|
+
show: "Mostrar v\xEDdeo",
|
|
1625
|
+
carousel: "V\xEDdeos",
|
|
1626
|
+
carouselRole: "carrossel",
|
|
1627
|
+
previous: "V\xEDdeo anterior",
|
|
1628
|
+
next: "Pr\xF3ximo v\xEDdeo",
|
|
1629
|
+
player: "V\xEDdeo",
|
|
1630
|
+
expand: "Expandir v\xEDdeo",
|
|
1631
|
+
collapse: "Reduzir v\xEDdeo",
|
|
1632
|
+
close: "Fechar v\xEDdeo",
|
|
1633
|
+
play: "Reproduzir v\xEDdeo",
|
|
1634
|
+
pause: "Pausar v\xEDdeo",
|
|
1635
|
+
soundOn: "Ativar som",
|
|
1636
|
+
soundOff: "Desativar som",
|
|
1637
|
+
addToCart: "Adicionar ao carrinho",
|
|
1638
|
+
cartQuantity: "Quantidade no carrinho",
|
|
1639
|
+
decreaseQuantity: "Diminuir quantidade",
|
|
1640
|
+
removeFromCart: "Remover do carrinho",
|
|
1641
|
+
increaseQuantity: "Aumentar quantidade",
|
|
1642
|
+
unavailable: "Produto indispon\xEDvel",
|
|
1643
|
+
soldOut: "Esgotado",
|
|
1644
|
+
viewProduct: "Ver produto",
|
|
1645
|
+
videoUnavailable: "V\xEDdeo indispon\xEDvel",
|
|
1646
|
+
videoFailed: "N\xE3o foi poss\xEDvel carregar o v\xEDdeo",
|
|
1647
|
+
retry: "Tentar de novo",
|
|
1648
|
+
videoLoading: "Carregando v\xEDdeo",
|
|
1649
|
+
product: (name, price, listPrice, soldOut) => {
|
|
1650
|
+
let text = name;
|
|
1651
|
+
if (price && listPrice) text = `${name}, de ${listPrice} por ${price}`;
|
|
1652
|
+
else if (price) text = `${name}, ${price}`;
|
|
1653
|
+
return soldOut ? `${text}, ${soldOut}` : text;
|
|
1654
|
+
},
|
|
1655
|
+
position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
|
|
1656
|
+
};
|
|
1657
|
+
|
|
1658
|
+
// src/locales/index.ts
|
|
1659
|
+
var BY_LANGUAGE = /* @__PURE__ */ new Map([
|
|
1660
|
+
["pt", pt],
|
|
1661
|
+
["es", es],
|
|
1662
|
+
["en", en]
|
|
1663
|
+
]);
|
|
1664
|
+
function labelsFor(locale, overrides = {}) {
|
|
1665
|
+
var _a13, _b3, _c;
|
|
1666
|
+
const language = locale.split("-")[0].toLowerCase();
|
|
1667
|
+
const labels = (_a13 = BY_LANGUAGE.get(language)) != null ? _a13 : pt;
|
|
1668
|
+
const addToCart = (_b3 = overrides.addToCart) == null ? void 0 : _b3.trim();
|
|
1669
|
+
const viewProduct = (_c = overrides.viewProduct) == null ? void 0 : _c.trim();
|
|
1670
|
+
return {
|
|
1671
|
+
...labels,
|
|
1672
|
+
...addToCart && { addToCart },
|
|
1673
|
+
...viewProduct && { viewProduct }
|
|
1674
|
+
};
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
// src/utils/safe-url.ts
|
|
1529
1678
|
function httpUrl(value) {
|
|
1530
1679
|
if (!value) return null;
|
|
1531
1680
|
try {
|
|
@@ -1535,18 +1684,82 @@ function httpUrl(value) {
|
|
|
1535
1684
|
return null;
|
|
1536
1685
|
}
|
|
1537
1686
|
}
|
|
1687
|
+
var STORE_BASE = "https://store.invalid";
|
|
1688
|
+
function storePath(value) {
|
|
1689
|
+
try {
|
|
1690
|
+
const url = new URL(value, STORE_BASE);
|
|
1691
|
+
if (url.origin !== STORE_BASE || url.pathname.startsWith("//")) {
|
|
1692
|
+
return null;
|
|
1693
|
+
}
|
|
1694
|
+
return `${url.pathname}${url.search}${url.hash}`;
|
|
1695
|
+
} catch (e6) {
|
|
1696
|
+
return null;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
function destinationUrl(value) {
|
|
1700
|
+
if (!value) return null;
|
|
1701
|
+
return value.startsWith("/") ? storePath(value) : httpUrl(value);
|
|
1702
|
+
}
|
|
1538
1703
|
|
|
1539
1704
|
// src/components/media/media.ts
|
|
1705
|
+
var REDUCED_MOTION = "(prefers-reduced-motion: reduce)";
|
|
1540
1706
|
function prefersReducedMotion() {
|
|
1541
1707
|
var _a13, _b3;
|
|
1542
|
-
return (_b3 = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis,
|
|
1708
|
+
return (_b3 = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, REDUCED_MOTION).matches) != null ? _b3 : false;
|
|
1543
1709
|
}
|
|
1544
1710
|
function hasVideo(story, video) {
|
|
1545
|
-
return !video.failed && httpUrl(story.media_url) !== null;
|
|
1711
|
+
return !video.failed && !video.retrying && httpUrl(story.media_url) !== null;
|
|
1712
|
+
}
|
|
1713
|
+
function renderFailed(labels, onRetry) {
|
|
1714
|
+
const retry = (event) => {
|
|
1715
|
+
event.stopPropagation();
|
|
1716
|
+
onRetry == null ? void 0 : onRetry();
|
|
1717
|
+
};
|
|
1718
|
+
return T`
|
|
1719
|
+
<div class="media-status" ?data-retry=${!!onRetry}>
|
|
1720
|
+
<span class="media-status-text">
|
|
1721
|
+
${icon("warning")}
|
|
1722
|
+
${onRetry ? labels.videoFailed : labels.videoUnavailable}
|
|
1723
|
+
</span>
|
|
1724
|
+
${onRetry ? T`
|
|
1725
|
+
<button type="button" class="media-retry" @click=${retry}>
|
|
1726
|
+
${labels.retry}
|
|
1727
|
+
</button>
|
|
1728
|
+
` : A}
|
|
1729
|
+
</div>
|
|
1730
|
+
`;
|
|
1546
1731
|
}
|
|
1547
|
-
function
|
|
1732
|
+
function renderVideoLoading(labels) {
|
|
1733
|
+
return T`
|
|
1734
|
+
<div class="media-status">
|
|
1735
|
+
<span class="media-status-text">
|
|
1736
|
+
<span class="media-spinner" aria-hidden="true"></span>
|
|
1737
|
+
${labels.videoLoading}
|
|
1738
|
+
</span>
|
|
1739
|
+
</div>
|
|
1740
|
+
`;
|
|
1741
|
+
}
|
|
1742
|
+
function renderStatus(video, labels, onRetry) {
|
|
1743
|
+
if (video.failed) return renderFailed(labels, onRetry);
|
|
1744
|
+
if (video.retrying) return renderVideoLoading(labels);
|
|
1745
|
+
return A;
|
|
1746
|
+
}
|
|
1747
|
+
function renderNotice(video, { labels = pt, onRetry, announce = true }) {
|
|
1748
|
+
return T`
|
|
1749
|
+
<div
|
|
1750
|
+
class="media-notice"
|
|
1751
|
+
role=${announce ? "status" : A}
|
|
1752
|
+
aria-hidden=${announce ? A : "true"}
|
|
1753
|
+
>
|
|
1754
|
+
${renderStatus(video, labels, onRetry)}
|
|
1755
|
+
</div>
|
|
1756
|
+
`;
|
|
1757
|
+
}
|
|
1758
|
+
function renderMedia(story, video, options = {}) {
|
|
1759
|
+
const { withVideo = true, loop = true, onEnded, autoplay = true } = options;
|
|
1548
1760
|
const posterUrl = httpUrl(story.poster_url);
|
|
1549
1761
|
const mediaUrl = withVideo ? httpUrl(story.media_url) : null;
|
|
1762
|
+
const preload = autoplay ? "metadata" : "auto";
|
|
1550
1763
|
return T`
|
|
1551
1764
|
${posterUrl ? T`<img class="poster" alt="" src=${posterUrl} />` : A}
|
|
1552
1765
|
${mediaUrl && !video.failed ? T`
|
|
@@ -1555,22 +1768,137 @@ function renderMedia(story, video, { withVideo = true, loop = true, onEnded } =
|
|
|
1555
1768
|
muted
|
|
1556
1769
|
playsinline
|
|
1557
1770
|
?loop=${loop}
|
|
1558
|
-
preload
|
|
1771
|
+
preload=${preload}
|
|
1559
1772
|
.muted=${true}
|
|
1560
|
-
?autoplay=${!prefersReducedMotion()}
|
|
1773
|
+
?autoplay=${autoplay && !prefersReducedMotion()}
|
|
1561
1774
|
poster=${posterUrl != null ? posterUrl : A}
|
|
1562
1775
|
src=${mediaUrl}
|
|
1563
1776
|
${n5(video.ref)}
|
|
1564
1777
|
@play=${video.sync}
|
|
1565
1778
|
@pause=${video.sync}
|
|
1566
1779
|
@volumechange=${video.sync}
|
|
1780
|
+
@loadeddata=${video.loaded}
|
|
1567
1781
|
@error=${video.fail}
|
|
1568
1782
|
@ended=${onEnded}
|
|
1569
1783
|
></video>
|
|
1570
1784
|
` : A}
|
|
1785
|
+
${mediaUrl ? renderNotice(video, options) : A}
|
|
1571
1786
|
`;
|
|
1572
1787
|
}
|
|
1573
1788
|
|
|
1789
|
+
// src/components/media/media.styles.ts
|
|
1790
|
+
var mediaStyles = i`
|
|
1791
|
+
/* The live region the notice shows in, over the cover. Empty until the
|
|
1792
|
+
video can't load or is loading again. Clicks go through to the card. */
|
|
1793
|
+
.media-notice {
|
|
1794
|
+
position: absolute;
|
|
1795
|
+
inset: 0;
|
|
1796
|
+
pointer-events: none;
|
|
1797
|
+
}
|
|
1798
|
+
|
|
1799
|
+
/* The notice: a dimmed layer with the text in the middle. */
|
|
1800
|
+
.media-status {
|
|
1801
|
+
position: absolute;
|
|
1802
|
+
inset: 0;
|
|
1803
|
+
display: flex;
|
|
1804
|
+
flex-direction: column;
|
|
1805
|
+
gap: 12px;
|
|
1806
|
+
align-items: center;
|
|
1807
|
+
justify-content: center;
|
|
1808
|
+
box-sizing: border-box;
|
|
1809
|
+
padding: 16px;
|
|
1810
|
+
background: rgba(0, 0, 0, 0.45);
|
|
1811
|
+
color: #fff;
|
|
1812
|
+
text-align: center;
|
|
1813
|
+
pointer-events: none;
|
|
1814
|
+
}
|
|
1815
|
+
|
|
1816
|
+
.media-status > * {
|
|
1817
|
+
animation: media-status-in 0.4s ease-out both;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
.media-status-text {
|
|
1821
|
+
display: flex;
|
|
1822
|
+
flex-direction: column;
|
|
1823
|
+
gap: 8px;
|
|
1824
|
+
align-items: center;
|
|
1825
|
+
max-width: 100%;
|
|
1826
|
+
font-size: 14px;
|
|
1827
|
+
font-weight: 600;
|
|
1828
|
+
line-height: 1.3;
|
|
1829
|
+
text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
|
|
1830
|
+
}
|
|
1831
|
+
|
|
1832
|
+
.media-status-text .icon {
|
|
1833
|
+
width: 18px;
|
|
1834
|
+
height: 18px;
|
|
1835
|
+
}
|
|
1836
|
+
|
|
1837
|
+
.media-status[data-retry] .media-status-text .icon {
|
|
1838
|
+
width: 24px;
|
|
1839
|
+
height: 24px;
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
.media-retry {
|
|
1843
|
+
min-height: 36px;
|
|
1844
|
+
padding: 0 16px;
|
|
1845
|
+
border: 0;
|
|
1846
|
+
border-radius: var(--_button-radius);
|
|
1847
|
+
background: rgba(255, 255, 255, 0.15);
|
|
1848
|
+
backdrop-filter: blur(4px);
|
|
1849
|
+
box-shadow: inset 0 0 3px rgba(255, 255, 255, 0.42);
|
|
1850
|
+
color: #fff;
|
|
1851
|
+
font: inherit;
|
|
1852
|
+
font-size: 14px;
|
|
1853
|
+
font-weight: 600;
|
|
1854
|
+
cursor: pointer;
|
|
1855
|
+
pointer-events: auto;
|
|
1856
|
+
animation-delay: 0.06s;
|
|
1857
|
+
}
|
|
1858
|
+
|
|
1859
|
+
.media-retry:focus-visible {
|
|
1860
|
+
outline: 2px solid #fff;
|
|
1861
|
+
outline-offset: 2px;
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
@media (hover: hover) and (pointer: fine) {
|
|
1865
|
+
.media-retry:hover {
|
|
1866
|
+
background: rgba(255, 255, 255, 0.25);
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
/* It spins with reduced motion too: a still ring wouldn't read as
|
|
1871
|
+
loading. */
|
|
1872
|
+
.media-spinner {
|
|
1873
|
+
width: 24px;
|
|
1874
|
+
height: 24px;
|
|
1875
|
+
box-sizing: border-box;
|
|
1876
|
+
border: 2px solid rgba(255, 255, 255, 0.35);
|
|
1877
|
+
border-top-color: #fff;
|
|
1878
|
+
border-radius: 50%;
|
|
1879
|
+
animation: media-spin 0.8s linear infinite;
|
|
1880
|
+
}
|
|
1881
|
+
|
|
1882
|
+
@keyframes media-status-in {
|
|
1883
|
+
from {
|
|
1884
|
+
opacity: 0;
|
|
1885
|
+
transform: translateY(4px);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
@keyframes media-spin {
|
|
1890
|
+
to {
|
|
1891
|
+
transform: rotate(360deg);
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
|
|
1895
|
+
@media (prefers-reduced-motion: reduce) {
|
|
1896
|
+
.media-status > :not(.media-spinner) {
|
|
1897
|
+
animation: none;
|
|
1898
|
+
}
|
|
1899
|
+
}
|
|
1900
|
+
`;
|
|
1901
|
+
|
|
1574
1902
|
// src/components/media/video-controller.ts
|
|
1575
1903
|
function playVideo(video) {
|
|
1576
1904
|
var _a13;
|
|
@@ -1584,8 +1912,7 @@ var VideoController = class {
|
|
|
1584
1912
|
this.paused = true;
|
|
1585
1913
|
// The video always starts muted: that is what browsers allow to autoplay.
|
|
1586
1914
|
this.muted = true;
|
|
1587
|
-
|
|
1588
|
-
this.failed = false;
|
|
1915
|
+
this.status = "playable";
|
|
1589
1916
|
/** Listener for the video's play, pause and volumechange events. */
|
|
1590
1917
|
this.sync = () => {
|
|
1591
1918
|
const video = this.ref.value;
|
|
@@ -1594,22 +1921,78 @@ var VideoController = class {
|
|
|
1594
1921
|
this.muted = video.muted;
|
|
1595
1922
|
this.host.requestUpdate();
|
|
1596
1923
|
};
|
|
1924
|
+
/** Listener for the video's loadeddata event. */
|
|
1925
|
+
this.loaded = () => {
|
|
1926
|
+
this.settleReady(true);
|
|
1927
|
+
if (!this.retrying) return;
|
|
1928
|
+
this.status = "playable";
|
|
1929
|
+
this.host.requestUpdate();
|
|
1930
|
+
};
|
|
1597
1931
|
/** Listener for the video's error event. */
|
|
1598
1932
|
this.fail = () => {
|
|
1599
|
-
this.
|
|
1933
|
+
this.status = "failed";
|
|
1934
|
+
this.settleReady(false);
|
|
1600
1935
|
this.host.requestUpdate();
|
|
1601
1936
|
};
|
|
1937
|
+
this.waitForReady();
|
|
1938
|
+
}
|
|
1939
|
+
/**
|
|
1940
|
+
* Resolves true once the video's first frame has loaded, or false if it
|
|
1941
|
+
* fails. A new one for each new <video> (see reset).
|
|
1942
|
+
*/
|
|
1943
|
+
get ready() {
|
|
1944
|
+
return this.readyState;
|
|
1945
|
+
}
|
|
1946
|
+
/** The video could not load: the cover shows with a notice over it. */
|
|
1947
|
+
get failed() {
|
|
1948
|
+
return this.status === "failed";
|
|
1949
|
+
}
|
|
1950
|
+
/** A failed video is loading again (see retry), until it loads or fails. */
|
|
1951
|
+
get retrying() {
|
|
1952
|
+
return this.status === "retrying";
|
|
1602
1953
|
}
|
|
1603
1954
|
/** The rendered <video> is on the page and playing. */
|
|
1604
1955
|
get playing() {
|
|
1605
1956
|
const video = this.ref.value;
|
|
1606
1957
|
return !!video && video.isConnected && !video.paused;
|
|
1607
1958
|
}
|
|
1608
|
-
/**
|
|
1959
|
+
/**
|
|
1960
|
+
* For a new <video>, such as each time the player opens. A retry still
|
|
1961
|
+
* loading resolves false.
|
|
1962
|
+
*/
|
|
1609
1963
|
reset() {
|
|
1964
|
+
this.cancelRetry();
|
|
1610
1965
|
this.paused = true;
|
|
1611
1966
|
this.muted = true;
|
|
1612
|
-
this.
|
|
1967
|
+
this.status = "playable";
|
|
1968
|
+
this.waitForReady();
|
|
1969
|
+
}
|
|
1970
|
+
/**
|
|
1971
|
+
* For the next Story's <video>: neither failed nor loading again (a retry
|
|
1972
|
+
* still loading resolves false). Unlike reset, it keeps the playback and
|
|
1973
|
+
* sound state.
|
|
1974
|
+
*/
|
|
1975
|
+
clearFailure() {
|
|
1976
|
+
if (this.retrying) {
|
|
1977
|
+
this.cancelRetry();
|
|
1978
|
+
this.waitForReady();
|
|
1979
|
+
}
|
|
1980
|
+
this.status = "playable";
|
|
1981
|
+
this.host.requestUpdate();
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Loads a failed video again: renderMedia renders a new <video> with a
|
|
1985
|
+
* notice that it is loading, until it loads or fails. Resolves as `ready`
|
|
1986
|
+
* does: false too if the video is replaced first (see reset and
|
|
1987
|
+
* clearFailure), and at once for a video that didn't fail.
|
|
1988
|
+
*/
|
|
1989
|
+
retry() {
|
|
1990
|
+
if (this.retrying) return this.ready;
|
|
1991
|
+
if (!this.failed) return Promise.resolve(false);
|
|
1992
|
+
this.reset();
|
|
1993
|
+
this.status = "retrying";
|
|
1994
|
+
this.host.requestUpdate();
|
|
1995
|
+
return this.ready;
|
|
1613
1996
|
}
|
|
1614
1997
|
play() {
|
|
1615
1998
|
const video = this.ref.value;
|
|
@@ -1669,6 +2052,13 @@ var VideoController = class {
|
|
|
1669
2052
|
const video = this.ref.value;
|
|
1670
2053
|
if (video) video.muted = !video.muted;
|
|
1671
2054
|
}
|
|
2055
|
+
// The video loading again is replaced: its retry resolves false.
|
|
2056
|
+
cancelRetry() {
|
|
2057
|
+
if (this.retrying) this.settleReady(false);
|
|
2058
|
+
}
|
|
2059
|
+
waitForReady() {
|
|
2060
|
+
this.readyState = new Promise((settle) => this.settleReady = settle);
|
|
2061
|
+
}
|
|
1672
2062
|
};
|
|
1673
2063
|
|
|
1674
2064
|
// src/components/product/price.ts
|
|
@@ -1717,33 +2107,31 @@ function priceFormatter(locale, currency) {
|
|
|
1717
2107
|
|
|
1718
2108
|
// src/components/product/product.ts
|
|
1719
2109
|
function toCardProduct(story, format, labels, fetched) {
|
|
1720
|
-
var _a13, _b3, _c, _d;
|
|
2110
|
+
var _a13, _b3, _c, _d, _e, _f;
|
|
1721
2111
|
const product = story.product;
|
|
1722
2112
|
const name = (_a13 = product == null ? void 0 : product.product_name) == null ? void 0 : _a13.trim();
|
|
1723
2113
|
if (!product || !name) return void 0;
|
|
1724
2114
|
const base = {
|
|
1725
2115
|
name,
|
|
1726
2116
|
imageUrl: (_b3 = httpUrl(product.image_url)) != null ? _b3 : void 0,
|
|
1727
|
-
url: (_c =
|
|
2117
|
+
url: (_c = destinationUrl(story.destination_url)) != null ? _c : void 0,
|
|
2118
|
+
sku: ((_d = product.product_sku) == null ? void 0 : _d.trim()) || void 0,
|
|
2119
|
+
seller: ((_e = product.seller_id) == null ? void 0 : _e.trim()) || void 0
|
|
1728
2120
|
};
|
|
1729
2121
|
if (fetched === "loading") {
|
|
1730
2122
|
return { ...base, label: labels.product(name), isLoading: true };
|
|
1731
2123
|
}
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
label: labels.product(name, labels.soldOut),
|
|
1736
|
-
soldOut: labels.soldOut
|
|
1737
|
-
};
|
|
1738
|
-
}
|
|
1739
|
-
const amounts = (_d = fetched == null ? void 0 : fetched.price) != null ? _d : readProductPrice(product.product_metadata);
|
|
2124
|
+
const soldOut = (fetched == null ? void 0 : fetched.available) === false ? labels.soldOut : void 0;
|
|
2125
|
+
const shown = (amounts2) => soldOut && (amounts2 == null ? void 0 : amounts2.price) === 0 ? void 0 : amounts2;
|
|
2126
|
+
const amounts = (_f = shown(fetched == null ? void 0 : fetched.price)) != null ? _f : shown(readProductPrice(product.product_metadata));
|
|
1740
2127
|
const price = amounts && format(amounts.price);
|
|
1741
2128
|
const listPrice = (amounts == null ? void 0 : amounts.listPrice) === void 0 ? void 0 : format(amounts.listPrice);
|
|
1742
2129
|
return {
|
|
1743
2130
|
...base,
|
|
1744
2131
|
price,
|
|
1745
2132
|
listPrice,
|
|
1746
|
-
|
|
2133
|
+
soldOut,
|
|
2134
|
+
label: labels.product(name, price, listPrice, soldOut)
|
|
1747
2135
|
};
|
|
1748
2136
|
}
|
|
1749
2137
|
var priceSkeleton = T`
|
|
@@ -1760,10 +2148,9 @@ var addToCartSkeleton = T`
|
|
|
1760
2148
|
`;
|
|
1761
2149
|
function renderPrice({ isLoading, soldOut, price, listPrice }) {
|
|
1762
2150
|
if (isLoading) return priceSkeleton;
|
|
1763
|
-
if (
|
|
1764
|
-
return T`<span class="product-price product-sold-out">${soldOut}</span
|
|
2151
|
+
if (!price) {
|
|
2152
|
+
return soldOut ? T`<span class="product-price product-sold-out">${soldOut}</span>` : A;
|
|
1765
2153
|
}
|
|
1766
|
-
if (!price) return A;
|
|
1767
2154
|
return T`
|
|
1768
2155
|
<span class="product-price">
|
|
1769
2156
|
<span>${price}</span>
|
|
@@ -1792,7 +2179,48 @@ function renderProduct(product, onSelect) {
|
|
|
1792
2179
|
</button>
|
|
1793
2180
|
`;
|
|
1794
2181
|
}
|
|
1795
|
-
|
|
2182
|
+
var STEPPER_ADD_CLASS = "product-stepper-add";
|
|
2183
|
+
var ADD_TO_CART_CLASS = "product-add-to-cart";
|
|
2184
|
+
function focusCartAction(root, action) {
|
|
2185
|
+
var _a13;
|
|
2186
|
+
const className = action === "stepper" ? STEPPER_ADD_CLASS : ADD_TO_CART_CLASS;
|
|
2187
|
+
(_a13 = root.querySelector(`.${className}`)) == null ? void 0 : _a13.focus();
|
|
2188
|
+
}
|
|
2189
|
+
function renderStepper(quantity, {
|
|
2190
|
+
labels,
|
|
2191
|
+
onAddToCart,
|
|
2192
|
+
onRemoveFromCart
|
|
2193
|
+
}) {
|
|
2194
|
+
const last = quantity === 1;
|
|
2195
|
+
return T`
|
|
2196
|
+
<div
|
|
2197
|
+
class="product-action product-stepper"
|
|
2198
|
+
role="group"
|
|
2199
|
+
aria-label=${labels.cartQuantity}
|
|
2200
|
+
>
|
|
2201
|
+
<button
|
|
2202
|
+
type="button"
|
|
2203
|
+
class="product-stepper-button product-stepper-remove"
|
|
2204
|
+
aria-label=${last ? labels.removeFromCart : labels.decreaseQuantity}
|
|
2205
|
+
@click=${onRemoveFromCart}
|
|
2206
|
+
>
|
|
2207
|
+
${icon(last ? "trash" : "minus")}
|
|
2208
|
+
</button>
|
|
2209
|
+
<span class="product-quantity">${quantity}</span>
|
|
2210
|
+
<button
|
|
2211
|
+
type="button"
|
|
2212
|
+
class="product-stepper-button ${STEPPER_ADD_CLASS}"
|
|
2213
|
+
aria-label=${labels.increaseQuantity}
|
|
2214
|
+
@click=${onAddToCart}
|
|
2215
|
+
>
|
|
2216
|
+
${icon("plus")}
|
|
2217
|
+
</button>
|
|
2218
|
+
</div>
|
|
2219
|
+
`;
|
|
2220
|
+
}
|
|
2221
|
+
function renderAddToCart({ isLoading, soldOut, sku }, options) {
|
|
2222
|
+
const { labels, onAddToCart, cartQuantity = 0 } = options;
|
|
2223
|
+
if (!sku || !onAddToCart) return A;
|
|
1796
2224
|
if (isLoading) return addToCartSkeleton;
|
|
1797
2225
|
if (soldOut) {
|
|
1798
2226
|
return T`
|
|
@@ -1801,12 +2229,25 @@ function renderAddToCart({ isLoading, soldOut }, { labels }) {
|
|
|
1801
2229
|
</button>
|
|
1802
2230
|
`;
|
|
1803
2231
|
}
|
|
2232
|
+
if (cartQuantity > 0) return renderStepper(cartQuantity, options);
|
|
1804
2233
|
return T`
|
|
1805
|
-
<button
|
|
2234
|
+
<button
|
|
2235
|
+
type="button"
|
|
2236
|
+
class="product-action ${ADD_TO_CART_CLASS}"
|
|
2237
|
+
@click=${onAddToCart}
|
|
2238
|
+
>
|
|
1806
2239
|
${labels.addToCart}
|
|
1807
2240
|
</button>
|
|
1808
2241
|
`;
|
|
1809
2242
|
}
|
|
2243
|
+
function renderCartStatus({ sku }, { labels, cartQuantity = 0, onAddToCart }) {
|
|
2244
|
+
if (!sku || !onAddToCart) return A;
|
|
2245
|
+
return T`
|
|
2246
|
+
<span class="product-cart-status" role="status">
|
|
2247
|
+
${cartQuantity > 0 ? `${labels.cartQuantity}: ${cartQuantity}` : ""}
|
|
2248
|
+
</span>
|
|
2249
|
+
`;
|
|
2250
|
+
}
|
|
1810
2251
|
function renderExpandableProduct(product, options) {
|
|
1811
2252
|
const { open } = options;
|
|
1812
2253
|
return T`
|
|
@@ -1824,6 +2265,7 @@ function renderExpandableProduct(product, options) {
|
|
|
1824
2265
|
</button>
|
|
1825
2266
|
<div id=${options.panelId} class="product-panel" ?inert=${!open}>
|
|
1826
2267
|
<div class="product-actions">
|
|
2268
|
+
${renderCartStatus(product, options)}
|
|
1827
2269
|
${renderAddToCart(product, options)}
|
|
1828
2270
|
${product.url ? T`
|
|
1829
2271
|
<a
|
|
@@ -1846,7 +2288,7 @@ function toCardCta(story) {
|
|
|
1846
2288
|
var _a13;
|
|
1847
2289
|
if (story.product) return void 0;
|
|
1848
2290
|
const label = (_a13 = story.call_to_action) == null ? void 0 : _a13.trim();
|
|
1849
|
-
const url =
|
|
2291
|
+
const url = destinationUrl(story.destination_url);
|
|
1850
2292
|
return label && url ? { label, url } : void 0;
|
|
1851
2293
|
}
|
|
1852
2294
|
function renderCta(cta, onSelect) {
|
|
@@ -1883,9 +2325,9 @@ var productStyles = i`
|
|
|
1883
2325
|
gap: 8px;
|
|
1884
2326
|
align-items: center;
|
|
1885
2327
|
box-sizing: border-box;
|
|
1886
|
-
padding:
|
|
2328
|
+
padding: var(--_pill-inset);
|
|
1887
2329
|
border: 0;
|
|
1888
|
-
border-radius:
|
|
2330
|
+
border-radius: var(--_pill-radius);
|
|
1889
2331
|
background: rgba(255, 255, 255, 0.15);
|
|
1890
2332
|
backdrop-filter: blur(5px);
|
|
1891
2333
|
color: #fff;
|
|
@@ -1980,7 +2422,7 @@ var productStyles = i`
|
|
|
1980
2422
|
align-items: center;
|
|
1981
2423
|
box-sizing: border-box;
|
|
1982
2424
|
width: 100%;
|
|
1983
|
-
padding:
|
|
2425
|
+
padding: var(--_pill-inset);
|
|
1984
2426
|
border: 0;
|
|
1985
2427
|
border-radius: inherit;
|
|
1986
2428
|
background: transparent;
|
|
@@ -2043,7 +2485,7 @@ var productStyles = i`
|
|
|
2043
2485
|
height: 48px;
|
|
2044
2486
|
padding: 0 16px;
|
|
2045
2487
|
border: 1px solid var(--vtex-ads-story-color-accent, #1b75a8);
|
|
2046
|
-
border-radius:
|
|
2488
|
+
border-radius: var(--_button-radius);
|
|
2047
2489
|
font: inherit;
|
|
2048
2490
|
font-size: 14px;
|
|
2049
2491
|
font-weight: 700;
|
|
@@ -2070,6 +2512,62 @@ var productStyles = i`
|
|
|
2070
2512
|
);
|
|
2071
2513
|
}
|
|
2072
2514
|
|
|
2515
|
+
/* In the cart: the add to cart button's pill, with minus and plus at its
|
|
2516
|
+
ends and the quantity between them. */
|
|
2517
|
+
.product-stepper {
|
|
2518
|
+
justify-content: space-between;
|
|
2519
|
+
padding: 0;
|
|
2520
|
+
background: var(--vtex-ads-story-color-accent, #1b75a8);
|
|
2521
|
+
color: var(--vtex-ads-story-color-accent-contrast, #fff);
|
|
2522
|
+
cursor: auto;
|
|
2523
|
+
}
|
|
2524
|
+
|
|
2525
|
+
.product-stepper-button {
|
|
2526
|
+
display: grid;
|
|
2527
|
+
flex: none;
|
|
2528
|
+
place-items: center;
|
|
2529
|
+
width: 46px;
|
|
2530
|
+
height: 46px;
|
|
2531
|
+
padding: 0;
|
|
2532
|
+
border: 0;
|
|
2533
|
+
border-radius: var(--_button-radius);
|
|
2534
|
+
background: transparent;
|
|
2535
|
+
color: inherit;
|
|
2536
|
+
cursor: pointer;
|
|
2537
|
+
transition: background-color 0.2s ease;
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
.product-stepper-button .icon {
|
|
2541
|
+
width: 18px;
|
|
2542
|
+
height: 18px;
|
|
2543
|
+
}
|
|
2544
|
+
|
|
2545
|
+
.product-stepper-button:hover {
|
|
2546
|
+
background: rgba(0, 0, 0, 0.15);
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
.product-stepper-button:focus-visible {
|
|
2550
|
+
outline: 2px solid var(--vtex-ads-story-color-accent-contrast, #fff);
|
|
2551
|
+
outline-offset: -4px;
|
|
2552
|
+
}
|
|
2553
|
+
|
|
2554
|
+
.product-quantity {
|
|
2555
|
+
flex: 1;
|
|
2556
|
+
min-width: 0;
|
|
2557
|
+
font-size: 16px;
|
|
2558
|
+
text-align: center;
|
|
2559
|
+
}
|
|
2560
|
+
|
|
2561
|
+
.product-cart-status {
|
|
2562
|
+
position: absolute;
|
|
2563
|
+
width: 1px;
|
|
2564
|
+
height: 1px;
|
|
2565
|
+
margin: -1px;
|
|
2566
|
+
overflow: hidden;
|
|
2567
|
+
clip-path: inset(50%);
|
|
2568
|
+
white-space: nowrap;
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2073
2571
|
/* Sold out: add to cart, disabled and grayed. */
|
|
2074
2572
|
.product-unavailable {
|
|
2075
2573
|
border-color: transparent;
|
|
@@ -2159,11 +2657,12 @@ var productStyles = i`
|
|
|
2159
2657
|
}
|
|
2160
2658
|
}
|
|
2161
2659
|
|
|
2660
|
+
/* Its corners follow the pill's, one inset in from them: 8px by default. */
|
|
2162
2661
|
.product-image {
|
|
2163
2662
|
flex: none;
|
|
2164
2663
|
width: 60px;
|
|
2165
2664
|
height: 60px;
|
|
2166
|
-
border-radius:
|
|
2665
|
+
border-radius: max(0px, var(--_pill-radius) - var(--_pill-inset));
|
|
2167
2666
|
background: #fff;
|
|
2168
2667
|
object-fit: contain;
|
|
2169
2668
|
}
|
|
@@ -2227,7 +2726,7 @@ var productStyles = i`
|
|
|
2227
2726
|
.product-add-to-cart-loading {
|
|
2228
2727
|
display: block;
|
|
2229
2728
|
height: 48px;
|
|
2230
|
-
border-radius:
|
|
2729
|
+
border-radius: var(--_button-radius);
|
|
2231
2730
|
}
|
|
2232
2731
|
|
|
2233
2732
|
@media (prefers-reduced-motion: reduce) {
|
|
@@ -2371,7 +2870,12 @@ function renderCard(story, video, options) {
|
|
|
2371
2870
|
return (_a14 = options.onPress) == null ? void 0 : _a14.call(options);
|
|
2372
2871
|
}, capture: true }}
|
|
2373
2872
|
>
|
|
2374
|
-
${renderMedia(story, video, {
|
|
2873
|
+
${renderMedia(story, video, {
|
|
2874
|
+
withVideo,
|
|
2875
|
+
autoplay: options.autoplay,
|
|
2876
|
+
labels: options.labels,
|
|
2877
|
+
announce: false
|
|
2878
|
+
})}
|
|
2375
2879
|
<button
|
|
2376
2880
|
type="button"
|
|
2377
2881
|
class="card-open"
|
|
@@ -2379,7 +2883,7 @@ function renderCard(story, video, options) {
|
|
|
2379
2883
|
aria-label=${options.label}
|
|
2380
2884
|
@click=${options.onSelect}
|
|
2381
2885
|
>
|
|
2382
|
-
|
|
2886
|
+
${withVideo && video.failed ? A : T`<span class="play" aria-hidden="true">${icon("play")}</span>`}
|
|
2383
2887
|
</button>
|
|
2384
2888
|
${withVideo && hasVideo(story, video) && !video.paused ? renderSoundButton(video, options) : A}
|
|
2385
2889
|
${options.product ? renderProduct(
|
|
@@ -2479,6 +2983,17 @@ var o8 = e3(class extends i5 {
|
|
|
2479
2983
|
var STAGE_HEIGHT = i`500px`;
|
|
2480
2984
|
var SOLO_PADDING = i`24px`;
|
|
2481
2985
|
var AUTO_ADVANCE_MS = 5e3;
|
|
2986
|
+
var MIN_SLIDE_DURATION_MS = 2e3;
|
|
2987
|
+
var MAX_SLIDE_DURATION_MS = 12e4;
|
|
2988
|
+
var toSlideDuration = (ms) => {
|
|
2989
|
+
if (ms === void 0 || !Number.isFinite(ms) || ms < 0) {
|
|
2990
|
+
return AUTO_ADVANCE_MS;
|
|
2991
|
+
}
|
|
2992
|
+
if (ms === 0) {
|
|
2993
|
+
return 0;
|
|
2994
|
+
}
|
|
2995
|
+
return Math.min(Math.max(ms, MIN_SLIDE_DURATION_MS), MAX_SLIDE_DURATION_MS);
|
|
2996
|
+
};
|
|
2482
2997
|
var SWIPE_DISTANCE = 40;
|
|
2483
2998
|
var NARROW_SCREEN = i`(max-width: 576px)`;
|
|
2484
2999
|
var VISIBLE_SIDE = 2;
|
|
@@ -2661,9 +3176,12 @@ var CarouselController = class {
|
|
|
2661
3176
|
this.distance = 1;
|
|
2662
3177
|
this.count = 0;
|
|
2663
3178
|
this.narrow = false;
|
|
3179
|
+
this.reducedMotion = false;
|
|
2664
3180
|
this.connected = false;
|
|
2665
3181
|
this.hovered = false;
|
|
2666
3182
|
this.focused = false;
|
|
3183
|
+
/** The interval the running timer was started with. */
|
|
3184
|
+
this.timerMs = 0;
|
|
2667
3185
|
/** The rendered cards, as their cardRef reported them. */
|
|
2668
3186
|
this.cards = /* @__PURE__ */ new Map();
|
|
2669
3187
|
/** The rendered cards' focus targets, as their focusRef reported them. */
|
|
@@ -2762,11 +3280,12 @@ var CarouselController = class {
|
|
|
2762
3280
|
}
|
|
2763
3281
|
}
|
|
2764
3282
|
hostConnected() {
|
|
2765
|
-
var _a13, _b3, _c, _d;
|
|
3283
|
+
var _a13, _b3, _c, _d, _e, _f, _g;
|
|
2766
3284
|
this.connected = true;
|
|
2767
3285
|
this.media = (_a13 = globalThis.matchMedia) == null ? void 0 : _a13.call(globalThis, NARROW_SCREEN.toString());
|
|
2768
3286
|
(_b3 = this.media) == null ? void 0 : _b3.addEventListener("change", this.onMediaChange);
|
|
2769
3287
|
this.narrow = (_d = (_c = this.media) == null ? void 0 : _c.matches) != null ? _d : false;
|
|
3288
|
+
this.reducedMotion = (_g = (_f = (_e = this.options).reducedMotion) == null ? void 0 : _f.call(_e)) != null ? _g : false;
|
|
2770
3289
|
this.syncTimer();
|
|
2771
3290
|
}
|
|
2772
3291
|
hostDisconnected() {
|
|
@@ -2777,8 +3296,8 @@ var CarouselController = class {
|
|
|
2777
3296
|
this.endSwipe();
|
|
2778
3297
|
this.syncTimer();
|
|
2779
3298
|
}
|
|
2780
|
-
// Whatever the host changed (the player opening, new Stories
|
|
2781
|
-
// stop the automatic advance.
|
|
3299
|
+
// Whatever the host changed (the player opening, new Stories, the slide
|
|
3300
|
+
// duration) may start, stop or restart the automatic advance.
|
|
2782
3301
|
hostUpdated() {
|
|
2783
3302
|
this.syncTimer();
|
|
2784
3303
|
}
|
|
@@ -2807,13 +3326,20 @@ var CarouselController = class {
|
|
|
2807
3326
|
(_d = (_c = this.options).onStep) == null ? void 0 : _d.call(_c, from, this.activeKey);
|
|
2808
3327
|
this.restartTimer();
|
|
2809
3328
|
}
|
|
3329
|
+
get slideDuration() {
|
|
3330
|
+
var _a13, _b3;
|
|
3331
|
+
return toSlideDuration((_b3 = (_a13 = this.options).slideDuration) == null ? void 0 : _b3.call(_a13));
|
|
3332
|
+
}
|
|
2810
3333
|
get shouldAdvance() {
|
|
2811
3334
|
var _a13, _b3;
|
|
2812
|
-
return this.connected && this.count > 1 && !this.hovered && !this.focused && !((_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13));
|
|
3335
|
+
return this.slideDuration > 0 && !this.reducedMotion && this.connected && this.count > 1 && !this.hovered && !this.focused && !((_b3 = (_a13 = this.options).locked) == null ? void 0 : _b3.call(_a13));
|
|
2813
3336
|
}
|
|
2814
3337
|
syncTimer() {
|
|
3338
|
+
const ms = this.slideDuration;
|
|
3339
|
+
if (this.timer && this.timerMs !== ms) this.stopTimer();
|
|
2815
3340
|
if (this.shouldAdvance && !this.timer) {
|
|
2816
|
-
this.
|
|
3341
|
+
this.timerMs = ms;
|
|
3342
|
+
this.timer = setInterval(() => this.step(1), ms);
|
|
2817
3343
|
} else if (!this.shouldAdvance && this.timer) {
|
|
2818
3344
|
this.stopTimer();
|
|
2819
3345
|
}
|
|
@@ -2821,6 +3347,7 @@ var CarouselController = class {
|
|
|
2821
3347
|
stopTimer() {
|
|
2822
3348
|
clearInterval(this.timer);
|
|
2823
3349
|
this.timer = void 0;
|
|
3350
|
+
this.timerMs = 0;
|
|
2824
3351
|
}
|
|
2825
3352
|
restartTimer() {
|
|
2826
3353
|
this.stopTimer();
|
|
@@ -2975,6 +3502,105 @@ var CarouselController = class {
|
|
|
2975
3502
|
}
|
|
2976
3503
|
};
|
|
2977
3504
|
|
|
3505
|
+
// src/components/carousel/carousel-skeleton.ts
|
|
3506
|
+
var carouselSkeletonStyles = i`
|
|
3507
|
+
.root {
|
|
3508
|
+
position: relative;
|
|
3509
|
+
}
|
|
3510
|
+
|
|
3511
|
+
.root[data-requesting] {
|
|
3512
|
+
height: ${STAGE_HEIGHT};
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
.root[data-loading] .carousel {
|
|
3516
|
+
visibility: hidden;
|
|
3517
|
+
}
|
|
3518
|
+
|
|
3519
|
+
.skeleton {
|
|
3520
|
+
position: absolute;
|
|
3521
|
+
inset: 0;
|
|
3522
|
+
z-index: 2;
|
|
3523
|
+
box-sizing: border-box;
|
|
3524
|
+
overflow: hidden;
|
|
3525
|
+
pointer-events: none;
|
|
3526
|
+
transition:
|
|
3527
|
+
opacity 0.3s ease,
|
|
3528
|
+
visibility 0s;
|
|
3529
|
+
}
|
|
3530
|
+
|
|
3531
|
+
.skeleton[data-done] {
|
|
3532
|
+
opacity: 0;
|
|
3533
|
+
visibility: hidden;
|
|
3534
|
+
transition:
|
|
3535
|
+
opacity 0.3s ease,
|
|
3536
|
+
visibility 0s 0.3s;
|
|
3537
|
+
}
|
|
3538
|
+
|
|
3539
|
+
.skeleton-slide {
|
|
3540
|
+
position: absolute;
|
|
3541
|
+
top: 0;
|
|
3542
|
+
left: 50%;
|
|
3543
|
+
width: calc(${STAGE_HEIGHT} * 9 / 16);
|
|
3544
|
+
height: 100%;
|
|
3545
|
+
margin-left: calc(${STAGE_HEIGHT} * 9 / -32);
|
|
3546
|
+
transform: translateX(calc(var(--place) * (100% + 8px))) scale(0.9);
|
|
3547
|
+
}
|
|
3548
|
+
|
|
3549
|
+
.skeleton-slide[data-active] {
|
|
3550
|
+
transform: none;
|
|
3551
|
+
}
|
|
3552
|
+
|
|
3553
|
+
.skeleton-card {
|
|
3554
|
+
width: 100%;
|
|
3555
|
+
height: 100%;
|
|
3556
|
+
border-radius: var(--vtex-ads-story-radius, 20px);
|
|
3557
|
+
background: #ececec;
|
|
3558
|
+
animation: skeleton-pulse 1.2s ease-in-out infinite alternate;
|
|
3559
|
+
}
|
|
3560
|
+
|
|
3561
|
+
.skeleton[data-done] .skeleton-card {
|
|
3562
|
+
animation: none;
|
|
3563
|
+
}
|
|
3564
|
+
|
|
3565
|
+
@keyframes skeleton-pulse {
|
|
3566
|
+
to {
|
|
3567
|
+
background-color: #f6f6f6;
|
|
3568
|
+
}
|
|
3569
|
+
}
|
|
3570
|
+
|
|
3571
|
+
@media (prefers-reduced-motion: reduce) {
|
|
3572
|
+
.skeleton,
|
|
3573
|
+
.skeleton[data-done] {
|
|
3574
|
+
transition: none;
|
|
3575
|
+
}
|
|
3576
|
+
|
|
3577
|
+
.skeleton-card {
|
|
3578
|
+
animation: none;
|
|
3579
|
+
}
|
|
3580
|
+
}
|
|
3581
|
+
`;
|
|
3582
|
+
function renderCarouselSkeleton({ done }) {
|
|
3583
|
+
const places = Array.from(
|
|
3584
|
+
{ length: VISIBLE_SIDE * 2 + 1 },
|
|
3585
|
+
(_2, i7) => i7 - VISIBLE_SIDE
|
|
3586
|
+
);
|
|
3587
|
+
return T`
|
|
3588
|
+
<div class="skeleton" aria-hidden="true" ?data-done=${done}>
|
|
3589
|
+
${places.map(
|
|
3590
|
+
(place) => T`
|
|
3591
|
+
<div
|
|
3592
|
+
class="skeleton-slide"
|
|
3593
|
+
?data-active=${place === 0}
|
|
3594
|
+
style=${o8({ "--place": String(place) })}
|
|
3595
|
+
>
|
|
3596
|
+
<div class="skeleton-card"></div>
|
|
3597
|
+
</div>
|
|
3598
|
+
`
|
|
3599
|
+
)}
|
|
3600
|
+
</div>
|
|
3601
|
+
`;
|
|
3602
|
+
}
|
|
3603
|
+
|
|
2978
3604
|
// src/tag-name.ts
|
|
2979
3605
|
var TAG_NAME = "vtex-ads-story-carousel";
|
|
2980
3606
|
|
|
@@ -3030,6 +3656,7 @@ var StoryEventsController = class {
|
|
|
3030
3656
|
click: /* @__PURE__ */ new Set()
|
|
3031
3657
|
};
|
|
3032
3658
|
this.pendingImpressions = [];
|
|
3659
|
+
this.connected = false;
|
|
3033
3660
|
this.watched = /* @__PURE__ */ new Map();
|
|
3034
3661
|
this.onIntersect = (entries) => {
|
|
3035
3662
|
for (const entry of entries) {
|
|
@@ -3052,6 +3679,7 @@ var StoryEventsController = class {
|
|
|
3052
3679
|
}
|
|
3053
3680
|
hostConnected() {
|
|
3054
3681
|
var _a13;
|
|
3682
|
+
this.connected = true;
|
|
3055
3683
|
if (typeof IntersectionObserver === "function") {
|
|
3056
3684
|
this.observer = new IntersectionObserver(this.onIntersect, {
|
|
3057
3685
|
threshold: VIEW_THRESHOLD
|
|
@@ -3061,10 +3689,15 @@ var StoryEventsController = class {
|
|
|
3061
3689
|
"visibilitychange",
|
|
3062
3690
|
this.onVisibilityChange
|
|
3063
3691
|
);
|
|
3064
|
-
this.host.updateComplete.then(() =>
|
|
3692
|
+
this.host.updateComplete.then(() => {
|
|
3693
|
+
if (!this.connected) return;
|
|
3694
|
+
this.sendImpressions();
|
|
3695
|
+
this.syncViewTargets();
|
|
3696
|
+
});
|
|
3065
3697
|
}
|
|
3066
3698
|
hostDisconnected() {
|
|
3067
3699
|
var _a13, _b3;
|
|
3700
|
+
this.connected = false;
|
|
3068
3701
|
(_a13 = globalThis.document) == null ? void 0 : _a13.removeEventListener(
|
|
3069
3702
|
"visibilitychange",
|
|
3070
3703
|
this.onVisibilityChange
|
|
@@ -3073,24 +3706,26 @@ var StoryEventsController = class {
|
|
|
3073
3706
|
this.observer = void 0;
|
|
3074
3707
|
for (const watched of this.watched.values()) clearTimeout(watched.timer);
|
|
3075
3708
|
this.watched.clear();
|
|
3076
|
-
this.pendingImpressions = [];
|
|
3077
3709
|
}
|
|
3078
3710
|
hostUpdated() {
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
this.pendingImpressions = [];
|
|
3082
|
-
for (const story of stories) this.send("impression", story);
|
|
3083
|
-
}
|
|
3711
|
+
if (!this.connected) return;
|
|
3712
|
+
this.sendImpressions();
|
|
3084
3713
|
this.syncViewTargets();
|
|
3085
3714
|
}
|
|
3086
3715
|
/**
|
|
3087
|
-
* The Stories the host
|
|
3088
|
-
* render is done,
|
|
3089
|
-
* has
|
|
3716
|
+
* The Stories the host shows next: their impressions go out once that
|
|
3717
|
+
* render is done, on the page, with a session (or after the first render
|
|
3718
|
+
* that has both). Replaces Stories passed before and not sent yet.
|
|
3090
3719
|
*/
|
|
3091
3720
|
impress(stories) {
|
|
3092
3721
|
this.pendingImpressions = stories;
|
|
3093
3722
|
}
|
|
3723
|
+
sendImpressions() {
|
|
3724
|
+
const stories = this.pendingImpressions;
|
|
3725
|
+
if (!stories.length || !this.options.identity().sessionId) return;
|
|
3726
|
+
this.pendingImpressions = [];
|
|
3727
|
+
for (const story of stories) this.send("impression", story);
|
|
3728
|
+
}
|
|
3094
3729
|
/** A touch on the Story: its click goes out, the first time only. */
|
|
3095
3730
|
click(story) {
|
|
3096
3731
|
this.send("click", story);
|
|
@@ -3372,7 +4007,7 @@ var playerStyles = i`
|
|
|
3372
4007
|
padding: 0;
|
|
3373
4008
|
overflow: hidden;
|
|
3374
4009
|
border: 0;
|
|
3375
|
-
border-radius: 16px;
|
|
4010
|
+
border-radius: var(--vtex-ads-story-radius, 16px);
|
|
3376
4011
|
background: #111;
|
|
3377
4012
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
|
|
3378
4013
|
cursor: pointer;
|
|
@@ -3700,6 +4335,18 @@ var PlayerController = class {
|
|
|
3700
4335
|
this.productOpen = !this.productOpen;
|
|
3701
4336
|
this.host.requestUpdate();
|
|
3702
4337
|
};
|
|
4338
|
+
/**
|
|
4339
|
+
* Loads the failed video again and, once it loads, plays it with the sound
|
|
4340
|
+
* on (muted if the browser blocks it). Not if the player closed or stepped
|
|
4341
|
+
* meanwhile, even back to the same Story: the retry then resolves false.
|
|
4342
|
+
*/
|
|
4343
|
+
this.retryVideo = () => {
|
|
4344
|
+
var _a13;
|
|
4345
|
+
(_a13 = this.dialog.value) == null ? void 0 : _a13.focus();
|
|
4346
|
+
void this.video.retry().then((loaded) => {
|
|
4347
|
+
if (loaded) this.video.playWithSound();
|
|
4348
|
+
});
|
|
4349
|
+
};
|
|
3703
4350
|
/**
|
|
3704
4351
|
* A click on the video: closes the product panel when it is open, plays or
|
|
3705
4352
|
* pauses the video otherwise.
|
|
@@ -3723,7 +4370,8 @@ var PlayerController = class {
|
|
|
3723
4370
|
this.close();
|
|
3724
4371
|
}
|
|
3725
4372
|
/**
|
|
3726
|
-
* Opens the mini player, plays the video
|
|
4373
|
+
* Opens the mini player, plays the video with the sound on (muted if the
|
|
4374
|
+
* browser blocks it) and focuses the close button.
|
|
3727
4375
|
* With `productOpen`, the product panel shows open (the shopper chose the
|
|
3728
4376
|
* product).
|
|
3729
4377
|
*/
|
|
@@ -3743,7 +4391,7 @@ var PlayerController = class {
|
|
|
3743
4391
|
const dialog = this.dialog.value;
|
|
3744
4392
|
if (!this.isOpen || !dialog) return;
|
|
3745
4393
|
this.show(dialog);
|
|
3746
|
-
this.video.
|
|
4394
|
+
this.video.playWithSound();
|
|
3747
4395
|
(_a13 = this.closeButton.value) == null ? void 0 : _a13.focus();
|
|
3748
4396
|
}
|
|
3749
4397
|
/** Hides the player now; the host removes it on its next update. */
|
|
@@ -3765,7 +4413,7 @@ var PlayerController = class {
|
|
|
3765
4413
|
async showNext(delta = 0) {
|
|
3766
4414
|
if (!this.isOpen) return;
|
|
3767
4415
|
const withSound = !this.video.muted;
|
|
3768
|
-
this.video.
|
|
4416
|
+
this.video.clearFailure();
|
|
3769
4417
|
this.productOpen = false;
|
|
3770
4418
|
this.host.requestUpdate();
|
|
3771
4419
|
await this.host.updateComplete;
|
|
@@ -3867,14 +4515,20 @@ var PlayerController = class {
|
|
|
3867
4515
|
* its actions, or the call to action of a link destination. Clicks on them
|
|
3868
4516
|
* don't reach the video.
|
|
3869
4517
|
*/
|
|
3870
|
-
renderDestination({
|
|
4518
|
+
renderDestination({
|
|
4519
|
+
product,
|
|
4520
|
+
cta,
|
|
4521
|
+
labels,
|
|
4522
|
+
productActions
|
|
4523
|
+
}) {
|
|
3871
4524
|
let content;
|
|
3872
4525
|
if (product) {
|
|
3873
4526
|
content = renderExpandableProduct(product, {
|
|
4527
|
+
...productActions,
|
|
4528
|
+
labels,
|
|
3874
4529
|
open: this.productOpen,
|
|
3875
4530
|
onToggle: this.toggleProduct,
|
|
3876
|
-
panelId: "player-product-panel"
|
|
3877
|
-
labels
|
|
4531
|
+
panelId: "player-product-panel"
|
|
3878
4532
|
});
|
|
3879
4533
|
} else if (cta) {
|
|
3880
4534
|
content = renderCta(cta);
|
|
@@ -4020,7 +4674,9 @@ var PlayerController = class {
|
|
|
4020
4674
|
onEnded: advances ? () => {
|
|
4021
4675
|
var _a13;
|
|
4022
4676
|
return (_a13 = options.onStep) == null ? void 0 : _a13.call(options, 1);
|
|
4023
|
-
} : void 0
|
|
4677
|
+
} : void 0,
|
|
4678
|
+
labels: destination.labels,
|
|
4679
|
+
onRetry: this.retryVideo
|
|
4024
4680
|
})}
|
|
4025
4681
|
${hasVideo(story, video) ? this.renderVideoControls(destination.labels) : A}
|
|
4026
4682
|
${this.renderDestination(destination)}
|
|
@@ -4051,13 +4707,12 @@ var PlayerController = class {
|
|
|
4051
4707
|
* The expanded view also shows the `neighbors` beside it.
|
|
4052
4708
|
*/
|
|
4053
4709
|
render(story, {
|
|
4054
|
-
labels,
|
|
4055
4710
|
navigation = false,
|
|
4056
4711
|
neighbors = [],
|
|
4057
|
-
|
|
4058
|
-
|
|
4059
|
-
onPress
|
|
4712
|
+
onPress,
|
|
4713
|
+
...destination
|
|
4060
4714
|
}) {
|
|
4715
|
+
const { labels } = destination;
|
|
4061
4716
|
if (!this.isOpen) return A;
|
|
4062
4717
|
const { video, expanded } = this;
|
|
4063
4718
|
const shownNeighbors = this.track(story, neighbors);
|
|
@@ -4096,11 +4751,7 @@ var PlayerController = class {
|
|
|
4096
4751
|
}}
|
|
4097
4752
|
>
|
|
4098
4753
|
${navigation ? this.renderNavigation(labels) : A}
|
|
4099
|
-
${this.renderVideo(story, navigation && expanded,
|
|
4100
|
-
product,
|
|
4101
|
-
cta,
|
|
4102
|
-
labels
|
|
4103
|
-
})}
|
|
4754
|
+
${this.renderVideo(story, navigation && expanded, destination)}
|
|
4104
4755
|
<span class="player-dim" aria-hidden="true" ${n5(this.dim)}></span>
|
|
4105
4756
|
</div>
|
|
4106
4757
|
</div>
|
|
@@ -4145,6 +4796,12 @@ var intelligentSearchHydration = {
|
|
|
4145
4796
|
price: import_ads_core.intelligentSearchPrice,
|
|
4146
4797
|
available: import_ads_core.intelligentSearchAvailability
|
|
4147
4798
|
};
|
|
4799
|
+
function toShownPrice(value) {
|
|
4800
|
+
const isAmount = (amount) => typeof amount === "number" && Number.isFinite(amount) && amount >= 0;
|
|
4801
|
+
if (!isAmount(value == null ? void 0 : value.price)) return void 0;
|
|
4802
|
+
const { price, listPrice } = value;
|
|
4803
|
+
return isAmount(listPrice) && listPrice > price ? { price, listPrice } : { price };
|
|
4804
|
+
}
|
|
4148
4805
|
async function hydrateStoryProducts(placement, stories, hydration, identity, { signal, timeout } = {}) {
|
|
4149
4806
|
var _a13, _b3;
|
|
4150
4807
|
const products = /* @__PURE__ */ new Map();
|
|
@@ -4159,12 +4816,19 @@ async function hydrateStoryProducts(placement, stories, hydration, identity, { s
|
|
|
4159
4816
|
);
|
|
4160
4817
|
for (const { story, product, offer } of (_a13 = hydrated.stories[placement]) != null ? _a13 : []) {
|
|
4161
4818
|
if (!product || !offer) continue;
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4819
|
+
try {
|
|
4820
|
+
const price = toShownPrice(hydration.price(product, offer));
|
|
4821
|
+
const available = (_b3 = hydration.available) == null ? void 0 : _b3.call(hydration, product, offer);
|
|
4822
|
+
products.set(story.ad_id, {
|
|
4823
|
+
...price && { price },
|
|
4824
|
+
...available !== void 0 && { available }
|
|
4825
|
+
});
|
|
4826
|
+
} catch (error) {
|
|
4827
|
+
console.error(
|
|
4828
|
+
`[${TAG_NAME}] Product details failed for ad ${story.ad_id}`,
|
|
4829
|
+
error
|
|
4830
|
+
);
|
|
4831
|
+
}
|
|
4168
4832
|
}
|
|
4169
4833
|
} catch (error) {
|
|
4170
4834
|
if (!limit.signal.aborted) {
|
|
@@ -4227,105 +4891,57 @@ async function fetchStories({
|
|
|
4227
4891
|
}
|
|
4228
4892
|
}
|
|
4229
4893
|
|
|
4230
|
-
// src/
|
|
4231
|
-
var
|
|
4232
|
-
|
|
4233
|
-
|
|
4234
|
-
|
|
4235
|
-
|
|
4236
|
-
|
|
4237
|
-
|
|
4238
|
-
|
|
4239
|
-
|
|
4240
|
-
|
|
4241
|
-
|
|
4242
|
-
|
|
4243
|
-
|
|
4244
|
-
|
|
4245
|
-
|
|
4246
|
-
|
|
4247
|
-
|
|
4248
|
-
|
|
4249
|
-
|
|
4250
|
-
|
|
4251
|
-
|
|
4252
|
-
|
|
4253
|
-
|
|
4254
|
-
|
|
4255
|
-
|
|
4256
|
-
|
|
4257
|
-
|
|
4258
|
-
|
|
4259
|
-
|
|
4260
|
-
|
|
4261
|
-
|
|
4262
|
-
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
player: "Video",
|
|
4266
|
-
expand: "Ampliar video",
|
|
4267
|
-
collapse: "Reducir video",
|
|
4268
|
-
close: "Cerrar video",
|
|
4269
|
-
play: "Reproducir video",
|
|
4270
|
-
pause: "Pausar video",
|
|
4271
|
-
soundOn: "Activar sonido",
|
|
4272
|
-
soundOff: "Desactivar sonido",
|
|
4273
|
-
addToCart: "Agregar al carrito",
|
|
4274
|
-
unavailable: "Producto no disponible",
|
|
4275
|
-
soldOut: "Agotado",
|
|
4276
|
-
viewProduct: "Ver producto",
|
|
4277
|
-
product: (name, price, listPrice) => {
|
|
4278
|
-
if (price && listPrice)
|
|
4279
|
-
return `${name}, antes ${listPrice}, ahora ${price}`;
|
|
4280
|
-
return price ? `${name}, ${price}` : name;
|
|
4281
|
-
},
|
|
4282
|
-
position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
|
|
4283
|
-
};
|
|
4284
|
-
|
|
4285
|
-
// src/locales/pt.ts
|
|
4286
|
-
var pt = {
|
|
4287
|
-
watch: "Assistir v\xEDdeo",
|
|
4288
|
-
show: "Mostrar v\xEDdeo",
|
|
4289
|
-
carousel: "V\xEDdeos",
|
|
4290
|
-
carouselRole: "carrossel",
|
|
4291
|
-
previous: "V\xEDdeo anterior",
|
|
4292
|
-
next: "Pr\xF3ximo v\xEDdeo",
|
|
4293
|
-
player: "V\xEDdeo",
|
|
4294
|
-
expand: "Expandir v\xEDdeo",
|
|
4295
|
-
collapse: "Reduzir v\xEDdeo",
|
|
4296
|
-
close: "Fechar v\xEDdeo",
|
|
4297
|
-
play: "Reproduzir v\xEDdeo",
|
|
4298
|
-
pause: "Pausar v\xEDdeo",
|
|
4299
|
-
soundOn: "Ativar som",
|
|
4300
|
-
soundOff: "Desativar som",
|
|
4301
|
-
addToCart: "Adicionar ao carrinho",
|
|
4302
|
-
unavailable: "Produto indispon\xEDvel",
|
|
4303
|
-
soldOut: "Esgotado",
|
|
4304
|
-
viewProduct: "Ver produto",
|
|
4305
|
-
product: (name, price, listPrice) => {
|
|
4306
|
-
if (price && listPrice) return `${name}, de ${listPrice} por ${price}`;
|
|
4307
|
-
return price ? `${name}, ${price}` : name;
|
|
4308
|
-
},
|
|
4309
|
-
position: (label, index, count) => count > 1 ? `${label} ${index + 1} de ${count}` : label
|
|
4310
|
-
};
|
|
4894
|
+
// src/utils/media-ready.ts
|
|
4895
|
+
var MEDIA_TIMEOUT = 3e3;
|
|
4896
|
+
function decodeImage(url) {
|
|
4897
|
+
if (typeof Image === "undefined") return Promise.resolve(true);
|
|
4898
|
+
const image = new Image();
|
|
4899
|
+
image.src = url;
|
|
4900
|
+
if (!image.decode) return Promise.resolve(true);
|
|
4901
|
+
return image.decode().then(
|
|
4902
|
+
() => true,
|
|
4903
|
+
() => false
|
|
4904
|
+
);
|
|
4905
|
+
}
|
|
4906
|
+
function firstReady(checks, signal) {
|
|
4907
|
+
if (!checks.length) return Promise.resolve();
|
|
4908
|
+
const limit = withTimeout(void 0, MEDIA_TIMEOUT, signal);
|
|
4909
|
+
return new Promise((resolve) => {
|
|
4910
|
+
const done = () => {
|
|
4911
|
+
limit.clear();
|
|
4912
|
+
resolve();
|
|
4913
|
+
};
|
|
4914
|
+
if (limit.signal.aborted) return done();
|
|
4915
|
+
limit.signal.addEventListener("abort", done, { once: true });
|
|
4916
|
+
let failed = 0;
|
|
4917
|
+
for (const check of checks) {
|
|
4918
|
+
check.then(
|
|
4919
|
+
(ready) => {
|
|
4920
|
+
if (ready || ++failed === checks.length) done();
|
|
4921
|
+
},
|
|
4922
|
+
() => {
|
|
4923
|
+
if (++failed === checks.length) done();
|
|
4924
|
+
}
|
|
4925
|
+
);
|
|
4926
|
+
}
|
|
4927
|
+
});
|
|
4928
|
+
}
|
|
4311
4929
|
|
|
4312
|
-
// src/
|
|
4313
|
-
var
|
|
4314
|
-
|
|
4315
|
-
|
|
4316
|
-
|
|
4317
|
-
|
|
4318
|
-
|
|
4319
|
-
|
|
4320
|
-
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
|
|
4324
|
-
|
|
4325
|
-
|
|
4326
|
-
|
|
4327
|
-
...viewProduct && { viewProduct }
|
|
4328
|
-
};
|
|
4930
|
+
// src/commerce-events.ts
|
|
4931
|
+
var ADD_TO_CART_EVENT = "vtex-ads-story:add-to-cart";
|
|
4932
|
+
var REMOVE_FROM_CART_EVENT = "vtex-ads-story:remove-from-cart";
|
|
4933
|
+
function cartEvent(type, { sku, seller }, quantity) {
|
|
4934
|
+
return new CustomEvent(type, {
|
|
4935
|
+
detail: { sku, ...seller && { seller }, quantity },
|
|
4936
|
+
bubbles: true,
|
|
4937
|
+
composed: true
|
|
4938
|
+
});
|
|
4939
|
+
}
|
|
4940
|
+
function addToCartEvent(item, quantity = 1) {
|
|
4941
|
+
return cartEvent(ADD_TO_CART_EVENT, item, quantity);
|
|
4942
|
+
}
|
|
4943
|
+
function removeFromCartEvent(item, quantity = 1) {
|
|
4944
|
+
return cartEvent(REMOVE_FROM_CART_EVENT, item, quantity);
|
|
4329
4945
|
}
|
|
4330
4946
|
|
|
4331
4947
|
// src/story/story.ts
|
|
@@ -4350,9 +4966,17 @@ var channelConverter = {
|
|
|
4350
4966
|
var hydrationConverter = {
|
|
4351
4967
|
fromAttribute: (value) => value === "none" ? "none" : void 0
|
|
4352
4968
|
};
|
|
4969
|
+
var cartKey = ({ sku, seller }) => JSON.stringify([sku, seller != null ? seller : ""]);
|
|
4353
4970
|
var VtexAdsStoryCarouselElement = class extends i3 {
|
|
4354
4971
|
constructor() {
|
|
4355
4972
|
super();
|
|
4973
|
+
/**
|
|
4974
|
+
* How many of each SKU, from each seller (see cartKey), were added since
|
|
4975
|
+
* the player opened, for its stepper. It doesn't read the store's cart: it
|
|
4976
|
+
* counts the add and remove events sent, and starts over each time the
|
|
4977
|
+
* player opens, as the cart may have changed meanwhile.
|
|
4978
|
+
*/
|
|
4979
|
+
this.cartQuantities = /* @__PURE__ */ new Map();
|
|
4356
4980
|
/**
|
|
4357
4981
|
* One per rendered card, by its key (see Slide): a Story can show in more
|
|
4358
4982
|
* than one card, each with its own video.
|
|
@@ -4374,7 +4998,9 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4374
4998
|
}
|
|
4375
4999
|
},
|
|
4376
5000
|
// The player shows the highlighted Story: the highlight stays on it.
|
|
4377
|
-
locked: () => this.player.isOpen
|
|
5001
|
+
locked: () => this.player.isOpen || this.mediaLoading,
|
|
5002
|
+
slideDuration: () => this.slideDuration,
|
|
5003
|
+
reducedMotion: prefersReducedMotion
|
|
4378
5004
|
});
|
|
4379
5005
|
this.player = new PlayerController(this, {
|
|
4380
5006
|
onStep: (delta) => this.stepInPlayer(delta),
|
|
@@ -4396,6 +5022,7 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4396
5022
|
),
|
|
4397
5023
|
labels: this.labels,
|
|
4398
5024
|
withVideo: active || this.inactiveAutoplay && !hidden,
|
|
5025
|
+
autoplay: !this.mediaLoading,
|
|
4399
5026
|
product: this.productOf(story),
|
|
4400
5027
|
onSelect: active ? () => this.openPlayer() : () => this.carousel.step(offset),
|
|
4401
5028
|
// On a card without the highlight, the product moves it, as the card.
|
|
@@ -4410,6 +5037,8 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4410
5037
|
});
|
|
4411
5038
|
this.inactiveAutoplay = false;
|
|
4412
5039
|
this.stories = [];
|
|
5040
|
+
this.requesting = false;
|
|
5041
|
+
this.mediaLoading = false;
|
|
4413
5042
|
}
|
|
4414
5043
|
// Lit keeps the card's DOM when the element is moved (removed and appended
|
|
4415
5044
|
// again), but the browser pauses a removed video and doesn't autoplay it
|
|
@@ -4425,9 +5054,10 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4425
5054
|
}
|
|
4426
5055
|
// A request still pending when the element leaves the page is cancelled.
|
|
4427
5056
|
disconnectedCallback() {
|
|
4428
|
-
var _a13;
|
|
5057
|
+
var _a13, _b3;
|
|
4429
5058
|
super.disconnectedCallback();
|
|
4430
5059
|
(_a13 = this.request) == null ? void 0 : _a13.abort();
|
|
5060
|
+
(_b3 = this.mediaWait) == null ? void 0 : _b3.abort();
|
|
4431
5061
|
}
|
|
4432
5062
|
willUpdate(changed) {
|
|
4433
5063
|
if (REQUEST_PROPERTIES.some((name) => changed.has(name))) {
|
|
@@ -4456,16 +5086,21 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4456
5086
|
const request = new AbortController();
|
|
4457
5087
|
this.request = request;
|
|
4458
5088
|
this.player.close();
|
|
5089
|
+
this.requesting = false;
|
|
4459
5090
|
this.showStories([]);
|
|
4460
5091
|
if (!this.isConnected) {
|
|
4461
5092
|
request.abort();
|
|
4462
5093
|
return;
|
|
4463
5094
|
}
|
|
5095
|
+
this.requesting = Boolean(
|
|
5096
|
+
this.publisherId && this.sessionId && this.placement
|
|
5097
|
+
);
|
|
4464
5098
|
const stories = await fetchStories(this, {
|
|
4465
5099
|
signal: request.signal,
|
|
4466
5100
|
timeout: this.timeout
|
|
4467
5101
|
});
|
|
4468
5102
|
if (request.signal.aborted) return;
|
|
5103
|
+
this.requesting = false;
|
|
4469
5104
|
const hydration = this.activeHydration;
|
|
4470
5105
|
if (!hydration || !stories.some((story) => story.product)) {
|
|
4471
5106
|
this.request = void 0;
|
|
@@ -4499,7 +5134,34 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4499
5134
|
this.afterRender = void 0;
|
|
4500
5135
|
this.carousel.reset(stories.length);
|
|
4501
5136
|
this.stories = stories;
|
|
5137
|
+
void this.waitForFirstMedia(stories);
|
|
5138
|
+
}
|
|
5139
|
+
/**
|
|
5140
|
+
* Shows the cards once the first Story's cover or video is ready: whichever
|
|
5141
|
+
* loads first, or once both failed. Only then are the Stories impressed
|
|
5142
|
+
* and do their videos play, from the start.
|
|
5143
|
+
*/
|
|
5144
|
+
async waitForFirstMedia(stories) {
|
|
5145
|
+
var _a13, _b3, _c;
|
|
5146
|
+
(_a13 = this.mediaWait) == null ? void 0 : _a13.abort();
|
|
5147
|
+
const wait = new AbortController();
|
|
5148
|
+
this.mediaWait = wait;
|
|
5149
|
+
const cover = httpUrl((_b3 = stories[0]) == null ? void 0 : _b3.poster_url);
|
|
5150
|
+
const video = httpUrl((_c = stories[0]) == null ? void 0 : _c.media_url);
|
|
5151
|
+
const checks = [];
|
|
5152
|
+
if (cover) checks.push(decodeImage(cover));
|
|
5153
|
+
if (video) checks.push(this.videoFor(this.carousel.activeKey).ready);
|
|
5154
|
+
this.mediaLoading = checks.length > 0;
|
|
5155
|
+
await firstReady(checks, wait.signal);
|
|
5156
|
+
if (this.mediaWait !== wait) return;
|
|
5157
|
+
this.mediaWait = void 0;
|
|
5158
|
+
this.mediaLoading = false;
|
|
4502
5159
|
this.events.impress(stories);
|
|
5160
|
+
this.afterRender = () => {
|
|
5161
|
+
if (!this.isConnected) return;
|
|
5162
|
+
for (const cardVideo of this.cardVideos.values()) cardVideo.resume();
|
|
5163
|
+
};
|
|
5164
|
+
this.requestUpdate();
|
|
4503
5165
|
}
|
|
4504
5166
|
/**
|
|
4505
5167
|
* Where each Story is being watched: the cards on screen (not the hidden
|
|
@@ -4510,6 +5172,7 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4510
5172
|
*viewTargets() {
|
|
4511
5173
|
var _a13;
|
|
4512
5174
|
const { stories } = this;
|
|
5175
|
+
if (this.mediaLoading) return;
|
|
4513
5176
|
if (!this.player.isExpanded) {
|
|
4514
5177
|
for (const [card, { key, index }] of this.carousel.visibleCards()) {
|
|
4515
5178
|
const story = stories[index];
|
|
@@ -4567,6 +5230,7 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4567
5230
|
openPlayer({ productOpen = false } = {}) {
|
|
4568
5231
|
var _a13;
|
|
4569
5232
|
if (this.player.isOpen) return;
|
|
5233
|
+
this.cartQuantities.clear();
|
|
4570
5234
|
(_a13 = this.activeVideo) == null ? void 0 : _a13.pause();
|
|
4571
5235
|
void this.player.open({ productOpen });
|
|
4572
5236
|
}
|
|
@@ -4620,7 +5284,23 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4620
5284
|
const { stories } = this;
|
|
4621
5285
|
const index = this.carousel.active;
|
|
4622
5286
|
const active = stories[index];
|
|
4623
|
-
if (!active) return A;
|
|
5287
|
+
if (!active && !this.requesting) return A;
|
|
5288
|
+
const loading = this.requesting || this.mediaLoading;
|
|
5289
|
+
return T`
|
|
5290
|
+
<div
|
|
5291
|
+
class="root"
|
|
5292
|
+
?data-loading=${loading}
|
|
5293
|
+
?data-requesting=${this.requesting}
|
|
5294
|
+
>
|
|
5295
|
+
${active ? this.carousel.render(stories, this.renderSlide, this.labels) : A}
|
|
5296
|
+
${renderCarouselSkeleton({ done: !loading })}
|
|
5297
|
+
</div>
|
|
5298
|
+
${active ? this.renderPlayer(active) : A}
|
|
5299
|
+
`;
|
|
5300
|
+
}
|
|
5301
|
+
renderPlayer(active) {
|
|
5302
|
+
const { stories } = this;
|
|
5303
|
+
const index = this.carousel.active;
|
|
4624
5304
|
const neighbors = neighborOffsets(stories.length, index).map((offset) => {
|
|
4625
5305
|
const neighbor = (index + offset + stories.length) % stories.length;
|
|
4626
5306
|
return {
|
|
@@ -4629,19 +5309,52 @@ var VtexAdsStoryCarouselElement = class extends i3 {
|
|
|
4629
5309
|
label: this.labels.position(this.labels.show, neighbor, stories.length)
|
|
4630
5310
|
};
|
|
4631
5311
|
});
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
${this.carousel.render(stories, this.renderSlide, this.labels)}
|
|
4635
|
-
</div>
|
|
4636
|
-
${this.player.render(active, {
|
|
5312
|
+
const product = this.productOf(active);
|
|
5313
|
+
return this.player.render(active, {
|
|
4637
5314
|
labels: this.labels,
|
|
4638
5315
|
navigation: stories.length > 1,
|
|
4639
5316
|
neighbors,
|
|
4640
|
-
product
|
|
5317
|
+
product,
|
|
4641
5318
|
cta: toCardCta(active),
|
|
5319
|
+
productActions: this.cartActionsFor(product),
|
|
4642
5320
|
onPress: () => this.events.click(active)
|
|
4643
|
-
})
|
|
4644
|
-
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
cartActionsFor(product) {
|
|
5324
|
+
const sku = product == null ? void 0 : product.sku;
|
|
5325
|
+
if (!sku) return void 0;
|
|
5326
|
+
const item = { sku, seller: product.seller };
|
|
5327
|
+
return {
|
|
5328
|
+
cartQuantity: this.cartQuantities.get(cartKey(item)),
|
|
5329
|
+
onAddToCart: () => this.changeCart(item, 1),
|
|
5330
|
+
onRemoveFromCart: () => this.changeCart(item, -1)
|
|
5331
|
+
};
|
|
5332
|
+
}
|
|
5333
|
+
/**
|
|
5334
|
+
* Adds one of `item` to the stepper's count, or removes one, and tells the
|
|
5335
|
+
* store, which changes its cart: the element has none. When add to cart
|
|
5336
|
+
* and the stepper swap places, the focus moves to the one now shown.
|
|
5337
|
+
*/
|
|
5338
|
+
changeCart(item, delta) {
|
|
5339
|
+
var _a13;
|
|
5340
|
+
const key = cartKey(item);
|
|
5341
|
+
const before = (_a13 = this.cartQuantities.get(key)) != null ? _a13 : 0;
|
|
5342
|
+
const after = Math.max(0, before + delta);
|
|
5343
|
+
if (after === before) return;
|
|
5344
|
+
if (after > 0) this.cartQuantities.set(key, after);
|
|
5345
|
+
else this.cartQuantities.delete(key);
|
|
5346
|
+
this.requestUpdate();
|
|
5347
|
+
this.dispatchEvent(
|
|
5348
|
+
delta > 0 ? addToCartEvent(item) : removeFromCartEvent(item)
|
|
5349
|
+
);
|
|
5350
|
+
let swapped;
|
|
5351
|
+
if (before === 0) swapped = "stepper";
|
|
5352
|
+
else if (after === 0) swapped = "add";
|
|
5353
|
+
if (!swapped) return;
|
|
5354
|
+
const action = swapped;
|
|
5355
|
+
this.updateComplete.then(
|
|
5356
|
+
() => this.shadowRoot && focusCartAction(this.shadowRoot, action)
|
|
5357
|
+
);
|
|
4645
5358
|
}
|
|
4646
5359
|
};
|
|
4647
5360
|
VtexAdsStoryCarouselElement.properties = {
|
|
@@ -4658,13 +5371,16 @@ VtexAdsStoryCarouselElement.properties = {
|
|
|
4658
5371
|
labelViewProduct: { attribute: "label-view-product" },
|
|
4659
5372
|
hydration: { converter: hydrationConverter },
|
|
4660
5373
|
hydrationTimeout: { type: Number, attribute: "hydration-timeout" },
|
|
5374
|
+
slideDuration: { type: Number, attribute: "slide-duration" },
|
|
4661
5375
|
inactiveAutoplay: {
|
|
4662
5376
|
type: Boolean,
|
|
4663
5377
|
attribute: "inactive-autoplay",
|
|
4664
5378
|
converter: booleanConverter
|
|
4665
5379
|
},
|
|
4666
5380
|
stories: { state: true },
|
|
4667
|
-
products: { state: true }
|
|
5381
|
+
products: { state: true },
|
|
5382
|
+
requesting: { state: true },
|
|
5383
|
+
mediaLoading: { state: true }
|
|
4668
5384
|
};
|
|
4669
5385
|
VtexAdsStoryCarouselElement.styles = [
|
|
4670
5386
|
i`
|
|
@@ -4672,11 +5388,16 @@ VtexAdsStoryCarouselElement.styles = [
|
|
|
4672
5388
|
display: block;
|
|
4673
5389
|
font-family: var(--vtex-ads-story-font-family, inherit);
|
|
4674
5390
|
color: var(--vtex-ads-story-color-text, inherit);
|
|
5391
|
+
--_pill-radius: var(--vtex-ads-story-radius, 16px);
|
|
5392
|
+
--_pill-inset: 8px;
|
|
5393
|
+
--_button-radius: var(--vtex-ads-story-radius, 999px);
|
|
4675
5394
|
}
|
|
4676
5395
|
`,
|
|
4677
5396
|
cardStyles,
|
|
5397
|
+
mediaStyles,
|
|
4678
5398
|
productStyles,
|
|
4679
5399
|
carouselStyles,
|
|
5400
|
+
carouselSkeletonStyles,
|
|
4680
5401
|
playerStyles
|
|
4681
5402
|
];
|
|
4682
5403
|
function defineVtexAdsStoryCarousel() {
|
|
@@ -4686,6 +5407,8 @@ function defineVtexAdsStoryCarousel() {
|
|
|
4686
5407
|
}
|
|
4687
5408
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4688
5409
|
0 && (module.exports = {
|
|
5410
|
+
ADD_TO_CART_EVENT,
|
|
5411
|
+
REMOVE_FROM_CART_EVENT,
|
|
4689
5412
|
TAG_NAME,
|
|
4690
5413
|
VtexAdsStoryCarouselElement,
|
|
4691
5414
|
defineVtexAdsStoryCarousel
|