@depict-ai/ui 4.10.18 → 4.10.20

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/latest/index.cjs CHANGED
@@ -109,7 +109,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
109
109
  $parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
110
110
  $parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
111
111
  /*! Depict.ai search and product listing SDK */
112
- const $b757f75811f3261f$export$83d89fbfd8236492 = "4.10.18";
112
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "4.10.20";
113
113
  function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
114
114
  const signal = $gVhhF$solidjs.createSignal(false);
115
115
  $gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
@@ -2593,6 +2593,7 @@ async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_
2593
2593
  const modal_els = $gVhhF$solidjs.createRoot(dispose => {
2594
2594
  let closing_animation;
2595
2595
  let animation_started;
2596
+ let focus_target_after_close;
2596
2597
  dispose_and_remove = () => {
2597
2598
  const actually_close = () => {
2598
2599
  dispose();
@@ -2611,11 +2612,19 @@ async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_
2611
2612
  activeElement?.blur?.();
2612
2613
  el.remove();
2613
2614
  });
2614
- if (should_restore_focus && element_focused_before_open?.isConnected) {
2615
+ const requested_focus_target = focus_target_after_close?.();
2616
+ if (should_restore_focus && (requested_focus_target?.isConnected || element_focused_before_open?.isConnected)) {
2615
2617
  restoring_focus = true;
2616
2618
  try {
2617
2619
  // preventScroll so this can't re-introduce the safari page-jump the blur() above works around
2618
- element_focused_before_open.focus({
2620
+ let focused = false;
2621
+ if (requested_focus_target?.isConnected) {
2622
+ requested_focus_target.focus({
2623
+ preventScroll: true
2624
+ });
2625
+ focused = requested_focus_target.getRootNode().activeElement === requested_focus_target;
2626
+ }
2627
+ if (!focused && element_focused_before_open?.isConnected) element_focused_before_open.focus({
2619
2628
  preventScroll: true
2620
2629
  });
2621
2630
  } finally {
@@ -2636,7 +2645,8 @@ async function $9abb0a35d4b60ed3$export$79b1565500412d9b(search_modal, modal_fn_
2636
2645
  ...extra_options_for_modal,
2637
2646
  close_modal_: close_modal_,
2638
2647
  open_modal_: open_modal_,
2639
- register_closing_animation_: animation => closing_animation = animation
2648
+ register_closing_animation_: animation => closing_animation = animation,
2649
+ set_focus_target_after_close_: get_target => focus_target_after_close = get_target
2640
2650
  });
2641
2651
  });
2642
2652
  body.append(...modal_els);
@@ -7816,7 +7826,8 @@ async function $20ff40266d725403$export$5d2f6cd705125cd3() {
7816
7826
  return hlsModule;
7817
7827
  }
7818
7828
  var $32c662f618f5d80d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<video class=d-standard-content>`),
7819
- $32c662f618f5d80d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=d-standard-content-text>`);
7829
+ $32c662f618f5d80d$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=d-standard-content-text-group><span class=d-standard-content-text></span><span class=d-standard-content-cta>`),
7830
+ $32c662f618f5d80d$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class=d-standard-content-text>`);
7820
7831
  function $32c662f618f5d80d$export$780a853d15174484({
7821
7832
  link_: link_,
7822
7833
  type_: type_,
@@ -7826,7 +7837,8 @@ function $32c662f618f5d80d$export$780a853d15174484({
7826
7837
  aspectRatioWhenAloneInRow_: aspectRatioWhenAloneInRow_,
7827
7838
  imageResizer_: imageResizer_,
7828
7839
  text_: text_,
7829
- textPosition_: textPosition_
7840
+ textPosition_: textPosition_,
7841
+ cta_: cta_
7830
7842
  }) {
7831
7843
  let wroteAspectRatioToContainer = false; // Only write this once so we don't get into a aspect ratio changed -> size changed -> image source changed -> aspect ratio slightly changed infinite loop
7832
7844
  const [wrapperSize, setWrapperSize] = $gVhhF$solidjs.createSignal();
@@ -7927,15 +7939,44 @@ function $32c662f618f5d80d$export$780a853d15174484({
7927
7939
  }), $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7928
7940
  when: text_,
7929
7941
  get children() {
7930
- var _el$2 = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$2);
7931
- $gVhhF$solidjsweb.setAttribute(_el$2, "data-position", textPosition_ || "bottom-center");
7932
- $gVhhF$solidjsweb.insert(_el$2, text_);
7933
- return _el$2;
7942
+ return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
7943
+ when: cta_,
7944
+ get fallback() {
7945
+ return (() => {
7946
+ var _el$5 = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$3);
7947
+ $gVhhF$solidjsweb.setAttribute(_el$5, "data-position", textPosition_ || "bottom-center");
7948
+ $gVhhF$solidjsweb.insert(_el$5, text_);
7949
+ return _el$5;
7950
+ })();
7951
+ },
7952
+ get children() {
7953
+ var _el$2 = $gVhhF$solidjsweb.getNextElement($32c662f618f5d80d$var$_tmpl$2),
7954
+ _el$3 = _el$2.firstChild,
7955
+ _el$4 = _el$3.nextSibling;
7956
+ $gVhhF$solidjsweb.setAttribute(_el$2, "data-position", textPosition_ || "bottom-center");
7957
+ $gVhhF$solidjsweb.setAttribute(_el$3, "data-position", textPosition_ || "bottom-center");
7958
+ $gVhhF$solidjsweb.insert(_el$3, text_);
7959
+ $gVhhF$solidjsweb.setAttribute(_el$4, "data-position", textPosition_ || "bottom-center");
7960
+ $gVhhF$solidjsweb.insert(_el$4, cta_);
7961
+ return _el$2;
7962
+ }
7963
+ });
7934
7964
  }
7935
7965
  })];
