@depict-ai/ui 4.2.0 → 4.2.1

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/latest/index.cjs CHANGED
@@ -94,7 +94,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
94
94
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
95
95
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
96
96
  /*! Depict.ai search and product listing SDK */
97
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.2.0";
97
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.2.1";
98
98
  const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
99
99
  const cols_at_size = [];
100
100
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -1310,15 +1310,18 @@ function $1ae437d7d388a66e$export$b73ed90f0ee50dc3({
1310
1310
  outerRef_: outerRef_,
1311
1311
  animationDuration_: animationDuration_
1312
1312
  }) {
1313
- const variantToUse = display_?.variant_displays[display_?.variant_index];
1314
- const imageUrls = variantToUse?.image_urls;
1315
- const imageUrl = imageUrls?.[0];
1316
- const secondaryImageUrl = imageUrls?.[1];
1313
+ const variantToUse = $gVhhF$solidjs.createMemo(() => {
1314
+ const display = display_();
1315
+ return display?.variant_displays[display?.variant_index];
1316
+ });
1317
+ const imageUrls = () => variantToUse()?.image_urls;
1318
+ const imageUrl = $gVhhF$solidjs.createMemo(() => imageUrls()?.[0]);
1319
+ const secondaryImageUrl = $gVhhF$solidjs.createMemo(() => imageUrls()?.[1]);
1317
1320
  const [animationIsRunning, setAnimationIsRunning] = textFadeInAnimationRunning_;
1318
1321
  const [isExpandedThrottledByOurEffectRun, setIsExpandedThrottledByOurEffectRun] = $gVhhF$solidjs.createSignal($gVhhF$solidjs.untrack(isExpanded_));
1319
1322
  const [animationEffectExists, setAnimationEffectExists] = $gVhhF$solidjs.createSignal(false);
1320
- const [salePrice] = $gVhhF$solidjs.createResource(() => variantToUse?.sale_price);
1321
- const [originalPrice] = $gVhhF$solidjs.createResource(() => variantToUse?.original_price);
1323
+ const [salePrice] = $gVhhF$solidjs.createResource(() => variantToUse()?.sale_price);
1324
+ const [originalPrice] = $gVhhF$solidjs.createResource(() => variantToUse()?.original_price);
1322
1325
  const isOnSale = $gVhhF$solidjs.createMemo(() => salePrice.latest !== originalPrice.latest); // .latest doesn't trigger suspense
1323
1326
  const FavoriteButton = FavoriteButton_; // Just to get rid of the type error - TS doesn't understand <Show>
1324
1327
  return (() => {
@@ -1330,7 +1333,7 @@ function $1ae437d7d388a66e$export$b73ed90f0ee50dc3({
1330
1333
  var _ref$ = outerRef_;
1331
1334
  typeof _ref$ === "function" ? $gVhhF$solidjsweb.use(_ref$, _el$) : outerRef_ = _el$;
1332
1335
  $gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(() => isExpanded_() && !animationIsRunning() ? {
1333
- href: variantToUse?.page_url
1336
+ href: variantToUse()?.page_url
1334
1337
  } : {}), false, true);
1335
1338
  $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1336
1339
  when: imageUrl,
@@ -1345,20 +1348,38 @@ function $1ae437d7d388a66e$export$b73ed90f0ee50dc3({
1345
1348
  [_el$4, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$3.nextSibling),
1346
1349
  _el$5 = _el$4.nextSibling,
1347
1350
  [_el$6, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling);
1348
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $d212a67662c5cf38$export$9d4a4b669b1929ab), {
1349
- src: imageUrl,
1350
- get aspectRatio() {
1351
- return isExpanded_() ? 0.75 : 1;
1351
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1352
+ get when() {
1353
+ return imageUrl();
1354
+ },
1355
+ get fallback() {
1356
+ return $gVhhF$solidjsweb.createComponent((0, $3bc4a89b971a3af5$export$3f37af283f8fb843), {
1357
+ aspectRatio: 1
1358
+ });
1352
1359
  },
1353
- get autoAdjustAspectRatio() {
1354
- return isExpanded_() ? "smoothed" : false;
1360
+ get children() {
1361
+ return $gVhhF$solidjsweb.createComponent((0, $d212a67662c5cf38$export$9d4a4b669b1929ab), {
1362
+ get src() {
1363
+ return imageUrl();
1364
+ },
1365
+ get aspectRatio() {
1366
+ return isExpanded_() ? 0.75 : 1;
1367
+ },
1368
+ get autoAdjustAspectRatio() {
1369
+ return isExpanded_() ? "smoothed" : false;
1370
+ }
1371
+ });
1355
1372
  }
1356
1373
  }), _el$4, _co$);
1357
1374
  $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1358
- when: secondaryImageUrl,
1375
+ get when() {
1376
+ return secondaryImageUrl();
1377
+ },
1359
1378
  get children() {
1360
1379
  return $gVhhF$solidjsweb.createComponent((0, $d212a67662c5cf38$export$9d4a4b669b1929ab), {
1361
- src: secondaryImageUrl,
1380
+ get src() {
1381
+ return secondaryImageUrl();
1382
+ },
1362
1383
  get aspectRatio() {
1363
1384
  return isExpanded_() ? 0.75 : 1;
1364
1385
  },
@@ -1417,12 +1438,12 @@ function $1ae437d7d388a66e$export$b73ed90f0ee50dc3({
1417
1438
  disconnector();
1418
1439
  }));
1419
1440
  }, _el$7);
1420
- $gVhhF$solidjsweb.insert(_el$9, () => variantToUse?.title ?? $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
1441
+ $gVhhF$solidjsweb.insert(_el$9, () => variantToUse()?.title ?? $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
1421
1442
  height: "1em",
1422
1443
  width: "20ch"
1423
1444
  }));
1424
1445
  $gVhhF$solidjsweb.insert(_el$10, (() => {
1425
- var _c$ = $gVhhF$solidjsweb.memo(() => !!(!variantToUse || salePrice.loading));
1446
+ var _c$ = $gVhhF$solidjsweb.memo(() => !!(!variantToUse() || salePrice.loading));
1426
1447
  return () => _c$() ? $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
1427
1448
  height: "1em",
1428
1449
  width: "20ch"
@@ -1435,7 +1456,7 @@ function $1ae437d7d388a66e$export$b73ed90f0ee50dc3({
1435
1456
  get children() {
1436
1457
  var _el$11 = $gVhhF$solidjsweb.getNextElement($1ae437d7d388a66e$var$_tmpl$2);
1437
1458
  $gVhhF$solidjsweb.insert(_el$11, (() => {
1438
- var _c$2 = $gVhhF$solidjsweb.memo(() => !!(!variantToUse || originalPrice.loading));
1459
+ var _c$2 = $gVhhF$solidjsweb.memo(() => !!(!variantToUse() || originalPrice.loading));
1439
1460
  return () => _c$2() ? $gVhhF$solidjsweb.createComponent((0, $061ff5b4c3d36171$export$89c6019e4baa40b1), {
1440
1461
  height: "1em",
1441
1462
  width: "20ch"
@@ -1502,7 +1523,7 @@ async function $b9e830d616d01b31$var$checkIfIsAffectedByChromeBug326498383() {
1502
1523
  // Passive to make it more likely to run the callback before our timeout if the browser is under high load during the test
1503
1524
  {
1504
1525
  once: true,
1505
- passive: true
1526
+ passive: false
1506
1527
  });
1507
1528
  await timeoutPromise;
1508
1529
  } catch (e) {
@@ -1526,19 +1547,16 @@ function $905010a06f9aeae5$export$ebf0b1d4f90c09ae({
1526
1547
  // The following three signals just contain the state if the animations are actually running and should only be set by the respective animation code
1527
1548
  const textFadeInAnimationRunning = $gVhhF$solidjs.createSignal(false);
1528
1549
  const [getSecondPartAnimationRunning] = textFadeInAnimationRunning;
1529
- // These expanded variables are what's used to trigger the second and first phase animations
1530
1550
  $b9e830d616d01b31$export$7b9a0e99f0aeb2f3().then(is => isAffectedByChromeBug = is);
1531
1551
  return $gVhhF$solidjsweb.createComponent((0, $84798aaa863a4909$export$e68cff63f76bd15b), {
1532
1552
  get children() {
1533
1553
  return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1534
1554
  get when() {
1535
- return containerWidth_();
1555
+ return containerWidth_() || !displays_;
1536
1556
  },
1537
1557
  get children() {
1538
1558
  var _el$ = $gVhhF$solidjsweb.getNextElement($905010a06f9aeae5$var$_tmpl$),
1539
1559
  _el$2 = _el$.firstChild;
1540
- $gVhhF$solidjsweb.addEventListener(_el$2, "mouseleave", $gVhhF$depictaiutilishared.catchify(() => supportsHover_() && setUserWantsExpanded(false)));
1541
- $gVhhF$solidjsweb.addEventListener(_el$2, "mouseenter", $gVhhF$depictaiutilishared.catchify(() => supportsHover_() && setUserWantsExpanded(true)));
1542
1560
  $gVhhF$solidjsweb.use(el => $gVhhF$solidjs.createEffect(() => {
1543
1561
  if (userWantsExpanded()) return;
1544
1562
  if (isAffectedByChromeBug) {
@@ -1550,35 +1568,45 @@ function $905010a06f9aeae5$export$ebf0b1d4f90c09ae({
1550
1568
  behavior: "smooth"
1551
1569
  });
1552
1570
  }), _el$2);
1553
- $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.For), {
1554
- each: displays_,
1555
- children: (display, index) => $gVhhF$solidjsweb.createComponent((0, $1ae437d7d388a66e$export$b73ed90f0ee50dc3), {
1556
- animationDuration_: animationDuration_,
1557
- display_: display,
1558
- FavoriteButton_: FavoriteButton_,
1559
- isExpanded_: userWantsExpanded,
1560
- textFadeInAnimationRunning_: textFadeInAnimationRunning,
1561
- outerRef_: el => $gVhhF$solidjs.createEffect(() => {
1562
- if (index() !== 0) return;
1563
- const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => setLookItemHeight(records.at(-1).contentRect.height)));
1564
- resizeObserver.observe(el);
1565
- $gVhhF$solidjs.onCleanup(() => resizeObserver.disconnect());
1566
- })
1567
- })
1571
+ $gVhhF$solidjsweb.spread(_el$2, $gVhhF$solidjsweb.mergeProps({
1572
+ get classList() {
1573
+ return {
1574
+ expanded: userWantsExpanded(),
1575
+ "resting-fully-expanded": !getSecondPartAnimationRunning() && userWantsExpanded()
1576
+ };
1577
+ },
1578
+ get onMouseEnter() {
1579
+ return $gVhhF$depictaiutilishared.catchify(() => supportsHover_() && setUserWantsExpanded(true));
1580
+ },
1581
+ get onMouseLeave() {
1582
+ return $gVhhF$depictaiutilishared.catchify(() => supportsHover_() && setUserWantsExpanded(false));
1583
+ }
1584
+ }, () => displays_ && {
1585
+ style: `--look-card-width:${containerWidth_()}px;--look-item-height:${lookItemHeight() || 200}px`
1586
+ }), false, true);
1587
+ $gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
1588
+ get each() {
1589
+ return displays_ || Array.from({
1590
+ length: 4
1591
+ });
1592
+ },
1593
+ children: (display, index) => {
1594
+ return $gVhhF$solidjsweb.createComponent((0, $1ae437d7d388a66e$export$b73ed90f0ee50dc3), {
1595
+ animationDuration_: animationDuration_,
1596
+ display_: display,
1597
+ FavoriteButton_: FavoriteButton_,
1598
+ isExpanded_: userWantsExpanded,
1599
+ textFadeInAnimationRunning_: textFadeInAnimationRunning,
1600
+ outerRef_: el => $gVhhF$solidjs.createEffect(() => {
1601
+ if (index !== 0) return;
1602
+ const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => setLookItemHeight(records.at(-1).contentRect.height)));
1603
+ resizeObserver.observe(el);
1604
+ $gVhhF$solidjs.onCleanup(() => resizeObserver.disconnect());
1605
+ })
1606
+ });
1607
+ }
1568
1608
  }));
1569
- $gVhhF$solidjsweb.effect(_p$ => {
1570
- var _v$ = `--look-card-width:${containerWidth_()}px;--look-item-height:${lookItemHeight() || 200}px`,
1571
- _v$2 = !!userWantsExpanded(),
1572
- _v$3 = !!(!getSecondPartAnimationRunning() && userWantsExpanded());
1573
- _p$.e = $gVhhF$solidjsweb.style(_el$2, _v$, _p$.e);
1574
- _v$2 !== _p$.t && _el$2.classList.toggle("expanded", _p$.t = _v$2);
1575
- _v$3 !== _p$.a && _el$2.classList.toggle("resting-fully-expanded", _p$.a = _v$3);
1576
- return _p$;
1577
- }, {
1578
- e: undefined,
1579
- t: undefined,
1580
- a: undefined
1581
- });
1609
+ $gVhhF$solidjsweb.runHydrationEvents();
1582
1610
  return _el$;
1583
1611
  }
1584
1612
  });
@@ -1605,20 +1633,25 @@ function $905010a06f9aeae5$var$scrollingFunctionForChrome(element, targetScrollY
1605
1633
  // Bootstrap our animation - it will get called right before next frame shall be rendered.
1606
1634
  requestAnimationFrame(step);
1607
1635
  }
1608
- var $ad882bbe664dbd53$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=look-card style=--animation-duration:300ms>`);
1609
- function $ad882bbe664dbd53$export$44809a8a3e867e30(display, info, FavoriteButton_) {
1636
+ var $ad882bbe664dbd53$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=look-card>`);
1637
+ function $ad882bbe664dbd53$export$44809a8a3e867e30({
1638
+ display_: display_,
1639
+ expandedLooksSignal_: [expandedLooks_, setExpandedLooks],
1640
+ FavoriteButton_: FavoriteButton_,
1641
+ placeholderImageAspectRatio_: placeholderImageAspectRatio_,
1642
+ animationDuration_: animationDuration_
1643
+ }) {
1610
1644
  // TODO: shopify, run displayTransformers to get dynamic prices
1611
1645
  // TODO: format prices
1612
- const animationDuration_ = 300;
1613
- const [coverImage] = display?.image_urls || [];
1646
+ const [coverImage] = display_?.image_urls || [];
1614
1647
  const useWantsExpandedSignal_ = $gVhhF$solidjs.createSignal(false);
1615
1648
  const [userWantsExpanded, setUserWantsExpanded] = useWantsExpandedSignal_;
1616
- const [expandedLooks_, setExpandedLooks] = info?.expandedLooksSignal_ || [];
1617
1649
  const supportsHover_ = $b54e6192d0caa293$export$d9f36cf74e24d595("(hover: hover) and (pointer: fine)");
1618
1650
  const us = Symbol("look");
1619
1651
  const container = (() => {
1620
1652
  var _el$ = $gVhhF$solidjsweb.getNextElement($ad882bbe664dbd53$var$_tmpl$);
1621
1653
  $gVhhF$solidjsweb.addEventListener(_el$, "click", $gVhhF$depictaiutilishared.catchify(() => setUserWantsExpanded(prev => !prev)), true);
1654
+ _el$.classList.toggle("placeholder", !!!display_);
1622
1655
  $gVhhF$solidjsweb.runHydrationEvents();
1623
1656
  return _el$;
1624
1657
  })();
@@ -1632,7 +1665,7 @@ function $ad882bbe664dbd53$export$44809a8a3e867e30(display, info, FavoriteButton
1632
1665
  });
1633
1666
  addEventListener("click", clickHandler);
1634
1667
  $gVhhF$solidjs.onCleanup(() => removeEventListener("click", clickHandler));
1635
- $gVhhF$solidjs.createEffect(() => setExpandedLooks?.(prev => {
1668
+ $gVhhF$solidjs.createEffect(() => setExpandedLooks(prev => {
1636
1669
  if (userWantsExpanded()) {
1637
1670
  // Close the other expanded looks
1638
1671
  prev.clear();
@@ -1642,42 +1675,42 @@ function $ad882bbe664dbd53$export$44809a8a3e867e30(display, info, FavoriteButton
1642
1675
  return prev;
1643
1676
  }));
1644
1677
  // Close us if another look expands
1645
- $gVhhF$solidjs.createEffect(() => expandedLooks_ && !expandedLooks_().has(us) && setUserWantsExpanded(false));
1646
- $gVhhF$solidjsweb.insert(container, () => $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1647
- when: display,
1678
+ $gVhhF$solidjs.createEffect(() => !expandedLooks_().has(us) && setUserWantsExpanded(false));
1679
+ $gVhhF$solidjsweb.insert(container, () => [$gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
1680
+ when: display_,
1648
1681
  get fallback() {
1649
1682
  return $gVhhF$solidjsweb.createComponent((0, $3bc4a89b971a3af5$export$3f37af283f8fb843), {
1650
- width: "100%",
1651
- height: "100%"
1683
+ aspectRatio: placeholderImageAspectRatio_
1652
1684
  });
1653
1685
  },
1654
1686
  get children() {
1655
- return [$gVhhF$solidjsweb.createComponent((0, $d212a67662c5cf38$export$9d4a4b669b1929ab), {
1687
+ return $gVhhF$solidjsweb.createComponent((0, $d212a67662c5cf38$export$9d4a4b669b1929ab), {
1656
1688
  src: coverImage,
1657
- aspectRatio: 0.75,
1689
+ aspectRatio: placeholderImageAspectRatio_,
1658
1690
  autoAdjustAspectRatio: true
1659
- }), $gVhhF$solidjsweb.createComponent((0, $905010a06f9aeae5$export$ebf0b1d4f90c09ae), {
1660
- get displays_() {
1661
- return display?.displays;
1662
- },
1663
- userWantsExpandedSignal_: useWantsExpandedSignal_,
1664
- containerWidth_: containerWidth_,
1665
- animationDuration_: animationDuration_,
1666
- supportsHover_: supportsHover_,
1667
- FavoriteButton_: FavoriteButton_
1668
- })];
1691
+ });
1669
1692
  }
1670
- }));
1693
+ }), $gVhhF$solidjsweb.createComponent((0, $905010a06f9aeae5$export$ebf0b1d4f90c09ae), {
1694
+ get displays_() {
1695
+ return display_?.displays;
1696
+ },
1697
+ userWantsExpandedSignal_: useWantsExpandedSignal_,
1698
+ containerWidth_: containerWidth_,
1699
+ animationDuration_: animationDuration_,
1700
+ supportsHover_: supportsHover_,
1701
+ FavoriteButton_: FavoriteButton_
1702
+ })]);
1671
1703
  return container;
1672
1704
  }
1673
1705
  $gVhhF$solidjsweb.delegateEvents(["click"]);
1674
- var $072863633018e322$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict recommendations looks">`);
1706
+ var $072863633018e322$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="depict recommendations looks"style=--animation-duration:240ms>`);
1675
1707
  let $072863633018e322$var$expandedLooksSignal_;
1676
1708
  function $072863633018e322$export$1935e6bdfc5ed8ce(props) {
1677
1709
  return $95837413165cc2df$export$23fca46f3143581f(() => {
1678
1710
  $072863633018e322$var$expandedLooksSignal_ ||= $gVhhF$solidjs.createSignal(new Set(), {
1679
1711
  equals: false
1680
1712
  });
1713
+ const expandingAnimationDuration = 240;
1681
1714
  const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
1682
1715
  const {
1683
1716
  gridSpacing_: gridSpacing_
@@ -1712,10 +1745,13 @@ function $072863633018e322$export$1935e6bdfc5ed8ce(props) {
1712
1745
  $gVhhF$solidjsweb.insert(_el$, $gVhhF$solidjsweb.createComponent((0, $84798aaa863a4909$export$e68cff63f76bd15b), {
1713
1746
  get children() {
1714
1747
  return $363ce4d1d71041aa$export$d41d19e89346fa2({
1715
- product_card_template_: (display, info) => $ad882bbe664dbd53$export$44809a8a3e867e30(display, info ? {
1716
- ...info,
1748
+ product_card_template_: (display, info) => $ad882bbe664dbd53$export$44809a8a3e867e30({
1749
+ display_: display,
1750
+ FavoriteButton_: props.FavoriteButton_,
1751
+ placeholderImageAspectRatio_: props.imagePlaceholderAspectRatio_,
1752
+ animationDuration_: expandingAnimationDuration,
1717
1753
  expandedLooksSignal_: $072863633018e322$var$expandedLooksSignal_
1718
- } : info, props.FavoriteButton_),
1754
+ }),
1719
1755
  recommendations_resource_: looksResource,
1720
1756
  title_: () => props.title_,
1721
1757
  layout_options_: $gVhhF$solidjs.createMemo(() => ({
package/latest/index.d.ts CHANGED
@@ -10,7 +10,7 @@ import { ProductListingRequestV3 } from "@depict-ai/types/api/ProductListingRequ
10
10
  import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { SearchFilter as _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
13
- export const version = "4.2.0";
13
+ export const version = "4.2.1";
14
14
  declare const LISTING_ID = "listingId";
15
15
  declare const EXTERNAL_ID = "externalId";
16
16
  type ScrollRestorationData = {
@@ -249,6 +249,7 @@ export function LooksSlider(props: {
249
249
  merchant_: string;
250
250
  market_: string;
251
251
  locale_: string;
252
+ imagePlaceholderAspectRatio_: number | string;
252
253
  title_?: JSX.Element;
253
254
  FavoriteButton_?: (props: {
254
255
  display_: ModernDisplay | null | undefined;