@depict-ai/ui 4.8.8 → 4.8.10

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.
@@ -1,7 +1,7 @@
1
1
  import { Accessor, JSX, Setter, Signal } from "solid-js";
2
2
  import { Display, ModernDisplay, report, Amazing_Slider, useExpandingContainer, ColsAtSize, Elem, Node_Array } from "@depict-ai/utilishared/latest";
3
3
  import { ContentLink, SearchResponse, SearchFilter as _SearchFilter1 } from "@depict-ai/types/api/SearchResponse";
4
- import { Ancestors, ListingSuggestion, SearchSuggestionsResponseV3 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
4
+ import { Ancestors, ListingSuggestion, SearchSuggestionsResponseV3, ProductListing as _ProductListing1 } from "@depict-ai/types/api/SearchSuggestionsResponseV3";
5
5
  import { ProductListing, GetListingResponse, ContentBlock as _ContentBlock1 } from "@depict-ai/types/api/GetListingResponse";
6
6
  import { SearchFilter, SearchRequestV3, SortModel } from "@depict-ai/types/api/SearchRequestV3";
7
7
  import { ProductListingResponseV3, SearchFilter as _SearchFilter2 } from "@depict-ai/types/api/ProductListingResponseV3";
@@ -11,7 +11,7 @@ import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
13
13
  import { SearchFilter as _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
14
- export const version = "4.8.8";
14
+ export const version = "4.8.10";
15
15
  /**
16
16
  * Returns two accessors (one width and one height) that will update when the size of the provided element changes, to be used with ResponsiveImg
17
17
  */
@@ -46,6 +46,10 @@ type ListingSuggestionForTransformer = (ListingSuggestion & {
46
46
  export type DisplayTransformers<InputDisplay extends ModernDisplay, OutputDisplay extends ModernDisplay | never> = {
47
47
  products?: (options: DisplayTransformerAlwaysThereData & {
48
48
  displays: InputDisplay[];
49
+ /**
50
+ * If the category display transformer was called due to navigating to a listing using a <CategoryPage> component, currentListing will be set and contain a promise that can be used to get information of said listing.
51
+ */
52
+ currentListing?: Promise<ProductListing>;
49
53
  }) => CanBePromiseWrapped<OutputDisplay extends ModernDisplay ? ModernDisplayWithPageUrl<OutputDisplay>[] : never>;
50
54
  categories?: <T extends ProductListingWithAncestors | ListingSuggestionForTransformer>(options: DisplayTransformerAlwaysThereData & {
51
55
  data: T[];
@@ -551,10 +555,12 @@ export class DepictAPI<InputDisplay extends Display, OutputDisplay extends Moder
551
555
  get_listing_products({
552
556
  id_to_query_for_,
553
557
  id_type_,
558
+ currentListingForTransformer_,
554
559
  ...input_req_
555
560
  }: ProductListingRequestV3 & {
556
561
  id_to_query_for_: string;
557
562
  id_type_: typeof LISTING_ID | typeof EXTERNAL_ID;
563
+ currentListingForTransformer_: Promise<_ProductListing1>;
558
564
  }): Promise<ProductListingResponseAfterDisplayTransformer & {
559
565
  failed?: true;
560
566
  }>;
@@ -1506,7 +1512,7 @@ type OpenModalParams<OriginalDisplay extends Display, OutputDisplay extends Mode
1506
1512
  * Open the modal with support for alignment.
1507
1513
  * @returns {void}
1508
1514
  */
1509
- export const open_modal_with_alignment: <OriginalDisplay extends Display, OutputDisplay extends unknown>(openModalParams: OpenModalParams<OriginalDisplay, OutputDisplay>) => void;
1515
+ export const open_modal_with_alignment: <OriginalDisplay extends Display, OutputDisplay extends ModernDisplay>(openModalParams: OpenModalParams<OriginalDisplay, OutputDisplay>) => void;
1510
1516
  export function open_search_with_shift_slash(open_search: VoidFunction): () => void;
1511
1517
  export interface PageReplacer {
1512
1518
  readonly render_: () => Node_Array;
@@ -1585,5 +1591,5 @@ export function CategoryPage<OriginalDisplay extends Display, OutputDisplay exte
1585
1591
  content_blocks_by_row?: ContentBlocksByRow;
1586
1592
  layout?: PossibleLayout;
1587
1593
  filterModalParent_?: HTMLElement | ShadowRoot;
1588
- }): import("@depict-ai/utilishared").Node_Array;
1594
+ }): import("@depict-ai/utilishared/latest").Node_Array;
1589
1595
  export type { SearchFilter } from "@depict-ai/types/api/SearchRequestV3";
@@ -7,7 +7,7 @@ import { dlog as $i7OB2$dlog, catchify as $i7OB2$catchify1, ListenableSet as $i7
7
7
  /*! Depict.ai search and product listing SDK */
8
8
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
9
9
  register_es_version("ui", "latest");
10
- const $ec291e0010116877$export$83d89fbfd8236492 = "4.8.8";
10
+ const $ec291e0010116877$export$83d89fbfd8236492 = "4.8.10";
11
11
  function $a444a52bafa0dacc$export$54c6d6ff54e72743(whatToWatch) {
12
12
  const [width, setWidth] = $i7OB2$createSignal(0);
13
13
  const [height, setHeight] = $i7OB2$createSignal(0);
@@ -7496,7 +7496,7 @@ function $5efb5894079b220e$export$b288c38ae3fddb56({
7496
7496
  JSON.stringify(new_local_filter_state) !== JSON.stringify(read_local_cache())) {
7497
7497
  const owner = $i7OB2$getOwner();
7498
7498
  const signal = owner?.sources?.find?.(source => source.value === read_local_cache());
7499
- if (executions > 30) {
7499
+ if (executions > 50) {
7500
7500
  // We're probably in an infinite loop, let's just stop
7501
7501
  $i7OB2$report(new Error("Infinite loop detected in create_modified_filters"), "error", {
7502
7502
  executions: executions,
@@ -7943,7 +7943,7 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
7943
7943
  /**
7944
7944
  * rest = everything except query suggestions
7945
7945
  */
7946
- async #run_display_transformers_for_rest(merchant, market, locale, input_data) {
7946
+ async #run_display_transformers_for_rest(merchant, market, locale, input_data, currentListingForTransformer) {
7947
7947
  const {
7948
7948
  display_transformers: display_transformers
7949
7949
  } = this;
@@ -7959,7 +7959,8 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
7959
7959
  merchant: merchant,
7960
7960
  market: market,
7961
7961
  locale: locale,
7962
- displays: [...displays]
7962
+ displays: [...displays],
7963
+ currentListing: currentListingForTransformer
7963
7964
  });
7964
7965
  input_data.displays = transformed_displays;
7965
7966
  }
@@ -7982,7 +7983,8 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
7982
7983
  endpoint_: endpoint_,
7983
7984
  input_req_: input_req_,
7984
7985
  fallback_response_: fallback_response_,
7985
- method_ = "POST"
7986
+ method_ = "POST",
7987
+ currentListingForTransformer_: currentListingForTransformer_
7986
7988
  }) {
7987
7989
  const cache_obj = this.#get_cache_obj_for_endpoint(endpoint_);
7988
7990
  const with_ids = this.#add_ids_to_request(input_req_);
@@ -8012,7 +8014,7 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
8012
8014
  let result;
8013
8015
  try {
8014
8016
  const unmodified_result = await api_response.json();
8015
- result = await this.#run_display_transformers_for_rest(input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result);
8017
+ result = await this.#run_display_transformers_for_rest(input_req_.merchant, input_req_.market, input_req_.locale, unmodified_result, currentListingForTransformer_);
8016
8018
  } catch (e) {
8017
8019
  $i7OB2$dwarn("displayTransformer or json decoding failed", e);
8018
8020
  break return_successfully;
@@ -8114,11 +8116,13 @@ class $7fa23e2a0079eca4$export$e015ed2f2950f2e3 {
8114
8116
  async get_listing_products({
8115
8117
  id_to_query_for_: id_to_query_for_,
8116
8118
  id_type_: id_type_,
8119
+ currentListingForTransformer_: currentListingForTransformer_,
8117
8120
  ...input_req_
8118
8121
  }) {
8119
8122
  return await this.#cached_request({
8120
8123
  endpoint_: $7fa23e2a0079eca4$var$v3_base_url + "listings/" + (id_type_ === $c20599a0d81d953a$export$5aae649db1b959fc ? "external_id/" : "") + encodeURIComponent(id_to_query_for_) + "/products",
8121
8124
  input_req_: input_req_,
8125
+ currentListingForTransformer_: currentListingForTransformer_,
8122
8126
  fallback_response_: () => ({
8123
8127
  "n_hits": 0,
8124
8128
  "displays": [],
@@ -8842,10 +8846,12 @@ function $b6d5529b253681aa$export$b3ad617e9036868({
8842
8846
  const rect = input_field.getBoundingClientRect(); /* for some reason contentRect.top and contentRect.left is 0 from the RO */
8843
8847
  const addToLeftValue = alignment & $b6d5529b253681aa$export$6060bc6bee850eb6 ? rect.width / 2 : 0;
8844
8848
  const leftWithoutScroll = rect.left + addToLeftValue;
8849
+ const topValue = rect.top + (includeScroll ? scrollY : 0);
8845
8850
  setModalBodyStyle(old_value => ({
8846
8851
  ...old_value,
8852
+ // Do not allow top values under 0, this usually happens when aligning to an element that's absolutely positioned and the user is scrolled down - in that case we want to sacrifice alignment for the modal being visible
8847
8853
  ...(alignment & $b6d5529b253681aa$export$3f238c96c45e6cc6 ? {
8848
- top: `${rect.top + (includeScroll ? scrollY : 0)}px`
8854
+ top: `${topValue >= 0 ? topValue : 0}px`
8849
8855
  } : {}),
8850
8856
  ...(alignment & $b6d5529b253681aa$export$7895aadd1956b1c7 ? {
8851
8857
  left: `${leftWithoutScroll + (includeScroll ? scrollX : 0)}px`
@@ -12508,6 +12514,10 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
12508
12514
  const all_products_loaded_ = $i7OB2$createSignal(false);
12509
12515
  const [currentlyLoadedDisplays, setCurrentlyLoadedDisplays_] = $i7OB2$createSignal(0);
12510
12516
  const [can_write_scroll_restoration_, set_can_write_scroll_restoration] = $i7OB2$createSignal(false);
12517
+ const owner = $i7OB2$getOwner();
12518
+ const [metaRequestsForQuery, setMetaRequestsForQuery] = $i7OB2$createSignal(new Map(), {
12519
+ equals: false
12520
+ });
12511
12521
  const products_query_base_ = $587cd61972788655$export$210f130a61ac1e8d(() => {
12512
12522
  const sort_obj = get_sorting() && {
12513
12523
  ...get_sorting()
@@ -12540,7 +12550,20 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
12540
12550
  limit: limit,
12541
12551
  ...(cursor ? {
12542
12552
  cursor: cursor
12543
- } : {})
12553
+ } : {}),
12554
+ // This gets exposed to the products display transformer and gives it information about the listing the products are in
12555
+ // It's very hard to implement tracking that uses the collection title without this information
12556
+ currentListingForTransformer_: new Promise(resolve => $i7OB2$createRoot(dispose => {
12557
+ $i7OB2$createEffect($i7OB2$catchify1(() => {
12558
+ const key = base_query.id_type_ + base_query.id_to_query_for_;
12559
+ const metaResponsePromise = metaRequestsForQuery().get(key);
12560
+ if (!metaResponsePromise) return;
12561
+ resolve(metaResponsePromise);
12562
+ dispose();
12563
+ setMetaRequestsForQuery(prev => (prev.delete(key), prev));
12564
+ }));
12565
+ $i7OB2$runWithOwner(owner, () => $i7OB2$onCleanup(dispose));
12566
+ }))
12544
12567
  })
12545
12568
  })));
12546
12569
  const meta_query_base = $587cd61972788655$export$210f130a61ac1e8d(() => ({
@@ -12551,7 +12574,17 @@ function $df5d81d0fe61ff21$export$f7d2f673fc2f091d({
12551
12574
  id_type_: id_type_()
12552
12575
  }));
12553
12576
  // Make "Get Listing" request to get quicklinks, breadcrumbs, title, etc
12554
- const [plp_meta] = $i7OB2$createResource(meta_query_base, $i7OB2$catchify1(query => depict_api_.get_listing(query)));
12577
+ const [plp_meta] = $i7OB2$createResource(meta_query_base, $i7OB2$catchify1(async query => {
12578
+ const result = await depict_api_.get_listing(query);
12579
+ // In the following two lines, do not expose the finished breadcrumbs and quicklinks in the products display transformer since it's already exposed in the categories display transformer
12580
+ const {
12581
+ breadcrumbs: breadcrumbs,
12582
+ quick_links: quick_links,
12583
+ ...listing
12584
+ } = result;
12585
+ setMetaRequestsForQuery(prev => prev.set(query.id_type_ + query.id_to_query_for_, listing));
12586
+ return result;
12587
+ }));
12555
12588
  const contentBlocksByRow = $486360b09f0d5729$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_);
12556
12589
  const countOfProductsForUI = $3ef0154d1cf118ed$export$a86bc18439445599(plp_products_, all_products_loaded_, currentlyLoadedDisplays);
12557
12590
  const available_sortings_ = $i7OB2$createMemo(() => plp_products_()?.sorts?.map(sort => ({