@depict-ai/ui 0.0.78 → 0.0.79

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/dist/index.d.ts CHANGED
@@ -7,7 +7,7 @@ import { SearchSuggestionsResponse, CategorySuggestion } from "@depict-ai/types/
7
7
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
8
8
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
9
9
  import { ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
10
- export const version = "0.0.78";
10
+ export const version = "0.0.79";
11
11
  export type OnNavigation = ((options: {
12
12
  is_replace: boolean;
13
13
  new_url: URL;
package/dist/main.js CHANGED
@@ -35,7 +35,7 @@ $parcel$export(module.exports, "solid_format_price", () => $5fc9fc23df1591db$exp
35
35
  $parcel$export(module.exports, "connect_search_field_height_to_aligner_height", () => $246e3e89a097f014$export$828dcdd425fd3231);
36
36
  $parcel$export(module.exports, "PageReplacer", () => $37e96a5ebc768cc7$export$3ccaa27d81dd8556);
37
37
  $parcel$export(module.exports, "version", () => $ae93561d5649a847$export$83d89fbfd8236492);
38
- /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.78";
38
+ /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.79";
39
39
 
40
40
 
41
41
 
@@ -4298,7 +4298,7 @@ const $c6a04c153e9853a7$export$e2cf3f19dd3f8aac = "went_sideways_clear_filters";
4298
4298
  function $c6a04c153e9853a7$export$43cd1e747fecd42e(to_url, set_clearing_flag, from_search_params = new URLSearchParams(location.search)) {
4299
4299
  if (!to_url) return to_url;
4300
4300
  const was_url_object = to_url instanceof URL;
4301
- const url_object = was_url_object ? to_url : new URL(to_url);
4301
+ const url_object = was_url_object ? to_url : new URL(to_url, location.origin);
4302
4302
  const { searchParams: searchParams } = url_object;
4303
4303
  if (set_clearing_flag) searchParams.set($c6a04c153e9853a7$export$e2cf3f19dd3f8aac, "true");
4304
4304
  if (from_search_params.has($c6a04c153e9853a7$var$sorting_query_param)) searchParams.set($c6a04c153e9853a7$var$sorting_query_param, from_search_params.get($c6a04c153e9853a7$var$sorting_query_param));
@@ -5327,6 +5327,7 @@ class $43940d5ca403c293$export$7e1297a3a19f10d8 {
5327
5327
  * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
5328
5328
  * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
5329
5329
  * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
5330
+ * @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
5330
5331
  */ go_to_: async ({ new_url_: new_url_ , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
5331
5332
  const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
5332
5333
  if (this.#dont_attempt_navigation(event_)) return;
@@ -5340,11 +5341,12 @@ class $43940d5ca403c293$export$7e1297a3a19f10d8 {
5340
5341
  if (force_spa_navigation_ && wants_hard_navigation) {
5341
5342
  // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
5342
5343
  const new_state = history.state;
5343
- if (category_query_id_) new_state.category_current_query_id = category_query_id_;
5344
+ if (category_query_id_) // In JS-UI we need to know the query_id of the current category, therefore push it into state
5345
+ new_state.category_current_query_id = category_query_id_;
5344
5346
  history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
5345
5347
  } else this.#throwing_on_navigation.call(this, {
5346
5348
  is_replace: is_replace_,
5347
- new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_)
5349
+ new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin)
5348
5350
  });
5349
5351
  await promise;
5350
5352
  }
@@ -6217,8 +6219,10 @@ function $690220645373c65e$export$2542ffb77b620b02(params_to_default_value) {
6217
6219
 
6218
6220
 
6219
6221
 
6222
+
6223
+
6220
6224
  const $1bf0125991f2d39b$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<span class="orig price"></span>`, 2), $1bf0125991f2d39b$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span></div><div class="price-container"><span class="price"></span></div></div></a>`, 16), $1bf0125991f2d39b$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="tagline"></div>`, 2);
6221
- const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n , market: market })=>{
6225
+ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n , market: market }, router_)=>{
6222
6226
  const display = (0, $46MJV$solidjs.createMemo)(()=>{
6223
6227
  const display = display_or_variant_container();
6224
6228
  // Support for backend's new display format
@@ -6230,11 +6234,6 @@ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container,
6230
6234
  };
6231
6235
  }
6232
6236
  if (display.page_url) return display;
6233
- // Support for post-migration (but still old basic format) Stronger displays, with slug but without page_url
6234
- if (display.slug) {
6235
- display.page_url = `/${market}/` + display.slug;
6236
- return display;
6237
- }
6238
6237
  // Support for Spendrups displays, used by our frontend script and Spendrups coming react-ui integration.
6239
6238
  if (!display?.variants?.length) return;
6240
6239
  return display.variants.filter((v)=>v.product_id == display.product_id)[0];
@@ -6252,8 +6251,14 @@ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container,
6252
6251
  init_with_placeholder: true
6253
6252
  }));
6254
6253
  const is_sale = (0, $46MJV$solidjs.createMemo)(()=>display().sale_price !== display().original_price);
6254
+ const href = (0, $46MJV$solidjs.createMemo)(()=>display().page_url);
6255
6255
  const returnVal = (()=>{
6256
6256
  const _el$ = $1bf0125991f2d39b$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$4.nextSibling, _el$9 = _el$7.firstChild;
6257
+ (0, $46MJV$solidjsweb.addEventListener)(_el$, "click", (0, $46MJV$depictaiutilishared.catchify)((event_)=>router_.navigate_.go_to_({
6258
+ new_url_: href(),
6259
+ is_replace_: false,
6260
+ event_: event_
6261
+ })), true);
6257
6262
  (0, $46MJV$solidjsweb.insert)(_el$2, contained_image);
6258
6263
  (0, $46MJV$solidjsweb.insert)(_el$5, ()=>display().brand);
6259
6264
  (0, $46MJV$solidjsweb.insert)(_el$6, ()=>display().title);
@@ -6290,7 +6295,7 @@ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container,
6290
6295
  }), null);
6291
6296
  (0, $46MJV$solidjsweb.insert)(_el$9, ()=>i18n.price_formatting_().post_, null);
6292
6297
  (0, $46MJV$solidjsweb.effect)((_p$)=>{
6293
- const _v$ = display().page_url, _v$2 = !!is_sale();
6298
+ const _v$ = href(), _v$2 = !!is_sale();
6294
6299
  _v$ !== _p$._v$ && (0, $46MJV$solidjsweb.setAttribute)(_el$, "href", _p$._v$ = _v$);
6295
6300
  _v$2 !== _p$._v$2 && _el$9.classList.toggle("sales-price", _p$._v$2 = _v$2);
6296
6301
  return _p$;
@@ -6303,10 +6308,13 @@ const $1bf0125991f2d39b$export$b05c0ae390cf3e06 = (display_or_variant_container,
6303
6308
  // This solves a JSX type issue where the return value does not match with the explicit JSX.Element type for some reason
6304
6309
  return returnVal;
6305
6310
  };
6311
+ (0, $46MJV$solidjsweb.delegateEvents)([
6312
+ "click"
6313
+ ]);
6306
6314
 
6307
6315
 
6308
6316
  const $4cadf33fd6aaf4b6$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="instant-results"></div>`, 2);
6309
- function $4cadf33fd6aaf4b6$export$62f101a8aa597bf8({ depict_api_: depict_api_ , search_field_value_: [get_search_field_value] , tenant_: tenant_ , market_: market_ , render_instant_card_: render_instant_card_ , render_instant_card_placeholder_: render_instant_card_placeholder_ , min_products_to_fetch_: min_products_to_fetch_ , has_sort_or_filters_: has_sort_or_filters_ , set_num_results_accessor_: set_num_results_accessor_ , i18n_: i18n_ }) {
6317
+ function $4cadf33fd6aaf4b6$export$62f101a8aa597bf8({ depict_api_: depict_api_ , search_field_value_: [get_search_field_value] , tenant_: tenant_ , market_: market_ , render_instant_card_: render_instant_card_ , render_instant_card_placeholder_: render_instant_card_placeholder_ , min_products_to_fetch_: min_products_to_fetch_ , has_sort_or_filters_: has_sort_or_filters_ , set_num_results_accessor_: set_num_results_accessor_ , i18n_: i18n_ , router_: router_ }) {
6310
6318
  const max_cards = 4;
6311
6319
  const [read_current_instant_query, write_current_instant_query] = (0, $46MJV$solidjs.createSignal)("");
6312
6320
  let timeout;
@@ -6364,7 +6372,7 @@ function $4cadf33fd6aaf4b6$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6364
6372
  i18n: i18n_,
6365
6373
  merchant: tenant_(),
6366
6374
  market: market_()
6367
- }), tenant_, market_)
6375
+ }, router_), tenant_, market_)
6368
6376
  });
