@depict-ai/portal-components 2.7.32 → 2.7.34

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/dist/index.d.ts CHANGED
@@ -4,7 +4,7 @@ import { SearchFilter } from "@depict-ai/types/api/SearchResponse";
4
4
  import { Locale } from "@depict-ai/react-ui/locales/latest";
5
5
  import { ReactNode } from "react";
6
6
  import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
7
- export const version = "2.7.32";
7
+ export const version = "2.7.34";
8
8
  type TextOptions = {
9
9
  /** Enabled */
10
10
  enabled: boolean;
package/dist/main.js CHANGED
@@ -20,7 +20,7 @@ $parcel$export(module.exports, "ExpandingSection", () => $2214dc111b9e2866$expor
20
20
  $parcel$export(module.exports, "ReactLookCard", () => $35bab9ff48bfe404$export$48787da2a5568bc);
21
21
  $parcel$export(module.exports, "version", () => $0a017be3a74fcc94$export$83d89fbfd8236492);
22
22
  /*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
23
- const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.32";
23
+ const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.34";
24
24
 
25
25
 
26
26
 
@@ -148,13 +148,17 @@ overrideAspectRatio) {
148
148
  (0, $7jsgb$solidjsweb.use)((el)=>props?.ref?.(el), _el$);
149
149
  (0, $7jsgb$solidjsweb.insert)(_el$, ()=>props.children);
150
150
  (0, $7jsgb$solidjsweb.effect)((_p$)=>{
151
- var _v$ = props.class, _v$2 = variantToShow()?.page_url || "#";
151
+ var _v$ = props.class, _v$2 = variantToShow()?.page_url || "#", _v$3 = !props.focusable_, _v$4 = props.focusable_ ? undefined : -1;
152
152
  _v$ !== _p$.e && (0, $7jsgb$solidjsweb.className)(_el$, _p$.e = _v$);
153
153
  _v$2 !== _p$.t && (0, $7jsgb$solidjsweb.setAttribute)(_el$, "href", _p$.t = _v$2);
154
+ _v$3 !== _p$.a && (0, $7jsgb$solidjsweb.setAttribute)(_el$, "aria-hidden", _p$.a = _v$3);
155
+ _v$4 !== _p$.o && (0, $7jsgb$solidjsweb.setAttribute)(_el$, "tabindex", _p$.o = _v$4);
154
156
  return _p$;
155
157
  }, {
156
158
  e: undefined,
157
- t: undefined
159
+ t: undefined,
160
+ a: undefined,
161
+ o: undefined
158
162
  });
159
163
  return _el$;
160
164
  })();
@@ -196,8 +200,6 @@ overrideAspectRatio) {
196
200
  "--alignment": alignment
197
201
  };
198
202
  };
199
- (0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
200
- (0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
201
203
  (0, $7jsgb$solidjs.createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
202
204
  // For switch from placeholders to product
203
205
  (0, $7jsgb$solidjs.createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
@@ -208,6 +210,7 @@ overrideAspectRatio) {
208
210
  (0, $7jsgb$solidjsweb.addEventListener)(_el$3, "mouseenter", (0, $7jsgb$depictaiutilisharedlatest.catchify)(()=>!noHoverSupport_() && setCardIsHovered(true)));
209
211
  (0, $7jsgb$solidjsweb.insert)(_el$3, (0, $7jsgb$solidjsweb.createComponent)(LinkWrapped, {
210
212
  "class": "upper",
213
+ focusable_: true,
211
214
  get children () {
212
215
  return (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$ImagesAndVideos, {
213
216
  image_urls_: ()=>variantToShow()?.image_urls,
@@ -348,14 +351,15 @@ overrideAspectRatio) {
348
351
  wrapperComponent_: ()=>containsColorSwatches() && LinkWrapped,
349
352
  ref_: ref_
350
353
  }),
351
- HoveredComponent_: ({ ref_: ref_ })=>(0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$ColorSwatches, {
354
+ HoveredComponent_: ({ ref_: ref_, isHidden_: isHidden_ })=>(0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$ColorSwatches, {
352
355
  colorMap_: colorMap,
353
356
  showVariantIndex_: showVariantIndex,
354
357
  setShowVariantIndex_: setShowVariantIndex,
355
358
  colorsAtIndex_: ()=>variantDisplays()?.map((variant)=>variant.color_name),
356
359
  ref_: ref_,
357
360
  wantedContainerHeightRem_: swatchContainerHeight,
358
- defaultVariantIndex_: defaultVariantIndex
361
+ defaultVariantIndex_: defaultVariantIndex,
362
+ isHidden_: isHidden_
359
363
  }),
360
364
  cardIsHovered_: cardIsHovered
361
365
  });
@@ -475,13 +479,14 @@ overrideAspectRatio) {
475
479
  ref_: (el)=>defaultElement = el
476
480
  }),
477
481
  (0, $7jsgb$solidjsweb.createComponent)(HoveredComponent_, {
478
- ref_: (el)=>hoveredElement = el
482
+ ref_: (el)=>hoveredElement = el,
483
+ isHidden_: ()=>!cardIsHovered_()
479
484
  })
480
485
  ];
481
486
  }
482
487
  });
483
488
  }
484
- function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVariantIndex_: setShowVariantIndex_, showVariantIndex_: showVariantIndex_, colorsAtIndex_: colorsAtIndex_, wantedContainerHeightRem_: wantedContainerHeightRem_, defaultVariantIndex_: defaultVariantIndex_, ref_: ref_ }) {
489
+ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVariantIndex_: setShowVariantIndex_, showVariantIndex_: showVariantIndex_, colorsAtIndex_: colorsAtIndex_, wantedContainerHeightRem_: wantedContainerHeightRem_, defaultVariantIndex_: defaultVariantIndex_, ref_: ref_, isHidden_: isHidden_ }) {
485
490
  let unHoverDebouncedTimeout;
486
491
  const entriesToShow = ()=>[
487
492
  ...colorMap_().entries()
@@ -527,17 +532,21 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
527
532
  (0, $7jsgb$solidjsweb.setAttribute)(_el$6, "href", pageUrl_);
528
533
  (0, $7jsgb$solidjsweb.setAttribute)(_el$6, "title", colorName);
529
534
  (0, $7jsgb$solidjsweb.effect)((_p$)=>{
530
- var _v$3 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$4 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$5 = !!thisColorIsDefaultColor(), _v$6 = !!($3375ddd88f77967d$var$isLightColor(hexColor_) || invalidColor());
531
- _p$.e = (0, $7jsgb$solidjsweb.style)(_el$6, _v$3, _p$.e);
532
- _v$4 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$4);
533
- _v$5 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$5);
534
- _v$6 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$6);
535
+ var _v$5 = isHidden_?.(), _v$6 = isHidden_?.() ? -1 : undefined, _v$7 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$8 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$9 = !!thisColorIsDefaultColor(), _v$10 = !!($3375ddd88f77967d$var$isLightColor(hexColor_) || invalidColor());
536
+ _v$5 !== _p$.e && (0, $7jsgb$solidjsweb.setAttribute)(_el$6, "aria-hidden", _p$.e = _v$5);
537
+ _v$6 !== _p$.t && (0, $7jsgb$solidjsweb.setAttribute)(_el$6, "tabindex", _p$.t = _v$6);
538
+ _p$.a = (0, $7jsgb$solidjsweb.style)(_el$6, _v$7, _p$.a);
539
+ _v$8 !== _p$.o && _el$6.classList.toggle("selected", _p$.o = _v$8);
540
+ _v$9 !== _p$.i && _el$6.classList.toggle("first", _p$.i = _v$9);
541
+ _v$10 !== _p$.n && _el$6.classList.toggle("light-colored", _p$.n = _v$10);
535
542
  return _p$;
536
543
  }, {
537
544
  e: undefined,
538
545
  t: undefined,
539
546
  a: undefined,
540
- o: undefined
547
+ o: undefined,
548
+ i: undefined,
549
+ n: undefined
541
550
  });
542
551
  return _el$6;
543
552
  })();
@@ -639,12 +648,22 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
639
648
  ];
640
649
  const productCardIsVisible = (0, $7jsgb$depictaiuilatest.useProductCardIsVisible)();
641
650
  const hasBeenVisible = (0, $7jsgb$solidjs.createMemo)((prev)=>prev || productCardIsVisible() || forceIsVisible_());
651
+ const video_urls = ()=>video_()?.video_urls;
652
+ const hasVideo = (0, $7jsgb$solidjs.createMemo)(()=>video_urls()?.length);
653
+ const hoverImageDisabled = (0, $7jsgb$solidjs.createMemo)(()=>!configuredOptions_().use_hover_image || noHoverSupport_());
654
+ const hasEnoughImagesForSlider = (0, $7jsgb$solidjs.createMemo)((prev)=>{
655
+ if (prev) return prev; // If we had it once, keep the slider (since removing it is not expected by some code IIRC and could look glitchy)
656
+ let minImagesAvailableToEnableSwipe = 2;
657
+ if (hasVideo()) minImagesAvailableToEnableSwipe--;
658
+ else if (!hoverImageDisabled()) minImagesAvailableToEnableSwipe++;
659
+ return image_urls_()?.length >= minImagesAvailableToEnableSwipe;
660
+ });
642
661
  const slidable = (0, $7jsgb$solidjs.createMemo)(()=>// Don't make cards swipable inside of sliders (PLP slider or recs slider)
643
662
  !((0, $7jsgb$depictaiuilatest.useSlidableInformation)() || PLPLayout?.()?.startsWith("slider")) && configuredOptions_().image_carousel && // Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
644
- hasBeenVisible());
645
- const hoverImageDisabled = (0, $7jsgb$solidjs.createMemo)(()=>!configuredOptions_().use_hover_image || noHoverSupport_());
646
- const video_urls = ()=>video_()?.video_urls;
663
+ // Don't delay the creation of the slider if there's a video, since (contrary to what I've observed with images) the move of the video in the DOM will abort the playback, which will abort the network request, which delays the playback of the video significantly
664
+ (hasBeenVisible() || hasVideo()) && hasEnoughImagesForSlider());
647
665
  const [userTriedSliding, setUserTriedSliding] = (0, $7jsgb$solidjs.createSignal)(false);
666
+ const [swipedPastVideo_, setSwipedPastVideo] = (0, $7jsgb$solidjs.createSignal)(false);
648
667
  const Container = (props)=>{
649
668
  const resolved = (0, $7jsgb$solidjs.children)(()=>props.children);
650
669
  return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
@@ -704,8 +723,13 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
704
723
  // Actually render (and load) the other images when the slider gets swiped
705
724
  slidableInformation.intersectionEntries_(); // Re-check when intersecting entries change
706
725
  const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
707
- // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
708
726
  if (1 in intersectingsObject) setUserTriedSliding(true);
727
+ // Pause video when swiping to the next image
728
+ // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
729
+ if (!intersectingsObject || !Object.keys(intersectingsObject).length) return;
730
+ // Video is always the first card in the slider
731
+ const ratio = intersectingsObject?.[0]?.intersectionRatio;
732
+ setSwipedPastVideo(!ratio);
709
733
  });
710
734
  return resolved;
711
735
  })();
@@ -753,7 +777,7 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
753
777
  return [
754
778
  (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
755
779
  get when () {
756
- return video_urls()?.length;
780
+ return hasVideo();
757
781
  },
758
782
  get children () {
759
783
  return (0, $7jsgb$solidjsweb.createComponent)(MaybeShowLazily, {
@@ -773,6 +797,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
773
797
  },
774
798
  get forceIsVisible_ () {
775
799
  return forceIsVisible_();
800
+ },
801
+ get swipedPastVideo_ () {
802
+ return swipedPastVideo_();
776
803
  }
777
804
  });
778
805
  }
@@ -784,7 +811,7 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
784
811
  }),
785
812
  (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
786
813
  get when () {
787
- return !video_urls()?.length || slidable();
814
+ return !hasVideo() || slidable();
788
815
  },
789
816
  get children () {
790
817
  return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
@@ -858,24 +885,13 @@ function $3375ddd88f77967d$var$Video(props) {
858
885
  return sources;
859
886
  });
860
887
  const productCardIndexAccessor = (0, $7jsgb$depictaiuilatest.useProductCardIndex)();
861
- const isVisible = (0, $7jsgb$depictaiuilatest.useProductCardIsVisible)();
862
- const slidableInformation = (0, $7jsgb$depictaiuilatest.useSlidableInformation)();
863
- const hiddenInImageCarousel = (0, $7jsgb$solidjs.createMemo)(()=>{
864
- // Pause video when swiping to the next image
865
- slidableInformation?.intersectionEntries_(); // Re-check when intersecting entries change
866
- const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
867
- // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
868
- if (!intersectingsObject || !Object.keys(intersectingsObject).length) return false;
869
- // Video is always the first card in the slider
870
- const ratio = intersectingsObject?.[0]?.intersectionRatio;
871
- return !ratio;
872
- });
888
+ const cardIsVisible = (0, $7jsgb$depictaiuilatest.useProductCardIsVisible)();
873
889
  return (()=>{
874
890
  var _el$17 = $3375ddd88f77967d$var$_tmpl$15();
875
891
  (0, $7jsgb$solidjsweb.use)((element)=>{
876
892
  element.disablePictureInPicture = true;
877
893
  (0, $7jsgb$solidjs.createEffect)(()=>{
878
- if ((isVisible() || props.forceIsVisible_) && tabIsVisible() && !hiddenInImageCarousel()) element.play().catch((e)=>(0, $7jsgb$depictaiutilisharedlatest.dwarn)("Error playing video", e));
894
+ if ((cardIsVisible() || props.forceIsVisible_) && tabIsVisible() && !props.swipedPastVideo_) element.play().catch((e)=>(0, $7jsgb$depictaiutilisharedlatest.dwarn)("Error playing video", e));
879
895
  else element.pause();
880
896
  });
881
897
  }, _el$17);
package/dist/module.js CHANGED
@@ -7,7 +7,7 @@ import {createContext as $2MCgq$createContext, createMemo as $2MCgq$createMemo,
7
7
  import {createPortal as $2MCgq$createPortal} from "react-dom";
8
8
 
9
9
  /*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
10
- const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.32";
10
+ const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.34";
11
11
 
12
12
 
13
13
 
@@ -135,13 +135,17 @@ overrideAspectRatio) {
135
135
  (0, $2MCgq$use)((el)=>props?.ref?.(el), _el$);
136
136
  (0, $2MCgq$insert)(_el$, ()=>props.children);
137
137
  (0, $2MCgq$effect)((_p$)=>{
138
- var _v$ = props.class, _v$2 = variantToShow()?.page_url || "#";
138
+ var _v$ = props.class, _v$2 = variantToShow()?.page_url || "#", _v$3 = !props.focusable_, _v$4 = props.focusable_ ? undefined : -1;
139
139
  _v$ !== _p$.e && (0, $2MCgq$className)(_el$, _p$.e = _v$);
140
140
  _v$2 !== _p$.t && (0, $2MCgq$setAttribute)(_el$, "href", _p$.t = _v$2);
141
+ _v$3 !== _p$.a && (0, $2MCgq$setAttribute)(_el$, "aria-hidden", _p$.a = _v$3);
142
+ _v$4 !== _p$.o && (0, $2MCgq$setAttribute)(_el$, "tabindex", _p$.o = _v$4);
141
143
  return _p$;
142
144
  }, {
143
145
  e: undefined,
144
- t: undefined
146
+ t: undefined,
147
+ a: undefined,
148
+ o: undefined
145
149
  });
146
150
  return _el$;
147
151
  })();
@@ -183,8 +187,6 @@ overrideAspectRatio) {
183
187
  "--alignment": alignment
184
188
  };
185
189
  };
186
- (0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
187
- (0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
188
190
  (0, $2MCgq$createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
189
191
  // For switch from placeholders to product
190
192
  (0, $2MCgq$createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
@@ -195,6 +197,7 @@ overrideAspectRatio) {
195
197
  (0, $2MCgq$addEventListener)(_el$3, "mouseenter", (0, $2MCgq$catchify)(()=>!noHoverSupport_() && setCardIsHovered(true)));
196
198
  (0, $2MCgq$insert)(_el$3, (0, $2MCgq$createComponent)(LinkWrapped, {
197
199
  "class": "upper",
200
+ focusable_: true,
198
201
  get children () {
199
202
  return (0, $2MCgq$createComponent)($29535f590238371c$var$ImagesAndVideos, {
200
203
  image_urls_: ()=>variantToShow()?.image_urls,
@@ -335,14 +338,15 @@ overrideAspectRatio) {
335
338
  wrapperComponent_: ()=>containsColorSwatches() && LinkWrapped,
336
339
  ref_: ref_
337
340
  }),
338
- HoveredComponent_: ({ ref_: ref_ })=>(0, $2MCgq$createComponent)($29535f590238371c$var$ColorSwatches, {
341
+ HoveredComponent_: ({ ref_: ref_, isHidden_: isHidden_ })=>(0, $2MCgq$createComponent)($29535f590238371c$var$ColorSwatches, {
339
342
  colorMap_: colorMap,
340
343
  showVariantIndex_: showVariantIndex,
341
344
  setShowVariantIndex_: setShowVariantIndex,
342
345
  colorsAtIndex_: ()=>variantDisplays()?.map((variant)=>variant.color_name),
343
346
  ref_: ref_,
344
347
  wantedContainerHeightRem_: swatchContainerHeight,
345
- defaultVariantIndex_: defaultVariantIndex
348
+ defaultVariantIndex_: defaultVariantIndex,
349
+ isHidden_: isHidden_
346
350
  }),
347
351
  cardIsHovered_: cardIsHovered
348
352
  });
@@ -462,13 +466,14 @@ overrideAspectRatio) {
462
466
  ref_: (el)=>defaultElement = el
463
467
  }),
464
468
  (0, $2MCgq$createComponent)(HoveredComponent_, {
465
- ref_: (el)=>hoveredElement = el
469
+ ref_: (el)=>hoveredElement = el,
470
+ isHidden_: ()=>!cardIsHovered_()
466
471
  })
467
472
  ];
468
473
  }
469
474
  });
470
475
  }
471
- function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVariantIndex_: setShowVariantIndex_, showVariantIndex_: showVariantIndex_, colorsAtIndex_: colorsAtIndex_, wantedContainerHeightRem_: wantedContainerHeightRem_, defaultVariantIndex_: defaultVariantIndex_, ref_: ref_ }) {
476
+ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVariantIndex_: setShowVariantIndex_, showVariantIndex_: showVariantIndex_, colorsAtIndex_: colorsAtIndex_, wantedContainerHeightRem_: wantedContainerHeightRem_, defaultVariantIndex_: defaultVariantIndex_, ref_: ref_, isHidden_: isHidden_ }) {
472
477
  let unHoverDebouncedTimeout;
473
478
  const entriesToShow = ()=>[
474
479
  ...colorMap_().entries()
@@ -514,17 +519,21 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
514
519
  (0, $2MCgq$setAttribute)(_el$6, "href", pageUrl_);
515
520
  (0, $2MCgq$setAttribute)(_el$6, "title", colorName);
516
521
  (0, $2MCgq$effect)((_p$)=>{
517
- var _v$3 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$4 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$5 = !!thisColorIsDefaultColor(), _v$6 = !!($29535f590238371c$var$isLightColor(hexColor_) || invalidColor());
518
- _p$.e = (0, $2MCgq$style)(_el$6, _v$3, _p$.e);
519
- _v$4 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$4);
520
- _v$5 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$5);
521
- _v$6 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$6);
522
+ var _v$5 = isHidden_?.(), _v$6 = isHidden_?.() ? -1 : undefined, _v$7 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$8 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$9 = !!thisColorIsDefaultColor(), _v$10 = !!($29535f590238371c$var$isLightColor(hexColor_) || invalidColor());
523
+ _v$5 !== _p$.e && (0, $2MCgq$setAttribute)(_el$6, "aria-hidden", _p$.e = _v$5);
524
+ _v$6 !== _p$.t && (0, $2MCgq$setAttribute)(_el$6, "tabindex", _p$.t = _v$6);
525
+ _p$.a = (0, $2MCgq$style)(_el$6, _v$7, _p$.a);
526
+ _v$8 !== _p$.o && _el$6.classList.toggle("selected", _p$.o = _v$8);
527
+ _v$9 !== _p$.i && _el$6.classList.toggle("first", _p$.i = _v$9);
528
+ _v$10 !== _p$.n && _el$6.classList.toggle("light-colored", _p$.n = _v$10);
522
529
  return _p$;
523
530
  }, {
524
531
  e: undefined,
525
532
  t: undefined,
526
533
  a: undefined,
527
- o: undefined
534
+ o: undefined,
535
+ i: undefined,
536
+ n: undefined
528
537
  });
529
538
  return _el$6;
530
539
  })();
@@ -626,12 +635,22 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
626
635
  ];
627
636
  const productCardIsVisible = (0, $2MCgq$useProductCardIsVisible)();
628
637
  const hasBeenVisible = (0, $2MCgq$createMemo)((prev)=>prev || productCardIsVisible() || forceIsVisible_());
638
+ const video_urls = ()=>video_()?.video_urls;
639
+ const hasVideo = (0, $2MCgq$createMemo)(()=>video_urls()?.length);
640
+ const hoverImageDisabled = (0, $2MCgq$createMemo)(()=>!configuredOptions_().use_hover_image || noHoverSupport_());
641
+ const hasEnoughImagesForSlider = (0, $2MCgq$createMemo)((prev)=>{
642
+ if (prev) return prev; // If we had it once, keep the slider (since removing it is not expected by some code IIRC and could look glitchy)
643
+ let minImagesAvailableToEnableSwipe = 2;
644
+ if (hasVideo()) minImagesAvailableToEnableSwipe--;
645
+ else if (!hoverImageDisabled()) minImagesAvailableToEnableSwipe++;
646
+ return image_urls_()?.length >= minImagesAvailableToEnableSwipe;
647
+ });
629
648
  const slidable = (0, $2MCgq$createMemo)(()=>// Don't make cards swipable inside of sliders (PLP slider or recs slider)
630
649
  !((0, $2MCgq$useSlidableInformation)() || PLPLayout?.()?.startsWith("slider")) && configuredOptions_().image_carousel && // Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
631
- hasBeenVisible());
632
- const hoverImageDisabled = (0, $2MCgq$createMemo)(()=>!configuredOptions_().use_hover_image || noHoverSupport_());
633
- const video_urls = ()=>video_()?.video_urls;
650
+ // Don't delay the creation of the slider if there's a video, since (contrary to what I've observed with images) the move of the video in the DOM will abort the playback, which will abort the network request, which delays the playback of the video significantly
651
+ (hasBeenVisible() || hasVideo()) && hasEnoughImagesForSlider());
634
652
  const [userTriedSliding, setUserTriedSliding] = (0, $2MCgq$createSignal)(false);
653
+ const [swipedPastVideo_, setSwipedPastVideo] = (0, $2MCgq$createSignal)(false);
635
654
  const Container = (props)=>{
636
655
  const resolved = (0, $2MCgq$children)(()=>props.children);
637
656
  return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
@@ -691,8 +710,13 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
691
710
  // Actually render (and load) the other images when the slider gets swiped
692
711
  slidableInformation.intersectionEntries_(); // Re-check when intersecting entries change
693
712
  const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
694
- // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
695
713
  if (1 in intersectingsObject) setUserTriedSliding(true);
714
+ // Pause video when swiping to the next image
715
+ // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
716
+ if (!intersectingsObject || !Object.keys(intersectingsObject).length) return;
717
+ // Video is always the first card in the slider
718
+ const ratio = intersectingsObject?.[0]?.intersectionRatio;
719
+ setSwipedPastVideo(!ratio);
696
720
  });
697
721
  return resolved;
698
722
  })();
@@ -740,7 +764,7 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
740
764
  return [
741
765
  (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
742
766
  get when () {
743
- return video_urls()?.length;
767
+ return hasVideo();
744
768
  },
745
769
  get children () {
746
770
  return (0, $2MCgq$createComponent)(MaybeShowLazily, {
@@ -760,6 +784,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
760
784
  },
761
785
  get forceIsVisible_ () {
762
786
  return forceIsVisible_();
787
+ },
788
+ get swipedPastVideo_ () {
789
+ return swipedPastVideo_();
763
790
  }
764
791
  });
765
792
  }
@@ -771,7 +798,7 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
771
798
  }),
772
799
  (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
773
800
  get when () {
774
- return !video_urls()?.length || slidable();
801
+ return !hasVideo() || slidable();
775
802
  },
776
803
  get children () {
777
804
  return (0, $2MCgq$createComponent)((0, $2MCgq$For), {
@@ -845,24 +872,13 @@ function $29535f590238371c$var$Video(props) {
845
872
  return sources;
846
873
  });
847
874
  const productCardIndexAccessor = (0, $2MCgq$useProductCardIndex)();
848
- const isVisible = (0, $2MCgq$useProductCardIsVisible)();
849
- const slidableInformation = (0, $2MCgq$useSlidableInformation)();
850
- const hiddenInImageCarousel = (0, $2MCgq$createMemo)(()=>{
851
- // Pause video when swiping to the next image
852
- slidableInformation?.intersectionEntries_(); // Re-check when intersecting entries change
853
- const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
854
- // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
855
- if (!intersectingsObject || !Object.keys(intersectingsObject).length) return false;
856
- // Video is always the first card in the slider
857
- const ratio = intersectingsObject?.[0]?.intersectionRatio;
858
- return !ratio;
859
- });
875
+ const cardIsVisible = (0, $2MCgq$useProductCardIsVisible)();
860
876
  return (()=>{
861
877
  var _el$17 = $29535f590238371c$var$_tmpl$15();
862
878
  (0, $2MCgq$use)((element)=>{
863
879
  element.disablePictureInPicture = true;
864
880
  (0, $2MCgq$createEffect)(()=>{
865
- if ((isVisible() || props.forceIsVisible_) && tabIsVisible() && !hiddenInImageCarousel()) element.play().catch((e)=>(0, $2MCgq$dwarn)("Error playing video", e));
881
+ if ((cardIsVisible() || props.forceIsVisible_) && tabIsVisible() && !props.swipedPastVideo_) element.play().catch((e)=>(0, $2MCgq$dwarn)("Error playing video", e));
866
882
  else element.pause();
867
883
  });
868
884
  }, _el$17);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/portal-components",
3
- "version": "2.7.32",
3
+ "version": "2.7.34",
4
4
  "packageManager": "yarn@3.2.2",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
@@ -104,7 +104,7 @@
104
104
  "@depict-ai/plp-styling": "^4.4.20",
105
105
  "@depict-ai/react-ui": "^4.8.7",
106
106
  "@depict-ai/types": "^5.4.5",
107
- "@depict-ai/ui": "^4.8.22",
107
+ "@depict-ai/ui": "^4.8.29",
108
108
  "@depict-ai/utilishared": "^2.4.7",
109
109
  "parcel": "^2.10.3",
110
110
  "solid-js": "^1.8.16"
@@ -191,12 +191,19 @@ export function DefaultSolidProductCard(
191
191
  return Math.max(...considerSize);
192
192
  });
193
193
 
194
- const LinkWrapped = (props: { children: JSX.Element; class?: string; ref?: (el: HTMLAnchorElement) => void }) => (
194
+ const LinkWrapped = (props: {
195
+ children: JSX.Element;
196
+ class?: string;
197
+ ref?: (el: HTMLAnchorElement) => void;
198
+ focusable_?: boolean;
199
+ }) => (
195
200
  <a
196
201
  class={props.class}
197
202
  href={variantToShow()?.page_url || "#"}
198
203
  // Work around https://github.com/solidjs/solid/issues/2137
199
204
  ref={el => props?.ref?.(el)}
205
+ aria-hidden={!props.focusable_}
206
+ tabIndex={props.focusable_ ? undefined : -1}
200
207
  onClick={catchify(e => {
201
208
  const { target } = e;
202
209
  const navbuttonSelector = ".d-navbutton";
@@ -243,9 +250,6 @@ export function DefaultSolidProductCard(
243
250
  return { "--flex-alignment": flexAlignment, "--alignment": alignment };
244
251
  };
245
252
 
246
- createEffect(() => dlog("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
247
- createEffect(() => dlog("Got passed display", JSON.parse(JSON.stringify(display()))));
248
-
249
253
  createEffect(() => noHoverSupport_() && setCardIsHovered(false));
250
254
  // For switch from placeholders to product
251
255
  createEffect(
@@ -260,7 +264,7 @@ export function DefaultSolidProductCard(
260
264
  onMouseEnter={catchify(() => !noHoverSupport_() && setCardIsHovered(true))}
261
265
  onMouseLeave={catchify(() => !noHoverSupport_() && setCardIsHovered(false))}
262
266
  >
263
- <LinkWrapped class="upper">
267
+ <LinkWrapped class="upper" focusable_={true}>
264
268
  <ImagesAndVideos
265
269
  image_urls_={() => variantToShow()?.image_urls}
266
270
  video_={() => variantToShow()?.video}
@@ -369,7 +373,7 @@ export function DefaultSolidProductCard(
369
373
  ref_={ref_}
370
374
  />
371
375
  )}
372
- HoveredComponent_={({ ref_ }) => (
376
+ HoveredComponent_={({ ref_, isHidden_ }) => (
373
377
  <ColorSwatches
374
378
  colorMap_={colorMap}
375
379
  showVariantIndex_={showVariantIndex}
@@ -378,6 +382,7 @@ export function DefaultSolidProductCard(
378
382
  ref_={ref_}
379
383
  wantedContainerHeightRem_={swatchContainerHeight}
380
384
  defaultVariantIndex_={defaultVariantIndex}
385
+ isHidden_={isHidden_}
381
386
  />
382
387
  )}
383
388
  cardIsHovered_={cardIsHovered}
@@ -414,7 +419,7 @@ function AnimatedRowSwitch({
414
419
  containerComponent_,
415
420
  }: {
416
421
  DefaultComponent_: (props: { ref_: (el: HTMLElement) => void }) => JSX.Element;
417
- HoveredComponent_: (props: { ref_: (el: HTMLElement) => void }) => JSX.Element;
422
+ HoveredComponent_: (props: { ref_: (el: HTMLElement) => void; isHidden_: Accessor<boolean> }) => JSX.Element;
418
423
  cardIsHovered_: Accessor<boolean>;
419
424
  containerComponent_: Accessor<
420
425
  false | ((props: { ref?: (el: HTMLElement) => void; class: string; children: JSX.Element }) => JSX.Element)
@@ -503,7 +508,7 @@ function AnimatedRowSwitch({
503
508
  ref_={(el: HTMLElement) => (containerElement = el)}
504
509
  >
505
510
  <DefaultComponent_ ref_={el => (defaultElement = el)} />
506
- <HoveredComponent_ ref_={el => (hoveredElement = el)} />
511
+ <HoveredComponent_ ref_={el => (hoveredElement = el)} isHidden_={() => !cardIsHovered_()} />
507
512
  </InComponentOrDiv>
508
513
  );
509
514
  }
@@ -516,6 +521,7 @@ function ColorSwatches({
516
521
  wantedContainerHeightRem_,
517
522
  defaultVariantIndex_,
518
523
  ref_,
524
+ isHidden_,
519
525
  }: {
520
526
  colorMap_: Accessor<Map<string, { hexColor_: string; pageUrl_: string; variantIndex_: number }>>;
521
527
  setShowVariantIndex_: Setter<number | undefined>;
@@ -524,6 +530,7 @@ function ColorSwatches({
524
530
  wantedContainerHeightRem_: Accessor<number | undefined>;
525
531
  defaultVariantIndex_: Accessor<number | undefined>;
526
532
  ref_?: (el: HTMLDivElement) => void;
533
+ isHidden_?: Accessor<boolean>;
527
534
  }) {
528
535
  let unHoverDebouncedTimeout: ReturnType<typeof setTimeout> | undefined;
529
536
  const entriesToShow = () => [...colorMap_().entries()].slice(0, 12);
@@ -572,6 +579,8 @@ function ColorSwatches({
572
579
  500
573
580
  );
574
581
  })}
582
+ aria-hidden={isHidden_?.()}
583
+ tabIndex={isHidden_?.() ? -1 : undefined}
575
584
  href={pageUrl_}
576
585
  class="d-swatch"
577
586
  ref={element =>
@@ -694,17 +703,31 @@ function ImagesAndVideos({
694
703
  const containerClasses = () => ["image-video", "border-radius-" + configuredOptions_().image_radius] as const;
695
704
  const productCardIsVisible = useProductCardIsVisible();
696
705
  const hasBeenVisible = createMemo<boolean | undefined>(prev => prev || productCardIsVisible() || forceIsVisible_());
706
+ const video_urls = () => video_()?.video_urls;
707
+ const hasVideo = createMemo(() => video_urls()?.length);
708
+ const hoverImageDisabled = createMemo(() => !configuredOptions_().use_hover_image || noHoverSupport_());
709
+ const hasEnoughImagesForSlider = createMemo<boolean | undefined>(prev => {
710
+ if (prev) return prev; // If we had it once, keep the slider (since removing it is not expected by some code IIRC and could look glitchy)
711
+ let minImagesAvailableToEnableSwipe = 2;
712
+ if (hasVideo()) {
713
+ minImagesAvailableToEnableSwipe--;
714
+ } else if (!hoverImageDisabled()) {
715
+ minImagesAvailableToEnableSwipe++;
716
+ }
717
+ return (image_urls_()?.length as number) >= minImagesAvailableToEnableSwipe;
718
+ });
697
719
  const slidable = createMemo(
698
720
  () =>
699
721
  // Don't make cards swipable inside of sliders (PLP slider or recs slider)
700
722
  !(useSlidableInformation() || PLPLayout?.()?.startsWith("slider")) &&
701
723
  configuredOptions_().image_carousel &&
702
724
  // Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
703
- hasBeenVisible()
725
+ // Don't delay the creation of the slider if there's a video, since (contrary to what I've observed with images) the move of the video in the DOM will abort the playback, which will abort the network request, which delays the playback of the video significantly
726
+ (hasBeenVisible() || hasVideo()) &&
727
+ hasEnoughImagesForSlider()
704
728
  );
705
- const hoverImageDisabled = createMemo(() => !configuredOptions_().use_hover_image || noHoverSupport_());
706
- const video_urls = () => video_()?.video_urls;
707
729
  const [userTriedSliding, setUserTriedSliding] = createSignal(false);
730
+ const [swipedPastVideo_, setSwipedPastVideo] = createSignal(false);
708
731
 
709
732
  const Container = (props: { children: JSX.Element }) => {
710
733
  const resolved = children(() => props.children);
@@ -758,10 +781,16 @@ function ImagesAndVideos({
758
781
  // Actually render (and load) the other images when the slider gets swiped
759
782
  slidableInformation!.intersectionEntries_(); // Re-check when intersecting entries change
760
783
  const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
761
- // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
762
784
  if (1 in intersectingsObject!) {
763
785
  setUserTriedSliding(true);
764
786
  }
787
+
788
+ // Pause video when swiping to the next image
789
+ // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
790
+ if (!intersectingsObject || !Object.keys(intersectingsObject).length) return;
791
+ // Video is always the first card in the slider
792
+ const ratio = intersectingsObject?.[0]?.intersectionRatio;
793
+ setSwipedPastVideo(!ratio);
765
794
  });
766
795
 
767
796
  return resolved as unknown as JSX.Element;
@@ -793,7 +822,7 @@ function ImagesAndVideos({
793
822
  return (
794
823
  <Show when={image_urls_()} fallback={<ImagePlaceholder aspectRatio={aspectRatio_()} />}>
795
824
  <Container>
796
- <Show when={video_urls()?.length}>
825
+ <Show when={hasVideo()}>
797
826
  <MaybeShowLazily>
798
827
  <div class="media-item video">
799
828
  <ImageContainer aspectRatio={aspectRatio_()}>
@@ -801,12 +830,13 @@ function ImagesAndVideos({
801
830
  video_sources_={video_urls() as [string, ...string[]]}
802
831
  poster_={video_()?.preview_image_url || image_urls_()?.[0]}
803
832
  forceIsVisible_={forceIsVisible_()}
833
+ swipedPastVideo_={swipedPastVideo_()}
804
834
  />
805
835
  </ImageContainer>
806
836
  </div>
807
837
  </MaybeShowLazily>
808
838
  </Show>
809
- <Show when={!video_urls()?.length || slidable()}>
839
+ <Show when={!hasVideo() || slidable()}>
810
840
  <For each={slidable() ? image_urls_() : image_urls_()?.slice(0, 1)}>
811
841
  {(image_url, index) => (
812
842
  <Show when={hoverImageDisabled() || index() !== 1}>
@@ -839,7 +869,12 @@ function ImagesAndVideos({
839
869
  );
840
870
  }
841
871
 
842
- function Video(props: { video_sources_: [string, ...string[]]; poster_?: string; forceIsVisible_?: boolean }) {
872
+ function Video(props: {
873
+ video_sources_: [string, ...string[]];
874
+ poster_?: string;
875
+ forceIsVisible_?: boolean;
876
+ swipedPastVideo_: boolean;
877
+ }) {
843
878
  // Making some assumptions for shopify here rn, change those if wanting to support other browsers too
844
879
 
845
880
  const tabIsVisible = useVisibilityState();
@@ -855,18 +890,7 @@ function Video(props: { video_sources_: [string, ...string[]]; poster_?: string;
855
890
  return sources;
856
891
  });
857
892
  const productCardIndexAccessor = useProductCardIndex();
858
- const isVisible = useProductCardIsVisible();
859
- const slidableInformation = useSlidableInformation();
860
- const hiddenInImageCarousel = createMemo(() => {
861
- // Pause video when swiping to the next image
862
- slidableInformation?.intersectionEntries_(); // Re-check when intersecting entries change
863
- const intersectingsObject = slidableInformation?.slider_.intersecting_items_object;
864
- // If intersection observers haven't started yet or we aren't in a slider, we count as visible for faster playback
865
- if (!intersectingsObject || !Object.keys(intersectingsObject).length) return false;
866
- // Video is always the first card in the slider
867
- const ratio = intersectingsObject?.[0]?.intersectionRatio;
868
- return !ratio;
869
- });
893
+ const cardIsVisible = useProductCardIsVisible();
870
894
 
871
895
  return (
872
896
  <video
@@ -880,7 +904,7 @@ function Video(props: { video_sources_: [string, ...string[]]; poster_?: string;
880
904
  ref={element => {
881
905
  element.disablePictureInPicture = true;
882
906
  createEffect(() => {
883
- if ((isVisible() || props.forceIsVisible_) && tabIsVisible() && !hiddenInImageCarousel()) {
907
+ if ((cardIsVisible() || props.forceIsVisible_) && tabIsVisible() && !props.swipedPastVideo_) {
884
908
  element.play().catch(e => dwarn("Error playing video", e));
885
909
  } else {
886
910
  element.pause();