@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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "1.4.18",
3
+ "version": "1.4.20",
4
4
  "description": "Base package containing the actual UI of Depict UI along with translations, with a not-simplified API. We recommend using @depict-ai/js-ui or @depict-ai/react-ui instead.",
5
5
  "packageManager": "yarn@3.2.2",
6
6
  "sass": "styles.scss",
@@ -236,9 +236,9 @@
236
236
  "@babel/plugin-transform-typescript": "^7.22.9",
237
237
  "@babel/runtime": "latest",
238
238
  "@babel/runtime-corejs3": "^7.22.6",
239
- "@depict-ai/plp-styling": "^1.1.1",
240
- "@depict-ai/types": "^1.0.36",
241
- "@depict-ai/utilishared": "^1.0.36",
239
+ "@depict-ai/plp-styling": "^1.1.2",
240
+ "@depict-ai/types": "^1.0.37",
241
+ "@depict-ai/utilishared": "^1.0.38",
242
242
  "solid-js": "^1.7.3"
243
243
  },
244
244
  "type": "module",
@@ -1,5 +1,6 @@
1
1
  var $3hooq$depictaiutilishared = require("@depict-ai/utilishared/ES10");
2
2
  var $3hooq$solidjsweb = require("solid-js/web");
3
+ var $3hooq$depictaiutilisharedlatest = require("@depict-ai/utilishared/latest/ES10");
3
4
  var $3hooq$solidjs = require("solid-js");
4
5
  var $3hooq$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
5
6
  var $3hooq$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,52 @@ $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.18";
68
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "1.4.20";
69
+ function $858fdcf73148519f$export$e6fffe67d4cdd848(whatToWatch) {
70
+ const [size, setSize] = $3hooq$solidjs.createSignal(0);
71
+ const resizeObserver = new ResizeObserver($3hooq$depictaiutilisharedlatest.catchify(records => {
72
+ for (let j = 0; j < records.length; j++) {
73
+ const {
74
+ width: width
75
+ } = records[j].contentRect;
76
+ if (!width) continue;
77
+ // 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
78
+ const new_size = width * 1.05 * ((0, $3hooq$depictaiutilishared.is_safari) ? 4 / 3 : 1);
79
+ setSize(Math.round(new_size));
80
+ }
81
+ }));
82
+ resizeObserver.observe(whatToWatch);
83
+ $3hooq$solidjs.onCleanup(() => resizeObserver.disconnect());
84
+ return size;
85
+ }
86
+ function $858fdcf73148519f$export$6e5611bc7e57e477(_ref) {
87
+ let {
88
+ src: raw_src,
89
+ size: size,
90
+ resolutions = [64, 128, 256, 300, 400, 512, 768, 1024, 1280, 1536, 2048, 4096],
91
+ ...otherOptions
92
+ } = _ref;
93
+ const src = new URL(raw_src, location.origin);
94
+ const fallbackSrc = $858fdcf73148519f$var$generateImageUrl(src, 400);
95
+ const srcset = $858fdcf73148519f$var$make_srcset(src, resolutions);
96
+ return $3hooq$solidjsweb.ssrElement("img", () => ({
97
+ ...otherOptions,
98
+ "src": fallbackSrc,
99
+ "srcset": srcset,
100
+ "sizes": size() + "px"
101
+ }), undefined, true);
102
+ }
103
+ function $858fdcf73148519f$var$make_srcset(url, resolutions) {
104
+ return resolutions.map(width => "".concat($858fdcf73148519f$var$generateImageUrl(url, width), " ").concat(width, "w")).join(", ");
105
+ }
106
+ function $858fdcf73148519f$var$generateImageUrl(url, width) {
107
+ url.searchParams.set("width", width);
108
+ return url.href;
109
+ }
110
+ const $ce467edb5343cfcd$var$_tmpl$ = ["<div", ' style="', '"></div>'];
111
+ function $ce467edb5343cfcd$export$94026ee33dbabc26(props) {
112
+ return $3hooq$solidjsweb.ssr($ce467edb5343cfcd$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.ssrStyle("position:relative;width:100%;padding-bottom:".concat(1 / props.aspectRatio * 100, "%")));
113
+ }
65
114
 
66
115
  // Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
67
116
  class $95e4006e1dcb5b72$export$e1d52e4f0c7557a1 extends Error {}
@@ -4306,6 +4355,7 @@ function $1c819dc9d820a149$export$5646050d516e06bc(_ref) {
4306
4355
  } = _ref;
4307
4356
  const placeholder_crumb_data = [,,,];
4308
4357
  const crumb_data = $3hooq$solidjs.createMemo(() => get_api_crumb_data() || placeholder_crumb_data);
4358
+ const href_accessor = $3hooq$depictaiutilishared.use_href_accessor();
4309
4359
  return $3hooq$solidjsweb.createComponent((0, $1b3cf201cdd38687$export$b69d0d92862de18b), {
4310
4360
  severity_: "error",
4311
4361
  message_: "BreadCrumbs failed",
@@ -4315,14 +4365,19 @@ function $1c819dc9d820a149$export$5646050d516e06bc(_ref) {
4315
4365
  return crumb_data();
4316
4366
  },
4317
4367
  children: (display_accessor, index) => {
4318
- const href = $3hooq$solidjs.createMemo(() => {
4368
+ const is_last = $3hooq$solidjs.createMemo(() => {
4369
+ var _crumb_data;
4370
+ return index === ((_crumb_data = crumb_data()) === null || _crumb_data === void 0 ? void 0 : _crumb_data.length) - 1;
4371
+ });
4372
+ const url = $3hooq$solidjs.createMemo(() => {
4319
4373
  var _display_accessor;
4320
- return $a68b73fd7ba0853f$export$43cd1e747fecd42e({
4321
- to_url_: (_display_accessor = display_accessor()) === null || _display_accessor === void 0 ? void 0 : _display_accessor.page_url,
4322
- filter_query_param_prefix_: filter_query_param_prefix_,
4323
- sorting_query_param_: sorting_query_param_
4324
- });
4374
+ return is_last() ? href_accessor() : (_display_accessor = display_accessor()) === null || _display_accessor === void 0 ? void 0 : _display_accessor.page_url;
4325
4375
  });
4376
+ const href = $3hooq$solidjs.createMemo(() => $a68b73fd7ba0853f$export$43cd1e747fecd42e({
4377
+ to_url_: url(),
4378
+ filter_query_param_prefix_: filter_query_param_prefix_,
4379
+ sorting_query_param_: sorting_query_param_
4380
+ }));
4326
4381
  return [$3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
4327
4382
  get when() {
4328
4383
  return display_accessor();
@@ -1,4 +1,4 @@
1
- import { JSX, Signal, Accessor, Setter } from "solid-js";
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.18";
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);