@depict-ai/react-ui 2.0.9 → 2.0.11

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.
Files changed (47) hide show
  1. package/ES10/index.cjs +22 -7
  2. package/ES10/index.d.ts +1 -1
  3. package/ES10/index.js +23 -8
  4. package/dist/main.js +374 -140
  5. package/dist/module.js +364 -139
  6. package/dist/styles/components/PLP/Buttons.scss +93 -36
  7. package/dist/styles/components/PLP/MorphingSign.scss +2 -3
  8. package/dist/styles/components/PLP/PLPResults.scss +6 -0
  9. package/dist/styles/components/PLP/ProductListingPage.scss +28 -2
  10. package/dist/styles/components/PLP/ScrollStatus.scss +8 -1
  11. package/dist/styles/components/PLP/SelectedFilters.scss +10 -2
  12. package/dist/styles/components/PLP/SlidableItems.scss +22 -0
  13. package/dist/styles/components/PLP/SortAndFilter/FloatingButtons.scss +9 -0
  14. package/dist/styles/components/PLP/SortAndFilter/SortAndFilter.scss +90 -18
  15. package/dist/styles/components/PLP/SortAndFilter/SortAndFilterModal.scss +2 -4
  16. package/dist/styles/components/PLP/SortAndFilter/WhiteSortAndFilter.scss +6 -2
  17. package/dist/styles/components/PLP/Toast.scss +5 -0
  18. package/dist/styles/components/PLP/index.scss +12 -6
  19. package/dist/styles/components/category/BreadCrumbs.scss +13 -4
  20. package/dist/styles/components/category/CategoryTitle.scss +14 -2
  21. package/dist/styles/components/category/QuickLinks.scss +16 -7
  22. package/dist/styles/components/category/index.scss +5 -5
  23. package/dist/styles/components/search/Autocomplete.scss +99 -19
  24. package/dist/styles/components/search/CategorySuggestions.scss +8 -0
  25. package/dist/styles/components/search/InstantCard.scss +7 -2
  26. package/dist/styles/components/search/InstantResults.scss +2 -0
  27. package/dist/styles/components/search/PreviousSearches.scss +17 -4
  28. package/dist/styles/components/search/QueryInput.scss +28 -6
  29. package/dist/styles/components/search/SearchModal.scss +16 -10
  30. package/dist/styles/components/search/SearchRecommendations.scss +3 -0
  31. package/dist/styles/components/search/ShowingResultsFor.scss +3 -0
  32. package/dist/styles/components/search/index.scss +5 -5
  33. package/dist/styles/default.css +1 -1
  34. package/dist/styles/helpers/custom_input.scss +38 -6
  35. package/dist/styles/helpers/supports-hover.scss +2 -0
  36. package/dist/styles/helpers/utils.scss +9 -1
  37. package/dist/styles/variables.scss +17 -3
  38. package/latest/index.cjs +17 -7
  39. package/latest/index.d.ts +1 -1
  40. package/latest/index.js +18 -8
  41. package/package.json +2 -2
  42. package/server/ES10/index.cjs +17 -4
  43. package/server/ES10/index.d.ts +1 -1
  44. package/server/ES10/index.js +18 -5
  45. package/server/latest/index.cjs +14 -4
  46. package/server/latest/index.d.ts +1 -1
  47. package/server/latest/index.js +15 -5
package/dist/module.js CHANGED
@@ -1,18 +1,21 @@
1
- import {SearchField as $TZSbU$SearchField, DepictSearch as $TZSbU$DepictSearch, swedish_search_translation as $TZSbU$swedish_search_translation, get_search_query_updating_blocked_signal as $TZSbU$get_search_query_updating_blocked_signal, SearchPage as $TZSbU$SearchPage} from "@depict-ai/ui";
2
- import {href_change_ipns as $TZSbU$href_change_ipns, observer as $TZSbU$observer, history_replacer as $TZSbU$history_replacer, queueMacroTask as $TZSbU$queueMacroTask} from "@depict-ai/utilishared";
3
- import {untrack as $TZSbU$untrack, createComponent as $TZSbU$createComponent, Show as $TZSbU$Show, createSignal as $TZSbU$createSignal, createMemo as $TZSbU$createMemo, createComputed as $TZSbU$createComputed, onCleanup as $TZSbU$onCleanup} from "solid-js";
1
+ import {dlog as $TZSbU$dlog, href_change_ipns as $TZSbU$href_change_ipns, catchify as $TZSbU$catchify, observer as $TZSbU$observer, history_replacer as $TZSbU$history_replacer, queueMacroTask as $TZSbU$queueMacroTask, ContainedPlaceholderImage as $TZSbU$ContainedPlaceholderImage, Placeholder as $TZSbU$Placeholder} from "@depict-ai/utilishared";
2
+ import {add_to_version_info as $TZSbU$add_to_version_info, CategoryTitle as $43099132aad1ceb6$re_export$CategoryTitle, embedded_num_products as $43099132aad1ceb6$re_export$EmbeddedNumProducts, SearchField as $TZSbU$SearchField, 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, styles_to_valid_css_string as $TZSbU$styles_to_valid_css_string, align_field as $TZSbU$align_field} from "@depict-ai/ui";
3
+ import {untrack as $TZSbU$untrack, createComponent as $TZSbU$createComponent, Show as $TZSbU$Show, onCleanup as $TZSbU$onCleanup, createSignal as $TZSbU$createSignal, createRoot as $TZSbU$createRoot, createComputed as $TZSbU$createComputed} from "solid-js";
4
4
  import {render as $TZSbU$render} from "solid-js/web";
