@depict-ai/ui 4.3.14 → 4.4.1

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.js CHANGED
@@ -7,7 +7,7 @@ import { createStore as $9HbP8$createStore, reconcile as $9HbP8$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.3.14";
10
+ const $ec291e0010116877$export$83d89fbfd8236492 = "4.4.1";
11
11
  const $b5cccc8ee7d24677$var$transform_elements = sorted_cols_at_size => {
12
12
  const cols_at_size = [];
13
13
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -3324,9 +3324,12 @@ let $f86ba724282f6690$export$44dad306455dddf;
3324
3324
  DEPICT_ID["PLP_CATEGORY"] = "depict-plp-category";
3325
3325
  })($f86ba724282f6690$export$44dad306455dddf || ($f86ba724282f6690$export$44dad306455dddf = {}));
3326
3326
  var $5285d2814d0fac0c$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<button class=back type=button>`),
3327
- $5285d2814d0fac0c$var$_tmpl$2 = /*#__PURE__*/$9HbP8$template(`<div class=search-field role=search><!$><!/><div class=field><input class=query tabindex=0><button type=button class=clear></button></div><button class="submit major"type=button>`);
3327
+ $5285d2814d0fac0c$var$_tmpl$2 = /*#__PURE__*/$9HbP8$template(`<button type=button class=clear>`),
3328
+ $5285d2814d0fac0c$var$_tmpl$3 = /*#__PURE__*/$9HbP8$template(`<div class=spacer>`),
3329
+ $5285d2814d0fac0c$var$_tmpl$4 = /*#__PURE__*/$9HbP8$template(`<button class="submit major"type=button>`),
3330
+ $5285d2814d0fac0c$var$_tmpl$5 = /*#__PURE__*/$9HbP8$template(`<div class=search-field role=search><!$><!/><!$><!/><div class=field><!$><!/><input class=query tabindex=0><!$><!/></div><!$><!/><!$><!/>`);
3328
3331
  function $5285d2814d0fac0c$export$b94867ecbd698f21({
3329
- search_field_value_: search_field_value_,
3332
+ search_field_value_: [searchFieldValue, setSearchFieldValue],
3330
3333
  input_field_ref_: input_field_ref_,
3331
3334
  field_element_ref_: field_element_ref_,
3332
3335
  submit_query_: submit_query_,
@@ -3337,7 +3340,7 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
3337
3340
  i18n_: i18n_,
3338
3341
  after_focusing_: after_focusing_,
3339
3342
  BackIcon_: BackIcon_,
3340
- submit_button_ref_: submit_button_ref_
3343
+ buttonInFieldRef_: buttonInFieldRef_
3341
3344
  }) {
3342
3345
  let input_element;
3343
3346
  // This is the div where we recommend (and ourselves do) attach the event listener to that opens the search modal.
@@ -3351,30 +3354,104 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
3351
3354
  })); // focus field on render
3352
3355
  const owner_of_field_element = $9HbP8$getOwner();
3353
3356
  const isNewModal = BackIcon_[(0, $66db7a014e20802e$export$1ea76ea778b880dd)] === 2;
3357
+ const [backButtonWidthAccessor, setBackButtonWidthAccessor] = $9HbP8$createSignal();
3358
+ const getBackButtonWidth = () => backButtonWidthAccessor()?.();
3359
+ const searchFieldEmpty = $9HbP8$createMemo(() => !searchFieldValue());
3360
+ const BackButton = () => $9HbP8$createComponent((0, $9HbP8$Show), {
3361
+ when: on_back_,
3362
+ get children() {
3363
+ var _el$ = $9HbP8$getNextElement($5285d2814d0fac0c$var$_tmpl$);
3364
+ $9HbP8$spread(_el$, $9HbP8$mergeProps({
3365
+ get onClick() {
3366
+ return $9HbP8$catchify(on_back_);
3367
+ },
3368
+ get ["aria-label"]() {
3369
+ return i18n_.back_();
3370
+ }
3371
+ }, isNewModal && {
3372
+ ref: el => {
3373
+ setBackButtonWidthAccessor(() => $2449872a62a75a20$export$ebdc3711f7e02ccd(el));
3374
+ $9HbP8$onCleanup(() => setBackButtonWidthAccessor());
3375
+ }
3376
+ }), false, true);
3377
+ $9HbP8$insert(_el$, isNewModal ? $9HbP8$createComponent((0, $19976a74d273070d$export$3b621d86b1566b2), {}) : $9HbP8$createComponent(BackIcon_, {}));
3378
+ $9HbP8$runHydrationEvents();
3379
+ return _el$;
3380
+ }
3381
+ });
3382
+ const ClearButton = () => (() => {
3383
+ var _el$2 = $9HbP8$getNextElement($5285d2814d0fac0c$var$_tmpl$2);
3384
+ var _ref$ = buttonInFieldRef_;
3385
+ typeof _ref$ === "function" ? $9HbP8$use(_ref$, _el$2) : buttonInFieldRef_ = _el$2;
3386
+ $9HbP8$spread(_el$2, $9HbP8$mergeProps({
3387
+ get classList() {
3388
+ return {
3389
+ empty: searchFieldEmpty()
3390
+ };
3391
+ },
3392
+ get style() {
3393
+ return isNewModal || !searchFieldEmpty() ? "" : "display: none";
3394
+ },
3395
+ get onClick() {
3396
+ return $9HbP8$catchify(() => {
3397
+ if (isNewModal && searchFieldEmpty()) return;
3398
+ setSearchFieldValue("");
3399
+ clear_filters_(true);
3400
+ if (!disabled_) input_element.focus();
3401
+ });
3402
+ }
3403
+ }, () => searchFieldEmpty() ? {
3404
+ "aria-hidden": "true"
3405
+ } : {
3406
+ title: i18n_.clear_filters_query_sorting_after_submit_()
3407
+ }), false, true);
3408
+ $9HbP8$insert(_el$2, isNewModal ? $9HbP8$createComponent((0, $9HbP8$Show), {
3409
+ get when() {
3410
+ return !searchFieldEmpty();
3411
+ },
3412
+ get fallback() {
3413
+ return $9HbP8$createComponent((0, $16f0ed5ea30d8d9c$export$82eafebb825fc23f), {});
3414
+ },
3415
+ get children() {
3416
+ return $9HbP8$createComponent(BackIcon_, {});
3417
+ }
3418
+ }) : $9HbP8$createComponent((0, $19976a74d273070d$export$3b621d86b1566b2), {}));
3419
+ $9HbP8$runHydrationEvents();
3420
+ return _el$2;
3421
+ })();
3354
3422
  return (() => {
3355
- var _el$ = $9HbP8$getNextElement($5285d2814d0fac0c$var$_tmpl$2),
3356
- _el$7 = _el$.firstChild,
3423
+ var _el$3 = $9HbP8$getNextElement($5285d2814d0fac0c$var$_tmpl$5),
3424
+ _el$12 = _el$3.firstChild,
3425
+ [_el$13, _co$3] = $9HbP8$getNextMarker(_el$12.nextSibling),
3426
+ _el$14 = _el$13.nextSibling,
3427
+ [_el$15, _co$4] = $9HbP8$getNextMarker(_el$14.nextSibling),
3428
+ _el$5 = _el$15.nextSibling,
3429
+ _el$7 = _el$5.firstChild,
3357
3430
  [_el$8, _co$] = $9HbP8$getNextMarker(_el$7.nextSibling),
3358
- _el$3 = _el$8.nextSibling,
3359
- _el$4 = _el$3.firstChild,
3360
- _el$5 = _el$4.nextSibling,
3361
- _el$6 = _el$3.nextSibling;
3362
- $9HbP8$insert(_el$, $9HbP8$createComponent((0, $9HbP8$Show), {
3363
- when: on_back_,
3431
+ _el$6 = _el$8.nextSibling,
3432
+ _el$9 = _el$6.nextSibling,
3433
+ [_el$10, _co$2] = $9HbP8$getNextMarker(_el$9.nextSibling),
3434
+ _el$16 = _el$5.nextSibling,
3435
+ [_el$17, _co$5] = $9HbP8$getNextMarker(_el$16.nextSibling),
3436
+ _el$18 = _el$17.nextSibling,
3437
+ [_el$19, _co$6] = $9HbP8$getNextMarker(_el$18.nextSibling);
3438
+ _el$3.classList.toggle("in-modal", !!!!on_back_);
3439
+ $9HbP8$insert(_el$3, $9HbP8$createComponent((0, $9HbP8$Show), {
3440
+ get when() {
3441
+ return getBackButtonWidth() !== undefined && on_back_;
3442
+ },
3364
3443
  get children() {
3365
- var _el$2 = $9HbP8$getNextElement($5285d2814d0fac0c$var$_tmpl$);
3366
- $9HbP8$addEventListener(_el$2, "click", $9HbP8$catchify(on_back_), true);
3367
- $9HbP8$insert(_el$2, $9HbP8$createComponent(BackIcon_, {}));
3368
- $9HbP8$effect(() => $9HbP8$setAttribute(_el$2, "aria-label", i18n_.back_()));
3369
- $9HbP8$runHydrationEvents();
3370
- return _el$2;
3444
+ var _el$4 = $9HbP8$getNextElement($5285d2814d0fac0c$var$_tmpl$3);
3445
+ $9HbP8$effect(() => (getBackButtonWidth(), _el$4.style.setProperty("width", getBackButtonWidth() + "px")));
3446
+ return _el$4;
3371
3447
  }
3372
- }), _el$8, _co$);
3448
+ }), _el$13, _co$3);
3449
+ $9HbP8$insert(_el$3, !isNewModal && $9HbP8$createComponent(BackButton, {}), _el$15, _co$4);
3373
3450
  $9HbP8$use(el => {
3374
3451
  field_div = el;
3375
3452
  field_element_ref_?.(el);
3376
- }, _el$3);
3377
- $9HbP8$addEventListener(_el$3, "click", $9HbP8$catchify(({
3453
+ }, _el$5);
3454
+ $9HbP8$addEventListener(_el$5, "click", $9HbP8$catchify(({
3378
3455
  target: target,
3379
3456
  currentTarget: currentTarget,
3380
3457
  detail: detail
@@ -3398,7 +3475,8 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
3398
3475
  }
3399
3476
  }
3400
3477
  }), true);
3401
- _el$4.$$pointerdown = ({
3478
+ $9HbP8$insert(_el$5, isNewModal && $9HbP8$createComponent(ClearButton, {}), _el$8, _co$);
3479
+ _el$6.$$pointerdown = ({
3402
3480
  pointerType: pointerType
3403
3481
  }) => {
3404
3482
  // When selecting text with a mouse we want a SearchField to be focussed even when releasing the mouse outside the .field element (we assume the event listener which opens the modal is attached to that).
@@ -3416,7 +3494,7 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
3416
3494
  $9HbP8$runWithOwner(owner_of_field_element, () => $9HbP8$onCleanup(() => window.removeEventListener("pointerup", handler)));
3417
3495
  }
3418
3496
  };
3419
- $9HbP8$addEventListener(_el$4, "select", $9HbP8$catchify(() => {
3497
+ $9HbP8$addEventListener(_el$6, "select", $9HbP8$catchify(() => {
3420
3498
  if (disabled_)
3421
3499
  // just in case. The field not actually being disabled when being disabled_ is so that you can focus it and open the modal. We don't want any of the other input-field-interaction features to work
3422
3500
  return;
@@ -3428,14 +3506,14 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
3428
3506
  once: true
3429
3507
  });
3430
3508
  }));
3431
- $9HbP8$addEventListener(_el$4, "input", $9HbP8$catchify(() => {
3509
+ $9HbP8$addEventListener(_el$6, "input", $9HbP8$catchify(() => {
3432
3510
  const {
3433
3511
  value: value
3434
3512
  } = input_element;
3435
3513
  if (!disabled_ && !value.length) clear_filters_(false); // if the user clears the whole field, reset filters on next submit
3436
- search_field_value_[1](value);
3514
+ setSearchFieldValue(value);
3437
3515
  }), true);
3438
- $9HbP8$addEventListener(_el$4, "keydown", $9HbP8$catchify(e => {
3516
+ $9HbP8$addEventListener(_el$6, "keydown", $9HbP8$catchify(e => {
3439
3517
  if (disabled_) {
3440
3518
  if (e.key !== "Tab" && e.key !== "Shift")
3441
3519
  // 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
@@ -3445,49 +3523,38 @@ function $5285d2814d0fac0c$export$b94867ecbd698f21({
3445
3523
  if (!dont_submit) submit_query_();
3446
3524
  }
3447
3525
  }), true);
3448
- var _ref$ = $9HbP8$catchify(el => {
3526
+ var _ref$2 = $9HbP8$catchify(el => {
3449
3527
  input_element = el;
3450
3528
  input_field_ref_?.(el);
3451
3529
  });
3452
- typeof _ref$ === "function" && $9HbP8$use(_ref$, _el$4);
3453
- _el$4.classList.toggle("has-adjacent-back-button", !!!!on_back_);
3454
- $9HbP8$addEventListener(_el$5, "click", $9HbP8$catchify(() => {
3455
- search_field_value_[1]("");
3456
- clear_filters_(true);
3457
- if (!disabled_) input_element.focus();
3458
- }), true);
3459
- $9HbP8$insert(_el$5, $9HbP8$createComponent((0, $19976a74d273070d$export$3b621d86b1566b2), {}));
3460
- var _ref$2 = submit_button_ref_;
3461
- typeof _ref$2 === "function" ? $9HbP8$use(_ref$2, _el$6) : submit_button_ref_ = _el$6;
3462
- $9HbP8$spread(_el$6, $9HbP8$mergeProps({
3463
- get onClick() {
3464
- return $9HbP8$catchify(() => submit_query_());
3530
+ typeof _ref$2 === "function" && $9HbP8$use(_ref$2, _el$6);
3531
+ _el$6.classList.toggle("has-adjacent-back-button", !!!!on_back_);
3532
+ $9HbP8$insert(_el$5, !isNewModal && $9HbP8$createComponent(ClearButton, {}), _el$10, _co$2);
3533
+ $9HbP8$insert(_el$3, isNewModal && $9HbP8$createComponent(BackButton, {}), _el$17, _co$5);
3534
+ $9HbP8$insert(_el$3, $9HbP8$createComponent((0, $9HbP8$Show), {
3535
+ when: !isNewModal,
3536
+ get children() {
3537
+ var _el$11 = $9HbP8$getNextElement($5285d2814d0fac0c$var$_tmpl$4);
3538
+ $9HbP8$addEventListener(_el$11, "click", $9HbP8$catchify(() => submit_query_()), true);
3539
+ $9HbP8$insert(_el$11, $9HbP8$createComponent((0, $16f0ed5ea30d8d9c$export$82eafebb825fc23f), {}));
3540
+ $9HbP8$effect(() => $9HbP8$setAttribute(_el$11, "aria-label", i18n_.search_submit_button_aria_label_()));
3541
+ $9HbP8$runHydrationEvents();
3542
+ return _el$11;
3465
3543
  }
3466
- }, () => isNewModal ? {
3467
- tabindex: "-1"
3468
- } : {
3469
- "aria-label": i18n_.search_submit_button_aria_label_()
3470
- }), false, true);
3471
- $9HbP8$insert(_el$6, $9HbP8$createComponent((0, $16f0ed5ea30d8d9c$export$82eafebb825fc23f), {}));
3544
+ }), _el$19, _co$6);
3472
3545
  $9HbP8$effect(_p$ => {
3473
3546
  var _v$ = i18n_.search_field_field_aria_label_(),
3474
- _v$2 = i18n_.placeholder_text_(),
3475
- _v$3 = i18n_.clear_filters_query_sorting_after_submit_(),
3476
- _v$4 = $9HbP8$createMemo(() => search_field_value_[0]() ? "" : "display: none")();
3477
- _v$ !== _p$.e && $9HbP8$setAttribute(_el$4, "aria-label", _p$.e = _v$);
3478
- _v$2 !== _p$.t && $9HbP8$setAttribute(_el$4, "placeholder", _p$.t = _v$2);
3479
- _v$3 !== _p$.a && $9HbP8$setAttribute(_el$5, "title", _p$.a = _v$3);
3480
- _p$.o = $9HbP8$style(_el$5, _v$4, _p$.o);
3547
+ _v$2 = i18n_.placeholder_text_();
3548
+ _v$ !== _p$.e && $9HbP8$setAttribute(_el$6, "aria-label", _p$.e = _v$);
3549
+ _v$2 !== _p$.t && $9HbP8$setAttribute(_el$6, "placeholder", _p$.t = _v$2);
3481
3550
  return _p$;
3482
3551
  }, {
3483
3552
  e: undefined,
3484
- t: undefined,
3485
- a: undefined,
3486
- o: undefined
3553
+ t: undefined
3487
3554
  });
3488
- $9HbP8$effect(() => $9HbP8$setProperty(_el$4, "value", search_field_value_[0]()));
3555
+ $9HbP8$effect(() => $9HbP8$setProperty(_el$6, "value", searchFieldValue()));
3489
3556
  $9HbP8$runHydrationEvents();
3490
- return _el$;
3557
+ return _el$3;
3491
3558
  })();
3492
3559
  }
3493
3560
  $9HbP8$delegateEvents(["click", "keydown", "input", "pointerdown"]);
@@ -3667,7 +3734,7 @@ function $42912431795f188e$var$RawClassicSearchModal({
3667
3734
  };
3668
3735
  });
3669
3736
  const search_field = $5285d2814d0fac0c$export$b94867ecbd698f21({
3670
- BackIcon_: () => $9HbP8$createComponent((0, $ffb84ffbf4014982$export$8d8893ffd8aca39a), {}),
3737
+ BackIcon_: (0, $ffb84ffbf4014982$export$8d8893ffd8aca39a),
3671
3738
  input_field_ref_: element => set_input_field(element),
3672
3739
  override_on_enter_: e => on_enter_in_search_field_function?.(e),
3673
3740
  on_back_: close_modal_,
@@ -3683,7 +3750,6 @@ function $42912431795f188e$var$RawClassicSearchModal({
3683
3750
  input_el.setSelectionRange(start, end);
3684
3751
  }
3685
3752
  });
3686
- search_field.classList.add("in-modal");
3687
3753
  const modal_element = (() => {
3688
3754
  var _el$4 = $9HbP8$getNextElement($42912431795f188e$var$_tmpl$3),
3689
3755
  _el$5 = _el$4.firstChild,
@@ -4907,7 +4973,7 @@ function $500a16dd18ee5a71$var$RawSearchModalV2({
4907
4973
  return _el$7;
4908
4974
  })();
4909
4975
  const search_field = $5285d2814d0fac0c$export$b94867ecbd698f21({
4910
- BackIcon_: () => $9HbP8$createComponent((0, $5cec65dd06ade2c4$export$11e9f390c90a537f), {}),
4976
+ BackIcon_: (0, $5cec65dd06ade2c4$export$11e9f390c90a537f),
4911
4977
  input_field_ref_: element => set_input_field(element),
4912
4978
  override_on_enter_: e => on_enter_in_search_field_function?.(e),
4913
4979
  on_back_: close_modal_,
@@ -4923,7 +4989,6 @@ function $500a16dd18ee5a71$var$RawSearchModalV2({
4923
4989
  input_el.setSelectionRange(start, end);
4924
4990
  }
4925
4991
  });
4926
- search_field.classList.add("in-modal");
4927
4992
  if (setSearchFieldOuterWidth_) {
4928
4993
  const resizeObserver = new ResizeObserver($9HbP8$catchify(records => setSearchFieldOuterWidth_(records.at(-1).contentRect.width)));
4929
4994
  resizeObserver.observe(search_field);
@@ -12666,7 +12731,7 @@ function $0e562a5b247b1fc2$export$44f738469d5570cf({
12666
12731
  bodyAlignmentSignal_: [, setBodyAlignment_],
12667
12732
  backdropStyleSignal_: [, setBackdropStyle_],
12668
12733
  setPollAlignment_: setPollAlignment_,
12669
- submitButton_: submitButton_,
12734
+ buttonInField_: buttonInField_,
12670
12735
  modalSearchFieldOuterWidth_: modalSearchFieldOuterWidth_
12671
12736
  }) {
12672
12737
  return $9HbP8$createRoot(dispose => {
@@ -12713,7 +12778,7 @@ function $0e562a5b247b1fc2$export$44f738469d5570cf({
12713
12778
  const closeDuration_ = pxOffCenter > 100 ? 150 : 100;
12714
12779
  setPollAlignment_(true);
12715
12780
  // Fade out submit button so there aren't two overlapping buttons for a split second
12716
- submitButton_.animate([{
12781
+ if (pxOffCenter > 10) buttonInField_.animate([{
12717
12782
  opacity: 1
12718
12783
  }, {
12719
12784
  opacity: 0
@@ -12780,6 +12845,8 @@ function $0e562a5b247b1fc2$export$44f738469d5570cf({
12780
12845
  width: width,
12781
12846
  left: left
12782
12847
  } = fakeField.getBoundingClientRect();
12848
+ // Just copy-pasted below line without thinking, it might be wrong
12849
+ const pxOffCenter = Math.abs($9HbP8$untrack(innerWidthReactive) / 2 - (left + width / 2));
12783
12850
  $0a901077d5c8a2b2$export$23d40cc5971c3acd({
12784
12851
  setBackdropStyle_: setBackdropStyle_,
12785
12852
  setBodyAlignment_: setBodyAlignment_,
@@ -12795,12 +12862,12 @@ function $0e562a5b247b1fc2$export$44f738469d5570cf({
12795
12862
  duration: closeDuration_,
12796
12863
  fill: "forwards",
12797
12864
  easing: "ease-out"
12798
- }).finished, submitButton_.animate([{
12865
+ }).finished, buttonInField_.animate([{
12799
12866
  opacity: 0
12800
12867
  }, {
12801
12868
  opacity: 1
12802
12869
  }], {
12803
- duration: closeDuration_ / 3,
12870
+ duration: pxOffCenter > 10 ? closeDuration_ / 3 : 1,
12804
12871
  delay: closeDuration_ * (2 / 3),
12805
12872
  fill: "forwards"
12806
12873
  }).finished]);
@@ -13002,7 +13069,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
13002
13069
  if (!input_field_accessor_value) break add_input_field;
13003
13070
  let input_element;
13004
13071
  let div_with_field_class;
13005
- let submitButton_;
13072
+ let buttonInField;
13006
13073
  const search_field = SafeSearchField({
13007
13074
  i18n_: i18n_,
13008
13075
  search_field_value_: search_field_value_,
@@ -13012,7 +13079,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
13012
13079
  field_element_ref_: el => div_with_field_class = el,
13013
13080
  disabled_: true,
13014
13081
  BackIcon_: BackIcon_,
13015
- submit_button_ref_: el => submitButton_ = el
13082
+ buttonInFieldRef_: el => buttonInField = el
13016
13083
  });
13017
13084
  if (!search_field) break add_input_field;
13018
13085
  setModalBodyStyle({});
@@ -13046,7 +13113,7 @@ function $7097477c78a89208$export$a54ec244c8863715({
13046
13113
  bodyAlignmentSignal_: modal_body_style,
13047
13114
  backdropStyleSignal_: modal_backdrop_style,
13048
13115
  setPollAlignment_: setPollAlignment_,
13049
- submitButton_: submitButton_,
13116
+ buttonInField_: buttonInField,
13050
13117
  modalSearchFieldOuterWidth_: modalSearchFieldOuterWidth_
13051
13118
  });
13052
13119
  }
@@ -13916,7 +13983,7 @@ function $58b3487626e85ece$export$316f6f283ae64765(props) {
13916
13983
  const shared_properties = $806c97b931758897$export$12fa711345994013(depict_search);
13917
13984
  return $16b52438165aafe2$export$23fca46f3143581f(() => {
13918
13985
  let input_element;
13919
- let submitButton_;
13986
+ let buttonInField;
13920
13987
  const search_field = $9HbP8$createComponent((0, $5285d2814d0fac0c$export$b94867ecbd698f21), {
13921
13988
  get BackIcon_() {
13922
13989
  return shared_properties.BackIcon_;
@@ -13935,7 +14002,7 @@ function $58b3487626e85ece$export$316f6f283ae64765(props) {
13935
14002
  },
13936
14003
  disabled_: true,
13937
14004
  input_field_ref_: el => input_element = el,
13938
- submit_button_ref_: el => submitButton_ = el,
14005
+ buttonInFieldRef_: el => buttonInField = el,
13939
14006
  field_element_ref_: field => {
13940
14007
  const bodyAlignmentSignal_ = $9HbP8$createSignal({
13941
14008
  position: "fixed"
@@ -13982,7 +14049,7 @@ function $58b3487626e85ece$export$316f6f283ae64765(props) {
13982
14049
  bodyAlignmentSignal_: bodyAlignmentSignal_,
13983
14050
  backdropStyleSignal_: backdropAlignmentSignal_,
13984
14051
  setPollAlignment_: setPollAlignment_,
13985
- submitButton_: submitButton_,
14052
+ buttonInField_: buttonInField,
13986
14053
  modalSearchFieldOuterWidth_: modalSearchFieldOuterWidth_
13987
14054
  });
13988
14055
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "4.3.14",
3
+ "version": "4.4.1",
4
4
  "description": "Base package containing the actual UI of Depict UI along with translations, with a not-simplified API. We recommend using @depict-ai/js-ui or @depict-ai/react-ui instead.",
5
5
  "packageManager": "yarn@3.2.2",
6
6
  "sass": "styles.scss",
@@ -236,7 +236,7 @@
236
236
  "@babel/plugin-transform-typescript": "^7.22.9",
237
237
  "@babel/runtime": "latest",
238
238
  "@babel/runtime-corejs3": "^7.22.6",
239
- "@depict-ai/plp-styling": "^4.0.4",
239
+ "@depict-ai/plp-styling": "^4.1.1",
240
240
  "@depict-ai/types": "^5.1.2",
241
241
  "@depict-ai/utilishared": "^2.1.2",
242
242
  "solid-js": "^1.8.12"
@@ -100,7 +100,7 @@ $parcel$export(module.exports, "BreadCrumbs", () => $335c02c1241a9ca8$export$5b7
100
100
  $parcel$export(module.exports, "QuickLinks", () => $335c02c1241a9ca8$export$de035477d6fef996);
101
101
  $parcel$export(module.exports, "CategoryPage", () => $c10e33c4681f8c9b$export$e2bf8ce7779e827e);
102
102
  /*! Depict.ai search and product listing SDK */
103
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.3.14";
103
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "4.4.1";
104
104
  const $5401a6698b0c0658$var$transform_elements = sorted_cols_at_size => {
105
105
  const cols_at_size = [];
106
106
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -3055,11 +3055,12 @@ let $c95c6dd9e93acd82$export$44dad306455dddf;
3055
3055
  DEPICT_ID["SEARCH_PAGE"] = "depict-search-page";
3056
3056
  DEPICT_ID["PLP_CATEGORY"] = "depict-plp-category";
3057
3057
  })($c95c6dd9e93acd82$export$44dad306455dddf || ($c95c6dd9e93acd82$export$44dad306455dddf = {}));
3058
- var $29e5dbeb69da7a36$var$_tmpl$ = ["<button", ' class="back" type="button"', ">", "</button>"],
3059
- $29e5dbeb69da7a36$var$_tmpl$2 = ["<div", ' class="search-field" role="search"><!--$-->', '<!--/--><div class="field"><input class="', '" tabindex="0"', '><button type="button" class="clear"', ' style="', '">', "</button></div>", "</div>"];
3058
+ var $29e5dbeb69da7a36$var$_tmpl$ = ["<div", ' style="', '" class="spacer"></div>'],
3059
+ $29e5dbeb69da7a36$var$_tmpl$2 = ["<button", ' class="submit major" type="button"', ">", "</button>"],
3060
+ $29e5dbeb69da7a36$var$_tmpl$3 = ["<div", ' class="', '" role="search"><!--$-->', "<!--/--><!--$-->", '<!--/--><div class="field"><!--$-->', '<!--/--><input class="', '" tabindex="0"', "><!--$-->", "<!--/--></div><!--$-->", "<!--/--><!--$-->", "<!--/--></div>"];
3060
3061
  function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
3061
3062
  let {
3062
- search_field_value_: search_field_value_,
3063
+ search_field_value_: [searchFieldValue, setSearchFieldValue],
3063
3064
  input_field_ref_: input_field_ref_,
3064
3065
  field_element_ref_: field_element_ref_,
3065
3066
  submit_query_: submit_query_,
@@ -3070,7 +3071,7 @@ function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
3070
3071
  i18n_: i18n_,
3071
3072
  after_focusing_: after_focusing_,
3072
3073
  BackIcon_: BackIcon_,
3073
- submit_button_ref_: submit_button_ref_
3074
+ buttonInFieldRef_: buttonInFieldRef_
3074
3075
  } = _ref;
3075
3076
  let input_element;
3076
3077
  // This is the div where we recommend (and ourselves do) attach the event listener to that opens the search modal.
@@ -3084,19 +3085,65 @@ function $29e5dbeb69da7a36$export$b94867ecbd698f21(_ref) {
3084
3085
  })); // focus field on render
3085
3086
  const owner_of_field_element = $3hooq$solidjs.getOwner();
3086
3087
  const isNewModal = BackIcon_[(0, $072ab198d82c3eb7$export$1ea76ea778b880dd)] === 2;
3087
- return $3hooq$solidjsweb.ssr($29e5dbeb69da7a36$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
3088
+ const [backButtonWidthAccessor, setBackButtonWidthAccessor] = $3hooq$solidjs.createSignal();
3089
+ const getBackButtonWidth = () => {
3090
+ var _backButtonWidthAcces;
3091
+ return (_backButtonWidthAcces = backButtonWidthAccessor()) === null || _backButtonWidthAcces === void 0 ? void 0 : _backButtonWidthAcces();
3092
+ };
3093
+ const searchFieldEmpty = $3hooq$solidjs.createMemo(() => !searchFieldValue());
3094
+ const BackButton = () => $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
3088
3095
  when: on_back_,
3089
3096
  get children() {
3090
- return $3hooq$solidjsweb.ssr($29e5dbeb69da7a36$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.ssrAttribute("aria-label", $3hooq$solidjsweb.escape(i18n_.back_(), true), false), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent(BackIcon_, {})));
3097
+ return $3hooq$solidjsweb.ssrElement("button", $3hooq$solidjsweb.mergeProps({
3098
+ "class": "back",
3099
+ type: "button",
3100
+ get ["aria-label"]() {
3101
+ return i18n_.back_();
3102
+ }
3103
+ }, isNewModal && {
3104
+ ref: el => {
3105
+ setBackButtonWidthAccessor(() => $c387d7f1d9fb66c0$export$ebdc3711f7e02ccd(el));
3106
+ $3hooq$solidjs.onCleanup(() => setBackButtonWidthAccessor());
3107
+ }
3108
+ }), () => isNewModal ? $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $083b2336093176cf$export$3b621d86b1566b2), {})) : $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent(BackIcon_, {})), true);
3091
3109
  }
3092
- })), "query ".concat(!!on_back_ ? "has-adjacent-back-button" : ""), $3hooq$solidjsweb.ssrAttribute("aria-label", $3hooq$solidjsweb.escape(i18n_.search_field_field_aria_label_(), true), false) + $3hooq$solidjsweb.ssrAttribute("value", $3hooq$solidjsweb.escape(search_field_value_[0](), true), false) + $3hooq$solidjsweb.ssrAttribute("placeholder", $3hooq$solidjsweb.escape(i18n_.placeholder_text_(), true), false), $3hooq$solidjsweb.ssrAttribute("title", $3hooq$solidjsweb.escape(i18n_.clear_filters_query_sorting_after_submit_(), true), false), $3hooq$solidjsweb.ssrStyle($3hooq$solidjs.createMemo(() => search_field_value_[0]() ? "" : "display: none")()), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $083b2336093176cf$export$3b621d86b1566b2), {})), $3hooq$solidjsweb.ssrElement("button", $3hooq$solidjsweb.mergeProps({
3093
- "class": "submit major",
3094
- type: "button"
3095
- }, () => isNewModal ? {
3096
- tabindex: "-1"
3110
+ });
3111
+ const ClearButton = () => $3hooq$solidjsweb.ssrElement("button", $3hooq$solidjsweb.mergeProps({
3112
+ type: "button",
3113
+ get ["class"]() {
3114
+ return "clear ".concat(searchFieldEmpty() ? "empty" : "");
3115
+ },
3116
+ get style() {
3117
+ return isNewModal || !searchFieldEmpty() ? "" : "display: none";
3118
+ }
3119
+ }, () => searchFieldEmpty() ? {
3120
+ "aria-hidden": "true"
3097
3121
  } : {
3098
- "aria-label": i18n_.search_submit_button_aria_label_()
3099
- }), () => $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $5b88b077e48a4451$export$82eafebb825fc23f), {})), false));
3122
+ title: i18n_.clear_filters_query_sorting_after_submit_()
3123
+ }), () => isNewModal ? $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
3124
+ get when() {
3125
+ return !searchFieldEmpty();
3126
+ },
3127
+ get fallback() {
3128
+ return $3hooq$solidjsweb.createComponent((0, $5b88b077e48a4451$export$82eafebb825fc23f), {});
3129
+ },
3130
+ get children() {
3131
+ return $3hooq$solidjsweb.createComponent(BackIcon_, {});
3132
+ }
3133
+ })) : $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $083b2336093176cf$export$3b621d86b1566b2), {})), true);
3134
+ return $3hooq$solidjsweb.ssr($29e5dbeb69da7a36$var$_tmpl$3, $3hooq$solidjsweb.ssrHydrationKey(), "search-field ".concat(!!on_back_ ? "in-modal" : ""), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
3135
+ get when() {
3136
+ return getBackButtonWidth() !== undefined && on_back_;
3137
+ },
3138
+ get children() {
3139
+ return $3hooq$solidjsweb.ssr($29e5dbeb69da7a36$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), "width:" + ($3hooq$solidjsweb.escape(getBackButtonWidth(), true) + "px"));
3140
+ }
3141
+ })), !isNewModal && $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent(BackButton, {})), isNewModal && $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent(ClearButton, {})), "query ".concat(!!on_back_ ? "has-adjacent-back-button" : ""), $3hooq$solidjsweb.ssrAttribute("aria-label", $3hooq$solidjsweb.escape(i18n_.search_field_field_aria_label_(), true), false) + $3hooq$solidjsweb.ssrAttribute("value", $3hooq$solidjsweb.escape(searchFieldValue(), true), false) + $3hooq$solidjsweb.ssrAttribute("placeholder", $3hooq$solidjsweb.escape(i18n_.placeholder_text_(), true), false), !isNewModal && $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent(ClearButton, {})), isNewModal && $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent(BackButton, {})), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
3142
+ when: !isNewModal,
3143
+ get children() {
3144
+ return $3hooq$solidjsweb.ssr($29e5dbeb69da7a36$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.ssrAttribute("aria-label", $3hooq$solidjsweb.escape(i18n_.search_submit_button_aria_label_(), true), false), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $5b88b077e48a4451$export$82eafebb825fc23f), {})));
3145
+ }
3146
+ })));
3100
3147
  }
3101
3148
  function $8c2e68c6d458169b$export$fe334901e8bebd57() {
3102
3149
  const cleanup_fns = [];
@@ -3263,7 +3310,7 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
3263
3310
  };
3264
3311
  });
3265
3312
  const search_field = $29e5dbeb69da7a36$export$b94867ecbd698f21({
3266
- BackIcon_: () => $3hooq$solidjsweb.createComponent((0, $820f2920cc576f7e$export$8d8893ffd8aca39a), {}),
3313
+ BackIcon_: (0, $820f2920cc576f7e$export$8d8893ffd8aca39a),
3267
3314
  input_field_ref_: element => set_input_field(element),
3268
3315
  override_on_enter_: e => {
3269
3316
  var _on_enter_in_search_f;
@@ -3282,7 +3329,6 @@ function $9035b24c2dbd3f36$var$RawClassicSearchModal(_ref) {
3282
3329
  input_el.setSelectionRange(start, end);
3283
3330
  }
3284
3331
  });
3285
- search_field.classList.add("in-modal");
3286
3332
  const modal_element = $3hooq$solidjsweb.ssr($9035b24c2dbd3f36$var$_tmpl$3, $3hooq$solidjsweb.ssrHydrationKey(), "depict-search-modal", "".concat("body", " ").concat($3hooq$solidjsweb.escape($3hooq$solidjsweb.escape(random_classname, true), true)), $3hooq$solidjsweb.escape(search_field), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $1b3cf201cdd38687$export$b69d0d92862de18b), {
3287
3333
  severity_: "error",
3288
3334
  message_: "Autocomplete/suggestions failed",
@@ -4320,7 +4366,7 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
4320
4366
  };
4321
4367
  const discoverMoreSection = $3hooq$solidjsweb.ssr($43600b30502feeda$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), get_search_field_value_() ? $3hooq$solidjsweb.escape(i18n_.modal_view_all_results_()($3hooq$solidjsweb.ssr($43600b30502feeda$var$_tmpl$3, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(formattedTotalNumberResults())))) : $3hooq$solidjsweb.escape(i18n_.modal_discover_more_()));
4322
4368
  const search_field = $29e5dbeb69da7a36$export$b94867ecbd698f21({
4323
- BackIcon_: () => $3hooq$solidjsweb.createComponent((0, $50b50df3efaa8776$export$11e9f390c90a537f), {}),
4369
+ BackIcon_: (0, $50b50df3efaa8776$export$11e9f390c90a537f),
4324
4370
  input_field_ref_: element => set_input_field(element),
4325
4371
  override_on_enter_: e => {
4326
4372
  var _on_enter_in_search_f;
@@ -4339,7 +4385,6 @@ function $43600b30502feeda$var$RawSearchModalV2(_ref) {
4339
4385
  input_el.setSelectionRange(start, end);
4340
4386
  }
4341
4387
  });
4342
- search_field.classList.add("in-modal");
4343
4388
  if (setSearchFieldOuterWidth_) {
4344
4389
  const resizeObserver = new ResizeObserver($3hooq$depictaiutilishared.catchify(records => setSearchFieldOuterWidth_(records.at(-1).contentRect.width)));
4345
4390
  resizeObserver.observe(search_field);
@@ -11117,7 +11162,7 @@ function $a60bc7692ce52705$export$44f738469d5570cf(_ref) {
11117
11162
  bodyAlignmentSignal_: [, setBodyAlignment_],
11118
11163
  backdropStyleSignal_: [, setBackdropStyle_],
11119
11164
  setPollAlignment_: setPollAlignment_,
11120
- submitButton_: submitButton_,
11165
+ buttonInField_: buttonInField_,
11121
11166
  modalSearchFieldOuterWidth_: modalSearchFieldOuterWidth_
11122
11167
  } = _ref;
11123
11168
  return $3hooq$solidjs.createRoot(dispose => {
@@ -11160,7 +11205,7 @@ function $a60bc7692ce52705$export$44f738469d5570cf(_ref) {
11160
11205
  const closeDuration_ = pxOffCenter > 100 ? 150 : 100;
11161
11206
  setPollAlignment_(true);
11162
11207
  // Fade out submit button so there aren't two overlapping buttons for a split second
11163
- submitButton_.animate([{
11208
+ if (pxOffCenter > 10) buttonInField_.animate([{
11164
11209
  opacity: 1
11165
11210
  }, {
11166
11211
  opacity: 0
@@ -11227,6 +11272,8 @@ function $a60bc7692ce52705$export$44f738469d5570cf(_ref) {
11227
11272
  width: width,
11228
11273
  left: left
11229
11274
  } = fakeField.getBoundingClientRect();
11275
+ // Just copy-pasted below line without thinking, it might be wrong
11276
+ const pxOffCenter = Math.abs($3hooq$solidjs.untrack(innerWidthReactive) / 2 - (left + width / 2));
11230
11277
  $ce2f7ec02a8f2173$export$23d40cc5971c3acd({
11231
11278
  setBackdropStyle_: setBackdropStyle_,
11232
11279
  setBodyAlignment_: setBodyAlignment_,
@@ -11242,12 +11289,12 @@ function $a60bc7692ce52705$export$44f738469d5570cf(_ref) {
11242
11289
  duration: closeDuration_,
11243
11290
  fill: "forwards",
11244
11291
  easing: "ease-out"
11245
- }).finished, submitButton_.animate([{
11292
+ }).finished, buttonInField_.animate([{
11246
11293
  opacity: 0
11247
11294
  }, {
11248
11295
  opacity: 1
11249
11296
  }], {
11250
- duration: closeDuration_ / 3,
11297
+ duration: pxOffCenter > 10 ? closeDuration_ / 3 : 1,
11251
11298
  delay: closeDuration_ * (2 / 3),
11252
11299
  fill: "forwards"
11253
11300
  }).finished]);
@@ -11458,7 +11505,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
11458
11505
  if (!input_field_accessor_value) break add_input_field;
11459
11506
  let input_element;
11460
11507
  let div_with_field_class;
11461
- let submitButton_;
11508
+ let buttonInField;
11462
11509
  const search_field = SafeSearchField({
11463
11510
  i18n_: i18n_,
11464
11511
  search_field_value_: search_field_value_,
@@ -11468,7 +11515,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
11468
11515
  field_element_ref_: el => div_with_field_class = el,
11469
11516
  disabled_: true,
11470
11517
  BackIcon_: BackIcon_,
11471
- submit_button_ref_: el => submitButton_ = el
11518
+ buttonInFieldRef_: el => buttonInField = el
11472
11519
  });
11473
11520
  if (!search_field) break add_input_field;
11474
11521
  setModalBodyStyle({});
@@ -11503,7 +11550,7 @@ function $739c927cbecd26b0$export$a54ec244c8863715(_ref) {
11503
11550
  bodyAlignmentSignal_: modal_body_style,
11504
11551
  backdropStyleSignal_: modal_backdrop_style,
11505
11552
  setPollAlignment_: setPollAlignment_,
11506
- submitButton_: submitButton_,
11553
+ buttonInField_: buttonInField,
11507
11554
  modalSearchFieldOuterWidth_: modalSearchFieldOuterWidth_
11508
11555
  });
11509
11556
  }
@@ -12526,7 +12573,7 @@ function $98aef9965764903d$export$316f6f283ae64765(props) {
12526
12573
  const shared_properties = $ddd39c5f36f49703$export$12fa711345994013(depict_search);
12527
12574
  return $d05611ff6b8c8357$export$23fca46f3143581f(() => {
12528
12575
  let input_element;
12529
- let submitButton_;
12576
+ let buttonInField;
12530
12577
  const search_field = $3hooq$solidjsweb.createComponent((0, $29e5dbeb69da7a36$export$b94867ecbd698f21), {
12531
12578
  get BackIcon_() {
12532
12579
  return shared_properties.BackIcon_;
@@ -12545,7 +12592,7 @@ function $98aef9965764903d$export$316f6f283ae64765(props) {
12545
12592
  },
12546
12593
  disabled_: true,
12547
12594
  input_field_ref_: el => input_element = el,
12548
- submit_button_ref_: el => submitButton_ = el,
12595
+ buttonInFieldRef_: el => buttonInField = el,
12549
12596
  field_element_ref_: field => {
12550
12597
  const bodyAlignmentSignal_ = $3hooq$solidjs.createSignal({
12551
12598
  position: "fixed"
@@ -12592,7 +12639,7 @@ function $98aef9965764903d$export$316f6f283ae64765(props) {
12592
12639
  bodyAlignmentSignal_: bodyAlignmentSignal_,
12593
12640
  backdropStyleSignal_: backdropAlignmentSignal_,
12594
12641
  setPollAlignment_: setPollAlignment_,
12595
- submitButton_: submitButton_,
12642
+ buttonInField_: buttonInField,
12596
12643
  modalSearchFieldOuterWidth_: modalSearchFieldOuterWidth_
12597
12644
  });
12598
12645
  }
@@ -10,7 +10,7 @@ import { ProductListingRequestV3 } from "@depict-ai/types/api/ProductListingRequ
10
10
  import { GetListingRequest } from "@depict-ai/types/api/GetListingRequest";
11
11
  import { BaseSearchRequestV3 } from "@depict-ai/types/api/BaseSearchRequestV3";
12
12
  import { SearchFilter as _SearchFilter3 } from "@depict-ai/types/api/SearchRequestV2";
13
- export const version = "4.3.14";
13
+ export const version = "4.4.1";
14
14
  declare const LISTING_ID = "listingId";
15
15
  declare const EXTERNAL_ID = "externalId";
16
16
  type ScrollRestorationData = {