@depict-ai/ui 1.4.18 → 1.4.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ES10/index.cjs +73 -7
- package/ES10/index.d.ts +33 -2
- package/ES10/index.js +228 -165
- package/latest/index.cjs +64 -2
- package/latest/index.d.ts +33 -2
- package/latest/index.js +219 -160
- package/package.json +4 -4
- package/server/ES10/index.cjs +62 -7
- package/server/ES10/index.d.ts +33 -2
- package/server/ES10/index.js +158 -106
- package/server/latest/index.cjs +53 -2
- package/server/latest/index.d.ts +33 -2
- package/server/latest/index.js +149 -101
package/latest/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var $gVhhF$depictaiutilishared = require("@depict-ai/utilishared/latest");
|
|
2
2
|
var $gVhhF$solidjsweb = require("solid-js/web");
|
|
3
|
+
var $gVhhF$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest/latest");
|
|
3
4
|
var $gVhhF$solidjs = require("solid-js");
|
|
4
5
|
require("../multi_import_deduplicator.cjs").register_es_version("ui", "latest");
|
|
5
6
|
function $parcel$export(e, n, v, s) {
|
|
@@ -10,6 +11,9 @@ function $parcel$export(e, n, v, s) {
|
|
|
10
11
|
configurable: true
|
|
11
12
|
});
|
|
12
13
|
}
|
|
14
|
+
$parcel$export(module.exports, "ShopifyResponsiveImg", () => $19950faaac026e09$export$6e5611bc7e57e477);
|
|
15
|
+
$parcel$export(module.exports, "makeSizeAccessor", () => $19950faaac026e09$export$e6fffe67d4cdd848);
|
|
16
|
+
$parcel$export(module.exports, "ImageContainer", () => $93304d59a9747aa6$export$94026ee33dbabc26);
|
|
13
17
|
$parcel$export(module.exports, "SentryErrorBoundary", () => $edafe91daf3091d7$export$b69d0d92862de18b);
|
|
14
18
|
$parcel$export(module.exports, "ExpandingDetails", () => $a69e505a12a77874$export$6c6d7a51fa9aa15d);
|
|
15
19
|
$parcel$export(module.exports, "accessor_of_object_to_object_with_accessor_values", () => $0785f4c9947d9b5f$export$f091cbac892643a4);
|
|
@@ -55,7 +59,62 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
|
|
|
55
59
|
$parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
|
|
56
60
|
$parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
|
|
57
61
|
/*! Depict.ai search and product listing SDK */
|
|
58
|
-
const $b757f75811f3261f$export$83d89fbfd8236492 = "1.4.
|
|
62
|
+
const $b757f75811f3261f$export$83d89fbfd8236492 = "1.4.20";
|
|
63
|
+
const $19950faaac026e09$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<img>`, 1);
|
|
64
|
+
function $19950faaac026e09$export$e6fffe67d4cdd848(whatToWatch) {
|
|
65
|
+
const [size, setSize] = $gVhhF$solidjs.createSignal(0);
|
|
66
|
+
const resizeObserver = new ResizeObserver($gVhhF$depictaiutilisharedlatest.catchify(records => {
|
|
67
|
+
for (let j = 0; j < records.length; j++) {
|
|
68
|
+
const {
|
|
69
|
+
width: width
|
|
70
|
+
} = records[j].contentRect;
|
|
71
|
+
if (!width) continue;
|
|
72
|
+
// add extra 5% just in case. + safari is (in some cases) acting a bit questionable and needs a third extra to fill the set width
|
|
73
|
+
const new_size = width * 1.05 * ((0, $gVhhF$depictaiutilishared.is_safari) ? 4 / 3 : 1);
|
|
74
|
+
setSize(Math.round(new_size));
|
|
75
|
+
}
|
|
76
|
+
}));
|
|
77
|
+
resizeObserver.observe(whatToWatch);
|
|
78
|
+
$gVhhF$solidjs.onCleanup(() => resizeObserver.disconnect());
|
|
79
|
+
return size;
|
|
80
|
+
}
|
|
81
|
+
function $19950faaac026e09$export$6e5611bc7e57e477({
|
|
82
|
+
src: raw_src,
|
|
83
|
+
size: size,
|
|
84
|
+
resolutions = [64, 128, 256, 300, 400, 512, 768, 1024, 1280, 1536, 2048, 4096],
|
|
85
|
+
...otherOptions
|
|
86
|
+
}) {
|
|
87
|
+
const src = new URL(raw_src, location.origin);
|
|
88
|
+
const fallbackSrc = $19950faaac026e09$var$generateImageUrl(src, 400);
|
|
89
|
+
const srcset = $19950faaac026e09$var$make_srcset(src, resolutions);
|
|
90
|
+
return (() => {
|
|
91
|
+
const _el$ = $gVhhF$solidjsweb.getNextElement($19950faaac026e09$var$_tmpl$);
|
|
92
|
+
$gVhhF$solidjsweb.spread(_el$, $gVhhF$solidjsweb.mergeProps(otherOptions, {
|
|
93
|
+
"src": fallbackSrc,
|
|
94
|
+
"srcset": srcset,
|
|
95
|
+
get sizes() {
|
|
96
|
+
return size() + "px";
|
|
97
|
+
}
|
|
98
|
+
}), false, false);
|
|
99
|
+
$gVhhF$solidjsweb.runHydrationEvents();
|
|
100
|
+
return _el$;
|
|
101
|
+
})();
|
|
102
|
+
}
|
|
103
|
+
function $19950faaac026e09$var$make_srcset(url, resolutions) {
|
|
104
|
+
return resolutions.map(width => `${$19950faaac026e09$var$generateImageUrl(url, width)} ${width}w`).join(", ");
|
|
105
|
+
}
|
|
106
|
+
function $19950faaac026e09$var$generateImageUrl(url, width) {
|
|
107
|
+
url.searchParams.set("width", width);
|
|
108
|
+
return url.href;
|
|
109
|
+
}
|
|
110
|
+
const $93304d59a9747aa6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div></div>`, 2);
|
|
111
|
+
function $93304d59a9747aa6$export$94026ee33dbabc26(props) {
|
|
112
|
+
return (() => {
|
|
113
|
+
const _el$ = $gVhhF$solidjsweb.getNextElement($93304d59a9747aa6$var$_tmpl$);
|
|
114
|
+
$gVhhF$solidjsweb.effect(_$p => $gVhhF$solidjsweb.style(_el$, `position:relative;width:100%;padding-bottom:${1 / props.aspectRatio * 100}%`, _$p));
|
|
115
|
+
return _el$;
|
|
116
|
+
})();
|
|
117
|
+
}
|
|
59
118
|
|
|
60
119
|
// Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
|
|
61
120
|
class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
|
|
@@ -5126,6 +5185,7 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
|
|
|
5126
5185
|
}) {
|
|
5127
5186
|
const placeholder_crumb_data = [,,,];
|
|
5128
5187
|
const crumb_data = $gVhhF$solidjs.createMemo(() => get_api_crumb_data() || placeholder_crumb_data);
|
|
5188
|
+
const href_accessor = $gVhhF$depictaiutilishared.use_href_accessor();
|
|
5129
5189
|
return $gVhhF$solidjsweb.createComponent((0, $edafe91daf3091d7$export$b69d0d92862de18b), {
|
|
5130
5190
|
severity_: "error",
|
|
5131
5191
|
message_: "BreadCrumbs failed",
|
|
@@ -5136,8 +5196,10 @@ function $e53b2e7e632ac4cb$export$5646050d516e06bc({
|
|
|
5136
5196
|
return crumb_data();
|
|
5137
5197
|
},
|
|
5138
5198
|
children: (display_accessor, index) => {
|
|
5199
|
+
const is_last = $gVhhF$solidjs.createMemo(() => index === crumb_data()?.length - 1);
|
|
5200
|
+
const url = $gVhhF$solidjs.createMemo(() => is_last() ? href_accessor() : display_accessor()?.page_url);
|
|
5139
5201
|
const href = $gVhhF$solidjs.createMemo(() => $1ab22f2cd39b3061$export$43cd1e747fecd42e({
|
|
5140
|
-
to_url_:
|
|
5202
|
+
to_url_: url(),
|
|
5141
5203
|
filter_query_param_prefix_: filter_query_param_prefix_,
|
|
5142
5204
|
sorting_query_param_: sorting_query_param_
|
|
5143
5205
|
}));
|
package/latest/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { JSX, Signal,
|
|
1
|
+
import { Accessor, JSX, Signal, Setter } from "solid-js";
|
|
2
2
|
import { report, Elem, Display, ColsAtSize, ModernDisplay, Node_Array } from "@depict-ai/utilishared/latest";
|
|
3
3
|
import { SearchFilter, SearchRequest } from "@depict-ai/types/api/SearchRequest";
|
|
4
4
|
import { SearchFilter as _SearchFilter1, ContentLink, SearchResponse } from "@depict-ai/types/api/SearchResponse";
|
|
@@ -7,7 +7,38 @@ import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/
|
|
|
7
7
|
import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
|
|
8
8
|
import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
|
|
9
9
|
import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
|
|
10
|
-
export const version = "1.4.
|
|
10
|
+
export const version = "1.4.20";
|
|
11
|
+
/**
|
|
12
|
+
* Returns an accessor that will update when the size of the provided element changes, to be used with ResponsiveImg
|
|
13
|
+
*/
|
|
14
|
+
export function makeSizeAccessor(whatToWatch: HTMLElement): Accessor<number>;
|
|
15
|
+
/**
|
|
16
|
+
* Automatically generate a srcset from the shopify CDN for an image and set the sizes attribute to the provided accessor.
|
|
17
|
+
* This is used for our responsive images:
|
|
18
|
+
* 1. The image must have a container with a fixed size (or aspect ratio) that is independent of the image. When aspectRatio is configured on the depict-cards element as data attribute, we will wrap the image in a ImageContainer for this. If it's false, the user has to provide this container themselves.
|
|
19
|
+
* 2. We set a ResizeObserver on one of the currently visible images (see makeSizeAccessor)
|
|
20
|
+
* 3. We set the size attribute of all the visible images to the size of the container we're observing. The point of this is that the sizes attribute is used to determine which image to load, and usually it's set by the user and depends on the relationship between image size and viewport size. By using a ResizeObserver, we can make sure the sizes attribute is always set to the correct value without it having to be configured. This will make so the browser always loads the correct image size for a crisp image but still fast load.
|
|
21
|
+
*/
|
|
22
|
+
export function ShopifyResponsiveImg({
|
|
23
|
+
src: raw_src,
|
|
24
|
+
size,
|
|
25
|
+
resolutions,
|
|
26
|
+
...otherOptions
|
|
27
|
+
}: {
|
|
28
|
+
resolutions?: number[];
|
|
29
|
+
size: Accessor<number>;
|
|
30
|
+
} & Omit<JSX.ImgHTMLAttributes<HTMLImageElement>, "srcset" | "src" | "sizes"> & {
|
|
31
|
+
src: string;
|
|
32
|
+
}): HTMLImageElement;
|
|
33
|
+
/** @jsxImportSource solid-js */
|
|
34
|
+
/**
|
|
35
|
+
* ImageContainer for using the padding hack to set the aspect ratio of an image
|
|
36
|
+
* Put this around an <img> or <ResponsiveImg> to give it a container that always has the same size as the image. This prevents CLS and enables ResponsiveImg to work (the browser to load the correct image size)
|
|
37
|
+
* (Not using the CSS aspect-ratio property yet here due to browser support)
|
|
38
|
+
*/
|
|
39
|
+
export function ImageContainer(props: {
|
|
40
|
+
aspectRatio: number;
|
|
41
|
+
}): HTMLDivElement;
|
|
11
42
|
declare class SDKError extends Error {}
|
|
12
43
|
export class ProductCardError extends SDKError {
|
|
13
44
|
constructor(templateError: Error);
|