@depict-ai/ui 0.0.67 → 0.0.68

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
@@ -1,5 +1,5 @@
1
- import { Display, Elem, ColsAtSize, InfoForProcessing, Node_Array, RR_PostProcessor, RR_PreProcessor } from "@depict-ai/utilishared";
2
- import { Accessor, JSX, Setter, Signal } from "solid-js";
1
+ import { JSX, Accessor, Setter, Signal } from "solid-js";
2
+ import { useExpandingContainer, Display, Elem, ColsAtSize, InfoForProcessing, Node_Array, RR_PostProcessor, RR_PreProcessor } from "@depict-ai/utilishared";
3
3
  import { search_i18n as _search_i18n1 } from "../../../locales";
4
4
  import { SearchResponse } from "@depict-ai/types/api/SearchResponse";
5
5
  import { SearchRequest, SearchFilter } from "@depict-ai/types/api/SearchRequest";
@@ -9,7 +9,17 @@ import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestions
9
9
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
10
10
  import { ProductListingResponse, BaseCategoryDisplay } from "@depict-ai/types/api/ProductListingResponse";
11
11
  import { JSX as _JSX1 } from "solid-js/types/jsx";
12
- export const version = "0.0.67";
12
+ export const version = "0.0.68";
13
+ /**
14
+ * Just like `useExpandingContainer` except that the children can be reactive solid-js signals, basically solid's JSX.Element instead of our JSX.Element
15
+ */
16
+ export function useExpandingContainerReactive(...params: Parameters<typeof useExpandingContainer>): {
17
+ collapse: (collapsing_delay?: any, time_to_collapse?: any) => Promise<Animation | undefined>;
18
+ expand: (expanding_delay?: any, time_to_expand?: any) => Promise<Animation | undefined>;
19
+ ExpandingContainer: ({ children }: {
20
+ children: JSX.Element | (() => JSX.Element);
21
+ }) => HTMLElement;
22
+ };
13
23
  type ExclusiveId = {
14
24
  categoryId: string;
15
25
  productId?: undefined;
@@ -322,6 +332,7 @@ type OpenModalArguments = [
322
332
  closing_animation_?: () => Promise<any>;
323
333
  class_list_?: Accessor<Record<string, boolean>>;
324
334
  selected_text_range_?: readonly [number | null, number | null] | [number | null, number | null];
335
+ dont_sync_search_field_value_except_on_submit_?: boolean;
325
336
  },
326
337
  on_dispose?: VoidFunction
327
338
  ];