6369
6377
  }
6370
6378
  }));
@@ -7317,6 +7325,7 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_
7317
7325
  i18n_: i18n_,
7318
7326
  market_: market_,
7319
7327
  set_num_results_accessor_: set_num_results_accessor_,
7328
+ router_: router_,
7320
7329
  ...instant_results_options_
7321
7330
  });
7322
7331
  }
package/dist/module.js CHANGED
@@ -3,7 +3,7 @@ import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$e
3
3
  import {createSignal as $g9l4l$createSignal, onCleanup as $g9l4l$onCleanup, createComputed as $g9l4l$createComputed, createEffect as $g9l4l$createEffect, untrack as $g9l4l$untrack, batch as $g9l4l$batch, createResource as $g9l4l$createResource, createMemo as $g9l4l$createMemo, Show as $g9l4l$Show, createRenderEffect as $g9l4l$createRenderEffect, runWithOwner as $g9l4l$runWithOwner, createRoot as $g9l4l$createRoot, getOwner as $g9l4l$getOwner, createReaction as $g9l4l$createReaction, on as $g9l4l$on, ErrorBoundary as $g9l4l$ErrorBoundary, Index as $g9l4l$Index, For as $g9l4l$For} from "solid-js";
4
4
  import {compressToBase64 as $g9l4l$compressToBase64, decompressFromBase64 as $g9l4l$decompressFromBase64} from "lz-string";
