@depict-ai/react-ui 0.0.38 → 0.0.40
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 +105 -28
- package/dist/main.js +7 -10
- package/dist/module.js +7 -10
- package/dist-server/index.d.ts +1 -1
- package/dist-server/main.js +1 -1
- package/dist-server/module.js +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,33 +4,25 @@ import { useNavigate } from "react-router";
|
|
|
4
4
|
import { Display } from "@depict-ai/utilishared";
|
|
5
5
|
import { SDKColsAtSize, SDKGridSpacing } from "@depict-ai/ui";
|
|
6
6
|
export function DepictSearchField(): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
7
|
-
|
|
8
|
-
* The props for the DepictProvider.
|
|
9
|
-
*/
|
|
10
|
-
type BaseSearchConfig = {
|
|
7
|
+
type BaseDepictConfig = {
|
|
11
8
|
/**
|
|
12
9
|
* The market to use for the search.
|
|
13
|
-
* @example "se"
|
|
14
|
-
* @example "no"
|
|
10
|
+
* @example "se", "no", "dk"
|
|
15
11
|
*/
|
|
16
12
|
merchant: string;
|
|
17
13
|
/**
|
|
18
14
|
* The merchant to use for the search.
|
|
19
|
-
* @example "se"
|
|
20
|
-
* @example "no"
|
|
21
|
-
* @example "dk"
|
|
15
|
+
* @example "se", "no", "dk"
|
|
22
16
|
*/
|
|
23
17
|
market: string;
|
|
24
18
|
/**
|
|
25
19
|
* The path to the search page.
|
|
26
|
-
* @example "/search"
|
|
27
|
-
* @example "/sok"
|
|
20
|
+
* @example "/search", "/sok"
|
|
28
21
|
*/
|
|
29
22
|
searchPagePath: string;
|
|
30
23
|
/**
|
|
31
24
|
* The name of the url parameter that will be used for the search query.
|
|
32
|
-
* @example "q"
|
|
33
|
-
* @example "search_query"
|
|
25
|
+
* @example "q", "search_query"
|
|
34
26
|
* @default "search_query"
|
|
35
27
|
*/
|
|
36
28
|
urlParamName?: string;
|
|
@@ -46,23 +38,71 @@ type BaseSearchConfig = {
|
|
|
46
38
|
In that case, the ReactRouterUseNavigate type becomes "never" and cannot be used.
|
|
47
39
|
*/
|
|
48
40
|
type ReactRouterUseNavigate = any extends typeof useNavigate ? never : typeof useNavigate;
|
|
41
|
+
type OnNavigation = (href: string, shallow?: boolean) => unknown;
|
|
49
42
|
/**
|
|
50
|
-
* The
|
|
51
|
-
* @param href - The href of the new page.
|
|
52
|
-
* @param shallow - Whether or not the navigation should be shallow.
|
|
53
|
-
* @returns {unknown}
|
|
43
|
+
* The config for Depict
|
|
54
44
|
*/
|
|
55
|
-
type
|
|
56
|
-
|
|
45
|
+
type DepictConfig = BaseDepictConfig & {
|
|
46
|
+
/**
|
|
47
|
+
* The function that will be called when the user navigates to a new page.
|
|
48
|
+
* @param href - The href of the new page.
|
|
49
|
+
* @param shallow - Whether or not the navigation should be shallow.
|
|
50
|
+
* @returns {unknown}
|
|
51
|
+
*/
|
|
57
52
|
onNavigation?: OnNavigation;
|
|
58
|
-
|
|
53
|
+
/**
|
|
54
|
+
* You can pass the function you use to navigate to a new page.
|
|
55
|
+
*
|
|
56
|
+
* Currently only works with react-router's useNavigate hook.
|
|
57
|
+
* @example
|
|
58
|
+
* ```tsx
|
|
59
|
+
* // @ts-ignore -- react-router is optional and only used for typing the reactRouterUseNavigate property
|
|
60
|
+
import { useNavigate } from "react-router";
|
|
61
|
+
*
|
|
62
|
+
* const App = () => {
|
|
63
|
+
* const navigate = useNavigate();
|
|
64
|
+
*
|
|
65
|
+
* return (
|
|
66
|
+
* <DepictProvider
|
|
67
|
+
* merchant="se"
|
|
68
|
+
* market="se"
|
|
69
|
+
* searchPagePath="/search"
|
|
70
|
+
* navigateFunction={navigate}
|
|
71
|
+
* >
|
|
72
|
+
* <App />
|
|
73
|
+
* </DepictProvider>
|
|
74
|
+
* );
|
|
75
|
+
* };
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
navigateFunction?: ReactRouterUseNavigate;
|
|
59
79
|
};
|
|
60
80
|
/**
|
|
61
|
-
* The DepictProvider is a wrapper component that should be used to wrap
|
|
62
|
-
*
|
|
63
|
-
*
|
|
81
|
+
* The DepictProvider is a wrapper component that should be used to wrap any component that uses Depict components.
|
|
82
|
+
*
|
|
83
|
+
* Make sure it's mounted on every page where the search modal should be available.
|
|
84
|
+
*
|
|
85
|
+
* @param props - The props for the DepictProvider.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```tsx
|
|
89
|
+
* const App = () => {
|
|
90
|
+
* const navigate = useNavigate();
|
|
91
|
+
*
|
|
92
|
+
* return (
|
|
93
|
+
* <DepictProvider
|
|
94
|
+
* merchant="se"
|
|
95
|
+
* market="se"
|
|
96
|
+
* searchPagePath="/search"
|
|
97
|
+
* >
|
|
98
|
+
* <App />
|
|
99
|
+
* </DepictProvider>
|
|
100
|
+
* );
|
|
101
|
+
* };
|
|
102
|
+
* ```
|
|
103
|
+
* @returns {JSX.Element} The DepictProvider.
|
|
64
104
|
*/
|
|
65
|
-
export function DepictProvider(props: PropsWithChildren<
|
|
105
|
+
export function DepictProvider(props: PropsWithChildren<DepictConfig>): import("react").FunctionComponentElement<{
|
|
66
106
|
children?: import("react").ReactNode;
|
|
67
107
|
}>;
|
|
68
108
|
/**
|
|
@@ -110,10 +150,47 @@ interface SearchPageConfig<T extends Display> {
|
|
|
110
150
|
}
|
|
111
151
|
/**
|
|
112
152
|
* DepictSearchPage is a component that renders a search page.
|
|
113
|
-
* @param
|
|
114
|
-
*
|
|
153
|
+
* @param props - The props for the search page.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* ```tsx
|
|
157
|
+
* import { DepictProductCard, ImagePlaceholder, Display } from '@depict-ai/react-ui'
|
|
158
|
+
*
|
|
159
|
+
* function Search() {
|
|
160
|
+
* return <DepictSearchPage productCard={MyCustomSearchProductCard} />
|
|
161
|
+
* }
|
|
162
|
+
*
|
|
163
|
+
* interface MyCustomDisplay extends Display {}
|
|
164
|
+
*
|
|
165
|
+
* export const MyCustomSearchProductCard: DepictProductCard<MyCustomDisplay> = ({
|
|
166
|
+
* display,
|
|
167
|
+
* }) => {
|
|
168
|
+
* if (!display) {
|
|
169
|
+
* return <ImagePlaceholder aspectRatio={3 / 4} />
|
|
170
|
+
* }
|
|
171
|
+
*
|
|
172
|
+
* return (
|
|
173
|
+
* <>
|
|
174
|
+
* <MyCustomProductCard
|
|
175
|
+
* product={{
|
|
176
|
+
* id: display.product_id,
|
|
177
|
+
* name: display.title,
|
|
178
|
+
* description: display.title,
|
|
179
|
+
* variants: [],
|
|
180
|
+
* options: [],
|
|
181
|
+
* images: [{ url: display.image_url }],
|
|
182
|
+
* price: {
|
|
183
|
+
* value: display.sale_price,
|
|
184
|
+
* },
|
|
185
|
+
* }}
|
|
186
|
+
* />
|
|
187
|
+
* </>
|
|
188
|
+
* )
|
|
189
|
+
* }
|
|
190
|
+
*
|
|
191
|
+
* ```
|
|
115
192
|
*/
|
|
116
|
-
export function DepictSearchPage<T extends Display>(
|
|
193
|
+
export function DepictSearchPage<T extends Display>(props: SearchPageConfig<T>): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
117
194
|
/**
|
|
118
195
|
* Props for the ImagePlaceholder component
|
|
119
196
|
*/
|
|
@@ -138,4 +215,4 @@ interface TextPlaceholderProps {
|
|
|
138
215
|
}
|
|
139
216
|
/** A placeholder text that can be used in place of a text that is loading */
|
|
140
217
|
export const TextPlaceholder: React.FC<TextPlaceholderProps>;
|
|
141
|
-
export const version = "0.0.
|
|
218
|
+
export const version = "0.0.40";
|
package/dist/main.js
CHANGED
|
@@ -145,11 +145,8 @@ function $18b830ef84ac138a$export$9fac37a9c21c2f3b(props) {
|
|
|
145
145
|
const [get_search_page_path, set_search_page_path] = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_;
|
|
146
146
|
set_search_page_path(searchPagePath);
|
|
147
147
|
if (!search) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
const { reactRouterUseNavigate: reactRouterUseNavigate } = props;
|
|
151
|
-
if (typeof reactRouterUseNavigate === "function") react_router_navigate = reactRouterUseNavigate();
|
|
152
|
-
}
|
|
148
|
+
const { navigateFunction: originalNavigateFunction } = props;
|
|
149
|
+
const navigateFunction = typeof originalNavigateFunction === "function" ? originalNavigateFunction : undefined;
|
|
153
150
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search = new (0, $4GYXz$depictaiui.DepictSearch)({
|
|
154
151
|
search_query_url_param_name: urlParamName,
|
|
155
152
|
market: market,
|
|
@@ -172,9 +169,9 @@ function $18b830ef84ac138a$export$9fac37a9c21c2f3b(props) {
|
|
|
172
169
|
const { onNavigation: onNavigation } = props;
|
|
173
170
|
if (typeof onNavigation === "function") return onNavigation(new_href, shallow);
|
|
174
171
|
}
|
|
175
|
-
if (
|
|
172
|
+
if (navigateFunction) {
|
|
176
173
|
const url_object = new URL(new_href);
|
|
177
|
-
return
|
|
174
|
+
return navigateFunction(url_object.pathname + url_object.search + url_object.hash);
|
|
178
175
|
}
|
|
179
176
|
if (window.next) window.next.router.push(new_href, undefined, {
|
|
180
177
|
shallow: shallow,
|
|
@@ -253,8 +250,8 @@ function $20bf907adee775ba$export$a7f6cffb6b8ba11c() {
|
|
|
253
250
|
|
|
254
251
|
|
|
255
252
|
|
|
256
|
-
function $a6bedbe4b4d6d027$export$210723f5a54a7028(
|
|
257
|
-
return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)((0, $b4d0d98857ed9934$export$e5139bbbb9a05035)($a6bedbe4b4d6d027$var$SolidSearchPage),
|
|
253
|
+
function $a6bedbe4b4d6d027$export$210723f5a54a7028(props) {
|
|
254
|
+
return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)((0, $b4d0d98857ed9934$export$e5139bbbb9a05035)($a6bedbe4b4d6d027$var$SolidSearchPage), props);
|
|
258
255
|
}
|
|
259
256
|
function $a6bedbe4b4d6d027$var$SolidSearchPage(props, set_portals) {
|
|
260
257
|
const depict_search = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search;
|
|
@@ -351,7 +348,7 @@ const $afce04c26b0c4208$export$89c6019e4baa40b1 = ({ width: width , height: heig
|
|
|
351
348
|
};
|
|
352
349
|
|
|
353
350
|
|
|
354
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.
|
|
351
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.40";
|
|
355
352
|
|
|
356
353
|
|
|
357
354
|
|
package/dist/module.js
CHANGED
|
@@ -133,11 +133,8 @@ function $faf794495ff8b304$export$9fac37a9c21c2f3b(props) {
|
|
|
133
133
|
const [get_search_page_path, set_search_page_path] = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_;
|
|
134
134
|
set_search_page_path(searchPagePath);
|
|
135
135
|
if (!search) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const { reactRouterUseNavigate: reactRouterUseNavigate } = props;
|
|
139
|
-
if (typeof reactRouterUseNavigate === "function") react_router_navigate = reactRouterUseNavigate();
|
|
140
|
-
}
|
|
136
|
+
const { navigateFunction: originalNavigateFunction } = props;
|
|
137
|
+
const navigateFunction = typeof originalNavigateFunction === "function" ? originalNavigateFunction : undefined;
|
|
141
138
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).search = new (0, $TZSbU$DepictSearch)({
|
|
142
139
|
search_query_url_param_name: urlParamName,
|
|
143
140
|
market: market,
|
|
@@ -160,9 +157,9 @@ function $faf794495ff8b304$export$9fac37a9c21c2f3b(props) {
|
|
|
160
157
|
const { onNavigation: onNavigation } = props;
|
|
161
158
|
if (typeof onNavigation === "function") return onNavigation(new_href, shallow);
|
|
162
159
|
}
|
|
163
|
-
if (
|
|
160
|
+
if (navigateFunction) {
|
|
164
161
|
const url_object = new URL(new_href);
|
|
165
|
-
return
|
|
162
|
+
return navigateFunction(url_object.pathname + url_object.search + url_object.hash);
|
|
166
163
|
}
|
|
167
164
|
if (window.next) window.next.router.push(new_href, undefined, {
|
|
168
165
|
shallow: shallow,
|
|
@@ -241,8 +238,8 @@ function $f41a371216eff80b$export$a7f6cffb6b8ba11c() {
|
|
|
241
238
|
|
|
242
239
|
|
|
243
240
|
|
|
244
|
-
function $9f8d5ef3c016c493$export$210723f5a54a7028(
|
|
245
|
-
return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)($9f8d5ef3c016c493$var$SolidSearchPage),
|
|
241
|
+
function $9f8d5ef3c016c493$export$210723f5a54a7028(props) {
|
|
242
|
+
return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)($9f8d5ef3c016c493$var$SolidSearchPage), props);
|
|
246
243
|
}
|
|
247
244
|
function $9f8d5ef3c016c493$var$SolidSearchPage(props, set_portals) {
|
|
248
245
|
const depict_search = (0, $42858f023ef23dab$export$8e769ad4338a911e).search;
|
|
@@ -339,7 +336,7 @@ const $8aa3ab31237c8dc9$export$89c6019e4baa40b1 = ({ width: width , height: heig
|
|
|
339
336
|
};
|
|
340
337
|
|
|
341
338
|
|
|
342
|
-
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.
|
|
339
|
+
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.40";
|
|
343
340
|
|
|
344
341
|
|
|
345
342
|
|
package/dist-server/index.d.ts
CHANGED
package/dist-server/main.js
CHANGED
|
@@ -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.
|
|
18
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "0.0.40";
|
|
19
19
|
|
|
20
20
|
|
|
21
21
|
function $41e7e5d85b5e0d49$export$9fac37a9c21c2f3b(props) {
|
package/dist-server/module.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depict-ai/react-ui",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -83,8 +83,8 @@
|
|
|
83
83
|
"/dist-server"
|
|
84
84
|
],
|
|
85
85
|
"dependencies": {
|
|
86
|
-
"@depict-ai/ui": "^0.0.
|
|
87
|
-
"@depict-ai/utilishared": "^0.0.
|
|
86
|
+
"@depict-ai/ui": "^0.0.18",
|
|
87
|
+
"@depict-ai/utilishared": "^0.0.16",
|
|
88
88
|
"solid-js": "^1.6.2"
|
|
89
89
|
},
|
|
90
90
|
"peerDependencies": {
|