@depict-ai/ui 4.2.0 → 4.2.2

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.js CHANGED
@@ -7,7 +7,7 @@ import { createStore as $9HbP8$createStore, reconcile as $9HbP8$reconcile } from
7
7
  /*! Depict.ai search and product listing SDK */
8
8
  import { register_es_version } from "../multi_import_deduplicator.mjs";
9
9
  register_es_version("ui", "latest");
10
- const $ec291e0010116877$export$83d89fbfd8236492 = "4.2.0";
10
+ const $ec291e0010116877$export$83d89fbfd8236492 = "4.2.2";
11
11
  const $b5cccc8ee7d24677$var$transform_elements = sorted_cols_at_size => {
12
12
  const cols_at_size = [];
13
13
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -1223,15 +1223,18 @@ function $5a6c386e1bde5665$export$b73ed90f0ee50dc3({
1223
1223
  outerRef_: outerRef_,
1224
1224
  animationDuration_: animationDuration_
1225
1225
  }) {
1226
- const variantToUse = display_?.variant_displays[display_?.variant_index];
1227
- const imageUrls = variantToUse?.image_urls;
1228
- const imageUrl = imageUrls?.[0];
1229
- const secondaryImageUrl = imageUrls?.[1];
1226
+ const variantToUse = $9HbP8$createMemo(() => {
1227
+ const display = display_();
1228
+ return display?.variant_displays[display?.variant_index];
1229
+ });
1230
+ const imageUrls = () => variantToUse()?.image_urls;
1231
+ const imageUrl = $9HbP8$createMemo(() => imageUrls()?.[0]);
1232
+ const secondaryImageUrl = $9HbP8$createMemo(() => imageUrls()?.[1]);
1230
1233
  const [animationIsRunning, setAnimationIsRunning] = textFadeInAnimationRunning_;
1231
1234
  const [isExpandedThrottledByOurEffectRun, setIsExpandedThrottledByOurEffectRun] = $9HbP8$createSignal($9HbP8$untrack(isExpanded_));
1232
1235
  const [animationEffectExists, setAnimationEffectExists] = $9HbP8$createSignal(false);
1233
- const [salePrice] = $9HbP8$createResource(() => variantToUse?.sale_price);
1234
- const [originalPrice] = $9HbP8$createResource(() => variantToUse?.original_price);
1236
+ const [salePrice] = $9HbP8$createResource(() => variantToUse()?.sale_price);
1237
+ const [originalPrice] = $9HbP8$createResource(() => variantToUse()?.original_price);
1235
1238
  const isOnSale = $9HbP8$createMemo(() => salePrice.latest !== originalPrice.latest); // .latest doesn't trigger suspense
1236
1239
  const FavoriteButton = FavoriteButton_; // Just to get rid of the type error - TS doesn't understand <Show>
1237
1240
  return (() => {
@@ -1243,7 +1246,7 @@ function $5a6c386e1bde5665$export$b73ed90f0ee50dc3({
1243
1246
  var _ref$ = outerRef_;
1244
1247
  typeof _ref$ === "function" ? $9HbP8$use(_ref$, _el$) : outerRef_ = _el$;
1245
1248
  $9HbP8$spread(_el$, $9HbP8$mergeProps(() => isExpanded_() && !animationIsRunning() ? {
1246
- href: variantToUse?.page_url
1249
+ href: variantToUse()?.page_url
1247
1250
  } : {}), false, true);
1248
1251
  $9HbP8$insert(_el$, $9HbP8$createComponent((0, $9HbP8$Show), {
1249
1252
  when: imageUrl,
@@ -1258,20 +1261,38 @@ function $5a6c386e1bde5665$export$b73ed90f0ee50dc3({
1258
1261
  [_el$4, _co$] = $9HbP8$getNextMarker(_el$3.nextSibling),
1259
1262
  _el$5 = _el$4.nextSibling,
1260
1263
  [_el$6, _co$2] = $9HbP8$getNextMarker(_el$5.nextSibling);
1261
- $9HbP8$insert(_el$2, $9HbP8$createComponent((0, $70bb27cc6be01fc7$export$9d4a4b669b1929ab), {
1262
- src: imageUrl,
1263
- get aspectRatio() {
1264
- return isExpanded_() ? 0.75 : 1;
1264
+ $9HbP8$insert(_el$2, $9HbP8$createComponent((0, $9HbP8$Show), {
1265
+ get when() {
1266
+ return imageUrl();
1267
+ },
1268
+ get fallback() {
1269
+ return $9HbP8$createComponent((0, $7f60f09116a3fe61$export$3f37af283f8fb843), {
1270
+ aspectRatio: 1
1271
+ });
1265
1272
  },
1266
- get autoAdjustAspectRatio() {
1267
- return isExpanded_() ? "smoothed" : false;
1273
+ get children() {
1274
+ return $9HbP8$createComponent((0, $70bb27cc6be01fc7$export$9d4a4b669b1929ab), {
1275
+ get src() {
1276
+ return imageUrl();
1277
+ },
1278
+ get aspectRatio() {
1279
+ return isExpanded_() ? 0.75 : 1;
1280
+ },
1281
+ get autoAdjustAspectRatio() {
1282
+ return isExpanded_() ? "smoothed" : false;
1283
+ }
1284
+ });
1268
1285
  }
1269
1286
  }), _el$4, _co$);
1270
1287
  $9HbP8$insert(_el$2, $9HbP8$createComponent((0, $9HbP8$Show), {
1271
- when: secondaryImageUrl,
1288
+ get when() {
1289
+ return secondaryImageUrl();
1290
+ },
1272
1291
  get children() {
1273
1292
  return $9HbP8$createComponent((0, $70bb27cc6be01fc7$export$9d4a4b669b1929ab), {
1274
- src: secondaryImageUrl,
1293
+ get src() {
1294
+ return secondaryImageUrl();
1295
+ },
1275
1296
  get aspectRatio() {
1276
1297
  return isExpanded_() ? 0.75 : 1;
1277
1298
  },
@@ -1330,12 +1351,12 @@ function $5a6c386e1bde5665$export$b73ed90f0ee50dc3({
1330
1351
  disconnector();
1331
1352
  }));
1332
1353
  }, _el$7);
1333
- $9HbP8$insert(_el$9, () => variantToUse?.title ?? $9HbP8$createComponent((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
1354
+ $9HbP8$insert(_el$9, () => variantToUse()?.title ?? $9HbP8$createComponent((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
1334
1355
  height: "1em",
1335
1356
  width: "20ch"
1336
1357
  }));
1337
1358
  $9HbP8$insert(_el$10, (() => {
1338
- var _c$ = $9HbP8$memo(() => !!(!variantToUse || salePrice.loading));
1359
+ var _c$ = $9HbP8$memo(() => !!(!variantToUse() || salePrice.loading));
1339
1360
  return () => _c$() ? $9HbP8$createComponent((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
1340
1361
  height: "1em",
1341
1362
  width: "20ch"
@@ -1348,7 +1369,7 @@ function $5a6c386e1bde5665$export$b73ed90f0ee50dc3({
1348
1369
  get children() {
1349
1370
  var _el$11 = $9HbP8$getNextElement($5a6c386e1bde5665$var$_tmpl$2);
1350
1371
  $9HbP8$insert(_el$11, (() => {
1351
- var _c$2 = $9HbP8$memo(() => !!(!variantToUse || originalPrice.loading));
1372
+ var _c$2 = $9HbP8$memo(() => !!(!variantToUse() || originalPrice.loading));
1352
1373
  return () => _c$2() ? $9HbP8$createComponent((0, $d134eae24341b4a1$export$89c6019e4baa40b1), {
1353
1374
  height: "1em",
1354
1375
  width: "20ch"
@@ -1415,7 +1436,7 @@ async function $62a8f670f8464532$var$checkIfIsAffectedByChromeBug326498383() {
1415
1436
  // Passive to make it more likely to run the callback before our timeout if the browser is under high load during the test
1416
1437
  {
1417
1438
  once: true,
1418
- passive: true
1439
+ passive: false
1419
1440
  });
1420
1441
  await timeoutPromise;
1421
1442
  } catch (e) {
@@ -1439,19 +1460,16 @@ function $7555dcad3b8a4632$export$ebf0b1d4f90c09ae({
1439
1460
  // The following three signals just contain the state if the animations are actually running and should only be set by the respective animation code
1440
1461
  const textFadeInAnimationRunning = $9HbP8$createSignal(false);
1441
1462
  const [getSecondPartAnimationRunning] = textFadeInAnimationRunning;
1442
- // These expanded variables are what's used to trigger the second and first phase animations
1443
1463
  $62a8f670f8464532$export$7b9a0e99f0aeb2f3().then(is => isAffectedByChromeBug = is);
1444
1464
  return $9HbP8$createComponent((0, $011607bdf658f807$export$e68cff63f76bd15b), {
1445
1465
  get children() {
1446
1466
  return $9HbP8$createComponent((0, $9HbP8$Show), {
1447
1467
  get when() {
1448
- return containerWidth_();
1468
+ return containerWidth_() || !displays_;
1449
1469
  },
1450
1470
  get children() {
1451
1471
  var _el$ = $9HbP8$getNextElement($7555dcad3b8a4632$var$_tmpl$),
1452
1472
  _el$2 = _el$.firstChild;
1453
- $9HbP8$addEventListener(_el$2, "mouseleave", $9HbP8$catchify(() => supportsHover_() && setUserWantsExpanded(false)));
1454
- $9HbP8$addEventListener(_el$2, "mouseenter", $9HbP8$catchify(() => supportsHover_() && setUserWantsExpanded(true)));
1455
1473
  $9HbP8$use(el => $9HbP8$createEffect(() => {
1456
1474
  if (userWantsExpanded()) return;
1457
1475
  if (isAffectedByChromeBug) {
@@ -1463,35 +1481,45 @@ function $7555dcad3b8a4632$export$ebf0b1d4f90c09ae({
1463
1481
  behavior: "smooth"
1464
1482
  });
1465
1483
  }), _el$2);
1466
- $9HbP8$insert(_el$2, $9HbP8$createComponent((0, $9HbP8$For), {
1467
- each: displays_,
1468
- children: (display, index) => $9HbP8$createComponent((0, $5a6c386e1bde5665$export$b73ed90f0ee50dc3), {
1469
- animationDuration_: animationDuration_,
1470
- display_: display,
1471
- FavoriteButton_: FavoriteButton_,
1472
- isExpanded_: userWantsExpanded,
1473
- textFadeInAnimationRunning_: textFadeInAnimationRunning,
1474
- outerRef_: el => $9HbP8$createEffect(() => {
1475
- if (index() !== 0) return;
1476
- const resizeObserver = new ResizeObserver($9HbP8$catchify(records => setLookItemHeight(records.at(-1).contentRect.height)));
1477
- resizeObserver.observe(el);
1478
- $9HbP8$onCleanup(() => resizeObserver.disconnect());
1479
- })
1480
- })
1484
+ $9HbP8$spread(_el$2, $9HbP8$mergeProps({
1485
+ get classList() {
1486
+ return {
1487
+ expanded: userWantsExpanded(),
1488
+ "resting-fully-expanded": !getSecondPartAnimationRunning() && userWantsExpanded()
1489
+ };
1490
+ },
1491
+ get onMouseEnter() {
1492
+ return $9HbP8$catchify(() => supportsHover_() && setUserWantsExpanded(true));
1493
+ },
1494
+ get onMouseLeave() {
1495
+ return $9HbP8$catchify(() => supportsHover_() && setUserWantsExpanded(false));
1496
+ }
1497
+ }, () => displays_ && {
1498
+ style: `--look-card-width:${containerWidth_()}px;--look-item-height:${lookItemHeight() || 200}px`
1499
+ }), false, true);
1500
+ $9HbP8$insert(_el$2, $9HbP8$createComponent((0, $9HbP8$Index), {
1501
+ get each() {
1502
+ return displays_ || Array.from({
1503
+ length: 4
1504
+ });
1505
+ },
1506
+ children: (display, index) => {
1507
+ return $9HbP8$createComponent((0, $5a6c386e1bde5665$export$b73ed90f0ee50dc3), {
1508
+ animationDuration_: animationDuration_,
1509
+ display_: display,
1510
+ FavoriteButton_: FavoriteButton_,
1511
+ isExpanded_: userWantsExpanded,
1512
+ textFadeInAnimationRunning_: textFadeInAnimationRunning,
1513
+ outerRef_: el => $9HbP8$createEffect(() => {
1514
+ if (index !== 0) return;
1515
+ const resizeObserver = new ResizeObserver($9HbP8$catchify(records => setLookItemHeight(records.at(-1).contentRect.height)));
1516
+ resizeObserver.observe(el);
1517
+ $9HbP8$onCleanup(() => resizeObserver.disconnect());
1518
+ })
1519
+ });
1520
+ }
1481
1521
  }));
1482
- $9HbP8$effect(_p$ => {
1483
- var _v$ = `--look-card-width:${containerWidth_()}px;--look-item-height:${lookItemHeight() || 200}px`,
1484
- _v$2 = !!userWantsExpanded(),
1485
- _v$3 = !!(!getSecondPartAnimationRunning() && userWantsExpanded());
1486
- _p$.e = $9HbP8$style(_el$2, _v$, _p$.e);
1487
- _v$2 !== _p$.t && _el$2.classList.toggle("expanded", _p$.t = _v$2);
1488
- _v$3 !== _p$.a && _el$2.classList.toggle("resting-fully-expanded", _p$.a = _v$3);
1489
- return _p$;
1490
- }, {
1491
- e: undefined,
1492
- t: undefined,
1493
- a: undefined
1494
- });
1522
+ $9HbP8$runHydrationEvents();
1495
1523
  return _el$;
1496
1524
  }
1497
1525
  });
@@ -1518,20 +1546,25 @@ function $7555dcad3b8a4632$var$scrollingFunctionForChrome(element, targetScrollY
1518
1546
  // Bootstrap our animation - it will get called right before next frame shall be rendered.
1519
1547
  requestAnimationFrame(step);
1520
1548
  }
1521
- var $28ee4f7db3cc44b8$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<div class=look-card style=--animation-duration:300ms>`);
1522
- function $28ee4f7db3cc44b8$export$44809a8a3e867e30(display, info, FavoriteButton_) {
1549
+ var $28ee4f7db3cc44b8$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<div class=look-card>`);
1550
+ function $28ee4f7db3cc44b8$export$44809a8a3e867e30({
1551
+ display_: display_,
1552
+ expandedLooksSignal_: [expandedLooks_, setExpandedLooks],
1553
+ FavoriteButton_: FavoriteButton_,
1554
+ placeholderImageAspectRatio_: placeholderImageAspectRatio_,
1555
+ animationDuration_: animationDuration_
1556
+ }) {
1523
1557
  // TODO: shopify, run displayTransformers to get dynamic prices
1524
1558
  // TODO: format prices
1525
- const animationDuration_ = 300;
1526
- const [coverImage] = display?.image_urls || [];
1559
+ const [coverImage] = display_?.image_urls || [];
1527
1560
  const useWantsExpandedSignal_ = $9HbP8$createSignal(false);
1528
1561
  const [userWantsExpanded, setUserWantsExpanded] = useWantsExpandedSignal_;
1529
- const [expandedLooks_, setExpandedLooks] = info?.expandedLooksSignal_ || [];
1530
1562
  const supportsHover_ = $dc9262ef6f786812$export$d9f36cf74e24d595("(hover: hover) and (pointer: fine)");
1531
1563
  const us = Symbol("look");
1532
1564
  const container = (() => {
1533
1565
  var _el$ = $9HbP8$getNextElement($28ee4f7db3cc44b8$var$_tmpl$);
1534
1566
  $9HbP8$addEventListener(_el$, "click", $9HbP8$catchify(() => setUserWantsExpanded(prev => !prev)), true);
1567
+ _el$.classList.toggle("placeholder", !!!display_);
1535
1568
  $9HbP8$runHydrationEvents();
1536
1569
  return _el$;
1537
1570
  })();
@@ -1545,7 +1578,7 @@ function $28ee4f7db3cc44b8$export$44809a8a3e867e30(display, info, FavoriteButton
1545
1578
  });
1546
1579
  addEventListener("click", clickHandler);
1547
1580
  $9HbP8$onCleanup(() => removeEventListener("click", clickHandler));
1548
- $9HbP8$createEffect(() => setExpandedLooks?.(prev => {
1581
+ $9HbP8$createEffect(() => setExpandedLooks(prev => {
1549
1582
  if (userWantsExpanded()) {
1550
1583
  // Close the other expanded looks
1551
1584
  prev.clear();
@@ -1555,42 +1588,42 @@ function $28ee4f7db3cc44b8$export$44809a8a3e867e30(display, info, FavoriteButton
1555
1588
  return prev;
1556
1589
  }));
1557
1590
  // Close us if another look expands
1558
- $9HbP8$createEffect(() => expandedLooks_ && !expandedLooks_().has(us) && setUserWantsExpanded(false));
1559
- $9HbP8$insert(container, () => $9HbP8$createComponent((0, $9HbP8$Show), {
1560
- when: display,
1591
+ $9HbP8$createEffect(() => !expandedLooks_().has(us) && setUserWantsExpanded(false));
1592
+ $9HbP8$insert(container, () => [$9HbP8$createComponent((0, $9HbP8$Show), {
1593
+ when: display_,
1561
1594
  get fallback() {
1562
1595
  return $9HbP8$createComponent((0, $7f60f09116a3fe61$export$3f37af283f8fb843), {
1563
- width: "100%",
1564
- height: "100%"
1596
+ aspectRatio: placeholderImageAspectRatio_
1565
1597
  });
1566
1598
  },
1567
1599
  get children() {
1568
- return [$9HbP8$createComponent((0, $70bb27cc6be01fc7$export$9d4a4b669b1929ab), {
1600
+ return $9HbP8$createComponent((0, $70bb27cc6be01fc7$export$9d4a4b669b1929ab), {
1569
1601
  src: coverImage,
1570
- aspectRatio: 0.75,
1602
+ aspectRatio: placeholderImageAspectRatio_,
1571
1603
  autoAdjustAspectRatio: true
1572
- }), $9HbP8$createComponent((0, $7555dcad3b8a4632$export$ebf0b1d4f90c09ae), {
1573
- get displays_() {
1574
- return display?.displays;
1575
- },
1576
- userWantsExpandedSignal_: useWantsExpandedSignal_,
1577
- containerWidth_: containerWidth_,
1578
- animationDuration_: animationDuration_,
1579
- supportsHover_: supportsHover_,
1580
- FavoriteButton_: FavoriteButton_
1581
- })];
1604
+ });
1582
1605
  }
1583
- }));
1606
+ }), $9HbP8$createComponent((0, $7555dcad3b8a4632$export$ebf0b1d4f90c09ae), {
1607
+ get displays_() {
1608
+ return display_?.displays;
1609
+ },
1610
+ userWantsExpandedSignal_: useWantsExpandedSignal_,
1611
+ containerWidth_: containerWidth_,
1612
+ animationDuration_: animationDuration_,
1613
+ supportsHover_: supportsHover_,
1614
+ FavoriteButton_: FavoriteButton_
1615
+ })]);
1584
1616
  return container;
1585
1617
  }
1586
1618
  $9HbP8$delegateEvents(["click"]);
1587
- var $f577edfe2240eec1$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<div class="depict recommendations looks">`);
1619
+ var $f577edfe2240eec1$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<div class="depict recommendations looks"style=--animation-duration:240ms>`);
1588
1620
  let $f577edfe2240eec1$var$expandedLooksSignal_;
1589
1621
  function $f577edfe2240eec1$export$1935e6bdfc5ed8ce(props) {
1590
1622
  return $16b52438165aafe2$export$23fca46f3143581f(() => {
1591
1623
  $f577edfe2240eec1$var$expandedLooksSignal_ ||= $9HbP8$createSignal(new Set(), {
1592
1624
  equals: false
1593
1625
  });
1626
+ const expandingAnimationDuration = 240;
1594
1627
  const grid_spacing_override = $9HbP8$createMemo(() => {
1595
1628
  const {
1596
1629
  gridSpacing_: gridSpacing_
@@ -1625,10 +1658,13 @@ function $f577edfe2240eec1$export$1935e6bdfc5ed8ce(props) {
1625
1658
  $9HbP8$insert(_el$, $9HbP8$createComponent((0, $011607bdf658f807$export$e68cff63f76bd15b), {
1626
1659
  get children() {
1627
1660
  return $c4492d24952ed731$export$d41d19e89346fa2({
1628
- product_card_template_: (display, info) => $28ee4f7db3cc44b8$export$44809a8a3e867e30(display, info ? {
1629
- ...info,
1661
+ product_card_template_: (display, info) => $28ee4f7db3cc44b8$export$44809a8a3e867e30({
1662
+ display_: display,
1663
+ FavoriteButton_: props.FavoriteButton_,
1664
+ placeholderImageAspectRatio_: props.imagePlaceholderAspectRatio_,
1665
+ animationDuration_: expandingAnimationDuration,
1630
1666
  expandedLooksSignal_: $f577edfe2240eec1$var$expandedLooksSignal_
1631
- } : info, props.FavoriteButton_),
1667
+ }),
1632
1668
  recommendations_resource_: looksResource,
1633
1669
  title_: () => props.title_,
1634
1670
  layout_options_: $9HbP8$createMemo(() => ({
@@ -3142,10 +3178,6 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
3142
3178
  $9HbP8$delegateEvents(["click", "keydown", "input", "pointerdown"]);
3143
3179
  function $aea1edf92433e81e$export$fe334901e8bebd57() {
3144
3180
  const cleanup_fns = [];
3145
- $9HbP8$dlog("DISABLING SCROLLING");
3146
- $9HbP8$onCleanup(() => {
3147
- console.log("RE-ENABLING SCROLLING");
3148
- });
3149
3181
  const cleanup = () => cleanup_fns.forEach(f => f());
3150
3182
  // use an animation to automatically retain the `overflow` values and all other styling
3151
3183
  for (const element of [document.documentElement, document.body]) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "4.2.0",
3
+ "version": "4.2.2",
4
4
  "description": "Base package containing the actual UI of Depict UI along with translations, with a not-simplified API. We recommend using @depict-ai/js-ui or @depict-ai/react-ui instead.",
5
5
  "packageManager": "yarn@3.2.2",
6
6
  "sass": "styles.scss",
@@ -236,9 +236,9 @@
236
236
  "@babel/plugin-transform-typescript": "^7.22.9",
237
237
  "@babel/runtime": "latest",
238
238
  "@babel/runtime-corejs3": "^7.22.6",
239
- "@depict-ai/plp-styling": "^3.1.0",
240
- "@depict-ai/types": "^5.1.0",
241
- "@depict-ai/utilishared": "^2.1.0",
239
+ "@depict-ai/plp-styling": "^3.1.1",
240
+ "@depict-ai/types": "^5.1.1",
241
+ "@depict-ai/utilishared": "^2.1.1",
242
242
  "solid-js": "^1.8.12"
243
243
  },
244
244
  "type": "module",