5
- import {useState as $TZSbU$useState, useRef as $TZSbU$useRef, useEffect as $TZSbU$useEffect, createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment} from "react";
5
+ import {useState as $TZSbU$useState, useRef as $TZSbU$useRef, useEffect as $TZSbU$useEffect, createElement as $TZSbU$createElement, Fragment as $TZSbU$Fragment, forwardRef as $TZSbU$forwardRef} from "react";
6
6
  import {jsx as $TZSbU$jsx} from "react/jsx-runtime";
7
7
  import {createPortal as $TZSbU$createPortal} from "react-dom";
8
+ import {en as $TZSbU$en} from "@depict-ai/ui/locales";
8
9
 
9
- // This is where the actual source of your React stuff should live
10
+ /*! Depict.ai search and product listing react SDK wrapper */ // This is where the actual source of your React stuff should live
10
11
  // Note, if you add an export here, also add one in src-server/main.ts
11
12
 
12
13
 
14
+
13
15
  const $42858f023ef23dab$export$8e769ad4338a911e = {
14
16
  search: null,
15
- header_alignment: null,
17
+ category: null,
18
+ category_path: null,
16
19
  search_page_path_: (0, $TZSbU$createSignal)(),
17
20
  required_state_set_: (0, $TZSbU$createSignal)(false)
18
21
  };
