@depict-ai/react-ui 1.0.10 → 1.0.11

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