@depict-ai/react-ui 1.5.19 → 1.5.20
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.cjs +1 -1
- package/ES10/index.d.ts +37 -504
- package/ES10/index.js +1 -1
- package/dist/styles/plain-css-fallback-styling.css +1 -1
- package/latest/index.cjs +1 -1
- package/latest/index.d.ts +37 -504
- package/latest/index.js +1 -1
- package/package.json +6 -6
- package/server/ES10/index.cjs +1 -1
- package/server/ES10/index.d.ts +37 -504
- package/server/ES10/index.js +1 -1
- package/server/latest/index.cjs +1 -1
- package/server/latest/index.d.ts +37 -504
- package/server/latest/index.js +1 -1
package/ES10/index.cjs
CHANGED
|
@@ -35,7 +35,7 @@ $parcel$export(module.exports, "version", () => $efbdd2dab4314170$export$83d89fb
|
|
|
35
35
|
$parcel$export(module.exports, "Navigation", () => $0d3a2413fdeb34b9$export$b8a61e5c71402559);
|
|
36
36
|
/*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
|
|
37
37
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
38
|
-
const $efbdd2dab4314170$export$83d89fbfd8236492 = "1.5.
|
|
38
|
+
const $efbdd2dab4314170$export$83d89fbfd8236492 = "1.5.20";
|
|
39
39
|
const $ef516b1f92253963$export$8e769ad4338a911e = {
|
|
40
40
|
usedLocale: $2kiy7$solidjs.createSignal((0, $2kiy7$depictaiuilocales.defaultLocale)),
|
|
41
41
|
search_instances: new Map(),
|
package/ES10/index.d.ts
CHANGED
|
@@ -1,458 +1,20 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Display, ModernDisplay } from "@depict-ai/utilishared/ES10";
|
|
3
|
-
import React, { ReactNode, PropsWithChildren, ReactElement } from "react";
|
|
1
|
+
import { ReactElement } from "react";
|
|
4
2
|
import { DPC } from "@depict-ai/dpc/ES10";
|
|
5
|
-
import {
|
|
6
|
-
|
|
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
|
-
scroll: boolean;
|
|
57
|
-
}) => void;
|
|
58
|
-
/**
|
|
59
|
-
* The config for the DepictProvider.
|
|
60
|
-
*/
|
|
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;
|
|
115
|
-
/**
|
|
116
|
-
* Options that can be used for category page functionality.
|
|
117
|
-
*/
|
|
118
|
-
category?: BaseCategoryProviderConfig;
|
|
119
|
-
};
|
|
120
|
-
/**
|
|
121
|
-
* The DepictProvider is a wrapper component that should be used to wrap any component that uses Depict components.
|
|
122
|
-
*
|
|
123
|
-
* Make sure it's mounted on every page where the search modal should be available.
|
|
124
|
-
*
|
|
125
|
-
* @param props - The props for the DepictProvider.
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```tsx
|
|
129
|
-
* const App = () => { *
|
|
130
|
-
* return (
|
|
131
|
-
* <DepictProvider
|
|
132
|
-
* merchant="YOUR_MERCHANT"
|
|
133
|
-
* market="YOUR_MARKET"
|
|
134
|
-
* search={{
|
|
135
|
-
* searchPagePath: "/search",
|
|
136
|
-
* }}
|
|
137
|
-
* >
|
|
138
|
-
* <App />
|
|
139
|
-
* </DepictProvider>
|
|
140
|
-
* );
|
|
141
|
-
* };
|
|
142
|
-
* ```
|
|
143
|
-
* @returns {JSX.Element} The DepictProvider.
|
|
144
|
-
*/
|
|
145
|
-
export function DepictProvider<InputDisplay extends Display, OutputDisplay extends ModernDisplay | never = InputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<InputDisplay> : never>(props: PropsWithChildren<ProviderConfig<InputDisplay, OutputDisplay>>): import("react").FunctionComponentElement<{
|
|
146
|
-
children?: import("react").ReactNode;
|
|
147
|
-
}>;
|
|
148
|
-
/**
|
|
149
|
-
* A component used to align other Depict components to.
|
|
150
|
-
* @example
|
|
151
|
-
* Align the search modal
|
|
152
|
-
* ```tsx
|
|
153
|
-
* import React from "react";
|
|
154
|
-
* import { ComponentAligner, useSearchModal } from "@depict-ai/react-ui";
|
|
155
|
-
*
|
|
156
|
-
* const App = () => {
|
|
157
|
-
* const ref = React.createRef();
|
|
158
|
-
*
|
|
159
|
-
* const { open } = useSearchModal({
|
|
160
|
-
* location: "aligned",
|
|
161
|
-
* alignerRef: ref,
|
|
162
|
-
* });
|
|
163
|
-
*
|
|
164
|
-
* return (
|
|
165
|
-
* <div>
|
|
166
|
-
* <ComponentAligner ref={ref} />
|
|
167
|
-
* <button onClick={open}>Open</button>
|
|
168
|
-
* </div>
|
|
169
|
-
* );
|
|
170
|
-
* };
|
|
171
|
-
* ```
|
|
172
|
-
* @returns {JSX.Element}
|
|
173
|
-
*/
|
|
174
|
-
export const ComponentAligner: import("react").ForwardRefExoticComponent<import("react").RefAttributes<unknown>>;
|
|
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
|
-
/**
|
|
324
|
-
* Parameters to configure the search modal.
|
|
325
|
-
*/
|
|
326
|
-
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
|
-
const App = () => {
|
|
343
|
-
const ref = React.createRef();
|
|
344
|
-
const { open } = useSearchModal({
|
|
345
|
-
location: "aligned",
|
|
346
|
-
alignerRef: ref,
|
|
347
|
-
});
|
|
348
|
-
return (
|
|
349
|
-
<div>
|
|
350
|
-
<ComponentAligner ref={ref} />
|
|
351
|
-
<button onClick={open}>Open</button>
|
|
352
|
-
</div>
|
|
353
|
-
);
|
|
354
|
-
};
|
|
355
|
-
* ```
|
|
356
|
-
*/
|
|
357
|
-
alignerRef?: React.RefObject<HTMLElement>;
|
|
358
|
-
/**
|
|
359
|
-
* 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.
|
|
360
|
-
*/
|
|
361
|
-
stateKey?: string;
|
|
362
|
-
}
|
|
3
|
+
import { ExclusiveId, fetchDepictRecommendations, ImagePlaceholder as _ImagePlaceholder1, TextPlaceholder as _TextPlaceholder1 } from "@depict-ai/ui/ES10";
|
|
4
|
+
import { Display } from "@depict-ai/utilishared/ES10";
|
|
363
5
|
type OpenModal = () => void;
|
|
364
|
-
/**
|
|
365
|
-
* How the modal should be opened.
|
|
366
|
-
*/
|
|
367
|
-
type ModalLocation = "centered" | "aligned";
|
|
368
6
|
interface UseSearchModalReturn {
|
|
369
7
|
open: OpenModal;
|
|
370
8
|
}
|
|
371
|
-
/**
|
|
372
|
-
* Hook used to open the search modal.
|
|
373
|
-
* @example
|
|
374
|
-
* Open a centered modal:
|
|
375
|
-
* ```tsx
|
|
376
|
-
* import React from "react";
|
|
377
|
-
* import { useSearchModal } from "@depict-ai/react-ui";
|
|
378
|
-
*
|
|
379
|
-
* const App = () => {
|
|
380
|
-
* const { open } = useSearchModal({
|
|
381
|
-
* location: "centered",
|
|
382
|
-
* });
|
|
383
|
-
*
|
|
384
|
-
* return (
|
|
385
|
-
* <div>
|
|
386
|
-
* <button onClick={open}>Open</button>
|
|
387
|
-
* </div>
|
|
388
|
-
* );
|
|
389
|
-
* };
|
|
390
|
-
* ```
|
|
391
|
-
* @returns {UseSearchModalReturn}
|
|
392
|
-
*/
|
|
393
|
-
export function useSearchModal(params?: UseSearchModalParams): UseSearchModalReturn;
|
|
394
|
-
interface SearchFieldProps {
|
|
395
|
-
/**
|
|
396
|
-
* A reference to the DOM element that the modal should be aligned to.
|
|
397
|
-
*
|
|
398
|
-
* The top of the modal will be aligned to the top of the element.
|
|
399
|
-
*
|
|
400
|
-
* The height of the search field in the modal will be the same as the height of the element.
|
|
401
|
-
* If not provided, the modal will be aligned to the search field itself.
|
|
402
|
-
*/
|
|
403
|
-
alignerRef?: React.RefObject<HTMLElement>;
|
|
404
|
-
/**
|
|
405
|
-
* 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.
|
|
406
|
-
*/
|
|
407
|
-
stateKey?: string;
|
|
408
|
-
}
|
|
409
9
|
interface UseSearchFieldReturn {
|
|
410
10
|
/**
|
|
411
11
|
* A React component that renders the search field.
|
|
412
12
|
*/
|
|
413
13
|
SearchField: () => ReactElement;
|
|
414
14
|
}
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
* Render a search field that opens a modal aligned to the search field itself:
|
|
419
|
-
* ```tsx
|
|
420
|
-
* import React from "react";
|
|
421
|
-
* import { useSearchField } from "@depict-ai/react-ui";
|
|
422
|
-
*
|
|
423
|
-
* const App = () => {
|
|
424
|
-
* const { SearchField } = useSearchField();
|
|
425
|
-
*
|
|
426
|
-
* return (
|
|
427
|
-
* <div>
|
|
428
|
-
* <SearchField />
|
|
429
|
-
* </div>
|
|
430
|
-
* );
|
|
431
|
-
* };
|
|
432
|
-
* ```
|
|
433
|
-
* @example
|
|
434
|
-
* Render a search field that opens a modal aligned another DOM element:
|
|
435
|
-
* ```tsx
|
|
436
|
-
* import React from "react";
|
|
437
|
-
* import { ComponentAligner, useSearchField } from "@depict-ai/react-ui";
|
|
438
|
-
*
|
|
439
|
-
* const App = () => {
|
|
440
|
-
* const ref = useRef(null);
|
|
441
|
-
* const { SearchField } = useSearchField({
|
|
442
|
-
* alignerRef: ref
|
|
443
|
-
* });
|
|
444
|
-
*
|
|
445
|
-
* return (
|
|
446
|
-
* <div>
|
|
447
|
-
* <ComponentAligner ref={ref} />
|
|
448
|
-
* <SearchField />
|
|
449
|
-
* </div>
|
|
450
|
-
* );
|
|
451
|
-
* };
|
|
452
|
-
* ```
|
|
453
|
-
* @returns {UseSearchFieldReturn}
|
|
454
|
-
*/
|
|
455
|
-
export const useSearchField: (props?: SearchFieldProps) => UseSearchFieldReturn;
|
|
15
|
+
interface UsePerformanceClientReturn {
|
|
16
|
+
dpc: DPC;
|
|
17
|
+
}
|
|
456
18
|
type FetchRecsOptions = Omit<Parameters<typeof fetchDepictRecommendations>[0], "merchant" | "market" | "userId" | "sessionId"> & ExclusiveId;
|
|
457
19
|
interface UseFetchRecommendationsReturn<T extends Display> {
|
|
458
20
|
/**
|
|
@@ -471,63 +33,34 @@ interface UseFetchRecommendationsReturn<T extends Display> {
|
|
|
471
33
|
*/
|
|
472
34
|
fetchRecommendations: (opts: FetchRecsOptions) => Promise<T[]>;
|
|
473
35
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
* export const ProductPage = ({ productId }) => {
|
|
506
|
-
* const [recs, setRecs] = React.useState();
|
|
507
|
-
* const { fetchRecommendations } = useFetchRecommendations();
|
|
508
|
-
*
|
|
509
|
-
* React.useEffect(() => {
|
|
510
|
-
* fetchRecommendations({ type: "related", productId }).then(setRecs);
|
|
511
|
-
* }, [fetchRecommendations, productId]);
|
|
512
|
-
*
|
|
513
|
-
* return (
|
|
514
|
-
* <div>
|
|
515
|
-
* {recs?.map((display) => (
|
|
516
|
-
* <ProductCard display={display} />
|
|
517
|
-
* ))}
|
|
518
|
-
* </div>
|
|
519
|
-
* );
|
|
520
|
-
* };
|
|
521
|
-
* ```
|
|
522
|
-
* @returns {UseFetchRecommendationsReturn}
|
|
523
|
-
*/
|
|
524
|
-
export function useFetchRecommendations<T extends Display>(): UseFetchRecommendationsReturn<T>;
|
|
525
|
-
/**
|
|
526
|
-
* Helper function to navigate to a new page depending on the navigation library used.
|
|
527
|
-
*/
|
|
528
|
-
export const Navigation: {
|
|
529
|
-
nextRouterNavigation: (router: import("next/router").NextRouter) => import("ui/components/DepictProvider").NavigateFunction;
|
|
530
|
-
};
|
|
531
|
-
export { CategoryTitle, embedded_num_products as EmbeddedNumProducts } from "@depict-ai/ui";
|
|
532
|
-
export type { PageURLCreator, DisplayTransformers } from "@depict-ai/ui";
|
|
533
|
-
export type { Locale } from "@depict-ai/ui/locales";
|
|
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>;
|
package/ES10/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { DPC as $jb2Oo$DPC } from "@depict-ai/dpc/ES10";
|
|
|
13
13
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
14
14
|
import { register_es_version } from "../multi_import_deduplicator.mjs";
|
|
15
15
|
register_es_version("react-ui", "ES10");
|
|
16
|
-
const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "1.5.
|
|
16
|
+
const $9bd9bb8700ab2ada$export$83d89fbfd8236492 = "1.5.20";
|
|
17
17
|
const $8c691d7f86317052$export$8e769ad4338a911e = {
|
|
18
18
|
usedLocale: $jb2Oo$createSignal((0, $jb2Oo$defaultLocale)),
|
|
19
19
|
search_instances: new Map(),
|