@@ -22,6 +25,7 @@ const $42858f023ef23dab$export$8e769ad4338a911e = {
22
25
 
23
26
 
24
27
 
28
+
25
29
  let $c83ba9ab79386687$var$run_on_href_change;
26
30
  function $c83ba9ab79386687$export$74f3924c5027fe1d(cb) {
27
31
  $c83ba9ab79386687$var$run_on_href_change = cb;
@@ -29,25 +33,29 @@ function $c83ba9ab79386687$export$74f3924c5027fe1d(cb) {
29
33
  (async ()=>{
30
34
  for await (const href of (0, $TZSbU$href_change_ipns))$c83ba9ab79386687$var$run_on_href_change?.(href);
31
35
  })();
32
- const $c83ba9ab79386687$export$6cb4d3a5c1ac9b43 = (url)=>url.pathname == (0, $TZSbU$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
33
- function $c83ba9ab79386687$export$f6e64e17bd69eeef(solid_component, props) {
36
+ const $c83ba9ab79386687$export$775e6b3892b5ad52 = (url)=>url.pathname == (0, $TZSbU$untrack)((0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_[0]); // might have changed therefore get it from globalState
37
+ const $c83ba9ab79386687$export$92a8f8b3c630fa0d = (url)=>{
38
+ return $c83ba9ab79386687$export$775e6b3892b5ad52(url) || url.pathname === (0, $42858f023ef23dab$export$8e769ad4338a911e).category_path;
39
+ };
40
+ function $c83ba9ab79386687$export$f6e64e17bd69eeef(solid_component, props, wrapper_type = "div", wrapper_style = {}, react_render_handler) {
34
41
  const [portals, set_portals] = (0, $TZSbU$useState)([]);
35
- const element_ref = (0, $TZSbU$useRef)();
42
+ const wrapper_element_ref = (0, $TZSbU$useRef)();
36
43
  (0, $TZSbU$useEffect)(()=>{
37
- const div_element = element_ref.current;
38
- const dispose = (0, $TZSbU$render)(()=>solid_component(props, set_portals), div_element);
44
+ const wrapper_element = wrapper_element_ref.current;
45
+ const dispose = (0, $TZSbU$render)(()=>solid_component(props, set_portals), wrapper_element);
39
46
  return dispose;
40
47
  }, []);
41
- return (0, $TZSbU$jsx)("div", {
42
- ref: element_ref,
43
- children: portals
44
- });
48
+ react_render_handler?.(props);
49
+ return (0, $TZSbU$createElement)(wrapper_type, {
50
+ ref: wrapper_element_ref,
51
+ style: wrapper_style
52
+ }, portals);
45
53
  }
46
- function $c83ba9ab79386687$export$e5139bbbb9a05035(component) {
54
+ function $c83ba9ab79386687$export$e5139bbbb9a05035(component, is_set = (0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[0]) {
47
55
  return (...args)=>{
48
56
  return (0, $TZSbU$createComponent)((0, $TZSbU$Show), {
49
57
  get when () {
50
- return (0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[0]();
58
+ return is_set();
51
59
  },
52
60
  get children () {
53
61
  return component(...args);
@@ -55,11 +63,43 @@ function $c83ba9ab79386687$export$e5139bbbb9a05035(component) {
55
63
  });
56
64
  };
57
65
  }
66
+ async function $c83ba9ab79386687$export$79c79419c1ef0081({ display: display , info: info , component_portals: component_portals , set_portals: set_portals , react_template: react_template }) {
67
+ const solid_container = document.createElement("div");
68
+ const react_has_rendered = new Promise((r)=>{
69
+ const m_o = new MutationObserver(()=>{
70
+ m_o.disconnect();
71
+ r();
72
+ });
73
+ m_o.observe(solid_container, {
74
+ childList: true
75
+ });
76
+ });
77
+ const is_placeholder = info.rendering_options.type === "placeholder";
78
+ const reactProductCard = (0, $TZSbU$jsx)(react_template, {
79
+ display: is_placeholder ? null : display
80
+ });
81
+ const portal = $TZSbU$createPortal(reactProductCard, solid_container);
82
+ component_portals.add(portal);
83
+ set_portals([
84
+ ...component_portals
85
+ ]);
86
+ (0, $TZSbU$onCleanup)(()=>{
87
+ // 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
88
+ component_portals.delete(portal);
89
+ set_portals([
90
+ ...component_portals
91
+ ]);
92
+ });
93
+ await react_has_rendered; // wait for react to have finish portaling the elements so that the placeholders get removed once we have an actual result and so that the PLP code knows it has a placeholder when this is a placeholder rendering
94
+ return [
95
+ solid_container
96
+ ];
97
+ }
58
98
 
59
99
 
60
100
 
61
101
 
62
- function $54b0d21b77e719c4$export$d2c02478244f91f7() {
102
+ function $02e2452814b6e7d6$export$4c0fa313cf50c4ad() {
63
103
  return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)(()=>(0, $TZSbU$SearchField)({
64
104
  depict_search: (0, $42858f023ef23dab$export$8e769ad4338a911e).search
65
105
  })), {});
@@ -69,7 +109,10 @@ function $54b0d21b77e719c4$export$d2c02478244f91f7() {
69
109
 
70
110
 
71
111
 
112
+
113
+
72
114
  let $8071251ee4e9ffa1$var$set = false;
115
+ let $8071251ee4e9ffa1$var$padding_animation;
73
116
  function $8071251ee4e9ffa1$export$6453cbc34515a94d(is_search_page) {
74
117
  if ($8071251ee4e9ffa1$var$set) return; // Just being safe
75
118
  $8071251ee4e9ffa1$var$set = true;
@@ -79,7 +122,7 @@ function $8071251ee4e9ffa1$export$6453cbc34515a94d(is_search_page) {
79
122
  if (should_use_old_scroll || process.env.__NEXT_SCROLL_RESTORATION || !is_search_page(location)) return Reflect.apply(old_scrollTo, window, args);
80
123
  else should_use_old_scroll = true;
81
124
  };
82
- addEventListener("popstate", (e)=>{
125
+ addEventListener("popstate", (0, $TZSbU$catchify)(()=>{
83
126
  if (!is_search_page(location)) {
84
127
  $8071251ee4e9ffa1$var$removeLotsOfPadding(); // Just making sure
85
128
  return;
@@ -89,7 +132,7 @@ function $8071251ee4e9ffa1$export$6453cbc34515a94d(is_search_page) {
89
132
  (0, $TZSbU$observer).wait_for_element(".depict.plp .listing-page").then(()=>{
90
133
  $8071251ee4e9ffa1$var$removeLotsOfPadding();
91
134
  });
92
- });
135
+ }));
93
136
  (0, $TZSbU$history_replacer)(()=>{
94
137
  (0, $TZSbU$queueMacroTask)(()=>{
95
138
  $8071251ee4e9ffa1$var$removeLotsOfPadding();
@@ -99,123 +142,118 @@ function $8071251ee4e9ffa1$export$6453cbc34515a94d(is_search_page) {
99
142
  $8071251ee4e9ffa1$var$addLotsOfPadding();
100
143
  });
101
144
  }
102
- // TODO: Make these animations so they don't collide with whatever padding is already on the body
103
- function $8071251ee4e9ffa1$var$addLotsOfPadding() {
104
- document.body.style.paddingBottom = (history.state?.search_scroll_restoration_data?.[0]?.min_results_loaded || 150) * 500 + "px";
145
+ /*
146
+ Here we want to be able to add padding that *definitely* gets applied and then be able to revert precisely to what was before.
147
+ The best way to achieve this is using an animation that with the fill set to none. This is because animations have the absolute highest precedence in CSS, even higher than !important. Then, to revert to the old padding, we just play the animation which is 1ms long so, it immediately finishes and whatever was defined before takes precedence again.
148
+ */ function $8071251ee4e9ffa1$var$addLotsOfPadding() {
149
+ if ($8071251ee4e9ffa1$var$padding_animation) return; // We're already showing a bunch of padding
150
+ $8071251ee4e9ffa1$var$padding_animation = document.body.animate({
151
+ paddingBottom: (history.state?.search_scroll_restoration_data?.[0]?.min_results_loaded || 150) * 500 + "px",
152
+ offset: 0
153
+ }, 1);
154
+ $8071251ee4e9ffa1$var$padding_animation.pause();
105
155
  }
106
156
  function $8071251ee4e9ffa1$var$removeLotsOfPadding() {
107
- document.body.style.paddingBottom = "";
157
+ if ($8071251ee4e9ffa1$var$padding_animation) {
158
+ $8071251ee4e9ffa1$var$padding_animation.play();
159
+ $8071251ee4e9ffa1$var$padding_animation = undefined;
160
+ }
108
161
  }
109
162
 
110
163
 
111
164
 
112
165
 
166
+ const $7216ca4c8308a0f9$export$599d4515591ef232 = (href)=>{
167
+ const shallow = (0, $c83ba9ab79386687$export$92a8f8b3c630fa0d)(location);
168
+ window.next.router.push(href, undefined, {
169
+ shallow: shallow,
170
+ scroll: true
171
+ });
172
+ };
173
+
113
174
 
114
- function $faf794495ff8b304$export$9fac37a9c21c2f3b(props) {
115
- if (!props.market || !props.merchant) {
175
+
176
+ function $5376eb2a386cd90d$export$9fac37a9c21c2f3b(props) {
177
+ const { children: children , navigateFunction: navigateFunction , market: market , merchant: merchant , locale: locale } = props;
178
+ const usedLocale = locale ?? (0, $TZSbU$en);
179
+ const { searchPagePath: searchPagePath , urlParamName: urlParamName , enableCategorySuggestions: enableCategorySuggestions } = props.search ?? {};
180
+ if (!market || !merchant) {
116
181
  (0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[1](false);
117
- return (0, $TZSbU$createElement)((0, $TZSbU$Fragment), null, props.children);
182
+ return (0, $TZSbU$createElement)((0, $TZSbU$Fragment), null, children);
118
183
  }
119
- const { children: children , search_page_path: search_page_path , url_param_name: url_param_name , ...assignable_options } = props;
120
- const { search: search } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
121
- const [get_search_page_path, set_search_page_path] = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_;
122
- set_search_page_path(search_page_path);
123
- if (!search) {
124
- (0, $42858f023ef23dab$export$8e769ad4338a911e).search = new (0, $TZSbU$DepictSearch)({
125
- search_query_url_param_name: url_param_name,
126
- ...assignable_options,
127
- enable_category_suggestions: false,
128
- localization: {
129
- ...(0, $TZSbU$swedish_search_translation),
130
- price_formatting_: {
131
- pre_: "kr ",
132
- post_: "",
133
- decimal_places_delimiter_: ",",
134
- thousands_delimiter_: " ",
135
- places_after_comma_: 2
136
- }
137
- },
138
- on_navigation: (new_href)=>{
139
- const shallow = (0, $c83ba9ab79386687$export$6cb4d3a5c1ac9b43)(location);
140
- if (window.next) window.next.router.push(new_href, undefined, {
141
- shallow: shallow,
142
- scroll: true
143
- });
144
- else location.href = new_href;
145
- },
146
- url_transformer: (url)=>url.pathname = (0, $TZSbU$untrack)(get_search_page_path)
184
+ try {
185
+ const { search: search , category: category } = (0, $42858f023ef23dab$export$8e769ad4338a911e);
186
+ const [get_search_page_path, set_search_page_path] = (0, $42858f023ef23dab$export$8e769ad4338a911e).search_page_path_;
187
+ set_search_page_path(searchPagePath);
188
+ const on_navigation = typeof window?.next?.router !== "undefined" || navigateFunction ? (new_href)=>{
189
+ if (navigateFunction) navigateFunction(new_href);
190
+ else (0, $7216ca4c8308a0f9$export$599d4515591ef232)(new_href);
191
+ } : undefined;
192
+ if (!search) (0, $TZSbU$createRoot)(()=>(0, $42858f023ef23dab$export$8e769ad4338a911e).search = new (0, $TZSbU$DepictSearch)({
193
+ search_query_url_param_name: urlParamName,
194
+ market: market,
195
+ merchant: merchant,
196
+ enable_category_suggestions: enableCategorySuggestions ?? false,
197
+ // default category suggestions to false for @depict-ai/react-ui (https://linear.app/depictai/issue/FRO-401/default-enablecategorysuggestions-to-false)
198
+ localization: usedLocale,
199
+ url_transformer: (url)=>url.pathname = (0, $TZSbU$untrack)(get_search_page_path),
200
+ on_navigation: on_navigation
201
+ }));
202
+ else {
203
+ search.market = market;
204
+ search.merchant = merchant;
205
+ search.localization = usedLocale;
206
+ }
207
+ if (!category) (0, $TZSbU$createRoot)(()=>(0, $42858f023ef23dab$export$8e769ad4338a911e).category = new (0, $TZSbU$DepictCategory)({
208
+ market: market,
209
+ merchant: merchant,
210
+ localization: usedLocale,
211
+ on_navigation: on_navigation
212
+ }));
213
+ else {
214
+ category.market = market;
215
+ category.merchant = merchant;
216
+ category.localization = usedLocale;
217
+ }
218
+ (0, $8071251ee4e9ffa1$export$6453cbc34515a94d)((0, $c83ba9ab79386687$export$92a8f8b3c630fa0d));
219
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[1](true);
220
+ } catch (e) {
221
+ // Make sure to not break the users app if we throw
222
+ queueMicrotask(()=>{
223
+ throw e;
147
224
  });
148
- (0, $8071251ee4e9ffa1$export$6453cbc34515a94d)((0, $c83ba9ab79386687$export$6cb4d3a5c1ac9b43));
149
- } else Object.assign(search, assignable_options);
150
- (0, $42858f023ef23dab$export$8e769ad4338a911e).required_state_set_[1](true);
225
+ }
151
226
  return (0, $TZSbU$createElement)((0, $TZSbU$Fragment), null, children);
152
227
  }
153
228
 
154
229
 
155
- // PoC maybe-component
156
- // Idea is to always give a nice "modal input in header" look with no more config than adding this component to the page header to where it can absolute-size
157
- // and cover the entire height of the header. Then we know where to put the modal input top and bottom, and the left and right we just center.
158
-
159
230
 
160
-
161
- function $f41a371216eff80b$export$cbcd1ecdb41b1d0a() {
162
- return (0, $TZSbU$createElement)("div", {
231
+ const $4db0e2f013fc5124$export$3f4580d6398c5027 = /*#__PURE__*/ (0, $TZSbU$forwardRef)((_, ref)=>{
232
+ return /*#__PURE__*/ (0, $TZSbU$createElement)("div", {
163
233
  className: "depict aligner",
164
- ref: (e)=>(0, $42858f023ef23dab$export$8e769ad4338a911e).header_alignment = e
165
- });
166
- }
167
- let $f41a371216eff80b$var$sheet;
168
- function $f41a371216eff80b$export$a7f6cffb6b8ba11c() {
169
- if (!(0, $42858f023ef23dab$export$8e769ad4338a911e).search) {
170
- console.error("No active search in the app!");
171
- return;
172
- }
173
- if (!(0, $42858f023ef23dab$export$8e769ad4338a911e).header_alignment) {
174
- console.error("No active search header aligner on the page!");
175
- return;
176
- }
177
- const style_props_ = (0, $TZSbU$createSignal)({
178
- position: "fixed",
179
- top: 0
234
+ style: {
235
+ height: "100%"
236
+ },
237
+ ref: ref
180
238
  });
181
- if ((0, $42858f023ef23dab$export$8e769ad4338a911e).header_alignment?.clientHeight) {
182
- let styles = `.depict.plp.in-header .depict-search-modal .query-input { height: ${(0, $42858f023ef23dab$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
183
- styles += `.depict.plp.in-header .depict-search-modal-backdrop { top: ${(0, $42858f023ef23dab$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
184
- if (!$f41a371216eff80b$var$sheet) {
185
- const style = document.createElement("style");
186
- style.append(styles);
187
- document.head.appendChild(style);
188
- }
189
- }
190
- const class_list_ = (0, $TZSbU$createMemo)(()=>({
191
- "in-header": true
192
- }));
193
- (0, $42858f023ef23dab$export$8e769ad4338a911e).search.modal_open = [
194
- {
195
- style_props_: style_props_,
196
- class_list_: class_list_
197
- }
198
- ];
199
- }
200
-
201
-
239
+ });
202
240
 
203
241
 
204
242
 
205
243
 
206
244
 
207
245
 
208
- function $9f8d5ef3c016c493$export$210723f5a54a7028(opts) {
209
- return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)($9f8d5ef3c016c493$var$SolidSearchPage), opts);
246
+ function $4a678f0c87b12e78$export$210723f5a54a7028(props) {
247
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)($4a678f0c87b12e78$var$SolidSearchPage), props);
210
248
  }
211
- function $9f8d5ef3c016c493$var$SolidSearchPage(props, set_portals) {
249
+ function $4a678f0c87b12e78$var$SolidSearchPage(props, set_portals) {
212
250
  const depict_search = (0, $42858f023ef23dab$export$8e769ad4338a911e).search;
213
- if (!depict_search) throw Error("No depict_search instance when rendering SearchPage.");
251
+ if (!depict_search) throw Error("No depict_search instance when rendering SearchPage. Did you forget to wrap your app in DepictProvider?");
214
252
  const search_query_updating_blocked_signal = (0, $TZSbU$get_search_query_updating_blocked_signal)(depict_search);
215
253
  if (!search_query_updating_blocked_signal) throw Error("No search_query_updating_blocked_signal when rendering SearchPage");
216
254
  const [, set_search_query_updating_blocked_signal] = search_query_updating_blocked_signal;
217
255
  const update_updating_blocked_signal = ()=>{
218
- set_search_query_updating_blocked_signal(!(0, $c83ba9ab79386687$export$6cb4d3a5c1ac9b43)(location));
256
+ set_search_query_updating_blocked_signal(!(0, $c83ba9ab79386687$export$775e6b3892b5ad52)(location));
219
257
  };
220
258
  // react is really slow with disposing components, we want to avoid a flash of another search query when you click on a product and navigate away
221
259
  (0, $c83ba9ab79386687$export$74f3924c5027fe1d)(update_updating_blocked_signal); // if we navigate, re-check
@@ -244,42 +282,229 @@ function $9f8d5ef3c016c493$var$SolidSearchPage(props, set_portals) {
244
282
  // Todo: Do we need this?
245
283
  get_product_id: ()=>"",
246
284
  depict_search: depict_search,
247
- product_card_template: async (display, info)=>{
248
- const solid_container = document.createElement("div");
249
- const react_has_rendered = new Promise((r)=>{
250
- const m_o = new MutationObserver(()=>{
251
- m_o.disconnect();
252
- r();
253
- });
254
- m_o.observe(solid_container, {
255
- childList: true
256
- });
257
- });
258
- const is_placeholder = info.rendering_options.type === "placeholder";
259
- const reactProductCard = (0, $TZSbU$jsx)(props.productCard, {
260
- display: is_placeholder ? null : display
261
- });
262
- const portal = $TZSbU$createPortal(reactProductCard, solid_container);
263
- component_portals.add(portal);
264
- set_portals([
265
- ...component_portals
266
- ]);
267
- (0, $TZSbU$onCleanup)(()=>{
268
- // 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
269
- component_portals.delete(portal);
270
- set_portals([
271
- ...component_portals
272
- ]);
273
- });
274
- await react_has_rendered; // wait for react to have finish portaling the elements so that the placeholders get removed once we have an actual result and so that the PLP code knows it has a placeholder when this is a placeholder rendering
275
- return [
276
- solid_container
277
- ];
285
+ product_card_template: (display, info)=>(0, $c83ba9ab79386687$export$79c79419c1ef0081)({
286
+ display: display,
287
+ info: info,
288
+ react_template: props.productCard,
289
+ component_portals: component_portals,
290
+ set_portals: set_portals
291
+ })
292
+ });
293
+ }
294
+
295
+
296
+
297
+
298
+
299
+
300
+ let $48d7f568740a317d$var$render_cb;
301
+ function $48d7f568740a317d$export$d87c61cecb2edf0d(props) {
302
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)($48d7f568740a317d$var$SolidCategoryPage), props, "div", {}, (props)=>$48d7f568740a317d$var$render_cb?.(props));
303
+ }
304
+ function $48d7f568740a317d$var$SolidCategoryPage(props, set_portals) {
305
+ const depict_category = (0, $42858f023ef23dab$export$8e769ad4338a911e).category;
306
+ if (!depict_category) throw Error("No depict_category instance when rendering SearchPage. Did you forget to wrap your app in DepictProvider?");
307
+ const [category_state_set, set_category_state_set] = (0, $TZSbU$createSignal)(false);
308
+ $48d7f568740a317d$var$render_cb = (props)=>{
309
+ depict_category.category_id = props.categoryId;
310
+ (0, $42858f023ef23dab$export$8e769ad4338a911e).category_path = location.pathname;
311
+ if (props.categoryId) set_category_state_set(true);
312
+ };
313
+ $48d7f568740a317d$var$render_cb(props);
314
+ const component_portals = new Set();
315
+ const category = ()=>(0, $TZSbU$CategoryPage)({
316
+ depict_category: depict_category,
317
+ cols_at_size: props.columnsAtSize ?? [
318
+ [
319
+ 4
320
+ ],
321
+ [
322
+ 3,
323
+ 1024
324
+ ],
325
+ [
326
+ 2,
327
+ 901
328
+ ]
329
+ ],
330
+ grid_spacing: props.gridSpacing ?? "2%",
331
+ get_product_id: ()=>"",
332
+ category_title: props.categoryTitlePlugin || (0, $43099132aad1ceb6$re_export$CategoryTitle),
333
+ show_breadcrumbs: props.showBreadcrumbs === undefined ? true : props.showBreadcrumbs,
334
+ show_quicklinks: props.showQuicklinks === undefined ? true : props.showQuicklinks,
335
+ product_card_template: (display, info)=>(0, $c83ba9ab79386687$export$79c79419c1ef0081)({
336
+ display: display,
337
+ info: info,
338
+ react_template: props.productCard,
339
+ component_portals: component_portals,
340
+ set_portals: set_portals
341
+ })
342
+ });
343
+ return (0, $c83ba9ab79386687$export$e5139bbbb9a05035)(category, category_state_set);
344
+ }
345
+
346
+
347
+
348
+
349
+
350
+ function $f866f7ed9f751af4$export$5646050d516e06bc() {
351
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)($f866f7ed9f751af4$var$vanilla_breadcrumbs), {});
352
+ }
353
+ function $f866f7ed9f751af4$var$vanilla_breadcrumbs() {
354
+ const depict_category = (0, $42858f023ef23dab$export$8e769ad4338a911e).category;
355
+ if (!depict_category) throw Error("No depict_category instance when rendering BreadCrumbs. Did you forget to wrap your app in DepictProvider?");
356
+ return (0, $TZSbU$BreadCrumbs)({
357
+ depict_category: depict_category
358
+ });
359
+ }
360
+
361
+
362
+
363
+
364
+
365
+ function $b68a14248b7ef667$export$466cdc317043f6cb() {
366
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)((0, $c83ba9ab79386687$export$e5139bbbb9a05035)($b68a14248b7ef667$var$vanilla_quick_links), {});
367
+ }
368
+ function $b68a14248b7ef667$var$vanilla_quick_links() {
369
+ const depict_category = (0, $42858f023ef23dab$export$8e769ad4338a911e).category;
370
+ if (!depict_category) throw Error("No depict_category instance when rendering QuickLinks. Did you forget to wrap your app in DepictProvider?");
371
+ return (0, $TZSbU$QuickLinks)({
372
+ depict_category: depict_category
373
+ });
374
+ }
375
+
376
+
377
+
378
+
379
+ const $f446a84f85ba06f6$export$3f37af283f8fb843 = ({ aspectRatio: aspectRatio })=>{
380
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)(()=>(0, $TZSbU$ContainedPlaceholderImage)({
381
+ aspect_ratio: aspectRatio
382
+ }), {}, "div", {
383
+ "height": "100%"
384
+ });
385
+ };
386
+
387
+
388
+
389
+
390
+ const $cbd250061abf11cb$export$89c6019e4baa40b1 = ({ width: width , height: height })=>{
391
+ return (0, $c83ba9ab79386687$export$f6e64e17bd69eeef)(()=>(0, $TZSbU$Placeholder)({
392
+ width: width,
393
+ height: height
394
+ }), {}, "div", {
395
+ "height": "100%"
396
+ });
397
+ };
398
+
399
+
400
+
401
+
402
+
403
+
404
+
405
+
406
+ const $5e26376d86621891$export$d69d8daa20eae175 = (createOpenModalParams)=>{
407
+ const { globalState: globalState , location: location , alignerRef: alignerRef } = createOpenModalParams;
408
+ const openModal = ()=>{
409
+ const headerAligner = alignerRef?.current;
410
+ if (!globalState.search) throw new Error("No active search in the app!");
411
+ if (!headerAligner && location === "aligned") throw new Error("No active search header aligner on the page!");
412
+ const alignment_height = headerAligner?.clientHeight;
413
+ if (location !== "aligned" || isNaN(alignment_height)) {
414
+ // Open centered modal
415
+ globalState.search.modal_open = true;
416
+ return;
278
417
  }
418
+ const style_element = document.createElement("style");
419
+ document.head.append(style_element);
420
+ const resize_observer = new ResizeObserver((0, $TZSbU$catchify)(()=>{
421
+ const styles = (0, $TZSbU$styles_to_valid_css_string)({
422
+ ".depict.plp .depict-search-modal .query-input": {
423
+ "height": `${headerAligner?.clientHeight}px`
424
+ }
425
+ });
426
+ style_element.replaceChildren(styles);
427
+ }));
428
+ resize_observer.observe(headerAligner);
429
+ let dispose_aligner;
430
+ /**
431
+ * Setting position to fixed is important to make the modal work with align_field.
432
+ */ const style_props_ = (0, $TZSbU$createSignal)({
433
+ position: "fixed"
434
+ });
435
+ (0, $TZSbU$createRoot)((dispose)=>{
436
+ dispose_aligner = ()=>{
437
+ resize_observer.disconnect();
438
+ style_element.remove();
439
+ dispose();
440
+ };
441
+ (0, $TZSbU$align_field)(style_props_, headerAligner, undefined, false, "top");
442
+ });
443
+ globalState.search.modal_open = [
444
+ {
445
+ style_props_: style_props_
446
+ },
447
+ dispose_aligner
448
+ ];
449
+ };
450
+ return openModal;
451
+ };
452
+
453
+
454
+ function $cfa72c75e6cf6901$export$cc1e9aaf280afdcb(params) {
455
+ const open = (0, $5e26376d86621891$export$d69d8daa20eae175)({
456
+ globalState: $42858f023ef23dab$export$8e769ad4338a911e,
457
+ ...params
279
458
  });
459
+ return {
460
+ open: open
461
+ };
280
462
  }
281
463
 
282
464
 
283
465
 
284
466
 
285
- export {$54b0d21b77e719c4$export$d2c02478244f91f7 as DepictSearchField, $faf794495ff8b304$export$9fac37a9c21c2f3b as DepictProvider, $f41a371216eff80b$export$a7f6cffb6b8ba11c as openModal, $f41a371216eff80b$export$cbcd1ecdb41b1d0a as DepictSearchHeader, $9f8d5ef3c016c493$export$210723f5a54a7028 as DepictSearchPage};
467
+
468
+ const $c9c4d066f9a5b51b$export$83d89fbfd8236492 = "0.0.59";
469
+
470
+
471
+
472
+
473
+ const $a92aa2beb560b8af$export$804fac5697cfbe35 = (router)=>(href)=>{
474
+ const shallow = (0, $c83ba9ab79386687$export$92a8f8b3c630fa0d)(location);
475
+ router.push(href, undefined, {
476
+ shallow: shallow,
477
+ scroll: true
478
+ });
479
+ };
480
+
481
+
482
+ /**
483
+ * Helper function that creates a function that can be used as the
484
+ * navigateFunction callback for DepictProvider when using react-router.
485
+ *
486
+ * React-router expect relative URLs, so this function will strip the
487
+ * protocol, hostname and port from the URL.
488
+ *
489
+ * @param navigateFunction what useNavigate() returns
490
+ * @returns a function that can be used as the navigateFunction callback for DepictProvider
491
+ */ const $01e1970add53d62a$export$d53481656a62aebe = (navigateFunction)=>(href)=>{
492
+ const url_object = new URL(href);
493
+ return navigateFunction(url_object.pathname + url_object.search + url_object.hash);
494
+ };
495
+
496
+
497
+ const $97603d19204ec48d$export$b8a61e5c71402559 = {
498
+ nextRouterNavigation: $a92aa2beb560b8af$export$804fac5697cfbe35,
499
+ reactRouterNavigation: $01e1970add53d62a$export$d53481656a62aebe
500
+ };
501
+
502
+
503
+ const $43099132aad1ceb6$var$package_name = "@depict-ai/react-ui";
504
+ (0, $TZSbU$dlog)($43099132aad1ceb6$var$package_name + " version", (0, $c9c4d066f9a5b51b$export$83d89fbfd8236492));
505
+ (0, $TZSbU$add_to_version_info)({
506
+ [$43099132aad1ceb6$var$package_name]: (0, $c9c4d066f9a5b51b$export$83d89fbfd8236492)
507
+ });
508
+
509
+
510
+ export {$b68a14248b7ef667$export$466cdc317043f6cb as QuickLinks, $f866f7ed9f751af4$export$5646050d516e06bc as BreadCrumbs, $4db0e2f013fc5124$export$3f4580d6398c5027 as DepictAligner, $5376eb2a386cd90d$export$9fac37a9c21c2f3b as DepictProvider, $48d7f568740a317d$export$d87c61cecb2edf0d as DepictCategoryPage, $4a678f0c87b12e78$export$210723f5a54a7028 as DepictSearchPage, $02e2452814b6e7d6$export$4c0fa313cf50c4ad as DepictSearchField, $f446a84f85ba06f6$export$3f37af283f8fb843 as ImagePlaceholder, $cbd250061abf11cb$export$89c6019e4baa40b1 as TextPlaceholder, $cfa72c75e6cf6901$export$cc1e9aaf280afdcb as useDepictSearchModal, $43099132aad1ceb6$re_export$CategoryTitle as CategoryTitle, $43099132aad1ceb6$re_export$EmbeddedNumProducts as EmbeddedNumProducts, $c9c4d066f9a5b51b$export$83d89fbfd8236492 as version, $97603d19204ec48d$export$b8a61e5c71402559 as Navigation};