@depict-ai/react-ui 0.0.44 → 0.0.45

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,18 +1,19 @@
1
1
  import React, { PropsWithChildren, ReactNode } from "react";
2
2
  // @ts-ignore -- react-router is optional and only used for typing the reactRouterUseNavigate property
3
3
  import { useNavigate } from "react-router";
4
+ import { Locale } from "@depict-ai/ui/locales";
4
5
  import { Display } from "@depict-ai/utilishared";
5
6
  import { SDKColsAtSize, SDKGridSpacing } from "@depict-ai/ui";
6
7
  export function DepictSearchField(): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
7
8
  type BaseSearchConfig = {
8
9
  /**
9
- * The market to use for the search.
10
- * @example "se", "no", "dk"
10
+ * The merchant to use for the search.
11
+ * @example "YOUR_MERCHANT", "stronger"
11
12
  */
12
13
  merchant: string;
13
14
  /**
14
- * The merchant to use for the search.
15
- * @example "se", "no", "dk"
15
+ * The market to use for the search.
16
+ * @example "YOUR_MARKET", "no", "en-de"
16
17
  */
17
18
  market: string;
18
19
  /**
@@ -27,10 +28,11 @@ type BaseSearchConfig = {
27
28
  */
28
29
  urlParamName?: string;
29
30
  /**
30
- * Whether or not to enable category suggestions.
31
+ * Whether or not to enable category suggestions in the search modal and search page.
31
32
  * @default false
32
33
  */
33
34
  enableCategorySuggestions?: boolean;
35
+ locale: Locale;
34
36
  };
35
37
  /**
36
38
  * You can pass the function you use to navigate to a new page.
@@ -38,8 +40,7 @@ type BaseSearchConfig = {
38
40
  * Currently only works with react-router's useNavigate hook.
39
41
  * @example
40
42
  * ```tsx
41
- * // @ts-ignore -- react-router is optional and only used for typing the reactRouterUseNavigate property
42
- import { useNavigate } from "react-router";
43
+ * import { useNavigate } from "react-router-dom";
43
44
  *
44
45
  * const App = () => {
45
46
  * return (
@@ -47,7 +48,7 @@ import { useNavigate } from "react-router";
47
48
  * merchant="YOUR_MERCHANT"
48
49
  * market="YOUR_MARKET"
49
50
  * searchPagePath="/search"
50
- * navigateFunction={useNavigate}
51
+ * reactRouterUseNavigate={useNavigate}
51
52
  * >
52
53
  * <App />
53
54
  * </DepictProvider>
@@ -56,11 +57,15 @@ import { useNavigate } from "react-router";
56
57
  * ```
57
58
  */
58
59
  type DepictConfigInReactRouterContext = {
60
+ /** Expects useNavigate hook from react-router */
59
61
  reactRouterUseNavigate: ReactRouterUseNavigate;
62
+ /** Not to be used in this context */
60
63
  onNavigation?: undefined;
61
64
  } & BaseSearchConfig;
62
65
  type DepictConfigInOtherContext = {
66
+ /** Expects a function that takes a url and navigates to it */
63
67
  onNavigation: (href: string, shallow?: boolean) => unknown;
68
+ /** Not to be used in this context */
64
69
  reactRouterUseNavigate?: undefined;
65
70
  } & BaseSearchConfig;
66
71
  type DepictConfig = BaseSearchConfig | DepictConfigInReactRouterContext | DepictConfigInOtherContext;
@@ -79,9 +84,7 @@ type ReactRouterUseNavigate = any extends typeof useNavigate ? never : typeof us
79
84
  *
80
85
  * @example
