@depict-ai/ui 0.0.67 → 0.0.70

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
@@ -9,7 +9,7 @@ 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.70";
13
13
  type ExclusiveId = {
14
14
  categoryId: string;
15
15
  productId?: undefined;
@@ -322,6 +322,7 @@ type OpenModalArguments = [
322
322
  closing_animation_?: () => Promise<any>;
323
323
  class_list_?: Accessor<Record<string, boolean>>;
324
324
  selected_text_range_?: readonly [number | null, number | null] | [number | null, number | null];
325
+ dont_sync_search_field_value_except_on_submit_?: boolean;
325
326
  },
326
327
  on_dispose?: VoidFunction
327
328
  ];
@@ -463,6 +464,10 @@ type AlignedLocation = {
463
464
  type ModalLocation = AlignedLocation | CenteredLocation;
464
465
  type OpenModalParams<T extends Display> = ModalLocation & {
465
466
  search: DepictSearch<T>;
467
+ /**
468
+ * If true, the search field in the modal opened will be empty and de-coupled from the other SearchFields.
469
+ */
470
+ makesNewSearch?: boolean;
466
471
  };
467
472
  /**
468
473
  * Open the modal with support for alignment.
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.67";
38
+ /*! Depict.ai search and product listing SDK */ const $ae93561d5649a847$export$83d89fbfd8236492 = "0.0.70";
39
39
 
40
40
 
41
41
 
@@ -6846,8 +6846,26 @@ function $4a976b492943589f$export$f021bdedd3ec901a(props) {
6846
6846
 
6847
6847
 
6848
6848
  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_ }) {
6849
+ 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
6850
  let on_enter_in_search_field_function;
6851
+ // 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.
6852
+ // 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
6853
+ // Basically the UI signals that the button that opens the modal starts a new search.
6854
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? (0, $46MJV$solidjs.createSignal)("") : props_search_field_value;
6855
+ 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
6856
+ : undefined;
6857
+ const submit_query_ = (...args)=>{
6858
+ // 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
6859
+ // It will write the old one back and then write the new one after submit
6860
+ propagate_search_field_value_back?.();
6861
+ return props_submit_query(...args);
6862
+ };
6863
+ const after_submit_ = props_after_submit && ((...args)=>{
6864
+ // This will be called by link_to_param_change when clicking on a suggestion
6865
+ // 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
6866
+ propagate_search_field_value_back?.();
6867
+ return props_after_submit(...args);
6868
+ });
6851
6869
  const [input_field, set_input_field] = (0, $46MJV$solidjs.createSignal)();
6852
6870
  const [get_search_field_value_] = search_field_value_;
6853
6871
  const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $46MJV$solidjs.createSignal)();
