@depict-ai/ui 2.0.5 → 2.0.6

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.js CHANGED
@@ -8,7 +8,7 @@ import $8tj43$babelruntimehelpersdefineProperty from "@babel/runtime/helpers/def
8
8
  /*! Depict.ai search and product listing SDK */
9
9
  import { register_es_version } from "../multi_import_deduplicator.mjs";
10
10
  register_es_version("ui", "ES10");
11
- const $8db9a15135765c11$export$83d89fbfd8236492 = "2.0.5";
11
+ const $8db9a15135765c11$export$83d89fbfd8236492 = "2.0.6";
12
12
 
13
13
  /** @jsxImportSource solid-js */
14
14
 
@@ -1861,6 +1861,7 @@ function $1e7465a8ffa97f6c$var$RangeSelector(_ref3) {
1861
1861
  const [get_current_range] = current_range_;
1862
1862
  const pre_price = $8tj43$createMemo(() => price_formatting_().pre_);
1863
1863
  const post_price = $8tj43$createMemo(() => price_formatting_().post_);
1864
+ const should_be_disabled_ = $8tj43$createMemo(() => Math.abs(min_() - max_()) < 2);
1864
1865
  return (() => {
1865
1866
  const _el$ = $8tj43$getNextElement($1e7465a8ffa97f6c$var$_tmpl$),
1866
1867
  _el$2 = _el$.firstChild,
@@ -1908,7 +1909,8 @@ function $1e7465a8ffa97f6c$var$RangeSelector(_ref3) {
1908
1909
  max_: max_,
1909
1910
  min_: min_,
1910
1911
  current_range_: current_range_,
1911
- i18n_: i18n_
1912
+ i18n_: i18n_,
1913
+ should_be_disabled_: should_be_disabled_
1912
1914
  }), _el$24, _co$7);
1913
1915
  $8tj43$insert(_el$9, pre_price, _el$11, _co$);
1914
1916
  $8tj43$insert(_el$9, $8tj43$createComponent((0, $60ec7a29849d81db$export$a71e92cfbb498adc), {
@@ -1931,18 +1933,24 @@ function $1e7465a8ffa97f6c$var$RangeSelector(_ref3) {
1931
1933
  }), _el$20, _co$5);
1932
1934
  $8tj43$insert(_el$16, post_price, _el$22, _co$6);
1933
1935
  $8tj43$effect(_p$ => {
1934
- const _v$ = i18n_.range_filter_low_point_aria_label_(),
1935
- _v$2 = min_(),
1936
- _v$3 = max_(),
1937
- _v$4 = i18n_.range_filter_high_point_aria_label_(),
1938
- _v$5 = min_(),
1939
- _v$6 = max_();
1940
- _v$ !== _p$._v$ && $8tj43$setAttribute(_el$4, "aria-label", _p$._v$ = _v$);
1941
- _v$2 !== _p$._v$2 && $8tj43$setAttribute(_el$4, "min", _p$._v$2 = _v$2);
1942
- _v$3 !== _p$._v$3 && $8tj43$setAttribute(_el$4, "max", _p$._v$3 = _v$3);
1943
- _v$4 !== _p$._v$4 && $8tj43$setAttribute(_el$7, "aria-label", _p$._v$4 = _v$4);
1944
- _v$5 !== _p$._v$5 && $8tj43$setAttribute(_el$7, "min", _p$._v$5 = _v$5);
1945
- _v$6 !== _p$._v$6 && $8tj43$setAttribute(_el$7, "max", _p$._v$6 = _v$6);
1936
+ const _v$ = !!(min_() === max_()),
1937
+ _v$2 = should_be_disabled_(),
1938
+ _v$3 = i18n_.range_filter_low_point_aria_label_(),
1939
+ _v$4 = min_(),
1940
+ _v$5 = max_(),
1941
+ _v$6 = should_be_disabled_(),
1942
+ _v$7 = i18n_.range_filter_high_point_aria_label_(),
1943
+ _v$8 = min_(),
1944
+ _v$9 = max_();
1945
+ _v$ !== _p$._v$ && _el$.classList.toggle("disabled", _p$._v$ = _v$);
1946
+ _v$2 !== _p$._v$2 && (_el$4.disabled = _p$._v$2 = _v$2);
1947
+ _v$3 !== _p$._v$3 && $8tj43$setAttribute(_el$4, "aria-label", _p$._v$3 = _v$3);
1948
+ _v$4 !== _p$._v$4 && $8tj43$setAttribute(_el$4, "min", _p$._v$4 = _v$4);
1949
+ _v$5 !== _p$._v$5 && $8tj43$setAttribute(_el$4, "max", _p$._v$5 = _v$5);
1950
+ _v$6 !== _p$._v$6 && (_el$7.disabled = _p$._v$6 = _v$6);
1951
+ _v$7 !== _p$._v$7 && $8tj43$setAttribute(_el$7, "aria-label", _p$._v$7 = _v$7);
1952
+ _v$8 !== _p$._v$8 && $8tj43$setAttribute(_el$7, "min", _p$._v$8 = _v$8);
1953
+ _v$9 !== _p$._v$9 && $8tj43$setAttribute(_el$7, "max", _p$._v$9 = _v$9);
1946
1954
  return _p$;
1947
1955
  }, {
1948
1956
  _v$: undefined,
@@ -1950,7 +1958,10 @@ function $1e7465a8ffa97f6c$var$RangeSelector(_ref3) {
1950
1958
  _v$3: undefined,
1951
1959
  _v$4: undefined,
1952
1960
  _v$5: undefined,
1953
- _v$6: undefined
1961
+ _v$6: undefined,
1962
+ _v$7: undefined,
1963
+ _v$8: undefined,
1964
+ _v$9: undefined
1954
1965
  });
1955
1966
  $8tj43$effect(() => _el$4.value = get_current_range()[0]);
1956
1967
  $8tj43$effect(() => _el$7.value = get_current_range()[1]);
@@ -1963,7 +1974,8 @@ function $1e7465a8ffa97f6c$var$ExponentialSlider(_ref6) {
1963
1974
  current_range_: current_range_,
1964
1975
  min_: min_,
1965
1976
  i18n_: i18n_,
1966
- max_: max_
1977
+ max_: max_,
1978
+ should_be_disabled_: should_be_disabled_
1967
1979
  } = _ref6;
1968
1980
  // inspired by https://observablehq.com/@mbostock/nonlinear-slider
1969
1981
  const transform_linear_to_nonlinear = _ref7 => {
@@ -1971,8 +1983,7 @@ function $1e7465a8ffa97f6c$var$ExponentialSlider(_ref6) {
1971
1983
  return [Math.sqrt(smaller), Math.sqrt(larger)];
1972
1984
  };
1973
1985
  const [read_current_range, write_current_range] = current_range_;
1974
- const modified_range = $8tj43$createSignal(transform_linear_to_nonlinear($8tj43$untrack(read_current_range)));
1975
- const [read_modified_range, write_modified_range] = modified_range;
1986
+ const modified_range_accessor = $8tj43$createMemo(() => transform_linear_to_nonlinear(read_current_range()));
1976
1987
  const modified_max = $8tj43$createMemo(() => Math.sqrt(max_()));
1977
1988
  const modified_min = $8tj43$createMemo(() => Math.sqrt(min_()));
1978
1989
  const offset_value_calculator_ = (value, how_many) => {
@@ -1980,36 +1991,39 @@ function $1e7465a8ffa97f6c$var$ExponentialSlider(_ref6) {
1980
1991
  const changed = number_in_linear + how_many;
1981
1992
  return Math.sqrt(changed);
1982
1993
  };
1983
- $8tj43$createComputed($8tj43$on(read_current_range, new_range_from_above => {
1984
- // to prevent from infinite looping, don't write if it's around the same
1985
- const new_modified_range = transform_linear_to_nonlinear(new_range_from_above);
1986
- const current_modified_range = read_modified_range();
1987
- if (!current_modified_range.every((item, index) => Math.round(item) === Math.round(new_modified_range[index]))) write_modified_range(new_modified_range);
1988
- }, {
1989
- defer: true
1990
- }));
1991
- $8tj43$createComputed($8tj43$on(read_modified_range, _ref8 => {
1992
- let [smaller, larger] = _ref8;
1993
- return write_current_range([Math.round(smaller * smaller), Math.round(larger * larger)]);
1994
- }, {
1995
- defer: true
1996
- }));
1994
+ const convert_back = (smaller, larger) => [Math.round(smaller * smaller), Math.round(larger * larger)];
1995
+ const modified_range_setter = new_range_or_function => {
1996
+ const old_range = $8tj43$untrack(modified_range_accessor);
1997
+ const new_range = typeof new_range_or_function === "function" ? new_range_or_function(old_range) : new_range_or_function;
1998
+ const [smaller, larger] = new_range;
1999
+ const [old_smaller, old_larger] = old_range;
2000
+ const new_range_converted = convert_back(smaller, larger);
2001
+ const old_range_converted = convert_back(old_smaller, old_larger);
2002
+ if (new_range_converted[0] === old_range_converted[0] && new_range_converted[1] === old_range_converted[1])
2003
+ // If the new value gets identical rounding errors to the old value when being converted back, don't write it to the signal since it would cause an infinite loop
2004
+ return new_range;
2005
+ write_current_range(new_range_converted);
2006
+ return new_range;
2007
+ };
1997
2008
  return $1e7465a8ffa97f6c$var$LinearSlider({
1998
- current_range_: modified_range,
2009
+ current_range_: [modified_range_accessor, modified_range_setter],
2010
+ // "Lie" to the actual slider so we don't have to implement exponential handling in there
1999
2011
  min_: modified_min,
2000
2012
  max_: modified_max,
2001
2013
  offset_value_calculator_: offset_value_calculator_,
2002
- i18n_: i18n_
2014
+ i18n_: i18n_,
2015
+ should_be_disabled_: should_be_disabled_
2003
2016
  });
2004
2017
  }
2005
- function $1e7465a8ffa97f6c$var$LinearSlider(_ref9) {
2018
+ function $1e7465a8ffa97f6c$var$LinearSlider(_ref8) {
2006
2019
  let {
2007
2020
  max_: max_,
2008
2021
  min_: min_,
2009
2022
  current_range_: current_range_,
2010
2023
  offset_value_calculator_: offset_value_calculator_,
2011
- i18n_: i18n_
2012
- } = _ref9;
2024
+ i18n_: i18n_,
2025
+ should_be_disabled_: should_be_disabled_
2026
+ } = _ref8;
2013
2027
  let range_input_1;
2014
2028
  let range_input_2;
2015
2029
  let clickable_slider;
@@ -2018,6 +2032,7 @@ function $1e7465a8ffa97f6c$var$LinearSlider(_ref9) {
2018
2032
  const min = min_();
2019
2033
  const span = max_() - min;
2020
2034
  const [start, end] = get_current_range();
2035
+ if (should_be_disabled_()) return "left:50%;right:50%";
2021
2036
  return "left:".concat((start - min) / span * 100, "%;right:").concat(100 - (end - min) / span * 100, "%");
2022
2037
  });
2023
2038
  const set_value = (el, index) => {
@@ -2067,26 +2082,32 @@ function $1e7465a8ffa97f6c$var$LinearSlider(_ref9) {
2067
2082
  }, _el$29);
2068
2083
  $8tj43$addEventListener(_el$29, "input", $8tj43$catchify(() => $1e7465a8ffa97f6c$var$set_range_with_sanitation(min_, max_, current_range_, 1, range_input_2, offset_value_calculator_)), true);
2069
2084
  $8tj43$effect(_p$ => {
2070
- const _v$7 = i18n_.range_filter_low_point_aria_label_(),
2071
- _v$8 = min_(),
2072
- _v$9 = max_(),
2073
- _v$10 = i18n_.range_filter_high_point_aria_label_(),
2074
- _v$11 = min_(),
2075
- _v$12 = max_();
2076
- _v$7 !== _p$._v$7 && $8tj43$setAttribute(_el$28, "aria-label", _p$._v$7 = _v$7);
2077
- _v$8 !== _p$._v$8 && $8tj43$setAttribute(_el$28, "min", _p$._v$8 = _v$8);
2078
- _v$9 !== _p$._v$9 && $8tj43$setAttribute(_el$28, "max", _p$._v$9 = _v$9);
2079
- _v$10 !== _p$._v$10 && $8tj43$setAttribute(_el$29, "aria-label", _p$._v$10 = _v$10);
2080
- _v$11 !== _p$._v$11 && $8tj43$setAttribute(_el$29, "min", _p$._v$11 = _v$11);
2081
- _v$12 !== _p$._v$12 && $8tj43$setAttribute(_el$29, "max", _p$._v$12 = _v$12);
2085
+ const _v$10 = should_be_disabled_(),
2086
+ _v$11 = i18n_.range_filter_low_point_aria_label_(),
2087
+ _v$12 = min_(),
2088
+ _v$13 = max_(),
2089
+ _v$14 = should_be_disabled_(),
2090
+ _v$15 = i18n_.range_filter_high_point_aria_label_(),
2091
+ _v$16 = min_(),
2092
+ _v$17 = max_();
2093
+ _v$10 !== _p$._v$10 && (_el$28.disabled = _p$._v$10 = _v$10);
2094
+ _v$11 !== _p$._v$11 && $8tj43$setAttribute(_el$28, "aria-label", _p$._v$11 = _v$11);
2095
+ _v$12 !== _p$._v$12 && $8tj43$setAttribute(_el$28, "min", _p$._v$12 = _v$12);
2096
+ _v$13 !== _p$._v$13 && $8tj43$setAttribute(_el$28, "max", _p$._v$13 = _v$13);
2097
+ _v$14 !== _p$._v$14 && (_el$29.disabled = _p$._v$14 = _v$14);
2098
+ _v$15 !== _p$._v$15 && $8tj43$setAttribute(_el$29, "aria-label", _p$._v$15 = _v$15);
2099
+ _v$16 !== _p$._v$16 && $8tj43$setAttribute(_el$29, "min", _p$._v$16 = _v$16);
2100
+ _v$17 !== _p$._v$17 && $8tj43$setAttribute(_el$29, "max", _p$._v$17 = _v$17);
2082
2101
  return _p$;
2083
2102
  }, {
2084
- _v$7: undefined,
2085
- _v$8: undefined,
2086
- _v$9: undefined,
2087
2103
  _v$10: undefined,
2088
2104
  _v$11: undefined,
2089
- _v$12: undefined
2105
+ _v$12: undefined,
2106
+ _v$13: undefined,
2107
+ _v$14: undefined,
2108
+ _v$15: undefined,
2109
+ _v$16: undefined,
2110
+ _v$17: undefined
2090
2111
  });
2091
2112
  $8tj43$effect(() => _el$28.value = $8tj43$createMemo(() => {
2092
2113
  min_();
@@ -2396,59 +2417,62 @@ function $0ae614c5c7babb43$var$render_stuff(data, existing_filter, i18n_) {
2396
2417
  return has_expandable();
2397
2418
  },
2398
2419
  get children() {
2399
- return $8tj43$createComponent((0, $ad371564683947ab$export$6c6d7a51fa9aa15d), {
2400
- get details_() {
2401
- return $8tj43$getNextElement($0ae614c5c7babb43$var$_tmpl$3);
2402
- },
2403
- get summary_() {
2404
- return (() => {
2405
- const _el$12 = $8tj43$getNextElement($0ae614c5c7babb43$var$_tmpl$4),
2406
- _el$13 = _el$12.firstChild,
2407
- _el$14 = _el$13.firstChild,
2408
- _el$15 = _el$14.nextSibling,
2409
- [_el$16, _co$5] = $8tj43$getNextMarker(_el$15.nextSibling);
2410
- $8tj43$insert(_el$14, () => {
2411
- var _value10;
2412
- return (_value10 = value()) === null || _value10 === void 0 ? void 0 : _value10.count_;
2413
- });
2414
- $8tj43$insert(_el$13, $8tj43$createComponent((0, $457279ff15864cb9$export$e5c2828934226505), {
2415
- i18n_: i18n_,
2416
- get expanded_() {
2417
- return $8tj43$createMemo(() => {
2418
- var _value$is_expanded_$u, _value11, _value11$is_expanded_, _value11$is_expanded_2;
2419
- return (_value$is_expanded_$u = (_value11 = value()) === null || _value11 === void 0 ? void 0 : (_value11$is_expanded_ = _value11.is_expanded_) === null || _value11$is_expanded_ === void 0 ? void 0 : (_value11$is_expanded_2 = _value11$is_expanded_.ui_should_show_expanded_) === null || _value11$is_expanded_2 === void 0 ? void 0 : _value11$is_expanded_2.call(_value11$is_expanded_)) !== null && _value$is_expanded_$u !== void 0 ? _value$is_expanded_$u : false;
2420
- });
2421
- }
2422
- }), _el$16, _co$5);
2423
- $8tj43$effect(() => {
2424
- var _value12;
2425
- return _el$14.classList.toggle("count-0", !!(((_value12 = value()) === null || _value12 === void 0 ? void 0 : _value12.count_) === 0));
2426
- });
2427
- return _el$12;
2428
- })();
2429
- },
2430
- get is_open_() {
2431
- return $8tj43$createMemo(() => {
2432
- const v = value();
2433
- if (!v)
2434
- // only to prevent cleanup errors
2435
- return $8tj43$createSignal(false);
2436
- const {
2437
- is_expanded_: {
2438
- ui_should_show_expanded_: ui_should_show_expanded_,
2439
- set_user_expanded_: set_user_expanded_
2440
- }
2441
- } = v;
2442
- return [ui_should_show_expanded_, set_user_expanded_];
2443
- })();
2444
- },
2445
- get children() {
2446
- return $0ae614c5c7babb43$var$render_stuff($8tj43$createMemo(() => {
2447
- var _value13;
2448
- return ((_value13 = value()) === null || _value13 === void 0 ? void 0 : _value13.children_) || {};
2449
- }), existing_filter, i18n_);
2450
- }
2451
- });
2420
+ return (() => {
2421
+ const is_open = $8tj43$createMemo(() => {
2422
+ const v = value();
2423
+ if (!v)
2424
+ // only to prevent cleanup errors
2425
+ return $8tj43$createSignal(false);
2426
+ const {
2427
+ is_expanded_: {
2428
+ ui_should_show_expanded_: ui_should_show_expanded_,
2429
+ set_user_expanded_: set_user_expanded_
2430
+ }
2431
+ } = v;
2432
+ return [ui_should_show_expanded_, set_user_expanded_];
2433
+ });
2434
+ return $8tj43$createComponent((0, $ad371564683947ab$export$6c6d7a51fa9aa15d), {
2435
+ get details_() {
2436
+ return $8tj43$getNextElement($0ae614c5c7babb43$var$_tmpl$3);
2437
+ },
2438
+ get summary_() {
2439
+ return (() => {
2440
+ const _el$12 = $8tj43$getNextElement($0ae614c5c7babb43$var$_tmpl$4),
2441
+ _el$13 = _el$12.firstChild,
2442
+ _el$14 = _el$13.firstChild,
2443
+ _el$15 = _el$14.nextSibling,
2444
+ [_el$16, _co$5] = $8tj43$getNextMarker(_el$15.nextSibling);
2445
+ $8tj43$insert(_el$14, () => {
2446
+ var _value10;
2447
+ return (_value10 = value()) === null || _value10 === void 0 ? void 0 : _value10.count_;
2448
+ });
2449
+ $8tj43$insert(_el$13, $8tj43$createComponent((0, $457279ff15864cb9$export$e5c2828934226505), {
2450
+ i18n_: i18n_,
2451
+ get expanded_() {
2452
+ return $8tj43$createMemo(() => {
2453
+ var _value$is_expanded_$u, _value11, _value11$is_expanded_, _value11$is_expanded_2;
2454
+ return (_value$is_expanded_$u = (_value11 = value()) === null || _value11 === void 0 ? void 0 : (_value11$is_expanded_ = _value11.is_expanded_) === null || _value11$is_expanded_ === void 0 ? void 0 : (_value11$is_expanded_2 = _value11$is_expanded_.ui_should_show_expanded_) === null || _value11$is_expanded_2 === void 0 ? void 0 : _value11$is_expanded_2.call(_value11$is_expanded_)) !== null && _value$is_expanded_$u !== void 0 ? _value$is_expanded_$u : false;
2455
+ });
2456
+ }
2457
+ }), _el$16, _co$5);
2458
+ $8tj43$effect(() => {
2459
+ var _value12;
2460
+ return _el$14.classList.toggle("count-0", !!(((_value12 = value()) === null || _value12 === void 0 ? void 0 : _value12.count_) === 0));
2461
+ });
2462
+ return _el$12;
2463
+ })();
2464
+ },
2465
+ get is_open_() {
2466
+ return is_open();
2467
+ },
2468
+ get children() {
2469
+ return $0ae614c5c7babb43$var$render_stuff($8tj43$createMemo(() => {
2470
+ var _value13;
2471
+ return ((_value13 = value()) === null || _value13 === void 0 ? void 0 : _value13.children_) || {};
2472
+ }), existing_filter, i18n_);
2473
+ }
2474
+ });
2475
+ })();
2452
2476
  }
2453
2477
  }), _el$10, _co$4);
2454
2478
  $8tj43$effect(() => _el$6.classList.toggle("expandable", !!has_expandable()));
@@ -2516,7 +2540,7 @@ function $0ae614c5c7babb43$var$create_updating_signal(_ref3) {
2516
2540
  // wait for the children to have populated and us to have received the correct value_ and name_ values
2517
2541
  let updating_blocked = false;
2518
2542
  const index_of_us_in_selected_filter = existing_filter_ === null || existing_filter_ === void 0 ? void 0 : (_existing_filter_$dat = existing_filter_.data) === null || _existing_filter_$dat === void 0 ? void 0 : (_existing_filter_$dat2 = _existing_filter_$dat.findIndex) === null || _existing_filter_$dat2 === void 0 ? void 0 : _existing_filter_$dat2.call(_existing_filter_$dat, el => el.length === self_.value_.length && el.every((sub_el, index) => self_.value_[index] === sub_el));
2519
- signal_.push(...$8tj43$createSignal(index_of_us_in_selected_filter >= 0 ? true : false));
2543
+ signal_.push(...$8tj43$createSignal(index_of_us_in_selected_filter >= 0));
2520
2544
  const [read_checked, write_checked] = signal_;
2521
2545
  const child_objects = Object.values(self_.children_);
2522
2546
  const get_child_object_values = child_objects.map(_ref4 => {