@depict-ai/portal-components 2.7.6 → 2.7.8

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
@@ -3,7 +3,7 @@ import { SearchFilter } from "@depict-ai/types/api/SearchResponse";
3
3
  import { Locale } from "@depict-ai/react-ui/locales/latest";
4
4
  import { ReactNode } from "react";
5
5
  import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
6
- export const version = "2.7.6";
6
+ export const version = "2.7.8";
7
7
  type TextOptions = {
8
8
  /** Enabled */
9
9
  enabled: boolean;
@@ -41,6 +41,7 @@ type ProductCardSchema = {
41
41
  use_hover_image: boolean;
42
42
  /** Image Carousel */
43
43
  image_carousel: boolean;
44
+ image_aspect_ratio: number;
44
45
  };
45
46
  export function ReactDefaultProductCard(react_props: {
46
47
  options: ProductCardSchema;
package/dist/main.js CHANGED
@@ -18,7 +18,7 @@ $parcel$export(module.exports, "ExpandingSection", () => $2214dc111b9e2866$expor
18
18
  $parcel$export(module.exports, "ReactLookCard", () => $35bab9ff48bfe404$export$48787da2a5568bc);
19
19
  $parcel$export(module.exports, "version", () => $0a017be3a74fcc94$export$83d89fbfd8236492);
20
20
  /*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
21
- const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.6";
21
+ const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.8";
22
22
 
23
23
 
24
24
 
@@ -68,7 +68,6 @@ const $3375ddd88f77967d$var$sizeOrder = [
68
68
  "One Size",
69
69
  "Onesize"
70
70
  ];
71
- const $3375ddd88f77967d$var$imageAspectRatio = 1;
72
71
  const $3375ddd88f77967d$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $7jsgb$solidjs.createContext)();
73
72
  let $3375ddd88f77967d$var$colorCanvasContext;
74
73
  function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOptions_ = ()=>({
@@ -106,7 +105,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
106
105
  },
107
106
  use_hover_image: true,
108
107
  image_carousel: true,
109
- color_options: true
108
+ color_options: true,
109
+ image_aspect_ratio: 1
110
110
  })) {
111
111
  const variantDisplays = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_displays);
112
112
  const defaultVariantIndex = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_index);
@@ -114,6 +114,14 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
114
114
  const [cardIsHovered, setCardIsHovered] = (0, $7jsgb$solidjs.createSignal)(false);
115
115
  const variantToShow = (0, $7jsgb$solidjs.createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
116
116
  const noHoverSupport_ = (0, $7jsgb$depictaiuilatest.media_query_to_accessor)("(hover: none)");
117
+ const [salePrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.sale_price);
118
+ const [originalPrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.original_price);
119
+ const onSale = (0, $7jsgb$solidjs.createMemo)(()=>(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Suspense), {
120
+ get children () {
121
+ return originalPrice() !== salePrice();
122
+ }
123
+ }));
124
+ const aspectRatio_ = (0, $7jsgb$solidjs.createMemo)(()=>configuredOptions_().image_aspect_ratio);
117
125
  const sizesInStock_ = (0, $7jsgb$solidjs.createMemo)(()=>new Map(variantDisplays()?.map((d)=>[
118
126
  d.size_name,
119
127
  d.in_stock
@@ -128,13 +136,6 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
128
136
  }
129
137
  ]).filter(([colorName])=>colorName) // in case color_name is null
130
138
  ));
131
- const [salePrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.sale_price);
132
- const [originalPrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.original_price);
133
- const onSale = (0, $7jsgb$solidjs.createMemo)(()=>(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Suspense), {
134
- get children () {
135
- return originalPrice() !== salePrice();
136
- }
137
- }));
138
139
  const swatchContainerHeight = (0, $7jsgb$solidjs.createMemo)(()=>{
139
140
  // To avoid the product cards switching around as one hovers and price switches to the swatches, we have to make the swatches container have the same height as the price one
140
141
  let considerSize = [];
@@ -168,8 +169,10 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
168
169
  })();
169
170
  const Title = (props)=>(()=>{
170
171
  var _el$2 = $3375ddd88f77967d$var$_tmpl$2();
171
- var _ref$ = props.ref_;
172
- typeof _ref$ === "function" ? (0, $7jsgb$solidjsweb.use)(_ref$, _el$2) : props.ref_ = _el$2;
172
+ (0, $7jsgb$solidjsweb.use)((el)=>{
173
+ props.ref_?.(el);
174
+ $3375ddd88f77967d$var$setStyleForTextOptions(el, titleOptions);
175
+ }, _el$2);
173
176
  (0, $7jsgb$solidjsweb.insert)(_el$2, ()=>variantToShow()?.title ?? [
174
177
  (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.TextPlaceholder), {
175
178
  height: "1em",
@@ -180,17 +183,30 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
180
183
  width: "20ch"
181
184
  })
182
185
  ]);
183
- (0, $7jsgb$solidjsweb.effect)((_p$)=>{
184
- var _v$3 = variantToShow()?.title, _v$4 = $3375ddd88f77967d$var$styleForTextOptions(titleOptions());
185
- _v$3 !== _p$.e && (0, $7jsgb$solidjsweb.setAttribute)(_el$2, "title", _p$.e = _v$3);
186
- _p$.t = (0, $7jsgb$solidjsweb.style)(_el$2, _v$4, _p$.t);
187
- return _p$;
188
- }, {
189
- e: undefined,
190
- t: undefined
191
- });
186
+ (0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.setAttribute)(_el$2, "title", variantToShow()?.title));
192
187
  return _el$2;
193
188
  })();
189
+ const mainStyle = ()=>{
190
+ const { alignment: alignment } = configuredOptions_();
191
+ let flexAlignment;
192
+ switch(alignment){
193
+ case "left":
194
+ flexAlignment = "flex-start";
195
+ break;
196
+ case "right":
197
+ flexAlignment = "flex-end";
198
+ break;
199
+ default:
200
+ flexAlignment = alignment;
201
+ break;
202
+ }
203
+ return {
204
+ "--flex-alignment": flexAlignment,
205
+ "--alignment": alignment
206
+ };
207
+ };
208
+ (0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
209
+ (0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
194
210
  (0, $7jsgb$solidjs.createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
195
211
  return (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$ContainsColorSwatchesProvider, {
196
212
  get children () {
@@ -204,7 +220,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
204
220
  image_urls_: ()=>variantToShow()?.image_urls,
205
221
  video_: ()=>variantToShow()?.videos?.[0],
206
222
  configuredOptions_: configuredOptions_,
207
- cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered()
223
+ cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered(),
224
+ aspectRatio_: aspectRatio_
208
225
  });
209
226
  }
210
227
  }), null);
@@ -355,7 +372,7 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
355
372
  })();
356
373
  }
357
374
  }), null);
358
- (0, $7jsgb$solidjsweb.effect)(()=>configuredOptions_().alignment != null ? _el$3.style.setProperty("--alignment", configuredOptions_().alignment) : _el$3.style.removeProperty("--alignment"));
375
+ (0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$3, mainStyle(), _$p));
359
376
  return _el$3;
360
377
  }
361
378
  });
@@ -476,8 +493,11 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
476
493
  (0, $7jsgb$solidjs.onCleanup)(()=>setContainsColorSwatches(false));
477
494
  return (()=>{
478
495
  var _el$4 = $3375ddd88f77967d$var$_tmpl$5();
479
- var _ref$2 = ref_;
480
- typeof _ref$2 === "function" ? (0, $7jsgb$solidjsweb.use)(_ref$2, _el$4) : ref_ = _el$4;
496
+ (0, $7jsgb$solidjsweb.use)((el)=>{
497
+ ref_?.(el);
498
+ // Do like this so we don't override other styles set by AnimateRowSwitch
499
+ (0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(el.style, "--swatch-container-height", wantedContainerHeightRem_() && wantedContainerHeightRem_() + "rem"));
500
+ }, _el$4);
481
501
  (0, $7jsgb$solidjsweb.insert)(_el$4, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
482
502
  get each () {
483
503
  return entriesToShow();
@@ -503,11 +523,11 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
503
523
  (0, $7jsgb$solidjsweb.setAttribute)(_el$6, "href", pageUrl_);
504
524
  (0, $7jsgb$solidjsweb.setAttribute)(_el$6, "title", colorName);
505
525
  (0, $7jsgb$solidjsweb.effect)((_p$)=>{
506
- var _v$5 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$6 = !!(colorsAtIndex_?.[showVariantIndex_()] === colorName), _v$7 = !!thisColorIsDefaultColor(), _v$8 = !!($3375ddd88f77967d$var$isLightColor(hexColor_) || invalidColor());
507
- _p$.e = (0, $7jsgb$solidjsweb.style)(_el$6, _v$5, _p$.e);
508
- _v$6 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$6);
509
- _v$7 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$7);
510
- _v$8 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$8);
526
+ var _v$3 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$4 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$5 = !!thisColorIsDefaultColor(), _v$6 = !!($3375ddd88f77967d$var$isLightColor(hexColor_) || invalidColor());
527
+ _p$.e = (0, $7jsgb$solidjsweb.style)(_el$6, _v$3, _p$.e);
528
+ _v$4 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$4);
529
+ _v$5 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$5);
530
+ _v$6 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$6);
511
531
  return _p$;
512
532
  }, {
513
533
  e: undefined,
@@ -527,7 +547,6 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
527
547
  return $3375ddd88f77967d$var$_tmpl$4();
528
548
  }
529
549
  }), null);
530
- (0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$4, isNaN(wantedContainerHeightRem_()) ? "" : `--swatch-container-height:${wantedContainerHeightRem_()}rem`, _$p));
531
550
  return _el$4;
532
551
  })();
533
552
  })();
@@ -546,8 +565,11 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
546
565
  },
547
566
  get children () {
548
567
  var _el$7 = $3375ddd88f77967d$var$_tmpl$8();
549
- var _ref$3 = ref_;
550
- typeof _ref$3 === "function" ? (0, $7jsgb$solidjsweb.use)(_ref$3, _el$7) : ref_ = _el$7;
568
+ (0, $7jsgb$solidjsweb.use)((el)=>{
569
+ ref_?.(el);
570
+ // Do like this so we don't override other styles set by AnimateRowSwitch
571
+ (0, $7jsgb$solidjs.createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
572
+ }, _el$7);
551
573
  (0, $7jsgb$solidjsweb.insert)(_el$7, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
552
574
  get each () {
553
575
  return $3375ddd88f77967d$var$sortSizes(keysToShow());
@@ -580,29 +602,23 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
580
602
  return _el$8;
581
603
  }
582
604
  }), null);
583
- (0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$7, `--font-size-rem:${fontSizeRem_()}rem`, _$p));
584
605
  return _el$7;
585
606
  }
586
607
  });
587
608
  }
588
- function $3375ddd88f77967d$var$styleForTextOptions(options) {
589
- return {
590
- "--font-size-rem": options.font_size_rem + "rem",
591
- ...options.bold && {
592
- "--font-weight": "bold"
593
- },
594
- ...options.italic && {
595
- "--font-style": "italic"
596
- },
597
- ...options.color && {
598
- "--color": options.color
599
- },
600
- ...options.bg_color && {
601
- "--background": options.bg_color
602
- }
603
- };
609
+ function $3375ddd88f77967d$var$setPropertyIfExists(style, property, value) {
610
+ if (value) style.setProperty(property, value);
611
+ else style.removeProperty(property);
612
+ }
613
+ function $3375ddd88f77967d$var$setStyleForTextOptions({ style: style }, options) {
614
+ // Doing this instead of just using style={} because AnimatedRowSwitch needs to be able to set inline styling without it being overridden
615
+ (0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--font-size-rem", options().font_size_rem + "rem"));
616
+ (0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--font-weight", options().bold && "bold"));
617
+ (0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--font-style", options().italic && "italic"));
618
+ (0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--color", options().color));
619
+ (0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--background", options().bg_color));
604
620
  }
605
- function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_ }) {
621
+ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_ }) {
606
622
  const isAlreadyInSlider = !!(0, $7jsgb$depictaiuilatest.useSlidableInformation)();
607
623
  const containerClasses = ()=>[
608
624
  "image-video",
@@ -613,38 +629,48 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
613
629
  const hoverImageDisabled = (0, $7jsgb$solidjs.createMemo)(()=>!configuredOptions_().use_hover_image);
614
630
  const video_urls = ()=>video_()?.video_urls;
615
631
  const Container = (props)=>{
616
- if (slidable()) return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.SlidableItems), {
617
- arrow_height_: 25,
618
- arrow_width_: 12.5,
619
- disable_fading_: true,
620
- slider_ref_: (slider)=>{
621
- const { container: container, insert_here: insert_here } = slider;
622
- slider.stepstoslide = 1; // In case anyone enables the hidden buttons using css
623
- (0, $7jsgb$solidjs.createRenderEffect)((previous)=>(0, $7jsgb$solidjsweb.classList)(container, {
624
- products: true,
625
- ...Object.fromEntries(containerClasses().map((cls)=>[
626
- cls,
627
- true
628
- ]))
629
- }, previous));
630
- // Scroll to beginning when changing what variant we're showing
631
- (0, $7jsgb$solidjs.createEffect)((0, $7jsgb$solidjs.on)(image_urls_, ()=>insert_here.scrollTo({
632
- left: 0,
633
- behavior: "auto"
634
- }), {
635
- defer: true
636
- }));
632
+ const resolved = (0, $7jsgb$solidjs.children)(()=>props.children);
633
+ return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
634
+ get when () {
635
+ return slidable();
636
+ },
637
+ get fallback () {
638
+ return (()=>{
639
+ var _el$14 = $3375ddd88f77967d$var$_tmpl$11();
640
+ (0, $7jsgb$solidjsweb.insert)(_el$14, resolved);
641
+ (0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.className)(_el$14, containerClasses().join(" ")));
642
+ return _el$14;
643
+ })();
637
644
  },
638
645
  get children () {
639
- return props.children;
646
+ return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.SlidableItems), {
647
+ arrow_height_: 25,
648
+ arrow_width_: 12.5,
649
+ disable_fading_: true,
650
+ slider_ref_: (slider)=>{
651
+ const { container: container, insert_here: insert_here } = slider;
652
+ slider.stepstoslide = 1; // In case anyone enables the hidden buttons using css
653
+ (0, $7jsgb$solidjs.createRenderEffect)((previous)=>(0, $7jsgb$solidjsweb.classList)(container, {
654
+ products: true,
655
+ ...Object.fromEntries(containerClasses().map((cls)=>[
656
+ cls,
657
+ true
658
+ ]))
659
+ }, previous));
660
+ // Scroll to beginning when changing what variant we're showing
661
+ (0, $7jsgb$solidjs.createEffect)((0, $7jsgb$solidjs.on)(image_urls_, ()=>insert_here.scrollTo({
662
+ left: 0,
663
+ behavior: "auto"
664
+ }), {
665
+ defer: true
666
+ }));
667
+ },
668
+ get children () {
669
+ return resolved();
670
+ }
671
+ });
640
672
  }
641
673
  });
642
- return (()=>{
643
- var _el$14 = $3375ddd88f77967d$var$_tmpl$11();
644
- (0, $7jsgb$solidjsweb.insert)(_el$14, ()=>props.children);
645
- (0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.className)(_el$14, containerClasses().join(" ")));
646
- return _el$14;
647
- })();
648
674
  };
649
675
  return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
650
676
  get when () {
@@ -652,7 +678,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
652
678
  },
653
679
  get fallback () {
654
680
  return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.ImagePlaceholder), {
655
- aspectRatio: $3375ddd88f77967d$var$imageAspectRatio
681
+ get aspectRatio () {
682
+ return aspectRatio_();
683
+ }
656
684
  });
657
685
  },
658
686
  get children () {
@@ -666,7 +694,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
666
694
  get children () {
667
695
  var _el$15 = $3375ddd88f77967d$var$_tmpl$12();
668
696
  (0, $7jsgb$solidjsweb.insert)(_el$15, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.ImageContainer), {
669
- aspectRatio: $3375ddd88f77967d$var$imageAspectRatio,
697
+ get aspectRatio () {
698
+ return aspectRatio_();
699
+ },
670
700
  get children () {
671
701
  return (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$Video, {
672
702
  get video_sources_ () {
@@ -698,7 +728,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
698
728
  var _el$16 = $3375ddd88f77967d$var$_tmpl$13();
699
729
  (0, $7jsgb$solidjsweb.insert)(_el$16, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.ShopifyContainedImage), {
700
730
  src: image_url,
701
- aspectRatio: $3375ddd88f77967d$var$imageAspectRatio,
731
+ get aspectRatio () {
732
+ return aspectRatio_();
733
+ },
702
734
  imgProps: {
703
735
  alt: "Product image"
704
736
  }
@@ -712,7 +744,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
712
744
  get src () {
713
745
  return image_urls_()[1];
714
746
  },
715
- aspectRatio: $3375ddd88f77967d$var$imageAspectRatio,
747
+ get aspectRatio () {
748
+ return aspectRatio_();
749
+ },
716
750
  imgProps: {
717
751
  alt: "Product image"
718
752
  },
@@ -839,6 +873,7 @@ function $3375ddd88f77967d$var$Prices({ formatPrice_: formatPrice_, configuredOp
839
873
  return [
840
874
  (()=>{
841
875
  var _el$20 = $3375ddd88f77967d$var$_tmpl$17();
876
+ (0, $7jsgb$solidjsweb.use)((el)=>$3375ddd88f77967d$var$setStyleForTextOptions(el, priceOptions), _el$20);
842
877
  (0, $7jsgb$solidjsweb.insert)(_el$20, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
843
878
  get when () {
844
879
  return variantToShow_();
@@ -863,7 +898,6 @@ function $3375ddd88f77967d$var$Prices({ formatPrice_: formatPrice_, configuredOp
863
898
  });
864
899
  }
865
900
  }));
866
- (0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$20, $3375ddd88f77967d$var$styleForTextOptions(priceOptions()), _$p));
867
901
  return _el$20;
868
902
  })(),
869
903
  (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Suspense), {
@@ -877,8 +911,8 @@ function $3375ddd88f77967d$var$Prices({ formatPrice_: formatPrice_, configuredOp
877
911
  " ",
878
912
  (()=>{
879
913
  var _el$21 = $3375ddd88f77967d$var$_tmpl$18();
914
+ (0, $7jsgb$solidjsweb.use)((el)=>$3375ddd88f77967d$var$setStyleForTextOptions(el, originalPriceOptions), _el$21);
880
915
  (0, $7jsgb$solidjsweb.insert)(_el$21, ()=>formatPrice_?.(originalPrice_()));
881
- (0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$21, $3375ddd88f77967d$var$styleForTextOptions(originalPriceOptions()), _$p));
882
916
  return _el$21;
883
917
  })()
884
918
  ];
@@ -950,21 +984,19 @@ function $3375ddd88f77967d$var$InComponentOrDiv(props) {
950
984
  const resolved = (0, $7jsgb$solidjs.children)(()=>props.children);
951
985
  return (0, $7jsgb$solidjs.createMemo)(()=>{
952
986
  const Component = props.component_;
953
- if (Component) return (0, $7jsgb$solidjsweb.createComponent)(Component, {
954
- get ["class"] () {
987
+ if (Component) // Written like this because the JSX transform mutates our props object: https://github.com/ryansolid/dom-expressions/pull/316#issuecomment-2066925544
988
+ return (0, $7jsgb$solidjsweb.createComponent)(Component, {
989
+ get class () {
955
990
  return props.class_;
956
991
  },
957
- ref (r$) {
958
- var _ref$4 = props.ref_;
959
- typeof _ref$4 === "function" ? _ref$4(r$) : props.ref_ = r$;
992
+ get ref () {
993
+ return props.ref_;
960
994
  },
961
- get children () {
962
- return resolved();
963
- }
995
+ children: resolved
964
996
  });
965
997
  return (()=>{
966
998
  var _el$22 = $3375ddd88f77967d$var$_tmpl$11();
967
- (0, $7jsgb$solidjsweb.use)((el)=>props.ref_?.(el), _el$22);
999
+ (0, $7jsgb$solidjsweb.use)((el)=>props?.ref_?.(el), _el$22);
968
1000
  (0, $7jsgb$solidjsweb.insert)(_el$22, resolved);
969
1001
  (0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.className)(_el$22, props.class_));
970
1002
  return _el$22;
@@ -986,7 +1018,8 @@ function $70cc6bd7e3f1dd4b$export$d1a48be4967fe67c(react_props) {
986
1018
  formatPrice: (price)=>price && (0, $7jsgb$depictaiutilisharedlatest.standard_price_format)(price)
987
1019
  }, ()=>props_store.options);
988
1020
  },
989
- props: react_props,
1021
+ // Work around in case https://github.com/solidjs/solid/issues/2139 potentially arises
1022
+ props: structuredClone(react_props),
990
1023
  className: "depict"
991
1024
  });
992
1025
  }
package/dist/module.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import {add_to_version_info as $2MCgq$add_to_version_info, standard_price_format as $2MCgq$standard_price_format, catchify as $2MCgq$catchify, dlog as $2MCgq$dlog, dwarn as $2MCgq$dwarn} from "@depict-ai/utilishared/latest";
2
- import {render as $2MCgq$render, template as $2MCgq$template, createComponent as $2MCgq$createComponent, addEventListener as $2MCgq$addEventListener, use as $2MCgq$use, insert as $2MCgq$insert, effect as $2MCgq$effect, className as $2MCgq$className, setAttribute as $2MCgq$setAttribute, style as $2MCgq$style, memo as $2MCgq$memo, classList as $2MCgq$classList, spread as $2MCgq$spread, mergeProps as $2MCgq$mergeProps, delegateEvents as $2MCgq$delegateEvents} from "solid-js/web";
2
+ import {render as $2MCgq$render, template as $2MCgq$template, createComponent as $2MCgq$createComponent, addEventListener as $2MCgq$addEventListener, use as $2MCgq$use, insert as $2MCgq$insert, effect as $2MCgq$effect, className as $2MCgq$className, setAttribute as $2MCgq$setAttribute, memo as $2MCgq$memo, style as $2MCgq$style, classList as $2MCgq$classList, spread as $2MCgq$spread, mergeProps as $2MCgq$mergeProps, delegateEvents as $2MCgq$delegateEvents} from "solid-js/web";
3
3
  import {useRef as $2MCgq$useRef, useState as $2MCgq$useState, useEffect as $2MCgq$useEffect, createElement as $2MCgq$createElement, Fragment as $2MCgq$Fragment} from "react";
4
4
  import {createStore as $2MCgq$createStore, reconcile as $2MCgq$reconcile} from "solid-js/store";
5
5
  import {media_query_to_accessor as $2MCgq$media_query_to_accessor, TextPlaceholder as $2MCgq$TextPlaceholder, useSlidableInformation as $2MCgq$useSlidableInformation, SlidableItems as $2MCgq$SlidableItems, ImagePlaceholder as $2MCgq$ImagePlaceholder, ImageContainer as $2MCgq$ImageContainer, ShopifyContainedImage as $2MCgq$ShopifyContainedImage, useVisibilityState as $2MCgq$useVisibilityState, useProductCardIndex as $2MCgq$useProductCardIndex, useProductCardIsVisible as $2MCgq$useProductCardIsVisible, accessor_of_object_to_object_with_accessor_values as $2MCgq$accessor_of_object_to_object_with_accessor_values, create_modified_filters as $2MCgq$create_modified_filters, SelectedFilters as $2MCgq$SelectedFilters, FilterBody as $2MCgq$FilterBody, ExpandingDetails as $2MCgq$ExpandingDetails, ListingProvider as $2MCgq$ListingProvider, PseudoRouter as $2MCgq$PseudoRouter, LookCard as $2MCgq$LookCard} from "@depict-ai/ui/latest";
@@ -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.6";
10
+ const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.8";
11
11
 
12
12
 
13
13
 
@@ -57,7 +57,6 @@ const $29535f590238371c$var$sizeOrder = [
57
57
  "One Size",
58
58
  "Onesize"
59
59
  ];
60
- const $29535f590238371c$var$imageAspectRatio = 1;
61
60
  const $29535f590238371c$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $2MCgq$createContext)();
62
61
  let $29535f590238371c$var$colorCanvasContext;
63
62
  function $29535f590238371c$export$f11681c54c860912(display, info, configuredOptions_ = ()=>({
@@ -95,7 +94,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
95
94
  },
96
95
  use_hover_image: true,
97
96
  image_carousel: true,
98
- color_options: true
97
+ color_options: true,
98
+ image_aspect_ratio: 1
99
99
  })) {
100
100
  const variantDisplays = (0, $2MCgq$createMemo)(()=>display()?.variant_displays);
101
101
  const defaultVariantIndex = (0, $2MCgq$createMemo)(()=>display()?.variant_index);
@@ -103,6 +103,14 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
103
103
  const [cardIsHovered, setCardIsHovered] = (0, $2MCgq$createSignal)(false);
104
104
  const variantToShow = (0, $2MCgq$createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
105
105
  const noHoverSupport_ = (0, $2MCgq$media_query_to_accessor)("(hover: none)");
106
+ const [salePrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.sale_price);
107
+ const [originalPrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.original_price);
108
+ const onSale = (0, $2MCgq$createMemo)(()=>(0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
109
+ get children () {
110
+ return originalPrice() !== salePrice();
111
+ }
112
+ }));
113
+ const aspectRatio_ = (0, $2MCgq$createMemo)(()=>configuredOptions_().image_aspect_ratio);
106
114
  const sizesInStock_ = (0, $2MCgq$createMemo)(()=>new Map(variantDisplays()?.map((d)=>[
107
115
  d.size_name,
108
116
  d.in_stock
@@ -117,13 +125,6 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
117
125
  }
118
126
  ]).filter(([colorName])=>colorName) // in case color_name is null
119
127
  ));
120
- const [salePrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.sale_price);
121
- const [originalPrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.original_price);
122
- const onSale = (0, $2MCgq$createMemo)(()=>(0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
123
- get children () {
124
- return originalPrice() !== salePrice();
125
- }
126
- }));
127
128
  const swatchContainerHeight = (0, $2MCgq$createMemo)(()=>{
128
129
  // To avoid the product cards switching around as one hovers and price switches to the swatches, we have to make the swatches container have the same height as the price one
129
130
  let considerSize = [];
@@ -157,8 +158,10 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
157
158
  })();
158
159
  const Title = (props)=>(()=>{
159
160
  var _el$2 = $29535f590238371c$var$_tmpl$2();
160
- var _ref$ = props.ref_;
161
- typeof _ref$ === "function" ? (0, $2MCgq$use)(_ref$, _el$2) : props.ref_ = _el$2;
161
+ (0, $2MCgq$use)((el)=>{
162
+ props.ref_?.(el);
163
+ $29535f590238371c$var$setStyleForTextOptions(el, titleOptions);
164
+ }, _el$2);
162
165
  (0, $2MCgq$insert)(_el$2, ()=>variantToShow()?.title ?? [
163
166
  (0, $2MCgq$createComponent)((0, $2MCgq$TextPlaceholder), {
164
167
  height: "1em",
@@ -169,17 +172,30 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
169
172
  width: "20ch"
170
173
  })
171
174
  ]);
172
- (0, $2MCgq$effect)((_p$)=>{
173
- var _v$3 = variantToShow()?.title, _v$4 = $29535f590238371c$var$styleForTextOptions(titleOptions());
174
- _v$3 !== _p$.e && (0, $2MCgq$setAttribute)(_el$2, "title", _p$.e = _v$3);
175
- _p$.t = (0, $2MCgq$style)(_el$2, _v$4, _p$.t);
176
- return _p$;
177
- }, {
178
- e: undefined,
179
- t: undefined
180
- });
175
+ (0, $2MCgq$effect)(()=>(0, $2MCgq$setAttribute)(_el$2, "title", variantToShow()?.title));
181
176
  return _el$2;
182
177
  })();
178
+ const mainStyle = ()=>{
179
+ const { alignment: alignment } = configuredOptions_();
180
+ let flexAlignment;
181
+ switch(alignment){
182
+ case "left":
183
+ flexAlignment = "flex-start";
184
+ break;
185
+ case "right":
186
+ flexAlignment = "flex-end";
187
+ break;
188
+ default:
189
+ flexAlignment = alignment;
190
+ break;
191
+ }
192
+ return {
193
+ "--flex-alignment": flexAlignment,
194
+ "--alignment": alignment
195
+ };
196
+ };
197
+ (0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
198
+ (0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
183
199
  (0, $2MCgq$createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
184
200
  return (0, $2MCgq$createComponent)($29535f590238371c$var$ContainsColorSwatchesProvider, {
185
201
  get children () {
@@ -193,7 +209,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
193
209
  image_urls_: ()=>variantToShow()?.image_urls,
194
210
  video_: ()=>variantToShow()?.videos?.[0],
195
211
  configuredOptions_: configuredOptions_,
196
- cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered()
212
+ cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered(),
213
+ aspectRatio_: aspectRatio_
197
214
  });
198
215
  }
199
216
  }), null);
@@ -344,7 +361,7 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
344
361
  })();
345
362
  }
346
363
  }), null);
347
- (0, $2MCgq$effect)(()=>configuredOptions_().alignment != null ? _el$3.style.setProperty("--alignment", configuredOptions_().alignment) : _el$3.style.removeProperty("--alignment"));
364
+ (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$3, mainStyle(), _$p));
348
365
  return _el$3;
349
366
  }
350
367
  });
@@ -465,8 +482,11 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
465
482
  (0, $2MCgq$onCleanup)(()=>setContainsColorSwatches(false));
466
483
  return (()=>{
467
484
  var _el$4 = $29535f590238371c$var$_tmpl$5();
468
- var _ref$2 = ref_;
469
- typeof _ref$2 === "function" ? (0, $2MCgq$use)(_ref$2, _el$4) : ref_ = _el$4;
485
+ (0, $2MCgq$use)((el)=>{
486
+ ref_?.(el);
487
+ // Do like this so we don't override other styles set by AnimateRowSwitch
488
+ (0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(el.style, "--swatch-container-height", wantedContainerHeightRem_() && wantedContainerHeightRem_() + "rem"));
489
+ }, _el$4);
470
490
  (0, $2MCgq$insert)(_el$4, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
471
491
  get each () {
472
492
  return entriesToShow();
@@ -492,11 +512,11 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
492
512
  (0, $2MCgq$setAttribute)(_el$6, "href", pageUrl_);
493
513
  (0, $2MCgq$setAttribute)(_el$6, "title", colorName);
494
514
  (0, $2MCgq$effect)((_p$)=>{
495
- var _v$5 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$6 = !!(colorsAtIndex_?.[showVariantIndex_()] === colorName), _v$7 = !!thisColorIsDefaultColor(), _v$8 = !!($29535f590238371c$var$isLightColor(hexColor_) || invalidColor());
496
- _p$.e = (0, $2MCgq$style)(_el$6, _v$5, _p$.e);
497
- _v$6 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$6);
498
- _v$7 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$7);
499
- _v$8 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$8);
515
+ var _v$3 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$4 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$5 = !!thisColorIsDefaultColor(), _v$6 = !!($29535f590238371c$var$isLightColor(hexColor_) || invalidColor());
516
+ _p$.e = (0, $2MCgq$style)(_el$6, _v$3, _p$.e);
517
+ _v$4 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$4);
518
+ _v$5 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$5);
519
+ _v$6 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$6);
500
520
  return _p$;
501
521
  }, {
502
522
  e: undefined,
@@ -516,7 +536,6 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
516
536
  return $29535f590238371c$var$_tmpl$4();
517
537
  }
518
538
  }), null);
519
- (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$4, isNaN(wantedContainerHeightRem_()) ? "" : `--swatch-container-height:${wantedContainerHeightRem_()}rem`, _$p));
520
539
  return _el$4;
521
540
  })();
522
541
  })();
@@ -535,8 +554,11 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
535
554
  },
536
555
  get children () {
537
556
  var _el$7 = $29535f590238371c$var$_tmpl$8();
538
- var _ref$3 = ref_;
539
- typeof _ref$3 === "function" ? (0, $2MCgq$use)(_ref$3, _el$7) : ref_ = _el$7;
557
+ (0, $2MCgq$use)((el)=>{
558
+ ref_?.(el);
559
+ // Do like this so we don't override other styles set by AnimateRowSwitch
560
+ (0, $2MCgq$createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
561
+ }, _el$7);
540
562
  (0, $2MCgq$insert)(_el$7, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
541
563
  get each () {
542
564
  return $29535f590238371c$var$sortSizes(keysToShow());
@@ -569,29 +591,23 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
569
591
  return _el$8;
570
592
  }
571
593
  }), null);
572
- (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$7, `--font-size-rem:${fontSizeRem_()}rem`, _$p));
573
594
  return _el$7;
574
595
  }
575
596
  });
576
597
  }
577
- function $29535f590238371c$var$styleForTextOptions(options) {
578
- return {
579
- "--font-size-rem": options.font_size_rem + "rem",
580
- ...options.bold && {
581
- "--font-weight": "bold"
582
- },
583
- ...options.italic && {
584
- "--font-style": "italic"
585
- },
586
- ...options.color && {
587
- "--color": options.color
588
- },
589
- ...options.bg_color && {
590
- "--background": options.bg_color
591
- }
592
- };
598
+ function $29535f590238371c$var$setPropertyIfExists(style, property, value) {
599
+ if (value) style.setProperty(property, value);
600
+ else style.removeProperty(property);
601
+ }
602
+ function $29535f590238371c$var$setStyleForTextOptions({ style: style }, options) {
603
+ // Doing this instead of just using style={} because AnimatedRowSwitch needs to be able to set inline styling without it being overridden
604
+ (0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--font-size-rem", options().font_size_rem + "rem"));
605
+ (0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--font-weight", options().bold && "bold"));
606
+ (0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--font-style", options().italic && "italic"));
607
+ (0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--color", options().color));
608
+ (0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--background", options().bg_color));
593
609
  }
594
- function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_ }) {
610
+ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_ }) {
595
611
  const isAlreadyInSlider = !!(0, $2MCgq$useSlidableInformation)();
596
612
  const containerClasses = ()=>[
597
613
  "image-video",
@@ -602,38 +618,48 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
602
618
  const hoverImageDisabled = (0, $2MCgq$createMemo)(()=>!configuredOptions_().use_hover_image);
603
619
  const video_urls = ()=>video_()?.video_urls;
604
620
  const Container = (props)=>{
605
- if (slidable()) return (0, $2MCgq$createComponent)((0, $2MCgq$SlidableItems), {
606
- arrow_height_: 25,
607
- arrow_width_: 12.5,
608
- disable_fading_: true,
609
- slider_ref_: (slider)=>{
610
- const { container: container, insert_here: insert_here } = slider;
611
- slider.stepstoslide = 1; // In case anyone enables the hidden buttons using css
612
- (0, $2MCgq$createRenderEffect)((previous)=>(0, $2MCgq$classList)(container, {
613
- products: true,
614
- ...Object.fromEntries(containerClasses().map((cls)=>[
615
- cls,
616
- true
617
- ]))
618
- }, previous));
619
- // Scroll to beginning when changing what variant we're showing
620
- (0, $2MCgq$createEffect)((0, $2MCgq$on)(image_urls_, ()=>insert_here.scrollTo({
621
- left: 0,
622
- behavior: "auto"
623
- }), {
624
- defer: true
625
- }));
621
+ const resolved = (0, $2MCgq$children)(()=>props.children);
622
+ return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
623
+ get when () {
624
+ return slidable();
625
+ },
626
+ get fallback () {
627
+ return (()=>{
628
+ var _el$14 = $29535f590238371c$var$_tmpl$11();
629
+ (0, $2MCgq$insert)(_el$14, resolved);
630
+ (0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$14, containerClasses().join(" ")));
631
+ return _el$14;
632
+ })();
626
633
  },
627
634
  get children () {
628
- return props.children;
635
+ return (0, $2MCgq$createComponent)((0, $2MCgq$SlidableItems), {
636
+ arrow_height_: 25,
637
+ arrow_width_: 12.5,
638
+ disable_fading_: true,
639
+ slider_ref_: (slider)=>{
640
+ const { container: container, insert_here: insert_here } = slider;
641
+ slider.stepstoslide = 1; // In case anyone enables the hidden buttons using css
642
+ (0, $2MCgq$createRenderEffect)((previous)=>(0, $2MCgq$classList)(container, {
643
+ products: true,
644
+ ...Object.fromEntries(containerClasses().map((cls)=>[
645
+ cls,
646
+ true
647
+ ]))
648
+ }, previous));
649
+ // Scroll to beginning when changing what variant we're showing
650
+ (0, $2MCgq$createEffect)((0, $2MCgq$on)(image_urls_, ()=>insert_here.scrollTo({
651
+ left: 0,
652
+ behavior: "auto"
653
+ }), {
654
+ defer: true
655
+ }));
656
+ },
657
+ get children () {
658
+ return resolved();
659
+ }
660
+ });
629
661
  }
630
662
  });
631
- return (()=>{
632
- var _el$14 = $29535f590238371c$var$_tmpl$11();
633
- (0, $2MCgq$insert)(_el$14, ()=>props.children);
634
- (0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$14, containerClasses().join(" ")));
635
- return _el$14;
636
- })();
637
663
  };
638
664
  return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
639
665
  get when () {
@@ -641,7 +667,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
641
667
  },
642
668
  get fallback () {
643
669
  return (0, $2MCgq$createComponent)((0, $2MCgq$ImagePlaceholder), {
644
- aspectRatio: $29535f590238371c$var$imageAspectRatio
670
+ get aspectRatio () {
671
+ return aspectRatio_();
672
+ }
645
673
  });
646
674
  },
647
675
  get children () {
@@ -655,7 +683,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
655
683
  get children () {
656
684
  var _el$15 = $29535f590238371c$var$_tmpl$12();
657
685
  (0, $2MCgq$insert)(_el$15, (0, $2MCgq$createComponent)((0, $2MCgq$ImageContainer), {
658
- aspectRatio: $29535f590238371c$var$imageAspectRatio,
686
+ get aspectRatio () {
687
+ return aspectRatio_();
688
+ },
659
689
  get children () {
660
690
  return (0, $2MCgq$createComponent)($29535f590238371c$var$Video, {
661
691
  get video_sources_ () {
@@ -687,7 +717,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
687
717
  var _el$16 = $29535f590238371c$var$_tmpl$13();
688
718
  (0, $2MCgq$insert)(_el$16, (0, $2MCgq$createComponent)((0, $2MCgq$ShopifyContainedImage), {
689
719
  src: image_url,
690
- aspectRatio: $29535f590238371c$var$imageAspectRatio,
720
+ get aspectRatio () {
721
+ return aspectRatio_();
722
+ },
691
723
  imgProps: {
692
724
  alt: "Product image"
693
725
  }
@@ -701,7 +733,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
701
733
  get src () {
702
734
  return image_urls_()[1];
703
735
  },
704
- aspectRatio: $29535f590238371c$var$imageAspectRatio,
736
+ get aspectRatio () {
737
+ return aspectRatio_();
738
+ },
705
739
  imgProps: {
706
740
  alt: "Product image"
707
741
  },
@@ -828,6 +862,7 @@ function $29535f590238371c$var$Prices({ formatPrice_: formatPrice_, configuredOp
828
862
  return [
829
863
  (()=>{
830
864
  var _el$20 = $29535f590238371c$var$_tmpl$17();
865
+ (0, $2MCgq$use)((el)=>$29535f590238371c$var$setStyleForTextOptions(el, priceOptions), _el$20);
831
866
  (0, $2MCgq$insert)(_el$20, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
832
867
  get when () {
833
868
  return variantToShow_();
@@ -852,7 +887,6 @@ function $29535f590238371c$var$Prices({ formatPrice_: formatPrice_, configuredOp
852
887
  });
853
888
  }
854
889
  }));
855
- (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$20, $29535f590238371c$var$styleForTextOptions(priceOptions()), _$p));
856
890
  return _el$20;
857
891
  })(),
858
892
  (0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
@@ -866,8 +900,8 @@ function $29535f590238371c$var$Prices({ formatPrice_: formatPrice_, configuredOp
866
900
  " ",
867
901
  (()=>{
868
902
  var _el$21 = $29535f590238371c$var$_tmpl$18();
903
+ (0, $2MCgq$use)((el)=>$29535f590238371c$var$setStyleForTextOptions(el, originalPriceOptions), _el$21);
869
904
  (0, $2MCgq$insert)(_el$21, ()=>formatPrice_?.(originalPrice_()));
870
- (0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$21, $29535f590238371c$var$styleForTextOptions(originalPriceOptions()), _$p));
871
905
  return _el$21;
872
906
  })()
873
907
  ];
@@ -939,21 +973,19 @@ function $29535f590238371c$var$InComponentOrDiv(props) {
939
973
  const resolved = (0, $2MCgq$children)(()=>props.children);
940
974
  return (0, $2MCgq$createMemo)(()=>{
941
975
  const Component = props.component_;
942
- if (Component) return (0, $2MCgq$createComponent)(Component, {
943
- get ["class"] () {
976
+ if (Component) // Written like this because the JSX transform mutates our props object: https://github.com/ryansolid/dom-expressions/pull/316#issuecomment-2066925544
977
+ return (0, $2MCgq$createComponent)(Component, {
978
+ get class () {
944
979
  return props.class_;
945
980
  },
946
- ref (r$) {
947
- var _ref$4 = props.ref_;
948
- typeof _ref$4 === "function" ? _ref$4(r$) : props.ref_ = r$;
981
+ get ref () {
982
+ return props.ref_;
949
983
  },
950
- get children () {
951
- return resolved();
952
- }
984
+ children: resolved
953
985
  });
954
986
  return (()=>{
955
987
  var _el$22 = $29535f590238371c$var$_tmpl$11();
956
- (0, $2MCgq$use)((el)=>props.ref_?.(el), _el$22);
988
+ (0, $2MCgq$use)((el)=>props?.ref_?.(el), _el$22);
957
989
  (0, $2MCgq$insert)(_el$22, resolved);
958
990
  (0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$22, props.class_));
959
991
  return _el$22;
@@ -975,7 +1007,8 @@ function $474e9d712b745d60$export$d1a48be4967fe67c(react_props) {
975
1007
  formatPrice: (price)=>price && (0, $2MCgq$standard_price_format)(price)
976
1008
  }, ()=>props_store.options);
977
1009
  },
978
- props: react_props,
1010
+ // Work around in case https://github.com/solidjs/solid/issues/2139 potentially arises
1011
+ props: structuredClone(react_props),
979
1012
  className: "depict"
980
1013
  });
981
1014
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/portal-components",
3
- "version": "2.7.6",
3
+ "version": "2.7.8",
4
4
  "packageManager": "yarn@3.2.2",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
@@ -92,7 +92,7 @@
92
92
  "@types/node": "^18.11.11",
93
93
  "@types/react": "^18.0.26",
94
94
  "@types/react-dom": "^18.0.10",
95
- "babel-preset-solid": "^1.8.12",
95
+ "babel-preset-solid": "^1.8.16",
96
96
  "react": "^18.2.0",
97
97
  "react-dom": "^18.2.0",
98
98
  "ts-jest": "^29.0.5"
@@ -100,12 +100,12 @@
100
100
  "dependencies": {
101
101
  "@babel/runtime": "latest",
102
102
  "@babel/runtime-corejs3": "^7.22.6",
103
- "@depict-ai/plp-styling": "^4.4.11",
104
- "@depict-ai/react-ui": "^4.8.5",
105
- "@depict-ai/types": "^5.4.2",
106
- "@depict-ai/ui": "^4.8.13",
107
- "@depict-ai/utilishared": "^2.4.4",
103
+ "@depict-ai/plp-styling": "^4.4.13",
104
+ "@depict-ai/react-ui": "^4.8.6",
105
+ "@depict-ai/types": "^5.4.4",
106
+ "@depict-ai/ui": "^4.8.15",
107
+ "@depict-ai/utilishared": "^2.4.5",
108
108
  "parcel": "^2.10.3",
109
- "solid-js": "^1.8.12"
109
+ "solid-js": "^1.8.16"
110
110
  }
111
111
  }
@@ -1,40 +1,40 @@
1
1
  import {
2
+ ImageContainer,
2
3
  ImagePlaceholder,
4
+ media_query_to_accessor,
3
5
  ModernDisplayWithPageUrl,
4
6
  SDKRenderingInfo,
5
7
  ShopifyContainedImage,
8
+ SlidableItems,
6
9
  TextPlaceholder,
7
10
  useProductCardIndex,
8
11
  useProductCardIsVisible,
9
- SlidableItems,
10
- ImageContainer,
11
- media_query_to_accessor,
12
12
  useSlidableInformation,
13
13
  useVisibilityState,
14
14
  } from "@depict-ai/ui/latest";
15
- import { dlog, catchify, dwarn } from "@depict-ai/utilishared/latest";
15
+ import { catchify, dlog, dwarn } from "@depict-ai/utilishared/latest";
16
16
  import {
17
+ type Accessor,
18
+ children,
19
+ createContext,
20
+ createEffect,
21
+ createMemo,
22
+ createRenderEffect,
23
+ createResource,
24
+ createSignal,
25
+ For,
17
26
  type JSX,
27
+ on,
28
+ onCleanup,
18
29
  type Resource,
19
- type Signal,
20
- createResource,
30
+ type Setter,
21
31
  Show,
32
+ type Signal,
22
33
  Suspense,
23
- For,
24
- createEffect,
25
- createSignal,
26
- createMemo,
27
- type Setter,
28
- type Accessor,
29
34
  untrack,
30
- on,
31
- children,
32
- createRenderEffect,
33
- onCleanup,
34
35
  useContext,
35
- createContext,
36
36
  } from "solid-js";
37
- import { classList } from "solid-js/web";
37
+ import { classList, createComponent } from "solid-js/web";
38
38
  // You can import from the solid-js library here and leverage its reactivity to create an interactive UI.
39
39
  // Also, Depict packages can be imported (you must import /latest from those).
40
40
 
@@ -76,6 +76,7 @@ export type ProductCardSchema = {
76
76
  use_hover_image: boolean;
77
77
  /** Image Carousel */
78
78
  image_carousel: boolean;
79
+ image_aspect_ratio: number;
79
80
  };
80
81
 
81
82
  const sizeOrder = [
@@ -94,12 +95,9 @@ const sizeOrder = [
94
95
  "One Size",
95
96
  "Onesize",
96
97
  ];
97
- const imageAspectRatio = 1;
98
98
  const ContainsColorSwatchesContext = /*@__PURE__*/ createContext<Signal<boolean>>();
99
99
  let colorCanvasContext: CanvasRenderingContext2D | undefined | null;
100
100
 
101
- // Remove weird spaces around swatches
102
-
103
101
  /**
104
102
  * ProductCard built according to this excerpt of our SDK docs https://docs.depict.ai/js-ui-guide/setup/product-card
105
103
  */
@@ -148,6 +146,7 @@ export function DefaultSolidProductCard(
148
146
  use_hover_image: true,
149
147
  image_carousel: true,
150
148
  color_options: true,
149
+ image_aspect_ratio: 1,
151
150
  })
152
151
  ) {
153
152
  const variantDisplays = createMemo(() => display()?.variant_displays);
@@ -156,6 +155,10 @@ export function DefaultSolidProductCard(
156
155
  const [cardIsHovered, setCardIsHovered] = createSignal(false);
157
156
  const variantToShow = createMemo(() => variantDisplays()?.[showVariantIndex() as number]);
158
157
  const noHoverSupport_ = media_query_to_accessor("(hover: none)");
158
+ const [salePrice] = createResource(variantToShow, v => v?.sale_price);
159
+ const [originalPrice] = createResource(variantToShow, v => v?.original_price);
160
+ const onSale = createMemo(() => <Suspense>{originalPrice() !== salePrice()}</Suspense>);
161
+ const aspectRatio_ = createMemo(() => configuredOptions_().image_aspect_ratio);
159
162
  const sizesInStock_ = createMemo(
160
163
  () =>
161
164
  new Map(
@@ -183,10 +186,6 @@ export function DefaultSolidProductCard(
183
186
  .filter(([colorName]) => colorName) // in case color_name is null
184
187
  )
185
188
  );
186
- const [salePrice] = createResource(variantToShow, v => v?.sale_price);
187
- const [originalPrice] = createResource(variantToShow, v => v?.original_price);
188
- const onSale = createMemo(() => <Suspense>{originalPrice() !== salePrice()}</Suspense>);
189
-
190
189
  const swatchContainerHeight = createMemo(() => {
191
190
  // To avoid the product cards switching around as one hovers and price switches to the swatches, we have to make the swatches container have the same height as the price one
192
191
  let considerSize: number[] = [];
@@ -224,8 +223,10 @@ export function DefaultSolidProductCard(
224
223
  <div
225
224
  class="d-title line-clamp"
226
225
  title={variantToShow()?.title}
227
- style={styleForTextOptions(titleOptions())}
228
- ref={props.ref_}
226
+ ref={el => {
227
+ props.ref_?.(el);
228
+ setStyleForTextOptions(el, titleOptions);
229
+ }}
229
230
  >
230
231
  {variantToShow()?.title ?? (
231
232
  <>
@@ -235,6 +236,25 @@ export function DefaultSolidProductCard(
235
236
  )}
236
237
  </div>
237
238
  );
239
+ const mainStyle = () => {
240
+ const { alignment } = configuredOptions_();
241
+ let flexAlignment: "flex-start" | "flex-end" | "center";
242
+ switch (alignment) {
243
+ case "left":
244
+ flexAlignment = "flex-start";
245
+ break;
246
+ case "right":
247
+ flexAlignment = "flex-end";
248
+ break;
249
+ default:
250
+ flexAlignment = alignment;
251
+ break;
252
+ }
253
+ return { "--flex-alignment": flexAlignment, "--alignment": alignment };
254
+ };
255
+
256
+ createEffect(() => dlog("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
257
+ createEffect(() => dlog("Got passed display", JSON.parse(JSON.stringify(display()))));
238
258
 
239
259
  createEffect(() => noHoverSupport_() && setCardIsHovered(false));
240
260
 
@@ -242,7 +262,7 @@ export function DefaultSolidProductCard(
242
262
  <ContainsColorSwatchesProvider>
243
263
  <div
244
264
  class={`d-product-card`}
245
- style={{ "--alignment": configuredOptions_().alignment }}
265
+ style={mainStyle()}
246
266
  onMouseEnter={catchify(() => !noHoverSupport_() && setCardIsHovered(true))}
247
267
  onMouseLeave={catchify(() => !noHoverSupport_() && setCardIsHovered(false))}
248
268
  >
@@ -252,6 +272,7 @@ export function DefaultSolidProductCard(
252
272
  video_={() => variantToShow()?.videos?.[0]}
253
273
  configuredOptions_={configuredOptions_}
254
274
  cardIsHovered_={() => showVariantIndex() === display()?.variant_index && cardIsHovered()}
275
+ aspectRatio_={aspectRatio_}
255
276
  />
256
277
  </LinkWrapped>
257
278
  <Show
@@ -507,12 +528,17 @@ function ColorSwatches({
507
528
  return (
508
529
  <div
509
530
  class="d-swatches"
510
- ref={ref_}
511
- style={
512
- isNaN(wantedContainerHeightRem_() as number)
513
- ? ""
514
- : `--swatch-container-height:${wantedContainerHeightRem_()}rem`
515
- }
531
+ ref={el => {
532
+ ref_?.(el);
533
+ // Do like this so we don't override other styles set by AnimateRowSwitch
534
+ createEffect(() =>
535
+ setPropertyIfExists(
536
+ el.style,
537
+ "--swatch-container-height",
538
+ wantedContainerHeightRem_() && wantedContainerHeightRem_() + "rem"
539
+ )
540
+ );
541
+ }}
516
542
  >
517
543
  <For each={entriesToShow()}>
518
544
  {([colorName, { pageUrl_, hexColor_, variantIndex_ }]) => {
@@ -549,7 +575,7 @@ function ColorSwatches({
549
575
  // Value first take canvas color because it's more likely to exist for for example Aubergine
550
576
  style={`--background:${invalidColor() ? "white" : hexColor_}`}
551
577
  classList={{
552
- selected: colorsAtIndex_?.[showVariantIndex_()!] === colorName,
578
+ selected: colorsAtIndex_()?.[showVariantIndex_()!] === colorName,
553
579
  first: thisColorIsDefaultColor(),
554
580
  "light-colored": isLightColor(hexColor_) || invalidColor(),
555
581
  }}
@@ -584,7 +610,14 @@ function Sizes({
584
610
 
585
611
  return (
586
612
  <Show when={keysToShow().length > 1}>
587
- <div class="sizes" ref={ref_} style={`--font-size-rem:${fontSizeRem_()}rem`}>
613
+ <div
614
+ class="sizes"
615
+ ref={el => {
616
+ ref_?.(el);
617
+ // Do like this so we don't override other styles set by AnimateRowSwitch
618
+ createEffect(() => el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
619
+ }}
620
+ >
588
621
  <For each={sortSizes(keysToShow())}>
589
622
  {size => (
590
623
  <Show when={sizesInStock_().get(size)} fallback={<s>{size}</s>}>
@@ -600,14 +633,21 @@ function Sizes({
600
633
  );
601
634
  }
602
635
 
603
- function styleForTextOptions(options: TextOptions) {
604
- return {
605
- "--font-size-rem": options.font_size_rem + "rem",
606
- ...(options.bold && { "--font-weight": "bold" }),
607
- ...(options.italic && { "--font-style": "italic" }),
608
- ...(options.color && { "--color": options.color }),
609
- ...(options.bg_color && { "--background": options.bg_color }),
610
- };
636
+ function setPropertyIfExists(style: CSSStyleDeclaration, property: string, value?: string | false | 0) {
637
+ if (value) {
638
+ style.setProperty(property, value);
639
+ } else {
640
+ style.removeProperty(property);
641
+ }
642
+ }
643
+
644
+ function setStyleForTextOptions({ style }: HTMLElement, options: Accessor<TextOptions>) {
645
+ // Doing this instead of just using style={} because AnimatedRowSwitch needs to be able to set inline styling without it being overridden
646
+ createEffect(() => setPropertyIfExists(style, "--font-size-rem", options().font_size_rem + "rem"));
647
+ createEffect(() => setPropertyIfExists(style, "--font-weight", options().bold && "bold"));
648
+ createEffect(() => setPropertyIfExists(style, "--font-style", options().italic && "italic"));
649
+ createEffect(() => setPropertyIfExists(style, "--color", options().color));
650
+ createEffect(() => setPropertyIfExists(style, "--background", options().bg_color));
611
651
  }
612
652
 
613
653
  function ImagesAndVideos({
@@ -615,11 +655,13 @@ function ImagesAndVideos({
615
655
  video_,
616
656
  configuredOptions_,
617
657
  cardIsHovered_,
658
+ aspectRatio_,
618
659
  }: {
619
660
  image_urls_: Accessor<undefined | string[]>;
620
661
  video_: Accessor<undefined | { preview_image_url: string; video_urls: string[] }>;
621
662
  configuredOptions_: Accessor<ProductCardSchema>;
622
663
  cardIsHovered_: Accessor<boolean>;
664
+ aspectRatio_: Accessor<number>;
623
665
  }) {
624
666
  const isAlreadyInSlider = !!useSlidableInformation();
625
667
  const containerClasses = () => ["image-video", "border-radius-" + configuredOptions_().image_radius] as const;
@@ -627,9 +669,11 @@ function ImagesAndVideos({
627
669
  const slidable = createMemo(() => !isAlreadyInSlider && configuredOptions_().image_carousel);
628
670
  const hoverImageDisabled = createMemo(() => !configuredOptions_().use_hover_image);
629
671
  const video_urls = () => video_()?.video_urls;
672
+
630
673
  const Container = (props: { children: JSX.Element }) => {
631
- if (slidable()) {
632
- return (
674
+ const resolved = children(() => props.children);
675
+ return (
676
+ <Show when={slidable()} fallback={<div class={containerClasses().join(" ")}>{resolved()}</div>}>
633
677
  <SlidableItems
634
678
  arrow_height_={25}
635
679
  arrow_width_={12.5}
@@ -650,19 +694,18 @@ function ImagesAndVideos({
650
694
  createEffect(on(image_urls_, () => insert_here.scrollTo({ left: 0, behavior: "auto" }), { defer: true }));
651
695
  }}
652
696
  >
653
- {props.children}
697
+ {resolved()}
654
698
  </SlidableItems>
655
- );
656
- }
657
- return <div class={containerClasses().join(" ")}>{props.children}</div>;
699
+ </Show>
700
+ );
658
701
  };
659
702
 
660
703
  return (
661
- <Show when={image_urls_()} fallback={<ImagePlaceholder aspectRatio={imageAspectRatio} />}>
704
+ <Show when={image_urls_()} fallback={<ImagePlaceholder aspectRatio={aspectRatio_()} />}>
662
705
  <Container>
663
706
  <Show when={video_urls()?.length}>
664
707
  <div class="media-item video">
665
- <ImageContainer aspectRatio={imageAspectRatio}>
708
+ <ImageContainer aspectRatio={aspectRatio_()}>
666
709
  <Video
667
710
  video_sources_={video_urls() as [string, ...string[]]}
668
711
  poster_={video_()?.preview_image_url || image_urls_()?.[0]}
@@ -680,13 +723,13 @@ function ImagesAndVideos({
680
723
  {/* Hover to see JSDOc for ShopifyContainedImage */}
681
724
  <ShopifyContainedImage
682
725
  src={image_url}
683
- aspectRatio={imageAspectRatio}
726
+ aspectRatio={aspectRatio_()}
684
727
  imgProps={{ alt: "Product image" }}
685
728
  />
686
729
  <Show when={!index() && image_urls_()?.[1] && !hoverImageDisabled()}>
687
730
  <ShopifyContainedImage
688
731
  src={image_urls_()![1]}
689
- aspectRatio={imageAspectRatio}
732
+ aspectRatio={aspectRatio_()}
690
733
  imgProps={{ alt: "Product image" }}
691
734
  class={`hover${cardIsHovered_() ? " visible" : ""}`}
692
735
  />
@@ -806,7 +849,7 @@ function Prices({
806
849
  return (
807
850
  <Show when={priceOptions().enabled}>
808
851
  <InComponentOrDiv component_={wrapperComponent_()} class_="price-container" ref_={ref_}>
809
- <span class="price" style={styleForTextOptions(priceOptions())}>
852
+ <span class="price" ref={el => setStyleForTextOptions(el, priceOptions)}>
810
853
  <Show
811
854
  when={variantToShow_()}
812
855
  fallback={
@@ -825,7 +868,7 @@ function Prices({
825
868
  {/* Only show original price if it exists and deviates from the salePrice */}
826
869
  <Show when={originalPrice_() !== salePrice_() && originalPriceOptions().enabled}>
827
870
  {" "}
828
- <span class="original-price" style={styleForTextOptions(originalPriceOptions())}>
871
+ <span class="original-price" ref={el => setStyleForTextOptions(el, originalPriceOptions)}>
829
872
  {formatPrice_?.(originalPrice_())}
830
873
  </span>
831
874
  </Show>
@@ -919,14 +962,19 @@ function InComponentOrDiv(props: {
919
962
  return createMemo(() => {
920
963
  const Component = props.component_;
921
964
  if (Component) {
922
- return (
923
- <Component class={props.class_} ref={props.ref_}>
924
- {resolved()}
925
- </Component>
926
- );
965
+ // Written like this because the JSX transform mutates our props object: https://github.com/ryansolid/dom-expressions/pull/316#issuecomment-2066925544
966
+ return createComponent(Component, {
967
+ get class() {
968
+ return props.class_;
969
+ },
970
+ get ref() {
971
+ return props.ref_;
972
+ },
973
+ children: resolved as unknown as JSX.Element,
974
+ });
927
975
  }
928
976
  return (
929
- <div class={props.class_} ref={el => props.ref_?.(el)}>
977
+ <div class={props.class_} ref={el => props?.ref_?.(el)}>
930
978
  {resolved()}
931
979
  </div>
932
980
  );