@depict-ai/react-ui 0.0.9 → 0.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 (38) hide show
  1. package/dist/main.js +144 -118
  2. package/dist/module.js +141 -115
  3. package/dist/styles/components/PLP/Buttons.scss +124 -0
  4. package/dist/styles/components/PLP/MorphingSign.scss +31 -0
  5. package/dist/styles/components/PLP/PLPResults.scss +20 -0
  6. package/dist/styles/components/PLP/ProductListingPage.scss +142 -0
  7. package/dist/styles/components/PLP/ScrollStatus.scss +24 -0
  8. package/dist/styles/components/PLP/SelectedFilters.scss +74 -0
  9. package/dist/styles/components/PLP/SlidableItems.scss +99 -0
  10. package/dist/styles/components/PLP/SortAndFilter/FloatingButtons.scss +75 -0
  11. package/dist/styles/components/PLP/SortAndFilter/SortAndFilter.scss +728 -0
  12. package/dist/styles/components/PLP/SortAndFilter/SortAndFilterModal.scss +160 -0
  13. package/dist/styles/components/PLP/SortAndFilter/WhiteSortAndFilter.scss +148 -0
  14. package/dist/styles/components/PLP/Toast.scss +54 -0
  15. package/dist/styles/components/PLP/index.scss +45 -0
  16. package/dist/styles/components/category/BreadCrumbs.scss +23 -0
  17. package/dist/styles/components/category/CategoryTitle.scss +28 -0
  18. package/dist/styles/components/category/QuickLinks.scss +71 -0
  19. package/dist/styles/components/category/index.scss +23 -0
  20. package/dist/styles/components/search/Autocomplete.scss +117 -0
  21. package/dist/styles/components/search/CategorySuggestions.scss +74 -0
  22. package/dist/styles/components/search/InstantCard.scss +94 -0
  23. package/dist/styles/components/search/InstantResults.scss +10 -0
  24. package/dist/styles/components/search/PreviousSearches.scss +77 -0
  25. package/dist/styles/components/search/QueryInput.scss +167 -0
  26. package/dist/styles/components/search/SearchModal.scss +90 -0
  27. package/dist/styles/components/search/SearchRecommendations.scss +25 -0
  28. package/dist/styles/components/search/ShowingResultsFor.scss +10 -0
  29. package/dist/styles/components/search/index.scss +40 -0
  30. package/dist/styles/default.css +1 -0
  31. package/dist/styles/helpers/custom_input.scss +162 -0
  32. package/dist/styles/helpers/supports-hover.scss +5 -0
  33. package/dist/styles/helpers/utils.scss +82 -0
  34. package/dist/styles/variables.scss +10 -0
  35. package/dist-server/main.js +13 -13
  36. package/dist-server/module.js +10 -10
  37. package/package.json +10 -10
  38. package/dist/styling/default.css +0 -1
package/dist/main.js CHANGED
@@ -1,90 +1,103 @@
1
- var $lgFzj$reactdom = require("react-dom");
2
- var $lgFzj$depictaireactsolidbridge = require("@depict-ai/react-solid-bridge");
3
- var $lgFzj$react = require("react");
4
- var $lgFzj$depictaiui = require("@depict-ai/ui");
5
- var $lgFzj$reactjsxruntime = require("react/jsx-runtime");
6
- var $lgFzj$depictaiutilishared = require("@depict-ai/utilishared");
7
- var $lgFzj$solidjs = require("solid-js");
1
+ var $1pn1h$reactdom = require("react-dom");
2
+ var $1pn1h$depictaireactsolidbridge = require("@depict-ai/react-solid-bridge");
3
+ var $1pn1h$react = require("react");
4
+ var $1pn1h$depictaiui = require("@depict-ai/ui");
5
+ var $1pn1h$reactjsxruntime = require("react/jsx-runtime");
6
+ var $1pn1h$solidjs = require("solid-js");
7
+ var $1pn1h$depictaiutilishared = require("@depict-ai/utilishared");
8
8
 
9
9
  function $parcel$export(e, n, v, s) {
10
10
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
11
11
  }
12
12
 
13
- $parcel$export(module.exports, "DepictSearchPage", () => $6abe21f0d440de7c$export$210723f5a54a7028);
14
- $parcel$export(module.exports, "DepictProvider", () => $36997bef3cf034d6$export$9fac37a9c21c2f3b);
15
- $parcel$export(module.exports, "openModal", () => $74e00cdf1575ca1b$export$a7f6cffb6b8ba11c);
16
- $parcel$export(module.exports, "DepictSearchHeader", () => $74e00cdf1575ca1b$export$cbcd1ecdb41b1d0a);
13
+ $parcel$export(module.exports, "DepictSearchPage", () => $7c7f5a6b750dca70$export$210723f5a54a7028);
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
17
 
