@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/ES10/index.cjs
CHANGED
|
@@ -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.
|
|
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++) {
|
|
@@ -762,9 +762,18 @@ function $41227f10ad680afd$export$9756467d34d91cdb(props) {
|
|
|
762
762
|
return $d05611ff6b8c8357$export$23fca46f3143581f(() => {
|
|
763
763
|
const rows_object_ = $52FdA$solidjs.createMemo(() => {
|
|
764
764
|
var _view_more_button$row;
|
|
765
|
-
const
|
|
766
|
-
|
|
765
|
+
const {
|
|
766
|
+
view_more_button: view_more_button,
|
|
767
|
+
max_rows: max_rows
|
|
768
|
+
} = props;
|
|
769
|
+
if (!view_more_button) {
|
|
770
|
+
if (max_rows) return {
|
|
771
|
+
max_rows: max_rows
|
|
772
|
+
};
|
|
773
|
+
return "all";
|
|
774
|
+
}
|
|
767
775
|
return {
|
|
776
|
+
max_rows: max_rows,
|
|
768
777
|
start_rows: view_more_button.start_rows,
|
|
769
778
|
rows_per_click: (_view_more_button$row = view_more_button.rows_per_click) !== null && _view_more_button$row !== void 0 ? _view_more_button$row : 2,
|
|
770
779
|
button: (() => {
|
|
@@ -1486,9 +1495,9 @@ function $c5842bdb10e57229$export$fecbb157621501bd(_ref) {
|
|
|
1486
1495
|
return outmost_element;
|
|
1487
1496
|
}
|
|
1488
1497
|
$52FdA$solidjsweb.delegateEvents(["click"]);
|
|
1489
|
-
const $
|
|
1490
|
-
$
|
|
1491
|
-
const $
|
|
1498
|
+
const $902a0ca2b52f3898$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<span class="count"></span>`, 2),
|
|
1499
|
+
$902a0ca2b52f3898$var$_tmpl$2 = /*#__PURE__*/$52FdA$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);
|
|
1500
|
+
const $902a0ca2b52f3898$export$48513f6b9f8ce62d = props => {
|
|
1492
1501
|
// 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
|
|
1493
1502
|
const count = $52FdA$solidjs.createMemo(() => props.count_);
|
|
1494
1503
|
const label = $52FdA$solidjs.createMemo(() => props.label_);
|
|
@@ -1497,7 +1506,7 @@ const $6b92e147c6e24046$export$48513f6b9f8ce62d = props => {
|
|
|
1497
1506
|
const is_count_zero = $52FdA$solidjs.createMemo(() => props.is_count_zero_ || count() === 0);
|
|
1498
1507
|
const id = $52FdA$depictaiutilishared.make_random_classname();
|
|
1499
1508
|
return (/* We can't use actual margin because ExpandingContainer gets messed up */(() => {
|
|
1500
|
-
const _el$ = $52FdA$solidjsweb.getNextElement($
|
|
1509
|
+
const _el$ = $52FdA$solidjsweb.getNextElement($902a0ca2b52f3898$var$_tmpl$2),
|
|
1501
1510
|
_el$2 = _el$.firstChild,
|
|
1502
1511
|
_el$3 = _el$2.firstChild,
|
|
1503
1512
|
_el$4 = _el$3.nextSibling,
|
|
@@ -1528,7 +1537,7 @@ const $6b92e147c6e24046$export$48513f6b9f8ce62d = props => {
|
|
|
1528
1537
|
return count() != undefined;
|
|
1529
1538
|
},
|
|
1530
1539
|
get children() {
|
|
1531
|
-
const _el$6 = $52FdA$solidjsweb.getNextElement($
|
|
1540
|
+
const _el$6 = $52FdA$solidjsweb.getNextElement($902a0ca2b52f3898$var$_tmpl$);
|
|
1532
1541
|
$52FdA$solidjsweb.insert(_el$6, count);
|
|
1533
1542
|
return _el$6;
|
|
1534
1543
|
}
|
|
@@ -1624,7 +1633,7 @@ function $9b54b9c5381716eb$export$dd948f91abc3a1c4(_ref) {
|
|
|
1624
1633
|
});
|
|
1625
1634
|
const render_checkbox = checkbox => {
|
|
1626
1635
|
// Checkbox always calls the getters in props, so we don't wrap these values into memos
|
|
1627
|
-
return $52FdA$solidjsweb.createComponent((0, $
|
|
1636
|
+
return $52FdA$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
|
|
1628
1637
|
get value_() {
|
|
1629
1638
|
return checkbox().value_;
|
|
1630
1639
|
},
|
|
@@ -2368,7 +2377,7 @@ function $9c1d49181fb3002a$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
2368
2377
|
[_el$8, _co$3] = $52FdA$solidjsweb.getNextMarker(_el$7.nextSibling),
|
|
2369
2378
|
_el$9 = _el$8.nextSibling,
|
|
2370
2379
|
[_el$10, _co$4] = $52FdA$solidjsweb.getNextMarker(_el$9.nextSibling);
|
|
2371
|
-
$52FdA$solidjsweb.insert(_el$6, $52FdA$solidjsweb.createComponent((0, $
|
|
2380
|
+
$52FdA$solidjsweb.insert(_el$6, $52FdA$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
|
|
2372
2381
|
get value_() {
|
|
2373
2382
|
var _value2;
|
|
2374
2383
|
return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
|
|
@@ -2658,9 +2667,27 @@ function $9c1d49181fb3002a$var$expand_until_choice(data_structure) {
|
|
|
2658
2667
|
}
|
|
2659
2668
|
});
|
|
2660
2669
|
}
|
|
2661
|
-
|
|
2670
|
+
|
|
2671
|
+
/** @jsxImportSource solid-js */
|
|
2672
|
+
|
|
2673
|
+
function $13671aa5e984acd9$export$9f191182275e9ef(what_to_watch) {
|
|
2674
|
+
const [size, setSize] = $52FdA$solidjs.createSignal();
|
|
2675
|
+
const resizeObserver = new ResizeObserver($52FdA$depictaiutilishared.catchify(records => {
|
|
2676
|
+
for (let j = 0; j < records.length; j++) {
|
|
2677
|
+
var _records$j$borderBoxS, _records$j$borderBoxS2, _records$j$borderBoxS3;
|
|
2678
|
+
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;
|
|
2679
|
+
setSize(width);
|
|
2680
|
+
}
|
|
2681
|
+
}));
|
|
2682
|
+
resizeObserver.observe(what_to_watch);
|
|
2683
|
+
$52FdA$solidjs.onCleanup(() => resizeObserver.disconnect());
|
|
2684
|
+
return size;
|
|
2685
|
+
}
|
|
2686
|
+
const $cd0e5524f9476f9b$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0"></div>`, 2),
|
|
2662
2687
|
$cd0e5524f9476f9b$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<span class="count-wrapper"><span class="count"></span></span>`, 4),
|
|
2663
|
-
$cd0e5524f9476f9b$var$_tmpl$3 = /*#__PURE__*/$52FdA$solidjsweb.template(`<button
|
|
2688
|
+
$cd0e5524f9476f9b$var$_tmpl$3 = /*#__PURE__*/$52FdA$solidjsweb.template(`<button><!#><!/><!#><!/></button>`, 6);
|
|
2689
|
+
const $cd0e5524f9476f9b$var$gap_px = 5;
|
|
2690
|
+
const $cd0e5524f9476f9b$var$max_columns = 3;
|
|
2664
2691
|
const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
|
|
2665
2692
|
let {
|
|
2666
2693
|
filter_: filter_,
|
|
@@ -2690,77 +2717,187 @@ const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
|
|
|
2690
2717
|
};
|
|
2691
2718
|
});
|
|
2692
2719
|
});
|
|
2693
|
-
|
|
2720
|
+
const [sizes_set, set_sizes_set] = $52FdA$solidjs.createSignal(new Set(), {
|
|
2721
|
+
equals: false
|
|
2722
|
+
});
|
|
2723
|
+
const [cols_at_size, set_cols_at_size] = $52FdA$solidjs.createSignal([[1, "0px", ""]]);
|
|
2724
|
+
const [container, set_container] = $52FdA$solidjs.createSignal();
|
|
2725
|
+
const container_width_accessor = $52FdA$solidjs.createMemo(() => {
|
|
2726
|
+
const element = container();
|
|
2727
|
+
if (!element) return;
|
|
2728
|
+
return $13671aa5e984acd9$export$9f191182275e9ef(element);
|
|
2729
|
+
});
|
|
2730
|
+
const [shadow_children, set_shadow_children] = $52FdA$solidjs.createSignal(new Set(), {
|
|
2731
|
+
equals: false
|
|
2732
|
+
});
|
|
2733
|
+
const shadow_grid = (() => {
|
|
2694
2734
|
const _el$ = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$);
|
|
2695
|
-
$52FdA$solidjsweb.insert(_el$,
|
|
2696
|
-
get each() {
|
|
2697
|
-
return buttons();
|
|
2698
|
-
},
|
|
2699
|
-
children: value => {
|
|
2700
|
-
const is_selected = $52FdA$solidjs.createMemo(() => {
|
|
2701
|
-
var _existing_filter, _existing_filter$data;
|
|
2702
|
-
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_);
|
|
2703
|
-
});
|
|
2704
|
-
return (() => {
|
|
2705
|
-
const _el$2 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$3),
|
|
2706
|
-
_el$5 = _el$2.firstChild,
|
|
2707
|
-
[_el$6, _co$] = $52FdA$solidjsweb.getNextMarker(_el$5.nextSibling),
|
|
2708
|
-
_el$7 = _el$6.nextSibling,
|
|
2709
|
-
[_el$8, _co$2] = $52FdA$solidjsweb.getNextMarker(_el$7.nextSibling);
|
|
2710
|
-
$52FdA$solidjsweb.addEventListener(_el$2, "click", $52FdA$depictaiutilishared.catchify(() => {
|
|
2711
|
-
const set_filter = existing_filter();
|
|
2712
|
-
const {
|
|
2713
|
-
field: field,
|
|
2714
|
-
op: op
|
|
2715
|
-
} = filter_();
|
|
2716
|
-
const base_object = set_filter ? set_filter : {
|
|
2717
|
-
op: op,
|
|
2718
|
-
field: field
|
|
2719
|
-
};
|
|
2720
|
-
const old_data = base_object.data;
|
|
2721
|
-
const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
|
|
2722
|
-
const new_filter_object = {
|
|
2723
|
-
...base_object,
|
|
2724
|
-
data: new_data
|
|
2725
|
-
};
|
|
2726
|
-
if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
|
|
2727
|
-
const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
|
|
2728
|
-
set_selected_filters(selected_filters);
|
|
2729
|
-
}), true);
|
|
2730
|
-
$52FdA$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
|
|
2731
|
-
$52FdA$solidjsweb.insert(_el$2, $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
|
|
2732
|
-
get when() {
|
|
2733
|
-
return value().count_ != undefined;
|
|
2734
|
-
},
|
|
2735
|
-
get children() {
|
|
2736
|
-
const _el$3 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$2),
|
|
2737
|
-
_el$4 = _el$3.firstChild;
|
|
2738
|
-
$52FdA$solidjsweb.insert(_el$4, () => value().count_);
|
|
2739
|
-
return _el$3;
|
|
2740
|
-
}
|
|
2741
|
-
}), _el$8, _co$2);
|
|
2742
|
-
$52FdA$solidjsweb.effect(_p$ => {
|
|
2743
|
-
const _v$ = value().count_ === 0 && !is_selected(),
|
|
2744
|
-
_v$2 = !is_selected(),
|
|
2745
|
-
_v$3 = !!is_selected();
|
|
2746
|
-
_v$ !== _p$._v$ && (_el$2.disabled = _p$._v$ = _v$);
|
|
2747
|
-
_v$2 !== _p$._v$2 && _el$2.classList.toggle("minor", _p$._v$2 = _v$2);
|
|
2748
|
-
_v$3 !== _p$._v$3 && _el$2.classList.toggle("major", _p$._v$3 = _v$3);
|
|
2749
|
-
return _p$;
|
|
2750
|
-
}, {
|
|
2751
|
-
_v$: undefined,
|
|
2752
|
-
_v$2: undefined,
|
|
2753
|
-
_v$3: undefined
|
|
2754
|
-
});
|
|
2755
|
-
$52FdA$solidjsweb.runHydrationEvents();
|
|
2756
|
-
return _el$2;
|
|
2757
|
-
})();
|
|
2758
|
-
}
|
|
2759
|
-
}));
|
|
2735
|
+
$52FdA$solidjsweb.insert(_el$, () => [...shadow_children()]);
|
|
2760
2736
|
return _el$;
|
|
2761
|
-
})();
|
|
2737
|
+
})(); // for getting the smallest possible sizes of all the items
|
|
2738
|
+
$52FdA$solidjs.createEffect(() => {
|
|
2739
|
+
var _container_width_acce;
|
|
2740
|
+
const container_width = (_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce();
|
|
2741
|
+
if (container_width == undefined) return;
|
|
2742
|
+
$cd0e5524f9476f9b$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
|
|
2743
|
+
});
|
|
2744
|
+
return [shadow_grid, $52FdA$solidjsweb.createComponent((0, $6c2c739b113a8ddf$export$d21e32dfedac04be), {
|
|
2745
|
+
get cols_at_size() {
|
|
2746
|
+
return cols_at_size();
|
|
2747
|
+
},
|
|
2748
|
+
grid_spacing: $cd0e5524f9476f9b$var$gap_px + "px",
|
|
2749
|
+
rows: "all",
|
|
2750
|
+
layout: "grid",
|
|
2751
|
+
element_attributes: {
|
|
2752
|
+
class: "checkbox-grid",
|
|
2753
|
+
ref: el => set_container(el)
|
|
2754
|
+
},
|
|
2755
|
+
get children() {
|
|
2756
|
+
return $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Index), {
|
|
2757
|
+
get each() {
|
|
2758
|
+
return buttons();
|
|
2759
|
+
},
|
|
2760
|
+
children: value => {
|
|
2761
|
+
const is_selected = $52FdA$solidjs.createMemo(() => {
|
|
2762
|
+
var _existing_filter, _existing_filter$data;
|
|
2763
|
+
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_);
|
|
2764
|
+
});
|
|
2765
|
+
const MakeButton = attributes => (() => {
|
|
2766
|
+
const _el$2 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$3),
|
|
2767
|
+
_el$5 = _el$2.firstChild,
|
|
2768
|
+
[_el$6, _co$] = $52FdA$solidjsweb.getNextMarker(_el$5.nextSibling),
|
|
2769
|
+
_el$7 = _el$6.nextSibling,
|
|
2770
|
+
[_el$8, _co$2] = $52FdA$solidjsweb.getNextMarker(_el$7.nextSibling);
|
|
2771
|
+
$52FdA$solidjsweb.spread(_el$2, $52FdA$solidjsweb.mergeProps(attributes, {
|
|
2772
|
+
get disabled() {
|
|
2773
|
+
return $52FdA$solidjsweb.memo(() => value().count_ === 0)() && !is_selected();
|
|
2774
|
+
},
|
|
2775
|
+
get classList() {
|
|
2776
|
+
return {
|
|
2777
|
+
minor: !is_selected(),
|
|
2778
|
+
major: is_selected(),
|
|
2779
|
+
"major-minor-transition": true
|
|
2780
|
+
};
|
|
2781
|
+
},
|
|
2782
|
+
get onClick() {
|
|
2783
|
+
return $52FdA$depictaiutilishared.catchify(() => {
|
|
2784
|
+
const set_filter = existing_filter();
|
|
2785
|
+
const {
|
|
2786
|
+
field: field,
|
|
2787
|
+
op: op
|
|
2788
|
+
} = filter_();
|
|
2789
|
+
const base_object = set_filter ? set_filter : {
|
|
2790
|
+
op: op,
|
|
2791
|
+
field: field
|
|
2792
|
+
};
|
|
2793
|
+
const old_data = base_object.data;
|
|
2794
|
+
const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
|
|
2795
|
+
const new_filter_object = {
|
|
2796
|
+
...base_object,
|
|
2797
|
+
data: new_data
|
|
2798
|
+
};
|
|
2799
|
+
if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
|
|
2800
|
+
const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
|
|
2801
|
+
set_selected_filters(selected_filters);
|
|
2802
|
+
});
|
|
2803
|
+
}
|
|
2804
|
+
}), false, true);
|
|
2805
|
+
$52FdA$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
|
|
2806
|
+
$52FdA$solidjsweb.insert(_el$2, $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
|
|
2807
|
+
get when() {
|
|
2808
|
+
return value().count_ != undefined;
|
|
2809
|
+
},
|
|
2810
|
+
get children() {
|
|
2811
|
+
const _el$3 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$2),
|
|
2812
|
+
_el$4 = _el$3.firstChild;
|
|
2813
|
+
$52FdA$solidjsweb.insert(_el$4, () => value().count_);
|
|
2814
|
+
return _el$3;
|
|
2815
|
+
}
|
|
2816
|
+
}), _el$8, _co$2);
|
|
2817
|
+
$52FdA$solidjsweb.runHydrationEvents();
|
|
2818
|
+
return _el$2;
|
|
2819
|
+
})();
|
|
2820
|
+
const invisible_size_button = $52FdA$solidjsweb.createComponent(MakeButton, {});
|
|
2821
|
+
const smallest_possible_size = $13671aa5e984acd9$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
|
|
2822
|
+
const sizes_value = $52FdA$solidjs.untrack(sizes_set);
|
|
2823
|
+
const shadow_children_value = $52FdA$solidjs.untrack(shadow_children);
|
|
2824
|
+
sizes_value.add(smallest_possible_size);
|
|
2825
|
+
set_sizes_set(sizes_value);
|
|
2826
|
+
shadow_children_value.add(invisible_size_button);
|
|
2827
|
+
set_shadow_children(shadow_children_value);
|
|
2828
|
+
$52FdA$solidjs.onCleanup(() => {
|
|
2829
|
+
const sizes_value = $52FdA$solidjs.untrack(sizes_set);
|
|
2830
|
+
const shadow_children_value = $52FdA$solidjs.untrack(shadow_children);
|
|
2831
|
+
sizes_value.delete(smallest_possible_size);
|
|
2832
|
+
set_sizes_set(sizes_value);
|
|
2833
|
+
shadow_children_value.delete(invisible_size_button);
|
|
2834
|
+
set_shadow_children(shadow_children_value);
|
|
2835
|
+
});
|
|
2836
|
+
// The actual button that will be visible
|
|
2837
|
+
return $52FdA$solidjsweb.createComponent(MakeButton, {});
|
|
2838
|
+
}
|
|
2839
|
+
});
|
|
2840
|
+
}
|
|
2841
|
+
})];
|
|
2762
2842
|
};
|
|
2763
|
-
|
|
2843
|
+
/**
|
|
2844
|
+
* Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
|
|
2845
|
+
*/
|
|
2846
|
+
function $cd0e5524f9476f9b$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
|
|
2847
|
+
let current_row_index = 0;
|
|
2848
|
+
let current_row_items = [];
|
|
2849
|
+
const column_to_row_result = {};
|
|
2850
|
+
const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
|
|
2851
|
+
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)
|
|
2852
|
+
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
|
|
2853
|
+
};
|
|
2854
|
+
|
|
2855
|
+
for (const size_item of sizes) {
|
|
2856
|
+
const size = size_item();
|
|
2857
|
+
if (size == undefined) return; // Only do stuff if we know all the sizes
|
|
2858
|
+
const current_row_length = current_row_items.length;
|
|
2859
|
+
const can_add_another_column_initial_val = current_row_length < $cd0e5524f9476f9b$var$max_columns; // allow max 4 items per row
|
|
2860
|
+
let can_add_another_column = can_add_another_column_initial_val;
|
|
2861
|
+
if (can_add_another_column)
|
|
2862
|
+
// can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
|
|
2863
|
+
for (let i = -1; i < current_row_length; i++) {
|
|
2864
|
+
var _ref3;
|
|
2865
|
+
// -1 is for the new item we're adding and every item is guaranteed to exist
|
|
2866
|
+
const size_to_check = (_ref3 = current_row_items[i]) !== null && _ref3 !== void 0 ? _ref3 : size;
|
|
2867
|
+
const would_have_columns = current_row_length + 1; // if we added another column
|
|
2868
|
+
const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
|
|
2869
|
+
if (!would_fit_evenly) {
|
|
2870
|
+
can_add_another_column = false;
|
|
2871
|
+
break;
|
|
2872
|
+
}
|
|
2873
|
+
}
|
|
2874
|
+
if (can_add_another_column) current_row_items.push(size);else {
|
|
2875
|
+
column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
|
|
2876
|
+
current_row_items = [size]; // save current item for next row
|
|
2877
|
+
}
|
|
2878
|
+
}
|
|
2879
|
+
|
|
2880
|
+
const items_left_to_add = current_row_items.length;
|
|
2881
|
+
if (items_left_to_add) {
|
|
2882
|
+
let num_columns = 1; // We want to have as close to max_columns as possible in the last row
|
|
2883
|
+
let fits = true;
|
|
2884
|
+
do
|
|
2885
|
+
// Check if more columns would fit
|
|
2886
|
+
for (let i = 0; i < items_left_to_add; i++) {
|
|
2887
|
+
const item = current_row_items[i];
|
|
2888
|
+
const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
|
|
2889
|
+
if (!would_fit_evenly) {
|
|
2890
|
+
fits = false;
|
|
2891
|
+
break;
|
|
2892
|
+
}
|
|
2893
|
+
} while (fits && ++num_columns < $cd0e5524f9476f9b$var$max_columns);
|
|
2894
|
+
column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
|
|
2895
|
+
}
|
|
2896
|
+
|
|
2897
|
+
set_cols_at_size([[1, "0px", "", null, {
|
|
2898
|
+
overrides: column_to_row_result
|
|
2899
|
+
}]]);
|
|
2900
|
+
}
|
|
2764
2901
|
function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
|
|
2765
2902
|
const signal = $52FdA$solidjs.createSignal(false);
|
|
2766
2903
|
$52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.javascript_media_query(media_query, _ref => {
|
|
@@ -2819,7 +2956,7 @@ function $476a3dc36afc1938$export$82ed4b28ecb67608(_ref) {
|
|
|
2819
2956
|
});
|
|
2820
2957
|
const rgb_color = $52FdA$solidjs.createMemo(() => $52FdA$depictaiutilishared.hex_to_rgb(hex_color()));
|
|
2821
2958
|
const black_contrast_better = $52FdA$solidjs.createMemo(() => rgb_color() ? $476a3dc36afc1938$var$does_black_contrast_better(rgb_color()) : false);
|
|
2822
|
-
const input_row = $52FdA$solidjsweb.createComponent((0, $
|
|
2959
|
+
const input_row = $52FdA$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
|
|
2823
2960
|
get value_() {
|
|
2824
2961
|
return checkbox().value_;
|
|
2825
2962
|
},
|
package/ES10/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.
|