@depict-ai/react-ui 1.5.3 → 1.5.4

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,28 +1,28 @@
1
- import { BaseProductListingConfig, BaseProviderConfig, BaseSearchProviderConfig, ModernDisplayWithPageUrl, BaseSearchPageConfig, BaseCategoryPageConfig, CategoryTitle, embedded_num_products, ImagePlaceholder as _ImagePlaceholder1, TextPlaceholder as _TextPlaceholder1, ExclusiveId, fetchDepictRecommendations } from "@depict-ai/ui";
2
- import { Display, ModernDisplay } from "@depict-ai/utilishared";
1
+ import { BaseProductListingConfig, BaseProviderConfig, BaseSearchProviderConfig, ModernDisplayWithPageUrl, BaseSearchPageConfig, BaseCategoryPageConfig, CategoryTitle, embedded_num_products, ImagePlaceholder as _ImagePlaceholder1, TextPlaceholder as _TextPlaceholder1, ExclusiveId, fetchDepictRecommendations } from "@depict-ai/ui/ES10";
2
+ import { Display, ModernDisplay } from "@depict-ai/utilishared/ES10";
3
3
  import React, { ReactNode, PropsWithChildren, ReactElement } from "react";
4
- import { DPC } from "@depict-ai/dpc";
5
- import { Locale } from "@depict-ai/ui/locales";
6
- export const version = "1.5.3";
4
+ import { DPC } from "@depict-ai/dpc/ES10";
5
+ import { Locale } from "@depict-ai/ui/locales/ES10";
6
+ export const version = "1.5.4";
7
7
  interface PLPConfig<T extends Display> extends BaseProductListingConfig {
8
- /**
9
- * The product card to use for rendering products.
10
- */
11
- productCard: DepictProductCard<T>;
8
+ /**
9
+ * The product card to use for rendering products.
10
+ */
11
+ productCard: DepictProductCard<T>;
12
12
  }
13
13
  /**
14
14
  * The Depict product card props.
15
15
  */
16
16
  export interface DepictProductCardProps<T extends Display> {
17
- /** The display data to render. */
18
- display: T | null;
17
+ /** The display data to render. */
18
+ display: T | null;
19
19
  }
20
20
  /**
21
21
  * Depict product card to use for rendering products.
22
22
  */
23
23
  export type DepictProductCard<T extends Display> = (props: DepictProductCardProps<T>) => ReactNode;
24
24
  interface UsePerformanceClientReturn {
25
- dpc: DPC;
25
+ dpc: DPC;
26
26
  }
27
27
  /**
28
28
  * Hook used to access the Depict Performance Client.
@@ -52,66 +52,66 @@ export const usePerformanceClient: () => UsePerformanceClientReturn;
52
52
  * replace: Whether to replace the current url or push a new one.
53
53
  */
54
54
  type NavigateFunction = (relativeUrl: string, options: {
55
- replace: boolean;
56
- scroll: boolean;
55
+ replace: boolean;
56
+ scroll: boolean;
57
57
  }) => void;
58
58
  /**
59
59
  * The config for the DepictProvider.
60
60
  */
