@depict-ai/react-ui 1.3.10 → 1.5.1
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 +3 -1
- package/dist/index.d.ts +29 -7
- package/dist/main.js +294 -142
- package/dist/module.js +297 -145
- 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 +2 -2
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, derror as $TZSbU$derror} from "@depict-ai/utilishared";
|
|
2
|
-
import {CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts, DepictAPI as $TZSbU$DepictAPI,
|
|
3
|
-
import {
|
|
4
|
-
import {createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment,
|
|
2
|
+
import {CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts, DepictAPI as $TZSbU$DepictAPI, ProductCardError as $TZSbU$ProductCardError, 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, defaultColsAtSize as $TZSbU$defaultColsAtSize, defaultGridSpacing as $TZSbU$defaultGridSpacing, CategoryPage as $TZSbU$CategoryPage, defaultCategoryTitlePlugin as $TZSbU$defaultCategoryTitlePlugin, BreadCrumbs as $TZSbU$BreadCrumbs, QuickLinks as $TZSbU$QuickLinks, ImagePlaceholder as $TZSbU$ImagePlaceholder, TextPlaceholder as $TZSbU$TextPlaceholder, open_modal_with_alignment as $TZSbU$open_modal_with_alignment, SearchField as $TZSbU$SearchField, fetchDepictRecommendations as $TZSbU$fetchDepictRecommendations} from "@depict-ai/ui";
|
|
3
|
+
import {untrack as $TZSbU$untrack, createRoot as $TZSbU$createRoot, createEffect as $TZSbU$createEffect, createMemo as $TZSbU$createMemo, 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} from "solid-js";
|
|
4
|
+
import {createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment, useEffect as $TZSbU$useEffect, useState as $TZSbU$useState, useRef as $TZSbU$useRef, Component as $TZSbU$Component, forwardRef as $TZSbU$forwardRef, useCallback as $TZSbU$useCallback} from "react";
|
|
5
5
|
import {defaultLocale as $TZSbU$defaultLocale} from "@depict-ai/ui/locales";
|
|
6
6
|
import {render as $TZSbU$render, hydrate as $TZSbU$hydrate} from "solid-js/web";
|
|
7
7
|
import {jsx as $TZSbU$jsx} from "react/jsx-runtime";
|
|
@@ -11,7 +11,8 @@ 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.
|
|
14
|
+
const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "1.5.1";
|
|
15
|
+
|
|
15
16
|
|
|
16
17
|
|
|
17
18
|
|
|
@@ -23,18 +24,17 @@ const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "1.3.10";
|
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
const $42858f023ef23dab$export$8e769ad4338a911e = {
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
usedLocale: (0, $TZSbU$createSignal)((0, $TZSbU$defaultLocale)),
|
|
28
|
+
search_instances: new Map(),
|
|
29
|
+
category_instances: new Map(),
|
|
28
30
|
api: null,
|
|
29
31
|
dpc: null,
|
|
30
|
-
merchant:
|
|
31
|
-
market:
|
|
32
|
-
userId:
|
|
33
|
-
sessionId:
|
|
34
|
-
metaData: undefined,
|
|
32
|
+
merchant: (0, $TZSbU$createSignal)(),
|
|
33
|
+
market: (0, $TZSbU$createSignal)(),
|
|
34
|
+
userId: (0, $TZSbU$createSignal)(),
|
|
35
|
+
sessionId: (0, $TZSbU$createSignal)(),
|
|
35
36
|
known_category_paths: new Set(),
|
|
36
37
|
search_page_path_: (0, $TZSbU$createSignal)(),
|
|
37
|
-
required_state_set_: (0, $TZSbU$createSignal)(false),
|
|
38
38
|
search_page_in_dom: (0, $TZSbU$createSignal)(false),
|
|
39
39
|
category_page_in_dom: (0, $TZSbU$createSignal)(false)
|
|
40
40
|
};
|
|
@@ -112,12 +112,13 @@ function $c83ba9ab79386687$export$f6e64e17bd69eeef({ solid_component: solid_comp
|
|
|
112
112
|
} : {}
|
|
113
113
|
}), ...portals);
|
|
114
114
|
}
|
|
115
|
-
function $c83ba9ab79386687$export$e5139bbbb9a05035(component, is_set
|
|
115
|
+
function $c83ba9ab79386687$export$e5139bbbb9a05035(component, is_set) {
|
|
116
116
|
return (...args)=>{
|
|
117
|
+
const default_is_set = (0, $TZSbU$createMemo)(()=>!!((0, $42858f023ef23dab$export$8e769ad4338a911e).merchant[0]() && (0, $42858f023ef23dab$export$8e769ad4338a911e).market[0]())); // Apparently Show re-renders kids otherwise even if the falsiness of the condition doesn't change
|
|
117
118
|
// @ts-ignore
|
|
118
119
|
return (0, $TZSbU$createComponent)((0, $TZSbU$Show), {
|
|
119
120
|
get when () {
|
|
120
|
-
return is_set();
|
|
121
|
+
return (is_set || default_is_set)();
|
|
121
122
|
},
|
|
122
123
|
get children () {
|
|
123
124
|
return component(...args);
|
|
@@ -154,9 +155,10 @@ async function $c83ba9ab79386687$export$79c79419c1ef0081({ display: display , co
|
|
|
154
155
|
was_cleaned_up = true;
|
|
155
156
|
// 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
|
|
156
157
|
component_portals.delete(portal);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
// 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
|
|
159
|
+
queueMicrotask(()=>set_portals([
|
|
160
|
+
...component_portals
|
|
161
|
+
]));
|
|
160
162
|
});
|
|
161
163
|
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.
|
|
162
164
|
return [
|
|
@@ -300,23 +302,102 @@ const $a00d8f27abd5d0b0$export$47e064413edabf36 = (merchant, market, userId, ses
|
|
|
300
302
|
};
|
|
301
303
|
|
|
302
304
|
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
function $80202ccbe2ade418$export$bae2769a30719c48(disposable, stateKey) {
|
|
309
|
+
const actual_function = (dispose)=>{
|
|
310
|
+
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, $42858f023ef23dab$export$8e769ad4338a911e);
|
|
311
|
+
const instance = new (0, $TZSbU$DepictSearch)({
|
|
312
|
+
api: (0, $42858f023ef23dab$export$8e769ad4338a911e).api,
|
|
313
|
+
search_query_url_param_name: search_query_url_param_name,
|
|
314
|
+
market: (0, $TZSbU$untrack)(get_market),
|
|
315
|
+
// TODO: check if we can do this
|
|
316
|
+
merchant: (0, $TZSbU$untrack)(get_merchant),
|
|
317
|
+
enable_category_suggestions: (0, $42858f023ef23dab$export$8e769ad4338a911e).enableCategorySuggestions ?? false,
|
|
318
|
+
// default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
|
|
319
|
+
localization: (0, $TZSbU$untrack)(get_locale),
|
|
320
|
+
url_transformer: (url)=>url.pathname = (0, $TZSbU$untrack)(get_search_page_path),
|
|
321
|
+
on_navigation: (0, $42858f023ef23dab$export$8e769ad4338a911e).on_navigation,
|
|
322
|
+
unique_instance_key_for_state: stateKey
|
|
323
|
+
});
|
|
324
|
+
(0, $TZSbU$createComputed)(()=>{
|
|
325
|
+
const new_merchant = get_merchant();
|
|
326
|
+
if (new_merchant) instance.merchant = new_merchant;
|
|
327
|
+
});
|
|
328
|
+
(0, $TZSbU$createComputed)(()=>{
|
|
329
|
+
const new_market = get_market();
|
|
330
|
+
if (new_market) instance.market = new_market;
|
|
331
|
+
});
|
|
332
|
+
(0, $TZSbU$createComputed)(()=>instance.localization = get_locale());
|
|
333
|
+
return {
|
|
334
|
+
instance: instance,
|
|
335
|
+
dispose: dispose,
|
|
336
|
+
users: 0
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
const function_length_0 = ()=>actual_function();
|
|
340
|
+
const function_length_1 = (dispose)=>actual_function(dispose);
|
|
341
|
+
return (0, $TZSbU$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
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
function $9145bcf81a0216ce$export$248b95d5073d5bab(disposable, stateKey) {
|
|
349
|
+
const actual_function = (dispose)=>{
|
|
350
|
+
const { usedLocale: [get_locale] , merchant: [get_merchant] , market: [get_market] } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
|
|
351
|
+
const instance = new (0, $TZSbU$DepictCategory)({
|
|
352
|
+
api: (0, $42858f023ef23dab$export$8e769ad4338a911e).api,
|
|
353
|
+
market: (0, $TZSbU$untrack)(get_market),
|
|
354
|
+
// TODO: check if we can do this
|
|
355
|
+
merchant: (0, $TZSbU$untrack)(get_merchant),
|
|
356
|
+
localization: (0, $TZSbU$untrack)(get_locale),
|
|
357
|
+
on_navigation: (0, $42858f023ef23dab$export$8e769ad4338a911e).on_navigation,
|
|
358
|
+
unique_instance_key_for_state: stateKey
|
|
359
|
+
});
|
|
360
|
+
(0, $TZSbU$createComputed)(()=>{
|
|
361
|
+
const new_merchant = get_merchant();
|
|
362
|
+
if (new_merchant) instance.merchant = new_merchant;
|
|
363
|
+
});
|
|
364
|
+
(0, $TZSbU$createComputed)(()=>{
|
|
365
|
+
const new_market = get_market();
|
|
366
|
+
if (new_market) instance.market = new_market;
|
|
367
|
+
});
|
|
368
|
+
(0, $TZSbU$createComputed)(()=>instance.localization = get_locale());
|
|
369
|
+
return {
|
|
370
|
+
instance: instance,
|
|
371
|
+
dispose: dispose,
|
|
372
|
+
users: 0
|
|
373
|
+
};
|
|
374
|
+
};
|
|
375
|
+
const function_length_0 = ()=>actual_function();
|
|
376
|
+
const function_length_1 = (dispose)=>actual_function(dispose);
|
|
377
|
+
return (0, $TZSbU$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
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
let $5376eb2a386cd90d$var$provider_instances = 0;
|
|
303
382
|
function $5376eb2a386cd90d$export$9fac37a9c21c2f3b(props) {
|
|
304
383
|
const { children: children , navigateFunction: navigateFunction , market: market , merchant: merchant , locale: locale , metaData: metaData , userId: userId , sessionId: sessionId } = props;
|
|
305
384
|
const usedLocale = locale ?? (0, $TZSbU$defaultLocale);
|
|
306
385
|
const { searchPagePath: searchPagePath , urlParamName: urlParamName , enableCategorySuggestions: enableCategorySuggestions } = props.search ?? {};
|
|
386
|
+
$5376eb2a386cd90d$var$multiple_depictprovider_guard();
|
|
307
387
|
// Will run on other prop changes, but harmless
|
|
308
|
-
(0, $42858f023ef23dab$export$8e769ad4338a911e).userId
|
|
309
|
-
(0, $42858f023ef23dab$export$8e769ad4338a911e).sessionId
|
|
388
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).userId[1](userId);
|
|
389
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).sessionId[1](sessionId);
|
|
390
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).usedLocale[1](usedLocale);
|
|
310
391
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).metaData = metaData;
|
|
311
|
-
(0, $42858f023ef23dab$export$8e769ad4338a911e).
|
|
312
|
-
(0, $42858f023ef23dab$export$8e769ad4338a911e).
|
|
392
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).search_query_url_param_name = urlParamName;
|
|
393
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).enableCategorySuggestions = enableCategorySuggestions;
|
|
313
394
|
(0, $a00d8f27abd5d0b0$export$47e064413edabf36)(merchant, market, userId, sessionId);
|
|
314
|
-
if (!market || !merchant)
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
395
|
+
if (!market || !merchant) return (0, $TZSbU$createElement)((0, $TZSbU$Fragment), null, children);
|
|
396
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).market[1](market);
|
|
397
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).merchant[1](merchant);
|
|
398
|
+
(0, $8071251ee4e9ffa1$export$6453cbc34515a94d)();
|
|
318
399
|
try {
|
|
319
|
-
const {
|
|
400
|
+
const { search_instances: search_instances , category_instances: category_instances , api: api , search_page_path_: [, set_search_page_path] } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
|
|
320
401
|
if (typeof window?.next?.router === "undefined" && !navigateFunction) throw new Error("You must provide a navigateFunction when not using Next.js.");
|
|
321
402
|
const on_navigation = ({ is_replace: is_replace , new_url: new_url , scroll: scroll })=>{
|
|
322
403
|
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
|
|
@@ -326,45 +407,24 @@ function $5376eb2a386cd90d$export$9fac37a9c21c2f3b(props) {
|
|
|
326
407
|
});
|
|
327
408
|
else (0, $7216ca4c8308a0f9$export$599d4515591ef232)(new_relative_url, is_replace, scroll);
|
|
328
409
|
};
|
|
410
|
+
(0, $42858f023ef23dab$export$8e769ad4338a911e).on_navigation = on_navigation;
|
|
329
411
|
if (!api) (0, $42858f023ef23dab$export$8e769ad4338a911e).api = new (0, $TZSbU$DepictAPI)({
|
|
330
412
|
get_metadata: async ()=>(0, $42858f023ef23dab$export$8e769ad4338a911e).metaData,
|
|
331
|
-
get_user_id: ()=>(0, $42858f023ef23dab$export$8e769ad4338a911e).userId,
|
|
332
|
-
get_session_id: ()=>(0, $42858f023ef23dab$export$8e769ad4338a911e).sessionId
|
|
413
|
+
get_user_id: ()=>(0, $TZSbU$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).userId[0]),
|
|
414
|
+
get_session_id: ()=>(0, $TZSbU$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).sessionId[0])
|
|
333
415
|
});
|
|
334
416
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).api.page_url_creator = props.pageURLCreator;
|
|
335
|
-
if (searchPagePath)
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
merchant: merchant,
|
|
342
|
-
enable_category_suggestions: enableCategorySuggestions ?? false,
|
|
343
|
-
// default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
|
|
344
|
-
localization: usedLocale,
|
|
345
|
-
url_transformer: (url)=>url.pathname = (0, $TZSbU$untrack)(get_search_page_path),
|
|
346
|
-
on_navigation: on_navigation
|
|
347
|
-
}));
|
|
348
|
-
else {
|
|
349
|
-
search.market = market;
|
|
350
|
-
search.merchant = merchant;
|
|
351
|
-
search.localization = usedLocale;
|
|
352
|
-
}
|
|
417
|
+
if (searchPagePath) set_search_page_path($5376eb2a386cd90d$var$ensure_correct_formatting(searchPagePath));
|
|
418
|
+
if (!search_instances.get(undefined)) {
|
|
419
|
+
// 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.
|
|
420
|
+
// Also, it emulates the behavior pre-supporting multiple "depict blocks" on the same page
|
|
421
|
+
const instance = (0, $80202ccbe2ade418$export$bae2769a30719c48)(false);
|
|
422
|
+
search_instances.set(undefined, instance);
|
|
353
423
|
}
|
|
354
|
-
if (!
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
merchant: merchant,
|
|
358
|
-
localization: usedLocale,
|
|
359
|
-
on_navigation: on_navigation
|
|
360
|
-
}));
|
|
361
|
-
else {
|
|
362
|
-
category.market = market;
|
|
363
|
-
category.merchant = merchant;
|
|
364
|
-
category.localization = usedLocale;
|
|
424
|
+
if (!category_instances.get(undefined)) {
|
|
425
|
+
const instance = (0, $9145bcf81a0216ce$export$248b95d5073d5bab)(false);
|
|
426
|
+
category_instances.set(undefined, instance);
|
|
365
427
|
}
|
|
366
|
-
(0, $8071251ee4e9ffa1$export$6453cbc34515a94d)();
|
|
367
|
-
(0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[1](true);
|
|
368
428
|
} catch (e) {
|
|
369
429
|
// Make sure to not break the users app if we throw
|
|
370
430
|
queueMicrotask(()=>{
|
|
@@ -378,6 +438,15 @@ function $5376eb2a386cd90d$var$ensure_correct_formatting(path) {
|
|
|
378
438
|
if (!path.startsWith("/")) return "/" + path;
|
|
379
439
|
return path;
|
|
380
440
|
}
|
|
441
|
+
function $5376eb2a386cd90d$var$multiple_depictprovider_guard() {
|
|
442
|
+
(0, $TZSbU$useEffect)(()=>{
|
|
443
|
+
$5376eb2a386cd90d$var$provider_instances++;
|
|
444
|
+
if ($5376eb2a386cd90d$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.");
|
|
445
|
+
return ()=>{
|
|
446
|
+
$5376eb2a386cd90d$var$provider_instances--;
|
|
447
|
+
};
|
|
448
|
+
}, []);
|
|
449
|
+
}
|
|
381
450
|
|
|
382
451
|
|
|
383
452
|
|
|
@@ -397,6 +466,32 @@ const $421f32789b6f111f$export$80e99ee6b29cadd2 = /*#__PURE__*/ (0, $TZSbU$forwa
|
|
|
397
466
|
|
|
398
467
|
|
|
399
468
|
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
function $99489374cd4f601d$export$f4d89133c6985668(type, stateKey, componentName) {
|
|
474
|
+
const instances = (0, $42858f023ef23dab$export$8e769ad4338a911e)[type + "_instances"];
|
|
475
|
+
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.`);
|
|
476
|
+
let instance = instances.get(stateKey);
|
|
477
|
+
if (!instance) {
|
|
478
|
+
instance = type === "search" ? (0, $80202ccbe2ade418$export$bae2769a30719c48)(true, stateKey) : (0, $9145bcf81a0216ce$export$248b95d5073d5bab)(true, stateKey);
|
|
479
|
+
instances.set(stateKey, instance);
|
|
480
|
+
}
|
|
481
|
+
instance.users++;
|
|
482
|
+
(0, $TZSbU$onCleanup)(()=>{
|
|
483
|
+
instance.users--;
|
|
484
|
+
if (!instance.users && instance?.dispose) {
|
|
485
|
+
// main instance is not disposable, and shouldn't be deletable either
|
|
486
|
+
instance.dispose();
|
|
487
|
+
instances.delete(stateKey);
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
return instance.instance;
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
const $4a678f0c87b12e78$var$rendered_components_with_state_key = new Set();
|
|
400
495
|
function $4a678f0c87b12e78$export$a54ec244c8863715(props) {
|
|
401
496
|
return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
|
|
402
497
|
solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)($4a678f0c87b12e78$var$SolidSearchPage),
|
|
@@ -404,13 +499,29 @@ function $4a678f0c87b12e78$export$a54ec244c8863715(props) {
|
|
|
404
499
|
});
|
|
405
500
|
}
|
|
406
501
|
function $4a678f0c87b12e78$var$SolidSearchPage(props, set_portals) {
|
|
407
|
-
const depict_search = (0, $
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
502
|
+
const depict_search = (0, $TZSbU$createMemo)(()=>{
|
|
503
|
+
const instance = (0, $99489374cd4f601d$export$f4d89133c6985668)("search", props.stateKey, "SearchPage");
|
|
504
|
+
(0, $TZSbU$onCleanup)(()=>{
|
|
505
|
+
// Make sure we don't block the search query updating signal when we switch to a new provider instance
|
|
506
|
+
(0, $TZSbU$get_search_query_updating_blocked_signal)(instance)?.[1](false);
|
|
507
|
+
});
|
|
508
|
+
return instance;
|
|
509
|
+
});
|
|
412
510
|
const update_updating_blocked_signal = ()=>{
|
|
413
|
-
|
|
511
|
+
// if search instances changes, also re-check for good measure (otherwise would have untrack around depict_search)
|
|
512
|
+
const signal = (0, $TZSbU$get_search_query_updating_blocked_signal)(depict_search());
|
|
513
|
+
if (!signal) throw Error("No search_query_updating_blocked_signal when rendering SearchPage");
|
|
514
|
+
const [, write_signal] = signal;
|
|
515
|
+
// This causes a bug. To reproduce:
|
|
516
|
+
// 1. Go to front page
|
|
517
|
+
// 2. Make a search
|
|
518
|
+
// 3. Press back button
|
|
519
|
+
// 4. Open search modal
|
|
520
|
+
// 5. Check the list of previous queries - the query just made isn't shown
|
|
521
|
+
// 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
|
|
522
|
+
// 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
|
|
523
|
+
// EDIT: now that we're resetting this in the onCleanup of the memo above this might no longer be the case
|
|
524
|
+
write_signal(!(0, $c83ba9ab79386687$export$775e6b3892b5ad52)(location));
|
|
414
525
|
};
|
|
415
526
|
const [, set_search_page_in_dom] = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_in_dom;
|
|
416
527
|
const component_portals = new Set();
|
|
@@ -424,24 +535,30 @@ function $4a678f0c87b12e78$var$SolidSearchPage(props, set_portals) {
|
|
|
424
535
|
update_updating_blocked_signal();
|
|
425
536
|
});
|
|
426
537
|
$4a678f0c87b12e78$var$search_page_path_checker();
|
|
427
|
-
return (0, $TZSbU$
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
538
|
+
return (0, $TZSbU$createMemo)(()=>{
|
|
539
|
+
const stateKey = (0, $TZSbU$untrack)(()=>props.stateKey);
|
|
540
|
+
if ($4a678f0c87b12e78$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.`);
|
|
541
|
+
$4a678f0c87b12e78$var$rendered_components_with_state_key.add(stateKey);
|
|
542
|
+
(0, $TZSbU$onCleanup)(()=>$4a678f0c87b12e78$var$rendered_components_with_state_key.delete(stateKey));
|
|
543
|
+
return (0, $TZSbU$SearchPage)({
|
|
544
|
+
// Default config goes here
|
|
545
|
+
get include_input_field () {
|
|
546
|
+
return props.includeInputField;
|
|
547
|
+
},
|
|
548
|
+
get cols_at_size () {
|
|
549
|
+
return props.columnsAtSize ?? (0, $TZSbU$defaultColsAtSize);
|
|
550
|
+
},
|
|
551
|
+
get grid_spacing () {
|
|
552
|
+
return props.gridSpacing ?? (0, $TZSbU$defaultGridSpacing);
|
|
553
|
+
},
|
|
554
|
+
depict_search: depict_search(),
|
|
555
|
+
product_card_template: (display)=>(0, $c83ba9ab79386687$export$79c79419c1ef0081)({
|
|
556
|
+
display: display,
|
|
557
|
+
react_template: (0, $TZSbU$untrack)(()=>props.productCard),
|
|
558
|
+
component_portals: component_portals,
|
|
559
|
+
set_portals: set_portals
|
|
560
|
+
})
|
|
561
|
+
});
|
|
445
562
|
});
|
|
446
563
|
}
|
|
447
564
|
/**
|
|
@@ -465,6 +582,8 @@ function $4a678f0c87b12e78$var$SolidSearchPage(props, set_portals) {
|
|
|
465
582
|
|
|
466
583
|
|
|
467
584
|
|
|
585
|
+
|
|
586
|
+
const $48d7f568740a317d$var$rendered_components_with_state_key = new Set();
|
|
468
587
|
function $48d7f568740a317d$export$f7d2f673fc2f091d(props) {
|
|
469
588
|
return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
|
|
470
589
|
// @ts-ignore
|
|
@@ -475,8 +594,8 @@ function $48d7f568740a317d$export$f7d2f673fc2f091d(props) {
|
|
|
475
594
|
});
|
|
476
595
|
}
|
|
477
596
|
function $48d7f568740a317d$var$SolidCategoryPage(props, set_portals) {
|
|
478
|
-
const depict_category = (0, $
|
|
479
|
-
|
|
597
|
+
const depict_category = (0, $TZSbU$createMemo)(()=>(0, $99489374cd4f601d$export$f4d89133c6985668)("category", props.stateKey, "CategoryPage") // stateKey can change
|
|
598
|
+
);
|
|
480
599
|
const [category_state_set, set_category_state_set] = (0, $TZSbU$createSignal)(false);
|
|
481
600
|
const component_portals = new Set();
|
|
482
601
|
const [, set_category_page_in_dom] = (0, $42858f023ef23dab$export$8e769ad4338a911e).category_page_in_dom;
|
|
@@ -485,34 +604,40 @@ function $48d7f568740a317d$var$SolidCategoryPage(props, set_portals) {
|
|
|
485
604
|
(0, $TZSbU$onCleanup)(()=>set_category_page_in_dom(false));
|
|
486
605
|
(0, $TZSbU$createComputed)(()=>{
|
|
487
606
|
const { categoryId: categoryId } = props;
|
|
488
|
-
depict_category.category_id = categoryId;
|
|
607
|
+
depict_category().category_id = categoryId;
|
|
489
608
|
if (categoryId) {
|
|
490
609
|
set_category_state_set(true);
|
|
491
610
|
(0, $42858f023ef23dab$export$8e769ad4338a911e).known_category_paths.add(location.pathname);
|
|
492
611
|
}
|
|
493
612
|
});
|
|
494
|
-
(0, $TZSbU$createComputed)(()=>depict_category.listing_type = props.listingType);
|
|
495
|
-
const category = ()=>(0, $TZSbU$
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
613
|
+
(0, $TZSbU$createComputed)(()=>depict_category().listing_type = props.listingType);
|
|
614
|
+
const category = ()=>(0, $TZSbU$createMemo)(()=>{
|
|
615
|
+
const stateKey = (0, $TZSbU$untrack)(()=>props.stateKey);
|
|
616
|
+
if ($48d7f568740a317d$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.`);
|
|
617
|
+
$48d7f568740a317d$var$rendered_components_with_state_key.add(stateKey);
|
|
618
|
+
(0, $TZSbU$onCleanup)(()=>$48d7f568740a317d$var$rendered_components_with_state_key.delete(stateKey));
|
|
619
|
+
return (0, $TZSbU$CategoryPage)({
|
|
620
|
+
depict_category: depict_category(),
|
|
621
|
+
get cols_at_size () {
|
|
622
|
+
return props.columnsAtSize ?? (0, $TZSbU$defaultColsAtSize);
|
|
623
|
+
},
|
|
624
|
+
get grid_spacing () {
|
|
625
|
+
return props.gridSpacing ?? (0, $TZSbU$defaultGridSpacing);
|
|
626
|
+
},
|
|
627
|
+
category_title: (0, $TZSbU$untrack)(()=>props.categoryTitlePlugin) || (0, $TZSbU$defaultCategoryTitlePlugin),
|
|
628
|
+
get show_breadcrumbs () {
|
|
629
|
+
return props.showBreadcrumbs;
|
|
630
|
+
},
|
|
631
|
+
get show_quicklinks () {
|
|
632
|
+
return props.showQuicklinks;
|
|
633
|
+
},
|
|
634
|
+
product_card_template: (display)=>(0, $c83ba9ab79386687$export$79c79419c1ef0081)({
|
|
635
|
+
display: display,
|
|
636
|
+
react_template: (0, $TZSbU$untrack)(()=>props.productCard),
|
|
637
|
+
component_portals: component_portals,
|
|
638
|
+
set_portals: set_portals
|
|
639
|
+
})
|
|
640
|
+
});
|
|
516
641
|
});
|
|
517
642
|
return (0, $c83ba9ab79386687$export$e5139bbbb9a05035)(category, category_state_set);
|
|
518
643
|
}
|
|
@@ -521,17 +646,20 @@ function $48d7f568740a317d$var$SolidCategoryPage(props, set_portals) {
|
|
|
521
646
|
|
|
522
647
|
|
|
523
648
|
|
|
524
|
-
|
|
649
|
+
|
|
650
|
+
function $f866f7ed9f751af4$export$5646050d516e06bc(react_props) {
|
|
525
651
|
return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
|
|
526
652
|
solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)($f866f7ed9f751af4$var$vanilla_breadcrumbs),
|
|
527
|
-
props:
|
|
653
|
+
props: react_props
|
|
528
654
|
});
|
|
529
655
|
}
|
|
530
|
-
function $f866f7ed9f751af4$var$vanilla_breadcrumbs() {
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
656
|
+
function $f866f7ed9f751af4$var$vanilla_breadcrumbs(props) {
|
|
657
|
+
// memo so stateKey can be dynamically changed
|
|
658
|
+
return (0, $TZSbU$createMemo)(()=>{
|
|
659
|
+
const depict_category = (0, $99489374cd4f601d$export$f4d89133c6985668)("category", props.stateKey, "BreadCrumbs");
|
|
660
|
+
return (0, $TZSbU$BreadCrumbs)({
|
|
661
|
+
depict_category: depict_category
|
|
662
|
+
});
|
|
535
663
|
});
|
|
536
664
|
}
|
|
537
665
|
|
|
@@ -539,17 +667,20 @@ function $f866f7ed9f751af4$var$vanilla_breadcrumbs() {
|
|
|
539
667
|
|
|
540
668
|
|
|
541
669
|
|
|
542
|
-
|
|
670
|
+
|
|
671
|
+
function $b68a14248b7ef667$export$466cdc317043f6cb(react_props = {}) {
|
|
543
672
|
return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
|
|
544
673
|
solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)($b68a14248b7ef667$var$vanilla_quick_links),
|
|
545
|
-
props:
|
|
674
|
+
props: react_props
|
|
546
675
|
});
|
|
547
676
|
}
|
|
548
|
-
function $b68a14248b7ef667$var$vanilla_quick_links() {
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
677
|
+
function $b68a14248b7ef667$var$vanilla_quick_links(props) {
|
|
678
|
+
// memo so stateKey can be dynamically changed
|
|
679
|
+
return (0, $TZSbU$createMemo)(()=>{
|
|
680
|
+
const depict_category = (0, $99489374cd4f601d$export$f4d89133c6985668)("category", props.stateKey, "QuickLinks");
|
|
681
|
+
return (0, $TZSbU$QuickLinks)({
|
|
682
|
+
depict_category: depict_category
|
|
683
|
+
});
|
|
553
684
|
});
|
|
554
685
|
}
|
|
555
686
|
|
|
@@ -595,21 +726,34 @@ const $cbd250061abf11cb$export$89c6019e4baa40b1 = (raw_react_props)=>{
|
|
|
595
726
|
|
|
596
727
|
|
|
597
728
|
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
|
|
598
732
|
const $41cab674edff4277$export$d69d8daa20eae175 = (createOpenModalParams)=>{
|
|
599
|
-
const {
|
|
733
|
+
const { location: location = "centered" , alignerRef: alignerRef , stateKey: stateKey } = createOpenModalParams;
|
|
734
|
+
let [deduped_variable, set_deduped_variable] = (0, $TZSbU$useState)();
|
|
735
|
+
// When component using this hook unmounts, "untrack" our component and dispose the search instance if needed
|
|
736
|
+
(0, $TZSbU$useEffect)(()=>deduped_variable?.[1]?.(), []);
|
|
600
737
|
const openModal = ()=>{
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
738
|
+
// Get the search instance and track this component, but only once (basically work around re-rendering)
|
|
739
|
+
// We have to do this in the openModal function since people might call this hook before creating DepictProvider
|
|
740
|
+
if (!deduped_variable) {
|
|
741
|
+
deduped_variable = (0, $TZSbU$createRoot)((dispose)=>[
|
|
742
|
+
(0, $99489374cd4f601d$export$f4d89133c6985668)("search", stateKey, "useSearchModal"),
|
|
743
|
+
dispose
|
|
744
|
+
]);
|
|
745
|
+
set_deduped_variable(deduped_variable);
|
|
746
|
+
}
|
|
747
|
+
const [search] = deduped_variable;
|
|
748
|
+
if (location === "aligned" && alignerRef?.current) (0, $TZSbU$open_modal_with_alignment)({
|
|
749
|
+
"element": alignerRef.current,
|
|
750
|
+
"location": location,
|
|
751
|
+
"search": search
|
|
752
|
+
});
|
|
753
|
+
else (0, $TZSbU$open_modal_with_alignment)({
|
|
754
|
+
"location": "centered",
|
|
755
|
+
"search": search
|
|
756
|
+
});
|
|
613
757
|
};
|
|
614
758
|
return openModal;
|
|
615
759
|
};
|
|
@@ -639,13 +783,18 @@ const $2b886cf548a4775c$export$9bb30bbe003b82e0 = (props = {})=>{
|
|
|
639
783
|
set_aligner_signal_value(props?.alignerRef);
|
|
640
784
|
// Make sure react never re-renders the actual SearchField component
|
|
641
785
|
const componentFunction = (0, $TZSbU$useCallback)(()=>(0, $c83ba9ab79386687$export$f6e64e17bd69eeef)({
|
|
642
|
-
solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)(()=>
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
786
|
+
solid_component: (0, $c83ba9ab79386687$export$e5139bbbb9a05035)(()=>{
|
|
787
|
+
return (0, $TZSbU$createMemo)(()=>{
|
|
788
|
+
const depict_search = (0, $99489374cd4f601d$export$f4d89133c6985668)("search", props.stateKey, "useSearchField");
|
|
789
|
+
return (0, $TZSbU$SearchField)({
|
|
790
|
+
depict_search: depict_search,
|
|
791
|
+
get aligner_ref () {
|
|
792
|
+
// React mutates the object at some random time so only get the current value once it actually is requested
|
|
793
|
+
return get_aligner_signal_value()?.current;
|
|
794
|
+
}
|
|
795
|
+
});
|
|
796
|
+
});
|
|
797
|
+
}),
|
|
649
798
|
props: {}
|
|
650
799
|
}), []);
|
|
651
800
|
return {
|
|
@@ -657,19 +806,22 @@ const $2b886cf548a4775c$export$9bb30bbe003b82e0 = (props = {})=>{
|
|
|
657
806
|
|
|
658
807
|
|
|
659
808
|
|
|
809
|
+
|
|
660
810
|
function $1bb4271dc44722e2$export$6501da23a2770fc() {
|
|
661
811
|
return {
|
|
662
812
|
fetchRecommendations: $1bb4271dc44722e2$var$fetchRecommendations
|
|
663
813
|
};
|
|
664
814
|
}
|
|
665
815
|
function $1bb4271dc44722e2$var$fetchRecommendations(opts) {
|
|
666
|
-
const { merchant:
|
|
816
|
+
const { merchant: [get_merchant] , market: [get_market] , userId: [get_userId] , sessionId: [get_sessionId] } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
|
|
817
|
+
const merchant = (0, $TZSbU$untrack)(get_merchant);
|
|
818
|
+
const market = (0, $TZSbU$untrack)(get_market);
|
|
667
819
|
if (!merchant || !market) throw new Error("Depict recommendations are not configured. Wrap your app in a DepictProvider.");
|
|
668
820
|
return (0, $TZSbU$fetchDepictRecommendations)({
|
|
669
821
|
merchant: merchant,
|
|
670
822
|
market: market,
|
|
671
|
-
userId:
|
|
672
|
-
sessionId:
|
|
823
|
+
userId: (0, $TZSbU$untrack)(get_userId),
|
|
824
|
+
sessionId: (0, $TZSbU$untrack)(get_sessionId),
|
|
673
825
|
...opts
|
|
674
826
|
});
|
|
675
827
|
}
|
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.
|
|
36
|
+
export const version = "1.5.1";
|
|
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
|
@@ -40,7 +40,7 @@ function $35dfe83eec81954c$export$4b564d7f5a1b1d43({ solid_component: solid_comp
|
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
|
|
43
|
-
const $db7b67857900028b$export$83d89fbfd8236492 = "1.
|
|
43
|
+
const $db7b67857900028b$export$83d89fbfd8236492 = "1.5.1";
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
function $41e7e5d85b5e0d49$export$9fac37a9c21c2f3b(props) {
|