@depict-ai/ui 4.10.19 → 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.
@@ -7,7 +7,7 @@ import { createStore as $i7OB2$createStore, reconcile as $i7OB2$reconcile } from
7
7
  /*! Depict.ai search and product listing SDK */
8
8
  import { register_es_version } from "../../multi_import_deduplicator.mjs";
9
9
  register_es_version("ui", "latest");
10
- const $ec291e0010116877$export$83d89fbfd8236492 = "4.10.19";
10
+ const $ec291e0010116877$export$83d89fbfd8236492 = "4.10.20";
11
11
  function $dc9262ef6f786812$export$d9f36cf74e24d595(media_query) {
12
12
  const signal = $i7OB2$createSignal(false);
13
13
  $i7OB2$onCleanup($i7OB2$javascript_media_query(media_query, ({
@@ -2049,6 +2049,7 @@ async function $194bd6b8e4c59830$export$79b1565500412d9b(search_modal, modal_fn_
2049
2049
  const modal_els = $i7OB2$createRoot(dispose => {
2050
2050
  let closing_animation;
2051
2051
  let animation_started;
2052
+ let focus_target_after_close;
2052
2053
  dispose_and_remove = () => {
2053
2054
  const actually_close = () => {
2054
2055
  dispose();
@@ -2067,11 +2068,19 @@ async function $194bd6b8e4c59830$export$79b1565500412d9b(search_modal, modal_fn_
2067
2068
  activeElement?.blur?.();
2068
2069
  el.remove();
2069
2070
  });
2070
- if (should_restore_focus && element_focused_before_open?.isConnected) {
2071
+ const requested_focus_target = focus_target_after_close?.();
2072
+ if (should_restore_focus && (requested_focus_target?.isConnected || element_focused_before_open?.isConnected)) {
2071
2073
  restoring_focus = true;
2072
2074
  try {
2073
2075
  // preventScroll so this can't re-introduce the safari page-jump the blur() above works around
2074
- element_focused_before_open.focus({
2076
+ let focused = false;
2077
+ if (requested_focus_target?.isConnected) {
2078
+ requested_focus_target.focus({
2079
+ preventScroll: true
2080
+ });
2081
+ focused = requested_focus_target.getRootNode().activeElement === requested_focus_target;
2082
+ }
2083
+ if (!focused && element_focused_before_open?.isConnected) element_focused_before_open.focus({
2075
2084
  preventScroll: true
2076
2085
  });
2077
2086
  } finally {
@@ -2092,7 +2101,8 @@ async function $194bd6b8e4c59830$export$79b1565500412d9b(search_modal, modal_fn_
2092
2101
  ...extra_options_for_modal,
2093
2102
  close_modal_: close_modal_,
2094
2103
  open_modal_: open_modal_,
2095
- register_closing_animation_: animation => closing_animation = animation
2104
+ register_closing_animation_: animation => closing_animation = animation,
2105
+ set_focus_target_after_close_: get_target => focus_target_after_close = get_target
2096
2106
  });
2097
2107
  });
2098
2108
  body.append(...modal_els);
@@ -8738,6 +8748,7 @@ function $081752ca508a876f$export$f7658c347b037c3f(props = {}) {
8738
8748
  var $5285d2814d0fac0c$var$_tmpl$ = ["<div", ' style="', '" class="spacer"></div>'],
8739
8749
  $5285d2814d0fac0c$var$_tmpl$2 = ['<div class="field"><!--$-->', "<!--/-->", "<!--$-->", "<!--/--></div>"],
8740
8750
  $5285d2814d0fac0c$var$_tmpl$3 = ["<button", ' class="submit major" type="button"', ">", "</button>"];
8751
+ const $5285d2814d0fac0c$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"]);
8741
8752
  function $5285d2814d0fac0c$export$b94867ecbd698f21({
8742
8753
  search_field_value_: [searchFieldValue, setSearchFieldValue],
8743
8754
  input_field_ref_: input_field_ref_,
@@ -8879,6 +8890,31 @@ function $512b994d501f412b$export$93d9bfd0c9c1a5b8(close_modal, search_query_url
8879
8890
  }
8880
8891
  })();
8881
8892
  }
8893
+ function $8b2ecf1919837863$export$9e9e2ae069cf2fe1({
8894
+ props_search_field_value_: props_search_field_value_,
8895
+ props_submit_query_: props_submit_query_,
8896
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
8897
+ set_focus_target_after_close_: set_focus_target_after_close_,
8898
+ get_search_page_input_element_: get_search_page_input_element_
8899
+ }) {
8900
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $i7OB2$createSignal("") : props_search_field_value_;
8901
+ let submits_in_flight = 0;
8902
+ const submit_query_ = async (new_query = $i7OB2$untrack(search_field_value_[0])) => {
8903
+ submits_in_flight++;
8904
+ try {
8905
+ return await props_submit_query_(new_query, () => set_focus_target_after_close_(get_search_page_input_element_));
8906
+ } finally {
8907
+ submits_in_flight--;
8908
+ }
8909
+ };
8910
+ if (dont_sync_search_field_value_except_on_submit_) $i7OB2$createEffect($i7OB2$on(search_field_value_[0], value => submits_in_flight > 0 && props_search_field_value_[1](value), {
8911
+ defer: true
8912
+ }));
8913
+ return {
8914
+ search_field_value_: search_field_value_,
8915
+ submit_query_: submit_query_
8916
+ };
8917
+ }
8882
8918
  var $42912431795f188e$var$_tmpl$ = ["<div", ' class="discover-more"><button class="major" type="button">', "</button></div>"],
8883
8919
  $42912431795f188e$var$_tmpl$2 = ["<b", ">", "</b>"],
8884
8920
  $42912431795f188e$var$_tmpl$3 = ["<div", ' class="', '"><div class="', '" 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><!--$-->", "<!--/--></div>"],
@@ -8892,6 +8928,8 @@ function $42912431795f188e$var$RawClassicSearchModal({
8892
8928
  search_query_url_param_name_: search_query_url_param_name_,
8893
8929
  previous_searches_: previous_searches_,
8894
8930
  close_modal_: close_modal_,
8931
+ set_focus_target_after_close_: set_focus_target_after_close_,
8932
+ get_search_page_input_element_: get_search_page_input_element_,
8895
8933
  depict_api_: depict_api_,
8896
8934
  merchant_: merchant_,
8897
8935
  market_: market_,
@@ -8916,15 +8954,16 @@ function $42912431795f188e$var$RawClassicSearchModal({
8916
8954
  // 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.
8917
8955
  // 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
8918
8956
  // Basically the UI signals that the button that opens the modal starts a new search.
8919
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $i7OB2$createSignal("") : props_search_field_value;
8920
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($i7OB2$untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
8921
- : undefined;
8922
- const submit_query_ = (...args) => {
8923
- // 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
8924
- // It will write the old one back and then write the new one after submit
8925
- propagate_search_field_value_back?.();
8926
- return props_submit_query(...args);
8927
- };
8957
+ const {
8958
+ search_field_value_: search_field_value_,
8959
+ submit_query_: submit_query_
8960
+ } = $8b2ecf1919837863$export$9e9e2ae069cf2fe1({
8961
+ props_search_field_value_: props_search_field_value,
8962
+ props_submit_query_: props_submit_query,
8963
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
8964
+ set_focus_target_after_close_: set_focus_target_after_close_,
8965
+ get_search_page_input_element_: get_search_page_input_element_
8966
+ });
8928
8967
  const [input_field, set_input_field] = $i7OB2$createSignal();
8929
8968
  const [get_search_field_value_] = search_field_value_;
8930
8969
  // Search field alignment unused in ClassicSearchModal since the search field spans the whole modal
@@ -9522,6 +9561,8 @@ function $500a16dd18ee5a71$var$RawSearchModalV2({
9522
9561
  search_query_url_param_name_: search_query_url_param_name_,
9523
9562
  previous_searches_: previous_searches_,
9524
9563
  close_modal_: close_modal_,
9564
+ set_focus_target_after_close_: set_focus_target_after_close_,
9565
+ get_search_page_input_element_: get_search_page_input_element_,
9525
9566
  alignmentSignals_: alignmentSignals_,
9526
9567
  depict_api_: depict_api_,
9527
9568
  merchant_: merchant_,
@@ -9552,15 +9593,16 @@ function $500a16dd18ee5a71$var$RawSearchModalV2({
9552
9593
  // 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.
9553
9594
  // 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
9554
9595
  // Basically the UI signals that the button that opens the modal starts a new search.
9555
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $i7OB2$createSignal("") : props_search_field_value;
9556
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($i7OB2$untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
9557
- : undefined;
9558
- const submit_query_ = (...args) => {
9559
- // 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
9560
- // It will write the old one back and then write the new one after submit
9561
- propagate_search_field_value_back?.();
9562
- return props_submit_query(...args);
9563
- };
9596
+ const {
9597
+ search_field_value_: search_field_value_,
9598
+ submit_query_: submit_query_
9599
+ } = $8b2ecf1919837863$export$9e9e2ae069cf2fe1({
9600
+ props_search_field_value_: props_search_field_value,
9601
+ props_submit_query_: props_submit_query,
9602
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
9603
+ set_focus_target_after_close_: set_focus_target_after_close_,
9604
+ get_search_page_input_element_: get_search_page_input_element_
9605
+ });
9564
9606
  const [input_field, set_input_field] = $i7OB2$createSignal();
9565
9607
  const [searching_for_value_, set_searching_for_value_] = $i7OB2$createSignal();
9566
9608
  const [show_stale_content_results_, set_show_stale_content_results_] = $i7OB2$createSignal(false);
@@ -11388,11 +11430,12 @@ function $21f51c14cb3f586f$export$84bba84a7b837187(read_search_query) {
11388
11430
  async function $bfd908d13d90934c$export$e16630ecb9644a1c({
11389
11431
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
11390
11432
  search_param_name_: search_param_name_,
11391
- set_search_field_value_: set_search_field_value_,
11433
+ search_field_value_: search_field_value_,
11392
11434
  get_search_query_: get_search_query_,
11393
11435
  url_transformer_: url_transformer_,
11394
11436
  router_: router_,
11395
11437
  after_submit_: after_submit_,
11438
+ before_navigate_: before_navigate_,
11396
11439
  get_new_query: get_new_query
11397
11440
  }) {
11398
11441
  const new_search_query = get_new_query();
@@ -11400,21 +11443,89 @@ async function $bfd908d13d90934c$export$e16630ecb9644a1c({
11400
11443
  if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
11401
11444
  // don't push a history entry / re-search if someone submits a search again
11402
11445
  // do close the modal though
11446
+ search_field_value_.settle_(new_search_query);
11403
11447
  on_submit_with_unchanged_value_?.();
11404
- return;
11448
+ return false;
11405
11449
  }
11406
- set_search_field_value_(previous_query); // restore the value to the previous query since this one goes to the new history entry
11407
11450
  const target_url = new URL(location.href);
11408
11451
  url_transformer_?.(target_url);
11409
11452
  target_url.searchParams.set(search_param_name_, new_search_query);
11410
- await router_.navigate_.go_to_({
11411
- new_url_: target_url,
11412
- is_replace_: false,
11413
- force_spa_navigation_: true
11414
- });
11415
- set_search_field_value_(new_search_query);
11453
+ const end_submit = search_field_value_.begin_submit_(new_search_query, previous_query);
11454
+ before_navigate_?.();
11455
+ let landed;
11456
+ try {
11457
+ await router_.navigate_.go_to_({
11458
+ new_url_: target_url,
11459
+ is_replace_: false,
11460
+ force_spa_navigation_: true
11461
+ });
11462
+ } finally {
11463
+ landed = end_submit();
11464
+ }
11465
+ if (!landed) return false;
11416
11466
  scrollTo(0, 0);
11417
11467
  after_submit_?.();
11468
+ return true;
11469
+ }
11470
+ function $a578366fad1bde47$export$d13a185c53aa5edf(persisted_, get_search_query_) {
11471
+ const [get_persisted, set_persisted] = persisted_;
11472
+ const [get_submitting, set_submitting] = $i7OB2$createSignal();
11473
+ const get_value = $i7OB2$createMemo(() => get_submitting() ?? get_persisted());
11474
+ const set_value = value => {
11475
+ const new_value = typeof value === "function" ? value($i7OB2$untrack(get_value)) : value;
11476
+ if ($i7OB2$untrack(get_submitting) === undefined) set_persisted(new_value);else set_submitting(new_value);
11477
+ return new_value;
11478
+ };
11479
+ let current_submit;
11480
+ const end_submit = landed => {
11481
+ current_submit.landed_ = landed;
11482
+ current_submit = undefined;
11483
+ $i7OB2$batch(() => {
11484
+ const submitting = $i7OB2$untrack(get_submitting);
11485
+ set_submitting(undefined);
11486
+ if (landed && submitting !== undefined) set_persisted(submitting);
11487
+ });
11488
+ };
11489
+ const abort_on_popstate = what_happened => {
11490
+ if (what_happened === "popstate" && current_submit) end_submit(false);
11491
+ };
11492
+ (0, $i7OB2$instant_exec_on_suspect_history_change).add(abort_on_popstate);
11493
+ $i7OB2$onCleanup(() => (0, $i7OB2$instant_exec_on_suspect_history_change).delete(abort_on_popstate));
11494
+ $i7OB2$createEffect($i7OB2$on(get_search_query_, query => {
11495
+ const token = current_submit;
11496
+ if (!token || query !== token.query_) return;
11497
+ queueMicrotask(() => {
11498
+ if (current_submit === token) end_submit(true);
11499
+ });
11500
+ }, {
11501
+ defer: true
11502
+ }));
11503
+ const begin_submit_ = (submitted_query, query_of_current_history_entry) => {
11504
+ const token = current_submit = {
11505
+ query_: submitted_query,
11506
+ landed_: false
11507
+ };
11508
+ $i7OB2$batch(() => {
11509
+ set_submitting(submitted_query);
11510
+ set_persisted(query_of_current_history_entry);
11511
+ });
11512
+ return () => {
11513
+ if (current_submit === token) end_submit(true);
11514
+ return token.landed_;
11515
+ };
11516
+ };
11517
+ const settle_ = query => {
11518
+ if (current_submit) return;
11519
+ $i7OB2$batch(() => {
11520
+ set_submitting(undefined);
11521
+ set_persisted(query);
11522
+ });
11523
+ };
11524
+ return {
11525
+ value_: [get_value, set_value],
11526
+ begin_submit_: begin_submit_,
11527
+ settle_: settle_
11528
+ };
11418
11529
  }
11419
11530
  function $d68658730065de95$export$181cceed5c91919e(callback, alsoRaF, passiveListener) {
11420
11531
  let aligned_this_microtask = false;
@@ -12050,6 +12161,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
12050
12161
  scroll_restoration_data_: scroll_restoration_data_,
12051
12162
  product_card_template_: product_card_template_,
12052
12163
  modalAlignmentSignalsRef_: modalAlignmentSignalsRef_,
12164
+ inputFieldRef_: inputFieldRef_,
12053
12165
  router_: router_,
12054
12166
  content_results_rows_: content_results_rows_,
12055
12167
  content_layout_options_: content_layout_options_,
@@ -12229,6 +12341,8 @@ function $7097477c78a89208$export$a54ec244c8863715({
12229
12341
  if (!search_field) break add_input_field;
12230
12342
  setModalBodyStyle({});
12231
12343
  modalAlignmentSignalsRef_?.(alignmentSignals_);
12344
+ inputFieldRef_?.(input_element);
12345
+ $i7OB2$onCleanup(() => inputFieldRef_?.(undefined));
12232
12346
  const [pollAlignment, setPollAlignment_] = $i7OB2$createSignal(false);
12233
12347
  const align_position = $i7OB2$catchify1((0, $b6d5529b253681aa$export$b3ad617e9036868))(alignmentSignals_, search_field, (0, $b6d5529b253681aa$export$3f238c96c45e6cc6) | (0, $b6d5529b253681aa$export$7895aadd1956b1c7) | (modalVersionUsed_ === 1 ? (0, $b6d5529b253681aa$export$902f8b4a7dae5d78) : (0, $b6d5529b253681aa$export$6060bc6bee850eb6) | (0, $b6d5529b253681aa$export$5097308c5200105a)), true, pollAlignment);
12234
12348
  div_with_field_class.addEventListener("click", $i7OB2$catchify1(e => {
@@ -12530,14 +12644,16 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
12530
12644
  set_search_content_results_rows((0, $49de9d31aeea1b5e$export$70ceae36059a1036));
12531
12645
  }; // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
12532
12646
  const on_submit_with_unchanged_value_ = () => this.modal_open = false;
12533
- const [get_search_field_value_, set_search_field_value_] = state_.field_value;
12534
- const configured_submit_query_ = new_query => $bfd908d13d90934c$export$e16630ecb9644a1c({
12647
+ const search_field_value_ = $a578366fad1bde47$export$d13a185c53aa5edf(state_.field_value, get_search_query_);
12648
+ const [get_search_field_value_] = search_field_value_.value_;
12649
+ const configured_submit_query_ = (new_query, before_navigate_) => $bfd908d13d90934c$export$e16630ecb9644a1c({
12535
12650
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
12536
- set_search_field_value_: set_search_field_value_,
12651
+ search_field_value_: search_field_value_,
12537
12652
  get_search_query_: get_search_query_,
12538
12653
  search_param_name_: search_query_url_param_name_,
12539
12654
  after_submit_: after_submit_,
12540
- get_new_query: () => new_query || $i7OB2$untrack(get_search_field_value_),
12655
+ before_navigate_: before_navigate_,
12656
+ get_new_query: () => new_query ?? $i7OB2$untrack(get_search_field_value_),
12541
12657
  url_transformer_: url_transformer,
12542
12658
  router_: this.#router
12543
12659
  });
@@ -12556,6 +12672,7 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
12556
12672
  search_query_url_param_name_: search_query_url_param_name_,
12557
12673
  reset_history_state_: reset_history_state_,
12558
12674
  state_: state_,
12675
+ search_field_value_: search_field_value_.value_,
12559
12676
  router_: this.#router,
12560
12677
  url_transformer_: url_transformer,
12561
12678
  depict_api_: depict_api_,
@@ -12579,7 +12696,8 @@ class $806c97b931758897$export$ac6237957a15b3f0 {
12579
12696
  $i7OB2$onCleanup(() => this.modal_open = false);
12580
12697
  return searchModalComponent(...args);
12581
12698
  }, {
12582
- search_field_value_: state_.field_value,
12699
+ search_field_value_: search_field_value_.value_,
12700
+ get_search_page_input_element_: () => $806c97b931758897$export$dde08b2dca8cc1ce.get(this)?.search_page_input_element_,
12583
12701
  get_search_query_: get_search_query_,
12584
12702
  search_query_url_param_name_: search_query_url_param_name_,
12585
12703
  previous_searches_: previous_searches,
@@ -12727,6 +12845,7 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
12727
12845
  const {
12728
12846
  state_: state_
12729
12847
  } = shared_properties;
12848
+ let registered_input_element;
12730
12849
  const grid_spacing_override = $i7OB2$createMemo(() => {
12731
12850
  const {
12732
12851
  grid_spacing: grid_spacing
@@ -12755,7 +12874,7 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
12755
12874
  min_products_to_fetch_: $806c97b931758897$var$min_products_to_fetch_,
12756
12875
  local_filter_cache_: state_.local_filter_cache,
12757
12876
  content_search_enabled_: () => depict_search.enable_content_search ?? $806c97b931758897$var$content_search_default,
12758
- search_field_value_: state_.field_value,
12877
+ search_field_value_: shared_properties.search_field_value_,
12759
12878
  get_search_query_: shared_properties.get_search_query_,
12760
12879
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
12761
12880
  open_modal_: (...args) => depict_search.modal_open = args,
@@ -12763,6 +12882,16 @@ function $806c97b931758897$export$f2dc7e4e4aa11abb(props) {
12763
12882
  modalVersionUsed_: shared_properties.modalVersionUsed_,
12764
12883
  showSliderArrow_: () => props.showSliderArrow_,
12765
12884
  i18n_: shared_properties.i18n_,
12885
+ inputFieldRef_: input_element => {
12886
+ const shared_info_right_now = $806c97b931758897$export$dde08b2dca8cc1ce.get(depict_search);
12887
+ if (!shared_info_right_now) return;
12888
+ if (input_element === undefined && shared_info_right_now.search_page_input_element_ !== registered_input_element) return;
12889
+ registered_input_element = input_element;
12890
+ $806c97b931758897$export$dde08b2dca8cc1ce.set(depict_search, {
12891
+ ...shared_info_right_now,
12892
+ search_page_input_element_: input_element
12893
+ });
12894
+ },
12766
12895
  modalAlignmentSignalsRef_: style => {
12767
12896
  const shared_info_right_now = $806c97b931758897$export$dde08b2dca8cc1ce.get(depict_search);
12768
12897
  if (!shared_info_right_now) return;
@@ -13113,7 +13242,7 @@ function $58b3487626e85ece$export$316f6f283ae64765(props) {
13113
13242
  return shared_properties.BackIcon_;
13114
13243
  },
13115
13244
  get search_field_value_() {
13116
- return shared_properties.state_.field_value;
13245
+ return shared_properties.search_field_value_;
13117
13246
  },
13118
13247
  get submit_query_() {
13119
13248
  return shared_properties.configured_submit_query_;
@@ -13156,7 +13285,7 @@ function $58b3487626e85ece$export$316f6f283ae64765(props) {
13156
13285
  return shared_properties.BackIcon_;
13157
13286
  },
13158
13287
  get search_field_value_() {
13159
- return shared_properties.state_.field_value;
13288
+ return shared_properties.search_field_value_;
13160
13289
  },
13161
13290
  get submit_query_() {
13162
13291
  return shared_properties.configured_submit_query_;