@depict-ai/ui 2.0.1 → 2.0.2

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
@@ -5,7 +5,7 @@ import { createMemo as $9HbP8$createMemo, createResource as $9HbP8$createResourc
5
5
  /*! Depict.ai search and product listing SDK */
6
6
  import { register_es_version } from "../multi_import_deduplicator.mjs";
7
7
  register_es_version("ui", "latest");
8
- const $ec291e0010116877$export$83d89fbfd8236492 = "2.0.1";
8
+ const $ec291e0010116877$export$83d89fbfd8236492 = "2.0.2";
9
9
  const $b5cccc8ee7d24677$var$transform_elements = sorted_cols_at_size => {
10
10
  const cols_at_size = [];
11
11
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -1362,9 +1362,9 @@ function $1adfe60f3a14a1d7$export$fecbb157621501bd({
1362
1362
  return outmost_element;
1363
1363
  }
1364
1364
  $9HbP8$delegateEvents(["click"]);
1365
- const $87c712b5b33f24f7$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<span class="count"></span>`, 2),
1366
- $87c712b5b33f24f7$var$_tmpl$2 = /*#__PURE__*/$9HbP8$template(`<label class="input-row"><div class="left"><input type="checkbox"><span class="custom-indicator"></span><span class="text line-clamp"></span></div><!#><!/></label>`, 11);
1367
- const $87c712b5b33f24f7$export$48513f6b9f8ce62d = props => {
1365
+ const $49b79728e7d9e2a1$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<span class="count"></span>`, 2),
1366
+ $49b79728e7d9e2a1$var$_tmpl$2 = /*#__PURE__*/$9HbP8$template(`<label class="input-row"><div class="left"><input type="checkbox"><span class="custom-indicator"></span><span class="text line-clamp"></span></div><!#><!/></label>`, 11);
1367
+ const $49b79728e7d9e2a1$export$48513f6b9f8ce62d = props => {
1368
1368
  // It seems like there's no diffing without memos here (since we often just have computations in the getters above that update to the same result often because their dependencies change with unrelated changes often), so put memos here to avoid unneeded DOM changes
1369
1369
  const count = $9HbP8$createMemo(() => props.count_);
1370
1370
  const label = $9HbP8$createMemo(() => props.label_);
@@ -1373,7 +1373,7 @@ const $87c712b5b33f24f7$export$48513f6b9f8ce62d = props => {
1373
1373
  const is_count_zero = $9HbP8$createMemo(() => props.is_count_zero_ || count() === 0);
1374
1374
  const id = $9HbP8$make_random_classname();
1375
1375
  return (/* We can't use actual margin because ExpandingContainer gets messed up */(() => {
1376
- const _el$ = $9HbP8$getNextElement($87c712b5b33f24f7$var$_tmpl$2),
1376
+ const _el$ = $9HbP8$getNextElement($49b79728e7d9e2a1$var$_tmpl$2),
1377
1377
  _el$2 = _el$.firstChild,
1378
1378
  _el$3 = _el$2.firstChild,
1379
1379
  _el$4 = _el$3.nextSibling,
@@ -1400,7 +1400,7 @@ const $87c712b5b33f24f7$export$48513f6b9f8ce62d = props => {
1400
1400
  return count() != undefined;
1401
1401
  },
1402
1402
  get children() {
1403
- const _el$6 = $9HbP8$getNextElement($87c712b5b33f24f7$var$_tmpl$);
1403
+ const _el$6 = $9HbP8$getNextElement($49b79728e7d9e2a1$var$_tmpl$);
1404
1404
  $9HbP8$insert(_el$6, count);
1405
1405
  return _el$6;
1406
1406
  }
@@ -1488,7 +1488,7 @@ function $a4601e6bea3ed1e6$export$dd948f91abc3a1c4({
1488
1488
  });
1489
1489
  const render_checkbox = checkbox => {
1490
1490
  // Checkbox always calls the getters in props, so we don't wrap these values into memos
1491
- return $9HbP8$createComponent((0, $87c712b5b33f24f7$export$48513f6b9f8ce62d), {
1491
+ return $9HbP8$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
1492
1492
  get value_() {
1493
1493
  return checkbox().value_;
1494
1494
  },
@@ -2190,7 +2190,7 @@ function $1c8cac76cb67e9af$var$render_stuff(data, existing_filter, i18n_) {
2190
2190
  [_el$8, _co$3] = $9HbP8$getNextMarker(_el$7.nextSibling),
2191
2191
  _el$9 = _el$8.nextSibling,
2192
2192
  [_el$10, _co$4] = $9HbP8$getNextMarker(_el$9.nextSibling);
2193
- $9HbP8$insert(_el$6, $9HbP8$createComponent((0, $87c712b5b33f24f7$export$48513f6b9f8ce62d), {
2193
+ $9HbP8$insert(_el$6, $9HbP8$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
2194
2194
  get value_() {
2195
2195
  return JSON.stringify(value()?.value_);
2196
2196
  },
@@ -2444,9 +2444,26 @@ function $1c8cac76cb67e9af$var$expand_until_choice(data_structure) {
2444
2444
  }
2445
2445
  });
2446
2446
  }
2447
- const $93716a9ad0dea854$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<div class="checkbox-grid"></div>`, 2),
2447
+
2448
+ /** @jsxImportSource solid-js */
2449
+
2450
+ function $0fdb37d8ddabef25$export$9f191182275e9ef(what_to_watch) {
2451
+ const [size, setSize] = $9HbP8$createSignal();
2452
+ const resizeObserver = new ResizeObserver($9HbP8$catchify(records => {
2453
+ for (let j = 0; j < records.length; j++) {
2454
+ const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
2455
+ setSize(width);
2456
+ }
2457
+ }));
2458
+ resizeObserver.observe(what_to_watch);
2459
+ $9HbP8$onCleanup(() => resizeObserver.disconnect());
2460
+ return size;
2461
+ }
2462
+ const $93716a9ad0dea854$var$_tmpl$ = /*#__PURE__*/$9HbP8$template(`<div class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0"></div>`, 2),
2448
2463
  $93716a9ad0dea854$var$_tmpl$2 = /*#__PURE__*/$9HbP8$template(`<span class="count-wrapper"><span class="count"></span></span>`, 4),
2449
- $93716a9ad0dea854$var$_tmpl$3 = /*#__PURE__*/$9HbP8$template(`<button class="major-minor-transition"><!#><!/><!#><!/></button>`, 6);
2464
+ $93716a9ad0dea854$var$_tmpl$3 = /*#__PURE__*/$9HbP8$template(`<button><!#><!/><!#><!/></button>`, 6);
2465
+ const $93716a9ad0dea854$var$gap_px = 5;
2466
+ const $93716a9ad0dea854$var$max_columns = 3;
2450
2467
  const $93716a9ad0dea854$export$414f6a19d38e655c = ({
2451
2468
  filter_: filter_,
2452
2469
  selected_filters_: [get_selected_filters, set_selected_filters]
@@ -2469,74 +2486,182 @@ const $93716a9ad0dea854$export$414f6a19d38e655c = ({
2469
2486
  count_: meta.counts?.[index]
2470
2487
  }));
2471
2488
  });
2472
- return (() => {
2489
+ const [sizes_set, set_sizes_set] = $9HbP8$createSignal(new Set(), {
2490
+ equals: false
2491
+ });
2492
+ const [cols_at_size, set_cols_at_size] = $9HbP8$createSignal([[1, "0px", ""]]);
2493
+ const [container, set_container] = $9HbP8$createSignal();
2494
+ const container_width_accessor = $9HbP8$createMemo(() => {
2495
+ const element = container();
2496
+ if (!element) return;
2497
+ return $0fdb37d8ddabef25$export$9f191182275e9ef(element);
2498
+ });
2499
+ const [shadow_children, set_shadow_children] = $9HbP8$createSignal(new Set(), {
2500
+ equals: false
2501
+ });
2502
+ const shadow_grid = (() => {
2473
2503
  const _el$ = $9HbP8$getNextElement($93716a9ad0dea854$var$_tmpl$);
2474
- $9HbP8$insert(_el$, $9HbP8$createComponent((0, $9HbP8$Index), {
2475
- get each() {
2476
- return buttons();
2477
- },
2478
- children: value => {
2479
- const is_selected = $9HbP8$createMemo(() => existing_filter()?.data?.includes(value().value_));
2480
- return (() => {
2481
- const _el$2 = $9HbP8$getNextElement($93716a9ad0dea854$var$_tmpl$3),
2482
- _el$5 = _el$2.firstChild,
2483
- [_el$6, _co$] = $9HbP8$getNextMarker(_el$5.nextSibling),
2484
- _el$7 = _el$6.nextSibling,
2485
- [_el$8, _co$2] = $9HbP8$getNextMarker(_el$7.nextSibling);
2486
- $9HbP8$addEventListener(_el$2, "click", $9HbP8$catchify(() => {
2487
- const set_filter = existing_filter();
2488
- const {
2489
- field: field,
2490
- op: op
2491
- } = filter_();
2492
- const base_object = set_filter ? set_filter : {
2493
- op: op,
2494
- field: field
2495
- };
2496
- const old_data = base_object.data;
2497
- const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
2498
- const new_filter_object = {
2499
- ...base_object,
2500
- data: new_data
2501
- };
2502
- if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
2503
- const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
2504
- set_selected_filters(selected_filters);
2505
- }), true);
2506
- $9HbP8$insert(_el$2, () => value().value_, _el$6, _co$);
2507
- $9HbP8$insert(_el$2, $9HbP8$createComponent((0, $9HbP8$Show), {
2508
- get when() {
2509
- return value().count_ != undefined;
2510
- },
2511
- get children() {
2512
- const _el$3 = $9HbP8$getNextElement($93716a9ad0dea854$var$_tmpl$2),
2513
- _el$4 = _el$3.firstChild;
2514
- $9HbP8$insert(_el$4, () => value().count_);
2515
- return _el$3;
2516
- }
2517
- }), _el$8, _co$2);
2518
- $9HbP8$effect(_p$ => {
2519
- const _v$ = value().count_ === 0 && !is_selected(),
2520
- _v$2 = !is_selected(),
2521
- _v$3 = !!is_selected();
2522
- _v$ !== _p$._v$ && (_el$2.disabled = _p$._v$ = _v$);
2523
- _v$2 !== _p$._v$2 && _el$2.classList.toggle("minor", _p$._v$2 = _v$2);
2524
- _v$3 !== _p$._v$3 && _el$2.classList.toggle("major", _p$._v$3 = _v$3);
2525
- return _p$;
2526
- }, {
2527
- _v$: undefined,
2528
- _v$2: undefined,
2529
- _v$3: undefined
2530
- });
2531
- $9HbP8$runHydrationEvents();
2532
- return _el$2;
2533
- })();
2534
- }
2535
- }));
2504
+ $9HbP8$insert(_el$, () => [...shadow_children()]);
2536
2505
  return _el$;
2537
- })();
2506
+ })(); // for getting the smallest possible sizes of all the items
2507
+ $9HbP8$createEffect(() => {
2508
+ const container_width = container_width_accessor()?.();
2509
+ if (container_width == undefined) return;
2510
+ $93716a9ad0dea854$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
2511
+ });
2512
+ return [shadow_grid, $9HbP8$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), {
2513
+ get cols_at_size() {
2514
+ return cols_at_size();
2515
+ },
2516
+ grid_spacing: $93716a9ad0dea854$var$gap_px + "px",
2517
+ rows: "all",
2518
+ layout: "grid",
2519
+ element_attributes: {
2520
+ class: "checkbox-grid",
2521
+ ref: el => set_container(el)
2522
+ },
2523
+ get children() {
2524
+ return $9HbP8$createComponent((0, $9HbP8$Index), {
2525
+ get each() {
2526
+ return buttons();
2527
+ },
2528
+ children: value => {
2529
+ const is_selected = $9HbP8$createMemo(() => existing_filter()?.data?.includes(value().value_));
2530
+ const MakeButton = attributes => (() => {
2531
+ const _el$2 = $9HbP8$getNextElement($93716a9ad0dea854$var$_tmpl$3),
2532
+ _el$5 = _el$2.firstChild,
2533
+ [_el$6, _co$] = $9HbP8$getNextMarker(_el$5.nextSibling),
2534
+ _el$7 = _el$6.nextSibling,
2535
+ [_el$8, _co$2] = $9HbP8$getNextMarker(_el$7.nextSibling);
2536
+ $9HbP8$spread(_el$2, $9HbP8$mergeProps(attributes, {
2537
+ get disabled() {
2538
+ return $9HbP8$memo(() => value().count_ === 0)() && !is_selected();
2539
+ },
2540
+ get classList() {
2541
+ return {
2542
+ minor: !is_selected(),
2543
+ major: is_selected(),
2544
+ "major-minor-transition": true
2545
+ };
2546
+ },
2547
+ get onClick() {
2548
+ return $9HbP8$catchify(() => {
2549
+ const set_filter = existing_filter();
2550
+ const {
2551
+ field: field,
2552
+ op: op
2553
+ } = filter_();
2554
+ const base_object = set_filter ? set_filter : {
2555
+ op: op,
2556
+ field: field
2557
+ };
2558
+ const old_data = base_object.data;
2559
+ const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
2560
+ const new_filter_object = {
2561
+ ...base_object,
2562
+ data: new_data
2563
+ };
2564
+ if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
2565
+ const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
2566
+ set_selected_filters(selected_filters);
2567
+ });
2568
+ }
2569
+ }), false, true);
2570
+ $9HbP8$insert(_el$2, () => value().value_, _el$6, _co$);
2571
+ $9HbP8$insert(_el$2, $9HbP8$createComponent((0, $9HbP8$Show), {
2572
+ get when() {
2573
+ return value().count_ != undefined;
2574
+ },
2575
+ get children() {
2576
+ const _el$3 = $9HbP8$getNextElement($93716a9ad0dea854$var$_tmpl$2),
2577
+ _el$4 = _el$3.firstChild;
2578
+ $9HbP8$insert(_el$4, () => value().count_);
2579
+ return _el$3;
2580
+ }
2581
+ }), _el$8, _co$2);
2582
+ $9HbP8$runHydrationEvents();
2583
+ return _el$2;
2584
+ })();
2585
+ const invisible_size_button = $9HbP8$createComponent(MakeButton, {});
2586
+ const smallest_possible_size = $0fdb37d8ddabef25$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2587
+ const sizes_value = $9HbP8$untrack(sizes_set);
2588
+ const shadow_children_value = $9HbP8$untrack(shadow_children);
2589
+ sizes_value.add(smallest_possible_size);
2590
+ set_sizes_set(sizes_value);
2591
+ shadow_children_value.add(invisible_size_button);
2592
+ set_shadow_children(shadow_children_value);
2593
+ $9HbP8$onCleanup(() => {
2594
+ const sizes_value = $9HbP8$untrack(sizes_set);
2595
+ const shadow_children_value = $9HbP8$untrack(shadow_children);
2596
+ sizes_value.delete(smallest_possible_size);
2597
+ set_sizes_set(sizes_value);
2598
+ shadow_children_value.delete(invisible_size_button);
2599
+ set_shadow_children(shadow_children_value);
2600
+ });
2601
+ // The actual button that will be visible
2602
+ return $9HbP8$createComponent(MakeButton, {});
2603
+ }
2604
+ });
2605
+ }
2606
+ })];
2538
2607
  };
2539
- $9HbP8$delegateEvents(["click"]);
2608
+ /**
2609
+ * Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
2610
+ */
2611
+ function $93716a9ad0dea854$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
2612
+ let current_row_index = 0;
2613
+ let current_row_items = [];
2614
+ const column_to_row_result = {};
2615
+ const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
2616
+ const would_have_even_size = container_width / at_number_of_columnns - (at_number_of_columnns * 2 - 2) * ($93716a9ad0dea854$var$gap_px / 2) / at_number_of_columnns; // What size would our element have (without gaps), given that now every column had the same width (equation from Layout.tsx)
2617
+ return would_have_even_size >= min_size_of_item; // would this item still fit if we added another column? (probably what the caller has done with at_number_of_columns), given that every item has the same size
2618
+ };
2619
+
2620
+ for (const size_item of sizes) {
2621
+ const size = size_item();
2622
+ if (size == undefined) return; // Only do stuff if we know all the sizes
2623
+ const current_row_length = current_row_items.length;
2624
+ const can_add_another_column_initial_val = current_row_length < $93716a9ad0dea854$var$max_columns; // allow max 4 items per row
2625
+ let can_add_another_column = can_add_another_column_initial_val;
2626
+ if (can_add_another_column)
2627
+ // can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
2628
+ for (let i = -1; i < current_row_length; i++) {
2629
+ // -1 is for the new item we're adding and every item is guaranteed to exist
2630
+ const size_to_check = current_row_items[i] ?? size;
2631
+ const would_have_columns = current_row_length + 1; // if we added another column
2632
+ const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
2633
+ if (!would_fit_evenly) {
2634
+ can_add_another_column = false;
2635
+ break;
2636
+ }
2637
+ }
2638
+ if (can_add_another_column) current_row_items.push(size);else {
2639
+ column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
2640
+ current_row_items = [size]; // save current item for next row
2641
+ }
2642
+ }
2643
+
2644
+ const items_left_to_add = current_row_items.length;
2645
+ if (items_left_to_add) {
2646
+ let num_columns = 1; // We want to have as close to max_columns as possible in the last row
2647
+ let fits = true;
2648
+ do
2649
+ // Check if more columns would fit
2650
+ for (let i = 0; i < items_left_to_add; i++) {
2651
+ const item = current_row_items[i];
2652
+ const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
2653
+ if (!would_fit_evenly) {
2654
+ fits = false;
2655
+ break;
2656
+ }
2657
+ } while (fits && ++num_columns < $93716a9ad0dea854$var$max_columns);
2658
+ column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
2659
+ }
2660
+
2661
+ set_cols_at_size([[1, "0px", "", null, {
2662
+ overrides: column_to_row_result
2663
+ }]]);
2664
+ }
2540
2665
  function $dc9262ef6f786812$export$d9f36cf74e24d595(media_query) {
2541
2666
  const signal = $9HbP8$createSignal(false);
2542
2667
  $9HbP8$onCleanup($9HbP8$javascript_media_query(media_query, ({
@@ -2581,7 +2706,7 @@ function $e731d52d97444b7c$export$82ed4b28ecb67608({
2581
2706
  const hex_color = $9HbP8$createMemo(() => checkbox().value_.split(";")?.[1] || "");
2582
2707
  const rgb_color = $9HbP8$createMemo(() => $9HbP8$hex_to_rgb(hex_color()));
2583
2708
  const black_contrast_better = $9HbP8$createMemo(() => rgb_color() ? $e731d52d97444b7c$var$does_black_contrast_better(rgb_color()) : false);
2584
- const input_row = $9HbP8$createComponent((0, $87c712b5b33f24f7$export$48513f6b9f8ce62d), {
2709
+ const input_row = $9HbP8$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
2585
2710
  get value_() {
2586
2711
  return checkbox().value_;
2587
2712
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depict-ai/ui",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
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": "^1.2.1",
239
+ "@depict-ai/plp-styling": "^1.2.2",
240
240
  "@depict-ai/types": "^1.0.39",
241
241
  "@depict-ai/utilishared": "^1.0.41",
242
242
  "solid-js": "^1.7.3"
@@ -66,7 +66,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $33eed84f447aa0c0$expo
66
66
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $33eed84f447aa0c0$export$7bf543b9d9be2c22);
67
67
  $parcel$export(module.exports, "version", () => $aa1938dec50d6c12$export$83d89fbfd8236492);
68
68
  /*! Depict.ai search and product listing SDK */
69
- const $aa1938dec50d6c12$export$83d89fbfd8236492 = "2.0.1";
69
+ const $aa1938dec50d6c12$export$83d89fbfd8236492 = "2.0.2";
70
70
  const $5401a6698b0c0658$var$transform_elements = sorted_cols_at_size => {
71
71
  const cols_at_size = [];
72
72
  for (let i = 0; i < sorted_cols_at_size.length; i++) {
@@ -1128,9 +1128,9 @@ function $c5842bdb10e57229$export$fecbb157621501bd(_ref) {
1128
1128
  }));
1129
1129
  return outmost_element;
1130
1130
  }
1131
- const $6b92e147c6e24046$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
1132
- $6b92e147c6e24046$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--#-->", "<!--/--></label>"];
1133
- const $6b92e147c6e24046$export$48513f6b9f8ce62d = props => {
1131
+ const $902a0ca2b52f3898$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
1132
+ $902a0ca2b52f3898$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--#-->", "<!--/--></label>"];
1133
+ const $902a0ca2b52f3898$export$48513f6b9f8ce62d = props => {
1134
1134
  // It seems like there's no diffing without memos here (since we often just have computations in the getters above that update to the same result often because their dependencies change with unrelated changes often), so put memos here to avoid unneeded DOM changes
1135
1135
  const count = $3hooq$solidjs.createMemo(() => props.count_);
1136
1136
  const label = $3hooq$solidjs.createMemo(() => props.label_);
@@ -1138,12 +1138,12 @@ const $6b92e147c6e24046$export$48513f6b9f8ce62d = props => {
1138
1138
  const value = $3hooq$solidjs.createMemo(() => props.value_);
1139
1139
  const is_count_zero = $3hooq$solidjs.createMemo(() => props.is_count_zero_ || count() === 0);
1140
1140
  const id = $3hooq$depictaiutilishared.make_random_classname();
1141
- return (/* We can't use actual margin because ExpandingContainer gets messed up */$3hooq$solidjsweb.ssr($6b92e147c6e24046$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "input-row ".concat(is_count_zero() ? "count-0" : ""), $3hooq$solidjsweb.ssrAttribute("for", $3hooq$solidjsweb.escape(id, true), false), $3hooq$solidjsweb.ssrAttribute("name", $3hooq$solidjsweb.escape(value(), true), false) + $3hooq$solidjsweb.ssrAttribute("id", $3hooq$solidjsweb.escape(id, true), false), $3hooq$solidjsweb.ssrAttribute("checked", checked(), true), $3hooq$solidjsweb.ssrAttribute("disabled", !checked() && is_count_zero(), true), $3hooq$solidjsweb.escape(label()) || $3hooq$solidjsweb.escape(value()), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1141
+ return (/* We can't use actual margin because ExpandingContainer gets messed up */$3hooq$solidjsweb.ssr($902a0ca2b52f3898$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "input-row ".concat(is_count_zero() ? "count-0" : ""), $3hooq$solidjsweb.ssrAttribute("for", $3hooq$solidjsweb.escape(id, true), false), $3hooq$solidjsweb.ssrAttribute("name", $3hooq$solidjsweb.escape(value(), true), false) + $3hooq$solidjsweb.ssrAttribute("id", $3hooq$solidjsweb.escape(id, true), false), $3hooq$solidjsweb.ssrAttribute("checked", checked(), true), $3hooq$solidjsweb.ssrAttribute("disabled", !checked() && is_count_zero(), true), $3hooq$solidjsweb.escape(label()) || $3hooq$solidjsweb.escape(value()), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
1142
1142
  get when() {
1143
1143
  return count() != undefined;
1144
1144
  },
1145
1145
  get children() {
1146
- return $3hooq$solidjsweb.ssr($6b92e147c6e24046$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(count()));
1146
+ return $3hooq$solidjsweb.ssr($902a0ca2b52f3898$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(count()));
1147
1147
  }
1148
1148
  })))
1149
1149
  );
@@ -1202,7 +1202,7 @@ function $9b54b9c5381716eb$export$dd948f91abc3a1c4(_ref) {
1202
1202
  });
1203
1203
  const render_checkbox = checkbox => {
1204
1204
  // Checkbox always calls the getters in props, so we don't wrap these values into memos
1205
- return $3hooq$solidjsweb.createComponent((0, $6b92e147c6e24046$export$48513f6b9f8ce62d), {
1205
+ return $3hooq$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
1206
1206
  get value_() {
1207
1207
  return checkbox().value_;
1208
1208
  },
@@ -1710,7 +1710,7 @@ function $9c1d49181fb3002a$var$render_stuff(data, existing_filter, i18n_) {
1710
1710
  var _value;
1711
1711
  return !!Object.keys(((_value = value()) === null || _value === void 0 ? void 0 : _value.children_) || {}).length;
1712
1712
  });
1713
- return $3hooq$solidjsweb.ssr($9c1d49181fb3002a$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "checkbox-details ".concat(has_expandable() ? "expandable" : ""), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $6b92e147c6e24046$export$48513f6b9f8ce62d), {
1713
+ return $3hooq$solidjsweb.ssr($9c1d49181fb3002a$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), "checkbox-details ".concat(has_expandable() ? "expandable" : ""), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
1714
1714
  get value_() {
1715
1715
  var _value2;
1716
1716
  return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
@@ -1981,9 +1981,26 @@ function $9c1d49181fb3002a$var$expand_until_choice(data_structure) {
1981
1981
  }
1982
1982
  });
1983
1983
  }
1984
- const $cd0e5524f9476f9b$var$_tmpl$ = ["<div", ' class="checkbox-grid">', "</div>"],
1985
- $cd0e5524f9476f9b$var$_tmpl$2 = ["<span", ' class="count-wrapper"><span class="count">', "</span></span>"],
1986
- $cd0e5524f9476f9b$var$_tmpl$3 = ["<button", "", ' class="', '"><!--#-->', "<!--/--><!--#-->", "<!--/--></button>"];
1984
+
1985
+ /** @jsxImportSource solid-js */
1986
+
1987
+ function $13671aa5e984acd9$export$9f191182275e9ef(what_to_watch) {
1988
+ const [size, setSize] = $3hooq$solidjs.createSignal();
1989
+ const resizeObserver = new ResizeObserver($3hooq$depictaiutilishared.catchify(records => {
1990
+ for (let j = 0; j < records.length; j++) {
1991
+ var _records$j$borderBoxS, _records$j$borderBoxS2, _records$j$borderBoxS3;
1992
+ const width = (_records$j$borderBoxS = (_records$j$borderBoxS2 = records[j].borderBoxSize) === null || _records$j$borderBoxS2 === void 0 ? void 0 : (_records$j$borderBoxS3 = _records$j$borderBoxS2[0]) === null || _records$j$borderBoxS3 === void 0 ? void 0 : _records$j$borderBoxS3.inlineSize) !== null && _records$j$borderBoxS !== void 0 ? _records$j$borderBoxS : what_to_watch.getBoundingClientRect().width;
1993
+ setSize(width);
1994
+ }
1995
+ }));
1996
+ resizeObserver.observe(what_to_watch);
1997
+ $3hooq$solidjs.onCleanup(() => resizeObserver.disconnect());
1998
+ return size;
1999
+ }
2000
+ const $cd0e5524f9476f9b$var$_tmpl$ = ["<div", ' class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0">', "</div>"],
2001
+ $cd0e5524f9476f9b$var$_tmpl$2 = ["<span", ' class="count-wrapper"><span class="count">', "</span></span>"];
2002
+ const $cd0e5524f9476f9b$var$gap_px = 5;
2003
+ const $cd0e5524f9476f9b$var$max_columns = 3;
1987
2004
  const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
1988
2005
  let {
1989
2006
  filter_: filter_,
@@ -2013,26 +2030,144 @@ const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
2013
2030
  };
2014
2031
  });
2015
2032
  });
2016
- return $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
2017
- get each() {
2018
- return buttons();
2033
+ const [sizes_set, set_sizes_set] = $3hooq$solidjs.createSignal(new Set(), {
2034
+ equals: false
2035
+ });
2036
+ const [cols_at_size, set_cols_at_size] = $3hooq$solidjs.createSignal([[1, "0px", ""]]);
2037
+ const [container, set_container] = $3hooq$solidjs.createSignal();
2038
+ const container_width_accessor = $3hooq$solidjs.createMemo(() => {
2039
+ const element = container();
2040
+ if (!element) return;
2041
+ return $13671aa5e984acd9$export$9f191182275e9ef(element);
2042
+ });
2043
+ const [shadow_children, set_shadow_children] = $3hooq$solidjs.createSignal(new Set(), {
2044
+ equals: false
2045
+ });
2046
+ const shadow_grid = $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
2047
+ $3hooq$solidjs.createEffect(() => {
2048
+ var _container_width_acce;
2049
+ const container_width = (_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce();
2050
+ if (container_width == undefined) return;
2051
+ $cd0e5524f9476f9b$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
2052
+ });
2053
+ return [shadow_grid, $3hooq$solidjsweb.createComponent((0, $6c2c739b113a8ddf$export$d21e32dfedac04be), {
2054
+ get cols_at_size() {
2055
+ return cols_at_size();
2019
2056
  },
2020
- children: value => {
2021
- const is_selected = $3hooq$solidjs.createMemo(() => {
2022
- var _existing_filter, _existing_filter$data;
2023
- return (_existing_filter = existing_filter()) === null || _existing_filter === void 0 ? void 0 : (_existing_filter$data = _existing_filter.data) === null || _existing_filter$data === void 0 ? void 0 : _existing_filter$data.includes(value().value_);
2024
- });
2025
- return $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$3, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.ssrAttribute("disabled", value().count_ === 0 && !is_selected(), true), "".concat(!is_selected() ? "minor" : "", " ").concat(is_selected() ? "major" : "", " major-minor-transition"), $3hooq$solidjsweb.escape(value().value_), $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2026
- get when() {
2027
- return value().count_ != undefined;
2057
+ grid_spacing: $cd0e5524f9476f9b$var$gap_px + "px",
2058
+ rows: "all",
2059
+ layout: "grid",
2060
+ element_attributes: {
2061
+ class: "checkbox-grid",
2062
+ ref: el => set_container(el)
2063
+ },
2064
+ get children() {
2065
+ return $3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Index), {
2066
+ get each() {
2067
+ return buttons();
2028
2068
  },
2029
- get children() {
2030
- return $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(value().count_));
2069
+ children: value => {
2070
+ const is_selected = $3hooq$solidjs.createMemo(() => {
2071
+ var _existing_filter, _existing_filter$data;
2072
+ return (_existing_filter = existing_filter()) === null || _existing_filter === void 0 ? void 0 : (_existing_filter$data = _existing_filter.data) === null || _existing_filter$data === void 0 ? void 0 : _existing_filter$data.includes(value().value_);
2073
+ });
2074
+ const MakeButton = attributes => $3hooq$solidjsweb.ssrElement("button", () => ({
2075
+ ...attributes,
2076
+ "disabled": value().count_ === 0 && !is_selected(),
2077
+ "classList": {
2078
+ minor: !is_selected(),
2079
+ major: is_selected(),
2080
+ "major-minor-transition": true
2081
+ }
2082
+ }), () => ["<!--#-->", $3hooq$solidjsweb.escape(value().value_), "<!--/-->", "<!--#-->", $3hooq$solidjsweb.escape($3hooq$solidjsweb.createComponent((0, $3hooq$solidjs.Show), {
2083
+ get when() {
2084
+ return value().count_ != undefined;
2085
+ },
2086
+ get children() {
2087
+ return $3hooq$solidjsweb.ssr($cd0e5524f9476f9b$var$_tmpl$2, $3hooq$solidjsweb.ssrHydrationKey(), $3hooq$solidjsweb.escape(value().count_));
2088
+ }
2089
+ })), "<!--/-->"], true);
2090
+ const invisible_size_button = $3hooq$solidjsweb.createComponent(MakeButton, {});
2091
+ const smallest_possible_size = $13671aa5e984acd9$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
2092
+ const sizes_value = $3hooq$solidjs.untrack(sizes_set);
2093
+ const shadow_children_value = $3hooq$solidjs.untrack(shadow_children);
2094
+ sizes_value.add(smallest_possible_size);
2095
+ set_sizes_set(sizes_value);
2096
+ shadow_children_value.add(invisible_size_button);
2097
+ set_shadow_children(shadow_children_value);
2098
+ $3hooq$solidjs.onCleanup(() => {
2099
+ const sizes_value = $3hooq$solidjs.untrack(sizes_set);
2100
+ const shadow_children_value = $3hooq$solidjs.untrack(shadow_children);
2101
+ sizes_value.delete(smallest_possible_size);
2102
+ set_sizes_set(sizes_value);
2103
+ shadow_children_value.delete(invisible_size_button);
2104
+ set_shadow_children(shadow_children_value);
2105
+ });
2106
+ // The actual button that will be visible
2107
+ return $3hooq$solidjsweb.createComponent(MakeButton, {});
2031
2108
  }
2032
- })));
2109
+ });
2033
2110
  }
2034
- })));
2111
+ })];
2035
2112
  };
2113
+ /**
2114
+ * Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
2115
+ */
2116
+ function $cd0e5524f9476f9b$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
2117
+ let current_row_index = 0;
2118
+ let current_row_items = [];
2119
+ const column_to_row_result = {};
2120
+ const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
2121
+ const would_have_even_size = container_width / at_number_of_columnns - (at_number_of_columnns * 2 - 2) * ($cd0e5524f9476f9b$var$gap_px / 2) / at_number_of_columnns; // What size would our element have (without gaps), given that now every column had the same width (equation from Layout.tsx)
2122
+ return would_have_even_size >= min_size_of_item; // would this item still fit if we added another column? (probably what the caller has done with at_number_of_columns), given that every item has the same size
2123
+ };
2124
+
2125
+ for (const size_item of sizes) {
2126
+ const size = size_item();
2127
+ if (size == undefined) return; // Only do stuff if we know all the sizes
2128
+ const current_row_length = current_row_items.length;
2129
+ const can_add_another_column_initial_val = current_row_length < $cd0e5524f9476f9b$var$max_columns; // allow max 4 items per row
2130
+ let can_add_another_column = can_add_another_column_initial_val;
2131
+ if (can_add_another_column)
2132
+ // can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
2133
+ for (let i = -1; i < current_row_length; i++) {
2134
+ var _ref3;
2135
+ // -1 is for the new item we're adding and every item is guaranteed to exist
2136
+ const size_to_check = (_ref3 = current_row_items[i]) !== null && _ref3 !== void 0 ? _ref3 : size;
2137
+ const would_have_columns = current_row_length + 1; // if we added another column
2138
+ const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
2139
+ if (!would_fit_evenly) {
2140
+ can_add_another_column = false;
2141
+ break;
2142
+ }
2143
+ }
2144
+ if (can_add_another_column) current_row_items.push(size);else {
2145
+ column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
2146
+ current_row_items = [size]; // save current item for next row
2147
+ }
2148
+ }
2149
+
2150
+ const items_left_to_add = current_row_items.length;
2151
+ if (items_left_to_add) {
2152
+ let num_columns = 1; // We want to have as close to max_columns as possible in the last row
2153
+ let fits = true;
2154
+ do
2155
+ // Check if more columns would fit
2156
+ for (let i = 0; i < items_left_to_add; i++) {
2157
+ const item = current_row_items[i];
2158
+ const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
2159
+ if (!would_fit_evenly) {
2160
+ fits = false;
2161
+ break;
2162
+ }
2163
+ } while (fits && ++num_columns < $cd0e5524f9476f9b$var$max_columns);
2164
+ column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
2165
+ }
2166
+
2167
+ set_cols_at_size([[1, "0px", "", null, {
2168
+ overrides: column_to_row_result
2169
+ }]]);
2170
+ }
2036
2171
  function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
2037
2172
  const signal = $3hooq$solidjs.createSignal(false);
2038
2173
  $3hooq$solidjs.onCleanup($3hooq$depictaiutilishared.javascript_media_query(media_query, _ref => {
@@ -2091,7 +2226,7 @@ function $476a3dc36afc1938$export$82ed4b28ecb67608(_ref) {
2091
2226
  });
2092
2227
  const rgb_color = $3hooq$solidjs.createMemo(() => $3hooq$depictaiutilishared.hex_to_rgb(hex_color()));
2093
2228
  const black_contrast_better = $3hooq$solidjs.createMemo(() => rgb_color() ? $476a3dc36afc1938$var$does_black_contrast_better(rgb_color()) : false);
2094
- const input_row = $3hooq$solidjsweb.createComponent((0, $6b92e147c6e24046$export$48513f6b9f8ce62d), {
2229
+ const input_row = $3hooq$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
2095
2230
  get value_() {
2096
2231
  return checkbox().value_;
2097
2232
  },
@@ -7,7 +7,7 @@ import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/
7
7
  import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
8
8
  import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
9
9
  import { ProductListingRequest } from "@depict-ai/types/api/ProductListingRequest";
10
- export const version = "2.0.1";
10
+ export const version = "2.0.2";
11
11
  export type SDKGridSpacing = string | {
12
12
  horizontal: string;
13
13
  vertical: string;