@depict-ai/ui 2.0.13 → 2.0.15

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.
@@ -1,5 +1,5 @@
1
- import { JSX, Signal, Accessor, Setter } from "solid-js";
2
- import { Display, ColsAtSize, report, Elem, ModernDisplay, Node_Array } from "@depict-ai/utilishared/latest";
1
+ import { JSX, Accessor, Signal, Setter } from "solid-js";
2
+ import { Amazing_Slider, Display, ColsAtSize, report, Elem, 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";
5
5
  import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
@@ -7,7 +7,77 @@ 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 = "2.0.13";
10
+ export const version = "2.0.15";
11
+ /**
12
+ * Provider to wrap every listing (group of products) in
13
+ * Used for example for deduplicating ResizeObservers for responsive images
14
+ */
15
+ export function ListingProvider(props: {
16
+ children: JSX.Element;
17
+ }): JSX.Element;
18
+ /**
19
+ * Use this to get the context object if your component is within a ListingProvider
20
+ */
21
+ export function useListing(): Record<symbol, any> | undefined;
22
+ /** @jsxImportSource solid-js */
23
+ /**
24
+ * ImageContainer for using the padding hack to set the aspect ratio of an image
25
+ * 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)
26
+ * (Not using the CSS aspect-ratio property yet here due to browser support)
27
+ */
28
+ export function ImageContainer(props: {
29
+ aspectRatio: number;
30
+ }): HTMLDivElement;
31
+ /**
32
+ * Returns an accessor that will update when the size of the provided element changes, to be used with ResponsiveImg
33
+ */
34
+ export function makeSizeAccessor(whatToWatch: HTMLElement): Accessor<number>;
35
+ /**
36
+ * Automatically generate a srcset from the shopify CDN for an image and set the sizes attribute to the provided accessor.
37
+ * This is used for our responsive images:
38
+ * 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.
39
+ * 2. We set a ResizeObserver on one of the currently visible images (see makeSizeAccessor)
40
+ * 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.
41
+ */
42
+ export function ShopifyResponsiveImg(props: {
43
+ resolutions?: number[];
44
+ size: Accessor<number>;
45
+ } & Omit<JSX.ImgHTMLAttributes<HTMLImageElement>, "srcset" | "src" | "sizes"> & {
46
+ src: string;
47
+ }): HTMLImageElement;
48
+ export const shopifyContainedImageContextSymbol: unique symbol;
49
+ /**
50
+ * Abstraction built on top of ShopifyResponsiveImg
51
+ * @param src TODO
52
+ * @param aspectRatio
53
+ * @constructor
54
+ */
55
+ export function ShopifyContainedImage(props: {
56
+ src: string;
57
+ aspectRatio: number;
58
+ }): HTMLDivElement;
59
+ /** @jsxImportSource solid-js */
60
+ export function GenericSliderArrowButton(props?: {
61
+ width_?: number;
62
+ height_?: number;
63
+ }): SVGElement;
64
+ export function SlidableItems({
65
+ children,
66
+ slider_ref_,
67
+ faded_opacity_,
68
+ mutation_plugins_,
69
+ disable_fading_,
70
+ arrow_width_,
71
+ arrow_height_
72
+ }: {
73
+ children?: JSX.Element;
74
+ slider_ref_?: (slider: Amazing_Slider) => any;
75
+ faded_opacity_?: number;
76
+ disable_fading_?: boolean;
77
+ mutation_plugins_?: ((this: Amazing_Slider, mutations: IntersectionObserverEntry[], intersecting_items: Record<number, IntersectionObserverEntry>) => unknown)[];
78
+ arrow_width_?: number;
79
+ arrow_height_?: number;
80
+ }): HTMLDivElement;
11
81
  /**
12
82
  * Returns accessor with the size of the provided element, including padding and border (I think)
13
83
  */
@@ -88,11 +158,6 @@ export type SolidLayoutOptions = {
88
158
  * @return An accessor containing a CSS string
89
159
  */
90
160
  export function SolidLayout(props: SolidLayoutOptions): JSX.Element;
91
- /** @jsxImportSource solid-js */
92
- export function GenericSliderArrowButton(props?: {
93
- width_?: number;
94
- height_?: number;
95
- }): SVGElement;
96
161
  type RecommendationSliderBaseProps<T extends Display> = {
97
162
  grid_spacing: SDKGridSpacing;
98
163
  cols_at_size: SDKColsAtSize;
@@ -137,37 +202,6 @@ export function RecommendationGrid<T extends Display>(props: {
137
202
  merchant?: never;
138
203
  market?: never;
139
204
  } & RecommendationGridBaseProps<T>): HTMLDivElement;
140
- /**
141
- * Returns an accessor that will update when the size of the provided element changes, to be used with ResponsiveImg
142
- */
143
- export function makeSizeAccessor(whatToWatch: HTMLElement): Accessor<number>;
144
- /**
145
- * Automatically generate a srcset from the shopify CDN for an image and set the sizes attribute to the provided accessor.
146
- * This is used for our responsive images:
147
- * 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.
148
- * 2. We set a ResizeObserver on one of the currently visible images (see makeSizeAccessor)
149
- * 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.
150
- */
151
- export function ShopifyResponsiveImg({
152
- src: raw_src,
153
- size,
154
- resolutions,
155
- ...otherOptions
156
- }: {
157
- resolutions?: number[];
158
- size: Accessor<number>;
159
- } & Omit<JSX.ImgHTMLAttributes<HTMLImageElement>, "srcset" | "src" | "sizes"> & {
160
- src: string;
161
- }): HTMLImageElement;
162
- /** @jsxImportSource solid-js */
163
- /**
164
- * ImageContainer for using the padding hack to set the aspect ratio of an image
165
- * 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)
166
- * (Not using the CSS aspect-ratio property yet here due to browser support)
167
- */
168
- export function ImageContainer(props: {
169
- aspectRatio: number;
170
- }): HTMLDivElement;
171
205
  export function ExpandingDetails(props: {
172
206
  details_: HTMLDetailsElement;
173
207
  summary_: HTMLElement;