@depict-ai/portal-components 2.7.17 → 2.7.19
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 +37 -1
- package/dist/main.js +114 -9
- package/dist/module.js +114 -11
- package/package.json +2 -2
- package/src/specialForShopify/DefaultSolidProductCard.tsx +37 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { ModernDisplay } from "@depict-ai/utilishared";
|
|
2
|
+
import { BaseProductListingConfig } from "@depict-ai/ui";
|
|
1
3
|
import { ModernDisplayWithPageUrl } from "@depict-ai/ui/latest";
|
|
2
4
|
import { SearchFilter } from "@depict-ai/types/api/SearchResponse";
|
|
3
5
|
import { Locale } from "@depict-ai/react-ui/locales/latest";
|
|
4
6
|
import { ReactNode } from "react";
|
|
5
7
|
import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
|
|
6
|
-
export const version = "2.7.
|
|
8
|
+
export const version = "2.7.19";
|
|
7
9
|
type TextOptions = {
|
|
8
10
|
/** Enabled */
|
|
9
11
|
enabled: boolean;
|
|
@@ -43,6 +45,40 @@ type ProductCardSchema = {
|
|
|
43
45
|
image_carousel: boolean;
|
|
44
46
|
image_aspect_ratio: number;
|
|
45
47
|
};
|
|
48
|
+
interface PortalRecsConfig<T extends ModernDisplay> extends BaseProductListingConfig {
|
|
49
|
+
/**
|
|
50
|
+
* A promise containing the recommendations to render, see https://docs.depict.ai/api-guide/recommendations/api-client/fetching
|
|
51
|
+
*/
|
|
52
|
+
recommendations: Promise<T[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Title to show when recommendations are being shown
|
|
55
|
+
*/
|
|
56
|
+
title?: string;
|
|
57
|
+
/**
|
|
58
|
+
* Config to use for the product card
|
|
59
|
+
*/
|
|
60
|
+
productCardConfig: ProductCardSchema;
|
|
61
|
+
}
|
|
62
|
+
interface PortalRecommendationGridConfig<T extends ModernDisplay> extends PortalRecsConfig<T> {
|
|
63
|
+
maxRows?: number;
|
|
64
|
+
viewMoreButton?: {
|
|
65
|
+
text: string;
|
|
66
|
+
startRows?: number;
|
|
67
|
+
rowsPerClick?: number;
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Copy-pasted RecommendationGrid from react-ui that's hardcoded to render the default product card
|
|
72
|
+
* By not wrapping the default product card in a react component again we get working placeholder (react's rendering delay otherwise makes them not show sometimes) and working <ListingContext> and therefore videos, correctly dosed sizes. etc
|
|
73
|
+
*/
|
|
74
|
+
export function PortalRecsGrid<T extends ModernDisplay>(props: Parameters<typeof SolidWrapper<T>>[0]): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
75
|
+
declare function SolidWrapper<T extends ModernDisplay>(props: PortalRecommendationGridConfig<T>): HTMLDivElement;
|
|
76
|
+
/**
|
|
77
|
+
* Copy-pasted RecommendationGrid from react-ui that's hardcoded to render the default product card
|
|
78
|
+
* By not wrapping the default product card in a react component again we get working placeholder (react's rendering delay otherwise makes them not show sometimes) and working <ListingContext> and therefore videos, correctly dosed sizes. etc
|
|
79
|
+
*/
|
|
80
|
+
export function PortalRecsSlider<T extends ModernDisplay>(props: Parameters<typeof _SolidWrapper1<T>>[0]): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
81
|
+
declare function _SolidWrapper1<T extends ModernDisplay>(props: PortalRecsConfig<T>): HTMLDivElement;
|
|
46
82
|
export function ReactDefaultProductCard(react_props: {
|
|
47
83
|
options?: ProductCardSchema;
|
|
48
84
|
display: null | ModernDisplayWithPageUrl<any>;
|
package/dist/main.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var $7jsgb$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest");
|
|
2
|
+
var $7jsgb$depictaiui = require("@depict-ai/ui");
|
|
2
3
|
var $7jsgb$solidjsweb = require("solid-js/web");
|
|
3
4
|
var $7jsgb$react = require("react");
|
|
4
5
|
var $7jsgb$solidjsstore = require("solid-js/store");
|
|
@@ -11,6 +12,8 @@ function $parcel$export(e, n, v, s) {
|
|
|
11
12
|
Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
$parcel$export(module.exports, "PortalRecsGrid", () => $9b4cfecb283dbb57$export$d20a7e68f6a71456);
|
|
16
|
+
$parcel$export(module.exports, "PortalRecsSlider", () => $1113a95ded76fc38$export$a640309a759938e9);
|
|
14
17
|
$parcel$export(module.exports, "ReactDefaultProductCard", () => $70cc6bd7e3f1dd4b$export$d1a48be4967fe67c);
|
|
15
18
|
$parcel$export(module.exports, "ReactSelectedFilters", () => $19e9e02e1e300b6d$export$aea1707d7b01c3a2);
|
|
16
19
|
$parcel$export(module.exports, "ReactFilterBody", () => $240090d16a629bfe$export$d929db7fb6179159);
|
|
@@ -18,7 +21,8 @@ $parcel$export(module.exports, "ExpandingSection", () => $2214dc111b9e2866$expor
|
|
|
18
21
|
$parcel$export(module.exports, "ReactLookCard", () => $35bab9ff48bfe404$export$48787da2a5568bc);
|
|
19
22
|
$parcel$export(module.exports, "version", () => $0a017be3a74fcc94$export$83d89fbfd8236492);
|
|
20
23
|
/*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
|
|
21
|
-
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.
|
|
24
|
+
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.19";
|
|
25
|
+
|
|
22
26
|
|
|
23
27
|
|
|
24
28
|
|
|
@@ -96,6 +100,7 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
96
100
|
const defaultVariantIndex = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_index);
|
|
97
101
|
const [showVariantIndex, setShowVariantIndex] = (0, $7jsgb$solidjs.createSignal)((0, $7jsgb$solidjs.untrack)(defaultVariantIndex));
|
|
98
102
|
const [cardIsHovered, setCardIsHovered] = (0, $7jsgb$solidjs.createSignal)(false);
|
|
103
|
+
const [widthAvailableForSizes, setWidthAvailableForSizes] = (0, $7jsgb$solidjs.createSignal)();
|
|
99
104
|
const variantToShow = (0, $7jsgb$solidjs.createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
|
|
100
105
|
const noHoverSupport_ = (0, $7jsgb$depictaiuilatest.media_query_to_accessor)("(hover: none)");
|
|
101
106
|
const [salePrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.sale_price);
|
|
@@ -195,7 +200,7 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
195
200
|
(0, $7jsgb$solidjs.createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
196
201
|
// For switch from placeholders to product
|
|
197
202
|
(0, $7jsgb$solidjs.createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
|
|
198
|
-
|
|
203
|
+
const element = (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$ContainsColorSwatchesProvider, {
|
|
199
204
|
get children () {
|
|
200
205
|
var _el$3 = $3375ddd88f77967d$var$_tmpl$3();
|
|
201
206
|
(0, $7jsgb$solidjsweb.addEventListener)(_el$3, "mouseleave", (0, $7jsgb$depictaiutilisharedlatest.catchify)(()=>!noHoverSupport_() && setCardIsHovered(false)));
|
|
@@ -259,7 +264,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
259
264
|
get children () {
|
|
260
265
|
return (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$Sizes, {
|
|
261
266
|
sizesInStock_: sizesInStock_,
|
|
262
|
-
fontSizeRem_: ()=>titleOptions().font_size_rem
|
|
267
|
+
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
268
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
263
269
|
});
|
|
264
270
|
}
|
|
265
271
|
});
|
|
@@ -284,7 +290,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
284
290
|
HoveredComponent_: ({ ref_: ref_ })=>(0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$Sizes, {
|
|
285
291
|
sizesInStock_: sizesInStock_,
|
|
286
292
|
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
287
|
-
ref_: ref_
|
|
293
|
+
ref_: ref_,
|
|
294
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
288
295
|
}),
|
|
289
296
|
cardIsHovered_: cardIsHovered,
|
|
290
297
|
containerComponent_: ()=>containsColorSwatches() && LinkWrapped
|
|
@@ -363,6 +370,13 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
363
370
|
return _el$3;
|
|
364
371
|
}
|
|
365
372
|
});
|
|
373
|
+
// Now that we have created the ShopifyContainedImage, we can hook into its resize observer to know how many sizes we can fit into the size container
|
|
374
|
+
const context = (0, $7jsgb$depictaiuilatest.useListing)();
|
|
375
|
+
if (context) {
|
|
376
|
+
const signal = context[0, $7jsgb$depictaiuilatest.shopifyContainedImageContextSymbol];
|
|
377
|
+
(0, $7jsgb$solidjs.createEffect)(()=>setWidthAvailableForSizes(signal?.[0]?.()?.[0]?.()));
|
|
378
|
+
}
|
|
379
|
+
return element;
|
|
366
380
|
}
|
|
367
381
|
/**
|
|
368
382
|
* Transitions between DefaultComponent_ and HoveredComponent_ when cardIsHovered_ changes in both height and opacity.
|
|
@@ -540,12 +554,19 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
540
554
|
}
|
|
541
555
|
});
|
|
542
556
|
}
|
|
543
|
-
function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_ }) {
|
|
544
|
-
const keys = ()=>[
|
|
557
|
+
function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_, widthAvailableForSizes_: widthAvailableForSizes_ }) {
|
|
558
|
+
const keys = (0, $7jsgb$solidjs.createMemo)(()=>[
|
|
545
559
|
...sizesInStock_().keys()
|
|
546
|
-
];
|
|
547
|
-
const
|
|
548
|
-
const
|
|
560
|
+
]);
|
|
561
|
+
const gap = (0, $7jsgb$solidjs.createMemo)(()=>widthAvailableForSizes_() <= 250 ? 12 : 16);
|
|
562
|
+
const showMax = (0, $7jsgb$solidjs.createMemo)(()=>{
|
|
563
|
+
const fontSizeCircaPx = fontSizeRem_() * 16;
|
|
564
|
+
const availableWidth = widthAvailableForSizes_();
|
|
565
|
+
if (availableWidth && availableWidth < fontSizeCircaPx * 7 + gap() * 7 && keys().length > 4) return 2;
|
|
566
|
+
return 7;
|
|
567
|
+
});
|
|
568
|
+
const keysToShow = (0, $7jsgb$solidjs.createMemo)(()=>keys().slice(0, showMax()));
|
|
569
|
+
const hidden = (0, $7jsgb$solidjs.createMemo)(()=>keys().length - keysToShow().length);
|
|
549
570
|
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
550
571
|
get when () {
|
|
551
572
|
return keysToShow().length > 1;
|
|
@@ -556,6 +577,7 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
556
577
|
ref_?.(el);
|
|
557
578
|
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
558
579
|
(0, $7jsgb$solidjs.createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
580
|
+
(0, $7jsgb$solidjs.createEffect)(()=>el.style.setProperty("--sizes-gap", gap() + "px"));
|
|
559
581
|
}, _el$7);
|
|
560
582
|
(0, $7jsgb$solidjsweb.insert)(_el$7, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
|
|
561
583
|
get each () {
|
|
@@ -589,6 +611,7 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
589
611
|
return _el$8;
|
|
590
612
|
}
|
|
591
613
|
}), null);
|
|
614
|
+
(0, $7jsgb$solidjsweb.effect)(()=>_el$7.classList.toggle("small", !!(widthAvailableForSizes_() < 250)));
|
|
592
615
|
return _el$7;
|
|
593
616
|
}
|
|
594
617
|
});
|
|
@@ -996,6 +1019,88 @@ function $3375ddd88f77967d$var$InComponentOrDiv(props) {
|
|
|
996
1019
|
|
|
997
1020
|
|
|
998
1021
|
|
|
1022
|
+
function $9b4cfecb283dbb57$export$d20a7e68f6a71456(props) {
|
|
1023
|
+
return (0, $d38f1fd3cc4cd6b2$export$f6e64e17bd69eeef)({
|
|
1024
|
+
solid_component: $9b4cfecb283dbb57$export$ef681ece395f74,
|
|
1025
|
+
props: props,
|
|
1026
|
+
wrapper_type: "section"
|
|
1027
|
+
});
|
|
1028
|
+
}
|
|
1029
|
+
function $9b4cfecb283dbb57$export$ef681ece395f74(props) {
|
|
1030
|
+
return (0, $7jsgb$depictaiui.RecommendationGrid)({
|
|
1031
|
+
get recommendations () {
|
|
1032
|
+
return props.recommendations;
|
|
1033
|
+
},
|
|
1034
|
+
product_card_template: (display, info)=>{
|
|
1035
|
+
return (0, $3375ddd88f77967d$export$f11681c54c860912)(()=>display, info && {
|
|
1036
|
+
...info,
|
|
1037
|
+
depictCardsDataset: {},
|
|
1038
|
+
formatPrice: (price)=>price && (0, $7jsgb$depictaiutilisharedlatest.standard_price_format)(price)
|
|
1039
|
+
}, ()=>props.productCardConfig);
|
|
1040
|
+
},
|
|
1041
|
+
get cols_at_size () {
|
|
1042
|
+
return props.columnsAtSize || (0, $7jsgb$depictaiui.defaultColsAtSize);
|
|
1043
|
+
},
|
|
1044
|
+
get grid_spacing () {
|
|
1045
|
+
return props.gridSpacing ?? (0, $7jsgb$depictaiui.defaultGridSpacing);
|
|
1046
|
+
},
|
|
1047
|
+
get max_rows () {
|
|
1048
|
+
return props.maxRows;
|
|
1049
|
+
},
|
|
1050
|
+
get title () {
|
|
1051
|
+
return props.title;
|
|
1052
|
+
},
|
|
1053
|
+
get view_more_button () {
|
|
1054
|
+
const { viewMoreButton: viewMoreButton } = props;
|
|
1055
|
+
return viewMoreButton ? {
|
|
1056
|
+
text: viewMoreButton.text,
|
|
1057
|
+
start_rows: viewMoreButton.startRows ?? 2,
|
|
1058
|
+
rows_per_click: viewMoreButton.rowsPerClick
|
|
1059
|
+
} : undefined;
|
|
1060
|
+
}
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
|
|
1065
|
+
|
|
1066
|
+
|
|
1067
|
+
|
|
1068
|
+
|
|
1069
|
+
function $1113a95ded76fc38$export$a640309a759938e9(props) {
|
|
1070
|
+
return (0, $d38f1fd3cc4cd6b2$export$f6e64e17bd69eeef)({
|
|
1071
|
+
solid_component: $1113a95ded76fc38$var$SolidWrapper,
|
|
1072
|
+
props: props,
|
|
1073
|
+
wrapper_type: "section"
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
function $1113a95ded76fc38$var$SolidWrapper(props) {
|
|
1077
|
+
return (0, $7jsgb$depictaiui.RecommendationSlider)({
|
|
1078
|
+
get recommendations () {
|
|
1079
|
+
return props.recommendations;
|
|
1080
|
+
},
|
|
1081
|
+
product_card_template: (display, info)=>{
|
|
1082
|
+
return (0, $3375ddd88f77967d$export$f11681c54c860912)(()=>display, info && {
|
|
1083
|
+
...info,
|
|
1084
|
+
depictCardsDataset: {},
|
|
1085
|
+
formatPrice: (price)=>price && (0, $7jsgb$depictaiutilisharedlatest.standard_price_format)(price)
|
|
1086
|
+
}, ()=>props.productCardConfig);
|
|
1087
|
+
},
|
|
1088
|
+
get cols_at_size () {
|
|
1089
|
+
return props.columnsAtSize || (0, $7jsgb$depictaiui.defaultColsAtSize);
|
|
1090
|
+
},
|
|
1091
|
+
get grid_spacing () {
|
|
1092
|
+
return props.gridSpacing ?? (0, $7jsgb$depictaiui.defaultGridSpacing);
|
|
1093
|
+
},
|
|
1094
|
+
get title () {
|
|
1095
|
+
return props.title;
|
|
1096
|
+
}
|
|
1097
|
+
});
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
|
|
1101
|
+
|
|
1102
|
+
|
|
1103
|
+
|
|
999
1104
|
function $70cc6bd7e3f1dd4b$export$d1a48be4967fe67c(react_props) {
|
|
1000
1105
|
return (0, $d38f1fd3cc4cd6b2$export$f6e64e17bd69eeef)({
|
|
1001
1106
|
solid_component: (props_store)=>{
|
package/dist/module.js
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
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 {RecommendationGrid as $2MCgq$RecommendationGrid, defaultColsAtSize as $2MCgq$defaultColsAtSize, defaultGridSpacing as $2MCgq$defaultGridSpacing, RecommendationSlider as $2MCgq$RecommendationSlider} from "@depict-ai/ui";
|
|
2
3
|
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
4
|
import {useRef as $2MCgq$useRef, useState as $2MCgq$useState, useEffect as $2MCgq$useEffect, createElement as $2MCgq$createElement, Fragment as $2MCgq$Fragment} from "react";
|
|
4
5
|
import {createStore as $2MCgq$createStore, reconcile as $2MCgq$reconcile} from "solid-js/store";
|
|
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";
|
|
6
|
+
import {media_query_to_accessor as $2MCgq$media_query_to_accessor, TextPlaceholder as $2MCgq$TextPlaceholder, useListing as $2MCgq$useListing, shopifyContainedImageContextSymbol as $2MCgq$shopifyContainedImageContextSymbol, 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";
|
|
6
7
|
import {createContext as $2MCgq$createContext, createMemo as $2MCgq$createMemo, createSignal as $2MCgq$createSignal, untrack as $2MCgq$untrack, createResource as $2MCgq$createResource, Suspense as $2MCgq$Suspense, createEffect as $2MCgq$createEffect, children as $2MCgq$children, Show as $2MCgq$Show, onCleanup as $2MCgq$onCleanup, For as $2MCgq$For, createRenderEffect as $2MCgq$createRenderEffect, on as $2MCgq$on, useContext as $2MCgq$useContext} from "solid-js";
|
|
7
8
|
import {createPortal as $2MCgq$createPortal} from "react-dom";
|
|
8
9
|
|
|
9
10
|
/*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
|
|
10
|
-
const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.
|
|
11
|
+
const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.19";
|
|
12
|
+
|
|
11
13
|
|
|
12
14
|
|
|
13
15
|
|
|
@@ -85,6 +87,7 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
85
87
|
const defaultVariantIndex = (0, $2MCgq$createMemo)(()=>display()?.variant_index);
|
|
86
88
|
const [showVariantIndex, setShowVariantIndex] = (0, $2MCgq$createSignal)((0, $2MCgq$untrack)(defaultVariantIndex));
|
|
87
89
|
const [cardIsHovered, setCardIsHovered] = (0, $2MCgq$createSignal)(false);
|
|
90
|
+
const [widthAvailableForSizes, setWidthAvailableForSizes] = (0, $2MCgq$createSignal)();
|
|
88
91
|
const variantToShow = (0, $2MCgq$createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
|
|
89
92
|
const noHoverSupport_ = (0, $2MCgq$media_query_to_accessor)("(hover: none)");
|
|
90
93
|
const [salePrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.sale_price);
|
|
@@ -184,7 +187,7 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
184
187
|
(0, $2MCgq$createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
185
188
|
// For switch from placeholders to product
|
|
186
189
|
(0, $2MCgq$createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
|
|
187
|
-
|
|
190
|
+
const element = (0, $2MCgq$createComponent)($29535f590238371c$var$ContainsColorSwatchesProvider, {
|
|
188
191
|
get children () {
|
|
189
192
|
var _el$3 = $29535f590238371c$var$_tmpl$3();
|
|
190
193
|
(0, $2MCgq$addEventListener)(_el$3, "mouseleave", (0, $2MCgq$catchify)(()=>!noHoverSupport_() && setCardIsHovered(false)));
|
|
@@ -248,7 +251,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
248
251
|
get children () {
|
|
249
252
|
return (0, $2MCgq$createComponent)($29535f590238371c$var$Sizes, {
|
|
250
253
|
sizesInStock_: sizesInStock_,
|
|
251
|
-
fontSizeRem_: ()=>titleOptions().font_size_rem
|
|
254
|
+
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
255
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
252
256
|
});
|
|
253
257
|
}
|
|
254
258
|
});
|
|
@@ -273,7 +277,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
273
277
|
HoveredComponent_: ({ ref_: ref_ })=>(0, $2MCgq$createComponent)($29535f590238371c$var$Sizes, {
|
|
274
278
|
sizesInStock_: sizesInStock_,
|
|
275
279
|
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
276
|
-
ref_: ref_
|
|
280
|
+
ref_: ref_,
|
|
281
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
277
282
|
}),
|
|
278
283
|
cardIsHovered_: cardIsHovered,
|
|
279
284
|
containerComponent_: ()=>containsColorSwatches() && LinkWrapped
|
|
@@ -352,6 +357,13 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
352
357
|
return _el$3;
|
|
353
358
|
}
|
|
354
359
|
});
|
|
360
|
+
// Now that we have created the ShopifyContainedImage, we can hook into its resize observer to know how many sizes we can fit into the size container
|
|
361
|
+
const context = (0, $2MCgq$useListing)();
|
|
362
|
+
if (context) {
|
|
363
|
+
const signal = context[0, $2MCgq$shopifyContainedImageContextSymbol];
|
|
364
|
+
(0, $2MCgq$createEffect)(()=>setWidthAvailableForSizes(signal?.[0]?.()?.[0]?.()));
|
|
365
|
+
}
|
|
366
|
+
return element;
|
|
355
367
|
}
|
|
356
368
|
/**
|
|
357
369
|
* Transitions between DefaultComponent_ and HoveredComponent_ when cardIsHovered_ changes in both height and opacity.
|
|
@@ -529,12 +541,19 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
529
541
|
}
|
|
530
542
|
});
|
|
531
543
|
}
|
|
532
|
-
function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_ }) {
|
|
533
|
-
const keys = ()=>[
|
|
544
|
+
function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_, widthAvailableForSizes_: widthAvailableForSizes_ }) {
|
|
545
|
+
const keys = (0, $2MCgq$createMemo)(()=>[
|
|
534
546
|
...sizesInStock_().keys()
|
|
535
|
-
];
|
|
536
|
-
const
|
|
537
|
-
const
|
|
547
|
+
]);
|
|
548
|
+
const gap = (0, $2MCgq$createMemo)(()=>widthAvailableForSizes_() <= 250 ? 12 : 16);
|
|
549
|
+
const showMax = (0, $2MCgq$createMemo)(()=>{
|
|
550
|
+
const fontSizeCircaPx = fontSizeRem_() * 16;
|
|
551
|
+
const availableWidth = widthAvailableForSizes_();
|
|
552
|
+
if (availableWidth && availableWidth < fontSizeCircaPx * 7 + gap() * 7 && keys().length > 4) return 2;
|
|
553
|
+
return 7;
|
|
554
|
+
});
|
|
555
|
+
const keysToShow = (0, $2MCgq$createMemo)(()=>keys().slice(0, showMax()));
|
|
556
|
+
const hidden = (0, $2MCgq$createMemo)(()=>keys().length - keysToShow().length);
|
|
538
557
|
return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
539
558
|
get when () {
|
|
540
559
|
return keysToShow().length > 1;
|
|
@@ -545,6 +564,7 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
545
564
|
ref_?.(el);
|
|
546
565
|
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
547
566
|
(0, $2MCgq$createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
567
|
+
(0, $2MCgq$createEffect)(()=>el.style.setProperty("--sizes-gap", gap() + "px"));
|
|
548
568
|
}, _el$7);
|
|
549
569
|
(0, $2MCgq$insert)(_el$7, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
|
|
550
570
|
get each () {
|
|
@@ -578,6 +598,7 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
578
598
|
return _el$8;
|
|
579
599
|
}
|
|
580
600
|
}), null);
|
|
601
|
+
(0, $2MCgq$effect)(()=>_el$7.classList.toggle("small", !!(widthAvailableForSizes_() < 250)));
|
|
581
602
|
return _el$7;
|
|
582
603
|
}
|
|
583
604
|
});
|
|
@@ -985,6 +1006,88 @@ function $29535f590238371c$var$InComponentOrDiv(props) {
|
|
|
985
1006
|
|
|
986
1007
|
|
|
987
1008
|
|
|
1009
|
+
function $8ade1943efc108c6$export$d20a7e68f6a71456(props) {
|
|
1010
|
+
return (0, $0fe03f2fcd2418f8$export$f6e64e17bd69eeef)({
|
|
1011
|
+
solid_component: $8ade1943efc108c6$export$ef681ece395f74,
|
|
1012
|
+
props: props,
|
|
1013
|
+
wrapper_type: "section"
|
|
1014
|
+
});
|
|
1015
|
+
}
|
|
1016
|
+
function $8ade1943efc108c6$export$ef681ece395f74(props) {
|
|
1017
|
+
return (0, $2MCgq$RecommendationGrid)({
|
|
1018
|
+
get recommendations () {
|
|
1019
|
+
return props.recommendations;
|
|
1020
|
+
},
|
|
1021
|
+
product_card_template: (display, info)=>{
|
|
1022
|
+
return (0, $29535f590238371c$export$f11681c54c860912)(()=>display, info && {
|
|
1023
|
+
...info,
|
|
1024
|
+
depictCardsDataset: {},
|
|
1025
|
+
formatPrice: (price)=>price && (0, $2MCgq$standard_price_format)(price)
|
|
1026
|
+
}, ()=>props.productCardConfig);
|
|
1027
|
+
},
|
|
1028
|
+
get cols_at_size () {
|
|
1029
|
+
return props.columnsAtSize || (0, $2MCgq$defaultColsAtSize);
|
|
1030
|
+
},
|
|
1031
|
+
get grid_spacing () {
|
|
1032
|
+
return props.gridSpacing ?? (0, $2MCgq$defaultGridSpacing);
|
|
1033
|
+
},
|
|
1034
|
+
get max_rows () {
|
|
1035
|
+
return props.maxRows;
|
|
1036
|
+
},
|
|
1037
|
+
get title () {
|
|
1038
|
+
return props.title;
|
|
1039
|
+
},
|
|
1040
|
+
get view_more_button () {
|
|
1041
|
+
const { viewMoreButton: viewMoreButton } = props;
|
|
1042
|
+
return viewMoreButton ? {
|
|
1043
|
+
text: viewMoreButton.text,
|
|
1044
|
+
start_rows: viewMoreButton.startRows ?? 2,
|
|
1045
|
+
rows_per_click: viewMoreButton.rowsPerClick
|
|
1046
|
+
} : undefined;
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
|
|
1052
|
+
|
|
1053
|
+
|
|
1054
|
+
|
|
1055
|
+
|
|
1056
|
+
function $e3716493302f533c$export$a640309a759938e9(props) {
|
|
1057
|
+
return (0, $0fe03f2fcd2418f8$export$f6e64e17bd69eeef)({
|
|
1058
|
+
solid_component: $e3716493302f533c$var$SolidWrapper,
|
|
1059
|
+
props: props,
|
|
1060
|
+
wrapper_type: "section"
|
|
1061
|
+
});
|
|
1062
|
+
}
|
|
1063
|
+
function $e3716493302f533c$var$SolidWrapper(props) {
|
|
1064
|
+
return (0, $2MCgq$RecommendationSlider)({
|
|
1065
|
+
get recommendations () {
|
|
1066
|
+
return props.recommendations;
|
|
1067
|
+
},
|
|
1068
|
+
product_card_template: (display, info)=>{
|
|
1069
|
+
return (0, $29535f590238371c$export$f11681c54c860912)(()=>display, info && {
|
|
1070
|
+
...info,
|
|
1071
|
+
depictCardsDataset: {},
|
|
1072
|
+
formatPrice: (price)=>price && (0, $2MCgq$standard_price_format)(price)
|
|
1073
|
+
}, ()=>props.productCardConfig);
|
|
1074
|
+
},
|
|
1075
|
+
get cols_at_size () {
|
|
1076
|
+
return props.columnsAtSize || (0, $2MCgq$defaultColsAtSize);
|
|
1077
|
+
},
|
|
1078
|
+
get grid_spacing () {
|
|
1079
|
+
return props.gridSpacing ?? (0, $2MCgq$defaultGridSpacing);
|
|
1080
|
+
},
|
|
1081
|
+
get title () {
|
|
1082
|
+
return props.title;
|
|
1083
|
+
}
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
|
|
1087
|
+
|
|
1088
|
+
|
|
1089
|
+
|
|
1090
|
+
|
|
988
1091
|
function $474e9d712b745d60$export$d1a48be4967fe67c(react_props) {
|
|
989
1092
|
return (0, $0fe03f2fcd2418f8$export$f6e64e17bd69eeef)({
|
|
990
1093
|
solid_component: (props_store)=>{
|
|
@@ -1226,4 +1329,4 @@ function $8a700ff0722c56b3$export$48787da2a5568bc(react_props) {
|
|
|
1226
1329
|
(0, $2MCgq$add_to_version_info)("react-ui", (0, $91c11b750e80ede3$export$83d89fbfd8236492));
|
|
1227
1330
|
|
|
1228
1331
|
|
|
1229
|
-
export {$474e9d712b745d60$export$d1a48be4967fe67c as ReactDefaultProductCard, $0cb1638b3c084153$export$aea1707d7b01c3a2 as ReactSelectedFilters, $890b58a81f64b470$export$d929db7fb6179159 as ReactFilterBody, $c79c5cb5e9424dd7$export$4ea53cd12ff17334 as ExpandingSection, $8a700ff0722c56b3$export$48787da2a5568bc as ReactLookCard, $91c11b750e80ede3$export$83d89fbfd8236492 as version};
|
|
1332
|
+
export {$8ade1943efc108c6$export$d20a7e68f6a71456 as PortalRecsGrid, $e3716493302f533c$export$a640309a759938e9 as PortalRecsSlider, $474e9d712b745d60$export$d1a48be4967fe67c as ReactDefaultProductCard, $0cb1638b3c084153$export$aea1707d7b01c3a2 as ReactSelectedFilters, $890b58a81f64b470$export$d929db7fb6179159 as ReactFilterBody, $c79c5cb5e9424dd7$export$4ea53cd12ff17334 as ExpandingSection, $8a700ff0722c56b3$export$48787da2a5568bc as ReactLookCard, $91c11b750e80ede3$export$83d89fbfd8236492 as version};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depict-ai/portal-components",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.19",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@babel/runtime": "latest",
|
|
103
103
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
104
|
-
"@depict-ai/plp-styling": "^4.4.
|
|
104
|
+
"@depict-ai/plp-styling": "^4.4.18",
|
|
105
105
|
"@depict-ai/react-ui": "^4.8.6",
|
|
106
106
|
"@depict-ai/types": "^5.4.4",
|
|
107
107
|
"@depict-ai/ui": "^4.8.16",
|
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
useProductCardIsVisible,
|
|
12
12
|
useSlidableInformation,
|
|
13
13
|
useVisibilityState,
|
|
14
|
+
shopifyContainedImageContextSymbol,
|
|
15
|
+
useListing,
|
|
14
16
|
} from "@depict-ai/ui/latest";
|
|
15
17
|
import { catchify, dlog, dwarn } from "@depict-ai/utilishared/latest";
|
|
16
18
|
import {
|
|
@@ -137,6 +139,7 @@ export function DefaultSolidProductCard(
|
|
|
137
139
|
const defaultVariantIndex = createMemo(() => display()?.variant_index);
|
|
138
140
|
const [showVariantIndex, setShowVariantIndex] = createSignal<number | undefined>(untrack(defaultVariantIndex));
|
|
139
141
|
const [cardIsHovered, setCardIsHovered] = createSignal(false);
|
|
142
|
+
const [widthAvailableForSizes, setWidthAvailableForSizes] = createSignal<number | undefined>();
|
|
140
143
|
const variantToShow = createMemo(() => variantDisplays()?.[showVariantIndex() as number]);
|
|
141
144
|
const noHoverSupport_ = media_query_to_accessor("(hover: none)");
|
|
142
145
|
const [salePrice] = createResource(variantToShow, v => v?.sale_price);
|
|
@@ -247,7 +250,7 @@ export function DefaultSolidProductCard(
|
|
|
247
250
|
() => !showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex())
|
|
248
251
|
);
|
|
249
252
|
|
|
250
|
-
|
|
253
|
+
const element = (
|
|
251
254
|
<ContainsColorSwatchesProvider>
|
|
252
255
|
<div
|
|
253
256
|
class={`d-product-card`}
|
|
@@ -289,7 +292,11 @@ export function DefaultSolidProductCard(
|
|
|
289
292
|
fallback={
|
|
290
293
|
<Show when={configuredOptions_().sizes}>
|
|
291
294
|
<LinkWrappedIfHaveSwatches>
|
|
292
|
-
<Sizes
|
|
295
|
+
<Sizes
|
|
296
|
+
sizesInStock_={sizesInStock_}
|
|
297
|
+
fontSizeRem_={() => titleOptions().font_size_rem}
|
|
298
|
+
widthAvailableForSizes_={widthAvailableForSizes}
|
|
299
|
+
/>
|
|
293
300
|
</LinkWrappedIfHaveSwatches>
|
|
294
301
|
</Show>
|
|
295
302
|
}
|
|
@@ -309,6 +316,7 @@ export function DefaultSolidProductCard(
|
|
|
309
316
|
sizesInStock_={sizesInStock_}
|
|
310
317
|
fontSizeRem_={() => titleOptions().font_size_rem}
|
|
311
318
|
ref_={ref_}
|
|
319
|
+
widthAvailableForSizes_={widthAvailableForSizes}
|
|
312
320
|
/>
|
|
313
321
|
)}
|
|
314
322
|
cardIsHovered_={cardIsHovered}
|
|
@@ -379,6 +387,17 @@ export function DefaultSolidProductCard(
|
|
|
379
387
|
</div>
|
|
380
388
|
</ContainsColorSwatchesProvider>
|
|
381
389
|
);
|
|
390
|
+
|
|
391
|
+
// Now that we have created the ShopifyContainedImage, we can hook into its resize observer to know how many sizes we can fit into the size container
|
|
392
|
+
const context = useListing();
|
|
393
|
+
if (context) {
|
|
394
|
+
const signal = context[shopifyContainedImageContextSymbol] as
|
|
395
|
+
| Signal<[Accessor<number>, Accessor<number>] | undefined>
|
|
396
|
+
| undefined;
|
|
397
|
+
createEffect(() => setWidthAvailableForSizes(signal?.[0]?.()?.[0]?.()));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return element;
|
|
382
401
|
}
|
|
383
402
|
|
|
384
403
|
/**
|
|
@@ -586,23 +605,36 @@ function Sizes({
|
|
|
586
605
|
sizesInStock_,
|
|
587
606
|
ref_,
|
|
588
607
|
fontSizeRem_,
|
|
608
|
+
widthAvailableForSizes_,
|
|
589
609
|
}: {
|
|
590
610
|
sizesInStock_: Accessor<Map<string, boolean>>;
|
|
591
611
|
ref_?: (el: HTMLDivElement) => void;
|
|
592
612
|
fontSizeRem_: Accessor<number>;
|
|
613
|
+
widthAvailableForSizes_: Accessor<number | undefined>;
|
|
593
614
|
}) {
|
|
594
|
-
const keys = () => [...sizesInStock_().keys()];
|
|
595
|
-
const
|
|
596
|
-
const
|
|
615
|
+
const keys = createMemo(() => [...sizesInStock_().keys()]);
|
|
616
|
+
const gap = createMemo(() => ((widthAvailableForSizes_() as number) <= 250 ? 12 : 16));
|
|
617
|
+
const showMax = createMemo(() => {
|
|
618
|
+
const fontSizeCircaPx = fontSizeRem_() * 16;
|
|
619
|
+
const availableWidth = widthAvailableForSizes_();
|
|
620
|
+
if (availableWidth && availableWidth < fontSizeCircaPx * 7 + gap() * 7 && keys().length > 4) {
|
|
621
|
+
return 2;
|
|
622
|
+
}
|
|
623
|
+
return 7;
|
|
624
|
+
});
|
|
625
|
+
const keysToShow = createMemo(() => keys().slice(0, showMax()));
|
|
626
|
+
const hidden = createMemo(() => keys().length - keysToShow().length);
|
|
597
627
|
|
|
598
628
|
return (
|
|
599
629
|
<Show when={keysToShow().length > 1}>
|
|
600
630
|
<div
|
|
601
631
|
class="sizes"
|
|
632
|
+
classList={{ small: (widthAvailableForSizes_() as number) < 250 }}
|
|
602
633
|
ref={el => {
|
|
603
634
|
ref_?.(el);
|
|
604
635
|
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
605
636
|
createEffect(() => el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
637
|
+
createEffect(() => el.style.setProperty("--sizes-gap", gap() + "px"));
|
|
606
638
|
}}
|
|
607
639
|
>
|
|
608
640
|
<For each={sortSizes(keysToShow())}>
|