18
18
 
19
19
 
20
20
 
21
21
 
22
+ const $e589c49931886c97$export$8e769ad4338a911e = {
23
+ search: null,
24
+ header_alignment: null
25
+ };
26
+
27
+
28
+
22
29
 
23
- let $35c9ea6fbd139a83$var$set = false;
24
- function $35c9ea6fbd139a83$export$6453cbc34515a94d() {
25
- if ($35c9ea6fbd139a83$var$set) return; // Just being safe
26
- $35c9ea6fbd139a83$var$set = true;
30
+
31
+ function $b4d0d98857ed9934$export$5cae361ad82dce8b(value) {
32
+ const ref = (0, $1pn1h$react.useRef)();
33
+ (0, $1pn1h$react.useEffect)(()=>{
34
+ ref.current = value;
35
+ }, [
36
+ value
37
+ ]);
38
+ return ref.current;
39
+ }
40
+ let $b4d0d98857ed9934$var$run_on_href_change;
41
+ function $b4d0d98857ed9934$export$74f3924c5027fe1d(cb) {
42
+ $b4d0d98857ed9934$var$run_on_href_change = cb;
43
+ }
44
+ (async ()=>{
45
+ for await (const href of (0, $1pn1h$depictaiutilishared.href_change_ipns))$b4d0d98857ed9934$var$run_on_href_change?.(href);
46
+ })();
47
+
48
+
49
+
50
+
51
+
52
+ let $80a9072c96ebf849$var$set = false;
53
+ function $80a9072c96ebf849$export$6453cbc34515a94d(is_search_page) {
54
+ if ($80a9072c96ebf849$var$set) return; // Just being safe
55
+ $80a9072c96ebf849$var$set = true;
27
56
  let should_use_old_scroll = false;
28
57
  const old_scrollTo = window.scrollTo;
29
58
  window.scrollTo = (...args)=>{
30
- const is_next_scrolling_enabled = args?.[1] !== 0; // TODO: This is not working for me right now: process.env.__NEXT_SCROLL_RESTORATION
31
- if (should_use_old_scroll || is_next_scrolling_enabled) return Reflect.apply(old_scrollTo, window, args);
59
+ if (should_use_old_scroll || process.env.__NEXT_SCROLL_RESTORATION || !is_search_page(location)) return Reflect.apply(old_scrollTo, window, args);
32
60
  else should_use_old_scroll = true;
33
61
  };
34
- addEventListener("popstate", ()=>{
62
+ addEventListener("popstate", (e)=>{
63
+ if (!is_search_page(location)) {
64
+ $80a9072c96ebf849$var$removeLotsOfPadding(); // Just making sure
65
+ return;
66
+ }
35
67
  should_use_old_scroll = false;
36
- $35c9ea6fbd139a83$var$addLotsOfPadding();
37
- });
38
- (0, $lgFzj$depictaiutilishared.observer).onexists(".depict.plp .listing-page .cards > div > *", ()=>{
39
- $35c9ea6fbd139a83$var$removeLotsOfPadding();
68
+ $80a9072c96ebf849$var$addLotsOfPadding();
69
+ (0, $1pn1h$depictaiutilishared.observer).wait_for_element(".depict.plp .listing-page").then(()=>{
70
+ $80a9072c96ebf849$var$removeLotsOfPadding();
71
+ });
40
72
  });
41
- (0, $lgFzj$depictaiutilishared.history_replacer)(()=>{
42
- (0, $lgFzj$depictaiutilishared.queueMacroTask)(()=>{
43
- $35c9ea6fbd139a83$var$removeLotsOfPadding();
73
+ (0, $1pn1h$depictaiutilishared.history_replacer)(()=>{
74
+ (0, $1pn1h$depictaiutilishared.queueMacroTask)(()=>{
75
+ $80a9072c96ebf849$var$removeLotsOfPadding();
44
76
  });
45
77
  }, false);
46
78
  window?.next?.router?.events?.on("routeChangeStart", ()=>{
47
- $35c9ea6fbd139a83$var$addLotsOfPadding();
79
+ $80a9072c96ebf849$var$addLotsOfPadding();
48
80
  });
49
81
  }
50
- function $35c9ea6fbd139a83$var$addLotsOfPadding() {
82
+ function $80a9072c96ebf849$var$addLotsOfPadding() {
51
83
  document.body.style.paddingBottom = (history.state?.search_scroll_restoration_data?.[0]?.min_results_loaded || 150) * 500 + "px";
52
84
  }
53
- function $35c9ea6fbd139a83$var$removeLotsOfPadding() {
85
+ function $80a9072c96ebf849$var$removeLotsOfPadding() {
54
86
  document.body.style.paddingBottom = "";
55
87
  }
56
88
 
57
89
 
58
- const $eb4ef6a57c8b8ada$export$8e769ad4338a911e = {
59
- search: null,
60
- header_alignment: null
61
- };
62
-
63
-
64
-
65
-
66
- function $c23231ddd12eea0a$export$5cae361ad82dce8b(value) {
67
- const ref = (0, $lgFzj$react.useRef)();
68
- (0, $lgFzj$react.useEffect)(()=>{
69
- ref.current = value;
70
- }, [
71
- value
72
- ]);
73
- return ref.current;
74
- }
75
-
76
-
77
-
78
- const $ed09819de7bb86d1$export$99ae278b8f3607a0 = (opts)=>{
90
+ const $7b6eabbde6829606$export$99ae278b8f3607a0 = (opts)=>{
79
91
  const path = "/search";
80
92
  const param = "q";
81
93
  const is_page_ = (url)=>url.pathname == path;
82
- const search = new (0, $lgFzj$depictaiui.DepictSearch)({
94
+ const search = new (0, $1pn1h$depictaiui.DepictSearch)({
83
95
  search_query_url_param_name: param,
84
96
  merchant: opts.merchant,
85
97
  market: opts.market,
98
+ enable_category_suggestions: false,
86
99
  localization: {
87
- ...(0, $lgFzj$depictaiui.swedish_search_translation),
100
+ ...(0, $1pn1h$depictaiui.swedish_search_translation),
88
101
  price_formatting_: {
89
102
  pre_: "€ ",
90
103
  post_: "",
@@ -95,7 +108,6 @@ const $ed09819de7bb86d1$export$99ae278b8f3607a0 = (opts)=>{
95
108
  },
96
109
  on_navigation: (new_href)=>{
97
110
  const shallow = is_page_(location);
98
- debugger;
99
111
  window.next.router.push(new_href, undefined, {
100
112
  shallow: shallow,
101
113
  scroll: true
@@ -105,25 +117,19 @@ const $ed09819de7bb86d1$export$99ae278b8f3607a0 = (opts)=>{
105
117
  url.pathname = path;
106
118
  }
107
119
  });
120
+ (0, $80a9072c96ebf849$export$6453cbc34515a94d)(is_page_);
108
121
  return search;
109
122
  };
110
123
 
111
124
 
112
- function $36997bef3cf034d6$export$9fac37a9c21c2f3b(props) {
113
- const { children: children , merchant: merchant , market: market , search_page_path: search_page_path } = props;
114
- const previous_props = (0, $c23231ddd12eea0a$export$5cae361ad82dce8b)(props);
115
- if (!(0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).search) // Todo: use search_page_path for navigation
116
- (0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).search = (0, $ed09819de7bb86d1$export$99ae278b8f3607a0)({
117
- merchant: merchant,
118
- market: market
125
+ function $18b830ef84ac138a$export$9fac37a9c21c2f3b(props) {
126
+ const { children: children , search_page_path: search_page_path , ...assignable_options } = props;
127
+ const { search: search } = (0, $e589c49931886c97$export$8e769ad4338a911e);
128
+ if (!search) // Todo: use search_page_path for navigation
129
+ (0, $e589c49931886c97$export$8e769ad4338a911e).search = (0, $7b6eabbde6829606$export$99ae278b8f3607a0)({
130
+ ...assignable_options
119
131
  });
120
- else if (previous_props) {
121
- const { prev_merchant: prev_merchant , prev_market: prev_market , search_page_path: search_page_path1 } = previous_props;
122
- // Todo: here we can check if our search config changed and react to it.
123
- // Do we need to know if it changed specifically, or could we just always set the values regardless if they changed or not?
124
- // Should changing merchant log an error? Is it ever not a bug?
125
- }
126
- console.log("DepictProvider render", props, previous_props);
132
+ else Object.assign(search, assignable_options);
127
133
  return children;
128
134
  }
129
135
 
@@ -134,39 +140,39 @@ function $36997bef3cf034d6$export$9fac37a9c21c2f3b(props) {
134
140
 
135
141
 
136
142
 
137
- function $74e00cdf1575ca1b$export$cbcd1ecdb41b1d0a() {
138
- return (0, $lgFzj$react.createElement)("div", {
143
+ function $20bf907adee775ba$export$cbcd1ecdb41b1d0a() {
144
+ return (0, $1pn1h$react.createElement)("div", {
139
145
  className: "depict aligner",
140
- ref: (e)=>(0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).header_alignment = e
146
+ ref: (e)=>(0, $e589c49931886c97$export$8e769ad4338a911e).header_alignment = e
141
147
  });
142
148
  }
143
- let $74e00cdf1575ca1b$var$sheet;
144
- function $74e00cdf1575ca1b$export$a7f6cffb6b8ba11c() {
145
- if (!(0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).search) {
149
+ let $20bf907adee775ba$var$sheet;
150
+ function $20bf907adee775ba$export$a7f6cffb6b8ba11c() {
151
+ if (!(0, $e589c49931886c97$export$8e769ad4338a911e).search) {
146
152
  console.error("No active search in the app!");
147
153
  return;
148
154
  }
149
- if (!(0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).header_alignment) {
155
+ if (!(0, $e589c49931886c97$export$8e769ad4338a911e).header_alignment) {
150
156
  console.error("No active search header aligner on the page!");
151
157
  return;
152
158
  }
153
- const style_props_ = (0, $lgFzj$solidjs.createSignal)({
159
+ const style_props_ = (0, $1pn1h$solidjs.createSignal)({
154
160
  position: "fixed",
155
161
  top: 0
156
162
  });
157
- if ((0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).header_alignment?.clientHeight) {
158
- let styles = `.depict.plp.in_header .depict-search-modal .query_input { height: ${(0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
159
- styles += `.depict.plp.in_header .depict-search-modal-backdrop { top: ${(0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
160
- if (!$74e00cdf1575ca1b$var$sheet) {
163
+ if ((0, $e589c49931886c97$export$8e769ad4338a911e).header_alignment?.clientHeight) {
164
+ let styles = `.depict.plp.in_header .depict-search-modal .query_input { height: ${(0, $e589c49931886c97$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
165
+ styles += `.depict.plp.in_header .depict-search-modal-backdrop { top: ${(0, $e589c49931886c97$export$8e769ad4338a911e).header_alignment?.clientHeight}px; }`;
166
+ if (!$20bf907adee775ba$var$sheet) {
161
167
  const style = document.createElement("style");
162
168
  style.append(styles);
163
169
  document.head.appendChild(style);
164
170
  }
165
171
  }
166
- const class_list_ = (0, $lgFzj$solidjs.createMemo)(()=>({
172
+ const class_list_ = (0, $1pn1h$solidjs.createMemo)(()=>({
167
173
  in_header: true
168
174
  }));
169
- (0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).search.modal_open = [
175
+ (0, $e589c49931886c97$export$8e769ad4338a911e).search.modal_open = [
170
176
  {
171
177
  style_props_: style_props_,
172
178
  class_list_: class_list_
@@ -175,14 +181,13 @@ function $74e00cdf1575ca1b$export$a7f6cffb6b8ba11c() {
175
181
  }
176
182
 
177
183
 
178
- let $6abe21f0d440de7c$var$active_render_card;
179
- function $6abe21f0d440de7c$var$DepictSearchPageContent(opts) {
180
- (0, $35c9ea6fbd139a83$export$6453cbc34515a94d)();
181
- const [bridge, setBridge] = (0, $lgFzj$react.useState)(null);
182
- const [portals, set_portals] = (0, $lgFzj$react.useState)([]);
183
- (0, $lgFzj$react.useEffect)(()=>{
184
- const component_portals = [];
185
- $6abe21f0d440de7c$var$active_render_card = async (display)=>{
184
+ let $7c7f5a6b750dca70$var$active_render_card;
185
+ function $7c7f5a6b750dca70$var$DepictSearchPageContent(opts) {
186
+ const [bridge, setBridge] = (0, $1pn1h$react.useState)(null);
187
+ const [portals, set_portals] = (0, $1pn1h$react.useState)([]);
188
+ (0, $1pn1h$react.useEffect)(()=>{
189
+ const component_portals = new Set((0, $1pn1h$react.ReactPortal));
190
+ $7c7f5a6b750dca70$var$active_render_card = async (display)=>{
186
191
  const solid_container = document.createElement("div");
187
192
  const react_has_rendered = new Promise((r)=>{
188
193
  const m_o = new MutationObserver(()=>{
@@ -193,55 +198,76 @@ function $6abe21f0d440de7c$var$DepictSearchPageContent(opts) {
193
198
  childList: true
194
199
  });
195
200
  });
196
- const reactProductCard = (0, $lgFzj$reactjsxruntime.jsx)(opts.productCardFactory, {
201
+ const reactProductCard = (0, $1pn1h$reactjsxruntime.jsx)(opts.productCardFactory, {
197
202
  display: display
198
203
  });
199
- const portal = $lgFzj$reactdom.createPortal(reactProductCard, solid_container);
200
- component_portals.push(portal);
204
+ const portal = $1pn1h$reactdom.createPortal(reactProductCard, solid_container);
205
+ component_portals.add(portal);
201
206
  set_portals([
202
207
  ...component_portals
203
208
  ]);
209
+ (0, $1pn1h$solidjs.onCleanup)(()=>{
210
+ // 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
211
+ component_portals.delete(portal);
212
+ set_portals([
213
+ ...component_portals
214
+ ]);
215
+ });
204
216
  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
205
217
  return [
206
218
  solid_container
207
219
  ];
208
220
  };
209
- if (!(0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).search) throw Error("No search when rendering SearchPage??");
210
- const el = (0, $lgFzj$depictaiui.SearchPage)({
211
- depict_search: (0, $eb4ef6a57c8b8ada$export$8e769ad4338a911e).search,
212
- cols_at_size: [
213
- [
214
- 4
215
- ],
216
- [
217
- 3,
218
- 1024
219
- ],
220
- [
221
- 2,
222
- 901
223
- ]
224
- ],
225
- grid_spacing: "10px",
226
- product_card_template: (...args)=>$6abe21f0d440de7c$var$active_render_card(...args),
227
- // function might not exist yet,
228
- get_product_id: ()=>""
229
- });
230
- const solidBridge = (0, $lgFzj$reactjsxruntime.jsx)((0, $lgFzj$depictaireactsolidbridge.ReactToSolidBridge), {
231
- solidComponent: ()=>el,
221
+ if (!(0, $e589c49931886c97$export$8e769ad4338a911e).search) throw Error("No search when rendering SearchPage??");
222
+ const solidBridge = (0, $1pn1h$reactjsxruntime.jsx)((0, $1pn1h$depictaireactsolidbridge.ReactToSolidBridge), {
223
+ solidComponent: ()=>{
224
+ const [el, dispose] = (0, $1pn1h$solidjs.createRoot)((dispose)=>{
225
+ (0, $b4d0d98857ed9934$export$74f3924c5027fe1d)((href)=>{
226
+ // TODO: Will be user specified
227
+ if (!new URL(href).pathname.startsWith("/search")) dispose();
228
+ });
229
+ const el = (0, $1pn1h$depictaiui.SearchPage)({
230
+ depict_search: (0, $e589c49931886c97$export$8e769ad4338a911e).search,
231
+ include_input_field: true,
232
+ cols_at_size: [
233
+ [
234
+ 4
235
+ ],
236
+ [
237
+ 3,
238
+ 1024
239
+ ],
240
+ [
241
+ 2,
242
+ 901
243
+ ]
244
+ ],
245
+ grid_spacing: "10px",
246
+ product_card_template: (...args)=>$7c7f5a6b750dca70$var$active_render_card(...args),
247
+ // function might not exist yet,
248
+ get_product_id: ()=>""
249
+ });
250
+ return [
251
+ el,
252
+ dispose
253
+ ];
254
+ });
255
+ (0, $1pn1h$solidjs.onCleanup)(dispose);
256
+ return el;
257
+ },
232
258
  key: Math.random()
233
259
  });
234
260
  setBridge(solidBridge);
235
261
  }, []);
236
262
  console.log("Searchpage render", bridge, portals.length);
237
- return bridge ? (0, $lgFzj$react.createElement)("div", {}, [
263
+ return bridge ? (0, $1pn1h$react.createElement)("div", {}, [
238
264
  bridge,
239
265
  ...portals
240
266
  ]) : "";
241
267
  }
242
- function $6abe21f0d440de7c$export$210723f5a54a7028(opts) {
243
- return (0, $lgFzj$reactjsxruntime.jsx)((0, $lgFzj$depictaireactsolidbridge.ReactToSolidBridgeProvider), {
244
- children: (0, $lgFzj$reactjsxruntime.jsx)($6abe21f0d440de7c$var$DepictSearchPageContent, opts)
268
+ function $7c7f5a6b750dca70$export$210723f5a54a7028(opts) {
269
+ return (0, $1pn1h$reactjsxruntime.jsx)((0, $1pn1h$depictaireactsolidbridge.ReactToSolidBridgeProvider), {
270
+ children: (0, $1pn1h$reactjsxruntime.jsx)($7c7f5a6b750dca70$var$DepictSearchPageContent, opts)
245
271
  });
246
272
  }
247
273