@depict-ai/ui 1.4.25 → 2.0.1

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.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { JSX, Signal, Accessor, Setter } from "solid-js";
2
- import { Display, report, ColsAtSize, Elem, ModernDisplay, Node_Array } from "@depict-ai/utilishared/ES10";
2
+ import { Display, ColsAtSize, report, Elem, 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";
5
5
  import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
@@ -7,7 +7,7 @@ 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.25";
10
+ export const version = "2.0.1";
11
11
  export type SDKGridSpacing = string | {
12
12
  horizontal: string;
13
13
  vertical: string;
@@ -15,11 +15,21 @@ export type SDKGridSpacing = string | {
15
15
  export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
16
16
  type FilterWithData = WithRequired<SearchFilter, "data">;
17
17
  export interface SDKRenderingInfo {
18
+ /**
19
+ * If you call this function with a provided function, the provided function will be called whenever the index of the currently displayed product changes.
20
+ */
18
21
  set_on_index_change: (fn: (index: number) => void) => void;
19
22
  merchant: string;
20
23
  market: string;
21
24
  }
22
25
  export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
26
+ type WithoutMerchant<T> = T extends {
27
+ merchant: string;
28
+ } ? Omit<T, "merchant"> : T;
29
+ type WithoutMarket<T> = T extends {
30
+ market: string;
31
+ } ? Omit<T, "market"> : T;
32
+ export type ProductCardTemplateWithoutMerchantAndMarket<T extends Display> = (display: Parameters<ProductCardTemplate<T>>[0], info?: WithoutMerchant<WithoutMarket<SDKRenderingInfo>>) => ReturnType<ProductCardTemplate<T>>;
23
33
  /**
24
34
  * Will be sent to backend to indicate whether the query_id_ is for a collection or category.
25
35
  * Backend defaults to category if not specified.
@@ -29,6 +39,13 @@ type AddActualFieldToArray<T> = T extends Array<infer U> ? (U & {
29
39
  actual_field?: string;
30
40
  })[] : never;
31
41
  type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends undefined ? undefined : AddActualFieldToArray<T>;
42
+ export type SDKColsAtSize = [number, number?][];
43
+ /**
44
+ * Transform SDK ColsAtSize into valid Layout ColsAtSize
45
+ * @param cols_at_size [nbCol, maxWidth]
46
+ * @returns
47
+ */
48
+ export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
32
49
  declare class SDKError extends Error {}
33
50
  export class ProductCardError extends SDKError {
34
51
  constructor(templateError: Error);
@@ -55,7 +72,7 @@ export type SolidLayoutOptions = {
55
72
  disable_partial_rows?: boolean;
56
73
  override_vertical_spacing?: string;
57
74
  children: JSX.Element;
58
- element_attributes: JSX.HTMLAttributes<HTMLDivElement>;
75
+ element_attributes: Omit<JSX.HTMLAttributes<HTMLDivElement>, "classList">;
59
76
  };
60
77
  /**
61
78
  * SolidLayout: SolidJS adaption of Layout. Calculates CSS for a grid or slider with a certain spacing and certain number of columns at certain screen sizes, including a view more button. All properties are reactive.
@@ -67,25 +84,11 @@ export type SolidLayoutOptions = {
67
84
  * @return An accessor containing a CSS string
68
85
  */
69
86
  export function SolidLayout(props: SolidLayoutOptions): JSX.Element;
70
- export type SDKColsAtSize = [number, number?][];
71
- /**
72
- * Transform SDK ColsAtSize into valid Layout ColsAtSize
73
- * @param cols_at_size [nbCol, maxWidth]
74
- * @returns
75
- */
76
- export const convert_sdk_cols_at_size_to_layout: (cols_at_size: SDKColsAtSize) => ColsAtSize;
77
87
  /** @jsxImportSource solid-js */
78
88
  export function GenericSliderArrowButton(props?: {
79
89
  width_?: number;
80
90
  height_?: number;
81
91
  }): SVGElement;
82
- type WithoutMerchant<T> = T extends {
83
- merchant: string;
84
- } ? Omit<T, "merchant"> : T;
85
- type WithoutMarket<T> = T extends {
86
- market: string;
87
- } ? Omit<T, "market"> : T;
88
- type ModifiedProductCardTemplate<T extends Display> = (display: Parameters<ProductCardTemplate<T>>[0], info?: WithoutMerchant<WithoutMarket<SDKRenderingInfo>>) => ReturnType<ProductCardTemplate<T>>;
89
92
  type RecommendationSliderBaseProps<T extends Display> = {
90
93
  grid_spacing: SDKGridSpacing;
91
94
  cols_at_size: SDKColsAtSize;
@@ -99,19 +102,12 @@ export function RecommendationSlider<T extends Display>(props: {
99
102
  product_card_template: ProductCardTemplate<T>;
100
103
  merchant: string;
101
104
  market: string;
102
- } & RecommendationSliderBaseProps<T>): any;
105
+ } & RecommendationSliderBaseProps<T>): HTMLDivElement;
103
106
  export function RecommendationSlider<T extends Display>(props: {
104
- product_card_template: ModifiedProductCardTemplate<T>;
107
+ product_card_template: ProductCardTemplateWithoutMerchantAndMarket<T>;
105
108
  merchant?: never;
106
109
  market?: never;
107
- } & RecommendationSliderBaseProps<T>): any;
108
- type _WithoutMerchant1<T> = T extends {
109
- merchant: string;
110
- } ? Omit<T, "merchant"> : T;
111
- type _WithoutMarket1<T> = T extends {
112
- market: string;
113
- } ? Omit<T, "market"> : T;
114
- type _ModifiedProductCardTemplate1<T extends Display> = (display: Parameters<ProductCardTemplate<T>>[0], info?: _WithoutMerchant1<_WithoutMarket1<SDKRenderingInfo>>) => ReturnType<ProductCardTemplate<T>>;
110
+ } & RecommendationSliderBaseProps<T>): HTMLDivElement;
115
111
  type RecommendationGridBaseProps<T extends Display> = {
116
112
  grid_spacing: SDKGridSpacing;
117
113
  cols_at_size: SDKColsAtSize;
@@ -121,6 +117,7 @@ type RecommendationGridBaseProps<T extends Display> = {
121
117
  start_rows?: number;
122
118
  rows_per_click?: number;
123
119
  };
120
+ max_rows?: number;
124
121
  };
125
122
  /**
126
123
  * Render a grid with provided recommendations. displayTransformers will not be applied for this since you yourself provide the displays. Options are reactive.
@@ -130,12 +127,12 @@ export function RecommendationGrid<T extends Display>(props: {
130
127
  product_card_template: ProductCardTemplate<T>;
131
128
  merchant: string;
132
129
  market: string;
133
- } & RecommendationGridBaseProps<T>): any;
130
+ } & RecommendationGridBaseProps<T>): HTMLDivElement;
134
131
  export function RecommendationGrid<T extends Display>(props: {
135
- product_card_template: _ModifiedProductCardTemplate1<T>;
132
+ product_card_template: ProductCardTemplateWithoutMerchantAndMarket<T>;
136
133
  merchant?: never;
137
134
  market?: never;
138
- } & RecommendationGridBaseProps<T>): any;
135
+ } & RecommendationGridBaseProps<T>): HTMLDivElement;
139
136
  /**
140
137
  * Returns an accessor that will update when the size of the provided element changes, to be used with ResponsiveImg
141
138
  */
@@ -824,7 +821,7 @@ interface SearchFieldParams {
824
821
  click_handler?: (this: HTMLDivElement, ev: MouseEvent) => any;
825
822
  aligner_ref?: HTMLElement | null;
826
823
  }
827
- export function SearchField(props: SearchFieldParams): import("@depict-ai/utilishared").Node_Array;
824
+ export function SearchField(props: SearchFieldParams): HTMLDivElement[];
828
825
  export type BaseProviderConfig<InputDisplay extends Display, PossibleTransformedDisplay extends ModernDisplay | never> = {
829
826
  /**
830
827
  * The merchant to use for the search.