7936
7966
  }
7937
7967
  }));
7938
7968
  }
7969
+ const $0a80939bf0a1e9cc$export$af2c67164f68e9e9 = content => {
7970
+ const {
7971
+ link: link,
7972
+ type: type,
7973
+ url: url,
7974
+ text: text,
7975
+ text_position: text_position,
7976
+ cta: cta
7977
+ } = content;
7978
+ return JSON.stringify([link, type, url, text ?? null, text_position ?? null, cta ?? null]);
7979
+ };
7939
7980
  function $0a80939bf0a1e9cc$export$7a92d995f1bf3592(history_content_blocks_, plp_meta, content_blocks_by_row_, router_, products_request_loading_, imageResizer_) {
7940
7981
  let hasSeenContentBlock = false;
7941
7982
  const [historyContentBlocks, setHistoryContentBlocks] = history_content_blocks_;
@@ -7972,13 +8013,11 @@ function $0a80939bf0a1e9cc$export$7a92d995f1bf3592(history_content_blocks_, plp_
7972
8013
  type: type,
7973
8014
  url: url,
7974
8015
  text: text,
7975
- text_position: text_position
8016
+ text_position: text_position,
8017
+ cta: cta
7976
8018
  }
7977
8019
  } = row;
7978
- // Key the "content"-component by its rendered inputs, so we can reuse the component (and later downstream the block elements) if it's the same
7979
- // This makes the block not flicker when going backwards/forwards if the content is the same on both pages
7980
- // Also it lets us rewrite the blocks state in the history based on the block aspect ratio without infinite looping
7981
- const componentCacheKey = JSON.stringify([link, type, url, text ?? null, text_position ?? null]);
8020
+ const componentCacheKey = $0a80939bf0a1e9cc$export$af2c67164f68e9e9(row.content);
7982
8021
  // The aspect ratio depends only on the media, so its history key must stay the pre-text 3-element shape — widening it would orphan every ratio already persisted in history.state
7983
8022
  const mediaCacheKey = JSON.stringify([link, type, url]);
7984
8023
  let component = contentComponents.get(componentCacheKey);
@@ -7998,7 +8037,8 @@ function $0a80939bf0a1e9cc$export$7a92d995f1bf3592(history_content_blocks_, plp_
7998
8037
  })),
7999
8038
  imageResizer_: imageResizer_,
8000
8039
  text_: text,
8001
- textPosition_: text_position
8040
+ textPosition_: text_position,
8041
+ cta_: cta
8002
8042
  });
