@depict-ai/react-ui 1.0.1 → 1.0.3
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 +1 -1
- package/dist/main.js +42 -5
- package/dist/module.js +45 -8
- 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 +6 -6
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 { DPC } from "@depict-ai/dpc";
|
|
5
5
|
import { Locale } from "@depict-ai/ui/locales";
|
|
6
|
-
export const version = "1.0.
|
|
6
|
+
export const version = "1.0.3";
|
|
7
7
|
interface PLPConfig<T extends Display> extends BaseProductListingConfig {
|
|
8
8
|
/**
|
|
9
9
|
* The product card to use for rendering products.
|
package/dist/main.js
CHANGED
|
@@ -31,7 +31,7 @@ $parcel$export(module.exports, "version", () => $db7b67857900028b$export$83d89fb
|
|
|
31
31
|
$parcel$export(module.exports, "Navigation", () => $b742053c966024b4$export$b8a61e5c71402559);
|
|
32
32
|
/*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
|
|
33
33
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
34
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "1.0.
|
|
34
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "1.0.3";
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
@@ -66,6 +66,34 @@ const $0b7cd4fb39fc3502$export$8e769ad4338a911e = {
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
|
|
69
|
+
|
|
70
|
+
class $d7a14567b529586f$export$d0f82e3ef89b1f22 extends (0, $4GYXz$react.Component) {
|
|
71
|
+
constructor(props){
|
|
72
|
+
super(props);
|
|
73
|
+
this.state = {
|
|
74
|
+
hasError: false
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static getDerivedStateFromError() {
|
|
78
|
+
// Update state so the next render will show the fallback UI.
|
|
79
|
+
return {
|
|
80
|
+
hasError: true
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
componentDidCatch(error) {
|
|
84
|
+
this.props.on_error(error);
|
|
85
|
+
}
|
|
86
|
+
render() {
|
|
87
|
+
if (this.state.hasError) // You can render any custom fallback UI
|
|
88
|
+
return (0, $4GYXz$react.createElement)("div", {
|
|
89
|
+
children: "Component failed"
|
|
90
|
+
});
|
|
91
|
+
return this.props.children;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
69
97
|
let $b4d0d98857ed9934$var$run_on_href_change;
|
|
70
98
|
let $b4d0d98857ed9934$var$old_href = location.href;
|
|
71
99
|
function $b4d0d98857ed9934$export$74f3924c5027fe1d(cb) {
|
|
@@ -73,8 +101,7 @@ function $b4d0d98857ed9934$export$74f3924c5027fe1d(cb) {
|
|
|
73
101
|
}
|
|
74
102
|
(0, $4GYXz$depictaiutilishared.instant_exec_on_suspect_history_change).add((0, $4GYXz$depictaiutilishared.catchify)(()=>{
|
|
75
103
|
const { href: href } = location;
|
|
76
|
-
if (
|
|
77
|
-
$b4d0d98857ed9934$var$run_on_href_change?.(href);
|
|
104
|
+
if ($b4d0d98857ed9934$var$run_on_href_change && $b4d0d98857ed9934$var$old_href !== href) $b4d0d98857ed9934$var$run_on_href_change(href);
|
|
78
105
|
$b4d0d98857ed9934$var$old_href = href;
|
|
79
106
|
}));
|
|
80
107
|
const $b4d0d98857ed9934$export$775e6b3892b5ad52 = (url = location)=>url.pathname == (0, $4GYXz$solidjs.untrack)((0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
|
|
@@ -110,21 +137,31 @@ function $b4d0d98857ed9934$export$e5139bbbb9a05035(component, is_set = (0, $0b7c
|
|
|
110
137
|
}
|
|
111
138
|
async function $b4d0d98857ed9934$export$79c79419c1ef0081({ display: display , component_portals: component_portals , set_portals: set_portals , react_template: react_template }) {
|
|
112
139
|
let set_react_has_ran_hooks;
|
|
140
|
+
let was_cleaned_up = false;
|
|
113
141
|
const react_has_ran_hooks = new Promise((r)=>set_react_has_ran_hooks = r);
|
|
114
142
|
const solid_container = document.createElement("div");
|
|
143
|
+
const owner = (0, $4GYXz$solidjs.getOwner)();
|
|
115
144
|
const reactProductCard = (0, $4GYXz$reactjsxruntime.jsx)((props)=>{
|
|
116
|
-
// Sneak in a hook into their product card component
|
|
145
|
+
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
117
146
|
(0, $4GYXz$react.useEffect)(set_react_has_ran_hooks, []);
|
|
118
147
|
return react_template(props);
|
|
119
148
|
}, {
|
|
120
149
|
display: display
|
|
121
150
|
});
|
|
122
|
-
const
|
|
151
|
+
const reactProductCardInErrorBoundary = (0, $4GYXz$reactjsxruntime.jsx)((0, $d7a14567b529586f$export$d0f82e3ef89b1f22), {
|
|
152
|
+
children: reactProductCard,
|
|
153
|
+
on_error: (error)=>(0, $4GYXz$solidjs.runWithOwner)(owner, ()=>{
|
|
154
|
+
if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
|
|
155
|
+
throw new (0, $4GYXz$depictaiui.ProductCardError)(error);
|
|
156
|
+
})
|
|
157
|
+
});
|
|
158
|
+
const portal = $4GYXz$reactdom.createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
123
159
|
component_portals.add(portal);
|
|
124
160
|
set_portals([
|
|
125
161
|
...component_portals
|
|
126
162
|
]);
|
|
127
163
|
(0, $4GYXz$solidjs.onCleanup)(()=>{
|
|
164
|
+
was_cleaned_up = true;
|
|
128
165
|
// this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
|
|
129
166
|
component_portals.delete(portal);
|
|
130
167
|
set_portals([
|
package/dist/module.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {add_to_version_info as $TZSbU$add_to_version_info, catchify as $TZSbU$catchify, queueMacroTask as $TZSbU$queueMacroTask, instant_exec_on_suspect_history_change as $TZSbU$instant_exec_on_suspect_history_change, ContainedPlaceholderImage as $TZSbU$ContainedPlaceholderImage, Placeholder as $TZSbU$Placeholder} from "@depict-ai/utilishared";
|
|
2
|
-
import {CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts, DepictAPI as $TZSbU$DepictAPI, DepictSearch as $TZSbU$DepictSearch, DepictCategory as $TZSbU$DepictCategory, get_search_query_updating_blocked_signal as $TZSbU$get_search_query_updating_blocked_signal, SearchPage as $TZSbU$SearchPage, CategoryPage as $TZSbU$CategoryPage, BreadCrumbs as $TZSbU$BreadCrumbs, QuickLinks as $TZSbU$QuickLinks, open_modal_with_alignment as $TZSbU$open_modal_with_alignment, SearchField as $TZSbU$SearchField, fetchDepictRecommendations as $TZSbU$fetchDepictRecommendations} from "@depict-ai/ui";
|
|
3
|
-
import {createRoot as $TZSbU$createRoot, untrack as $TZSbU$untrack, createEffect as $TZSbU$createEffect, createComponent as $TZSbU$createComponent, Show as $TZSbU$Show, onCleanup as $TZSbU$onCleanup, createSignal as $TZSbU$createSignal, createComputed as $TZSbU$createComputed, createMemo as $TZSbU$createMemo} from "solid-js";
|
|
4
|
-
import {createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment, useState as $TZSbU$useState, useRef as $TZSbU$useRef, useEffect as $TZSbU$useEffect, forwardRef as $TZSbU$forwardRef} from "react";
|
|
2
|
+
import {CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts, DepictAPI as $TZSbU$DepictAPI, DepictSearch as $TZSbU$DepictSearch, DepictCategory as $TZSbU$DepictCategory, ProductCardError as $TZSbU$ProductCardError, get_search_query_updating_blocked_signal as $TZSbU$get_search_query_updating_blocked_signal, SearchPage as $TZSbU$SearchPage, CategoryPage as $TZSbU$CategoryPage, BreadCrumbs as $TZSbU$BreadCrumbs, QuickLinks as $TZSbU$QuickLinks, open_modal_with_alignment as $TZSbU$open_modal_with_alignment, SearchField as $TZSbU$SearchField, fetchDepictRecommendations as $TZSbU$fetchDepictRecommendations} from "@depict-ai/ui";
|
|
3
|
+
import {createRoot as $TZSbU$createRoot, untrack as $TZSbU$untrack, createEffect as $TZSbU$createEffect, createComponent as $TZSbU$createComponent, Show as $TZSbU$Show, getOwner as $TZSbU$getOwner, runWithOwner as $TZSbU$runWithOwner, onCleanup as $TZSbU$onCleanup, createSignal as $TZSbU$createSignal, createComputed as $TZSbU$createComputed, createMemo as $TZSbU$createMemo} from "solid-js";
|
|
4
|
+
import {createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment, useState as $TZSbU$useState, useRef as $TZSbU$useRef, useEffect as $TZSbU$useEffect, Component as $TZSbU$Component, forwardRef as $TZSbU$forwardRef} from "react";
|
|
5
5
|
import {en as $TZSbU$en} from "@depict-ai/ui/locales";
|
|
6
6
|
import {render as $TZSbU$render} from "solid-js/web";
|
|
7
7
|
import {jsx as $TZSbU$jsx} from "react/jsx-runtime";
|
|
@@ -11,7 +11,7 @@ import {DPC as $TZSbU$DPC} from "@depict-ai/dpc";
|
|
|
11
11
|
|
|
12
12
|
/*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
|
|
13
13
|
// Note, if you add an export here, also add one in src-server/main.ts
|
|
14
|
-
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "1.0.
|
|
14
|
+
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "1.0.3";
|
|
15
15
|
|
|
16
16
|
|
|
17
17
|
|
|
@@ -46,6 +46,34 @@ const $42858f023ef23dab$export$8e769ad4338a911e = {
|
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
|
|
49
|
+
|
|
50
|
+
class $d5c9e1f3545b4984$export$d0f82e3ef89b1f22 extends (0, $TZSbU$Component) {
|
|
51
|
+
constructor(props){
|
|
52
|
+
super(props);
|
|
53
|
+
this.state = {
|
|
54
|
+
hasError: false
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
static getDerivedStateFromError() {
|
|
58
|
+
// Update state so the next render will show the fallback UI.
|
|
59
|
+
return {
|
|
60
|
+
hasError: true
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
componentDidCatch(error) {
|
|
64
|
+
this.props.on_error(error);
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
if (this.state.hasError) // You can render any custom fallback UI
|
|
68
|
+
return (0, $TZSbU$createElement)("div", {
|
|
69
|
+
children: "Component failed"
|
|
70
|
+
});
|
|
71
|
+
return this.props.children;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
49
77
|
let $c83ba9ab79386687$var$run_on_href_change;
|
|
50
78
|
let $c83ba9ab79386687$var$old_href = location.href;
|
|
51
79
|
function $c83ba9ab79386687$export$74f3924c5027fe1d(cb) {
|
|
@@ -53,8 +81,7 @@ function $c83ba9ab79386687$export$74f3924c5027fe1d(cb) {
|
|
|
53
81
|
}
|
|
54
82
|
(0, $TZSbU$instant_exec_on_suspect_history_change).add((0, $TZSbU$catchify)(()=>{
|
|
55
83
|
const { href: href } = location;
|
|
56
|
-
if (
|
|
57
|
-
$c83ba9ab79386687$var$run_on_href_change?.(href);
|
|
84
|
+
if ($c83ba9ab79386687$var$run_on_href_change && $c83ba9ab79386687$var$old_href !== href) $c83ba9ab79386687$var$run_on_href_change(href);
|
|
58
85
|
$c83ba9ab79386687$var$old_href = href;
|
|
59
86
|
}));
|
|
60
87
|
const $c83ba9ab79386687$export$775e6b3892b5ad52 = (url = location)=>url.pathname == (0, $TZSbU$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
|
|
@@ -90,21 +117,31 @@ function $c83ba9ab79386687$export$e5139bbbb9a05035(component, is_set = (0, $4285
|
|
|
90
117
|
}
|
|
91
118
|
async function $c83ba9ab79386687$export$79c79419c1ef0081({ display: display , component_portals: component_portals , set_portals: set_portals , react_template: react_template }) {
|
|
92
119
|
let set_react_has_ran_hooks;
|
|
120
|
+
let was_cleaned_up = false;
|
|
93
121
|
const react_has_ran_hooks = new Promise((r)=>set_react_has_ran_hooks = r);
|
|
94
122
|
const solid_container = document.createElement("div");
|
|
123
|
+
const owner = (0, $TZSbU$getOwner)();
|
|
95
124
|
const reactProductCard = (0, $TZSbU$jsx)((props)=>{
|
|
96
|
-
// Sneak in a hook into their product card component
|
|
125
|
+
// Sneak in a hook into their product card component to know once react has finished rendering and running hooks
|
|
97
126
|
(0, $TZSbU$useEffect)(set_react_has_ran_hooks, []);
|
|
98
127
|
return react_template(props);
|
|
99
128
|
}, {
|
|
100
129
|
display: display
|
|
101
130
|
});
|
|
102
|
-
const
|
|
131
|
+
const reactProductCardInErrorBoundary = (0, $TZSbU$jsx)((0, $d5c9e1f3545b4984$export$d0f82e3ef89b1f22), {
|
|
132
|
+
children: reactProductCard,
|
|
133
|
+
on_error: (error)=>(0, $TZSbU$runWithOwner)(owner, ()=>{
|
|
134
|
+
if (was_cleaned_up) return; // Would infinite loop if we'd throw after we've already been cleaned up. That is because the `ErrorBoundary` won't be "registered" with the cleaned-up owner anymore so react would hear about the throw and attempt to re-render the error boundary or something which would throw again, etc.
|
|
135
|
+
throw new (0, $TZSbU$ProductCardError)(error);
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
const portal = $TZSbU$createPortal(reactProductCardInErrorBoundary, solid_container);
|
|
103
139
|
component_portals.add(portal);
|
|
104
140
|
set_portals([
|
|
105
141
|
...component_portals
|
|
106
142
|
]);
|
|
107
143
|
(0, $TZSbU$onCleanup)(()=>{
|
|
144
|
+
was_cleaned_up = true;
|
|
108
145
|
// this will stop working after any await so be careful to not await before this, or you'll have to carry the owner over with getOwner and runWithOwner
|
|
109
146
|
component_portals.delete(portal);
|
|
110
147
|
set_portals([
|
package/dist-server/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ interface UseFetchRecommendationsReturn<T extends Display> {
|
|
|
33
33
|
*/
|
|
34
34
|
fetchRecommendations: (opts: FetchRecsOptions) => Promise<T[]>;
|
|
35
35
|
}
|
|
36
|
-
export const version = "1.0.
|
|
36
|
+
export const version = "1.0.3";
|
|
37
37
|
export function DepictProvider(props: any): any;
|
|
38
38
|
export function SearchPage(): any;
|
|
39
39
|
export function CategoryPage(): any;
|
package/dist-server/main.js
CHANGED
|
@@ -21,7 +21,7 @@ $parcel$export(module.exports, "useFetchRecommendations", () => $41e7e5d85b5e0d4
|
|
|
21
21
|
$parcel$export(module.exports, "version", () => $db7b67857900028b$export$83d89fbfd8236492);
|
|
22
22
|
|
|
23
23
|
|
|
24
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "1.0.
|
|
24
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "1.0.3";
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
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": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -96,10 +96,10 @@
|
|
|
96
96
|
"/locales"
|
|
97
97
|
],
|
|
98
98
|
"dependencies": {
|
|
99
|
-
"@depict-ai/dpc": "^1.0.
|
|
100
|
-
"@depict-ai/plp-styling": "^1.0.
|
|
101
|
-
"@depict-ai/ui": "^1.0.
|
|
102
|
-
"@depict-ai/utilishared": "^1.0.
|
|
99
|
+
"@depict-ai/dpc": "^1.0.4",
|
|
100
|
+
"@depict-ai/plp-styling": "^1.0.5",
|
|
101
|
+
"@depict-ai/ui": "^1.0.5",
|
|
102
|
+
"@depict-ai/utilishared": "^1.0.4",
|
|
103
103
|
"solid-js": "^1.7.3"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"@babel/preset-typescript": "latest",
|
|
113
113
|
"@babel/runtime": "latest",
|
|
114
114
|
"@babel/runtime-corejs3": "latest",
|
|
115
|
-
"@depict-ai/plp-styling": "^1.0.
|
|
115
|
+
"@depict-ai/plp-styling": "^1.0.5",
|
|
116
116
|
"@jest/globals": "^29.3.1",
|
|
117
117
|
"@parcel/babel-preset-env": "latest",
|
|
118
118
|
"@parcel/resolver-default": "^2.8.0",
|