@depict-ai/ui 4.10.19 → 4.10.21

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/ES10/index.cjs CHANGED
@@ -115,7 +115,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
115
115
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
116
116
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
117
117
  /*! Depict.ai search and product listing SDK */
118
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.19";
118
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.10.21";
119
119
  function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
120
120
  const signal = $52FdA$solidjs.createSignal(false);
121
121
  $52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.javascript_media_query(media_query, _ref => {
@@ -2678,6 +2678,63 @@ function $c5842bdb10e57229$export$fecbb157621501bd(_ref) {
2678
2678
  return outmost_element;
2679
2679
  }
2680
2680
  $52FdA$solidjsweb.delegateEvents(["click"]);
2681
+
2682
+ /**
2683
+ * `HTMLElement.focus()` is a **silent no-op** on an element that is not being rendered
2684
+ * (`display: none`, `visibility: hidden`, a collapsed menu). Nothing throws, focus simply
2685
+ * stays where it was, so a caller that does not check believes it restored focus when it
2686
+ * left it on `<body>` — which puts the keyboard user back at the top of the document.
2687
+ *
2688
+ * That is reachable whenever the element which opened a modal stops being rendered while the
2689
+ * modal is open, and the common way for that to happen is the responsive-duplicate header:
2690
+ * a theme renders the same search trigger twice, once for desktop and once for mobile, and
2691
+ * hides one at the current breakpoint. Open the modal from the desktop trigger, cross the
2692
+ * breakpoint (rotate a tablet, resize a window), close the modal, and the remembered trigger
2693
+ * is still `isConnected` but no longer rendered. Verified against a live merchant storefront
2694
+ * on 4.10.19.
2695
+ *
2696
+ * So: verify that focus landed, and when it did not, look for a rendered twin of the same
2697
+ * control — the other half of the responsive pair — and use that instead.
2698
+ */ /**
2699
+ * An element can only take focus if it is actually being rendered.
2700
+ *
2701
+ * Injectable because it is the one part of this module that needs a layout engine: jsdom
2702
+ * reports no client rects for anything, so the specs pass their own predicate to exercise the
2703
+ * matching rules. The real predicate is only exercised in a browser.
2704
+ */
2705
+ const $1573c1a34371380a$export$e0652711c614c755 = element => !!element.getClientRects().length;
2706
+ /**
2707
+ * `document.activeElement` is the outermost shadow host when focus is inside a shadow tree,
2708
+ * so ask the element's own root rather than the document — matching how the rest of
2709
+ * modal_opener treats shadow-mounted modals.
2710
+ */
2711
+ const $1573c1a34371380a$var$has_focus = element => element.getRootNode().activeElement === element;
2712
+ /**
2713
+ * The accessible-name-ish identity we match twins on. Deliberately narrow: an explicit label
2714
+ * or the trimmed text. Two controls that share a tag and this string are the same control
2715
+ * rendered twice, which is exactly the responsive-duplicate case.
2716
+ */
2717
+ const $1573c1a34371380a$var$identity_of = element => (element.getAttribute("aria-label") || element.getAttribute("title") || element.textContent || "").trim().replace(/\s+/g, " ");
2718
+ function $1573c1a34371380a$export$5800d9d535a06e96(element) {
2719
+ let rendered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $1573c1a34371380a$export$e0652711c614c755;
2720
+ const identity = $1573c1a34371380a$var$identity_of(element);
2721
+ if (!identity) return; // nothing to match on — an icon-only button with no label
2722
+ const twins = [...element.ownerDocument.querySelectorAll(element.localName)].filter(candidate => candidate !== element && rendered(candidate) && $1573c1a34371380a$var$identity_of(candidate) === identity);
2723
+ return twins.length === 1 ? twins[0] : undefined;
2724
+ }
2725
+ function $1573c1a34371380a$export$51461d633c351649(element) {
2726
+ let rendered = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $1573c1a34371380a$export$e0652711c614c755;
2727
+ element.focus({
2728
+ preventScroll: true
2729
+ });
2730
+ if ($1573c1a34371380a$var$has_focus(element)) return true;
2731
+ const twin = $1573c1a34371380a$export$5800d9d535a06e96(element, rendered);
2732
+ if (!twin) return false;
2733
+ twin.focus({
2734
+ preventScroll: true
2735
+ });
2736
+ return $1573c1a34371380a$var$has_focus(twin);
2737
+ }
2681
2738
  async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_opts, parent) {
2682
2739
  const body = parent || document.body || (await (0, $52FdA$depictaiutilishared.observer).wait_for_element("body"));
2683
2740
  let dispose_and_remove;
@@ -2709,8 +2766,10 @@ async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_
2709
2766
  const modal_els = $52FdA$solidjs.createRoot(dispose => {
2710
2767
  let closing_animation;
2711
2768
  let animation_started;
2769
+ let focus_target_after_close;
2712
2770
  dispose_and_remove = () => {
2713
2771
  const actually_close = () => {
2772
+ var _focus_target_after_c;
2714
2773
  dispose();
2715
2774
  on_dispose === null || on_dispose === void 0 || on_dispose();
2716
2775
  const {
@@ -2729,13 +2788,24 @@ async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_
2729
2788
  }
2730
2789
  el.remove();
2731
2790
  });
2732
- if (should_restore_focus && element_focused_before_open !== null && element_focused_before_open !== void 0 && element_focused_before_open.isConnected) {
2791
+ const requested_focus_target = (_focus_target_after_c = focus_target_after_close) === null || _focus_target_after_c === void 0 ? void 0 : _focus_target_after_c();
2792
+ if (should_restore_focus && (requested_focus_target !== null && requested_focus_target !== void 0 && requested_focus_target.isConnected || element_focused_before_open !== null && element_focused_before_open !== void 0 && element_focused_before_open.isConnected)) {
2733
2793
  restoring_focus = true;
2734
2794
  try {
2735
2795
  // preventScroll so this can't re-introduce the safari page-jump the blur() above works around
2736
- element_focused_before_open.focus({
2737
- preventScroll: true
2738
- });
2796
+ let focused = false;
2797
+ if (requested_focus_target !== null && requested_focus_target !== void 0 && requested_focus_target.isConnected) {
2798
+ requested_focus_target.focus({
2799
+ preventScroll: true
2800
+ });
2801
+ focused = requested_focus_target.getRootNode().activeElement === requested_focus_target;
2802
+ }
2803
+ if (!focused && element_focused_before_open !== null && element_focused_before_open !== void 0 && element_focused_before_open.isConnected)
2804
+ // restore_focus_to rather than a bare focus(): the remembered trigger can be
2805
+ // connected but no longer rendered (a responsive-duplicate header whose other
2806
+ // half is showing now), and focus() on an unrendered element silently does
2807
+ // nothing, leaving the keyboard user at the top of the page.
2808
+ $1573c1a34371380a$export$51461d633c351649(element_focused_before_open);
2739
2809
  } finally {
2740
2810
  // Cleared on a task instead of synchronously in case a browser delivers the focus event async
2741
2811
  setTimeout(() => restoring_focus = false, 0);
@@ -2755,7 +2825,8 @@ async function $4cf7d9829d60d844$export$79b1565500412d9b(search_modal, modal_fn_
2755
2825
  ...extra_options_for_modal,
2756
2826
  close_modal_: close_modal_,
2757
2827
  open_modal_: open_modal_,
2758
- register_closing_animation_: animation => closing_animation = animation
2828
+ register_closing_animation_: animation => closing_animation = animation,
2829
+ set_focus_target_after_close_: get_target => focus_target_after_close = get_target
2759
2830
  });
2760
2831
  });
2761
2832
  body.append(...modal_els);
@@ -9777,20 +9848,28 @@ function $73014ff36186a4dd$var$_classPrivateMethodGet(receiver, privateSet, fn)
9777
9848
  }
9778
9849
  var $73014ff36186a4dd$var$_throwing_on_navigation = /*#__PURE__*/new WeakSet();
9779
9850
  var $73014ff36186a4dd$var$_get_navigation_happened_promise = /*#__PURE__*/new WeakSet();
9851
+ var $73014ff36186a4dd$var$_watch_for_navigation_to_same_href = /*#__PURE__*/new WeakSet();
9780
9852
  class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
9781
9853
  /**
9782
9854
  * Function that will be called when we want to navigate, or a string saying it's not an SPA. You can change this OTG
9783
9855
  */ /**
9784
9856
  * We store listing_id in history.state and do operate on this both here and in js-ui, this is the key to be used which js-ui provides
9785
9857
  */ /**
9786
- * Vue has async router that needs to be awaited (it navigates after a microtask)
9787
- * This standardises waiting for all kinds of routers
9788
- */
9858
+ * Called when a go_to_ didn't change location.href, for example when following a link to the page one is already on. href_change_ipns stays silent then, so whoever waits for a href change to react to a navigation has to listen here too
9859
+ */ /**
9860
+ * Vue has async router that needs to be awaited (it navigates after a microtask)
9861
+ * This standardises waiting for all kinds of routers
9862
+ */ /**
9863
+ * Calls navigation_to_same_href_listeners_ if the navigation we're about to request ends on the href we're already on
9864
+ * @returns function to stop watching, call it when the navigation failed
9865
+ */
9789
9866
  constructor(on_navigation, listing_query_state_key) {
9867
+ $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_watch_for_navigation_to_same_href);
9790
9868
  $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_get_navigation_happened_promise);
9791
9869
  $73014ff36186a4dd$var$_classPrivateMethodInitSpec(this, $73014ff36186a4dd$var$_throwing_on_navigation);
9792
9870
  $parcel$interopDefault($52FdA$babelruntimehelpersdefineProperty)(this, "on_navigation_", void 0);
9793
9871
  $parcel$interopDefault($52FdA$babelruntimehelpersdefineProperty)(this, "listing_query_state_key", void 0);
9872
+ $parcel$interopDefault($52FdA$babelruntimehelpersdefineProperty)(this, "navigation_to_same_href_listeners_", new Set());
9794
9873
  $parcel$interopDefault($52FdA$babelruntimehelpersdefineProperty)(this, "navigate_", {
9795
9874
  /**
9796
9875
  * Call this if you *just* want to replace the state object in history.state
@@ -9832,6 +9911,7 @@ class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
9832
9911
  }
9833
9912
  event_ === null || event_ === void 0 || event_.preventDefault();
9834
9913
  const promise = $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_get_navigation_happened_promise, $73014ff36186a4dd$var$_get_navigation_happened_promise2).call(this, true);
9914
+ const stop_watching_for_same_href = $73014ff36186a4dd$var$_classPrivateMethodGet(this, $73014ff36186a4dd$var$_watch_for_navigation_to_same_href, $73014ff36186a4dd$var$_watch_for_navigation_to_same_href2).call(this, new_url_);
9835
9915
  if (force_spa_navigation_ && wants_hard_navigation) {
9836
9916
  // Don't allow hard navigation if we're forcing SPA navigation, which we do for things where PageReplacer can be used for performance
9837
9917
  const new_state = history.state;
@@ -9845,7 +9925,7 @@ class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
9845
9925
  is_replace: is_replace_,
9846
9926
  new_url: new_url_ instanceof URL ? new_url_ : new URL(new_url_, location.href),
9847
9927
  scroll: scroll
9848
- });
9928
+ }, stop_watching_for_same_href);
9849
9929
  await promise;
9850
9930
  })
9851
9931
  });
@@ -9853,15 +9933,16 @@ class $73014ff36186a4dd$export$7e1297a3a19f10d8 {
9853
9933
  this.on_navigation_ = on_navigation;
9854
9934
  }
9855
9935
  }
9856
- function $73014ff36186a4dd$var$_throwing_on_navigation2() {
9936
+ function $73014ff36186a4dd$var$_throwing_on_navigation2(options, on_throw_) {
9857
9937
  const {
9858
9938
  on_navigation_: on_navigation_
9859
9939
  } = this;
9860
9940
  if (typeof on_navigation_ !== "function") throw new Error("on_navigation_ is not a function");
9861
9941
  // make sure that we don't accidentally catchify if the SDK consumer has fucked up
9862
9942
  try {
9863
- return on_navigation_(...arguments);
9943
+ return on_navigation_(options);
9864
9944
  } catch (e) {
9945
+ on_throw_ === null || on_throw_ === void 0 || on_throw_();
9865
9946
  queueMicrotask(() => {
9866
9947
  throw e;
9867
9948
  });
@@ -9878,6 +9959,24 @@ function $73014ff36186a4dd$var$_get_navigation_happened_promise2(is_replace) {
9878
9959
  (0, $52FdA$depictaiutilishared.instant_exec_on_suspect_history_change).add(handler);
9879
9960
  });
9880
9961
  }
9962
+ function $73014ff36186a4dd$var$_watch_for_navigation_to_same_href2(target_url) {
9963
+ const href_before = location.href;
9964
+ const stop_watching = () => {
9965
+ (0, $52FdA$depictaiutilishared.instant_exec_on_suspect_history_change).delete(on_history_change);
9966
+ clearTimeout(timeout);
9967
+ };
9968
+ const notify_if_href_unchanged = $52FdA$depictaiutilishared.catchify(() => {
9969
+ stop_watching();
9970
+ if (location.href !== href_before) return;
9971
+ this.navigation_to_same_href_listeners_.forEach(listener => $52FdA$depictaiutilishared.catchify(listener)());
9972
+ });
9973
+ // The router has acted once it touches history, if the href is still the same then it took us to the page we're on
9974
+ const on_history_change = () => notify_if_href_unchanged();
9975
+ // A router asked to go to the exact href we're on might not touch history at all, so don't wait longer than 500ms for it. For any other target we can't tell a slow navigation from one that goes nowhere, so only stop listening after a while
9976
+ const timeout = target_url.href === href_before ? setTimeout(notify_if_href_unchanged, 500) : setTimeout(stop_watching, 10000);
9977
+ (0, $52FdA$depictaiutilishared.instant_exec_on_suspect_history_change).add(on_history_change);
9978
+ return stop_watching;
9979
+ }
9881
9980
  var $2c920813c92d6987$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<button class="show-more major"type=button>`),
9882
9981
  $2c920813c92d6987$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<h2 class=recs-title>`),
9883
9982
  $2c920813c92d6987$var$_tmpl$3 = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class=recommendation-grid><!$><!/><!$><!/>`);
@@ -11422,6 +11521,7 @@ var $29e5dbeb69da7a36$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<but
11422
11521
  $29e5dbeb69da7a36$var$_tmpl$3 = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class=spacer>`),
11423
11522
  $29e5dbeb69da7a36$var$_tmpl$4 = /*#__PURE__*/$52FdA$solidjsweb.template(`<button class="submit major"type=button>`),
11424
11523
  $29e5dbeb69da7a36$var$_tmpl$5 = /*#__PURE__*/$52FdA$solidjsweb.template(`<div><!$><!/><!$><!/><div class=field><!$><!/><input class=query tabindex=0 enterkeyhint=search><!$><!/></div><!$><!/><!$><!/>`);
11524
+ const $29e5dbeb69da7a36$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"]);
11425
11525
  function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
11426
11526
  let {
11427
11527
  search_field_value_: [searchFieldValue, setSearchFieldValue],
@@ -11604,7 +11704,7 @@ function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
11604
11704
  get onKeyDown() {
11605
11705
  return $52FdA$depictaiutilishared.catchify(e => {
11606
11706
  if (disabled_) {
11607
- if (e.key !== "Tab" && e.key !== "Shift")
11707
+ if (!$29e5dbeb69da7a36$var$keys_not_opening_modal.has(e.key) && !/^F\d{1,2}$/.test(e.key))
11608
11708
  // 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
11609
11709
  input_element.click();
11610
11710
  } else if (e.key === "Enter") {
@@ -11686,11 +11786,17 @@ var $820f2920cc576f7e$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<svg
11686
11786
  function $820f2920cc576f7e$export$8d8893ffd8aca39a() {
11687
11787
  return $52FdA$solidjsweb.getNextElement($820f2920cc576f7e$var$_tmpl$);
11688
11788
  }
11689
- function $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal, search_query_url_param_name_) {
11789
+ function $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal, search_query_url_param_name_, router_) {
11690
11790
  const [exit_iterable, exitable_iterable] = $52FdA$depictaiutilishared.make_asyncIterable_exiter((0, $52FdA$depictaiutilishared.href_change_ipns));
11791
+ const {
11792
+ navigation_to_same_href_listeners_: navigation_to_same_href_listeners_
11793
+ } = router_;
11691
11794
  let set_initial_values = false;
11692
11795
  let old_pathname;
11693
11796
  let old_param_value;
11797
+ // A card linking to the page one is already on doesn't change the href, close the modal anyway so the click does something
11798
+ navigation_to_same_href_listeners_.add(close_modal);
11799
+ $52FdA$solidjs.onCleanup(() => navigation_to_same_href_listeners_.delete(close_modal));
11694
11800
  $52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.catchify(exit_iterable));
11695
11801
  $52FdA$depictaiutilishared.catchify(async () => {
11696
11802
  for await (const href of exitable_iterable) {
@@ -11709,6 +11815,33 @@ function $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal, search_query_url
11709
11815
  }
11710
11816
  })();
11711
11817
  }
11818
+ function $9ccac7b807fe6451$export$9e9e2ae069cf2fe1(_ref) {
11819
+ let {
11820
+ props_search_field_value_: props_search_field_value_,
11821
+ props_submit_query_: props_submit_query_,
11822
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
11823
+ set_focus_target_after_close_: set_focus_target_after_close_,
11824
+ get_search_page_input_element_: get_search_page_input_element_
11825
+ } = _ref;
11826
+ const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $52FdA$solidjs.createSignal("") : props_search_field_value_;
11827
+ let submits_in_flight = 0;
11828
+ const submit_query_ = async function () {
11829
+ let new_query = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : $52FdA$solidjs.untrack(search_field_value_[0]);
11830
+ submits_in_flight++;
11831
+ try {
11832
+ return await props_submit_query_(new_query, () => set_focus_target_after_close_(get_search_page_input_element_));
11833
+ } finally {
11834
+ submits_in_flight--;
11835
+ }
11836
+ };
11837
+ if (dont_sync_search_field_value_except_on_submit_) $52FdA$solidjs.createEffect($52FdA$solidjs.on(search_field_value_[0], value => submits_in_flight > 0 && props_search_field_value_[1](value), {
11838
+ defer: true
11839
+ }));
11840
+ return {
11841
+ search_field_value_: search_field_value_,
11842
+ submit_query_: submit_query_
11843
+ };
11844
+ }
11712
11845
  var $9035b24c2dbd3f36$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class=discover-more><button class=major type=button>`),
11713
11846
  $9035b24c2dbd3f36$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<b>`),
11714
11847
  $9035b24c2dbd3f36$var$_tmpl$3 = /*#__PURE__*/$52FdA$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><!$><!/>`),
@@ -11723,6 +11856,8 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
11723
11856
  search_query_url_param_name_: search_query_url_param_name_,
11724
11857
  previous_searches_: previous_searches_,
11725
11858
  close_modal_: close_modal_,
11859
+ set_focus_target_after_close_: set_focus_target_after_close_,
11860
+ get_search_page_input_element_: get_search_page_input_element_,
11726
11861
  depict_api_: depict_api_,
11727
11862
  merchant_: merchant_,
11728
11863
  market_: market_,
@@ -11747,15 +11882,16 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
11747
11882
  // 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.
11748
11883
  // 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
11749
11884
  // Basically the UI signals that the button that opens the modal starts a new search.
11750
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $52FdA$solidjs.createSignal("") : props_search_field_value;
11751
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($52FdA$solidjs.untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
11752
- : undefined;
11753
- const submit_query_ = function () {
11754
- // 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
11755
- // It will write the old one back and then write the new one after submit
11756
- propagate_search_field_value_back === null || propagate_search_field_value_back === void 0 || propagate_search_field_value_back();
11757
- return props_submit_query(...arguments);
11758
- };
11885
+ const {
11886
+ search_field_value_: search_field_value_,
11887
+ submit_query_: submit_query_
11888
+ } = $9ccac7b807fe6451$export$9e9e2ae069cf2fe1({
11889
+ props_search_field_value_: props_search_field_value,
11890
+ props_submit_query_: props_submit_query,
11891
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
11892
+ set_focus_target_after_close_: set_focus_target_after_close_,
11893
+ get_search_page_input_element_: get_search_page_input_element_
11894
+ });
11759
11895
  const [input_field, set_input_field] = $52FdA$solidjs.createSignal();
11760
11896
  const [get_search_field_value_] = search_field_value_;
11761
11897
  // Search field alignment unused in ClassicSearchModal since the search field spans the whole modal
@@ -11821,7 +11957,7 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
11821
11957
  return _el$;
11822
11958
  })();
11823
11959
  if (disable_scrolling_) $8c2e68c6d458169b$export$fe334901e8bebd57();
11824
- $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_);
11960
+ $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_, router_);
11825
11961
  window.addEventListener("keydown", close_on_escape_handler);
11826
11962
  $52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.catchify(() => window.removeEventListener("keydown", close_on_escape_handler)));
11827
11963
  if (closing_animation_) register_closing_animation_(closing_animation_);
@@ -12587,6 +12723,8 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
12587
12723
  search_query_url_param_name_: search_query_url_param_name_,
12588
12724
  previous_searches_: previous_searches_,
12589
12725
  close_modal_: close_modal_,
12726
+ set_focus_target_after_close_: set_focus_target_after_close_,
12727
+ get_search_page_input_element_: get_search_page_input_element_,
12590
12728
  alignmentSignals_: alignmentSignals_,
12591
12729
  depict_api_: depict_api_,
12592
12730
  merchant_: merchant_,
@@ -12617,15 +12755,16 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
12617
12755
  // 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.
12618
12756
  // 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
12619
12757
  // Basically the UI signals that the button that opens the modal starts a new search.
12620
- const search_field_value_ = dont_sync_search_field_value_except_on_submit_ ? $52FdA$solidjs.createSignal("") : props_search_field_value;
12621
- const propagate_search_field_value_back = dont_sync_search_field_value_except_on_submit_ ? () => props_search_field_value[1]($52FdA$solidjs.untrack(search_field_value_[0])) // Set actual search field value to the throwaway internal one before submitting
12622
- : undefined;
12623
- const submit_query_ = function () {
12624
- // 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
12625
- // It will write the old one back and then write the new one after submit
12626
- propagate_search_field_value_back === null || propagate_search_field_value_back === void 0 || propagate_search_field_value_back();
12627
- return props_submit_query(...arguments);
12628
- };
12758
+ const {
12759
+ search_field_value_: search_field_value_,
12760
+ submit_query_: submit_query_
12761
+ } = $9ccac7b807fe6451$export$9e9e2ae069cf2fe1({
12762
+ props_search_field_value_: props_search_field_value,
12763
+ props_submit_query_: props_submit_query,
12764
+ dont_sync_search_field_value_except_on_submit_: dont_sync_search_field_value_except_on_submit_,
12765
+ set_focus_target_after_close_: set_focus_target_after_close_,
12766
+ get_search_page_input_element_: get_search_page_input_element_
12767
+ });
12629
12768
  const [input_field, set_input_field] = $52FdA$solidjs.createSignal();
12630
12769
  const [searching_for_value_, set_searching_for_value_] = $52FdA$solidjs.createSignal();
12631
12770
  const [show_stale_content_results_, set_show_stale_content_results_] = $52FdA$solidjs.createSignal(false);
@@ -12739,7 +12878,7 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
12739
12878
  return (((_get_modal_search_res5 = get_modal_search_results_()) === null || _get_modal_search_res5 === void 0 ? void 0 : _get_modal_search_res5.loading) === false && !suggestions_response_.loading || !!prev) && totalNumberResults() === 0 && previous_searches_matching_query().length === 0;
12740
12879
  });
12741
12880
  if (disable_scrolling_) $8c2e68c6d458169b$export$fe334901e8bebd57();
12742
- $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_);
12881
+ $4b71b4fabdee5753$export$93d9bfd0c9c1a5b8(close_modal_, search_query_url_param_name_, router_);
12743
12882
  addEventListener("keydown", close_on_escape_handler);
12744
12883
  $52FdA$solidjs.onCleanup(() => removeEventListener("keydown", close_on_escape_handler));
12745
12884
  $52FdA$solidjs.createEffect($52FdA$solidjs.on(get_search_field_value_, () => {
@@ -14943,11 +15082,12 @@ async function $7f680455a2aa1079$export$e16630ecb9644a1c(_ref) {
14943
15082
  let {
14944
15083
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
14945
15084
  search_param_name_: search_param_name_,
14946
- set_search_field_value_: set_search_field_value_,
15085
+ search_field_value_: search_field_value_,
14947
15086
  get_search_query_: get_search_query_,
14948
15087
  url_transformer_: url_transformer_,
14949
15088
  router_: router_,
14950
15089
  after_submit_: after_submit_,
15090
+ before_navigate_: before_navigate_,
14951
15091
  get_new_query: get_new_query
14952
15092
  } = _ref;
14953
15093
  const new_search_query = get_new_query();
@@ -14955,21 +15095,92 @@ async function $7f680455a2aa1079$export$e16630ecb9644a1c(_ref) {
14955
15095
  if (previous_query === new_search_query && new URLSearchParams(location.search).has(search_param_name_)) {
14956
15096
  // don't push a history entry / re-search if someone submits a search again
14957
15097
  // do close the modal though
15098
+ search_field_value_.settle_(new_search_query);
14958
15099
  on_submit_with_unchanged_value_ === null || on_submit_with_unchanged_value_ === void 0 || on_submit_with_unchanged_value_();
14959
- return;
15100
+ return false;
14960
15101
  }
14961
- set_search_field_value_(previous_query); // restore the value to the previous query since this one goes to the new history entry
14962
15102
  const target_url = new URL(location.href);
14963
15103
  url_transformer_ === null || url_transformer_ === void 0 || url_transformer_(target_url);
14964
15104
  target_url.searchParams.set(search_param_name_, new_search_query);
14965
- await router_.navigate_.go_to_({
14966
- new_url_: target_url,
14967
- is_replace_: false,
14968
- force_spa_navigation_: true
14969
- });
14970
- set_search_field_value_(new_search_query);
15105
+ const end_submit = search_field_value_.begin_submit_(new_search_query, previous_query);
15106
+ before_navigate_ === null || before_navigate_ === void 0 || before_navigate_();
15107
+ let landed;
15108
+ try {
15109
+ await router_.navigate_.go_to_({
15110
+ new_url_: target_url,
15111
+ is_replace_: false,
15112
+ force_spa_navigation_: true
15113
+ });
15114
+ } finally {
15115
+ landed = end_submit();
15116
+ }
15117
+ if (!landed) return false;
14971
15118
  scrollTo(0, 0);
14972
15119
  after_submit_ === null || after_submit_ === void 0 || after_submit_();
15120
+ return true;
15121
+ }
15122
+ function $24f1a81b790e371c$export$d13a185c53aa5edf(persisted_, get_search_query_) {
15123
+ const [get_persisted, set_persisted] = persisted_;
15124
+ const [get_submitting, set_submitting] = $52FdA$solidjs.createSignal();
15125
+ const get_value = $52FdA$solidjs.createMemo(() => {
15126
+ var _get_submitting;
15127
+ return (_get_submitting = get_submitting()) !== null && _get_submitting !== void 0 ? _get_submitting : get_persisted();
15128
+ });
15129
+ const set_value = value => {
15130
+ const new_value = typeof value === "function" ? value($52FdA$solidjs.untrack(get_value)) : value;
15131
+ if ($52FdA$solidjs.untrack(get_submitting) === undefined) set_persisted(new_value);else set_submitting(new_value);
15132
+ return new_value;
15133
+ };
15134
+ let current_submit;
15135
+ const end_submit = landed => {
15136
+ current_submit.landed_ = landed;
15137
+ current_submit = undefined;
15138
+ $52FdA$solidjs.batch(() => {
15139
+ const submitting = $52FdA$solidjs.untrack(get_submitting);
15140
+ set_submitting(undefined);
15141
+ if (landed && submitting !== undefined) set_persisted(submitting);
15142
+ });
15143
+ };
15144
+ const abort_on_popstate = what_happened => {
15145
+ if (what_happened === "popstate" && current_submit) end_submit(false);
15146
+ };
15147
+ (0, $52FdA$depictaiutilishared.instant_exec_on_suspect_history_change).add(abort_on_popstate);
15148
+ $52FdA$solidjs.onCleanup(() => (0, $52FdA$depictaiutilishared.instant_exec_on_suspect_history_change).delete(abort_on_popstate));
15149
+ $52FdA$solidjs.createEffect($52FdA$solidjs.on(get_search_query_, query => {
15150
+ const token = current_submit;
15151
+ if (!token || query !== token.query_) return;
15152
+ queueMicrotask(() => {
15153
+ if (current_submit === token) end_submit(true);
15154
+ });
15155
+ }, {
15156
+ defer: true
15157
+ }));
15158
+ const begin_submit_ = (submitted_query, query_of_current_history_entry) => {
15159
+ const token = current_submit = {
15160
+ query_: submitted_query,
15161
+ landed_: false
15162
+ };
15163
+ $52FdA$solidjs.batch(() => {
15164
+ set_submitting(submitted_query);
15165
+ set_persisted(query_of_current_history_entry);
15166
+ });
15167
+ return () => {
15168
+ if (current_submit === token) end_submit(true);
15169
+ return token.landed_;
15170
+ };
15171
+ };
15172
+ const settle_ = query => {
15173
+ if (current_submit) return;
15174
+ $52FdA$solidjs.batch(() => {
15175
+ set_submitting(undefined);
15176
+ set_persisted(query);
15177
+ });
15178
+ };
15179
+ return {
15180
+ value_: [get_value, set_value],
15181
+ begin_submit_: begin_submit_,
15182
+ settle_: settle_
15183
+ };
14973
15184
  }
14974
15185
  function $7a8e55af4ef13fae$export$181cceed5c91919e(callback, alsoRaF, passiveListener) {
14975
15186
  let aligned_this_microtask = false;
@@ -15713,6 +15924,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
15713
15924
  scroll_restoration_data_: scroll_restoration_data_,
15714
15925
  product_card_template_: product_card_template_,
15715
15926
  modalAlignmentSignalsRef_: modalAlignmentSignalsRef_,
15927
+ inputFieldRef_: inputFieldRef_,
15716
15928
  router_: router_,
15717
15929
  content_results_rows_: content_results_rows_,
15718
15930
  content_layout_options_: content_layout_options_,
@@ -15917,6 +16129,8 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
15917
16129
  if (!search_field) break add_input_field;
15918
16130
  setModalBodyStyle({});
15919
16131
  modalAlignmentSignalsRef_ === null || modalAlignmentSignalsRef_ === void 0 || modalAlignmentSignalsRef_(alignmentSignals_);
16132
+ inputFieldRef_ === null || inputFieldRef_ === void 0 || inputFieldRef_(input_element);
16133
+ $52FdA$solidjs.onCleanup(() => inputFieldRef_ === null || inputFieldRef_ === void 0 ? void 0 : inputFieldRef_(undefined));
15920
16134
  const [pollAlignment, setPollAlignment_] = $52FdA$solidjs.createSignal(false);
15921
16135
  const align_position = $52FdA$depictaiutilishared.catchify((0, $d6ed4dbb6507996d$export$b3ad617e9036868))(alignmentSignals_, search_field, (0, $d6ed4dbb6507996d$export$3f238c96c45e6cc6) | (0, $d6ed4dbb6507996d$export$7895aadd1956b1c7) | (modalVersionUsed_ === 1 ? (0, $d6ed4dbb6507996d$export$902f8b4a7dae5d78) : (0, $d6ed4dbb6507996d$export$6060bc6bee850eb6) | (0, $d6ed4dbb6507996d$export$5097308c5200105a)), true, pollAlignment);
15922
16136
  div_with_field_class.addEventListener("click", $52FdA$depictaiutilishared.catchify(e => {
@@ -16326,14 +16540,16 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
16326
16540
  set_search_content_results_rows((0, $eab939d0b95b75ee$export$70ceae36059a1036));
16327
16541
  }; // do this every time after we have submitted a new query - otherwise there might already be a saved number of rows in the state
16328
16542
  const on_submit_with_unchanged_value_ = () => this.modal_open = false;
16329
- const [get_search_field_value_, set_search_field_value_] = state_.field_value;
16330
- const configured_submit_query_ = new_query => $7f680455a2aa1079$export$e16630ecb9644a1c({
16543
+ const search_field_value_ = $24f1a81b790e371c$export$d13a185c53aa5edf(state_.field_value, get_search_query_);
16544
+ const [get_search_field_value_] = search_field_value_.value_;
16545
+ const configured_submit_query_ = (new_query, before_navigate_) => $7f680455a2aa1079$export$e16630ecb9644a1c({
16331
16546
  on_submit_with_unchanged_value_: on_submit_with_unchanged_value_,
16332
- set_search_field_value_: set_search_field_value_,
16547
+ search_field_value_: search_field_value_,
16333
16548
  get_search_query_: get_search_query_,
16334
16549
  search_param_name_: search_query_url_param_name_,
16335
16550
  after_submit_: after_submit_,
16336
- get_new_query: () => new_query || $52FdA$solidjs.untrack(get_search_field_value_),
16551
+ before_navigate_: before_navigate_,
16552
+ get_new_query: () => new_query !== null && new_query !== void 0 ? new_query : $52FdA$solidjs.untrack(get_search_field_value_),
16337
16553
  url_transformer_: url_transformer,
16338
16554
  router_: $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $ddd39c5f36f49703$var$_router)
16339
16555
  });
@@ -16352,6 +16568,7 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
16352
16568
  search_query_url_param_name_: search_query_url_param_name_,
16353
16569
  reset_history_state_: reset_history_state_,
16354
16570
  state_: state_,
16571
+ search_field_value_: search_field_value_.value_,
16355
16572
  router_: $parcel$interopDefault($52FdA$babelruntimehelpersclassPrivateFieldGet)(this, $ddd39c5f36f49703$var$_router),
16356
16573
  url_transformer_: url_transformer,
16357
16574
  depict_api_: depict_api_,
@@ -16375,7 +16592,11 @@ class $ddd39c5f36f49703$export$ac6237957a15b3f0 {
16375
16592
  $52FdA$solidjs.onCleanup(() => _this.modal_open = false);
16376
16593
  return searchModalComponent(...arguments);
16377
16594
  }, {
16378
- search_field_value_: state_.field_value,
16595
+ search_field_value_: search_field_value_.value_,
16596
+ get_search_page_input_element_: () => {
16597
+ var _privately_shared_pro2;
16598
+ return (_privately_shared_pro2 = $ddd39c5f36f49703$export$dde08b2dca8cc1ce.get(this)) === null || _privately_shared_pro2 === void 0 ? void 0 : _privately_shared_pro2.search_page_input_element_;
16599
+ },
16379
16600
  get_search_query_: get_search_query_,
16380
16601
  search_query_url_param_name_: search_query_url_param_name_,
16381
16602
  previous_searches_: previous_searches,
@@ -16540,6 +16761,7 @@ function $ddd39c5f36f49703$export$f2dc7e4e4aa11abb(props) {
16540
16761
  const {
16541
16762
  state_: state_
16542
16763
  } = shared_properties;
16764
+ let registered_input_element;
16543
16765
  const grid_spacing_override = $52FdA$solidjs.createMemo(() => {
16544
16766
  const {
16545
16767
  grid_spacing: grid_spacing
@@ -16571,7 +16793,7 @@ function $ddd39c5f36f49703$export$f2dc7e4e4aa11abb(props) {
16571
16793
  var _depict_search$enable;
16572
16794
  return (_depict_search$enable = depict_search.enable_content_search) !== null && _depict_search$enable !== void 0 ? _depict_search$enable : $ddd39c5f36f49703$var$content_search_default;
16573
16795
  },
16574
- search_field_value_: state_.field_value,
16796
+ search_field_value_: shared_properties.search_field_value_,
16575
16797
  get_search_query_: shared_properties.get_search_query_,
16576
16798
  clear_filters_on_next_submit_: shared_properties.clear_filters_on_next_submit_,
16577
16799
  open_modal_: function () {
@@ -16582,6 +16804,16 @@ function $ddd39c5f36f49703$export$f2dc7e4e4aa11abb(props) {
16582
16804
  modalVersionUsed_: shared_properties.modalVersionUsed_,
16583
16805
  showSliderArrow_: () => props.showSliderArrow_,
16584
16806
  i18n_: shared_properties.i18n_,
16807
+ inputFieldRef_: input_element => {
16808
+ const shared_info_right_now = $ddd39c5f36f49703$export$dde08b2dca8cc1ce.get(depict_search);
16809
+ if (!shared_info_right_now) return;
16810
+ if (input_element === undefined && shared_info_right_now.search_page_input_element_ !== registered_input_element) return;
16811
+ registered_input_element = input_element;
16812
+ $ddd39c5f36f49703$export$dde08b2dca8cc1ce.set(depict_search, {
16813
+ ...shared_info_right_now,
16814
+ search_page_input_element_: input_element
16815
+ });
16816
+ },
16585
16817
  modalAlignmentSignalsRef_: style => {
16586
16818
  const shared_info_right_now = $ddd39c5f36f49703$export$dde08b2dca8cc1ce.get(depict_search);
16587
16819
  if (!shared_info_right_now) return;
@@ -17028,7 +17260,7 @@ function $98aef9965764903d$export$316f6f283ae64765(props) {
17028
17260
  return shared_properties.BackIcon_;
17029
17261
  },
17030
17262
  get search_field_value_() {
17031
- return shared_properties.state_.field_value;
17263
+ return shared_properties.search_field_value_;
17032
17264
  },
17033
17265
  get submit_query_() {
17034
17266
  return shared_properties.configured_submit_query_;
@@ -17071,7 +17303,7 @@ function $98aef9965764903d$export$316f6f283ae64765(props) {
17071
17303
  return shared_properties.BackIcon_;
17072
17304
  },
17073
17305
  get search_field_value_() {
17074
- return shared_properties.state_.field_value;
17306
+ return shared_properties.search_field_value_;
17075
17307
  },
17076
17308
  get submit_query_() {
17077
17309
  return shared_properties.configured_submit_query_;