@depict-ai/react-ui 1.5.20 → 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.
Files changed (49) hide show
  1. package/ES10/index.cjs +152 -69
  2. package/ES10/index.d.ts +549 -37
  3. package/ES10/index.js +155 -74
  4. package/README.md +2 -1
  5. package/dist/main.js +293 -0
  6. package/dist/module.js +285 -0
  7. package/dist/styles/components/PLP/Buttons.scss +124 -0
  8. package/dist/styles/components/PLP/MorphingSign.scss +31 -0
  9. package/dist/styles/components/PLP/PLPResults.scss +20 -0
  10. package/dist/styles/components/PLP/ProductListingPage.scss +142 -0
  11. package/dist/styles/components/PLP/ScrollStatus.scss +24 -0
  12. package/dist/styles/components/PLP/SelectedFilters.scss +74 -0
  13. package/dist/styles/components/PLP/SlidableItems.scss +99 -0
  14. package/dist/styles/components/PLP/SortAndFilter/FloatingButtons.scss +75 -0
  15. package/dist/styles/components/PLP/SortAndFilter/SortAndFilter.scss +728 -0
  16. package/dist/styles/components/PLP/SortAndFilter/SortAndFilterModal.scss +160 -0
  17. package/dist/styles/components/PLP/SortAndFilter/WhiteSortAndFilter.scss +148 -0
  18. package/dist/styles/components/PLP/Toast.scss +54 -0
  19. package/dist/styles/components/PLP/index.scss +45 -0
  20. package/dist/styles/components/category/BreadCrumbs.scss +23 -0
  21. package/dist/styles/components/category/CategoryTitle.scss +28 -0
  22. package/dist/styles/components/category/QuickLinks.scss +71 -0
  23. package/dist/styles/components/category/index.scss +23 -0
  24. package/dist/styles/components/search/Autocomplete.scss +117 -0
  25. package/dist/styles/components/search/CategorySuggestions.scss +74 -0
  26. package/dist/styles/components/search/InstantCard.scss +117 -0
  27. package/dist/styles/components/search/InstantResults.scss +10 -0
  28. package/dist/styles/components/search/PreviousSearches.scss +77 -0
  29. package/dist/styles/components/search/QueryInput.scss +167 -0
  30. package/dist/styles/components/search/SearchModal.scss +95 -0
  31. package/dist/styles/components/search/SearchRecommendations.scss +25 -0
  32. package/dist/styles/components/search/ShowingResultsFor.scss +10 -0
  33. package/dist/styles/components/search/index.scss +40 -0
  34. package/dist/styles/default.css +1 -0
  35. package/dist/styles/helpers/custom_input.scss +162 -0
  36. package/dist/styles/helpers/supports-hover.scss +5 -0
  37. package/dist/styles/helpers/utils.scss +82 -0
  38. package/dist/styles/plain-css-fallback-styling.css +1 -1
  39. package/dist/styles/variables.scss +47 -0
  40. package/latest/index.cjs +148 -68
  41. package/latest/index.d.ts +549 -37
  42. package/latest/index.js +151 -73
  43. package/package.json +9 -9
  44. package/server/ES10/index.cjs +128 -1
  45. package/server/ES10/index.d.ts +549 -37
  46. package/server/ES10/index.js +130 -5
  47. package/server/latest/index.cjs +125 -1
  48. package/server/latest/index.d.ts +549 -37
  49. package/server/latest/index.js +127 -5
@@ -1,20 +1,503 @@
1
- import { ReactElement } from "react";
2
1
  import { DPC } from "@depict-ai/dpc/latest";