8003
8043
  contentComponents.set(componentCacheKey, component);
8004
8044
  }
@@ -10778,6 +10818,7 @@ var $66b8b9a9613c141d$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<but
10778
10818
  $66b8b9a9613c141d$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=spacer>`),
10779
10819
  $66b8b9a9613c141d$var$_tmpl$4 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button class="submit major"type=button>`),
10780
10820
  $66b8b9a9613c141d$var$_tmpl$5 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div><!$><!/><!$><!/><div class=field><!$><!/><input class=query tabindex=0 enterkeyhint=search><!$><!/></div><!$><!/><!$><!/>`);
10821
+ const $66b8b9a9613c141d$var$keys_not_opening_modal = new Set(["Tab", "Shift", "Control", "Alt", "AltGraph", "Meta", "CapsLock", "Escape", "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight", "PageUp", "PageDown", "Home", "End", "Insert", "ContextMenu", "NumLock", "ScrollLock", "Pause", "PrintScreen"]);
10781
10822
  function $66b8b9a9613c141d$export$b94867ecbd698f21({
10782
10823
  search_field_value_: [searchFieldValue, setSearchFieldValue],
10783
10824
  input_field_ref_: input_field_ref_,
@@ -10955,7 +10996,7 @@ function $66b8b9a9613c141d$export$b94867ecbd698f21({
10955
10996
  get onKeyDown() {
10956
10997
  return $gVhhF$depictaiutilishared.catchify(e => {
10957
10998
  if (disabled_) {
10958
- if (e.key !== "Tab" && e.key !== "Shift")
10999
+ if (!$66b8b9a9613c141d$var$keys_not_opening_modal.has(e.key) && !/^F\d{1,2}$/.test(e.key))
10959
11000
  // alow tab-selecting the input field and then open the modal when the user start writing but also to move past the field with tab
10960
11001
  input_element.click();
10961
11002
  } else if (e.key === "Enter") {
@@ -11058,6 +11099,31 @@ function $eb3039a27db40508$export$93d9bfd0c9c1a5b8(close_modal, search_query_url
11058
11099
  }
11059
11100
  })();
11060
11101
  }
11102
+ function $5f9dc76a99175920$export$9e9e2ae069cf2fe1({
11103
+ props_search_field_value_: props_search_field_value_,
11104
+ props_submit_query_: props_submit_query_,
11105
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
11106
+ set_focus_target_after_close_: set_focus_target_after_close_,
11107
+ get_search_page_input_element_: get_search_page_input_element_
11108
+ }) {
11109
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $gVhhF$solidjs.createSignal("") : props_search_field_value_;
11110
+ let submits_in_flight = 0;
11111
+ const submit_query_ = async (new_query = $gVhhF$solidjs.untrack(search_field_value_[0])) => {
11112
+ submits_in_flight++;
11113
+ try {
11114
+ return await props_submit_query_(new_query, () => set_focus_target_after_close_(get_search_page_input_element_));
11115
+ } finally {
11116
+ submits_in_flight--;
11117
+ }
11118
+ };
11119
+ if (dont_sync_search_field_value_except_on_submit_) $gVhhF$solidjs.createEffect($gVhhF$solidjs.on(search_field_value_[0], value => submits_in_flight > 0 && props_search_field_value_[1](value), {
11120
+ defer: true
11121
+ }));
11122
+ return {
11123
+ search_field_value_: search_field_value_,
11124
+ submit_query_: submit_query_
11125
+ };
11126
+ }
11061
11127
  var $44f0b2e312a9b710$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=discover-more><button class=major type=button>`),
11062
11128
  $44f0b2e312a9b710$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<b>`),
11063
11129
  $44f0b2e312a9b710$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class=depict-search-modal><div class=body role=search aria-label="Search modal with search field, query suggestions and result preview"><!$><!/><div id=depict-suggestions-and-result-preview class=padded><!$><!/><!$><!/><!$><!/></div><!$><!/></div><!$><!/>`),