61
61
  type ProviderConfig<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never> = BaseProviderConfig<OriginalDisplay, OutputDisplay> & {
62
- /**
63
- * The function to use for navigating to a new page.
64
- * This function will be used internally by our components to navigate.
65
- *
66
- * You don't need to provide any in a Next.js context.
67
- *
68
- * @param relativeUrl - The relative url to navigate to.
69
- *
70
- * @example
71
- * Here is how you would use it with react-router, @reach/router, Gatsby or similar.
72
- * ```tsx
73
- * import { DepictProvider, Navigation } from "@depict-ai/react-ui";
74
- * import { useNavigate } from "react-router-dom";
75
- * // import { navigate } from "gatsby";
76
- *
77
- * function Router() {
78
- * const navigate = useNavigate();
79
- * return (
80
- * <DepictProvider
81
- * merchant="houdini"
82
- * market="en-de"
83
- * navigateFunction={navigate}
84
- * search={{
85
- * searchPagePath: "/search",
86
- * }}
87
- * >
88
- * <Routes>[...]</Routes>
89
- * </DepictProvider>
90
- * );
91
- * }
92
- * ```
93
- * @example
94
- * If you're using another library, you can define your own navigate function, that's compatible with the `NavigateFunction` type.
95
- * ```tsx
96
- * const navigateFunction = (relativeUrl: string, { replace }) => {
97
- * router.push(relativeUrl, { replace });
98
- * };
99
- * ```
100
- */
101
- navigateFunction?: NavigateFunction;
102
- /**
103
- * The locale to use for the Depict components.
104
- * @default en
105
- */
106
- locale?: Locale;
107
- /**
108
- * Unique ID of the currently logged in user, if applicable.
109
- */
110
- userId?: string;
111
- /**
112
- * Options that are required for search functionality.
113
- */
114
- search?: BaseSearchProviderConfig;
62
+ /**
63
+ * The function to use for navigating to a new page.
64
+ * This function will be used internally by our components to navigate.
65
+ *
66
+ * You don't need to provide any in a Next.js context.
67
+ *
68
+ * @param relativeUrl - The relative url to navigate to.
69
+ *
70
+ * @example
71
+ * Here is how you would use it with react-router, @reach/router, Gatsby or similar.
72
+ * ```tsx
73
+ * import { DepictProvider, Navigation } from "@depict-ai/react-ui";
74
+ * import { useNavigate } from "react-router-dom";
75
+ * // import { navigate } from "gatsby";
76
+ *
77
+ * function Router() {
78
+ * const navigate = useNavigate();
79
+ * return (
80
+ * <DepictProvider
81
+ * merchant="houdini"
82
+ * market="en-de"
83
+ * navigateFunction={navigate}
84
+ * search={{
85
+ * searchPagePath: "/search",
86
+ * }}
87
+ * >
88
+ * <Routes>[...]</Routes>
89
+ * </DepictProvider>
90
+ * );
91
+ * }
92
+ * ```
93
+ * @example
94
+ * If you're using another library, you can define your own navigate function, that's compatible with the `NavigateFunction` type.
95
+ * ```tsx
96
+ * const navigateFunction = (relativeUrl: string, { replace }) => {
97
+ * router.push(relativeUrl, { replace });
98
+ * };
99
+ * ```
100
+ */
101
+ navigateFunction?: NavigateFunction;
102
+ /**
103
+ * The locale to use for the Depict components.
104
+ * @default en
105
+ */
106
+ locale?: Locale;
107
+ /**
108
+ * Unique ID of the currently logged in user, if applicable.
109
+ */
110
+ userId?: string;
111
+ /**
112
+ * Options that are required for search functionality.
113
+ */
114
+ search?: BaseSearchProviderConfig;
115
115
  };
116
116
  /**
117
117
  * The DepictProvider is a wrapper component that should be used to wrap any component that uses Depict components.
@@ -139,7 +139,7 @@ type ProviderConfig<OriginalDisplay extends Display, OutputDisplay extends Moder
139
139
  * @returns {JSX.Element} The DepictProvider.
140
140
  */
141
141
  export function DepictProvider<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never>(props: PropsWithChildren<ProviderConfig<InputDisplay, OutputDisplay>>): import("react").FunctionComponentElement<{
142
- children?: import("react").ReactNode;
142
+ children?: import("react").ReactNode;
143
143
  }>;
144
144
  /**
145
145
  * A component used to align other Depict components to.
@@ -169,10 +169,10 @@ export function DepictProvider<InputDisplay extends Display, OutputDisplay exten
169
169
  */
170
170
  export const ComponentAligner: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
171
171
  interface SearchPageConfig<T extends Display> extends BaseSearchPageConfig, PLPConfig<T> {
172
- /**
173
- * When using multiple search instances on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a modal with a SearchPage keyed component, set the same stateKey on both. If no stateKey is provided, the "default" instance will be used.
174
- */
175
- stateKey?: string;
172
+ /**
173
+ * When using multiple search instances on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a modal with a SearchPage keyed component, set the same stateKey on both. If no stateKey is provided, the "default" instance will be used.
174
+ */
175
+ stateKey?: string;
176
176
  }
177
177
  /**
178
178
  * SearchPage is a component that renders a Depict search results page.
@@ -214,32 +214,30 @@ interface SearchPageConfig<T extends Display> extends BaseSearchPageConfig, PLPC
214
214
  *
215
215
  * ```
216
216
  */