@@ -463,6 +474,10 @@ type AlignedLocation = {
463
474
  type ModalLocation = AlignedLocation | CenteredLocation;
464
475
  type OpenModalParams<T extends Display> = ModalLocation & {
465
476
  search: DepictSearch<T>;
477
+ /**
478
+ * If true, the search field in the modal opened will be empty and de-coupled from the other SearchFields.
479
+ */
480
+ makesNewSearch?: boolean;
466
481
  };
467
482
  /**
468
483
  * Open the modal with support for alignment.
package/dist/main.js CHANGED
@@ -6,6 +6,7 @@ function $parcel$export(e, n, v, s) {
6
6
  Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
7
  }
8
8
 
9
+ $parcel$export(module.exports, "useExpandingContainerReactive", () => $404797169c268f7a$export$5bad61ecde080b1f);
9
10
  $parcel$export(module.exports, "fetchDepictRecommendations", () => $8c4e48a4bf96b284$export$58e808b1db15d3bc);
10
11
  $parcel$export(module.exports, "QuickLinks", () => $068a627cc18f7bb6$export$de035477d6fef996);
11
12
  $parcel$export(module.exports, "BreadCrumbs", () => $068a627cc18f7bb6$export$5b7c3ce0ebe51f86);
@@ -35,11 +36,36 @@ $parcel$export(module.exports, "solid_format_price", () => $5fc9fc23df1591db$exp
35
36
  $parcel$export(module.exports, "connect_search_field_height_to_aligner_height", () => $246e3e89a097f014$export$828dcdd425fd3231);
36
37
  $parcel$export(module.exports, "PageReplacer", () => $37e96a5ebc768cc7$export$3ccaa27d81dd8556);
37
38
  $parcel$export(module.exports, "version", () => $ae93561d5649a847$export$83d89fbfd8236492);
38
- /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.67";
39
+ /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.68";
39
40
 
40
41
 
41
42
 
42
43
 
44
+
45
+
46
+ function $404797169c268f7a$export$5bad61ecde080b1f(...params) {
47
+ const { collapse: collapse , expand: expand , ExpandingContainer: ExpandingContainer } = (0, $46MJV$depictaiutilishared.useExpandingContainer)(...params);
48
+ return {
49
+ collapse: collapse,
50
+ expand: expand,
51
+ ExpandingContainer: ({ children: children })=>{
52
+ // get reactive signals/solid's jsx elements into `ExpandingContainer`
53
+ const fake_div = document.createElement("div");
54
+ const outer_expanding = (0, $46MJV$solidjsweb.createComponent)(ExpandingContainer, {
55
+ children: [
56
+ fake_div
57
+ ]
58
+ });
59
+ const parent = fake_div.parentElement;
60
+ fake_div.remove();
61
+ (0, $46MJV$solidjsweb.insert)(parent, children);
62
+ return outer_expanding;
63
+ }
64
+ };
65
+ }
66
+
67
+
68
+
43
69
  async function $8c4e48a4bf96b284$export$58e808b1db15d3bc({ merchant: merchant , market: market , headers: headers , ...fetch_recs_options }) {
44
70
  return await (0, $46MJV$depictaiutilishared.fetch_recs)({
45
71
  tenant: merchant,
@@ -1123,30 +1149,6 @@ function $8d94abc871e13baf$var$wrap_template_to_throw_into_error_boundary(templa
1123
1149
 
1124
1150
 
1125
1151
 
1126
- function $404797169c268f7a$export$5bad61ecde080b1f(...params) {
1127
- const { collapse: collapse , expand: expand , ExpandingContainer: ExpandingContainer } = (0, $46MJV$depictaiutilishared.useExpandingContainer)(...params);
1128
- return {
1129
- collapse: collapse,
1130
- expand: expand,
1131
- ExpandingContainer: ({ children: children })=>{
1132
- // get reactive signals/solid's jsx elements into `ExpandingContainer`
1133
- const fake_div = document.createElement("div");
1134
- const outer_expanding = (0, $46MJV$solidjsweb.createComponent)(ExpandingContainer, {
1135
- children: [
1136
- fake_div
1137
- ]
1138
- });
1139
- const parent = fake_div.parentElement;
1140
- fake_div.remove();
1141
- (0, $46MJV$solidjsweb.insert)(parent, children);
1142
- return outer_expanding;
1143
- }
1144
- };
1145
- }
1146
-
1147
-
1148
-
1149
-
1150
1152
 
1151
1153
 
1152
1154
 
@@ -6846,8 +6848,26 @@ function $4a976b492943589f$export$f021bdedd3ec901a(props) {
6846
6848
 
6847
6849
 
6848
6850
  const $121d25ca6af2898f$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="discover-more"><button class="major" type="button"></button></div>`, 4), $121d25ca6af2898f$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<b></b>`, 2), $121d25ca6af2898f$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict-search-modal"><div class="body"><div class="padded"></div></div></div>`, 6), $121d25ca6af2898f$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$46MJV$solidjsweb.template)(`<div class="depict plp search"><div class="depict-search-modal-backdrop"></div></div>`, 4);
6849
- function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: search_field_value_ , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $46MJV$solidjs.createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: submit_query_ , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , after_submit_: after_submit_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , selected_text_range_: selected_text_range_ }) {
6851
+ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: props_search_field_value , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $46MJV$solidjs.createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , after_submit_: props_after_submit , bottom_distance_under_modal_: bottom_distance_under_modal_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false }) {
6850
6852
  let on_enter_in_search_field_function;
6853
+ // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
6854
+ // This is desired for when the modal is opened from a UI element that visually does not look connected with the search page or current query
6855
+ // Basically the UI signals that the button that opens the modal starts a new search.
6856
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? (0, $46MJV$solidjs.createSignal)("") : props_search_field_value;
6857
+ const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? ()=>props_search_field_value[1]((0, $46MJV$solidjs.untrack)(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
6858
+ : undefined;
6859
+ const submit_query_ = (...args)=>{
6860
+ // submit_query expects to read the current search field value which is why we have to write the current one to the signal before calling it
6861
+ // It will write the old one back and then write the new one after submit
6862
+ propagate_search_field_value_back?.();
6863
+ return props_submit_query(...args);
6864
+ };
6865
+ const after_submit_ = props_after_submit && ((...args)=>{
6866
+ // This will be called by link_to_param_change when clicking on a suggestion
6867
+ // the logic in link_to_param_change doesn't need to read the search field value before submitting, so we can just propagate the changes after submitting
6868
+ propagate_search_field_value_back?.();
6869
+ return props_after_submit(...args);
6870
+ });
6851
6871
  const [input_field, set_input_field] = (0, $46MJV$solidjs.createSignal)();
6852
6872
  const [get_search_field_value_] = search_field_value_;
6853
6873
  const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $46MJV$solidjs.createSignal)();
@@ -6870,7 +6890,7 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: search
6870
6890
  (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
6871
6891
  (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((()=>{
6872
6892
  const _el$ = $121d25ca6af2898f$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
6873
- (0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", submit_query_, true);
6893
+ _el$2.$$click = submit_query_;
6874
6894
  (0, $46MJV$solidjsweb.insert)(_el$2, (()=>{
6875
6895
  const _c$ = (0, $46MJV$solidjsweb.memo)(()=>!!get_search_field_value_());
6876
6896
  return ()=>_c$() ? i18n_.modal_view_all_results_()((()=>{
@@ -7592,7 +7612,6 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7592
7612
  }
7593
7613
  if (!open_signal_value[0]?.style_props_ && search_page_aligned_modal_body_style_signal_) {
7594
7614
  // Open modal aligned with search page if no alignment specified and possible to align with search page
7595
- // TODO: nice to have: align with most visible SearchField if possible since that's always more desirable than centering
7596
7615
  if (!signal_value_is_options) {
7597
7616
  open_modal_({
7598
7617
  style_props_: search_page_aligned_modal_body_style_signal_
@@ -7623,7 +7642,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7623
7642
  const [options_arg, ...rest] = open_signal_value;
7624
7643
  open_modal_({
7625
7644
  ...options_arg,
7626
- style_props_: search_page_aligned_modal_body_style_signal_
7645
+ style_props_: search_page_aligned_modal_body_style_signal_ || style_props_
7627
7646
  }, ...rest);
7628
7647
  return;
7629
7648
  }
@@ -7832,18 +7851,26 @@ function $79fbf145b15af988$var$align_field_modal(style_props_, input, aligner_re
7832
7851
 
7833
7852
 
7834
7853
  const $9c5a1d57540c06e5$export$d86a33413558014e = (openModalParams)=>{
7835
- const { search: search } = openModalParams;
7854
+ const { search: search , makesNewSearch: makesNewSearch = true } = openModalParams;
7836
7855
  openModalParams.location ||= "centered";
7837
7856
  if (openModalParams.location === "aligned" && !openModalParams.element) throw new Error("No active search header aligner on the page!");
7838
7857
  if (openModalParams.location !== "aligned") {
7839
7858
  // Open centered modal
7840
- search.modal_open = true;
7859
+ search.modal_open = [
7860
+ {
7861
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7862
+ }
7863
+ ];
7841
7864
  return;
7842
7865
  }
7843
7866
  const alignment_height = openModalParams.element?.clientHeight;
7844
7867
  if (isNaN(alignment_height)) {
7845
7868
  // Open centered modal
7846
- search.modal_open = true;
7869
+ search.modal_open = [
7870
+ {
7871
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7872
+ }
7873
+ ];
7847
7874
  return;
7848
7875
  }
7849
7876
  const { cleanup: cleanup } = (0, $246e3e89a097f014$export$828dcdd425fd3231)(openModalParams.element);
@@ -7862,7 +7889,8 @@ const $9c5a1d57540c06e5$export$d86a33413558014e = (openModalParams)=>{
7862
7889
  });
7863
7890
  search.modal_open = [
7864
7891
  {
7865
- style_props_: style_props_
7892
+ style_props_: style_props_,
7893
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7866
7894
  },
7867
7895
  dispose_aligner
7868
7896
  ];
package/dist/module.js CHANGED
@@ -1,12 +1,37 @@
1
- import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Tenant as $g9l4l$Tenant, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, default_rr as $g9l4l$default_rr, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, Lazyfier as $g9l4l$Lazyfier, queueMacroTask as $g9l4l$queueMacroTask, deparallelize as $g9l4l$deparallelize, Rec_Renderer as $g9l4l$Rec_Renderer, CrossIcon as $g9l4l$CrossIcon, useExpandingContainer as $g9l4l$useExpandingContainer, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, hsl_to_rgb as $g9l4l$hsl_to_rgb, relative_luminance_from_rgb as $g9l4l$relative_luminance_from_rgb, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, normal_get_product_id as $g9l4l$normal_get_product_id, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, make_placeholder_rr as $g9l4l$make_placeholder_rr, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, depict_click as $g9l4l$depict_click, impression_track_element as $g9l4l$impression_track_element, add_new_tab_listener as $g9l4l$add_new_tab_listener, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces, instant_exec_on_popstate_before_ipns_update as $g9l4l$instant_exec_on_popstate_before_ipns_update} from "@depict-ai/utilishared";
2
- import {template as $g9l4l$template, insert as $g9l4l$insert, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, createComponent as $g9l4l$createComponent, use as $g9l4l$use, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList, memo as $g9l4l$memo, style as $g9l4l$style, mergeProps as $g9l4l$mergeProps, className as $g9l4l$className} from "solid-js/web";
1
+ import {add_to_version_info as $g9l4l$add_to_version_info, useExpandingContainer as $g9l4l$useExpandingContainer, fetch_recs as $g9l4l$fetch_recs, snakeCasifyObject as $g9l4l$snakeCasifyObject, GenericSliderArrowButton as $g9l4l$GenericSliderArrowButton, catchify as $g9l4l$catchify, base_url as $g9l4l$base_url, get_depict_id as $g9l4l$get_depict_id, get_user_id as $g9l4l$get_user_id, get_session_id as $g9l4l$get_session_id, dlog as $g9l4l$dlog, make_url_with_query_params as $g9l4l$make_url_with_query_params, fetch_retry as $g9l4l$fetch_retry, add_version_query_params as $g9l4l$add_version_query_params, sort_obj as $g9l4l$sort_obj, Tenant as $g9l4l$Tenant, Placeholder as $g9l4l$Placeholder, report as $g9l4l$report, javascript_media_query as $g9l4l$javascript_media_query, standard_price_format as $g9l4l$standard_price_format, deparallelize_no_drop as $g9l4l$deparallelize_no_drop, default_rr as $g9l4l$default_rr, make_random_classname as $g9l4l$make_random_classname, n_col_styling_with_dist as $g9l4l$n_col_styling_with_dist, observer as $g9l4l$observer, Lazyfier as $g9l4l$Lazyfier, queueMacroTask as $g9l4l$queueMacroTask, deparallelize as $g9l4l$deparallelize, Rec_Renderer as $g9l4l$Rec_Renderer, CrossIcon as $g9l4l$CrossIcon, Amazing_Slider as $g9l4l$Amazing_Slider, slider_snap_css as $g9l4l$slider_snap_css, slider_fading_factory as $g9l4l$slider_fading_factory, MinusIcon as $g9l4l$MinusIcon, FilterIcon as $g9l4l$FilterIcon, SortIconAsc as $g9l4l$SortIconAsc, SortIconDesc as $g9l4l$SortIconDesc, PlusIcon as $g9l4l$PlusIcon, hsl_to_rgb as $g9l4l$hsl_to_rgb, relative_luminance_from_rgb as $g9l4l$relative_luminance_from_rgb, TickIcon as $g9l4l$TickIcon, ArrowUp as $g9l4l$ArrowUp, normal_get_product_id as $g9l4l$normal_get_product_id, ContainedPlaceholderImage as $g9l4l$ContainedPlaceholderImage, BackIcon as $g9l4l$BackIcon, SearchIcon as $g9l4l$SearchIcon, Layout as $g9l4l$Layout, make_placeholder_rr as $g9l4l$make_placeholder_rr, async_iterable_ipns as $g9l4l$async_iterable_ipns, make_asyncIterable_exiter as $g9l4l$make_asyncIterable_exiter, href_change_ipns as $g9l4l$href_change_ipns, depict_click as $g9l4l$depict_click, impression_track_element as $g9l4l$impression_track_element, add_new_tab_listener as $g9l4l$add_new_tab_listener, ContainedImage as $g9l4l$ContainedImage, buildThresholdList as $g9l4l$buildThresholdList, PreviousSearchIcon as $g9l4l$PreviousSearchIcon, insert_surfaces as $g9l4l$insert_surfaces, instant_exec_on_popstate_before_ipns_update as $g9l4l$instant_exec_on_popstate_before_ipns_update} from "@depict-ai/utilishared";
2
+ import {createComponent as $g9l4l$createComponent, insert as $g9l4l$insert, template as $g9l4l$template, effect as $g9l4l$effect, setAttribute as $g9l4l$setAttribute, use as $g9l4l$use, addEventListener as $g9l4l$addEventListener, delegateEvents as $g9l4l$delegateEvents, spread as $g9l4l$spread, classList as $g9l4l$classList, memo as $g9l4l$memo, style as $g9l4l$style, mergeProps as $g9l4l$mergeProps, className as $g9l4l$className} from "solid-js/web";
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
 
5
- /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.67";
5
+ /*! Depict.ai search and product listing SDK */ const $18bf1d29fb889cca$export$83d89fbfd8236492 = "0.0.68";
6
6
 
7
7
 
8
8
 
9
9
 
10
+
11
+
12
+ function $198845c3fc59215a$export$5bad61ecde080b1f(...params) {
13
+ const { collapse: collapse , expand: expand , ExpandingContainer: ExpandingContainer } = (0, $g9l4l$useExpandingContainer)(...params);
14
+ return {
15
+ collapse: collapse,
16
+ expand: expand,
17
+ ExpandingContainer: ({ children: children })=>{
18
+ // get reactive signals/solid's jsx elements into `ExpandingContainer`
19
+ const fake_div = document.createElement("div");
20
+ const outer_expanding = (0, $g9l4l$createComponent)(ExpandingContainer, {
21
+ children: [
22
+ fake_div
23
+ ]
24
+ });
25
+ const parent = fake_div.parentElement;
26
+ fake_div.remove();
27
+ (0, $g9l4l$insert)(parent, children);
28
+ return outer_expanding;
29
+ }
30
+ };
31
+ }
32
+
33
+
34
+
10
35
  async function $e95f1855a5e3864f$export$58e808b1db15d3bc({ merchant: merchant , market: market , headers: headers , ...fetch_recs_options }) {
11
36
  return await (0, $g9l4l$fetch_recs)({
12
37
  tenant: merchant,
@@ -1090,30 +1115,6 @@ function $57363319986950eb$var$wrap_template_to_throw_into_error_boundary(templa
1090
1115
 
1091
1116
 
1092
1117
 
1093
- function $198845c3fc59215a$export$5bad61ecde080b1f(...params) {
1094
- const { collapse: collapse , expand: expand , ExpandingContainer: ExpandingContainer } = (0, $g9l4l$useExpandingContainer)(...params);
1095
- return {
1096
- collapse: collapse,
1097
- expand: expand,
1098
- ExpandingContainer: ({ children: children })=>{
1099
- // get reactive signals/solid's jsx elements into `ExpandingContainer`
1100
- const fake_div = document.createElement("div");
1101
- const outer_expanding = (0, $g9l4l$createComponent)(ExpandingContainer, {
1102
- children: [
1103
- fake_div
1104
- ]
1105
- });
1106
- const parent = fake_div.parentElement;
1107
- fake_div.remove();
1108
- (0, $g9l4l$insert)(parent, children);
1109
- return outer_expanding;
1110
- }
1111
- };
1112
- }
1113
-
1114
-
1115
-
1116
-
1117
1118
 
1118
1119
 
1119
1120
 
@@ -6813,8 +6814,26 @@ function $b24f16c875c2baa6$export$f021bdedd3ec901a(props) {
6813
6814
 
6814
6815
 
6815
6816
  const $a9f6faeac82c322b$var$_tmpl$ = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="discover-more"><button class="major" type="button"></button></div>`, 4), $a9f6faeac82c322b$var$_tmpl$2 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<b></b>`, 2), $a9f6faeac82c322b$var$_tmpl$3 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict-search-modal"><div class="body"><div class="padded"></div></div></div>`, 6), $a9f6faeac82c322b$var$_tmpl$4 = /*@__PURE__*/ (0, /*@__PURE__*/$g9l4l$template)(`<div class="depict plp search"><div class="depict-search-modal-backdrop"></div></div>`, 4);
6816
- function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: search_field_value_ , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $g9l4l$createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: submit_query_ , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , after_submit_: after_submit_ , bottom_distance_under_modal_: bottom_distance_under_modal_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , selected_text_range_: selected_text_range_ }) {
6817
+ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: props_search_field_value , search_query_: search_query_ , search_page_url_param_name_: search_page_url_param_name_ , previous_searches_: previous_searches_ , close_modal_: close_modal_ , style_props_: style_props_ = (0, $g9l4l$createSignal)({}) , depict_api_: depict_api_ , tenant_: tenant_ , market_: market_ , submit_query_: props_submit_query , instant_results_options_: instant_results_options_ , register_closing_animation_: register_closing_animation_ , url_transformer_: url_transformer_ , closing_animation_: closing_animation_ , alternative_query_submitter_for_spas_: alternative_query_submitter_for_spas_ , clear_filters_: clear_filters_ , i18n_: i18n_ , disable_scrolling_: disable_scrolling_ = true , enable_category_suggestions_: enable_category_suggestions_ , class_list_: class_list_ , after_submit_: props_after_submit , bottom_distance_under_modal_: bottom_distance_under_modal_ , navigate_page_to_href_: navigate_page_to_href_ , on_submit_with_unchanged_value_: on_submit_with_unchanged_value_ , selected_text_range_: selected_text_range_ , dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_ = false }) {
6817
6818
  let on_enter_in_search_field_function;
6819
+ // As per feedback from stronger we sometimes want a modal with the search field value disconnected from the one in the rest of the UI, see https://depictaiworkspace.slack.com/archives/C02J16R9XEH/p1679065878487709.
6820
+ // This is desired for when the modal is opened from a UI element that visually does not look connected with the search page or current query
6821
+ // Basically the UI signals that the button that opens the modal starts a new search.
6822
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? (0, $g9l4l$createSignal)("") : props_search_field_value;
6823
+ const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? ()=>props_search_field_value[1]((0, $g9l4l$untrack)(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
6824
+ : undefined;
6825
+ const submit_query_ = (...args)=>{
6826
+ // submit_query expects to read the current search field value which is why we have to write the current one to the signal before calling it
6827
+ // It will write the old one back and then write the new one after submit
6828
+ propagate_search_field_value_back?.();
6829
+ return props_submit_query(...args);
6830
+ };
6831
+ const after_submit_ = props_after_submit && ((...args)=>{
6832
+ // This will be called by link_to_param_change when clicking on a suggestion
6833
+ // the logic in link_to_param_change doesn't need to read the search field value before submitting, so we can just propagate the changes after submitting
6834
+ propagate_search_field_value_back?.();
6835
+ return props_after_submit(...args);
6836
+ });
6818
6837
  const [input_field, set_input_field] = (0, $g9l4l$createSignal)();
6819
6838
  const [get_search_field_value_] = search_field_value_;
6820
6839
  const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $g9l4l$createSignal)();
@@ -6837,7 +6856,7 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: search
6837
6856
  (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
6838
6857
  (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((()=>{
6839
6858
  const _el$ = $a9f6faeac82c322b$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
6840
- (0, $g9l4l$addEventListener)(_el$2, "click", submit_query_, true);
6859
+ _el$2.$$click = submit_query_;
6841
6860
  (0, $g9l4l$insert)(_el$2, (()=>{
6842
6861
  const _c$ = (0, $g9l4l$memo)(()=>!!get_search_field_value_());
6843
6862
  return ()=>_c$() ? i18n_.modal_view_all_results_()((()=>{
@@ -7559,7 +7578,6 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7559
7578
  }
7560
7579
  if (!open_signal_value[0]?.style_props_ && search_page_aligned_modal_body_style_signal_) {
7561
7580
  // Open modal aligned with search page if no alignment specified and possible to align with search page
7562
- // TODO: nice to have: align with most visible SearchField if possible since that's always more desirable than centering
7563
7581
  if (!signal_value_is_options) {
7564
7582
  open_modal_({
7565
7583
  style_props_: search_page_aligned_modal_body_style_signal_
@@ -7590,7 +7608,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7590
7608
  const [options_arg, ...rest] = open_signal_value;
7591
7609
  open_modal_({
7592
7610
  ...options_arg,
7593
- style_props_: search_page_aligned_modal_body_style_signal_
7611
+ style_props_: search_page_aligned_modal_body_style_signal_ || style_props_
7594
7612
  }, ...rest);
7595
7613
  return;
7596
7614
  }
@@ -7799,18 +7817,26 @@ function $540e930c58500cbe$var$align_field_modal(style_props_, input, aligner_re
7799
7817
 
7800
7818
 
7801
7819
  const $7cbfd6122dbaf087$export$d86a33413558014e = (openModalParams)=>{
7802
- const { search: search } = openModalParams;
7820
+ const { search: search , makesNewSearch: makesNewSearch = true } = openModalParams;
7803
7821
  openModalParams.location ||= "centered";
7804
7822
  if (openModalParams.location === "aligned" && !openModalParams.element) throw new Error("No active search header aligner on the page!");
7805
7823
  if (openModalParams.location !== "aligned") {
7806
7824
  // Open centered modal
7807
- search.modal_open = true;
7825
+ search.modal_open = [
7826
+ {
7827
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7828
+ }
7829
+ ];
7808
7830
  return;
7809
7831
  }
7810
7832
  const alignment_height = openModalParams.element?.clientHeight;
7811
7833
  if (isNaN(alignment_height)) {
7812
7834
  // Open centered modal
7813
- search.modal_open = true;
7835
+ search.modal_open = [
7836
+ {
7837
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7838
+ }
7839
+ ];
7814
7840
  return;
7815
7841
  }
7816
7842
  const { cleanup: cleanup } = (0, $a79ffb1cbfbd2a09$export$828dcdd425fd3231)(openModalParams.element);
@@ -7829,7 +7855,8 @@ const $7cbfd6122dbaf087$export$d86a33413558014e = (openModalParams)=>{
7829
7855
  });
7830
7856
  search.modal_open = [
7831
7857
  {
7832
- style_props_: style_props_
7858
+ style_props_: style_props_,
7859
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7833
7860
  },
7834
7861
  dispose_aligner
7835
7862
  ];
@@ -8055,4 +8082,4 @@ class $ba6c9609228edf6b$export$3ccaa27d81dd8556 extends EventTarget {
8055
8082
  (0, $g9l4l$add_to_version_info)("ui", (0, $18bf1d29fb889cca$export$83d89fbfd8236492));
8056
8083
 
8057
8084
 
8058
- export {$e95f1855a5e3864f$export$58e808b1db15d3bc as fetchDepictRecommendations, $ec52ef1e6c117813$export$de035477d6fef996 as QuickLinks, $ec52ef1e6c117813$export$5b7c3ce0ebe51f86 as BreadCrumbs, $6340962f8bafd049$export$b91cec6bdc6b32a1 as CategoryTitle, $9b693ea3ff420de6$export$824dde41348efed1 as embedded_num_products, $80a49d3809ecb080$export$643598a327b5833e as get_categories, $ec52ef1e6c117813$export$f34314aa9505732e as DepictCategory, $ec52ef1e6c117813$export$e2bf8ce7779e827e as CategoryPage, $540e930c58500cbe$export$ac6237957a15b3f0 as DepictSearch, $540e930c58500cbe$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $540e930c58500cbe$export$f2dc7e4e4aa11abb as SearchPage, $540e930c58500cbe$export$316f6f283ae64765 as SearchField, $22d7fd594100c3d0$export$aa14a9f43128f61f as ProductCardError, $7cbfd6122dbaf087$export$d86a33413558014e as open_modal_with_alignment, $aaacfac0064e97d9$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $079defea521d5e2a$export$b3ad617e9036868 as align_field, $b4e6a093ae83373b$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $246aa49a8f85c7f3$export$1233ca167bf71f9a as styles_to_valid_css_string, $a1123c5ed9b0ee29$export$fe334901e8bebd57 as disable_scrolling, $a3e81b85527bc866$export$d0596b5cae35ad4 as open_search_with_shift_slash, $972ebf2641490830$export$26df08e242fe83a3 as push_state_with_query_param_value, $3846bb34098c738f$export$e015ed2f2950f2e3 as DepictAPI, $fefe7683325039b3$export$d9f36cf74e24d595 as media_query_to_accessor, $36316d7b4c897a03$export$689e204eadb33baf as setup_fast_leave, $886fa987db4f3805$export$5196e4c01fa56fcb as show_toast, $5178263ed1e394ca$export$469c7af753d08925 as solid_format_price, $a79ffb1cbfbd2a09$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $ba6c9609228edf6b$export$3ccaa27d81dd8556 as PageReplacer, $18bf1d29fb889cca$export$83d89fbfd8236492 as version};
8085
+ export {$198845c3fc59215a$export$5bad61ecde080b1f as useExpandingContainerReactive, $e95f1855a5e3864f$export$58e808b1db15d3bc as fetchDepictRecommendations, $ec52ef1e6c117813$export$de035477d6fef996 as QuickLinks, $ec52ef1e6c117813$export$5b7c3ce0ebe51f86 as BreadCrumbs, $6340962f8bafd049$export$b91cec6bdc6b32a1 as CategoryTitle, $9b693ea3ff420de6$export$824dde41348efed1 as embedded_num_products, $80a49d3809ecb080$export$643598a327b5833e as get_categories, $ec52ef1e6c117813$export$f34314aa9505732e as DepictCategory, $ec52ef1e6c117813$export$e2bf8ce7779e827e as CategoryPage, $540e930c58500cbe$export$ac6237957a15b3f0 as DepictSearch, $540e930c58500cbe$export$bde3eb976dfded9 as get_search_query_updating_blocked_signal, $540e930c58500cbe$export$f2dc7e4e4aa11abb as SearchPage, $540e930c58500cbe$export$316f6f283ae64765 as SearchField, $22d7fd594100c3d0$export$aa14a9f43128f61f as ProductCardError, $7cbfd6122dbaf087$export$d86a33413558014e as open_modal_with_alignment, $aaacfac0064e97d9$export$ee1733d9a8495996 as DefaultInstantCardPlaceholder, $079defea521d5e2a$export$b3ad617e9036868 as align_field, $b4e6a093ae83373b$export$6daf8749b65a1b77 as convert_sdk_cols_at_size_to_layout, $246aa49a8f85c7f3$export$1233ca167bf71f9a as styles_to_valid_css_string, $a1123c5ed9b0ee29$export$fe334901e8bebd57 as disable_scrolling, $a3e81b85527bc866$export$d0596b5cae35ad4 as open_search_with_shift_slash, $972ebf2641490830$export$26df08e242fe83a3 as push_state_with_query_param_value, $3846bb34098c738f$export$e015ed2f2950f2e3 as DepictAPI, $fefe7683325039b3$export$d9f36cf74e24d595 as media_query_to_accessor, $36316d7b4c897a03$export$689e204eadb33baf as setup_fast_leave, $886fa987db4f3805$export$5196e4c01fa56fcb as show_toast, $5178263ed1e394ca$export$469c7af753d08925 as solid_format_price, $a79ffb1cbfbd2a09$export$828dcdd425fd3231 as connect_search_field_height_to_aligner_height, $ba6c9609228edf6b$export$3ccaa27d81dd8556 as PageReplacer, $18bf1d29fb889cca$export$83d89fbfd8236492 as version};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "0.0.67",
3
+ "version": "0.0.68",
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": [
@@ -86,7 +86,7 @@
86
86
  "dependencies": {
87
87
  "@depict-ai/plp-styling": "^0.0.28",
88
88
  "@depict-ai/types": "^0.0.19",
89
- "@depict-ai/utilishared": "^0.0.64",
89
+ "@depict-ai/utilishared": "^0.0.73",
90
90
  "solid-js": "^1.6.2"
91
91
  },
92
92
  "types": "dist/index.d.ts"
@@ -1,197 +0,0 @@
1
- /* tslint:disable */
2
- /**
3
- * This file was automatically generated by json-schema-to-typescript.
4
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
- * and run json-schema-to-typescript to regenerate this file.
6
- */
7
-
8
- /**
9
- * An enumeration.
10
- */
11
- export type SortingOrder = "asc" | "desc";
12
-
13
- export interface BaseSearchRequest {
14
- tenant: string;
15
- market: string;
16
- /**
17
- * List of filters to apply to the results.
18
- */
19
- filters?: SearchFilter[];
20
- /**
21
- * Specifies the sorting method. By default, the results are ordered by relevance. To find the possible values for this field, query the endpoint and look at the `sorts` field.
22
- */
23
- sort?: SortModel;
24
- /**
25
- * User identifier
26
- */
27
- user_id?: string;
28
- /**
29
- * Session identifier
30
- */
31
- session_id?: string;
32
- /**
33
- * Populated for integrations performed by Depict.ai only. Depict.ai Session Id
34
- */
35
- dsid?: string;
36
- /**
37
- * Metadata that can be used to modify the behaviour of the search.
38
- */
39
- metadata?: {
40
- [k: string]: string;
41
- };
42
- /**
43
- * The search query.
44
- */
45
- query?: string;
46
- }
47
- export interface SearchFilter {
48
- /**
49
- * The field to filter by.
50
- */
51
- field: string;
52
- /**
53
- * The operation used for filtering. The filtering should be read as `field op data`, for example `brand in ["Nike", "Adidas"]`.
54
- */
55
- op: "eq" | "neq" | "in" | "nin" | "leq" | "geq" | "inrange";
56
- /**
57
- * Data for the filter.
58
- */
59
- data?:
60
- | ("true" | "false")
61
- | number
62
- | number
63
- | string
64
- | [number, number]
65
- | [number, number]
66
- | [number, number]
67
- | [number, number]
68
- | (
69
- | ("true" | "false")
70
- | number
71
- | number
72
- | string
73
- | [number, number]
74
- | [number, number]
75
- | [number, number]
76
- | [number, number]
77
- )[]
78
- | (("true" | "false") | number | number | string)[][];
79
- /**
80
- * Metadata about the filter that can be used for rendering. For example, this could contain the possible values to filter by and their counts in the results.
81
- */
82
- meta?: RangeFilterMeta | ValuesFilterMeta | HierarchicalValuesFilterMeta;
83
- /**
84
- * ID of the filter. If multiple filters share the same ID, they should be grouped together in the UI.
85
- */
86
- id?: string;
87
- }
88
- export interface RangeFilterMeta {
89
- /**
90
- * Title of the group, where a group consists of all the filters that share an ID.
91
- */
92
- group_title?: string;
93
- /**
94
- * Whether the filter group should be expanded by default or not.
95
- */
96
- group_expanded?: boolean;
97
- type?: "range";
98
- /**
99
- * The minimum value that can be selected in the range.
100
- */
101
- min: number;
102
- /**
103
- * The maximum value that can be selected in the range.
104
- */
105
- max: number;
106
- /**
107
- * The unit of the range values.
108
- */
109
- unit?: string;
110
- /**
111
- * The currency of the range values.
112
- */
113
- currency?: string;
114
- }
115
- export interface ValuesFilterMeta {
116
- /**
117
- * Title of the group, where a group consists of all the filters that share an ID.
118
- */
119
- group_title?: string;
120
- /**
121
- * Whether the filter group should be expanded by default or not.
122
- */
123
- group_expanded?: boolean;
124
- /**
125
- * Type of filter.
126
- */
127
- type?: "radio" | "checkbox" | "checkbox-grid";
128
- /**
129
- * Selectable values
130
- */
131
- values: (
132
- | ("true" | "false")
133
- | number
134
- | number
135
- | string
136
- | [number, number]
137
- | [number, number]
138
- | [number, number]
139
- | [number, number]
140
- )[];
141
- /**
142
- * Counts for values
143
- */
144
- counts?: number[];
145
- /**
146
- * Names for values
147
- */
148
- names?: string[];
149
- }
150
- export interface HierarchicalValuesFilterMeta {
151
- /**
152
- * Title of the group, where a group consists of all the filters that share an ID.
153
- */
154
- group_title?: string;
155
- /**
156
- * Whether the filter group should be expanded by default or not.
157
- */
158
- group_expanded?: boolean;
159
- type?: "checkbox-hierarchical";
160
- /**
161
- * Selectable hierarchical values
162
- */
163
- values: (("true" | "false") | number | number | string)[][];
164
- /**
165
- * Counts for values
166
- */
167
- counts?: number[];
168
- /**
169
- * Names for hierarchical values
170
- */
171
- names?: string[];
172
- }
173
- export interface SortModel {
174
- /**
175
- * The field to sort by.
176
- */
177
- field: string;
178
- /**
179
- * The order to sort by.
180
- */
181
- order: SortingOrder;
182
- /**
183
- * Metadata about the sort that can be used for rendering.
184
- */
185
- meta?: SortMeta;
186
- }
187
- export interface SortMeta {
188
- title: string;
189
- /**
190
- * Selectable values
191
- */
192
- values?: SortingOrder[];
193
- /**
194
- * Names for orders
195
- */
196
- names?: string[];
197
- }
@@ -1,14 +0,0 @@
1
- /* tslint:disable */
2
- /**
3
- * This file was automatically generated by json-schema-to-typescript.
4
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
- * and run json-schema-to-typescript to regenerate this file.
6
- */
7
-
8
- export interface ProductListingQueriesRequest {
9
- tenant: string;
10
- market: string;
11
- metadata?: {
12
- [k: string]: string;
13
- };
14
- }
@@ -1,10 +0,0 @@
1
- /* tslint:disable */
2
- /**
3
- * This file was automatically generated by json-schema-to-typescript.
4
- * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
5
- * and run json-schema-to-typescript to regenerate this file.
6
- */
7
-
8
- export interface ProductListingQueriesResponse {
9
- query_ids?: string[];
10
- }