@depict-ai/react-ui 0.0.67 → 0.0.68

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
@@ -3,7 +3,7 @@ import { Display } from "@depict-ai/utilishared";
3
3
  import React, { ReactNode, PropsWithChildren, ReactElement } from "react";
4
4
  import { Locale } from "@depict-ai/ui/locales";
5
5
  import { CategoryTitle, embedded_num_products } from "@depict-ai/ui";
6
- export const version = "0.0.67";
6
+ export const version = "0.0.68";
7
7
  interface PLPConfig<T extends Display> {
8
8
  /**
9
9
  * The product card to use for rendering products.
@@ -37,7 +37,7 @@ export interface DepictProductCardProps<T extends Display> {
37
37
  * Depict product card to use for rendering products.
38
38
  */
39
39
  export type DepictProductCard<T extends Display> = (props: DepictProductCardProps<T>) => ReactNode;
40
- type NavigateFunction = (href: string) => void;
40
+ type NavigateFunction = (relativeUrl: string) => void;
41
41
  type DepictSearchConfig = {
42
42
  /**
43
43
  * The path to the search page.
@@ -51,7 +51,7 @@ type DepictSearchConfig = {
51
51
  */
52
52
  urlParamName?: string;
53
53
  /**
54
- * Whether or not to enable category suggestions in the search modal and search page.
54
+ * Whether to enable category suggestions in the search modal and search page.
55
55
  * @default false
56
56
  */
57
57
  enableCategorySuggestions?: boolean;
@@ -73,10 +73,14 @@ type DepictBaseConfig = {
73
73
  *
74
74
  * You don't need to provide any in a Next.js context.
75
75
  *
76
+ * @param relativeUrl - The relative url to navigate to.
77
+ *
76
78
  * @example
77
- * Here is how you would use it with react-router, using our helper function.
79
+ * Here is how you would use it with react-router, @reach/router, Gatsby or similar.
78
80
  * ```tsx
79
81
  * import { DepictProvider, Navigation } from "@depict-ai/react-ui";
82
+ * import { useNavigate } from "react-router-dom";
83
+ * // import { navigate } from "gatsby";
80
84
  *
81
85
  * function Router() {
82
86
  * const navigate = useNavigate();
@@ -84,7 +88,7 @@ type DepictBaseConfig = {
84
88
  * <DepictProvider
85
89
  * merchant="houdini"
86
90
  * market="en-de"
87
- * navigateFunction={Navigation.reactRouterNavigation(navigate)}
91
+ * navigateFunction={navigate}
88
92
  * search={{
89
93
  * searchPagePath: "/search",
90
94
  * }}
@@ -97,7 +101,7 @@ type DepictBaseConfig = {
97
101
  * @example
98
102
  * If you're using another library, you can define your own navigate function, that's compatible with the `NavigateFunction` type.
99
103
  * ```tsx
100
- * const navigateFunction = (href: string) => {
104
+ * const navigateFunction = (relativeUrl: string) => {
101
105
  * router.push(href);
102
106
  * };
103
107
  * ```
@@ -328,10 +332,11 @@ export const TextPlaceholder: React.FC<TextPlaceholderProps>;
328
332
  interface UseSearchModalParams {
329
333
  /**
330
334
  * How the modal should be opened.
335
+ * Will default to "centered" if nothing else is specified.
331
336
  * - "centered" - The modal will be opened in the center of the screen.
332
337
  * - "aligned" - The modal will be opened aligned to the alignerRef element.
333
338
  */
334
- location: ModalLocation;
339
+ location?: ModalLocation;
335
340
  /**
336
341
  * The ref to the element that the modal should be aligned to.
337
342
  * This is only used when location is "aligned".
@@ -390,7 +395,7 @@ interface UseSearchModalReturn {
390
395
  * ```
391
396
  * @returns {JSX.Element}
392
397
  */
393
- export function useDepictSearchModal(params: UseSearchModalParams): UseSearchModalReturn;
398
+ export function useDepictSearchModal(params?: UseSearchModalParams): UseSearchModalReturn;
394
399
  interface SearchFieldProps {
395
400
  /**
396
401
  * A reference to the DOM element that the modal should be aligned to.
@@ -453,8 +458,7 @@ export const useDepictSearchField: (props: SearchFieldProps) => UseDepictSearchF
453
458
  * Helper function to navigate to a new page depending on the navigation library used.
454
459
  */
455
460
  export const Navigation: {
456
- nextRouterNavigation: (router: import("next/router").NextRouter) => (href: string) => void;
457
- reactRouterNavigation: (navigateFunction: import("react-router").NavigateFunction) => (href: string) => void;
461
+ nextRouterNavigation: (router: import("next/router").NextRouter) => (relativeUrl: string) => void;
458
462
  };
459
463
  export { CategoryTitle, embedded_num_products as EmbeddedNumProducts } from "@depict-ai/ui";
460
464
  export type { Locale } from "@depict-ai/ui";
package/dist/main.js CHANGED
@@ -28,7 +28,7 @@ $parcel$export(module.exports, "Navigation", () => $b742053c966024b4$export$b8a6
28
28
  /*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
29
29
  // Note, if you add an export here, also add one in src-server/main.ts
30
30
 
31
- const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.67";
31
+ const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.68";
32
32
 
33
33
 
34
34
 
@@ -174,9 +174,9 @@ async function $b4d0d98857ed9934$export$79c79419c1ef0081({ display: display , co
174
174
  }
175
175
 
176
176
 
177
- const $bc389476eeb2b615$export$599d4515591ef232 = (href)=>{
177
+ const $bc389476eeb2b615$export$599d4515591ef232 = (relativeUrl)=>{
178
178
  const shallow = (0, $b4d0d98857ed9934$export$92a8f8b3c630fa0d)(location);
179
- window.next.router.push(href, undefined, {
179
+ window.next.router.push(relativeUrl, undefined, {
180
180
  shallow: shallow,
181
181
  scroll: true
182
182
  });
@@ -195,10 +195,10 @@ function $24b00503eef73528$export$9fac37a9c21c2f3b(props) {
195
195
  try {
196
196
  const { search: search , category: category } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
197
197
  const [get_search_page_path, set_search_page_path] = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_;
198
- set_search_page_path(searchPagePath);
199
- const on_navigation = typeof window?.next?.router !== "undefined" || navigateFunction ? (new_href)=>{
200
- if (navigateFunction) navigateFunction(new_href);
201
- else (0, $bc389476eeb2b615$export$599d4515591ef232)(new_href);
198
+ set_search_page_path($24b00503eef73528$var$ensure_correct_formatting(searchPagePath));
199
+ const on_navigation = typeof window?.next?.router !== "undefined" || navigateFunction ? (new_relative_url)=>{
200
+ if (navigateFunction) navigateFunction(new_relative_url);
201
+ else (0, $bc389476eeb2b615$export$599d4515591ef232)(new_relative_url);
202
202
  } : undefined;
203
203
  if (!search) (0, $4GYXz$solidjs.createRoot)(()=>(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search = new (0, $4GYXz$depictaiui.DepictSearch)({
204
204
  search_query_url_param_name: urlParamName,
@@ -236,6 +236,11 @@ function $24b00503eef73528$export$9fac37a9c21c2f3b(props) {
236
236
  }
237
237
  return (0, $4GYXz$react.createElement)((0, $4GYXz$react.Fragment), null, children);
238
238
  }
239
+ function $24b00503eef73528$var$ensure_correct_formatting(path) {
240
+ // Make sure the path starts with a slash as it always will and is_page will fail otherwise
241
+ if (!path.startsWith("/")) return "/" + path;
242
+ return path;
243
+ }
239
244
 
240
245
 
241
246
 
@@ -412,7 +417,7 @@ const $7c8b440edc188ad5$export$89c6019e4baa40b1 = ({ width: width , height: heig
412
417
 
413
418
 
414
419
  const $ef7db890e488d4f4$export$d69d8daa20eae175 = (createOpenModalParams)=>{
415
- const { globalState: globalState , location: location , alignerRef: alignerRef } = createOpenModalParams;
420
+ const { globalState: globalState , location: location = "centered" , alignerRef: alignerRef } = createOpenModalParams;
416
421
  const openModal = ()=>{
417
422
  const headerAligner = alignerRef?.current;
418
423
  if (!globalState.search) throw new Error("No active search in the app!");
@@ -449,7 +454,7 @@ const $ef7db890e488d4f4$export$d69d8daa20eae175 = (createOpenModalParams)=>{
449
454
  };
450
455
 
451
456
 
452
- function $3647cad61d03b89c$export$cc1e9aaf280afdcb(params) {
457
+ function $3647cad61d03b89c$export$cc1e9aaf280afdcb(params = {}) {
453
458
  const open = (0, $ef7db890e488d4f4$export$d69d8daa20eae175)({
454
459
  globalState: $0b7cd4fb39fc3502$export$8e769ad4338a911e,
455
460
  ...params
@@ -488,33 +493,17 @@ const $ca5840628781f899$export$45080d603eda647c = (props)=>{
488
493
 
489
494
 
490
495
 
491
- const $e387bd534de10acd$export$804fac5697cfbe35 = (router)=>(href)=>{
496
+ const $e387bd534de10acd$export$804fac5697cfbe35 = (router)=>(relativeUrl)=>{
492
497
  const shallow = (0, $b4d0d98857ed9934$export$92a8f8b3c630fa0d)(location);
493
- router.push(href, undefined, {
498
+ router.push(relativeUrl, undefined, {
494
499
  shallow: shallow,
495
500
  scroll: true
496
501
  });
497
502
  };
498
503
 
499
504
 
500
- /**
501
- * Helper function that creates a function that can be used as the
502
- * navigateFunction callback for DepictProvider when using react-router.
503
- *
504
- * React-router expect relative URLs, so this function will strip the
505
- * protocol, hostname and port from the URL.
506
- *
507
- * @param navigateFunction what useNavigate() returns
508
- * @returns a function that can be used as the navigateFunction callback for DepictProvider
509
- */ const $201a023b63de7d2f$export$d53481656a62aebe = (navigateFunction)=>(href)=>{
510
- const url_object = new URL(href);
511
- return navigateFunction(url_object.pathname + url_object.search + url_object.hash);
512
- };
513
-
514
-
515
505
  const $b742053c966024b4$export$b8a61e5c71402559 = {
516
- nextRouterNavigation: $e387bd534de10acd$export$804fac5697cfbe35,
517
- reactRouterNavigation: $201a023b63de7d2f$export$d53481656a62aebe
506
+ nextRouterNavigation: $e387bd534de10acd$export$804fac5697cfbe35
518
507
  };
519
508
 
520
509
 
package/dist/module.js CHANGED
@@ -10,7 +10,7 @@ import {createPortal as $TZSbU$createPortal} from "react-dom";
10
10
  /*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
11
11
  // Note, if you add an export here, also add one in src-server/main.ts
12
12
 
13
- const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.67";
13
+ const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.68";
14
14
 
15
15
 
16
16
 
@@ -156,9 +156,9 @@ async function $c83ba9ab79386687$export$79c79419c1ef0081({ display: display , co
156
156
  }
157
157
 
158
158
 
159
- const $7216ca4c8308a0f9$export$599d4515591ef232 = (href)=>{
159
+ const $7216ca4c8308a0f9$export$599d4515591ef232 = (relativeUrl)=>{
160
160
  const shallow = (0, $c83ba9ab79386687$export$92a8f8b3c630fa0d)(location);
161
- window.next.router.push(href, undefined, {
161
+ window.next.router.push(relativeUrl, undefined, {
162
162
  shallow: shallow,
163
163
  scroll: true
164
164
  });
@@ -177,10 +177,10 @@ function $5376eb2a386cd90d$export$9fac37a9c21c2f3b(props) {
177
177
  try {
178
178
  const { search: search , category: category } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
179
179
  const [get_search_page_path, set_search_page_path] = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_;
180
- set_search_page_path(searchPagePath);
181
- const on_navigation = typeof window?.next?.router !== "undefined" || navigateFunction ? (new_href)=>{
182
- if (navigateFunction) navigateFunction(new_href);
183
- else (0, $7216ca4c8308a0f9$export$599d4515591ef232)(new_href);
180
+ set_search_page_path($5376eb2a386cd90d$var$ensure_correct_formatting(searchPagePath));
181
+ const on_navigation = typeof window?.next?.router !== "undefined" || navigateFunction ? (new_relative_url)=>{
182
+ if (navigateFunction) navigateFunction(new_relative_url);
183
+ else (0, $7216ca4c8308a0f9$export$599d4515591ef232)(new_relative_url);
184
184
  } : undefined;
185
185
  if (!search) (0, $TZSbU$createRoot)(()=>(0, $42858f023ef23dab$export$8e769ad4338a911e).search = new (0, $TZSbU$DepictSearch)({
186
186
  search_query_url_param_name: urlParamName,
@@ -218,6 +218,11 @@ function $5376eb2a386cd90d$export$9fac37a9c21c2f3b(props) {
218
218
  }
219
219
  return (0, $TZSbU$createElement)((0, $TZSbU$Fragment), null, children);
220
220
  }
221
+ function $5376eb2a386cd90d$var$ensure_correct_formatting(path) {
222
+ // Make sure the path starts with a slash as it always will and is_page will fail otherwise
223
+ if (!path.startsWith("/")) return "/" + path;
224
+ return path;
225
+ }
221
226
 
222
227
 
223
228
 
@@ -394,7 +399,7 @@ const $cbd250061abf11cb$export$89c6019e4baa40b1 = ({ width: width , height: heig
394
399
 
395
400
 
396
401
  const $5e26376d86621891$export$d69d8daa20eae175 = (createOpenModalParams)=>{
397
- const { globalState: globalState , location: location , alignerRef: alignerRef } = createOpenModalParams;
402
+ const { globalState: globalState , location: location = "centered" , alignerRef: alignerRef } = createOpenModalParams;
398
403
  const openModal = ()=>{
399
404
  const headerAligner = alignerRef?.current;
400
405
  if (!globalState.search) throw new Error("No active search in the app!");
@@ -431,7 +436,7 @@ const $5e26376d86621891$export$d69d8daa20eae175 = (createOpenModalParams)=>{
431
436
  };
432
437
 
433
438
 
434
- function $cfa72c75e6cf6901$export$cc1e9aaf280afdcb(params) {
439
+ function $cfa72c75e6cf6901$export$cc1e9aaf280afdcb(params = {}) {
435
440
  const open = (0, $5e26376d86621891$export$d69d8daa20eae175)({
436
441
  globalState: $42858f023ef23dab$export$8e769ad4338a911e,
437
442
  ...params
@@ -470,33 +475,17 @@ const $e3ccaca62718bae4$export$45080d603eda647c = (props)=>{
470
475
 
471
476
 
472
477
 
473
- const $a92aa2beb560b8af$export$804fac5697cfbe35 = (router)=>(href)=>{
478
+ const $a92aa2beb560b8af$export$804fac5697cfbe35 = (router)=>(relativeUrl)=>{
474
479
  const shallow = (0, $c83ba9ab79386687$export$92a8f8b3c630fa0d)(location);
475
- router.push(href, undefined, {
480
+ router.push(relativeUrl, undefined, {
476
481
  shallow: shallow,
477
482
  scroll: true
478
483
  });
479
484
  };
480
485
 
481
486
 
482
- /**
483
- * Helper function that creates a function that can be used as the
484
- * navigateFunction callback for DepictProvider when using react-router.
485
- *
486
- * React-router expect relative URLs, so this function will strip the
487
- * protocol, hostname and port from the URL.
488
- *
489
- * @param navigateFunction what useNavigate() returns
490
- * @returns a function that can be used as the navigateFunction callback for DepictProvider
491
- */ const $01e1970add53d62a$export$d53481656a62aebe = (navigateFunction)=>(href)=>{
492
- const url_object = new URL(href);
493
- return navigateFunction(url_object.pathname + url_object.search + url_object.hash);
494
- };
495
-
496
-
497
487
  const $97603d19204ec48d$export$b8a61e5c71402559 = {
498
- nextRouterNavigation: $a92aa2beb560b8af$export$804fac5697cfbe35,
499
- reactRouterNavigation: $01e1970add53d62a$export$d53481656a62aebe
488
+ nextRouterNavigation: $a92aa2beb560b8af$export$804fac5697cfbe35
500
489
  };
501
490
 
502
491
 
@@ -9,7 +9,7 @@ interface UseDepictSearchFieldReturn {
9
9
  */
10
10
  DepictSearchField: () => ReactElement;
11
11
  }
12
- export const version = "0.0.67";
12
+ export const version = "0.0.68";
13
13
  export function DepictProvider(props: any): any;
14
14
  export function DepictSearchPage(): any;
15
15
  export function DepictCategoryPage(): any;
@@ -19,7 +19,7 @@ $parcel$export(module.exports, "useDepictSearchModal", () => $41e7e5d85b5e0d49$e
19
19
  $parcel$export(module.exports, "version", () => $db7b67857900028b$export$83d89fbfd8236492);
20
20
 
21
21
 
22
- const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.67";
22
+ const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.68";
23
23
 
24
24
 
25
25
  function $41e7e5d85b5e0d49$export$9fac37a9c21c2f3b(props) {
@@ -3,7 +3,7 @@ import {jsx as $1RlIW$jsx} from "react/jsx-runtime";
3
3
 
4
4
 
5
5
 
6
- const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.67";
6
+ const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.68";
7
7
 
8
8
 
9
9
  function $2b1fdeb83610500f$export$9fac37a9c21c2f3b(props) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/react-ui",
3
- "version": "0.0.67",
3
+ "version": "0.0.68",
4
4
  "packageManager": "yarn@3.2.2",
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/main.js",
@@ -90,8 +90,8 @@
90
90
  "/locales"
91
91
  ],
92
92
  "dependencies": {
93
- "@depict-ai/ui": "^0.0.44",
94
- "@depict-ai/utilishared": "^0.0.42",
93
+ "@depict-ai/ui": "^0.0.45",
94
+ "@depict-ai/utilishared": "^0.0.43",
95
95
  "solid-js": "^1.6.2"
96
96
  },
97
97
  "peerDependencies": {
@@ -104,7 +104,7 @@
104
104
  "@babel/preset-typescript": "latest",
105
105
  "@babel/runtime": "latest",
106
106
  "@babel/runtime-corejs3": "latest",
107
- "@depict-ai/plp-styling": "^0.0.7",
107
+ "@depict-ai/plp-styling": "^0.0.8",
108
108
  "@jest/globals": "^29.3.1",
109
109
  "@parcel/babel-preset-env": "latest",
110
110
  "@parcel/resolver-default": "^2.8.0",