@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/ES10/index.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
var $52FdA$depictaiutilishared = require("@depict-ai/utilishared/ES10");
|
|
2
2
|
var $52FdA$solidjsweb = require("solid-js/web");
|
|
3
|
+
var $52FdA$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest/ES10");
|
|
3
4
|
var $52FdA$solidjs = require("solid-js");
|
|
4
5
|
var $52FdA$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
|
|
5
6
|
var $52FdA$babelruntimehelpersclassPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
|
|
@@ -16,6 +17,9 @@ function $parcel$export(e, n, v, s) {
|
|
|
16
17
|
function $parcel$interopDefault(a) {
|
|
17
18
|
return a && a.__esModule ? a.default : a;
|
|
18
19
|
}
|
|
20
|
+
$parcel$export(module.exports, "ShopifyResponsiveImg", () => $858fdcf73148519f$export$6e5611bc7e57e477);
|
|
21
|
+
$parcel$export(module.exports, "makeSizeAccessor", () => $858fdcf73148519f$export$e6fffe67d4cdd848);
|
|
22
|
+
$parcel$export(module.exports, "ImageContainer", () => $ce467edb5343cfcd$export$94026ee33dbabc26);
|
|
19
23
|
$parcel$export(module.exports, "SentryErrorBoundary", () => $1b3cf201cdd38687$export$b69d0d92862de18b);
|
|
20
24
|
$parcel$export(module.exports, "ExpandingDetails", () => $4cfe8400ed3f92c4$export$6c6d7a51fa9aa15d);
|
|
21
25
|
$parcel$export(module.exports, "accessor_of_object_to_object_with_accessor_values", () => $39cca429fb71d8ff$export$f091cbac892643a4);
|
|
@@ -61,7 +65,63 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $33eed84f447aa0c0$expo
|
|
|
61
65
|
$parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $33eed84f447aa0c0$export$7bf543b9d9be2c22);
|
|
62
66
|
$parcel$export(module.exports, "version", () => $aa1938dec50d6c12$export$83d89fbfd8236492);
|
|
63
67
|
/*! Depict.ai search and product listing SDK */
|
|
64
|
-
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "1.4.
|
|
68
|
+
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "1.4.20";
|
|
69
|
+
const $858fdcf73148519f$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<img>`, 1);
|
|
70
|
+
function $858fdcf73148519f$export$e6fffe67d4cdd848(whatToWatch) {
|
|
71
|
+
const [size, setSize] = $52FdA$solidjs.createSignal(0);
|
|
72
|
+
const resizeObserver = new ResizeObserver($52FdA$depictaiutilisharedlatest.catchify(records => {
|
|
73
|
+
for (let j = 0; j < records.length; j++) {
|
|
74
|
+
const {
|
|
75
|
+
width: width
|
|
76
|
+
} = records[j].contentRect;
|
|
77
|
+
if (!width) continue;
|
|
78
|
+
// 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
|
|
79
|
+
const new_size = width * 1.05 * ((0, $52FdA$depictaiutilishared.is_safari) ? 4 / 3 : 1);
|
|
80
|
+
setSize(Math.round(new_size));
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
resizeObserver.observe(whatToWatch);
|
|
84
|
+
$52FdA$solidjs.onCleanup(() => resizeObserver.disconnect());
|
|
85
|
+
return size;
|
|
86
|
+
}
|
|
87
|
+
function $858fdcf73148519f$export$6e5611bc7e57e477(_ref) {
|
|
88
|
+
let {
|
|
89
|
+
src: raw_src,
|
|
90
|
+
size: size,
|
|
91
|
+
resolutions = [64, 128, 256, 300, 400, 512, 768, 1024, 1280, 1536, 2048, 4096],
|
|
92
|
+
...otherOptions
|
|
93
|
+
} = _ref;
|
|
94
|
+
const src = new URL(raw_src, location.origin);
|
|
95
|
+
const fallbackSrc = $858fdcf73148519f$var$generateImageUrl(src, 400);
|
|
96
|
+
const srcset = $858fdcf73148519f$var$make_srcset(src, resolutions);
|
|
97
|
+
return (() => {
|
|
98
|
+
const _el$ = $52FdA$solidjsweb.getNextElement($858fdcf73148519f$var$_tmpl$);
|
|
99
|
+
$52FdA$solidjsweb.spread(_el$, $52FdA$solidjsweb.mergeProps(otherOptions, {
|
|
100
|
+
"src": fallbackSrc,
|
|
101
|
+
"srcset": srcset,
|
|
102
|
+
get sizes() {
|
|
103
|
+
return size() + "px";
|
|
104
|
+
}
|
|
105
|
+
}), false, false);
|
|
106
|
+
$52FdA$solidjsweb.runHydrationEvents();
|
|
107
|
+
return _el$;
|
|
108
|
+
})();
|
|
109
|
+
}
|
|
110
|
+
function $858fdcf73148519f$var$make_srcset(url, resolutions) {
|
|
111
|
+
return resolutions.map(width => "".concat($858fdcf73148519f$var$generateImageUrl(url, width), " ").concat(width, "w")).join(", ");
|
|
112
|
+
}
|
|
113
|
+
function $858fdcf73148519f$var$generateImageUrl(url, width) {
|
|
114
|
+
url.searchParams.set("width", width);
|
|
115
|
+
return url.href;
|
|
116
|
+
}
|
|
117
|
+
const $ce467edb5343cfcd$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div></div>`, 2);
|
|
118
|
+
function $ce467edb5343cfcd$export$94026ee33dbabc26(props) {
|
|
119
|
+
return (() => {
|
|
120
|
+
const _el$ = $52FdA$solidjsweb.getNextElement($ce467edb5343cfcd$var$_tmpl$);
|
|
121
|
+
$52FdA$solidjsweb.effect(_$p => $52FdA$solidjsweb.style(_el$, "position:relative;width:100%;padding-bottom:".concat(1 / props.aspectRatio * 100, "%"), _$p));
|
|
122
|
+
return _el$;
|
|
123
|
+
})();
|
|
124
|
+
}
|
|
65
125
|
|
|
66
126
|
// Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
|
|
67
127
|
class $95e4006e1dcb5b72$export$e1d52e4f0c7557a1 extends Error {}
|
|
@@ -5499,6 +5559,7 @@ function $1c819dc9d820a149$export$5646050d516e06bc(_ref) {
|
|
|
5499
5559
|
} = _ref;
|
|
5500
5560
|
const placeholder_crumb_data = [,,,];
|
|
5501
5561
|
const crumb_data = $52FdA$solidjs.createMemo(() => get_api_crumb_data() || placeholder_crumb_data);
|
|
5562
|
+
const href_accessor = $52FdA$depictaiutilishared.use_href_accessor();
|
|
5502
5563
|
return $52FdA$solidjsweb.createComponent((0, $1b3cf201cdd38687$export$b69d0d92862de18b), {
|
|
5503
5564
|
severity_: "error",
|
|
5504
5565
|
message_: "BreadCrumbs failed",
|
|
@@ -5509,14 +5570,19 @@ function $1c819dc9d820a149$export$5646050d516e06bc(_ref) {
|
|
|
5509
5570
|
return crumb_data();
|
|
5510
5571
|
},
|
|
5511
5572
|
children: (display_accessor, index) => {
|
|
5512
|
-
const
|
|
5573
|
+
const is_last = $52FdA$solidjs.createMemo(() => {
|
|
5574
|
+
var _crumb_data;
|
|
5575
|
+
return index === ((_crumb_data = crumb_data()) === null || _crumb_data === void 0 ? void 0 : _crumb_data.length) - 1;
|
|
5576
|
+
});
|
|
5577
|
+
const url = $52FdA$solidjs.createMemo(() => {
|
|
5513
5578
|
var _display_accessor;
|
|
5514
|
-
return
|
|
5515
|
-
to_url_: (_display_accessor = display_accessor()) === null || _display_accessor === void 0 ? void 0 : _display_accessor.page_url,
|
|
5516
|
-
filter_query_param_prefix_: filter_query_param_prefix_,
|
|
5517
|
-
sorting_query_param_: sorting_query_param_
|
|
5518
|
-
});
|
|
5579
|
+
return is_last() ? href_accessor() : (_display_accessor = display_accessor()) === null || _display_accessor === void 0 ? void 0 : _display_accessor.page_url;
|
|
5519
5580
|
});
|
|
5581
|
+
const href = $52FdA$solidjs.createMemo(() => $a68b73fd7ba0853f$export$43cd1e747fecd42e({
|
|
5582
|
+
to_url_: url(),
|
|
5583
|
+
filter_query_param_prefix_: filter_query_param_prefix_,
|
|
5584
|
+
sorting_query_param_: sorting_query_param_
|
|
5585
|
+
}));
|
|
5520
5586
|
return [$52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
|
|
5521
5587
|
get when() {
|
|
5522
5588
|
return display_accessor();
|
package/ES10/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/ES10";
|
|
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);
|