@depict-ai/ui 2.0.0 → 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/ES10/index.cjs +218 -81
- package/ES10/index.d.ts +2 -1
- package/ES10/index.js +218 -81
- package/latest/index.cjs +212 -78
- package/latest/index.d.ts +2 -1
- package/latest/index.js +212 -78
- package/package.json +2 -2
- package/server/ES10/index.cjs +173 -29
- package/server/ES10/index.d.ts +2 -1
- package/server/ES10/index.js +173 -29
- package/server/latest/index.cjs +167 -26
- package/server/latest/index.d.ts +2 -1
- package/server/latest/index.js +167 -26
package/latest/index.cjs
CHANGED
|
@@ -60,7 +60,7 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
|
|
|
60
60
|
$parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
|
|
61
61
|
$parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
|
|
62
62
|
/*! Depict.ai search and product listing SDK */
|
|
63
|
-
const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.
|
|
63
|
+
const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.2";
|
|
64
64
|
const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
|
|
65
65
|
const cols_at_size = [];
|
|
66
66
|
for (let i = 0; i < sorted_cols_at_size.length; i++) {
|
|
@@ -705,9 +705,18 @@ const $1f8dbf7e28b3eff2$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<b
|
|
|
705
705
|
function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
|
|
706
706
|
return $95837413165cc2df$export$23fca46f3143581f(() => {
|
|
707
707
|
const rows_object_ = $gVhhF$solidjs.createMemo(() => {
|
|
708
|
-
const
|
|
709
|
-
|
|
708
|
+
const {
|
|
709
|
+
view_more_button: view_more_button,
|
|
710
|
+
max_rows: max_rows
|
|
711
|
+
} = props;
|
|
712
|
+
if (!view_more_button) {
|
|
713
|
+
if (max_rows) return {
|
|
714
|
+
max_rows: max_rows
|
|
715
|
+
};
|
|
716
|
+
return "all";
|
|
717
|
+
}
|
|
710
718
|
return {
|
|
719
|
+
max_rows: max_rows,
|
|
711
720
|
start_rows: view_more_button.start_rows,
|
|
712
721
|
rows_per_click: view_more_button.rows_per_click ?? 2,
|
|
713
722
|
button: (() => {
|
|
@@ -1408,9 +1417,9 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
|
|
|
1408
1417
|
return outmost_element;
|
|
1409
1418
|
}
|
|
1410
1419
|
$gVhhF$solidjsweb.delegateEvents(["click"]);
|
|
1411
|
-
const $
|
|
1412
|
-
$
|
|
1413
|
-
const $
|
|
1420
|
+
const $1c63082b2da848ad$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class="count"></span>`, 2),
|
|
1421
|
+
$1c63082b2da848ad$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.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);
|
|
1422
|
+
const $1c63082b2da848ad$export$48513f6b9f8ce62d = props => {
|
|
1414
1423
|
// 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
|
|
1415
1424
|
const count = $gVhhF$solidjs.createMemo(() => props.count_);
|
|
1416
1425
|
const label = $gVhhF$solidjs.createMemo(() => props.label_);
|
|
@@ -1419,7 +1428,7 @@ const $b3cf6ca8dc0e9998$export$48513f6b9f8ce62d = props => {
|
|
|
1419
1428
|
const is_count_zero = $gVhhF$solidjs.createMemo(() => props.is_count_zero_ || count() === 0);
|
|
1420
1429
|
const id = $gVhhF$depictaiutilishared.make_random_classname();
|
|
1421
1430
|
return (/* We can't use actual margin because ExpandingContainer gets messed up */(() => {
|
|
1422
|
-
const _el$ = $gVhhF$solidjsweb.getNextElement($
|
|
1431
|
+
const _el$ = $gVhhF$solidjsweb.getNextElement($1c63082b2da848ad$var$_tmpl$2),
|
|
1423
1432
|
_el$2 = _el$.firstChild,
|
|
1424
1433
|
_el$3 = _el$2.firstChild,
|
|
1425
1434
|
_el$4 = _el$3.nextSibling,
|
|
@@ -1446,7 +1455,7 @@ const $b3cf6ca8dc0e9998$export$48513f6b9f8ce62d = props => {
|
|
|
1446
1455
|
return count() != undefined;
|
|
1447
1456
|
},
|
|
1448
1457
|
get children() {
|
|
1449
|
-
const _el$6 = $gVhhF$solidjsweb.getNextElement($
|
|
1458
|
+
const _el$6 = $gVhhF$solidjsweb.getNextElement($1c63082b2da848ad$var$_tmpl$);
|
|
1450
1459
|
$gVhhF$solidjsweb.insert(_el$6, count);
|
|
1451
1460
|
return _el$6;
|
|
1452
1461
|
}
|
|
@@ -1534,7 +1543,7 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
|
|
|
1534
1543
|
});
|
|
1535
1544
|
const render_checkbox = checkbox => {
|
|
1536
1545
|
// Checkbox always calls the getters in props, so we don't wrap these values into memos
|
|
1537
|
-
return $gVhhF$solidjsweb.createComponent((0, $
|
|
1546
|
+
return $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
1538
1547
|
get value_() {
|
|
1539
1548
|
return checkbox().value_;
|
|
1540
1549
|
},
|
|
@@ -2236,7 +2245,7 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
2236
2245
|
[_el$8, _co$3] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling),
|
|
2237
2246
|
_el$9 = _el$8.nextSibling,
|
|
2238
2247
|
[_el$10, _co$4] = $gVhhF$solidjsweb.getNextMarker(_el$9.nextSibling);
|
|
2239
|
-
$gVhhF$solidjsweb.insert(_el$6, $gVhhF$solidjsweb.createComponent((0, $
|
|
2248
|
+
$gVhhF$solidjsweb.insert(_el$6, $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
2240
2249
|
get value_() {
|
|
2241
2250
|
return JSON.stringify(value()?.value_);
|
|
2242
2251
|
},
|
|
@@ -2490,9 +2499,26 @@ function $3bdc00a1353c1150$var$expand_until_choice(data_structure) {
|
|
|
2490
2499
|
}
|
|
2491
2500
|
});
|
|
2492
2501
|
}
|
|
2493
|
-
|
|
2502
|
+
|
|
2503
|
+
/** @jsxImportSource solid-js */
|
|
2504
|
+
|
|
2505
|
+
function $e5f442fb78c98741$export$9f191182275e9ef(what_to_watch) {
|
|
2506
|
+
const [size, setSize] = $gVhhF$solidjs.createSignal();
|
|
2507
|
+
const resizeObserver = new ResizeObserver($gVhhF$depictaiutilishared.catchify(records => {
|
|
2508
|
+
for (let j = 0; j < records.length; j++) {
|
|
2509
|
+
const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
|
|
2510
|
+
setSize(width);
|
|
2511
|
+
}
|
|
2512
|
+
}));
|
|
2513
|
+
resizeObserver.observe(what_to_watch);
|
|
2514
|
+
$gVhhF$solidjs.onCleanup(() => resizeObserver.disconnect());
|
|
2515
|
+
return size;
|
|
2516
|
+
}
|
|
2517
|
+
const $0ef1681699140f1a$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0"></div>`, 2),
|
|
2494
2518
|
$0ef1681699140f1a$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class="count-wrapper"><span class="count"></span></span>`, 4),
|
|
2495
|
-
$0ef1681699140f1a$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button
|
|
2519
|
+
$0ef1681699140f1a$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<button><!#><!/><!#><!/></button>`, 6);
|
|
2520
|
+
const $0ef1681699140f1a$var$gap_px = 5;
|
|
2521
|
+
const $0ef1681699140f1a$var$max_columns = 3;
|
|
2496
2522
|
const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
2497
2523
|
filter_: filter_,
|
|
2498
2524
|
selected_filters_: [get_selected_filters, set_selected_filters]
|
|
@@ -2515,74 +2541,182 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
|
2515
2541
|
count_: meta.counts?.[index]
|
|
2516
2542
|
}));
|
|
2517
2543
|
});
|
|
2518
|
-
|
|
2544
|
+
const [sizes_set, set_sizes_set] = $gVhhF$solidjs.createSignal(new Set(), {
|
|
2545
|
+
equals: false
|
|
2546
|
+
});
|
|
2547
|
+
const [cols_at_size, set_cols_at_size] = $gVhhF$solidjs.createSignal([[1, "0px", ""]]);
|
|
2548
|
+
const [container, set_container] = $gVhhF$solidjs.createSignal();
|
|
2549
|
+
const container_width_accessor = $gVhhF$solidjs.createMemo(() => {
|
|
2550
|
+
const element = container();
|
|
2551
|
+
if (!element) return;
|
|
2552
|
+
return $e5f442fb78c98741$export$9f191182275e9ef(element);
|
|
2553
|
+
});
|
|
2554
|
+
const [shadow_children, set_shadow_children] = $gVhhF$solidjs.createSignal(new Set(), {
|
|
2555
|
+
equals: false
|
|
2556
|
+
});
|
|
2557
|
+
const shadow_grid = (() => {
|
|
2519
2558
|
const _el$ = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$);
|
|
2520
|
-
$gVhhF$solidjsweb.insert(_el$,
|
|
2521
|
-
get each() {
|
|
2522
|
-
return buttons();
|
|
2523
|
-
},
|
|
2524
|
-
children: value => {
|
|
2525
|
-
const is_selected = $gVhhF$solidjs.createMemo(() => existing_filter()?.data?.includes(value().value_));
|
|
2526
|
-
return (() => {
|
|
2527
|
-
const _el$2 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$3),
|
|
2528
|
-
_el$5 = _el$2.firstChild,
|
|
2529
|
-
[_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling),
|
|
2530
|
-
_el$7 = _el$6.nextSibling,
|
|
2531
|
-
[_el$8, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling);
|
|
2532
|
-
$gVhhF$solidjsweb.addEventListener(_el$2, "click", $gVhhF$depictaiutilishared.catchify(() => {
|
|
2533
|
-
const set_filter = existing_filter();
|
|
2534
|
-
const {
|
|
2535
|
-
field: field,
|
|
2536
|
-
op: op
|
|
2537
|
-
} = filter_();
|
|
2538
|
-
const base_object = set_filter ? set_filter : {
|
|
2539
|
-
op: op,
|
|
2540
|
-
field: field
|
|
2541
|
-
};
|
|
2542
|
-
const old_data = base_object.data;
|
|
2543
|
-
const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
|
|
2544
|
-
const new_filter_object = {
|
|
2545
|
-
...base_object,
|
|
2546
|
-
data: new_data
|
|
2547
|
-
};
|
|
2548
|
-
if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
|
|
2549
|
-
const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
|
|
2550
|
-
set_selected_filters(selected_filters);
|
|
2551
|
-
}), true);
|
|
2552
|
-
$gVhhF$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
|
|
2553
|
-
$gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
|
|
2554
|
-
get when() {
|
|
2555
|
-
return value().count_ != undefined;
|
|
2556
|
-
},
|
|
2557
|
-
get children() {
|
|
2558
|
-
const _el$3 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$2),
|
|
2559
|
-
_el$4 = _el$3.firstChild;
|
|
2560
|
-
$gVhhF$solidjsweb.insert(_el$4, () => value().count_);
|
|
2561
|
-
return _el$3;
|
|
2562
|
-
}
|
|
2563
|
-
}), _el$8, _co$2);
|
|
2564
|
-
$gVhhF$solidjsweb.effect(_p$ => {
|
|
2565
|
-
const _v$ = value().count_ === 0 && !is_selected(),
|
|
2566
|
-
_v$2 = !is_selected(),
|
|
2567
|
-
_v$3 = !!is_selected();
|
|
2568
|
-
_v$ !== _p$._v$ && (_el$2.disabled = _p$._v$ = _v$);
|
|
2569
|
-
_v$2 !== _p$._v$2 && _el$2.classList.toggle("minor", _p$._v$2 = _v$2);
|
|
2570
|
-
_v$3 !== _p$._v$3 && _el$2.classList.toggle("major", _p$._v$3 = _v$3);
|
|
2571
|
-
return _p$;
|
|
2572
|
-
}, {
|
|
2573
|
-
_v$: undefined,
|
|
2574
|
-
_v$2: undefined,
|
|
2575
|
-
_v$3: undefined
|
|
2576
|
-
});
|
|
2577
|
-
$gVhhF$solidjsweb.runHydrationEvents();
|
|
2578
|
-
return _el$2;
|
|
2579
|
-
})();
|
|
2580
|
-
}
|
|
2581
|
-
}));
|
|
2559
|
+
$gVhhF$solidjsweb.insert(_el$, () => [...shadow_children()]);
|
|
2582
2560
|
return _el$;
|
|
2583
|
-
})();
|
|
2561
|
+
})(); // for getting the smallest possible sizes of all the items
|
|
2562
|
+
$gVhhF$solidjs.createEffect(() => {
|
|
2563
|
+
const container_width = container_width_accessor()?.();
|
|
2564
|
+
if (container_width == undefined) return;
|
|
2565
|
+
$0ef1681699140f1a$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
|
|
2566
|
+
});
|
|
2567
|
+
return [shadow_grid, $gVhhF$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
|
|
2568
|
+
get cols_at_size() {
|
|
2569
|
+
return cols_at_size();
|
|
2570
|
+
},
|
|
2571
|
+
grid_spacing: $0ef1681699140f1a$var$gap_px + "px",
|
|
2572
|
+
rows: "all",
|
|
2573
|
+
layout: "grid",
|
|
2574
|
+
element_attributes: {
|
|
2575
|
+
class: "checkbox-grid",
|
|
2576
|
+
ref: el => set_container(el)
|
|
2577
|
+
},
|
|
2578
|
+
get children() {
|
|
2579
|
+
return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
|
|
2580
|
+
get each() {
|
|
2581
|
+
return buttons();
|
|
2582
|
+
},
|
|
2583
|
+
children: value => {
|
|
2584
|
+
const is_selected = $gVhhF$solidjs.createMemo(() => existing_filter()?.data?.includes(value().value_));
|
|
2585
|
+
const MakeButton = attributes => (() => {
|
|
2586
|
+
const _el$2 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$3),
|
|
2587
|
+
_el$5 = _el$2.firstChild,
|
|
2588
|
+
[_el$6, _co$] = $gVhhF$solidjsweb.getNextMarker(_el$5.nextSibling),
|
|
2589
|
+
_el$7 = _el$6.nextSibling,
|
|
2590
|
+
[_el$8, _co$2] = $gVhhF$solidjsweb.getNextMarker(_el$7.nextSibling);
|
|
2591
|
+
$gVhhF$solidjsweb.spread(_el$2, $gVhhF$solidjsweb.mergeProps(attributes, {
|
|
2592
|
+
get disabled() {
|
|
2593
|
+
return $gVhhF$solidjsweb.memo(() => value().count_ === 0)() && !is_selected();
|
|
2594
|
+
},
|
|
2595
|
+
get classList() {
|
|
2596
|
+
return {
|
|
2597
|
+
minor: !is_selected(),
|
|
2598
|
+
major: is_selected(),
|
|
2599
|
+
"major-minor-transition": true
|
|
2600
|
+
};
|
|
2601
|
+
},
|
|
2602
|
+
get onClick() {
|
|
2603
|
+
return $gVhhF$depictaiutilishared.catchify(() => {
|
|
2604
|
+
const set_filter = existing_filter();
|
|
2605
|
+
const {
|
|
2606
|
+
field: field,
|
|
2607
|
+
op: op
|
|
2608
|
+
} = filter_();
|
|
2609
|
+
const base_object = set_filter ? set_filter : {
|
|
2610
|
+
op: op,
|
|
2611
|
+
field: field
|
|
2612
|
+
};
|
|
2613
|
+
const old_data = base_object.data;
|
|
2614
|
+
const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
|
|
2615
|
+
const new_filter_object = {
|
|
2616
|
+
...base_object,
|
|
2617
|
+
data: new_data
|
|
2618
|
+
};
|
|
2619
|
+
if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
|
|
2620
|
+
const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
|
|
2621
|
+
set_selected_filters(selected_filters);
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
}), false, true);
|
|
2625
|
+
$gVhhF$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
|
|
2626
|
+
$gVhhF$solidjsweb.insert(_el$2, $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Show), {
|
|
2627
|
+
get when() {
|
|
2628
|
+
return value().count_ != undefined;
|
|
2629
|
+
},
|
|
2630
|
+
get children() {
|
|
2631
|
+
const _el$3 = $gVhhF$solidjsweb.getNextElement($0ef1681699140f1a$var$_tmpl$2),
|
|
2632
|
+
_el$4 = _el$3.firstChild;
|
|
2633
|
+
$gVhhF$solidjsweb.insert(_el$4, () => value().count_);
|
|
2634
|
+
return _el$3;
|
|
2635
|
+
}
|
|
2636
|
+
}), _el$8, _co$2);
|
|
2637
|
+
$gVhhF$solidjsweb.runHydrationEvents();
|
|
2638
|
+
return _el$2;
|
|
2639
|
+
})();
|
|
2640
|
+
const invisible_size_button = $gVhhF$solidjsweb.createComponent(MakeButton, {});
|
|
2641
|
+
const smallest_possible_size = $e5f442fb78c98741$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
|
|
2642
|
+
const sizes_value = $gVhhF$solidjs.untrack(sizes_set);
|
|
2643
|
+
const shadow_children_value = $gVhhF$solidjs.untrack(shadow_children);
|
|
2644
|
+
sizes_value.add(smallest_possible_size);
|
|
2645
|
+
set_sizes_set(sizes_value);
|
|
2646
|
+
shadow_children_value.add(invisible_size_button);
|
|
2647
|
+
set_shadow_children(shadow_children_value);
|
|
2648
|
+
$gVhhF$solidjs.onCleanup(() => {
|
|
2649
|
+
const sizes_value = $gVhhF$solidjs.untrack(sizes_set);
|
|
2650
|
+
const shadow_children_value = $gVhhF$solidjs.untrack(shadow_children);
|
|
2651
|
+
sizes_value.delete(smallest_possible_size);
|
|
2652
|
+
set_sizes_set(sizes_value);
|
|
2653
|
+
shadow_children_value.delete(invisible_size_button);
|
|
2654
|
+
set_shadow_children(shadow_children_value);
|
|
2655
|
+
});
|
|
2656
|
+
// The actual button that will be visible
|
|
2657
|
+
return $gVhhF$solidjsweb.createComponent(MakeButton, {});
|
|
2658
|
+
}
|
|
2659
|
+
});
|
|
2660
|
+
}
|
|
2661
|
+
})];
|
|
2584
2662
|
};
|
|
2585
|
-
|
|
2663
|
+
/**
|
|
2664
|
+
* Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
|
|
2665
|
+
*/
|
|
2666
|
+
function $0ef1681699140f1a$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
|
|
2667
|
+
let current_row_index = 0;
|
|
2668
|
+
let current_row_items = [];
|
|
2669
|
+
const column_to_row_result = {};
|
|
2670
|
+
const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
|
|
2671
|
+
const would_have_even_size = container_width / at_number_of_columnns - (at_number_of_columnns * 2 - 2) * ($0ef1681699140f1a$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)
|
|
2672
|
+
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
|
|
2673
|
+
};
|
|
2674
|
+
|
|
2675
|
+
for (const size_item of sizes) {
|
|
2676
|
+
const size = size_item();
|
|
2677
|
+
if (size == undefined) return; // Only do stuff if we know all the sizes
|
|
2678
|
+
const current_row_length = current_row_items.length;
|
|
2679
|
+
const can_add_another_column_initial_val = current_row_length < $0ef1681699140f1a$var$max_columns; // allow max 4 items per row
|
|
2680
|
+
let can_add_another_column = can_add_another_column_initial_val;
|
|
2681
|
+
if (can_add_another_column)
|
|
2682
|
+
// can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
|
|
2683
|
+
for (let i = -1; i < current_row_length; i++) {
|
|
2684
|
+
// -1 is for the new item we're adding and every item is guaranteed to exist
|
|
2685
|
+
const size_to_check = current_row_items[i] ?? size;
|
|
2686
|
+
const would_have_columns = current_row_length + 1; // if we added another column
|
|
2687
|
+
const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
|
|
2688
|
+
if (!would_fit_evenly) {
|
|
2689
|
+
can_add_another_column = false;
|
|
2690
|
+
break;
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
if (can_add_another_column) current_row_items.push(size);else {
|
|
2694
|
+
column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
|
|
2695
|
+
current_row_items = [size]; // save current item for next row
|
|
2696
|
+
}
|
|
2697
|
+
}
|
|
2698
|
+
|
|
2699
|
+
const items_left_to_add = current_row_items.length;
|
|
2700
|
+
if (items_left_to_add) {
|
|
2701
|
+
let num_columns = 1; // We want to have as close to max_columns as possible in the last row
|
|
2702
|
+
let fits = true;
|
|
2703
|
+
do
|
|
2704
|
+
// Check if more columns would fit
|
|
2705
|
+
for (let i = 0; i < items_left_to_add; i++) {
|
|
2706
|
+
const item = current_row_items[i];
|
|
2707
|
+
const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
|
|
2708
|
+
if (!would_fit_evenly) {
|
|
2709
|
+
fits = false;
|
|
2710
|
+
break;
|
|
2711
|
+
}
|
|
2712
|
+
} while (fits && ++num_columns < $0ef1681699140f1a$var$max_columns);
|
|
2713
|
+
column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
|
|
2714
|
+
}
|
|
2715
|
+
|
|
2716
|
+
set_cols_at_size([[1, "0px", "", null, {
|
|
2717
|
+
overrides: column_to_row_result
|
|
2718
|
+
}]]);
|
|
2719
|
+
}
|
|
2586
2720
|
function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
|
|
2587
2721
|
const signal = $gVhhF$solidjs.createSignal(false);
|
|
2588
2722
|
$gVhhF$solidjs.onCleanup($gVhhF$depictaiutilishared.javascript_media_query(media_query, ({
|
|
@@ -2627,7 +2761,7 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
|
|
|
2627
2761
|
const hex_color = $gVhhF$solidjs.createMemo(() => checkbox().value_.split(";")?.[1] || "");
|
|
2628
2762
|
const rgb_color = $gVhhF$solidjs.createMemo(() => $gVhhF$depictaiutilishared.hex_to_rgb(hex_color()));
|
|
2629
2763
|
const black_contrast_better = $gVhhF$solidjs.createMemo(() => rgb_color() ? $b51a2b8b9355e66c$var$does_black_contrast_better(rgb_color()) : false);
|
|
2630
|
-
const input_row = $gVhhF$solidjsweb.createComponent((0, $
|
|
2764
|
+
const input_row = $gVhhF$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
2631
2765
|
get value_() {
|
|
2632
2766
|
return checkbox().value_;
|
|
2633
2767
|
},
|
package/latest/index.d.ts
CHANGED
|
@@ -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.
|
|
10
|
+
export const version = "2.0.2";
|
|
11
11
|
export type SDKGridSpacing = string | {
|
|
12
12
|
horizontal: string;
|
|
13
13
|
vertical: string;
|
|
@@ -117,6 +117,7 @@ type RecommendationGridBaseProps<T extends Display> = {
|
|
|
117
117
|
start_rows?: number;
|
|
118
118
|
rows_per_click?: number;
|
|
119
119
|
};
|
|
120
|
+
max_rows?: number;
|
|
120
121
|
};
|
|
121
122
|
/**
|
|
122
123
|
* Render a grid with provided recommendations. displayTransformers will not be applied for this since you yourself provide the displays. Options are reactive.
|