@@ -6870,7 +6888,7 @@ function $121d25ca6af2898f$export$1c593cbd6f1e10bc({ search_field_value_: search
6870
6888
  (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
6871
6889
  (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((()=>{
6872
6890
  const _el$ = $121d25ca6af2898f$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
6873
- (0, $46MJV$solidjsweb.addEventListener)(_el$2, "click", submit_query_, true);
6891
+ _el$2.$$click = submit_query_;
6874
6892
  (0, $46MJV$solidjsweb.insert)(_el$2, (()=>{
6875
6893
  const _c$ = (0, $46MJV$solidjsweb.memo)(()=>!!get_search_field_value_());
6876
6894
  return ()=>_c$() ? i18n_.modal_view_all_results_()((()=>{
@@ -7592,7 +7610,6 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7592
7610
  }
7593
7611
  if (!open_signal_value[0]?.style_props_ && search_page_aligned_modal_body_style_signal_) {
7594
7612
  // 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
7613
  if (!signal_value_is_options) {
7597
7614
  open_modal_({
7598
7615
  style_props_: search_page_aligned_modal_body_style_signal_
@@ -7623,7 +7640,7 @@ class $79fbf145b15af988$export$ac6237957a15b3f0 {
7623
7640
  const [options_arg, ...rest] = open_signal_value;
7624
7641
  open_modal_({
7625
7642
  ...options_arg,
7626
- style_props_: search_page_aligned_modal_body_style_signal_
7643
+ style_props_: search_page_aligned_modal_body_style_signal_ || style_props_
7627
7644
  }, ...rest);
7628
7645
  return;
7629
7646
  }
@@ -7832,18 +7849,26 @@ function $79fbf145b15af988$var$align_field_modal(style_props_, input, aligner_re
7832
7849
 
7833
7850
 
7834
7851
  const $9c5a1d57540c06e5$export$d86a33413558014e = (openModalParams)=>{
7835
- const { search: search } = openModalParams;
7852
+ const { search: search , makesNewSearch: makesNewSearch = true } = openModalParams;
7836
7853
  openModalParams.location ||= "centered";
7837
7854
  if (openModalParams.location === "aligned" && !openModalParams.element) throw new Error("No active search header aligner on the page!");
7838
7855
  if (openModalParams.location !== "aligned") {
7839
7856
  // Open centered modal
7840
- search.modal_open = true;
7857
+ search.modal_open = [
7858
+ {
7859
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7860
+ }
7861
+ ];
7841
7862
  return;
7842
7863
  }
7843
7864
  const alignment_height = openModalParams.element?.clientHeight;
7844
7865
  if (isNaN(alignment_height)) {
7845
7866
  // Open centered modal
7846
- search.modal_open = true;
7867
+ search.modal_open = [
7868
+ {
7869
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7870
+ }
7871
+ ];
7847
7872
  return;
7848
7873
  }
7849
7874
  const { cleanup: cleanup } = (0, $246e3e89a097f014$export$828dcdd425fd3231)(openModalParams.element);
@@ -7862,7 +7887,8 @@ const $9c5a1d57540c06e5$export$d86a33413558014e = (openModalParams)=>{
7862
7887
  });
7863
7888
  search.modal_open = [
7864
7889
  {
7865
- style_props_: style_props_
7890
+ style_props_: style_props_,
7891
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7866
7892
  },
7867
7893
  dispose_aligner
7868
7894
  ];
package/dist/module.js CHANGED
@@ -2,7 +2,7 @@ import {add_to_version_info as $g9l4l$add_to_version_info, fetch_recs as $g9l4l$
2
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";
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.70";
6
6
 
7
7
 
8
8
 
@@ -6813,8 +6813,26 @@ function $b24f16c875c2baa6$export$f021bdedd3ec901a(props) {
6813
6813
 
6814
6814
 
6815
6815
  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_ }) {
6816
+ 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
6817
  let on_enter_in_search_field_function;
6818
+ // 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.
6819
+ // 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
6820
+ // Basically the UI signals that the button that opens the modal starts a new search.
6821
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? (0, $g9l4l$createSignal)("") : props_search_field_value;
6822
+ 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
6823
+ : undefined;
6824
+ const submit_query_ = (...args)=>{
6825
+ // 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
6826
+ // It will write the old one back and then write the new one after submit
6827
+ propagate_search_field_value_back?.();
6828
+ return props_submit_query(...args);
6829
+ };
6830
+ const after_submit_ = props_after_submit && ((...args)=>{
6831
+ // This will be called by link_to_param_change when clicking on a suggestion
6832
+ // 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
6833
+ propagate_search_field_value_back?.();
6834
+ return props_after_submit(...args);
6835
+ });
6818
6836
  const [input_field, set_input_field] = (0, $g9l4l$createSignal)();
6819
6837
  const [get_search_field_value_] = search_field_value_;
6820
6838
  const [elements_outside_scrollable, set_elements_outside_scrollable] = (0, $g9l4l$createSignal)();
@@ -6837,7 +6855,7 @@ function $a9f6faeac82c322b$export$1c593cbd6f1e10bc({ search_field_value_: search
6837
6855
  (matches ? set_elements_outside_scrollable : set_elements_inside_scrollable)("");
6838
6856
  (matches ? set_elements_inside_scrollable : set_elements_outside_scrollable)((()=>{
6839
6857
  const _el$ = $a9f6faeac82c322b$var$_tmpl$.cloneNode(true), _el$2 = _el$.firstChild;
6840
- (0, $g9l4l$addEventListener)(_el$2, "click", submit_query_, true);
6858
+ _el$2.$$click = submit_query_;
6841
6859
  (0, $g9l4l$insert)(_el$2, (()=>{
6842
6860
  const _c$ = (0, $g9l4l$memo)(()=>!!get_search_field_value_());
6843
6861
  return ()=>_c$() ? i18n_.modal_view_all_results_()((()=>{
@@ -7559,7 +7577,6 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7559
7577
  }
7560
7578
  if (!open_signal_value[0]?.style_props_ && search_page_aligned_modal_body_style_signal_) {
7561
7579
  // 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
7580
  if (!signal_value_is_options) {
7564
7581
  open_modal_({
7565
7582
  style_props_: search_page_aligned_modal_body_style_signal_
@@ -7590,7 +7607,7 @@ class $540e930c58500cbe$export$ac6237957a15b3f0 {
7590
7607
  const [options_arg, ...rest] = open_signal_value;
7591
7608
  open_modal_({
7592
7609
  ...options_arg,
7593
- style_props_: search_page_aligned_modal_body_style_signal_
7610
+ style_props_: search_page_aligned_modal_body_style_signal_ || style_props_
7594
7611
  }, ...rest);
7595
7612
  return;
7596
7613
  }
@@ -7799,18 +7816,26 @@ function $540e930c58500cbe$var$align_field_modal(style_props_, input, aligner_re
7799
7816
 
7800
7817
 
7801
7818
  const $7cbfd6122dbaf087$export$d86a33413558014e = (openModalParams)=>{
7802
- const { search: search } = openModalParams;
7819
+ const { search: search , makesNewSearch: makesNewSearch = true } = openModalParams;
7803
7820
  openModalParams.location ||= "centered";
7804
7821
  if (openModalParams.location === "aligned" && !openModalParams.element) throw new Error("No active search header aligner on the page!");
7805
7822
  if (openModalParams.location !== "aligned") {
7806
7823
  // Open centered modal
7807
- search.modal_open = true;
7824
+ search.modal_open = [
7825
+ {
7826
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7827
+ }
7828
+ ];
7808
7829
  return;
7809
7830
  }
7810
7831
  const alignment_height = openModalParams.element?.clientHeight;
7811
7832
  if (isNaN(alignment_height)) {
7812
7833
  // Open centered modal
7813
- search.modal_open = true;
7834
+ search.modal_open = [
7835
+ {
7836
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7837
+ }
7838
+ ];
7814
7839
  return;
7815
7840
  }
7816
7841
  const { cleanup: cleanup } = (0, $a79ffb1cbfbd2a09$export$828dcdd425fd3231)(openModalParams.element);
@@ -7829,7 +7854,8 @@ const $7cbfd6122dbaf087$export$d86a33413558014e = (openModalParams)=>{
7829
7854
  });
7830
7855
  search.modal_open = [
7831
7856
  {
7832
- style_props_: style_props_
7857
+ style_props_: style_props_,
7858
+ dont_sync_search_field_value_except_on_submit_: makesNewSearch
7833
7859
  },
7834
7860
  dispose_aligner
7835
7861
  ];
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.70",
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": [
@@ -84,9 +84,9 @@
84
84
  "ts-jest": "^29.0.3"
85
85
  },
86
86
  "dependencies": {
87
- "@depict-ai/plp-styling": "^0.0.28",
88
- "@depict-ai/types": "^0.0.19",
89
- "@depict-ai/utilishared": "^0.0.64",
87
+ "@depict-ai/plp-styling": "^0.0.31",
88
+ "@depict-ai/types": "^0.0.22",
89
+ "@depict-ai/utilishared": "^0.0.74",
90
90
  "solid-js": "^1.6.2"
91
91
  },
92
92
  "types": "dist/index.d.ts"