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