@depict-ai/react-ui 1.4.1 → 1.5.2
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/README.md +2 -1
- package/dist/index.d.ts +29 -7
- package/dist/main.js +304 -152
- package/dist/module.js +307 -155
- package/dist/styles/plain-css-fallback-styling.css +1 -1
- package/dist-server/index.d.ts +1 -1
- package/dist-server/main.js +2 -2
- package/dist-server/module.js +2 -2
- package/package.json +7 -7
package/dist/main.js
CHANGED
|
@@ -31,7 +31,8 @@ $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.
|
|
34
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "1.5.2";
|
|
35
|
+
|
|
35
36
|
|
|
36
37
|
|
|
37
38
|
|
|
@@ -43,18 +44,17 @@ const $db7b67857900028b$export$83d89fbfd8236492 = "1.4.1";
|
|
|
43
44
|
|
|
44
45
|
|
|
45
46
|
const $0b7cd4fb39fc3502$export$8e769ad4338a911e = {
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
usedLocale: (0, $4GYXz$solidjs.createSignal)((0, $4GYXz$depictaiuilocales.defaultLocale)),
|
|
48
|
+
search_instances: new Map(),
|
|
49
|
+
category_instances: new Map(),
|
|
48
50
|
api: null,
|
|
49
51
|
dpc: null,
|
|
50
|
-
merchant:
|
|
51
|
-
market:
|
|
52
|
-
userId:
|
|
53
|
-
sessionId:
|
|
54
|
-
metaData: undefined,
|
|
52
|
+
merchant: (0, $4GYXz$solidjs.createSignal)(),
|
|
53
|
+
market: (0, $4GYXz$solidjs.createSignal)(),
|
|
54
|
+
userId: (0, $4GYXz$solidjs.createSignal)(),
|
|
55
|
+
sessionId: (0, $4GYXz$solidjs.createSignal)(),
|
|
55
56
|
known_category_paths: new Set(),
|
|
56
57
|
search_page_path_: (0, $4GYXz$solidjs.createSignal)(),
|
|
57
|
-
required_state_set_: (0, $4GYXz$solidjs.createSignal)(false),
|
|
58
58
|
search_page_in_dom: (0, $4GYXz$solidjs.createSignal)(false),
|
|
59
59
|
category_page_in_dom: (0, $4GYXz$solidjs.createSignal)(false)
|
|
60
60
|
};
|
|
@@ -100,13 +100,13 @@ function $b4d0d98857ed9934$export$74f3924c5027fe1d(cb) {
|
|
|
100
100
|
$b4d0d98857ed9934$var$run_on_href_change = cb;
|
|
101
101
|
}
|
|
102
102
|
(0, $4GYXz$depictaiutilishared.instant_exec_on_suspect_history_change).add((0, $4GYXz$depictaiutilishared.catchify)(()=>{
|
|
103
|
-
const { href: href
|
|
103
|
+
const { href: href } = location;
|
|
104
104
|
if ($b4d0d98857ed9934$var$run_on_href_change && $b4d0d98857ed9934$var$old_href !== href) $b4d0d98857ed9934$var$run_on_href_change(href);
|
|
105
105
|
$b4d0d98857ed9934$var$old_href = href;
|
|
106
106
|
}));
|
|
107
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
|
|
108
108
|
const $b4d0d98857ed9934$export$30c8a12df09be0e4 = (url = location)=>(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).known_category_paths.has(url.pathname);
|
|
109
|
-
function $b4d0d98857ed9934$export$f6e64e17bd69eeef({ solid_component: solid_component
|
|
109
|
+
function $b4d0d98857ed9934$export$f6e64e17bd69eeef({ solid_component: solid_component, props: props, wrapper_type: wrapper_type = "div", wrapper_style: wrapper_style = {}, hydrate_function_when_ssr: hydrate_function_when_ssr }) {
|
|
110
110
|
const [portals, set_portals] = (0, $4GYXz$react.useState)([]);
|
|
111
111
|
const wrapper_element_ref = (0, $4GYXz$react.useRef)();
|
|
112
112
|
const [[store, write_store]] = (0, $4GYXz$react.useState)(()=>(0, $4GYXz$solidjsstore.createStore)(props));
|
|
@@ -132,12 +132,13 @@ function $b4d0d98857ed9934$export$f6e64e17bd69eeef({ solid_component: solid_comp
|
|
|
132
132
|
} : {}
|
|
133
133
|
}), ...portals);
|
|
134
134
|
}
|
|
135
|
-
function $b4d0d98857ed9934$export$e5139bbbb9a05035(component, is_set
|
|
135
|
+
function $b4d0d98857ed9934$export$e5139bbbb9a05035(component, is_set) {
|
|
136
136
|
return (...args)=>{
|
|
137
|
+
const default_is_set = (0, $4GYXz$solidjs.createMemo)(()=>!!((0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).merchant[0]() && (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).market[0]())); // Apparently Show re-renders kids otherwise even if the falsiness of the condition doesn't change
|
|
137
138
|
// @ts-ignore
|
|
138
139
|
return (0, $4GYXz$solidjs.createComponent)((0, $4GYXz$solidjs.Show), {
|
|
139
140
|
get when () {
|
|
140
|
-
return is_set();
|
|
141
|
+
return (is_set || default_is_set)();
|
|
141
142
|
},
|
|
142
143
|
get children () {
|
|
143
144
|
return component(...args);
|
|
@@ -145,7 +146,7 @@ function $b4d0d98857ed9934$export$e5139bbbb9a05035(component, is_set = (0, $0b7c
|
|
|
145
146
|
});
|
|
146
147
|
};
|
|
147
148
|
}
|
|
148
|
-
async function $b4d0d98857ed9934$export$79c79419c1ef0081({ display: display
|
|
149
|
+
async function $b4d0d98857ed9934$export$79c79419c1ef0081({ display: display, component_portals: component_portals, set_portals: set_portals, react_template: react_template }) {
|
|
149
150
|
let set_react_has_ran_hooks;
|
|
150
151
|
let was_cleaned_up = false;
|
|
151
152
|
const react_has_ran_hooks = new Promise((r)=>set_react_has_ran_hooks = r);
|
|
@@ -174,9 +175,10 @@ async function $b4d0d98857ed9934$export$79c79419c1ef0081({ display: display , co
|
|
|
174
175
|
was_cleaned_up = true;
|
|
175
176
|
// 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
|
|
176
177
|
component_portals.delete(portal);
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
178
|
+
// Updating i.e. the merchant will cause a setState call while rendering the DepictProvider component which is illegal because it usually infinite loops react apps. In our case it doesn't though, so we just evade detection by doing it a microtask later. See also https://github.com/facebook/react/issues/18178#issuecomment-595846312
|
|
179
|
+
queueMicrotask(()=>set_portals([
|
|
180
|
+
...component_portals
|
|
181
|
+
]));
|
|
180
182
|
});
|
|
181
183
|
await react_has_ran_hooks; // After react has created elements it still takes some time to actually connect the refs and run the hooks. We don't want to replace placeholders before then.
|
|
182
184
|
return [
|
|
@@ -303,7 +305,7 @@ const $25c0a91312868994$export$38b98fae14bd1f64 = ()=>{
|
|
|
303
305
|
const $25c0a91312868994$export$47e064413edabf36 = (merchant, market, userId, sessionId)=>{
|
|
304
306
|
if (!merchant) return;
|
|
305
307
|
try {
|
|
306
|
-
let { dpc: dpc
|
|
308
|
+
let { dpc: dpc } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
|
|
307
309
|
if (!dpc) dpc = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).dpc = new (0, $4GYXz$depictaidpc.DPC)(merchant, {
|
|
308
310
|
market: market
|
|
309
311
|
});
|
|
@@ -320,25 +322,104 @@ const $25c0a91312868994$export$47e064413edabf36 = (merchant, market, userId, ses
|
|
|
320
322
|
};
|
|
321
323
|
|
|
322
324
|
|
|
325
|
+
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
function $b1cf911fa603e77a$export$bae2769a30719c48(disposable, stateKey) {
|
|
329
|
+
const actual_function = (dispose)=>{
|
|
330
|
+
const { usedLocale: [get_locale], merchant: [get_merchant], market: [get_market], search_query_url_param_name: search_query_url_param_name, search_page_path_: [get_search_page_path] } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
|
|
331
|
+
const instance = new (0, $4GYXz$depictaiui.DepictSearch)({
|
|
332
|
+
api: (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).api,
|
|
333
|
+
search_query_url_param_name: search_query_url_param_name,
|
|
334
|
+
market: (0, $4GYXz$solidjs.untrack)(get_market),
|
|
335
|
+
// TODO: check if we can do this
|
|
336
|
+
merchant: (0, $4GYXz$solidjs.untrack)(get_merchant),
|
|
337
|
+
enable_category_suggestions: (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).enableCategorySuggestions ?? false,
|
|
338
|
+
// default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
|
|
339
|
+
localization: (0, $4GYXz$solidjs.untrack)(get_locale),
|
|
340
|
+
url_transformer: (url)=>url.pathname = (0, $4GYXz$solidjs.untrack)(get_search_page_path),
|
|
341
|
+
on_navigation: (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).on_navigation,
|
|
342
|
+
unique_instance_key_for_state: stateKey
|
|
343
|
+
});
|
|
344
|
+
(0, $4GYXz$solidjs.createComputed)(()=>{
|
|
345
|
+
const new_merchant = get_merchant();
|
|
346
|
+
if (new_merchant) instance.merchant = new_merchant;
|
|
347
|
+
});
|
|
348
|
+
(0, $4GYXz$solidjs.createComputed)(()=>{
|
|
349
|
+
const new_market = get_market();
|
|
350
|
+
if (new_market) instance.market = new_market;
|
|
351
|
+
});
|
|
352
|
+
(0, $4GYXz$solidjs.createComputed)(()=>instance.localization = get_locale());
|
|
353
|
+
return {
|
|
354
|
+
instance: instance,
|
|
355
|
+
dispose: dispose,
|
|
356
|
+
users: 0
|
|
357
|
+
};
|
|
358
|
+
};
|
|
359
|
+
const function_length_0 = ()=>actual_function();
|
|
360
|
+
const function_length_1 = (dispose)=>actual_function(dispose);
|
|
361
|
+
return (0, $4GYXz$solidjs.createRoot)(disposable ? function_length_1 : function_length_0); // solid-js creates roots differently based on if it can detect a dispose argument, with function.length. That's why this is written like this
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
|
|
365
|
+
|
|
366
|
+
|
|
367
|
+
|
|
368
|
+
function $da98aca6c7d4c3f9$export$248b95d5073d5bab(disposable, stateKey) {
|
|
369
|
+
const actual_function = (dispose)=>{
|
|
370
|
+
const { usedLocale: [get_locale], merchant: [get_merchant], market: [get_market] } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
|
|
371
|
+
const instance = new (0, $4GYXz$depictaiui.DepictCategory)({
|
|
372
|
+
api: (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).api,
|
|
373
|
+
market: (0, $4GYXz$solidjs.untrack)(get_market),
|
|
374
|
+
// TODO: check if we can do this
|
|
375
|
+
merchant: (0, $4GYXz$solidjs.untrack)(get_merchant),
|
|
376
|
+
localization: (0, $4GYXz$solidjs.untrack)(get_locale),
|
|
377
|
+
on_navigation: (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).on_navigation,
|
|
378
|
+
unique_instance_key_for_state: stateKey
|
|
379
|
+
});
|
|
380
|
+
(0, $4GYXz$solidjs.createComputed)(()=>{
|
|
381
|
+
const new_merchant = get_merchant();
|
|
382
|
+
if (new_merchant) instance.merchant = new_merchant;
|
|
383
|
+
});
|
|
384
|
+
(0, $4GYXz$solidjs.createComputed)(()=>{
|
|
385
|
+
const new_market = get_market();
|
|
386
|
+
if (new_market) instance.market = new_market;
|
|
387
|
+
});
|
|
388
|
+
(0, $4GYXz$solidjs.createComputed)(()=>instance.localization = get_locale());
|
|
389
|
+
return {
|
|
390
|
+
instance: instance,
|
|
391
|
+
dispose: dispose,
|
|
392
|
+
users: 0
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
const function_length_0 = ()=>actual_function();
|
|
396
|
+
const function_length_1 = (dispose)=>actual_function(dispose);
|
|
397
|
+
return (0, $4GYXz$solidjs.createRoot)(disposable ? function_length_1 : function_length_0); // solid-js creates roots differently based on if it can detect a dispose argument, with function.length. That's why this is written like this
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
let $24b00503eef73528$var$provider_instances = 0;
|
|
323
402
|
function $24b00503eef73528$export$9fac37a9c21c2f3b(props) {
|
|
324
|
-
const { children: children
|
|
403
|
+
const { children: children, navigateFunction: navigateFunction, market: market, merchant: merchant, locale: locale, metaData: metaData, userId: userId, sessionId: sessionId } = props;
|
|
325
404
|
const usedLocale = locale ?? (0, $4GYXz$depictaiuilocales.defaultLocale);
|
|
326
|
-
const { searchPagePath: searchPagePath
|
|
405
|
+
const { searchPagePath: searchPagePath, urlParamName: urlParamName, enableCategorySuggestions: enableCategorySuggestions } = props.search ?? {};
|
|
406
|
+
$24b00503eef73528$var$multiple_depictprovider_guard();
|
|
327
407
|
// Will run on other prop changes, but harmless
|
|
328
|
-
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).userId
|
|
329
|
-
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).sessionId
|
|
408
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).userId[1](userId);
|
|
409
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).sessionId[1](sessionId);
|
|
410
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).usedLocale[1](usedLocale);
|
|
330
411
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).metaData = metaData;
|
|
331
|
-
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).
|
|
332
|
-
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).
|
|
412
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_query_url_param_name = urlParamName;
|
|
413
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).enableCategorySuggestions = enableCategorySuggestions;
|
|
333
414
|
(0, $25c0a91312868994$export$47e064413edabf36)(merchant, market, userId, sessionId);
|
|
334
|
-
if (!market || !merchant)
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
415
|
+
if (!market || !merchant) return (0, $4GYXz$react.createElement)((0, $4GYXz$react.Fragment), null, children);
|
|
416
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).market[1](market);
|
|
417
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).merchant[1](merchant);
|
|
418
|
+
(0, $6319748b4f0426f0$export$6453cbc34515a94d)();
|
|
338
419
|
try {
|
|
339
|
-
const {
|
|
420
|
+
const { search_instances: search_instances, category_instances: category_instances, api: api, search_page_path_: [, set_search_page_path] } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
|
|
340
421
|
if (typeof window?.next?.router === "undefined" && !navigateFunction) throw new Error("You must provide a navigateFunction when not using Next.js.");
|
|
341
|
-
const on_navigation = ({ is_replace: is_replace
|
|
422
|
+
const on_navigation = ({ is_replace: is_replace, new_url: new_url, scroll: scroll })=>{
|
|
342
423
|
const new_relative_url = new_url.origin === location.origin ? new_url.pathname + new_url.search + new_url.hash : new_url.href; // bail out of making URL relative if it's not possible
|
|
343
424
|
if (navigateFunction) navigateFunction(new_relative_url, {
|
|
344
425
|
replace: is_replace,
|
|
@@ -346,45 +427,24 @@ function $24b00503eef73528$export$9fac37a9c21c2f3b(props) {
|
|
|
346
427
|
});
|
|
347
428
|
else (0, $bc389476eeb2b615$export$599d4515591ef232)(new_relative_url, is_replace, scroll);
|
|
348
429
|
};
|
|
430
|
+
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).on_navigation = on_navigation;
|
|
349
431
|
if (!api) (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).api = new (0, $4GYXz$depictaiui.DepictAPI)({
|
|
350
432
|
get_metadata: async ()=>(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).metaData,
|
|
351
|
-
get_user_id: ()=>(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).userId,
|
|
352
|
-
get_session_id: ()=>(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).sessionId
|
|
433
|
+
get_user_id: ()=>(0, $4GYXz$solidjs.untrack)((0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).userId[0]),
|
|
434
|
+
get_session_id: ()=>(0, $4GYXz$solidjs.untrack)((0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).sessionId[0])
|
|
353
435
|
});
|
|
354
436
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).api.page_url_creator = props.pageURLCreator;
|
|
355
|
-
if (searchPagePath)
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
merchant: merchant,
|
|
362
|
-
enable_category_suggestions: enableCategorySuggestions ?? false,
|
|
363
|
-
// default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
|
|
364
|
-
localization: usedLocale,
|
|
365
|
-
url_transformer: (url)=>url.pathname = (0, $4GYXz$solidjs.untrack)(get_search_page_path),
|
|
366
|
-
on_navigation: on_navigation
|
|
367
|
-
}));
|
|
368
|
-
else {
|
|
369
|
-
search.market = market;
|
|
370
|
-
search.merchant = merchant;
|
|
371
|
-
search.localization = usedLocale;
|
|
372
|
-
}
|
|
437
|
+
if (searchPagePath) set_search_page_path($24b00503eef73528$var$ensure_correct_formatting(searchPagePath));
|
|
438
|
+
if (!search_instances.get(undefined)) {
|
|
439
|
+
// Create initial search instance which always exists. It i.e. gards against the state getting deleted from history.state by someone pushing to it with an empty object, which commonly people copy from code snippets.
|
|
440
|
+
// Also, it emulates the behavior pre-supporting multiple "depict blocks" on the same page
|
|
441
|
+
const instance = (0, $b1cf911fa603e77a$export$bae2769a30719c48)(false);
|
|
442
|
+
search_instances.set(undefined, instance);
|
|
373
443
|
}
|
|
374
|
-
if (!
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
merchant: merchant,
|
|
378
|
-
localization: usedLocale,
|
|
379
|
-
on_navigation: on_navigation
|
|
380
|
-
}));
|
|
381
|
-
else {
|
|
382
|
-
category.market = market;
|
|
383
|
-
category.merchant = merchant;
|
|
384
|
-
category.localization = usedLocale;
|
|
444
|
+
if (!category_instances.get(undefined)) {
|
|
445
|
+
const instance = (0, $da98aca6c7d4c3f9$export$248b95d5073d5bab)(false);
|
|
446
|
+
category_instances.set(undefined, instance);
|
|
385
447
|
}
|
|
386
|
-
(0, $6319748b4f0426f0$export$6453cbc34515a94d)();
|
|
387
|
-
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).required_state_set_[1](true);
|
|
388
448
|
} catch (e) {
|
|
389
449
|
// Make sure to not break the users app if we throw
|
|
390
450
|
queueMicrotask(()=>{
|
|
@@ -398,6 +458,15 @@ function $24b00503eef73528$var$ensure_correct_formatting(path) {
|
|
|
398
458
|
if (!path.startsWith("/")) return "/" + path;
|
|
399
459
|
return path;
|
|
400
460
|
}
|
|
461
|
+
function $24b00503eef73528$var$multiple_depictprovider_guard() {
|
|
462
|
+
(0, $4GYXz$react.useEffect)(()=>{
|
|
463
|
+
$24b00503eef73528$var$provider_instances++;
|
|
464
|
+
if ($24b00503eef73528$var$provider_instances > 1) throw new Error("You are using multiple DepictProviders. This is not supported and will lead to unexpected behavior. You can create multiple SearchPage and CategoryPage components, but only one DepictProvider.");
|
|
465
|
+
return ()=>{
|
|
466
|
+
$24b00503eef73528$var$provider_instances--;
|
|
467
|
+
};
|
|
468
|
+
}, []);
|
|
469
|
+
}
|
|
401
470
|
|
|
402
471
|
|
|
403
472
|
|
|
@@ -417,6 +486,32 @@ const $883a881f7926405d$export$80e99ee6b29cadd2 = /*#__PURE__*/ (0, $4GYXz$react
|
|
|
417
486
|
|
|
418
487
|
|
|
419
488
|
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
function $2506fd72fd4393aa$export$f4d89133c6985668(type, stateKey, componentName) {
|
|
494
|
+
const instances = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e)[type + "_instances"];
|
|
495
|
+
if (!instances.get(undefined)) throw Error(`${componentName}: State not set up. Did you forget to wrap your app in DepictProvider? Also make sure you've provided a merchant and a market.`);
|
|
496
|
+
let instance = instances.get(stateKey);
|
|
497
|
+
if (!instance) {
|
|
498
|
+
instance = type === "search" ? (0, $b1cf911fa603e77a$export$bae2769a30719c48)(true, stateKey) : (0, $da98aca6c7d4c3f9$export$248b95d5073d5bab)(true, stateKey);
|
|
499
|
+
instances.set(stateKey, instance);
|
|
500
|
+
}
|
|
501
|
+
instance.users++;
|
|
502
|
+
(0, $4GYXz$solidjs.onCleanup)(()=>{
|
|
503
|
+
instance.users--;
|
|
504
|
+
if (!instance.users && instance?.dispose) {
|
|
505
|
+
// main instance is not disposable, and shouldn't be deletable either
|
|
506
|
+
instance.dispose();
|
|
507
|
+
instances.delete(stateKey);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
return instance.instance;
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
const $7ad7a3d0011b7b1b$var$rendered_components_with_state_key = new Set();
|
|
420
515
|
function $7ad7a3d0011b7b1b$export$a54ec244c8863715(props) {
|
|
421
516
|
return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)({
|
|
422
517
|
solid_component: (0, $b4d0d98857ed9934$export$e5139bbbb9a05035)($7ad7a3d0011b7b1b$var$SolidSearchPage),
|
|
@@ -424,13 +519,29 @@ function $7ad7a3d0011b7b1b$export$a54ec244c8863715(props) {
|
|
|
424
519
|
});
|
|
425
520
|
}
|
|
426
521
|
function $7ad7a3d0011b7b1b$var$SolidSearchPage(props, set_portals) {
|
|
427
|
-
const depict_search = (0, $
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
522
|
+
const depict_search = (0, $4GYXz$solidjs.createMemo)(()=>{
|
|
523
|
+
const instance = (0, $2506fd72fd4393aa$export$f4d89133c6985668)("search", props.stateKey, "SearchPage");
|
|
524
|
+
(0, $4GYXz$solidjs.onCleanup)(()=>{
|
|
525
|
+
// Make sure we don't block the search query updating signal when we switch to a new provider instance
|
|
526
|
+
(0, $4GYXz$depictaiui.get_search_query_updating_blocked_signal)(instance)?.[1](false);
|
|
527
|
+
});
|
|
528
|
+
return instance;
|
|
529
|
+
});
|
|
432
530
|
const update_updating_blocked_signal = ()=>{
|
|
433
|
-
|
|
531
|
+
// if search instances changes, also re-check for good measure (otherwise would have untrack around depict_search)
|
|
532
|
+
const signal = (0, $4GYXz$depictaiui.get_search_query_updating_blocked_signal)(depict_search());
|
|
533
|
+
if (!signal) throw Error("No search_query_updating_blocked_signal when rendering SearchPage");
|
|
534
|
+
const [, write_signal] = signal;
|
|
535
|
+
// This causes a bug. To reproduce:
|
|
536
|
+
// 1. Go to front page
|
|
537
|
+
// 2. Make a search
|
|
538
|
+
// 3. Press back button
|
|
539
|
+
// 4. Open search modal
|
|
540
|
+
// 5. Check the list of previous queries - the query just made isn't shown
|
|
541
|
+
// This is because on the front page the search_query updating is blocked because it's not the search page, and that means that `filtered_previous_searches` in Autocomplete.tsx doesn't filter out the current search query
|
|
542
|
+
// Because it's so minor and would be quite hard to fix (one would need a second "actual search query" signal just for this purpose) it's wontfix for now
|
|
543
|
+
// EDIT: now that we're resetting this in the onCleanup of the memo above this might no longer be the case
|
|
544
|
+
write_signal(!(0, $b4d0d98857ed9934$export$775e6b3892b5ad52)(location));
|
|
434
545
|
};
|
|
435
546
|
const [, set_search_page_in_dom] = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_in_dom;
|
|
436
547
|
const component_portals = new Set();
|
|
@@ -444,24 +555,30 @@ function $7ad7a3d0011b7b1b$var$SolidSearchPage(props, set_portals) {
|
|
|
444
555
|
update_updating_blocked_signal();
|
|
445
556
|
});
|
|
446
557
|
$7ad7a3d0011b7b1b$var$search_page_path_checker();
|
|
447
|
-
return (0, $4GYXz$
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
558
|
+
return (0, $4GYXz$solidjs.createMemo)(()=>{
|
|
559
|
+
const stateKey = (0, $4GYXz$solidjs.untrack)(()=>props.stateKey);
|
|
560
|
+
if ($7ad7a3d0011b7b1b$var$rendered_components_with_state_key.has(stateKey)) throw new Error(`You have multiple SearchPage components with the same stateKey: ${stateKey}. Each SearchPage component must have a unique stateKey.`);
|
|
561
|
+
$7ad7a3d0011b7b1b$var$rendered_components_with_state_key.add(stateKey);
|
|
562
|
+
(0, $4GYXz$solidjs.onCleanup)(()=>$7ad7a3d0011b7b1b$var$rendered_components_with_state_key.delete(stateKey));
|
|
563
|
+
return (0, $4GYXz$depictaiui.SearchPage)({
|
|
564
|
+
// Default config goes here
|
|
565
|
+
get include_input_field () {
|
|
566
|
+
return props.includeInputField;
|
|
567
|
+
},
|
|
568
|
+
get cols_at_size () {
|
|
569
|
+
return props.columnsAtSize ?? (0, $4GYXz$depictaiui.defaultColsAtSize);
|
|
570
|
+
},
|
|
571
|
+
get grid_spacing () {
|
|
572
|
+
return props.gridSpacing ?? (0, $4GYXz$depictaiui.defaultGridSpacing);
|
|
573
|
+
},
|
|
574
|
+
depict_search: depict_search(),
|
|
575
|
+
product_card_template: (display)=>(0, $b4d0d98857ed9934$export$79c79419c1ef0081)({
|
|
576
|
+
display: display,
|
|
577
|
+
react_template: (0, $4GYXz$solidjs.untrack)(()=>props.productCard),
|
|
578
|
+
component_portals: component_portals,
|
|
579
|
+
set_portals: set_portals
|
|
580
|
+
})
|
|
581
|
+
});
|
|
465
582
|
});
|
|
466
583
|
}
|
|
467
584
|
/**
|
|
@@ -471,7 +588,7 @@ function $7ad7a3d0011b7b1b$var$SolidSearchPage(props, set_portals) {
|
|
|
471
588
|
(0, $4GYXz$solidjs.createEffect)(()=>{
|
|
472
589
|
if (has_warned) return;
|
|
473
590
|
const should_be_path = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).search_page_path_[0]();
|
|
474
|
-
const { pathname: pathname
|
|
591
|
+
const { pathname: pathname } = location;
|
|
475
592
|
if (// allow some variability just to be sure
|
|
476
593
|
should_be_path !== pathname && should_be_path + "/" !== pathname && should_be_path !== pathname + "/") {
|
|
477
594
|
(0, $4GYXz$depictaiutilishared.derror)("searchPagePath is set to", should_be_path, "but the SearchPage is rendered at", pathname, ". Please double-check your searchPagePath is where the SearchPage component ends up being rendered, after all redirects, unless you're sure this is intentional.");
|
|
@@ -485,6 +602,8 @@ function $7ad7a3d0011b7b1b$var$SolidSearchPage(props, set_portals) {
|
|
|
485
602
|
|
|
486
603
|
|
|
487
604
|
|
|
605
|
+
|
|
606
|
+
const $5aa5fcb9f8a2bebc$var$rendered_components_with_state_key = new Set();
|
|
488
607
|
function $5aa5fcb9f8a2bebc$export$f7d2f673fc2f091d(props) {
|
|
489
608
|
return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)({
|
|
490
609
|
// @ts-ignore
|
|
@@ -495,8 +614,8 @@ function $5aa5fcb9f8a2bebc$export$f7d2f673fc2f091d(props) {
|
|
|
495
614
|
});
|
|
496
615
|
}
|
|
497
616
|
function $5aa5fcb9f8a2bebc$var$SolidCategoryPage(props, set_portals) {
|
|
498
|
-
const depict_category = (0, $
|
|
499
|
-
|
|
617
|
+
const depict_category = (0, $4GYXz$solidjs.createMemo)(()=>(0, $2506fd72fd4393aa$export$f4d89133c6985668)("category", props.stateKey, "CategoryPage") // stateKey can change
|
|
618
|
+
);
|
|
500
619
|
const [category_state_set, set_category_state_set] = (0, $4GYXz$solidjs.createSignal)(false);
|
|
501
620
|
const component_portals = new Set();
|
|
502
621
|
const [, set_category_page_in_dom] = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).category_page_in_dom;
|
|
@@ -504,35 +623,41 @@ function $5aa5fcb9f8a2bebc$var$SolidCategoryPage(props, set_portals) {
|
|
|
504
623
|
set_category_page_in_dom(true);
|
|
505
624
|
(0, $4GYXz$solidjs.onCleanup)(()=>set_category_page_in_dom(false));
|
|
506
625
|
(0, $4GYXz$solidjs.createComputed)(()=>{
|
|
507
|
-
const { categoryId: categoryId
|
|
508
|
-
depict_category.category_id = categoryId;
|
|
626
|
+
const { categoryId: categoryId } = props;
|
|
627
|
+
depict_category().category_id = categoryId;
|
|
509
628
|
if (categoryId) {
|
|
510
629
|
set_category_state_set(true);
|
|
511
630
|
(0, $0b7cd4fb39fc3502$export$8e769ad4338a911e).known_category_paths.add(location.pathname);
|
|
512
631
|
}
|
|
513
632
|
});
|
|
514
|
-
(0, $4GYXz$solidjs.createComputed)(()=>depict_category.listing_type = props.listingType);
|
|
515
|
-
const category = ()=>(0, $4GYXz$
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
633
|
+
(0, $4GYXz$solidjs.createComputed)(()=>depict_category().listing_type = props.listingType);
|
|
634
|
+
const category = ()=>(0, $4GYXz$solidjs.createMemo)(()=>{
|
|
635
|
+
const stateKey = (0, $4GYXz$solidjs.untrack)(()=>props.stateKey);
|
|
636
|
+
if ($5aa5fcb9f8a2bebc$var$rendered_components_with_state_key.has(stateKey)) throw new Error(`You have multiple CategoryPage components with the same stateKey: ${stateKey}. Each CategoryPage component must have a unique stateKey.`);
|
|
637
|
+
$5aa5fcb9f8a2bebc$var$rendered_components_with_state_key.add(stateKey);
|
|
638
|
+
(0, $4GYXz$solidjs.onCleanup)(()=>$5aa5fcb9f8a2bebc$var$rendered_components_with_state_key.delete(stateKey));
|
|
639
|
+
return (0, $4GYXz$depictaiui.CategoryPage)({
|
|
640
|
+
depict_category: depict_category(),
|
|
641
|
+
get cols_at_size () {
|
|
642
|
+
return props.columnsAtSize ?? (0, $4GYXz$depictaiui.defaultColsAtSize);
|
|
643
|
+
},
|
|
644
|
+
get grid_spacing () {
|
|
645
|
+
return props.gridSpacing ?? (0, $4GYXz$depictaiui.defaultGridSpacing);
|
|
646
|
+
},
|
|
647
|
+
category_title: (0, $4GYXz$solidjs.untrack)(()=>props.categoryTitlePlugin) || (0, $4GYXz$depictaiui.defaultCategoryTitlePlugin),
|
|
648
|
+
get show_breadcrumbs () {
|
|
649
|
+
return props.showBreadcrumbs;
|
|
650
|
+
},
|
|
651
|
+
get show_quicklinks () {
|
|
652
|
+
return props.showQuicklinks;
|
|
653
|
+
},
|
|
654
|
+
product_card_template: (display)=>(0, $b4d0d98857ed9934$export$79c79419c1ef0081)({
|
|
655
|
+
display: display,
|
|
656
|
+
react_template: (0, $4GYXz$solidjs.untrack)(()=>props.productCard),
|
|
657
|
+
component_portals: component_portals,
|
|
658
|
+
set_portals: set_portals
|
|
659
|
+
})
|
|
660
|
+
});
|
|
536
661
|
});
|
|
537
662
|
return (0, $b4d0d98857ed9934$export$e5139bbbb9a05035)(category, category_state_set);
|
|
538
663
|
}
|
|
@@ -541,17 +666,20 @@ function $5aa5fcb9f8a2bebc$var$SolidCategoryPage(props, set_portals) {
|
|
|
541
666
|
|
|
542
667
|
|
|
543
668
|
|
|
544
|
-
|
|
669
|
+
|
|
670
|
+
function $d88e98b11c182b8e$export$5646050d516e06bc(react_props) {
|
|
545
671
|
return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)({
|
|
546
672
|
solid_component: (0, $b4d0d98857ed9934$export$e5139bbbb9a05035)($d88e98b11c182b8e$var$vanilla_breadcrumbs),
|
|
547
|
-
props:
|
|
673
|
+
props: react_props
|
|
548
674
|
});
|
|
549
675
|
}
|
|
550
|
-
function $d88e98b11c182b8e$var$vanilla_breadcrumbs() {
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
676
|
+
function $d88e98b11c182b8e$var$vanilla_breadcrumbs(props) {
|
|
677
|
+
// memo so stateKey can be dynamically changed
|
|
678
|
+
return (0, $4GYXz$solidjs.createMemo)(()=>{
|
|
679
|
+
const depict_category = (0, $2506fd72fd4393aa$export$f4d89133c6985668)("category", props.stateKey, "BreadCrumbs");
|
|
680
|
+
return (0, $4GYXz$depictaiui.BreadCrumbs)({
|
|
681
|
+
depict_category: depict_category
|
|
682
|
+
});
|
|
555
683
|
});
|
|
556
684
|
}
|
|
557
685
|
|
|
@@ -559,17 +687,20 @@ function $d88e98b11c182b8e$var$vanilla_breadcrumbs() {
|
|
|
559
687
|
|
|
560
688
|
|
|
561
689
|
|
|
562
|
-
|
|
690
|
+
|
|
691
|
+
function $f16af0e861aff3d0$export$466cdc317043f6cb(react_props = {}) {
|
|
563
692
|
return (0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)({
|
|
564
693
|
solid_component: (0, $b4d0d98857ed9934$export$e5139bbbb9a05035)($f16af0e861aff3d0$var$vanilla_quick_links),
|
|
565
|
-
props:
|
|
694
|
+
props: react_props
|
|
566
695
|
});
|
|
567
696
|
}
|
|
568
|
-
function $f16af0e861aff3d0$var$vanilla_quick_links() {
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
697
|
+
function $f16af0e861aff3d0$var$vanilla_quick_links(props) {
|
|
698
|
+
// memo so stateKey can be dynamically changed
|
|
699
|
+
return (0, $4GYXz$solidjs.createMemo)(()=>{
|
|
700
|
+
const depict_category = (0, $2506fd72fd4393aa$export$f4d89133c6985668)("category", props.stateKey, "QuickLinks");
|
|
701
|
+
return (0, $4GYXz$depictaiui.QuickLinks)({
|
|
702
|
+
depict_category: depict_category
|
|
703
|
+
});
|
|
573
704
|
});
|
|
574
705
|
}
|
|
575
706
|
|
|
@@ -615,21 +746,34 @@ const $7c8b440edc188ad5$export$89c6019e4baa40b1 = (raw_react_props)=>{
|
|
|
615
746
|
|
|
616
747
|
|
|
617
748
|
|
|
749
|
+
|
|
750
|
+
|
|
751
|
+
|
|
618
752
|
const $177ac8f5258066ba$export$d69d8daa20eae175 = (createOpenModalParams)=>{
|
|
619
|
-
const {
|
|
753
|
+
const { location: location = "centered", alignerRef: alignerRef, stateKey: stateKey } = createOpenModalParams;
|
|
754
|
+
let [deduped_variable, set_deduped_variable] = (0, $4GYXz$react.useState)();
|
|
755
|
+
// When component using this hook unmounts, "untrack" our component and dispose the search instance if needed
|
|
756
|
+
(0, $4GYXz$react.useEffect)(()=>deduped_variable?.[1]?.(), []);
|
|
620
757
|
const openModal = ()=>{
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
758
|
+
// Get the search instance and track this component, but only once (basically work around re-rendering)
|
|
759
|
+
// We have to do this in the openModal function since people might call this hook before creating DepictProvider
|
|
760
|
+
if (!deduped_variable) {
|
|
761
|
+
deduped_variable = (0, $4GYXz$solidjs.createRoot)((dispose)=>[
|
|
762
|
+
(0, $2506fd72fd4393aa$export$f4d89133c6985668)("search", stateKey, "useSearchModal"),
|
|
763
|
+
dispose
|
|
764
|
+
]);
|
|
765
|
+
set_deduped_variable(deduped_variable);
|
|
766
|
+
}
|
|
767
|
+
const [search] = deduped_variable;
|
|
768
|
+
if (location === "aligned" && alignerRef?.current) (0, $4GYXz$depictaiui.open_modal_with_alignment)({
|
|
769
|
+
"element": alignerRef.current,
|
|
770
|
+
"location": location,
|
|
771
|
+
"search": search
|
|
772
|
+
});
|
|
773
|
+
else (0, $4GYXz$depictaiui.open_modal_with_alignment)({
|
|
774
|
+
"location": "centered",
|
|
775
|
+
"search": search
|
|
776
|
+
});
|
|
633
777
|
};
|
|
634
778
|
return openModal;
|
|
635
779
|
};
|
|
@@ -659,13 +803,18 @@ const $913da7f4d0bc77f2$export$9bb30bbe003b82e0 = (props = {})=>{
|
|
|
659
803
|
set_aligner_signal_value(props?.alignerRef);
|
|
660
804
|
// Make sure react never re-renders the actual SearchField component
|
|
661
805
|
const componentFunction = (0, $4GYXz$react.useCallback)(()=>(0, $b4d0d98857ed9934$export$f6e64e17bd69eeef)({
|
|
662
|
-
solid_component: (0, $b4d0d98857ed9934$export$e5139bbbb9a05035)(()=>
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
806
|
+
solid_component: (0, $b4d0d98857ed9934$export$e5139bbbb9a05035)(()=>{
|
|
807
|
+
return (0, $4GYXz$solidjs.createMemo)(()=>{
|
|
808
|
+
const depict_search = (0, $2506fd72fd4393aa$export$f4d89133c6985668)("search", props.stateKey, "useSearchField");
|
|
809
|
+
return (0, $4GYXz$depictaiui.SearchField)({
|
|
810
|
+
depict_search: depict_search,
|
|
811
|
+
get aligner_ref () {
|
|
812
|
+
// React mutates the object at some random time so only get the current value once it actually is requested
|
|
813
|
+
return get_aligner_signal_value()?.current;
|
|
814
|
+
}
|
|
815
|
+
});
|
|
816
|
+
});
|
|
817
|
+
}),
|
|
669
818
|
props: {}
|
|
670
819
|
}), []);
|
|
671
820
|
return {
|
|
@@ -677,19 +826,22 @@ const $913da7f4d0bc77f2$export$9bb30bbe003b82e0 = (props = {})=>{
|
|
|
677
826
|
|
|
678
827
|
|
|
679
828
|
|
|
829
|
+
|
|
680
830
|
function $a134ea100690b628$export$6501da23a2770fc() {
|
|
681
831
|
return {
|
|
682
832
|
fetchRecommendations: $a134ea100690b628$var$fetchRecommendations
|
|
683
833
|
};
|
|
684
834
|
}
|
|
685
835
|
function $a134ea100690b628$var$fetchRecommendations(opts) {
|
|
686
|
-
const { merchant:
|
|
836
|
+
const { merchant: [get_merchant], market: [get_market], userId: [get_userId], sessionId: [get_sessionId] } = (0, $0b7cd4fb39fc3502$export$8e769ad4338a911e);
|
|
837
|
+
const merchant = (0, $4GYXz$solidjs.untrack)(get_merchant);
|
|
838
|
+
const market = (0, $4GYXz$solidjs.untrack)(get_market);
|
|
687
839
|
if (!merchant || !market) throw new Error("Depict recommendations are not configured. Wrap your app in a DepictProvider.");
|
|
688
840
|
return (0, $4GYXz$depictaiui.fetchDepictRecommendations)({
|
|
689
841
|
merchant: merchant,
|
|
690
842
|
market: market,
|
|
691
|
-
userId:
|
|
692
|
-
sessionId:
|
|
843
|
+
userId: (0, $4GYXz$solidjs.untrack)(get_userId),
|
|
844
|
+
sessionId: (0, $4GYXz$solidjs.untrack)(get_sessionId),
|
|
693
845
|
...opts
|
|
694
846
|
});
|
|
695
847
|
}
|
|
@@ -699,7 +851,7 @@ function $a134ea100690b628$var$fetchRecommendations(opts) {
|
|
|
699
851
|
|
|
700
852
|
|
|
701
853
|
|
|
702
|
-
const $e387bd534de10acd$export$804fac5697cfbe35 = (router)=>(relativeUrl, { scroll: scroll
|
|
854
|
+
const $e387bd534de10acd$export$804fac5697cfbe35 = (router)=>(relativeUrl, { scroll: scroll, replace: replace })=>{
|
|
703
855
|
let Page;
|
|
704
856
|
(function(Page) {
|
|
705
857
|
Page[Page["OTHER"] = 0] = "OTHER";
|