3
- import { ExclusiveId, fetchDepictRecommendations, ImagePlaceholder as _ImagePlaceholder1, TextPlaceholder as _TextPlaceholder1 } from "@depict-ai/ui/latest";
4
- import { Display } from "@depict-ai/utilishared/latest";
2
+ import React, { PropsWithChildren, ReactNode, ReactPortal, ReactElement } from "react";
3
+ import { BaseProviderConfig, BaseSearchProviderConfig, BaseCategoryProviderConfig, ModernDisplayWithPageUrl, BaseProductListingConfig, BaseSearchPageConfig, BaseCategoryPageConfig, CategoryTitle, embedded_num_products, ImagePlaceholder as _ImagePlaceholder1, TextPlaceholder as _TextPlaceholder1, ExclusiveId, fetchDepictRecommendations } from "@depict-ai/ui/latest";
4
+ import { Locale } from "@depict-ai/ui/locales/latest";
5
+ import { Display, ModernDisplay } from "@depict-ai/utilishared/latest";
6
+ export const version = "2.0.1";
7
+ interface UsePerformanceClientReturn {
8
+ dpc: DPC;
9
+ }
10
+ /**
11
+ * Hook used to access the Depict Performance Client.
12
+ * Calls on the returned DPC instance can not be done server side.
13
+ * @example
14
+ * Send an add-to-cart event
15
+ * ```tsx
16
+ * import { useEffect } from "react";
17
+ * import { usePerformanceClient } from "@depict-ai/react-ui";
18
+ *
19
+ * const ProductPage = ({ productId }) => {
20
+ * const { dpc } = usePerformanceClient();
21
+ *
22
+ * useEffect(() => {
23
+ * dpc.setProductId(productId);
24
+ * }, [dpc, productId]);
25
+ *
26
+ * return <div>Showing product {productId}</div>;
27
+ * }
28
+ * ```
29
+ * @returns {UsePerformanceClientReturn}
30
+ }
31
+ */
32
+ export const usePerformanceClient: () => UsePerformanceClientReturn;
33
+ /**
34
+ * relativeUrl: The relative url to navigate to.
35
+ * replace: Whether to replace the current url or push a new one.
36
+ */
37
+ type NavigateFunction = (relativeUrl: string, options: {
38
+ replace: boolean;
39
+ scroll: boolean;
40
+ }) => void;
41
+ /**
42
+ * The config for the DepictProvider.
43
+ */
44
+ type ProviderConfig<OriginalDisplay extends Display, OutputDisplay extends ModernDisplay | never> = BaseProviderConfig<OriginalDisplay, OutputDisplay> & {
45
+ /**
46
+ * The function to use for navigating to a new page.
47
+ * This function will be used internally by our components to navigate.
48
+ *
49
+ * You don't need to provide any in a Next.js context.
50
+ *
51
+ * @param relativeUrl - The relative url to navigate to.
52
+ *
53
+ * @example
54
+ * Here is how you would use it with react-router, @reach/router, Gatsby or similar.
55
+ * ```tsx
56
+ * import { DepictProvider, Navigation } from "@depict-ai/react-ui";
57
+ * import { useNavigate } from "react-router-dom";
58
+ * // import { navigate } from "gatsby";
59
+ *
60
+ * function Router() {
61
+ * const navigate = useNavigate();
62
+ * return (
63
+ * <DepictProvider
64
+ * merchant="houdini"
65
+ * market="en-de"
66
+ * navigateFunction={navigate}
67
+ * search={{
68
+ * searchPagePath: "/search",
69
+ * }}
70
+ * >
71
+ * <Routes>[...]</Routes>
72
+ * </DepictProvider>
73
+ * );
74
+ * }
75
+ * ```
76
+ * @example
77
+ * If you're using another library, you can define your own navigate function, that's compatible with the `NavigateFunction` type.
78
+ * ```tsx
79
+ * const navigateFunction = (relativeUrl: string, { replace }) => {
80
+ * router.push(relativeUrl, { replace });
81
+ * };
82
+ * ```
83
+ */
84
+ navigateFunction?: NavigateFunction;
85
+ /**
86
+ * The locale to use for the Depict components.
87
+ * @default en
88
+ */
89
+ locale?: Locale;
90
+ /**
91
+ * Unique ID of the currently logged in user, if applicable.
92
+ */
93
+ userId?: string;
94
+ /**
95
+ * Options that are required for search functionality.
96
+ */
97
+ search?: BaseSearchProviderConfig;
98
+ /**
99
+ * Options that can be used for category page functionality.
100
+ */
101
+ category?: BaseCategoryProviderConfig;
102
+ };
103
+ /**
104
+ * The DepictProvider is a wrapper component that should be used to wrap any component that uses Depict components.
105
+ *
106
+ * Make sure it's mounted on every page where the search modal should be available.
107
+ *
108
+ * @param props - The props for the DepictProvider.
109
+ *
110
+ * @example
111
+ * ```tsx
112
+ * const App = () => { *
113
+ * return (
114
+ * <DepictProvider
115
+ * merchant="YOUR_MERCHANT"
116
+ * market="YOUR_MARKET"
117
+ * search={{
118
+ * searchPagePath: "/search",
119
+ * }}
120
+ * >
121
+ * <App />
122
+ * </DepictProvider>
123
+ * );
124
+ * };
125
+ * ```
126
+ * @returns {JSX.Element} The DepictProvider.
127
+ */
128
+ export function DepictProvider<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never>(props: PropsWithChildren<ProviderConfig<InputDisplay, OutputDisplay>>): import("react").FunctionComponentElement<{
129
+ children?: import("react").ReactNode;
130
+ }>;
131
+ /**
132
+ * A component used to align other Depict components to.
133
+ * @example
134
+ * Align the search modal
135
+ * ```tsx
136
+ * import React from "react";
137
+ * import { ComponentAligner, useSearchModal } from "@depict-ai/react-ui";
138
+ *
139
+ * const App = () => {
140
+ * const ref = React.createRef();
141
+ *
142
+ * const { open } = useSearchModal({
143
+ * location: "aligned",
144
+ * alignerRef: ref,
145
+ * });
146
+ *
147
+ * return (
148
+ * <div>
149
+ * <ComponentAligner ref={ref} />
150
+ * <button onClick={open}>Open</button>
151
+ * </div>
152
+ * );
153
+ * };
154
+ * ```
155
+ * @returns {JSX.Element}
156
+ */
157
+ export const ComponentAligner: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
158
+ interface PLPConfig<T extends Display> extends BaseProductListingConfig {
159
+ /**
160
+ * The product card to use for rendering products.
161
+ */
162
+ productCard: DepictProductCard<T>;
163
+ }
164
+ /**
165
+ * The Depict product card props.
166
+ */
167
+ export interface DepictProductCardProps<T extends Display> {
168
+ /** The display data to render. */
169
+ display: T | null;
170
+ }
171
+ /**
172
+ * Depict product card to use for rendering products.
173
+ */
174
+ export type DepictProductCard<T extends Display> = (props: DepictProductCardProps<T>) => ReactNode;
175
+ interface SearchPageConfig<T extends Display> extends BaseSearchPageConfig, PLPConfig<T> {
176
+ /**
177
+ * 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.
178
+ */
179
+ stateKey?: string;
180
+ }
181
+ /**
182
+ * SearchPage is a component that renders a Depict search results page.
183
+ * @param props - The props for the search page. Go to definition for more info.
184
+ *
185
+ * @example
186
+ * ```tsx
187
+ * import { DepictProductCard, ImagePlaceholder, Display, SearchPage } from '@depict-ai/react-ui'
188
+ *
189
+ * function Search() {
190
+ * return <SearchPage productCard={MyCustomSearchProductCard} />
191
+ * }
192
+ *
193
+ * interface MyCustomDisplay extends Display {}
194
+ *
195
+ * export const MyCustomSearchProductCard: DepictProductCard<MyCustomDisplay> = ({
196
+ * display,
197
+ * }) => {
198
+ * if (!display) {
199
+ * return <ImagePlaceholder aspectRatio={3 / 4} />
200
+ * }
201
+ *
202
+ * return (
203
+ * <>
204
+ * <MyCustomProductCard
205
+ * product={{
206
+ * id: display.product_id,
207
+ * name: display.title,
208
+ * description: display.title,
209
+ * images: [{ url: display.image_url }],
210
+ * price: {
211
+ * value: display.sale_price,
212
+ * },
213
+ * }}
214
+ * />
215
+ * </>
216
+ * )
217
+ * }
218
+ *
219
+ * ```
220
+ */
221
+ 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>>;
222
+ interface CategoryPageConfig<T extends Display> extends BaseCategoryPageConfig, PLPConfig<T> {
223
+ /**
224
+ * The category id to show.
225
+ */
226
+ categoryId: string;
227
+ /**
228
+ * categoryTitlePlugin is an optional plugin that can be used to customize the title of the category page.
229
+ * @default CategoryTitle
230
+ *
231
+ * @example
232
+ * ```tsx
233
+ * <CategoryPage categoryId="jeans" productCard={MyCustomCategoryProductCard} categoryTitlePlugin={EmbeddedNumProducts} />
234
+ * ```
235
+ */
236
+ categoryTitlePlugin?: typeof CategoryTitle | typeof embedded_num_products;
237
+ /**
238
+ * 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
239
+ */
240
+ listingType?: "collection" | "category";
241
+ /**
242
+ * 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.
243
+ */
244
+ stateKey?: string;
245
+ }
246
+ /**
247
+ * CategoryPage is a component that renders a Depict category page. Go to definition on the props for more info.
248
+ * @param props the props for the category page.
249
+ *
250
+ * @example
251
+ * ```tsx
252
+ * import { DepictProductCard, ImagePlaceholder, Display, CategoryPage } from '@depict-ai/react-ui'
253
+ *
254
+ * function Category() {
255
+ * return <CategoryPage categoryId="jeans" productCard={MyCustomCategoryProductCard} />
256
+ * }
257
+ *
258
+ * interface MyCustomDisplay extends Display {}
259
+ *
260
+ * export const MyCustomCategoryProductCard: DepictProductCard<MyCustomDisplay> = ({
261
+ * display,
262
+ * }) => {
263
+ * if (!display) {
264
+ * return <ImagePlaceholder aspectRatio={3 / 4} />
265
+ * }
266
+ *
267
+ * return (
268
+ * <>
269
+ * <MyCustomProductCard
270
+ * product={{
271
+ * id: display.product_id,
272
+ * name: display.title,
273
+ * description: display.title,
274
+ * images: [{ url: display.image_url }],
275
+ * price: {
276
+ * value: display.sale_price,
277
+ * },
278
+ * }}
279
+ * />
280
+ * </>
281
+ * )
282
+ * }
283
+ * ```
284
+ */
285
+ 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
+ /**
287
+ * BreadCrumbs is the "trail" in the header of a category page.
288
+ * @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
+ */
290
+ export function BreadCrumbs(react_props: {
291
+ stateKey?: string | undefined;
292
+ }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
293
+ /**
294
+ * QuickLinks is a component enabling the user to go sideways and downwards in the category tree.
295
+ * @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
+ */
297
+ export function QuickLinks(react_props?: {
298
+ stateKey?: string | undefined;
299
+ }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
300
+ /**
301
+ * A placeholder that can be used instead of an image or other block of content while it's loading.
302
+ * The placeholder has `display:block`, meaning it will create a new "row" in the layout for itself. Can be used either for images with a defined aspect ratio (ContainedImage) or blocks.
303
+ * @property aspectRatio if aspectRatio is defined the placeholder will be in "image mode" and fill out the available width and then adjust the height according to the aspectRatio
304
+ * @property width If width and height is set, the defined width and height will be used.
305
+ * @property height If width and height is set, the defined width and height will be used.
306
+ * @property class extra classes to add to the placeholder
307
+ * @property style extra styles to add to the placeholder
308
+ */
309
+ export const ImagePlaceholder: React.FC<Parameters<typeof _ImagePlaceholder1>[0] & {
310
+ className?: string;
311
+ }>;
312
+ /**
313
+ * 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.
314
+ * If you want a block version, use `ImagePlaceholder` with `width`and `height` set instead.
315
+ * @property height height of the placeholder. Set to `1em` by default.
316
+ * @property width width of the placeholder. For specific number of characters use `ch`, ex: `width="7ch"`
317
+ * @property className extra classes to add to the placeholder
318
+ * @property style extra styles to add to the placeholder
319
+ */
320
+ export const TextPlaceholder: React.FC<Parameters<typeof _TextPlaceholder1>[0] & {
321
+ className?: string;
322
+ }>;
323
+ interface RecommendationConfig<T extends Display> extends BaseProductListingConfig {
324
+ /**
325
+ * A promise containing the recommendations to render, see https://docs.depict.ai/api-guide/recommendations/api-client/fetching
326
+ */
327
+ recommendations: Promise<T[]>;
328
+ /**
329
+ * The product card function to use for rendering products.
330
+ */
331
+ productCard: DepictProductCard<T>;
332
+ }
333
+ interface RecommendationGridConfig<T extends Display> extends RecommendationConfig<T> {
334
+ maxRows?: number;
335
+ viewMoreButton?: {
336
+ text: string;
337
+ startRows?: number;
338
+ rowsPerClick?: number;
339
+ };
340
+ }
341
+ declare function SolidRecommendationWrapper<T extends Display>(props: RecommendationGridConfig<T>, set_portals: (portals: ReactPortal[]) => void): HTMLDivElement;
342
+ interface RecommendationSliderConfig<T extends Display> extends RecommendationConfig<T> {
343
+ viewMoreButton?: {
344
+ text: string;
345
+ startRows?: number;
346
+ rowsPerClick?: number;
347
+ };
348
+ }
349
+ /**
350
+ * Renders a slider of the provided products
351
+ * @param recommendations a promise resolving to an array of displays to render
352
+ * @param productCard a function that renders a product card or a placeholder for one
353
+ * @param columnsAtSize the number of columns to show at each media breakpoint
354
+ * @param gridSpacing the spacing between the product cards
355
+ */
356
+ export function RecommendationSlider<T extends Display>(props: Parameters<typeof SolidRecommendationSliderWrapper<T>>[0]): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
357
+ declare function SolidRecommendationSliderWrapper<T extends Display>(props: RecommendationSliderConfig<T>, set_portals: (portals: ReactPortal[]) => void): HTMLDivElement;
358
+ /**
359
+ * Renders a product grid of the provided products
360
+ * @param recommendations a promise resolving to an array of displays to render
361
+ * @param productCard a function that renders a product card or a placeholder for one
362
+ * @param columnsAtSize the number of columns to show at each media breakpoint
363
+ * @param gridSpacing the spacing between the product cards
364
+ * @param maxRows the maximum number of rows to show.
365
+ * @param viewMoreButton optional configuration for the view more button. If unset, all products will be shown by default. Otherwise, a view more button with the given text will be shown. With the properties startRows and rowsPerClick, you can configure how many rows should be shown initially and how many rows should be added on each click.
366
+ */
367
+ export function RecommendationGrid<T extends Display>(props: Parameters<typeof SolidRecommendationWrapper<T>>[0]): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
368
+ /**
369
+ * Parameters to configure the search modal.
370
+ */
371
+ interface UseSearchModalParams {
372
+ /**
373
+ * How the modal should be opened.
374
+ * Will default to "centered" if nothing else is specified.
375
+ * - "centered" - The modal will be opened in the center of the screen.
376
+ * - "aligned" - The modal will be opened aligned to the alignerRef element.
377
+ */
378
+ location?: ModalLocation;
379
+ /**
380
+ * The ref to the element that the modal should be aligned to.
381
+ * This is only used when location is "aligned".
382
+ * @default undefined
383
+ * @example
384
+ * ```tsx
385
+ import React from "react";
386
+ import { ComponentAligner, useSearchModal } from "@depict-ai/react-ui";
387
+ const App = () => {
388
+ const ref = React.createRef();
389
+ const { open } = useSearchModal({
390
+ location: "aligned",
391
+ alignerRef: ref,
392
+ });
393
+ return (
394
+ <div>
395
+ <ComponentAligner ref={ref} />
396
+ <button onClick={open}>Open</button>
397
+ </div>
398
+ );
399
+ };
400
+ * ```
401
+ */
402
+ alignerRef?: React.RefObject<HTMLElement>;
403
+ /**
404
+ * 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.
405
+ */
406
+ stateKey?: string;
407
+ }
5
408
  type OpenModal = () => void;
409
+ /**
410
+ * How the modal should be opened.
411
+ */
412
+ type ModalLocation = "centered" | "aligned";
6
413
  interface UseSearchModalReturn {
7
414
  open: OpenModal;
8
415
  }
416
+ /**
417
+ * Hook used to open the search modal.
418
+ * @example
419
+ * Open a centered modal:
420
+ * ```tsx
421
+ * import React from "react";
422
+ * import { useSearchModal } from "@depict-ai/react-ui";
423
+ *
424
+ * const App = () => {
425
+ * const { open } = useSearchModal({
426
+ * location: "centered",
427
+ * });
428
+ *
429
+ * return (
430
+ * <div>
431
+ * <button onClick={open}>Open</button>
432
+ * </div>
433
+ * );
434
+ * };
435
+ * ```
436
+ * @returns {UseSearchModalReturn}
437
+ */
438
+ export function useSearchModal(params?: UseSearchModalParams): UseSearchModalReturn;
439
+ interface SearchFieldProps {
440
+ /**
441
+ * A reference to the DOM element that the modal should be aligned to.
442
+ *
443
+ * The top of the modal will be aligned to the top of the element.
444
+ *
445
+ * The height of the search field in the modal will be the same as the height of the element.
446
+ * If not provided, the modal will be aligned to the search field itself.
447
+ */
448
+ alignerRef?: React.RefObject<HTMLElement>;
449
+ /**
450
+ * 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.
451
+ */
452
+ stateKey?: string;
453
+ }
9
454
  interface UseSearchFieldReturn {
10
455
  /**
11
456
  * A React component that renders the search field.
12
457
  */
13
458
  SearchField: () => ReactElement;
14
459
  }
15
- interface UsePerformanceClientReturn {
16
- dpc: DPC;
17
- }
460
+ /**
461
+ * Hook used to configure the Depict search field.
462
+ * @example
463
+ * Render a search field that opens a modal aligned to the search field itself:
464
+ * ```tsx
465
+ * import React from "react";
466
+ * import { useSearchField } from "@depict-ai/react-ui";
467
+ *
468
+ * const App = () => {
469
+ * const { SearchField } = useSearchField();
470
+ *
471
+ * return (
472
+ * <div>
473
+ * <SearchField />
474
+ * </div>
475
+ * );
476
+ * };
477
+ * ```
478
+ * @example
479
+ * Render a search field that opens a modal aligned another DOM element:
480
+ * ```tsx
481
+ * import React from "react";
482
+ * import { ComponentAligner, useSearchField } from "@depict-ai/react-ui";
483
+ *
484
+ * const App = () => {
485
+ * const ref = useRef(null);
486
+ * const { SearchField } = useSearchField({
487
+ * alignerRef: ref
488
+ * });
489
+ *
490
+ * return (
491
+ * <div>
492
+ * <ComponentAligner ref={ref} />
493
+ * <SearchField />
494
+ * </div>
495
+ * );
496
+ * };
497
+ * ```
498
+ * @returns {UseSearchFieldReturn}
499
+ */
500
+ export const useSearchField: (props?: SearchFieldProps) => UseSearchFieldReturn;
18
501
  type FetchRecsOptions = Omit<Parameters<typeof fetchDepictRecommendations>[0], "merchant" | "market" | "userId" | "sessionId"> & ExclusiveId;
19
502
  interface UseFetchRecommendationsReturn<T extends Display> {
20
503
  /**
@@ -33,34 +516,63 @@ interface UseFetchRecommendationsReturn<T extends Display> {
33
516
  */
34
517
  fetchRecommendations: (opts: FetchRecsOptions) => Promise<T[]>;
35
518
  }
36
- export const version = "1.5.20";
37
- export function DepictProvider(props: any): any;
38
- export function SearchPage(): import("react").DetailedReactHTMLElement<{
39
- children: never[];
40
- }, HTMLElement>;
41
- export function CategoryPage(): import("react").DetailedReactHTMLElement<{
42
- children: never[];
43
- }, HTMLElement>;
44
- export function BreadCrumbs(): import("react").DetailedReactHTMLElement<{
45
- children: never[];
46
- }, HTMLElement>;
47
- export function QuickLinks(): import("react").DetailedReactHTMLElement<{
48
- children: never[];
49
- }, HTMLElement>;
50
- export function ComponentAligner(): import("react").DetailedReactHTMLElement<{
51
- className: string;
52
- style: {
53
- height: string;
54
- };
55
- }, HTMLElement>;
56
- export function ImagePlaceholder(raw_react_props: Parameters<typeof _ImagePlaceholder1>[0] & {
57
- className: string;
58
- }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
59
- export function TextPlaceholder(raw_react_props: Omit<Parameters<typeof _TextPlaceholder1>[0], "class"> & {
60
- className: string;
61
- }): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
62
- export function useSearchField(): UseSearchFieldReturn;
63
- export function openModal(): void;
64
- export function useSearchModal(): UseSearchModalReturn;
65
- export function usePerformanceClient(): UsePerformanceClientReturn;
66
- export function useFetchRecommendations<T extends Display>(): UseFetchRecommendationsReturn<T>;
519
+ /**
520
+ * Hook used to fetch Depict recommendations.
521
+ * @example
522
+ * Fetch general recommendations for a landing page:
523
+ * ```tsx
524
+ * import React from "react";
525
+ * import { useFetchRecommendations } from "@depict-ai/react-ui";
526
+ *
527
+ * export const LandingPage = () => {
528
+ * const [recs, setRecs] = React.useState();
529
+ * const { fetchRecommendations } = useFetchRecommendations();
530
+ *
531
+ * React.useEffect(() => {
532
+ * fetchRecommendations({ type: "landing_page" }).then(setRecs);
533
+ * }, [fetchRecommendations]);
534
+ *
535
+ * return (
536
+ * <div>
537
+ * {recs?.map((display) => (
538
+ * <ProductCard display={display} />
539
+ * ))}
540
+ * </div>
541
+ * );
542
+ * };
543
+ * ```
544
+ * @example
545
+ * Fetch targeted recommendations for a product details page (PDP):
546
+ * ```tsx
547
+ * import React from "react";
548
+ * import { useFetchRecommendations } from "@depict-ai/react-ui";
549
+ *
550
+ * export const ProductPage = ({ productId }) => {
551
+ * const [recs, setRecs] = React.useState();
552
+ * const { fetchRecommendations } = useFetchRecommendations();
553
+ *
554
+ * React.useEffect(() => {
555
+ * fetchRecommendations({ type: "related", productId }).then(setRecs);
556
+ * }, [fetchRecommendations, productId]);
557
+ *
558
+ * return (
559
+ * <div>
560
+ * {recs?.map((display) => (
561
+ * <ProductCard display={display} />
562
+ * ))}
563
+ * </div>
564
+ * );
565
+ * };
566
+ * ```
567
+ * @returns {UseFetchRecommendationsReturn}
568
+ */
569
+ export function useFetchRecommendations<T extends Display>(): UseFetchRecommendationsReturn<T>;
570
+ /**
571
+ * Helper function to navigate to a new page depending on the navigation library used.
572
+ */
573
+ export const Navigation: {
574
+ nextRouterNavigation: (router: import("next/router").NextRouter) => import("ui/components/DepictProvider").NavigateFunction;
575
+ };
576
+ export { CategoryTitle, embedded_num_products as EmbeddedNumProducts } from "@depict-ai/ui";
577
+ export type { PageURLCreator, DisplayTransformers } from "@depict-ai/ui";
578
+ export type { Locale } from "@depict-ai/ui/locales";