@@ -11071,6 +11137,8 @@ function $44f0b2e312a9b710$var$RawClassicSearchModal({
11071
11137
  search_query_url_param_name_: search_query_url_param_name_,
11072
11138
  previous_searches_: previous_searches_,
11073
11139
  close_modal_: close_modal_,
11140
+ set_focus_target_after_close_: set_focus_target_after_close_,
11141
+ get_search_page_input_element_: get_search_page_input_element_,
11074
11142
  depict_api_: depict_api_,
11075
11143
  merchant_: merchant_,
11076
11144
  market_: market_,
@@ -11095,15 +11163,16 @@ function $44f0b2e312a9b710$var$RawClassicSearchModal({
11095
11163
  // 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.
11096
11164
  // 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
11097
11165
  // Basically the UI signals that the button that opens the modal starts a new search.
11098
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $gVhhF$solidjs.createSignal("") : props_search_field_value;
11099
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($gVhhF$solidjs.untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
11100
- : undefined;
11101
- const submit_query_ = (...args) => {
11102
- // 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
11103
- // It will write the old one back and then write the new one after submit
11104
- propagate_search_field_value_back?.();
11105
- return props_submit_query(...args);
11106
- };
11166
+ const {
11167
+ search_field_value_: search_field_value_,
11168
+ submit_query_: submit_query_
11169
+ } = $5f9dc76a99175920$export$9e9e2ae069cf2fe1({
11170
+ props_search_field_value_: props_search_field_value,
11171
+ props_submit_query_: props_submit_query,
11172
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
11173
+ set_focus_target_after_close_: set_focus_target_after_close_,
11174
+ get_search_page_input_element_: get_search_page_input_element_
11175
+ });
11107
11176
  const [input_field, set_input_field] = $gVhhF$solidjs.createSignal();
11108
11177
  const [get_search_field_value_] = search_field_value_;
11109
11178
  // Search field alignment unused in ClassicSearchModal since the search field spans the whole modal
@@ -11898,6 +11967,8 @@ function $11597ae03e703a47$var$RawSearchModalV2({
11898
11967
  search_query_url_param_name_: search_query_url_param_name_,
11899
11968
  previous_searches_: previous_searches_,
11900
11969
  close_modal_: close_modal_,
11970
+ set_focus_target_after_close_: set_focus_target_after_close_,
11971
+ get_search_page_input_element_: get_search_page_input_element_,
11901
11972
  alignmentSignals_: alignmentSignals_,
11902
11973
  depict_api_: depict_api_,
11903
11974
  merchant_: merchant_,
@@ -11928,15 +11999,16 @@ function $11597ae03e703a47$var$RawSearchModalV2({
11928
11999
  // 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.
11929
12000
  // 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
11930
12001
  // Basically the UI signals that the button that opens the modal starts a new search.
11931
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $gVhhF$solidjs.createSignal("") : props_search_field_value;
11932
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($gVhhF$solidjs.untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
11933
- : undefined;
11934
- const submit_query_ = (...args) => {
11935
- // 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
11936
- // It will write the old one back and then write the new one after submit
11937
- propagate_search_field_value_back?.();
11938
- return props_submit_query(...args);
11939
- };
12002
+ const {
12003
+ search_field_value_: search_field_value_,
12004
+ submit_query_: submit_query_
12005
+ } = $5f9dc76a99175920$export$9e9e2ae069cf2fe1({
12006
+ props_search_field_value_: props_search_field_value,
12007
+ props_submit_query_: props_submit_query,
12008
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
12009
+ set_focus_target_after_close_: set_focus_target_after_close_,
12010
+ get_search_page_input_element_: get_search_page_input_element_
12011
+ });
11940
12012
  const [input_field, set_input_field] = $gVhhF$solidjs.createSignal();
11941
12013
  const [searching_for_value_, set_searching_for_value_] = $gVhhF$solidjs.createSignal();
11942
12014
  const [show_stale_content_results_, set_show_stale_content_results_] = $gVhhF$solidjs.createSignal(false);
@@ -14067,11 +14139,12 @@ function $2b7a005a65221045$export$84bba84a7b837187(read_search_query) {
14067
14139
  async function $f328bd45f8ede33c$export$e16630ecb9644a1c({
14068
14140
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
14069
14141
  search_param_name_: search_param_name_,
14070
- set_search_field_value_: set_search_field_value_,
14142
+ search_field_value_: search_field_value_,
14071
14143
  get_search_query_: get_search_query_,
14072
14144
  url_transformer_: url_transformer_,
14073
14145
  router_: router_,
14074
14146
  after_submit_: after_submit_,
14147
+ before_navigate_: before_navigate_,
14075
14148
  get_new_query: get_new_query
14076
14149
  }) {
14077
14150
  const new_search_query = get_new_query();
@@ -14079,21 +14152,89 @@ async function $f328bd45f8ede33c$export$e16630ecb9644a1c({
14079
14152
  if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
14080
14153
  // don't push a history entry / re-search if someone submits a search again
14081
14154
  // do close the modal though
14155
+ search_field_value_.settle_(new_search_query);
14082
14156
  on_submit_with_unchanged_value_?.();
14083
- return;
14157
+ return false;
14084
14158
  }
14085
- set_search_field_value_(previous_query); // restore the value to the previous query since this one goes to the new history entry
14086
14159
  const target_url = new URL(location.href);
14087
14160
  url_transformer_?.(target_url);
14088
14161
  target_url.searchParams.set(search_param_name_, new_search_query);
14089
- await router_.navigate_.go_to_({
14090
- new_url_: target_url,
14091
- is_replace_: false,
14092
- force_spa_navigation_: true
14093
- });
14094
- set_search_field_value_(new_search_query);
14162
+ const end_submit = search_field_value_.begin_submit_(new_search_query, previous_query);
14163
+ before_navigate_?.();
14164
+ let landed;
14165
+ try {
14166
+ await router_.navigate_.go_to_({
14167
+ new_url_: target_url,
14168
+ is_replace_: false,
14169
+ force_spa_navigation_: true
14170
+ });
14171
+ } finally {
14172
+ landed = end_submit();
14173
+ }
14174
+ if (!landed) return false;
14095
14175
  scrollTo(0, 0);
14096
14176
  after_submit_?.();
14177
+ return true;
14178
+ }
14179
+ function $380b434363eee5f6$export$d13a185c53aa5edf(persisted_, get_search_query_) {
14180
+ const [get_persisted, set_persisted] = persisted_;
14181
+ const [get_submitting, set_submitting] = $gVhhF$solidjs.createSignal();
14182
+ const get_value = $gVhhF$solidjs.createMemo(() => get_submitting() ?? get_persisted());
14183
+ const set_value = value => {
14184
+ const new_value = typeof value === "function" ? value($gVhhF$solidjs.untrack(get_value)) : value;
14185
+ if ($gVhhF$solidjs.untrack(get_submitting) === undefined) set_persisted(new_value);else set_submitting(new_value);
14186
+ return new_value;
14187
+ };
14188
+ let current_submit;
14189
+ const end_submit = landed => {
14190
+ current_submit.landed_ = landed;
14191
+ current_submit = undefined;
14192
+ $gVhhF$solidjs.batch(() => {
14193
+ const submitting = $gVhhF$solidjs.untrack(get_submitting);
14194
+ set_submitting(undefined);
14195
+ if (landed && submitting !== undefined) set_persisted(submitting);
14196
+ });
14197
+ };
14198
+ const abort_on_popstate = what_happened => {
14199
+ if (what_happened === "popstate" && current_submit) end_submit(false);
14200
+ };
14201
+ (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).add(abort_on_popstate);
14202
+ $gVhhF$solidjs.onCleanup(() => (0, $gVhhF$depictaiutilishared.instant_exec_on_suspect_history_change).delete(abort_on_popstate));
14203
+ $gVhhF$solidjs.createEffect($gVhhF$solidjs.on(get_search_query_, query => {
14204
+ const token = current_submit;
14205
+ if (!token || query !== token.query_) return;
14206
+ queueMicrotask(() => {
14207
+ if (current_submit === token) end_submit(true);
14208
+ });
14209
+ }, {
14210
+ defer: true
14211
+ }));
14212
+ const begin_submit_ = (submitted_query, query_of_current_history_entry) => {
14213
+ const token = current_submit = {
14214
+ query_: submitted_query,
14215
+ landed_: false
14216
+ };
14217
+ $gVhhF$solidjs.batch(() => {
14218
+ set_submitting(submitted_query);
14219
+ set_persisted(query_of_current_history_entry);
14220
+ });
14221
+ return () => {
14222
+ if (current_submit === token) end_submit(true);
14223
+ return token.landed_;
14224
+ };
14225
+ };
14226
+ const settle_ = query => {
14227
+ if (current_submit) return;
14228
+ $gVhhF$solidjs.batch(() => {
14229
+ set_submitting(undefined);
14230
+ set_persisted(query);
14231
+ });
14232
+ };
14233
+ return {
14234
+ value_: [get_value, set_value],
14235
+ begin_submit_: begin_submit_,
14236
+ settle_: settle_
14237
+ };
14097
14238
  }
14098
14239
  function $331c7a65de274e6c$export$181cceed5c91919e(callback, alsoRaF, passiveListener) {
14099
14240
  let aligned_this_microtask = false;
@@ -14797,6 +14938,7 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
14797
14938
  scroll_restoration_data_: scroll_restoration_data_,
14798
14939
  product_card_template_: product_card_template_,
14799
14940
  modalAlignmentSignalsRef_: modalAlignmentSignalsRef_,
14941
+ inputFieldRef_: inputFieldRef_,
14800
14942
  router_: router_,
14801
14943
  content_results_rows_: content_results_rows_,
14802
14944
  content_layout_options_: content_layout_options_,
@@ -14985,6 +15127,8 @@ function $f1d7cb69f839a526$export$a54ec244c8863715({
14985
15127
  if (!search_field) break add_input_field;
14986
15128
  setModalBodyStyle({});
14987
15129
  modalAlignmentSignalsRef_?.(alignmentSignals_);
15130
+ inputFieldRef_?.(input_element);
15131
+ $gVhhF$solidjs.onCleanup(() => inputFieldRef_?.(undefined));
14988
15132
  const [pollAlignment, setPollAlignment_] = $gVhhF$solidjs.createSignal(false);
14989
15133
  const align_position = $gVhhF$depictaiutilishared.catchify((0, $fd463ff0edb29915$export$b3ad617e9036868))(alignmentSignals_, search_field, (0, $fd463ff0edb29915$export$3f238c96c45e6cc6) | (0, $fd463ff0edb29915$export$7895aadd1956b1c7) | (modalVersionUsed_ === 1 ? (0, $fd463ff0edb29915$export$902f8b4a7dae5d78) : (0, $fd463ff0edb29915$export$6060bc6bee850eb6) | (0, $fd463ff0edb29915$export$5097308c5200105a)), true, pollAlignment);
14990
15134
  div_with_field_class.addEventListener("click", $gVhhF$depictaiutilishared.catchify(e => {
@@ -15327,14 +15471,16 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
15327
15471
  set_search_content_results_rows((0, $3716b8caf7f959e2$export$70ceae36059a1036));
15328
15472
  }; // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
15329
15473
  const on_submit_with_unchanged_value_ = () => this.modal_open = false;
15330
- const [get_search_field_value_, set_search_field_value_] = state_.field_value;
15331
- const configured_submit_query_ = new_query => $f328bd45f8ede33c$export$e16630ecb9644a1c({
15474
+ const search_field_value_ = $380b434363eee5f6$export$d13a185c53aa5edf(state_.field_value, get_search_query_);
15475
+ const [get_search_field_value_] = search_field_value_.value_;
15476
+ const configured_submit_query_ = (new_query, before_navigate_) => $f328bd45f8ede33c$export$e16630ecb9644a1c({
15332
15477
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
15333
- set_search_field_value_: set_search_field_value_,
15478
+ search_field_value_: search_field_value_,
15334
15479
  get_search_query_: get_search_query_,
15335
15480
  search_param_name_: search_query_url_param_name_,
15336
15481
  after_submit_: after_submit_,
15337
- get_new_query: () => new_query || $gVhhF$solidjs.untrack(get_search_field_value_),
15482
+ before_navigate_: before_navigate_,
15483
+ get_new_query: () => new_query ?? $gVhhF$solidjs.untrack(get_search_field_value_),
15338
15484
  url_transformer_: url_transformer,
15339
15485
  router_: this.#router
15340
15486
  });
@@ -15353,6 +15499,7 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
15353
15499
  search_query_url_param_name_: search_query_url_param_name_,
15354
15500
  reset_history_state_: reset_history_state_,
15355
15501
  state_: state_,
15502
+ search_field_value_: search_field_value_.value_,
15356
15503
  router_: this.#router,
15357
15504
  url_transformer_: url_transformer,
15358
15505
  depict_api_: depict_api_,
@@ -15376,7 +15523,8 @@ class $2c61e4cd8229c49a$export$ac6237957a15b3f0 {
15376
15523
  $gVhhF$solidjs.onCleanup(() => this.modal_open = false);
15377
15524
  return searchModalComponent(...args);
15378
15525
  }, {
15379
- search_field_value_: state_.field_value,
15526
+ search_field_value_: search_field_value_.value_,
15527
+ get_search_page_input_element_: () => $2c61e4cd8229c49a$export$dde08b2dca8cc1ce.get(this)?.search_page_input_element_,
15380
15528
  get_search_query_: get_search_query_,
15381
15529
  search_query_url_param_name_: search_query_url_param_name_,
15382
15530
  previous_searches_: previous_searches,
@@ -15524,6 +15672,7 @@ function $2c61e4cd8229c49a$export$f2dc7e4e4aa11abb(props) {
15524
15672
  const {
15525
15673
  state_: state_
15526
15674
  } = shared_properties;
15675
+ let registered_input_element;
15527
15676
  const grid_spacing_override = $gVhhF$solidjs.createMemo(() => {
15528
15677
  const {
15529
15678
  grid_spacing: grid_spacing
@@ -15552,7 +15701,7 @@ function $2c61e4cd8229c49a$export$f2dc7e4e4aa11abb(props) {
15552
15701
  min_products_to_fetch_: $2c61e4cd8229c49a$var$min_products_to_fetch_,
15553
15702
  local_filter_cache_: state_.local_filter_cache,
15554
15703
  content_search_enabled_: () => depict_search.enable_content_search ?? $2c61e4cd8229c49a$var$content_search_default,
15555
- search_field_value_: state_.field_value,
15704
+ search_field_value_: shared_properties.search_field_value_,
15556
15705
  get_search_query_: shared_properties.get_search_query_,
15557
15706
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
15558
15707
  open_modal_: (...args) => depict_search.modal_open = args,
@@ -15560,6 +15709,16 @@ function $2c61e4cd8229c49a$export$f2dc7e4e4aa11abb(props) {
15560
15709
  modalVersionUsed_: shared_properties.modalVersionUsed_,
15561
15710
  showSliderArrow_: () => props.showSliderArrow_,
15562
15711
  i18n_: shared_properties.i18n_,
15712
+ inputFieldRef_: input_element => {
15713
+ const shared_info_right_now = $2c61e4cd8229c49a$export$dde08b2dca8cc1ce.get(depict_search);
15714
+ if (!shared_info_right_now) return;
15715
+ if (input_element === undefined && shared_info_right_now.search_page_input_element_ !== registered_input_element) return;
15716
+ registered_input_element = input_element;
15717
+ $2c61e4cd8229c49a$export$dde08b2dca8cc1ce.set(depict_search, {
15718
+ ...shared_info_right_now,
15719
+ search_page_input_element_: input_element
15720
+ });
15721
+ },
15563
15722
  modalAlignmentSignalsRef_: style => {
15564
15723
  const shared_info_right_now = $2c61e4cd8229c49a$export$dde08b2dca8cc1ce.get(depict_search);
15565
15724
  if (!shared_info_right_now) return;
@@ -15910,7 +16069,7 @@ function $c0a0659cf97e8eb2$export$316f6f283ae64765(props) {
15910
16069
  return shared_properties.BackIcon_;
15911
16070
  },
15912
16071
  get search_field_value_() {
15913
- return shared_properties.state_.field_value;
16072
+ return shared_properties.search_field_value_;
15914
16073
  },
15915
16074
  get submit_query_() {
15916
16075
  return shared_properties.configured_submit_query_;
@@ -15953,7 +16112,7 @@ function $c0a0659cf97e8eb2$export$316f6f283ae64765(props) {
15953
16112
  return shared_properties.BackIcon_;
15954
16113
  },
15955
16114
  get search_field_value_() {
15956
- return shared_properties.state_.field_value;
16115
+ return shared_properties.search_field_value_;
15957
16116
  },
15958
16117
  get submit_query_() {
15959
16118
  return shared_properties.configured_submit_query_;
package/latest/index.d.ts CHANGED
@@ -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.10.18";
14
+ export const version = "4.10.20";
15
15
  /**
16
16
  * Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
17
17
  */
@@ -713,6 +713,8 @@ declare function RawSearchModalV2<InputDisplay extends Display, OutputDisplay ex
713
713
  search_query_url_param_name_,
714
714
  previous_searches_,
715
715
  close_modal_,
716
+ set_focus_target_after_close_,
717
+ get_search_page_input_element_,
716
718
  alignmentSignals_,
717
719
  depict_api_,
718
720
  merchant_,
@@ -743,12 +745,14 @@ declare function RawSearchModalV2<InputDisplay extends Display, OutputDisplay ex
743
745
  search_query_url_param_name_: string;
744
746
  previous_searches_: Signal<string[]>;
745
747
  close_modal_: VoidFunction;
748
+ set_focus_target_after_close_: (get_target: (() => HTMLElement | undefined) | undefined) => void;
749
+ get_search_page_input_element_: () => HTMLInputElement | undefined;
746
750
  alignmentSignals_?: ModalAlignmentSignals;
747
751
  depict_api_: DepictAPI<InputDisplay, OutputDisplay>;
748
752
  clear_filters_: (user_triggered: boolean) => void;
749
753
  merchant_: Accessor<string>;
750
754
  market_: Accessor<string>;
751
- submit_query_: (new_query?: string) => void;
755
+ submit_query_: (new_query?: string, before_navigate_?: VoidFunction) => Promise<boolean>;
752
756
  class_list_?: Accessor<Record<string, boolean>>;
753
757
  url_transformer_?: (url_object: URL) => unknown;
754
758
  disable_scrolling_?: boolean;
@@ -785,6 +789,8 @@ declare function RawClassicSearchModal({
785
789
  search_query_url_param_name_,
786
790
  previous_searches_,
787
791
  close_modal_,
792
+ set_focus_target_after_close_,
793
+ get_search_page_input_element_,
788
794
  depict_api_,
789
795
  merchant_,
790
796
  market_,
@@ -810,11 +816,13 @@ declare function RawClassicSearchModal({
810
816
  search_query_url_param_name_: string;
811
817
  previous_searches_: Signal<string[]>;
812
818
  close_modal_: VoidFunction;
819
+ set_focus_target_after_close_: (get_target: (() => HTMLElement | undefined) | undefined) => void;
820
+ get_search_page_input_element_: () => HTMLInputElement | undefined;
813
821
  depict_api_: DepictAPI<any>;
814
822
  clear_filters_: (user_triggered: boolean) => void;
815
823
  merchant_: Accessor<string>;
816
824
  market_: Accessor<string>;
817
- submit_query_: (new_query?: string) => void;
825
+ submit_query_: (new_query?: string, before_navigate_?: VoidFunction) => Promise<boolean>;
818
826
  class_list_?: Accessor<Record<string, boolean>>;
819
827
  url_transformer_?: (url_object: URL) => unknown;
820
828
  disable_scrolling_?: boolean;
@@ -1038,6 +1046,7 @@ export function general_modal_abstraction<StaticOptions extends {
1038
1046
  close_modal_: VoidFunction;
1039
1047
  open_modal_: (extra_options_for_modal?: ExtraOptionsProvidedOnOpen, on_dispose?: VoidFunction) => void;
1040
1048
  register_closing_animation_: (animation: () => Promise<any>) => void;
1049
+ set_focus_target_after_close_: (get_target: (() => HTMLElement | undefined) | undefined) => void;
1041
1050
  }) => Node_Array, modal_fn_opts: StaticOptions, parent?: HTMLElement | ShadowRoot): Promise<{
1042
1051
  open_modal_: (extra_options_for_modal?: any, on_dispose?: VoidFunction | undefined) => Promise<void | undefined>;
1043
1052
  close_modal_: () => void | undefined;