217
- export function SearchPage<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never>(props: SearchPageConfig<[
218
- OutputDisplay
219
- ] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<OutputDisplay>>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
217
+ export function SearchPage<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never>(props: SearchPageConfig<[OutputDisplay] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<OutputDisplay>>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
220
218
  interface CategoryPageConfig<T extends Display> extends BaseCategoryPageConfig, PLPConfig<T> {
221
- /**
222
- * The category id to show.
223
- */
224
- categoryId: string;
225
- /**
226
- * categoryTitlePlugin is an optional plugin that can be used to customize the title of the category page.
227
- * @default CategoryTitle
228
- *
229
- * @example
230
- * ```tsx
231
- * <CategoryPage categoryId="jeans" productCard={MyCustomCategoryProductCard} categoryTitlePlugin={EmbeddedNumProducts} />
232
- * ```
233
- */
234
- categoryTitlePlugin?: typeof CategoryTitle | typeof embedded_num_products;
235
- /**
236
- * Whether this page is a collection or a category. If not specified it will be inferred as described in the docs https://docs.depict.ai/reference/category-sdk/specifying-listing-type-in-the-category-page-sdk
237
- */
238
- listingType?: "collection" | "category";
239
- /**
240
- * When using multiple CategoryPage components on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a certain BreadCrumbs or QuickLinks component with a certain CategoryPage component, set the same stateKey on both.
241
- */
242
- stateKey?: string;
219
+ /**
220
+ * The category id to show.
221
+ */
222
+ categoryId: string;
223
+ /**
224
+ * categoryTitlePlugin is an optional plugin that can be used to customize the title of the category page.
225
+ * @default CategoryTitle
226
+ *
227
+ * @example
228
+ * ```tsx
229
+ * <CategoryPage categoryId="jeans" productCard={MyCustomCategoryProductCard} categoryTitlePlugin={EmbeddedNumProducts} />
230
+ * ```
231
+ */
232
+ categoryTitlePlugin?: typeof CategoryTitle | typeof embedded_num_products;
233
+ /**
234
+ * Whether this page is a collection or a category. If not specified it will be inferred as described in the docs https://docs.depict.ai/reference/category-sdk/specifying-listing-type-in-the-category-page-sdk
235
+ */
236
+ listingType?: "collection" | "category";
237
+ /**
238
+ * When using multiple CategoryPage components on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a certain BreadCrumbs or QuickLinks component with a certain CategoryPage component, set the same stateKey on both.
239
+ */
240
+ stateKey?: string;
243
241
  }
244
242
  /**
245
243
  * CategoryPage is a component that renders a Depict category page. Go to definition on the props for more info.
@@ -280,22 +278,20 @@ interface CategoryPageConfig<T extends Display> extends BaseCategoryPageConfig,
280
278
  * }
281
279
  * ```
282
280
  */
283
- export function CategoryPage<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never>(props: CategoryPageConfig<[
284
- OutputDisplay
285
- ] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<OutputDisplay>>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
281
+ export function CategoryPage<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never>(props: CategoryPageConfig<[OutputDisplay] extends [never] ? OriginalDisplay : ModernDisplayWithPageUrl<OutputDisplay>>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
286
282
  /**
287
283
  * BreadCrumbs is the "trail" in the header of a category page.
288
284
  * @property stateKey - When using multiple CategoryPage components on the same page, you need to set a unique stateKey for each one. To associate a certain BreadCrumbs component with a certain CategoryPage component, set the same stateKey on both.
289
285
  */
290
286
  export function BreadCrumbs(react_props: {
291
- stateKey?: string | undefined;
287
+ stateKey?: string | undefined;
292
288
  }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
293
289
  /**
294
290
  * QuickLinks is a component enabling the user to go sideways and downwards in the category tree.
295
291
  * @property stateKey - When using multiple CategoryPage components on the same page, you need to set a unique stateKey for each one. To associate a certain QuickLinks component with a certain CategoryPage component, set the same stateKey on both.
296
292
  */
297
293
  export function QuickLinks(react_props?: {
298
- stateKey?: string | undefined;
294
+ stateKey?: string | undefined;
299
295
  }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
300
296
  /**
301
297
  * A placeholder that can be used instead of an image or other block of content while it's loading.
@@ -307,7 +303,7 @@ export function QuickLinks(react_props?: {
307
303
  * @property style extra styles to add to the placeholder
308
304
  */
309
305
  export const ImagePlaceholder: React.FC<Parameters<typeof _ImagePlaceholder1>[0] & {
310
- className?: string;
306
+ className?: string;
311
307
  }>;
312
308
  /**
313
309
  * A Placeholder to use instead of some text, while it's loading. This is the inline version, meant to be embedded into sentences (or exist instead of them), etc.
@@ -318,50 +314,47 @@ export const ImagePlaceholder: React.FC<Parameters<typeof _ImagePlaceholder1>[0]
318
314
  * @property style extra styles to add to the placeholder
319
315
  */
320
316
  export const TextPlaceholder: React.FC<Parameters<typeof _TextPlaceholder1>[0] & {
321
- className?: string;
317
+ className?: string;
322
318
  }>;
323
319
  /**
324
320
  * Parameters to configure the search modal.
325
321
  */
326
322
  interface UseSearchModalParams {
327
- /**
328
- * How the modal should be opened.
329
- * Will default to "centered" if nothing else is specified.
330
- * - "centered" - The modal will be opened in the center of the screen.
331
- * - "aligned" - The modal will be opened aligned to the alignerRef element.
332
- */
333
- location?: ModalLocation;
334
- /**
335
- * The ref to the element that the modal should be aligned to.
336
- * This is only used when location is "aligned".
337
- * @default undefined
338
- * @example
339
- * ```tsx
340
- import React from "react";
341
- import { ComponentAligner, useSearchModal } from "@depict-ai/react-ui";
342
-
343
- const App = () => {
344
- const ref = React.createRef();
345
-
346
- const { open } = useSearchModal({
347
- location: "aligned",
348
- alignerRef: ref,
349
- });
350
-
351
- return (
352
- <div>
353
- <ComponentAligner ref={ref} />
354
- <button onClick={open}>Open</button>
355
- </div>
356
- );
357
- };
358
- * ```
359
- */
360
- alignerRef?: React.RefObject<HTMLElement>;
361
- /**
362
- * When using multiple search instances on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a modal with a SearchPage keyed component, set the same stateKey on both. If no stateKey is provided, the "default" instance will be used.
363
- */
364
- stateKey?: string;
323
+ /**
324
+ * How the modal should be opened.
325
+ * Will default to "centered" if nothing else is specified.
326
+ * - "centered" - The modal will be opened in the center of the screen.
327
+ * - "aligned" - The modal will be opened aligned to the alignerRef element.
328
+ */
329
+ location?: ModalLocation;
330
+ /**
331
+ * The ref to the element that the modal should be aligned to.
332
+ * This is only used when location is "aligned".
333
+ * @default undefined
334
+ * @example
335
+ * ```tsx
336
+ import React from "react";
337
+ import { ComponentAligner, useSearchModal } from "@depict-ai/react-ui";
338
+ const App = () => {
339
+ const ref = React.createRef();
340
+ const { open } = useSearchModal({
341
+ location: "aligned",
342
+ alignerRef: ref,
343
+ });
344
+ return (
345
+ <div>
346
+ <ComponentAligner ref={ref} />
347
+ <button onClick={open}>Open</button>
348
+ </div>
349
+ );
350
+ };
351
+ * ```
352
+ */
353
+ alignerRef?: React.RefObject<HTMLElement>;
354
+ /**
355
+ * When using multiple search instances on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a modal with a SearchPage keyed component, set the same stateKey on both. If no stateKey is provided, the "default" instance will be used.
356
+ */
357
+ stateKey?: string;
365
358
  }
366
359
  type OpenModal = () => void;
367
360
  /**
@@ -369,7 +362,7 @@ type OpenModal = () => void;
369
362
  */
370
363
  type ModalLocation = "centered" | "aligned";
371
364
  interface UseSearchModalReturn {
372
- open: OpenModal;
365
+ open: OpenModal;
373
366
  }
374
367
  /**
375
368
  * Hook used to open the search modal.
@@ -395,25 +388,25 @@ interface UseSearchModalReturn {
395
388
  */
396
389
  export function useSearchModal(params?: UseSearchModalParams): UseSearchModalReturn;
397
390
  interface SearchFieldProps {
398
- /**
399
- * A reference to the DOM element that the modal should be aligned to.
400
- *
401
- * The top of the modal will be aligned to the top of the element.
402
- *
403
- * The height of the search field in the modal will be the same as the height of the element.
404
- * If not provided, the modal will be aligned to the search field itself.
405
- */
406
- alignerRef?: React.RefObject<HTMLElement>;
407
- /**
408
- * When using multiple search instances on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a modal with a SearchPage keyed component, set the same stateKey on both. If no stateKey is provided, the "default" instance will be used.
409
- */
410
- stateKey?: string;
391
+ /**
392
+ * A reference to the DOM element that the modal should be aligned to.
393
+ *
394
+ * The top of the modal will be aligned to the top of the element.
395
+ *
396
+ * The height of the search field in the modal will be the same as the height of the element.
397
+ * If not provided, the modal will be aligned to the search field itself.
398
+ */
399
+ alignerRef?: React.RefObject<HTMLElement>;
400
+ /**
401
+ * When using multiple search instances on the same page, you need to set a unique stateKey for each one. We recommend using an incrementing number, such as "1", "2", "3", etc. To associate a modal with a SearchPage keyed component, set the same stateKey on both. If no stateKey is provided, the "default" instance will be used.
402
+ */
403
+ stateKey?: string;
411
404
  }
412
405
  interface UseSearchFieldReturn {
413
- /**
414
- * A React component that renders the search field.
415
- */
416
- SearchField: () => ReactElement;
406
+ /**
407
+ * A React component that renders the search field.
408
+ */
409
+ SearchField: () => ReactElement;
417
410
  }
418
411
  /**
419
412
  * Hook used to configure the Depict search field.
@@ -458,21 +451,21 @@ interface UseSearchFieldReturn {
458
451
  export const useSearchField: (props?: SearchFieldProps) => UseSearchFieldReturn;
459
452
  type FetchRecsOptions = Omit<Parameters<typeof fetchDepictRecommendations>[0], "merchant" | "market" | "userId" | "sessionId"> & ExclusiveId;
460
453
  interface UseFetchRecommendationsReturn<T extends Display> {
461
- /**
462
- * Fetch recommendations from the Depict API.
463
- * @example
464
- * General recommendations for a landing page:
465
- * ```tsx
466
- * fetchRecommendations({ type: "landing_page" });
467
- * ```
468
- * @example
469
- * Fetch targeted recommendations for a product details page (PDP):
470
- * ```tsx
471
- * fetchRecommendations({ type: "related", productId: "t-shirt-white" })
472
- * ```
473
- * @returns {Promise<T[]>}
474
- */
475
- fetchRecommendations: (opts: FetchRecsOptions) => Promise<T[]>;
454
+ /**
455
+ * Fetch recommendations from the Depict API.
456
+ * @example
457
+ * General recommendations for a landing page:
458
+ * ```tsx
459
+ * fetchRecommendations({ type: "landing_page" });
460
+ * ```
461
+ * @example
462
+ * Fetch targeted recommendations for a product details page (PDP):
463
+ * ```tsx
464
+ * fetchRecommendations({ type: "related", productId: "t-shirt-white" })
465
+ * ```
466
+ * @returns {Promise<T[]>}
467
+ */
468
+ fetchRecommendations: (opts: FetchRecsOptions) => Promise<T[]>;
476
469
  }
477
470
  /**
478
471
  * Hook used to fetch Depict recommendations.
@@ -529,8 +522,8 @@ export function useFetchRecommendations<T extends Display>(): UseFetchRecommenda
529
522
  * Helper function to navigate to a new page depending on the navigation library used.
530
523
  */
531
524
  export const Navigation: {
532
- nextRouterNavigation: (router: import("next/router").NextRouter) => import("ui/components/DepictProvider").NavigateFunction;
525
+ nextRouterNavigation: (router: import("next/router").NextRouter) => import("ui/components/DepictProvider").NavigateFunction;
533
526
  };
534
527
  export { CategoryTitle, embedded_num_products as EmbeddedNumProducts } from "@depict-ai/ui";
535
528
  export type { PageURLCreator } from "@depict-ai/ui";
536
- export type { Locale } from "@depict-ai/ui/locales";
529
+ export type { Locale } from "@depict-ai/ui/locales";