5
5
 
6
- /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.78";
6
+ /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.79";
7
7
 
8
8
 
9
9
 
@@ -4266,7 +4266,7 @@ const $73294c7089bfc7c9$export$e2cf3f19dd3f8aac = "went_sideways_clear_filters";
4266
4266
  function $73294c7089bfc7c9$export$43cd1e747fecd42e(to_url, set_clearing_flag, from_search_params = new URLSearchParams(location.search)) {
4267
4267
  if (!to_url) return to_url;
4268
4268
  const was_url_object = to_url instanceof URL;
4269
- const url_object = was_url_object ? to_url : new URL(to_url);
4269
+ const url_object = was_url_object ? to_url : new URL(to_url, location.origin);
4270
4270
  const { searchParams: searchParams } = url_object;
4271
4271
  if (set_clearing_flag) searchParams.set($73294c7089bfc7c9$export$e2cf3f19dd3f8aac, "true");
4272
4272
  if (from_search_params.has($73294c7089bfc7c9$var$sorting_query_param)) searchParams.set($73294c7089bfc7c9$var$sorting_query_param, from_search_params.get($73294c7089bfc7c9$var$sorting_query_param));
@@ -5295,6 +5295,7 @@ class $cfa2761d36e5714c$export$7e1297a3a19f10d8 {
5295
5295
  * @param event_ event if you have this in a click handler, will not do anything on cmd/ctrl or non-left click then
5296
5296
  * @param force_spa_navigation_ if you want to force SPA navigation even if on_navigation_ is set to "hard_navigation". You should only set this to true for inter-SDK-page navigations
5297
5297
  * @param is_replace_ if you want to replace the current URL in history instead of pushing a new one
5298
+ * @param category_query_id_ If you are navigating to a category and know the query_id of, please provide it. This is for making a better devEx in js-ui
5298
5299
  */ go_to_: async ({ new_url_: new_url_ , event_: event_ , force_spa_navigation_: force_spa_navigation_ , is_replace_: is_replace_ , category_query_id_: category_query_id_ })=>{
5299
5300
  const wants_hard_navigation = this.on_navigation_ === "hard_navigation";
5300
5301
  if (this.#dont_attempt_navigation(event_)) return;
@@ -5308,11 +5309,12 @@ class $cfa2761d36e5714c$export$7e1297a3a19f10d8 {
5308
5309
  if (force_spa_navigation_ && wants_hard_navigation) {
5309
5310
  // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
5310
5311
  const new_state = history.state;
5311
- if (category_query_id_) new_state.category_current_query_id = category_query_id_;
5312
+ if (category_query_id_) // In JS-UI we need to know the query_id of the current category, therefore push it into state
5313
+ new_state.category_current_query_id = category_query_id_;
5312
5314
  history[is_replace_ ? "replaceState" : "pushState"](new_state, "", new_url_);
5313
5315
  } else this.#throwing_on_navigation.call(this, {
5314
5316
  is_replace: is_replace_,
5315
- new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_)
5317
+ new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.origin)
5316
5318
  });
5317
5319
  await promise;
5318
5320
  }