81
86
  * ```tsx
82
- * const App = () => {
83
- * const navigate = useNavigate();
84
- *
87
+ * const App = () => { *
85
88
  * return (
86
89
  * <DepictProvider
87
90
  * merchant="YOUR_MERCHANT"
@@ -99,7 +102,9 @@ export function DepictProvider(props: PropsWithChildren<DepictConfig>): import("
99
102
  children?: import("react").ReactNode;
100
103
  }>;
101
104
  /**
102
- * A search header alignment component.
105
+ * A search header alignment component,
106
+ * which should be placed in the header of the page and
107
+ * will be used to align the search modal input.
103
108
  * @returns {JSX.Element}
104
109
  */
105
110
  export function DepictSearchHeader(): import("react").DetailedReactHTMLElement<{
@@ -115,10 +120,11 @@ export function openModal(): void;
115
120
  * The Depict product card props.
116
121
  */
117
122
  export interface DepictProductCardProps<T extends Display> {
123
+ /** The display data to render. */
118
124
  display: T | null;
119
125
  }
120
126
  /**
121
- * Depict product card
127
+ * Depict product card to use for rendering products.
122
128
  */
123
129
  export type DepictProductCard<T extends Display> = (props: DepictProductCardProps<T>) => ReactNode;
124
130
  interface SearchPageConfig<T extends Display> {
@@ -128,15 +134,22 @@ interface SearchPageConfig<T extends Display> {
128
134
  productCard: DepictProductCard<T>;
129
135
  /**
130
136
  * How many columns to show at each media size.
131
- * @default { [[4], [3, 1024], [2, 901]] }
137
+ * @default
138
+ * [[2, 901], [3, 1024], [4]]
139
+ * @example
140
+ * [[2, 901], [3, 1024], [4]]
141
+ * means 2 columns at sizes up to 901px, 3 columns at sizes up to 1024px and after that 4 columns at any size.
132
142
  */
133
143
  columnsAtSize?: SDKColsAtSize;
134
144
  /**
135
145
  * The spacing between products.
146
+ * @default "2%"
147
+ * @example
148
+ * "2%", "10px", "1rem"
136
149
  */
137
150
  gridSpacing?: SDKGridSpacing;
138
151
  /**
139
- * Whether or not to show the search input field.
152
+ * Whether or not to show the search input field in the search page.
140
153
  * @default true
141
154
  */
142
155
  includeInputField?: boolean;
@@ -169,8 +182,6 @@ interface SearchPageConfig<T extends Display> {
169
182
  * id: display.product_id,
170
183
  * name: display.title,
171
184
  * description: display.title,
172
- * variants: [],
173
- * options: [],
174
185
  * images: [{ url: display.image_url }],
175
186
  * price: {
176
187
  * value: display.sale_price,
@@ -188,7 +199,7 @@ export function DepictSearchPage<T extends Display>(props: SearchPageConfig<T>):
188
199
  * Props for the ImagePlaceholder component.
189
200
  */
190
201
  interface ImagePlaceholderProps {
191
- /** The aspect ratio of the image. */
202
+ /** The aspect ratio of the image that will be displayed. */
192
203
  aspectRatio: number;
193
204
  }
194
205
  /**
@@ -201,11 +212,18 @@ export const ImagePlaceholder: React.FC<ImagePlaceholderProps>;
201
212
  * Props for the TextPlaceholder component.
202
213
  */
203
214
  interface TextPlaceholderProps {
204
- /** The height of the text. */
215
+ /**
216
+ * The height of the text, including a unit.
217
+ * @example "1em"
218
+ */
205
219
  height: string;
206
- /** The width of the text. */
220
+ /**
221
+ * The width of the text.
222
+ * @example "60px", "10em"
223
+ */
207
224
  width: string;
208
225
  }
209
226
  /** A placeholder text that can be used in place of a text that is loading. */
210
227
  export const TextPlaceholder: React.FC<TextPlaceholderProps>;
211
- export const version = "0.0.44";
228
+ export const version = "0.0.45";
229
+ export type { Locale } from "@depict-ai/ui";
package/dist/main.js CHANGED
@@ -3,6 +3,7 @@ var $4GYXz$depictaiui = require("@depict-ai/ui");
3
3
  var $4GYXz$solidjs = require("solid-js");
4
4
  var $4GYXz$solidjsweb = require("solid-js/web");
5
5
  var $4GYXz$react = require("react");
6
+ var $4GYXz$depictaiuilocales = require("@depict-ai/ui/locales");
6
7
  var $4GYXz$reactdom = require("react-dom");
7
8
  var $4GYXz$reactjsxruntime = require("react/jsx-runtime");
8
9
 
@@ -82,6 +83,7 @@ function $a48f3b1a4abf2e0c$export$d2c02478244f91f7() {
82
83
 
83
84
 
84
85
 
86
+
85
87
  let $6319748b4f0426f0$var$set = false;
86
88
  let $6319748b4f0426f0$var$padding_animation;
87
89
  function $6319748b4f0426f0$export$6453cbc34515a94d(is_search_page) {
@@ -135,7 +137,8 @@ function $6319748b4f0426f0$var$removeLotsOfPadding() {
135
137
 
136
138
 
137
139
  function $18b830ef84ac138a$export$9fac37a9c21c2f3b(props) {
138
- const { children: children , searchPagePath: searchPagePath , urlParamName: urlParamName , enableCategorySuggestions: enableCategorySuggestions , market: market , merchant: merchant } = props;
140
+ const { children: children , searchPagePath: searchPagePath , urlParamName: urlParamName , enableCategorySuggestions: enableCategorySuggestions , market: market , merchant: merchant , locale: locale } = props;
141
+ const usedLocale = locale ?? (0, $4GYXz$depictaiuilocales.en);
139
142
  if (!market || !merchant) {
140
143
  (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).required_state_set_[1](false);
141
144
  return (0, $4GYXz$react.createElement)((0, $4GYXz$react.Fragment), null, children);
@@ -156,16 +159,7 @@ function $18b830ef84ac138a$export$9fac37a9c21c2f3b(props) {
156
159
  merchant: merchant,
157
160
  enable_category_suggestions: enableCategorySuggestions ?? false,
158
161
  // default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
159
- localization: {
160
- ...(0, $4GYXz$depictaiui.swedish_search_translation),
161
- price_formatting_: {
162
- pre_: "kr ",
163
- post_: "",
164
- decimal_places_delimiter_: ",",
165
- thousands_delimiter_: " ",
166
- places_after_comma_: 2
167
- }
168
- },
162
+ localization: usedLocale,
169
163
  on_navigation: (new_href)=>{
170
164
  const shallow = (0, $b4d0d98857ed9934$export$6cb4d3a5c1ac9b43)(location);
171
165
  if ("onNavigation" in props) {
@@ -188,6 +182,7 @@ function $18b830ef84ac138a$export$9fac37a9c21c2f3b(props) {
188
182
  } else {
189
183
  search.market = market;
190
184
  search.merchant = merchant;
185
+ search.localization = usedLocale;
191
186
  }
192
187
  (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).required_state_set_[1](true);
193
188
  } catch (e) {
@@ -351,7 +346,7 @@ const $afce04c26b0c4208$export$89c6019e4baa40b1 = ({ width: width , height: heig
351
346
  };
352
347
 
353
348
 
354
- const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.44";
349
+ const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.45";
355
350
 
356
351
 
357
352
 
package/dist/module.js CHANGED
@@ -1,8 +1,9 @@
1
1
  import {dlog as $TZSbU$dlog, href_change_ipns as $TZSbU$href_change_ipns, catchify as $TZSbU$catchify, observer as $TZSbU$observer, history_replacer as $TZSbU$history_replacer, queueMacroTask as $TZSbU$queueMacroTask, ContainedPlaceholderImage as $TZSbU$ContainedPlaceholderImage, Placeholder as $TZSbU$Placeholder} from "@depict-ai/utilishared";
2
- import {add_to_version_info as $TZSbU$add_to_version_info, SearchField as $TZSbU$SearchField, DepictSearch as $TZSbU$DepictSearch, swedish_search_translation as $TZSbU$swedish_search_translation, get_search_query_updating_blocked_signal as $TZSbU$get_search_query_updating_blocked_signal, SearchPage as $TZSbU$SearchPage} from "@depict-ai/ui";
2
+ import {add_to_version_info as $TZSbU$add_to_version_info, SearchField as $TZSbU$SearchField, DepictSearch as $TZSbU$DepictSearch, get_search_query_updating_blocked_signal as $TZSbU$get_search_query_updating_blocked_signal, SearchPage as $TZSbU$SearchPage} from "@depict-ai/ui";
3
3
  import {untrack as $TZSbU$untrack, createComponent as $TZSbU$createComponent, Show as $TZSbU$Show, createSignal as $TZSbU$createSignal, createMemo as $TZSbU$createMemo, createComputed as $TZSbU$createComputed, onCleanup as $TZSbU$onCleanup} from "solid-js";
4
4
  import {render as $TZSbU$render} from "solid-js/web";
5
5
  import {useState as $TZSbU$useState, useRef as $TZSbU$useRef, useEffect as $TZSbU$useEffect, createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment} from "react";
6
+ import {en as $TZSbU$en} from "@depict-ai/ui/locales";
6
7
  import {createPortal as $TZSbU$createPortal} from "react-dom";
7
8
  import {jsx as $TZSbU$jsx} from "react/jsx-runtime";
8
9
 
@@ -70,6 +71,7 @@ function $54b0d21b77e719c4$export$d2c02478244f91f7() {
70
71
 
71
72
 
72
73
 
74
+
73
75
  let $8071251ee4e9ffa1$var$set = false;
74
76
  let $8071251ee4e9ffa1$var$padding_animation;
75
77
  function $8071251ee4e9ffa1$export$6453cbc34515a94d(is_search_page) {
@@ -123,7 +125,8 @@ function $8071251ee4e9ffa1$var$removeLotsOfPadding() {
123
125
 
124
126
 
125
127
  function $faf794495ff8b304$export$9fac37a9c21c2f3b(props) {
126
- const { children: children , searchPagePath: searchPagePath , urlParamName: urlParamName , enableCategorySuggestions: enableCategorySuggestions , market: market , merchant: merchant } = props;
128
+ const { children: children , searchPagePath: searchPagePath , urlParamName: urlParamName , enableCategorySuggestions: enableCategorySuggestions , market: market , merchant: merchant , locale: locale } = props;
129
+ const usedLocale = locale ?? (0, $TZSbU$en);
127
130
  if (!market || !merchant) {
128
131
  (0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[1](false);
129
132
  return (0, $TZSbU$createElement)((0, $TZSbU$Fragment), null, children);
@@ -144,16 +147,7 @@ function $faf794495ff8b304$export$9fac37a9c21c2f3b(props) {
144
147
  merchant: merchant,
145
148
  enable_category_suggestions: enableCategorySuggestions ?? false,
146
149
  // default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
147
- localization: {
148
- ...(0, $TZSbU$swedish_search_translation),
149
- price_formatting_: {
150
- pre_: "kr ",
151
- post_: "",
152
- decimal_places_delimiter_: ",",
153
- thousands_delimiter_: " ",
154
- places_after_comma_: 2
155
- }
156
- },
150
+ localization: usedLocale,
157
151
  on_navigation: (new_href)=>{
158
152
  const shallow = (0, $c83ba9ab79386687$export$6cb4d3a5c1ac9b43)(location);
159
153
  if ("onNavigation" in props) {
@@ -176,6 +170,7 @@ function $faf794495ff8b304$export$9fac37a9c21c2f3b(props) {
176
170
  } else {
177
171
  search.market = market;
178
172
  search.merchant = merchant;
173
+ search.localization = usedLocale;
179
174
  }
180
175
  (0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[1](true);
181
176
  } catch (e) {
@@ -339,7 +334,7 @@ const $8aa3ab31237c8dc9$export$89c6019e4baa40b1 = ({ width: width , height: heig
339
334
  };
340
335
 
341
336
 
342
- const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.44";
337
+ const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.45";
343
338
 
344
339
 
345
340
 
@@ -1,4 +1,4 @@
1
- export const version = "0.0.44";
1
+ export const version = "0.0.45";
2
2
  export function DepictProvider(props: any): any;
3
3
  export function DepictSearchField(): any;
4
4
  export function DepictSearchPage(): any;
@@ -15,7 +15,7 @@ $parcel$export(module.exports, "openModal", () => $41e7e5d85b5e0d49$export$a7f6c
15
15
  $parcel$export(module.exports, "version", () => $db7b67857900028b$export$83d89fbfd8236492);
16
16
 
17
17
 
18
- const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.44";
18
+ const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.45";
19
19
 
20
20
 
21
21
  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.44";
6
+ const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.45";
7
7
 
8
8
 
9
9
  function $2b1fdeb83610500f$export$9fac37a9c21c2f3b(props) {
@@ -0,0 +1,88 @@
1
+ import { Elem } from "@depict-ai/utilishared";
2
+ /**
3
+ * PLP internationalisation shared between search and category listing
4
+ */
5
+ type plp_shared_i18n = {
6
+ scroll_to_top_: string;
7
+ back_: string;
8
+ open_sorting_: string;
9
+ close_sorting_: string;
10
+ open_filters_: string;
11
+ close_filters_: string;
12
+ close_: string;
13
+ ok_: string;
14
+ filters_cleared_: string;
15
+ we_cleared_your_filters_: string;
16
+ restore_: string;
17
+ sorting_text_: string;
18
+ filter_text_: string;
19
+ selected_filters_title_: string;
20
+ filters_: string;
21
+ view_less_: string;
22
+ view_more_: string;
23
+ clear_all_from_filter_crumbs_: string;
24
+ clear_individual_filter_: string;
25
+ of_: string;
26
+ clear_all_filters_from_big_button_: string;
27
+ try_without_filters_: string;
28
+ range_filter_low_point_aria_label_: string;
29
+ range_filter_high_point_aria_label_: string;
30
+ morphing_sign_expanded_aria_label_: string;
31
+ morphing_sign_collapsed_aria_label_: string;
32
+ price_formatting_: {
33
+ pre_: string;
34
+ post_: string;
35
+ decimal_places_delimiter_: string;
36
+ thousands_delimiter_: string;
37
+ places_after_comma_: number | "auto";
38
+ };
39
+ };
40
+ /**
41
+ * Search internationalisation
42
+ */
43
+ interface search_i18n extends plp_shared_i18n {
44
+ placeholder_text_: string;
45
+ show_n_results_: (number_of_results: HTMLElement) => Elem[];
46
+ no_results_text_: string;
47
+ search_recs_title_: string;
48
+ clear_filters_query_sorting_after_submit_: string;
49
+ modal_view_all_results_: (number_of_results: HTMLElement) => Elem[];
50
+ modal_discover_more_: string;
51
+ get_showing_results_for_: (query: HTMLElement, number_of_results: HTMLElement) => Elem[];
52
+ previous_searches_text_: string;
53
+ category_: string;
54
+ suggestions_: string;
55
+ search_submit_button_aria_label_: string;
56
+ query_input_field_aria_label_: string;
57
+ previous_searches_delete_entry_from_history_: string;
58
+ }
59
+ /**
60
+ * Category internationalisation
61
+ */
62
+ interface category_i18n extends plp_shared_i18n {
63
+ show_n_products_: (number_of_results: HTMLElement) => Elem[];
64
+ no_products_text_: string;
65
+ product_: string;
66
+ products_: string;
67
+ breadcrumbs_aria_label_: string;
68
+ quicklinks_aria_label_: string;
69
+ breadcrumbs_separator_: string;
70
+ }
71
+ /**
72
+ * Depict UI internationalisation
73
+ */
74
+ interface Locale extends category_i18n, search_i18n {
75
+ }
76
+ export const cz: Locale;
77
+ export const da: Locale;
78
+ export const nl: Locale;
79
+ export const en: Locale;
80
+ export const fi: Locale;
81
+ export const fr: Locale;
82
+ export const de: Locale;
83
+ export const it: Locale;
84
+ export const no: Locale;
85
+ export const pl: Locale;
86
+ export const pt: Locale;
87
+ export const es: Locale;
88
+ export const sv: Locale;