@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/ES10/index.js CHANGED
@@ -10,7 +10,7 @@ import { createStore as $8tj43$createStore, reconcile as $8tj43$reconcile } from
10
10
  /*! Depict.ai search and product listing SDK */
11
11
  import { register_es_version } from "../multi_import_deduplicator.mjs";
12
12
  register_es_version("ui", "ES10");
13
- const $8db9a15135765c11$export$83d89fbfd8236492 = "4.2.0";
13
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "4.2.1";
14
14
  const $a9c7ba6087881ac2$var$transform_elements = sorted_cols_at_size => {
15
15
  const cols_at_size = [];
16
16
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -1286,15 +1286,33 @@ function $0c5b1686f971e5e7$export$b73ed90f0ee50dc3(_ref) {
1286
1286
  outerRef_: outerRef_,
1287
1287
  animationDuration_: animationDuration_
1288
1288
  } = _ref;
1289
- const variantToUse = display_ === null || display_ === void 0 ? void 0 : display_.variant_displays[display_ === null || display_ === void 0 ? void 0 : display_.variant_index];
1290
- const imageUrls = variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.image_urls;
1291
- const imageUrl = imageUrls === null || imageUrls === void 0 ? void 0 : imageUrls[0];
1292
- const secondaryImageUrl = imageUrls === null || imageUrls === void 0 ? void 0 : imageUrls[1];
1289
+ const variantToUse = $8tj43$createMemo(() => {
1290
+ const display = display_();
1291
+ return display === null || display === void 0 ? void 0 : display.variant_displays[display === null || display === void 0 ? void 0 : display.variant_index];
1292
+ });
1293
+ const imageUrls = () => {
1294
+ var _variantToUse;
1295
+ return (_variantToUse = variantToUse()) === null || _variantToUse === void 0 ? void 0 : _variantToUse.image_urls;
1296
+ };
1297
+ const imageUrl = $8tj43$createMemo(() => {
1298
+ var _imageUrls;
1299
+ return (_imageUrls = imageUrls()) === null || _imageUrls === void 0 ? void 0 : _imageUrls[0];
1300
+ });
1301
+ const secondaryImageUrl = $8tj43$createMemo(() => {
1302
+ var _imageUrls2;
1303
+ return (_imageUrls2 = imageUrls()) === null || _imageUrls2 === void 0 ? void 0 : _imageUrls2[1];
1304
+ });
1293
1305
  const [animationIsRunning, setAnimationIsRunning] = textFadeInAnimationRunning_;
1294
1306
  const [isExpandedThrottledByOurEffectRun, setIsExpandedThrottledByOurEffectRun] = $8tj43$createSignal($8tj43$untrack(isExpanded_));
1295
1307
  const [animationEffectExists, setAnimationEffectExists] = $8tj43$createSignal(false);
1296
- const [salePrice] = $8tj43$createResource(() => variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.sale_price);
1297
- const [originalPrice] = $8tj43$createResource(() => variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.original_price);
1308
+ const [salePrice] = $8tj43$createResource(() => {
1309
+ var _variantToUse2;
1310
+ return (_variantToUse2 = variantToUse()) === null || _variantToUse2 === void 0 ? void 0 : _variantToUse2.sale_price;
1311
+ });
1312
+ const [originalPrice] = $8tj43$createResource(() => {
1313
+ var _variantToUse3;
1314
+ return (_variantToUse3 = variantToUse()) === null || _variantToUse3 === void 0 ? void 0 : _variantToUse3.original_price;
1315
+ });
1298
1316
  const isOnSale = $8tj43$createMemo(() => salePrice.latest !== originalPrice.latest); // .latest doesn't trigger suspense
1299
1317
  const FavoriteButton = FavoriteButton_; // Just to get rid of the type error - TS doesn't understand <Show>
1300
1318
  return (() => {
@@ -1305,9 +1323,12 @@ function $0c5b1686f971e5e7$export$b73ed90f0ee50dc3(_ref) {
1305
1323
  [_el$19, _co$6] = $8tj43$getNextMarker(_el$18.nextSibling);
1306
1324
  var _ref$ = outerRef_;
1307
1325
  typeof _ref$ === "function" ? $8tj43$use(_ref$, _el$) : outerRef_ = _el$;
1308
- $8tj43$spread(_el$, $8tj43$mergeProps(() => isExpanded_() && !animationIsRunning() ? {
1309
- href: variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.page_url
1310
- } : {}), false, true);
1326
+ $8tj43$spread(_el$, $8tj43$mergeProps(() => {
1327
+ var _variantToUse4;
1328
+ return isExpanded_() && !animationIsRunning() ? {
1329
+ href: (_variantToUse4 = variantToUse()) === null || _variantToUse4 === void 0 ? void 0 : _variantToUse4.page_url
1330
+ } : {};
1331
+ }), false, true);
1311
1332
  $8tj43$insert(_el$, $8tj43$createComponent((0, $8tj43$Show), {
1312
1333
  when: imageUrl,
1313
1334
  get fallback() {
@@ -1321,20 +1342,38 @@ function $0c5b1686f971e5e7$export$b73ed90f0ee50dc3(_ref) {
1321
1342
  [_el$4, _co$] = $8tj43$getNextMarker(_el$3.nextSibling),
1322
1343
  _el$5 = _el$4.nextSibling,
1323
1344
  [_el$6, _co$2] = $8tj43$getNextMarker(_el$5.nextSibling);
1324
- $8tj43$insert(_el$2, $8tj43$createComponent((0, $98688279b9059f50$export$9d4a4b669b1929ab), {
1325
- src: imageUrl,
1326
- get aspectRatio() {
1327
- return isExpanded_() ? 0.75 : 1;
1345
+ $8tj43$insert(_el$2, $8tj43$createComponent((0, $8tj43$Show), {
1346
+ get when() {
1347
+ return imageUrl();
1328
1348
  },
1329
- get autoAdjustAspectRatio() {
1330
- return isExpanded_() ? "smoothed" : false;
1349
+ get fallback() {
1350
+ return $8tj43$createComponent((0, $3ab4aa97880fb88d$export$3f37af283f8fb843), {
1351
+ aspectRatio: 1
1352
+ });
1353
+ },
1354
+ get children() {
1355
+ return $8tj43$createComponent((0, $98688279b9059f50$export$9d4a4b669b1929ab), {
1356
+ get src() {
1357
+ return imageUrl();
1358
+ },
1359
+ get aspectRatio() {
1360
+ return isExpanded_() ? 0.75 : 1;
1361
+ },
1362
+ get autoAdjustAspectRatio() {
1363
+ return isExpanded_() ? "smoothed" : false;
1364
+ }
1365
+ });
1331
1366
  }
1332
1367
  }), _el$4, _co$);
1333
1368
  $8tj43$insert(_el$2, $8tj43$createComponent((0, $8tj43$Show), {
1334
- when: secondaryImageUrl,
1369
+ get when() {
1370
+ return secondaryImageUrl();
1371
+ },
1335
1372
  get children() {
1336
1373
  return $8tj43$createComponent((0, $98688279b9059f50$export$9d4a4b669b1929ab), {
1337
- src: secondaryImageUrl,
1374
+ get src() {
1375
+ return secondaryImageUrl();
1376
+ },
1338
1377
  get aspectRatio() {
1339
1378
  return isExpanded_() ? 0.75 : 1;
1340
1379
  },
@@ -1395,14 +1434,14 @@ function $0c5b1686f971e5e7$export$b73ed90f0ee50dc3(_ref) {
1395
1434
  }));
1396
1435
  }, _el$7);
1397
1436
  $8tj43$insert(_el$9, () => {
1398
- var _variantToUse$title;
1399
- return (_variantToUse$title = variantToUse === null || variantToUse === void 0 ? void 0 : variantToUse.title) !== null && _variantToUse$title !== void 0 ? _variantToUse$title : $8tj43$createComponent((0, $ceafb6fb91c6f394$export$89c6019e4baa40b1), {
1437
+ var _variantToUse$title, _variantToUse5;
1438
+ return (_variantToUse$title = (_variantToUse5 = variantToUse()) === null || _variantToUse5 === void 0 ? void 0 : _variantToUse5.title) !== null && _variantToUse$title !== void 0 ? _variantToUse$title : $8tj43$createComponent((0, $ceafb6fb91c6f394$export$89c6019e4baa40b1), {
1400
1439
  height: "1em",
1401
1440
  width: "20ch"
1402
1441
  });
1403
1442
  });
1404
1443
  $8tj43$insert(_el$10, (() => {
1405
- var _c$ = $8tj43$memo(() => !!(!variantToUse || salePrice.loading));
1444
+ var _c$ = $8tj43$memo(() => !!(!variantToUse() || salePrice.loading));
1406
1445
  return () => _c$() ? $8tj43$createComponent((0, $ceafb6fb91c6f394$export$89c6019e4baa40b1), {
1407
1446
  height: "1em",
1408
1447
  width: "20ch"
@@ -1415,7 +1454,7 @@ function $0c5b1686f971e5e7$export$b73ed90f0ee50dc3(_ref) {
1415
1454
  get children() {
1416
1455
  var _el$11 = $8tj43$getNextElement($0c5b1686f971e5e7$var$_tmpl$2);
1417
1456
  $8tj43$insert(_el$11, (() => {
1418
- var _c$2 = $8tj43$memo(() => !!(!variantToUse || originalPrice.loading));
1457
+ var _c$2 = $8tj43$memo(() => !!(!variantToUse() || originalPrice.loading));
1419
1458
  return () => _c$2() ? $8tj43$createComponent((0, $ceafb6fb91c6f394$export$89c6019e4baa40b1), {
1420
1459
  height: "1em",
1421
1460
  width: "20ch"
@@ -1482,7 +1521,7 @@ async function $72017ebd8b9df947$var$checkIfIsAffectedByChromeBug326498383() {
1482
1521
  // Passive to make it more likely to run the callback before our timeout if the browser is under high load during the test
1483
1522
  {
1484
1523
  once: true,
1485
- passive: true
1524
+ passive: false
1486
1525
  });
1487
1526
  await timeoutPromise;
1488
1527
  } catch (e) {
@@ -1507,19 +1546,16 @@ function $4089a7972a508539$export$ebf0b1d4f90c09ae(_ref) {
1507
1546
  // The following three signals just contain the state if the animations are actually running and should only be set by the respective animation code
1508
1547
  const textFadeInAnimationRunning = $8tj43$createSignal(false);
1509
1548
  const [getSecondPartAnimationRunning] = textFadeInAnimationRunning;
1510
- // These expanded variables are what's used to trigger the second and first phase animations
1511
1549
  $72017ebd8b9df947$export$7b9a0e99f0aeb2f3().then(is => isAffectedByChromeBug = is);
1512
1550
  return $8tj43$createComponent((0, $5441862cd2f5e111$export$e68cff63f76bd15b), {
1513
1551
  get children() {
1514
1552
  return $8tj43$createComponent((0, $8tj43$Show), {
1515
1553
  get when() {
1516
- return containerWidth_();
1554
+ return containerWidth_() || !displays_;
1517
1555
  },
1518
1556
  get children() {
1519
1557
  var _el$ = $8tj43$getNextElement($4089a7972a508539$var$_tmpl$),
1520
1558
  _el$2 = _el$.firstChild;
1521
- $8tj43$addEventListener(_el$2, "mouseleave", $8tj43$catchify(() => supportsHover_() && setUserWantsExpanded(false)));
1522
- $8tj43$addEventListener(_el$2, "mouseenter", $8tj43$catchify(() => supportsHover_() && setUserWantsExpanded(true)));
1523
1559
  $8tj43$use(el => $8tj43$createEffect(() => {
1524
1560
  if (userWantsExpanded()) return;
1525
1561
  if (isAffectedByChromeBug) {
@@ -1531,35 +1567,45 @@ function $4089a7972a508539$export$ebf0b1d4f90c09ae(_ref) {
1531
1567
  behavior: "smooth"
1532
1568
  });
1533
1569
  }), _el$2);
1534
- $8tj43$insert(_el$2, $8tj43$createComponent((0, $8tj43$For), {
1535
- each: displays_,
1536
- children: (display, index) => $8tj43$createComponent((0, $0c5b1686f971e5e7$export$b73ed90f0ee50dc3), {
1537
- animationDuration_: animationDuration_,
1538
- display_: display,
1539
- FavoriteButton_: FavoriteButton_,
1540
- isExpanded_: userWantsExpanded,
1541
- textFadeInAnimationRunning_: textFadeInAnimationRunning,
1542
- outerRef_: el => $8tj43$createEffect(() => {
1543
- if (index() !== 0) return;
1544
- const resizeObserver = new ResizeObserver($8tj43$catchify(records => setLookItemHeight(records.at(-1).contentRect.height)));
1545
- resizeObserver.observe(el);
1546
- $8tj43$onCleanup(() => resizeObserver.disconnect());
1547
- })
1548
- })
1570
+ $8tj43$spread(_el$2, $8tj43$mergeProps({
1571
+ get classList() {
1572
+ return {
1573
+ expanded: userWantsExpanded(),
1574
+ "resting-fully-expanded": !getSecondPartAnimationRunning() && userWantsExpanded()
1575
+ };
1576
+ },
1577
+ get onMouseEnter() {
1578
+ return $8tj43$catchify(() => supportsHover_() && setUserWantsExpanded(true));
1579
+ },
1580
+ get onMouseLeave() {
1581
+ return $8tj43$catchify(() => supportsHover_() && setUserWantsExpanded(false));
1582
+ }
1583
+ }, () => displays_ && {
1584
+ style: "--look-card-width:".concat(containerWidth_(), "px;--look-item-height:").concat(lookItemHeight() || 200, "px")
1585
+ }), false, true);
1586
+ $8tj43$insert(_el$2, $8tj43$createComponent((0, $8tj43$Index), {
1587
+ get each() {
1588
+ return displays_ || Array.from({
1589
+ length: 4
1590
+ });
1591
+ },
1592
+ children: (display, index) => {
1593
+ return $8tj43$createComponent((0, $0c5b1686f971e5e7$export$b73ed90f0ee50dc3), {
1594
+ animationDuration_: animationDuration_,
1595
+ display_: display,
1596
+ FavoriteButton_: FavoriteButton_,
1597
+ isExpanded_: userWantsExpanded,
1598
+ textFadeInAnimationRunning_: textFadeInAnimationRunning,
1599
+ outerRef_: el => $8tj43$createEffect(() => {
1600
+ if (index !== 0) return;
1601
+ const resizeObserver = new ResizeObserver($8tj43$catchify(records => setLookItemHeight(records.at(-1).contentRect.height)));
1602
+ resizeObserver.observe(el);
1603
+ $8tj43$onCleanup(() => resizeObserver.disconnect());
1604
+ })
1605
+ });
1606
+ }
1549
1607
  }));
1550
- $8tj43$effect(_p$ => {
1551
- var _v$ = "--look-card-width:".concat(containerWidth_(), "px;--look-item-height:").concat(lookItemHeight() || 200, "px"),
1552
- _v$2 = !!userWantsExpanded(),
1553
- _v$3 = !!(!getSecondPartAnimationRunning() && userWantsExpanded());
1554
- _p$.e = $8tj43$style(_el$2, _v$, _p$.e);
1555
- _v$2 !== _p$.t && _el$2.classList.toggle("expanded", _p$.t = _v$2);
1556
- _v$3 !== _p$.a && _el$2.classList.toggle("resting-fully-expanded", _p$.a = _v$3);
1557
- return _p$;
1558
- }, {
1559
- e: undefined,
1560
- t: undefined,
1561
- a: undefined
1562
- });
1608
+ $8tj43$runHydrationEvents();
1563
1609
  return _el$;
1564
1610
  }
1565
1611
  });
@@ -1586,35 +1632,41 @@ function $4089a7972a508539$var$scrollingFunctionForChrome(element, targetScrollY
1586
1632
  // Bootstrap our animation - it will get called right before next frame shall be rendered.
1587
1633
  requestAnimationFrame(step);
1588
1634
  }
1589
- var $697d8713dc82b9ab$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<div class=look-card style=--animation-duration:300ms>`);
1590
- function $697d8713dc82b9ab$export$44809a8a3e867e30(display, info, FavoriteButton_) {
1635
+ var $697d8713dc82b9ab$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<div class=look-card>`);
1636
+ function $697d8713dc82b9ab$export$44809a8a3e867e30(_ref) {
1637
+ let {
1638
+ display_: display_,
1639
+ expandedLooksSignal_: [expandedLooks_, setExpandedLooks],
1640
+ FavoriteButton_: FavoriteButton_,
1641
+ placeholderImageAspectRatio_: placeholderImageAspectRatio_,
1642
+ animationDuration_: animationDuration_
1643
+ } = _ref;
1591
1644
  // TODO: shopify, run displayTransformers to get dynamic prices
1592
1645
  // TODO: format prices
1593
- const animationDuration_ = 300;
1594
- const [coverImage] = (display === null || display === void 0 ? void 0 : display.image_urls) || [];
1646
+ const [coverImage] = (display_ === null || display_ === void 0 ? void 0 : display_.image_urls) || [];
1595
1647
  const useWantsExpandedSignal_ = $8tj43$createSignal(false);
1596
1648
  const [userWantsExpanded, setUserWantsExpanded] = useWantsExpandedSignal_;
1597
- const [expandedLooks_, setExpandedLooks] = (info === null || info === void 0 ? void 0 : info.expandedLooksSignal_) || [];
1598
1649
  const supportsHover_ = $00a5b94f0c11efbb$export$d9f36cf74e24d595("(hover: hover) and (pointer: fine)");
1599
1650
  const us = Symbol("look");
1600
1651
  const container = (() => {
1601
1652
  var _el$ = $8tj43$getNextElement($697d8713dc82b9ab$var$_tmpl$);
1602
1653
  $8tj43$addEventListener(_el$, "click", $8tj43$catchify(() => setUserWantsExpanded(prev => !prev)), true);
1654
+ _el$.classList.toggle("placeholder", !!!display_);
1603
1655
  $8tj43$runHydrationEvents();
1604
1656
  return _el$;
1605
1657
  })();
1606
1658
  const containerWidth_ = $fc830a7ee59416ef$export$ebdc3711f7e02ccd(container);
1607
- const clickHandler = $8tj43$catchify(_ref => {
1659
+ const clickHandler = $8tj43$catchify(_ref2 => {
1608
1660
  let {
1609
1661
  target: target
1610
- } = _ref;
1662
+ } = _ref2;
1611
1663
  if (target !== container && !container.contains(target))
1612
1664
  // When clicking outside the look, close it
1613
1665
  setUserWantsExpanded(false);
1614
1666
  });
1615
1667
  addEventListener("click", clickHandler);
1616
1668
  $8tj43$onCleanup(() => removeEventListener("click", clickHandler));
1617
- $8tj43$createEffect(() => setExpandedLooks === null || setExpandedLooks === void 0 ? void 0 : setExpandedLooks(prev => {
1669
+ $8tj43$createEffect(() => setExpandedLooks(prev => {
1618
1670
  if (userWantsExpanded()) {
1619
1671
  // Close the other expanded looks
1620
1672
  prev.clear();
@@ -1624,42 +1676,42 @@ function $697d8713dc82b9ab$export$44809a8a3e867e30(display, info, FavoriteButton
1624
1676
  return prev;
1625
1677
  }));
1626
1678
  // Close us if another look expands
1627
- $8tj43$createEffect(() => expandedLooks_ && !expandedLooks_().has(us) && setUserWantsExpanded(false));
1628
- $8tj43$insert(container, () => $8tj43$createComponent((0, $8tj43$Show), {
1629
- when: display,
1679
+ $8tj43$createEffect(() => !expandedLooks_().has(us) && setUserWantsExpanded(false));
1680
+ $8tj43$insert(container, () => [$8tj43$createComponent((0, $8tj43$Show), {
1681
+ when: display_,
1630
1682
  get fallback() {
1631
1683
  return $8tj43$createComponent((0, $3ab4aa97880fb88d$export$3f37af283f8fb843), {
1632
- width: "100%",
1633
- height: "100%"
1684
+ aspectRatio: placeholderImageAspectRatio_
1634
1685
  });
1635
1686
  },
1636
1687
  get children() {
1637
- return [$8tj43$createComponent((0, $98688279b9059f50$export$9d4a4b669b1929ab), {
1688
+ return $8tj43$createComponent((0, $98688279b9059f50$export$9d4a4b669b1929ab), {
1638
1689
  src: coverImage,
1639
- aspectRatio: 0.75,
1690
+ aspectRatio: placeholderImageAspectRatio_,
1640
1691
  autoAdjustAspectRatio: true
1641
- }), $8tj43$createComponent((0, $4089a7972a508539$export$ebf0b1d4f90c09ae), {
1642
- get displays_() {
1643
- return display === null || display === void 0 ? void 0 : display.displays;
1644
- },
1645
- userWantsExpandedSignal_: useWantsExpandedSignal_,
1646
- containerWidth_: containerWidth_,
1647
- animationDuration_: animationDuration_,
1648
- supportsHover_: supportsHover_,
1649
- FavoriteButton_: FavoriteButton_
1650
- })];
1692
+ });
1651
1693
  }
1652
- }));
1694
+ }), $8tj43$createComponent((0, $4089a7972a508539$export$ebf0b1d4f90c09ae), {
1695
+ get displays_() {
1696
+ return display_ === null || display_ === void 0 ? void 0 : display_.displays;
1697
+ },
1698
+ userWantsExpandedSignal_: useWantsExpandedSignal_,
1699
+ containerWidth_: containerWidth_,
1700
+ animationDuration_: animationDuration_,
1701
+ supportsHover_: supportsHover_,
1702
+ FavoriteButton_: FavoriteButton_
1703
+ })]);
1653
1704
  return container;
1654
1705
  }
1655
1706
  $8tj43$delegateEvents(["click"]);
1656
- var $cee56a95f722f55f$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<div class="depict recommendations looks">`);
1707
+ var $cee56a95f722f55f$var$_tmpl$ = /*#__PURE__*/$8tj43$template(`<div class="depict recommendations looks"style=--animation-duration:240ms>`);
1657
1708
  let $cee56a95f722f55f$var$expandedLooksSignal_;
1658
1709
  function $cee56a95f722f55f$export$1935e6bdfc5ed8ce(props) {
1659
1710
  return $83e8cf2c0b87a58a$export$23fca46f3143581f(() => {
1660
1711
  $cee56a95f722f55f$var$expandedLooksSignal_ || ($cee56a95f722f55f$var$expandedLooksSignal_ = $8tj43$createSignal(new Set(), {
1661
1712
  equals: false
1662
1713
  }));
1714
+ const expandingAnimationDuration = 240;
1663
1715
  const grid_spacing_override = $8tj43$createMemo(() => {
1664
1716
  const {
1665
1717
  gridSpacing_: gridSpacing_
@@ -1696,10 +1748,13 @@ function $cee56a95f722f55f$export$1935e6bdfc5ed8ce(props) {
1696
1748
  $8tj43$insert(_el$, $8tj43$createComponent((0, $5441862cd2f5e111$export$e68cff63f76bd15b), {
1697
1749
  get children() {
1698
1750
  return $39ddb986053fb759$export$d41d19e89346fa2({
1699
- product_card_template_: (display, info) => $697d8713dc82b9ab$export$44809a8a3e867e30(display, info ? {
1700
- ...info,
1751
+ product_card_template_: (display, info) => $697d8713dc82b9ab$export$44809a8a3e867e30({
1752
+ display_: display,
1753
+ FavoriteButton_: props.FavoriteButton_,
1754
+ placeholderImageAspectRatio_: props.imagePlaceholderAspectRatio_,
1755
+ animationDuration_: expandingAnimationDuration,
1701
1756
  expandedLooksSignal_: $cee56a95f722f55f$var$expandedLooksSignal_
1702
- } : info, props.FavoriteButton_),
1757
+ }),
1703
1758
  recommendations_resource_: looksResource,
1704
1759
  title_: () => props.title_,
1705
1760
  layout_options_: $8tj43$createMemo(() => ({