@@ -6185,8 +6187,10 @@ function $4ad18a8b237ff7f6$export$2542ffb77b620b02(params_to_default_value) {
6185
6187
 
6186
6188
 
6187
6189
 
6190
+
6191
+
6188
6192
  const $d3c0043bb23a833f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<span class="orig price"></span>`, 2), $d3c0043bb23a833f$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<a class="instant-card"><div class="img-part"></div><div class="right-part"><div class="title-brand-tagline"><span class="brand"></span><span class="title"></span></div><div class="price-container"><span class="price"></span></div></div></a>`, 16), $d3c0043bb23a833f$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="tagline"></div>`, 2);
6189
- const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n , market: market })=>{
6193
+ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container, { i18n: i18n , market: market }, router_)=>{
6190
6194
  const display = (0, $g9l4l$createMemo)(()=>{
6191
6195
  const display = display_or_variant_container();
6192
6196
  // Support for backend's new display format
@@ -6198,11 +6202,6 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
6198
6202
  };
6199
6203
  }
6200
6204
  if (display.page_url) return display;
6201
- // Support for post-migration (but still old basic format) Stronger displays, with slug but without page_url
6202
- if (display.slug) {
6203
- display.page_url = `/${market}/` + display.slug;
6204
- return display;
6205
- }
6206
6205
  // Support for Spendrups displays, used by our frontend script and Spendrups coming react-ui integration.
6207
6206
  if (!display?.variants?.length) return;
6208
6207
  return display.variants.filter((v)=>v.product_id == display.product_id)[0];
@@ -6220,8 +6219,14 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
6220
6219
  init_with_placeholder: true
6221
6220
  }));
6222
6221
  const is_sale = (0, $g9l4l$createMemo)(()=>display().sale_price !== display().original_price);
6222
+ const href = (0, $g9l4l$createMemo)(()=>display().page_url);
6223
6223
  const returnVal = (()=>{
6224
6224
  const _el$ = $d3c0043bb23a833f$var$_tmpl$2.cloneNode(true), _el$2 = _el$.firstChild, _el$3 = _el$2.nextSibling, _el$4 = _el$3.firstChild, _el$5 = _el$4.firstChild, _el$6 = _el$5.nextSibling, _el$7 = _el$4.nextSibling, _el$9 = _el$7.firstChild;
6225
+ (0, $g9l4l$addEventListener)(_el$, "click", (0, $g9l4l$catchify)((event_)=>router_.navigate_.go_to_({
6226
+ new_url_: href(),
6227
+ is_replace_: false,
6228
+ event_: event_
6229
+ })), true);
6225
6230
  (0, $g9l4l$insert)(_el$2, contained_image);
6226
6231
  (0, $g9l4l$insert)(_el$5, ()=>display().brand);
6227
6232
  (0, $g9l4l$insert)(_el$6, ()=>display().title);
@@ -6258,7 +6263,7 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
6258
6263
  }), null);
6259
6264
  (0, $g9l4l$insert)(_el$9, ()=>i18n.price_formatting_().post_, null);
6260
6265
  (0, $g9l4l$effect)((_p$)=>{
6261
- const _v$ = display().page_url, _v$2 = !!is_sale();
6266
+ const _v$ = href(), _v$2 = !!is_sale();
6262
6267
  _v$ !== _p$._v$ && (0, $g9l4l$setAttribute)(_el$, "href", _p$._v$ = _v$);
6263
6268
  _v$2 !== _p$._v$2 && _el$9.classList.toggle("sales-price", _p$._v$2 = _v$2);
6264
6269
  return _p$;
@@ -6271,10 +6276,13 @@ const $d3c0043bb23a833f$export$b05c0ae390cf3e06 = (display_or_variant_container,
6271
6276
  // This solves a JSX type issue where the return value does not match with the explicit JSX.Element type for some reason
6272
6277
  return returnVal;
6273
6278
  };
6279
+ (0, $g9l4l$delegateEvents)([
6280
+ "click"
6281
+ ]);
6274
6282
 
6275
6283
 
6276
6284
  const $d811ce622b5b7626$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="instant-results"></div>`, 2);
6277
- function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ , search_field_value_: [get_search_field_value] , tenant_: tenant_ , market_: market_ , render_instant_card_: render_instant_card_ , render_instant_card_placeholder_: render_instant_card_placeholder_ , min_products_to_fetch_: min_products_to_fetch_ , has_sort_or_filters_: has_sort_or_filters_ , set_num_results_accessor_: set_num_results_accessor_ , i18n_: i18n_ }) {
6285
+ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ , search_field_value_: [get_search_field_value] , tenant_: tenant_ , market_: market_ , render_instant_card_: render_instant_card_ , render_instant_card_placeholder_: render_instant_card_placeholder_ , min_products_to_fetch_: min_products_to_fetch_ , has_sort_or_filters_: has_sort_or_filters_ , set_num_results_accessor_: set_num_results_accessor_ , i18n_: i18n_ , router_: router_ }) {
6278
6286
  const max_cards = 4;
6279
6287
  const [read_current_instant_query, write_current_instant_query] = (0, $g9l4l$createSignal)("");
6280
6288
  let timeout;
@@ -6332,7 +6340,7 @@ function $d811ce622b5b7626$export$62f101a8aa597bf8({ depict_api_: depict_api_ ,
6332
6340
  i18n: i18n_,
6333
6341
  merchant: tenant_(),
6334
6342
  market: market_()
6335
- }), tenant_, market_)
6343
+ }, router_), tenant_, market_)
6336
6344
  });
6337
6345
  }
6338
6346
  }));
@@ -7285,6 +7293,7 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_
7285
7293
  i18n_: i18n_,
7286
7294
  market_: market_,
7287
7295
  set_num_results_accessor_: set_num_results_accessor_,
7296
+ router_: router_,
7288
7297
  ...instant_results_options_
7289
7298
  });
7290
7299
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "0.0.78",
3
+ "version": "0.0.79",
4
4
  "description": "Base package containing the actual UI of Depict UI along with translations, with a not-simplified API. We recommend using @depict-ai/js-ui or @depict-ai/react-ui instead.",
5
5
  "packageManager": "yarn@3.2.2",
6
6
  "source": [
@@ -85,9 +85,9 @@
85
85
  "ts-jest": "^29.0.3"
86
86
  },
87
87
  "dependencies": {
88
- "@depict-ai/plp-styling": "^0.0.40",
89
- "@depict-ai/types": "^0.0.30",
90
- "@depict-ai/utilishared": "^0.0.82",
88
+ "@depict-ai/plp-styling": "^0.0.41",
89
+ "@depict-ai/types": "^0.0.31",
90
+ "@depict-ai/utilishared": "^0.0.83",
91
91
  "lz-string": "^1.4.4",
92
92
  "solid-js": "^1.6.2"
93
93
  },