@depict-ai/ui 2.0.1 → 2.0.3
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 +209 -80
- package/ES10/index.d.ts +5 -1
- package/ES10/index.js +210 -82
- package/latest/index.cjs +203 -77
- package/latest/index.d.ts +5 -1
- package/latest/index.js +204 -79
- package/package.json +2 -2
- package/server/ES10/index.cjs +164 -28
- package/server/ES10/index.d.ts +5 -1
- package/server/ES10/index.js +165 -30
- package/server/latest/index.cjs +158 -25
- package/server/latest/index.d.ts +5 -1
- package/server/latest/index.js +159 -27
- package/locales/require.js +0 -1152
package/ES10/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
var $52FdA$depictaiutilishared = require("@depict-ai/utilishared/ES10");
|
|
2
|
-
var $52FdA$solidjsweb = require("solid-js/web");
|
|
3
2
|
var $52FdA$solidjs = require("solid-js");
|
|
3
|
+
var $52FdA$solidjsweb = require("solid-js/web");
|
|
4
4
|
var $52FdA$babelruntimehelpersclassPrivateFieldSet = require("@babel/runtime/helpers/classPrivateFieldSet");
|
|
5
5
|
var $52FdA$babelruntimehelpersclassPrivateFieldGet = require("@babel/runtime/helpers/classPrivateFieldGet");
|
|
6
6
|
var $52FdA$babelruntimehelpersdefineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
@@ -16,6 +16,7 @@ function $parcel$export(e, n, v, s) {
|
|
|
16
16
|
function $parcel$interopDefault(a) {
|
|
17
17
|
return a && a.__esModule ? a.default : a;
|
|
18
18
|
}
|
|
19
|
+
$parcel$export(module.exports, "make_accurate_size_accessor", () => $13671aa5e984acd9$export$9f191182275e9ef);
|
|
19
20
|
$parcel$export(module.exports, "RecommendationSlider", () => $2badc30d7c6610e1$export$9574e176201e5e8d);
|
|
20
21
|
$parcel$export(module.exports, "RecommendationGrid", () => $41227f10ad680afd$export$9756467d34d91cdb);
|
|
21
22
|
$parcel$export(module.exports, "ShopifyResponsiveImg", () => $858fdcf73148519f$export$6e5611bc7e57e477);
|
|
@@ -66,7 +67,23 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $33eed84f447aa0c0$expo
|
|
|
66
67
|
$parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $33eed84f447aa0c0$export$7bf543b9d9be2c22);
|
|
67
68
|
$parcel$export(module.exports, "version", () => $aa1938dec50d6c12$export$83d89fbfd8236492);
|
|
68
69
|
/*! Depict.ai search and product listing SDK */
|
|
69
|
-
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "2.0.
|
|
70
|
+
const $aa1938dec50d6c12$export$83d89fbfd8236492 = "2.0.3";
|
|
71
|
+
|
|
72
|
+
/** @jsxImportSource solid-js */
|
|
73
|
+
|
|
74
|
+
function $13671aa5e984acd9$export$9f191182275e9ef(what_to_watch) {
|
|
75
|
+
const [size, setSize] = $52FdA$solidjs.createSignal();
|
|
76
|
+
const resizeObserver = new ResizeObserver($52FdA$depictaiutilishared.catchify(records => {
|
|
77
|
+
for (let j = 0; j < records.length; j++) {
|
|
78
|
+
var _records$j$borderBoxS, _records$j$borderBoxS2, _records$j$borderBoxS3;
|
|
79
|
+
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;
|
|
80
|
+
setSize(width);
|
|
81
|
+
}
|
|
82
|
+
}));
|
|
83
|
+
resizeObserver.observe(what_to_watch);
|
|
84
|
+
$52FdA$solidjs.onCleanup(() => resizeObserver.disconnect());
|
|
85
|
+
return size;
|
|
86
|
+
}
|
|
70
87
|
const $5401a6698b0c0658$var$transform_elements = sorted_cols_at_size => {
|
|
71
88
|
const cols_at_size = [];
|
|
72
89
|
for (let i = 0; i < sorted_cols_at_size.length; i++) {
|
|
@@ -1495,9 +1512,9 @@ function $c5842bdb10e57229$export$fecbb157621501bd(_ref) {
|
|
|
1495
1512
|
return outmost_element;
|
|
1496
1513
|
}
|
|
1497
1514
|
$52FdA$solidjsweb.delegateEvents(["click"]);
|
|
1498
|
-
const $
|
|
1499
|
-
$
|
|
1500
|
-
const $
|
|
1515
|
+
const $902a0ca2b52f3898$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<span class="count"></span>`, 2),
|
|
1516
|
+
$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);
|
|
1517
|
+
const $902a0ca2b52f3898$export$48513f6b9f8ce62d = props => {
|
|
1501
1518
|
// 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
|
|
1502
1519
|
const count = $52FdA$solidjs.createMemo(() => props.count_);
|
|
1503
1520
|
const label = $52FdA$solidjs.createMemo(() => props.label_);
|
|
@@ -1506,7 +1523,7 @@ const $6b92e147c6e24046$export$48513f6b9f8ce62d = props => {
|
|
|
1506
1523
|
const is_count_zero = $52FdA$solidjs.createMemo(() => props.is_count_zero_ || count() === 0);
|
|
1507
1524
|
const id = $52FdA$depictaiutilishared.make_random_classname();
|
|
1508
1525
|
return (/* We can't use actual margin because ExpandingContainer gets messed up */(() => {
|
|
1509
|
-
const _el$ = $52FdA$solidjsweb.getNextElement($
|
|
1526
|
+
const _el$ = $52FdA$solidjsweb.getNextElement($902a0ca2b52f3898$var$_tmpl$2),
|
|
1510
1527
|
_el$2 = _el$.firstChild,
|
|
1511
1528
|
_el$3 = _el$2.firstChild,
|
|
1512
1529
|
_el$4 = _el$3.nextSibling,
|
|
@@ -1537,7 +1554,7 @@ const $6b92e147c6e24046$export$48513f6b9f8ce62d = props => {
|
|
|
1537
1554
|
return count() != undefined;
|
|
1538
1555
|
},
|
|
1539
1556
|
get children() {
|
|
1540
|
-
const _el$6 = $52FdA$solidjsweb.getNextElement($
|
|
1557
|
+
const _el$6 = $52FdA$solidjsweb.getNextElement($902a0ca2b52f3898$var$_tmpl$);
|
|
1541
1558
|
$52FdA$solidjsweb.insert(_el$6, count);
|
|
1542
1559
|
return _el$6;
|
|
1543
1560
|
}
|
|
@@ -1633,7 +1650,7 @@ function $9b54b9c5381716eb$export$dd948f91abc3a1c4(_ref) {
|
|
|
1633
1650
|
});
|
|
1634
1651
|
const render_checkbox = checkbox => {
|
|
1635
1652
|
// Checkbox always calls the getters in props, so we don't wrap these values into memos
|
|
1636
|
-
return $52FdA$solidjsweb.createComponent((0, $
|
|
1653
|
+
return $52FdA$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
|
|
1637
1654
|
get value_() {
|
|
1638
1655
|
return checkbox().value_;
|
|
1639
1656
|
},
|
|
@@ -2377,7 +2394,7 @@ function $9c1d49181fb3002a$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
2377
2394
|
[_el$8, _co$3] = $52FdA$solidjsweb.getNextMarker(_el$7.nextSibling),
|
|
2378
2395
|
_el$9 = _el$8.nextSibling,
|
|
2379
2396
|
[_el$10, _co$4] = $52FdA$solidjsweb.getNextMarker(_el$9.nextSibling);
|
|
2380
|
-
$52FdA$solidjsweb.insert(_el$6, $52FdA$solidjsweb.createComponent((0, $
|
|
2397
|
+
$52FdA$solidjsweb.insert(_el$6, $52FdA$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
|
|
2381
2398
|
get value_() {
|
|
2382
2399
|
var _value2;
|
|
2383
2400
|
return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
|
|
@@ -2667,9 +2684,11 @@ function $9c1d49181fb3002a$var$expand_until_choice(data_structure) {
|
|
|
2667
2684
|
}
|
|
2668
2685
|
});
|
|
2669
2686
|
}
|
|
2670
|
-
const $cd0e5524f9476f9b$var$_tmpl$ = /*#__PURE__*/$52FdA$solidjsweb.template(`<div class="checkbox-grid"></div>`, 2),
|
|
2687
|
+
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),
|
|
2671
2688
|
$cd0e5524f9476f9b$var$_tmpl$2 = /*#__PURE__*/$52FdA$solidjsweb.template(`<span class="count-wrapper"><span class="count"></span></span>`, 4),
|
|
2672
|
-
$cd0e5524f9476f9b$var$_tmpl$3 = /*#__PURE__*/$52FdA$solidjsweb.template(`<button
|
|
2689
|
+
$cd0e5524f9476f9b$var$_tmpl$3 = /*#__PURE__*/$52FdA$solidjsweb.template(`<button><!#><!/><!#><!/></button>`, 6);
|
|
2690
|
+
const $cd0e5524f9476f9b$var$gap_px = 5;
|
|
2691
|
+
const $cd0e5524f9476f9b$var$max_columns = 3;
|
|
2673
2692
|
const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
|
|
2674
2693
|
let {
|
|
2675
2694
|
filter_: filter_,
|
|
@@ -2699,77 +2718,187 @@ const $cd0e5524f9476f9b$export$414f6a19d38e655c = _ref => {
|
|
|
2699
2718
|
};
|
|
2700
2719
|
});
|
|
2701
2720
|
});
|
|
2702
|
-
|
|
2721
|
+
const [sizes_set, set_sizes_set] = $52FdA$solidjs.createSignal(new Set(), {
|
|
2722
|
+
equals: false
|
|
2723
|
+
});
|
|
2724
|
+
const [cols_at_size, set_cols_at_size] = $52FdA$solidjs.createSignal([[1, "0px", ""]]);
|
|
2725
|
+
const [container, set_container] = $52FdA$solidjs.createSignal();
|
|
2726
|
+
const container_width_accessor = $52FdA$solidjs.createMemo(() => {
|
|
2727
|
+
const element = container();
|
|
2728
|
+
if (!element) return;
|
|
2729
|
+
return $13671aa5e984acd9$export$9f191182275e9ef(element);
|
|
2730
|
+
});
|
|
2731
|
+
const [shadow_children, set_shadow_children] = $52FdA$solidjs.createSignal(new Set(), {
|
|
2732
|
+
equals: false
|
|
2733
|
+
});
|
|
2734
|
+
const shadow_grid = (() => {
|
|
2703
2735
|
const _el$ = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$);
|
|
2704
|
-
$52FdA$solidjsweb.insert(_el$,
|
|
2705
|
-
get each() {
|
|
2706
|
-
return buttons();
|
|
2707
|
-
},
|
|
2708
|
-
children: value => {
|
|
2709
|
-
const is_selected = $52FdA$solidjs.createMemo(() => {
|
|
2710
|
-
var _existing_filter, _existing_filter$data;
|
|
2711
|
-
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_);
|
|
2712
|
-
});
|
|
2713
|
-
return (() => {
|
|
2714
|
-
const _el$2 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$3),
|
|
2715
|
-
_el$5 = _el$2.firstChild,
|
|
2716
|
-
[_el$6, _co$] = $52FdA$solidjsweb.getNextMarker(_el$5.nextSibling),
|
|
2717
|
-
_el$7 = _el$6.nextSibling,
|
|
2718
|
-
[_el$8, _co$2] = $52FdA$solidjsweb.getNextMarker(_el$7.nextSibling);
|
|
2719
|
-
$52FdA$solidjsweb.addEventListener(_el$2, "click", $52FdA$depictaiutilishared.catchify(() => {
|
|
2720
|
-
const set_filter = existing_filter();
|
|
2721
|
-
const {
|
|
2722
|
-
field: field,
|
|
2723
|
-
op: op
|
|
2724
|
-
} = filter_();
|
|
2725
|
-
const base_object = set_filter ? set_filter : {
|
|
2726
|
-
op: op,
|
|
2727
|
-
field: field
|
|
2728
|
-
};
|
|
2729
|
-
const old_data = base_object.data;
|
|
2730
|
-
const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
|
|
2731
|
-
const new_filter_object = {
|
|
2732
|
-
...base_object,
|
|
2733
|
-
data: new_data
|
|
2734
|
-
};
|
|
2735
|
-
if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
|
|
2736
|
-
const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
|
|
2737
|
-
set_selected_filters(selected_filters);
|
|
2738
|
-
}), true);
|
|
2739
|
-
$52FdA$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
|
|
2740
|
-
$52FdA$solidjsweb.insert(_el$2, $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
|
|
2741
|
-
get when() {
|
|
2742
|
-
return value().count_ != undefined;
|
|
2743
|
-
},
|
|
2744
|
-
get children() {
|
|
2745
|
-
const _el$3 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$2),
|
|
2746
|
-
_el$4 = _el$3.firstChild;
|
|
2747
|
-
$52FdA$solidjsweb.insert(_el$4, () => value().count_);
|
|
2748
|
-
return _el$3;
|
|
2749
|
-
}
|
|
2750
|
-
}), _el$8, _co$2);
|
|
2751
|
-
$52FdA$solidjsweb.effect(_p$ => {
|
|
2752
|
-
const _v$ = value().count_ === 0 && !is_selected(),
|
|
2753
|
-
_v$2 = !is_selected(),
|
|
2754
|
-
_v$3 = !!is_selected();
|
|
2755
|
-
_v$ !== _p$._v$ && (_el$2.disabled = _p$._v$ = _v$);
|
|
2756
|
-
_v$2 !== _p$._v$2 && _el$2.classList.toggle("minor", _p$._v$2 = _v$2);
|
|
2757
|
-
_v$3 !== _p$._v$3 && _el$2.classList.toggle("major", _p$._v$3 = _v$3);
|
|
2758
|
-
return _p$;
|
|
2759
|
-
}, {
|
|
2760
|
-
_v$: undefined,
|
|
2761
|
-
_v$2: undefined,
|
|
2762
|
-
_v$3: undefined
|
|
2763
|
-
});
|
|
2764
|
-
$52FdA$solidjsweb.runHydrationEvents();
|
|
2765
|
-
return _el$2;
|
|
2766
|
-
})();
|
|
2767
|
-
}
|
|
2768
|
-
}));
|
|
2736
|
+
$52FdA$solidjsweb.insert(_el$, () => [...shadow_children()]);
|
|
2769
2737
|
return _el$;
|
|
2770
|
-
})();
|
|
2738
|
+
})(); // for getting the smallest possible sizes of all the items
|
|
2739
|
+
$52FdA$solidjs.createEffect(() => {
|
|
2740
|
+
var _container_width_acce;
|
|
2741
|
+
const container_width = (_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce();
|
|
2742
|
+
if (container_width == undefined) return;
|
|
2743
|
+
$cd0e5524f9476f9b$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
|
|
2744
|
+
});
|
|
2745
|
+
return [shadow_grid, $52FdA$solidjsweb.createComponent((0, $6c2c739b113a8ddf$export$d21e32dfedac04be), {
|
|
2746
|
+
get cols_at_size() {
|
|
2747
|
+
return cols_at_size();
|
|
2748
|
+
},
|
|
2749
|
+
grid_spacing: $cd0e5524f9476f9b$var$gap_px + "px",
|
|
2750
|
+
rows: "all",
|
|
2751
|
+
layout: "grid",
|
|
2752
|
+
element_attributes: {
|
|
2753
|
+
class: "checkbox-grid",
|
|
2754
|
+
ref: el => set_container(el)
|
|
2755
|
+
},
|
|
2756
|
+
get children() {
|
|
2757
|
+
return $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Index), {
|
|
2758
|
+
get each() {
|
|
2759
|
+
return buttons();
|
|
2760
|
+
},
|
|
2761
|
+
children: value => {
|
|
2762
|
+
const is_selected = $52FdA$solidjs.createMemo(() => {
|
|
2763
|
+
var _existing_filter, _existing_filter$data;
|
|
2764
|
+
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_);
|
|
2765
|
+
});
|
|
2766
|
+
const MakeButton = attributes => (() => {
|
|
2767
|
+
const _el$2 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$3),
|
|
2768
|
+
_el$5 = _el$2.firstChild,
|
|
2769
|
+
[_el$6, _co$] = $52FdA$solidjsweb.getNextMarker(_el$5.nextSibling),
|
|
2770
|
+
_el$7 = _el$6.nextSibling,
|
|
2771
|
+
[_el$8, _co$2] = $52FdA$solidjsweb.getNextMarker(_el$7.nextSibling);
|
|
2772
|
+
$52FdA$solidjsweb.spread(_el$2, $52FdA$solidjsweb.mergeProps(attributes, {
|
|
2773
|
+
get disabled() {
|
|
2774
|
+
return $52FdA$solidjsweb.memo(() => value().count_ === 0)() && !is_selected();
|
|
2775
|
+
},
|
|
2776
|
+
get classList() {
|
|
2777
|
+
return {
|
|
2778
|
+
minor: !is_selected(),
|
|
2779
|
+
major: is_selected(),
|
|
2780
|
+
"major-minor-transition": true
|
|
2781
|
+
};
|
|
2782
|
+
},
|
|
2783
|
+
get onClick() {
|
|
2784
|
+
return $52FdA$depictaiutilishared.catchify(() => {
|
|
2785
|
+
const set_filter = existing_filter();
|
|
2786
|
+
const {
|
|
2787
|
+
field: field,
|
|
2788
|
+
op: op
|
|
2789
|
+
} = filter_();
|
|
2790
|
+
const base_object = set_filter ? set_filter : {
|
|
2791
|
+
op: op,
|
|
2792
|
+
field: field
|
|
2793
|
+
};
|
|
2794
|
+
const old_data = base_object.data;
|
|
2795
|
+
const new_data = [...(Array.isArray(old_data) ? [...old_data] : old_data ? [old_data] : [])];
|
|
2796
|
+
const new_filter_object = {
|
|
2797
|
+
...base_object,
|
|
2798
|
+
data: new_data
|
|
2799
|
+
};
|
|
2800
|
+
if (!is_selected()) new_filter_object.data.push(value().value_);else new_filter_object.data = new_filter_object.data.filter(v => v !== value().value_);
|
|
2801
|
+
const selected_filters = [...get_selected_filters().filter(f => f !== set_filter), ...(new_filter_object.data.length ? [new_filter_object] : [])];
|
|
2802
|
+
set_selected_filters(selected_filters);
|
|
2803
|
+
});
|
|
2804
|
+
}
|
|
2805
|
+
}), false, true);
|
|
2806
|
+
$52FdA$solidjsweb.insert(_el$2, () => value().value_, _el$6, _co$);
|
|
2807
|
+
$52FdA$solidjsweb.insert(_el$2, $52FdA$solidjsweb.createComponent((0, $52FdA$solidjs.Show), {
|
|
2808
|
+
get when() {
|
|
2809
|
+
return value().count_ != undefined;
|
|
2810
|
+
},
|
|
2811
|
+
get children() {
|
|
2812
|
+
const _el$3 = $52FdA$solidjsweb.getNextElement($cd0e5524f9476f9b$var$_tmpl$2),
|
|
2813
|
+
_el$4 = _el$3.firstChild;
|
|
2814
|
+
$52FdA$solidjsweb.insert(_el$4, () => value().count_);
|
|
2815
|
+
return _el$3;
|
|
2816
|
+
}
|
|
2817
|
+
}), _el$8, _co$2);
|
|
2818
|
+
$52FdA$solidjsweb.runHydrationEvents();
|
|
2819
|
+
return _el$2;
|
|
2820
|
+
})();
|
|
2821
|
+
const invisible_size_button = $52FdA$solidjsweb.createComponent(MakeButton, {});
|
|
2822
|
+
const smallest_possible_size = $13671aa5e984acd9$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
|
|
2823
|
+
const sizes_value = $52FdA$solidjs.untrack(sizes_set);
|
|
2824
|
+
const shadow_children_value = $52FdA$solidjs.untrack(shadow_children);
|
|
2825
|
+
sizes_value.add(smallest_possible_size);
|
|
2826
|
+
set_sizes_set(sizes_value);
|
|
2827
|
+
shadow_children_value.add(invisible_size_button);
|
|
2828
|
+
set_shadow_children(shadow_children_value);
|
|
2829
|
+
$52FdA$solidjs.onCleanup(() => {
|
|
2830
|
+
const sizes_value = $52FdA$solidjs.untrack(sizes_set);
|
|
2831
|
+
const shadow_children_value = $52FdA$solidjs.untrack(shadow_children);
|
|
2832
|
+
sizes_value.delete(smallest_possible_size);
|
|
2833
|
+
set_sizes_set(sizes_value);
|
|
2834
|
+
shadow_children_value.delete(invisible_size_button);
|
|
2835
|
+
set_shadow_children(shadow_children_value);
|
|
2836
|
+
});
|
|
2837
|
+
// The actual button that will be visible
|
|
2838
|
+
return $52FdA$solidjsweb.createComponent(MakeButton, {});
|
|
2839
|
+
}
|
|
2840
|
+
});
|
|
2841
|
+
}
|
|
2842
|
+
})];
|
|
2771
2843
|
};
|
|
2772
|
-
|
|
2844
|
+
/**
|
|
2845
|
+
* Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
|
|
2846
|
+
*/
|
|
2847
|
+
function $cd0e5524f9476f9b$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
|
|
2848
|
+
let current_row_index = 0;
|
|
2849
|
+
let current_row_items = [];
|
|
2850
|
+
const column_to_row_result = {};
|
|
2851
|
+
const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
|
|
2852
|
+
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)
|
|
2853
|
+
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
|
|
2854
|
+
};
|
|
2855
|
+
|
|
2856
|
+
for (const size_item of sizes) {
|
|
2857
|
+
const size = size_item();
|
|
2858
|
+
if (size == undefined) return; // Only do stuff if we know all the sizes
|
|
2859
|
+
const current_row_length = current_row_items.length;
|
|
2860
|
+
const can_add_another_column_initial_val = current_row_length < $cd0e5524f9476f9b$var$max_columns; // allow max 4 items per row
|
|
2861
|
+
let can_add_another_column = can_add_another_column_initial_val;
|
|
2862
|
+
if (can_add_another_column)
|
|
2863
|
+
// can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
|
|
2864
|
+
for (let i = -1; i < current_row_length; i++) {
|
|
2865
|
+
var _ref3;
|
|
2866
|
+
// -1 is for the new item we're adding and every item is guaranteed to exist
|
|
2867
|
+
const size_to_check = (_ref3 = current_row_items[i]) !== null && _ref3 !== void 0 ? _ref3 : size;
|
|
2868
|
+
const would_have_columns = current_row_length + 1; // if we added another column
|
|
2869
|
+
const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
|
|
2870
|
+
if (!would_fit_evenly) {
|
|
2871
|
+
can_add_another_column = false;
|
|
2872
|
+
break;
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
if (can_add_another_column) current_row_items.push(size);else {
|
|
2876
|
+
column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
|
|
2877
|
+
current_row_items = [size]; // save current item for next row
|
|
2878
|
+
}
|
|
2879
|
+
}
|
|
2880
|
+
|
|
2881
|
+
const items_left_to_add = current_row_items.length;
|
|
2882
|
+
if (items_left_to_add) {
|
|
2883
|
+
let num_columns = 1; // We want to have as close to max_columns as possible in the last row
|
|
2884
|
+
let fits = true;
|
|
2885
|
+
do
|
|
2886
|
+
// Check if more columns would fit
|
|
2887
|
+
for (let i = 0; i < items_left_to_add; i++) {
|
|
2888
|
+
const item = current_row_items[i];
|
|
2889
|
+
const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
|
|
2890
|
+
if (!would_fit_evenly) {
|
|
2891
|
+
fits = false;
|
|
2892
|
+
break;
|
|
2893
|
+
}
|
|
2894
|
+
} while (fits && ++num_columns < $cd0e5524f9476f9b$var$max_columns);
|
|
2895
|
+
column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
|
|
2896
|
+
}
|
|
2897
|
+
|
|
2898
|
+
set_cols_at_size([[1, "0px", "", null, {
|
|
2899
|
+
overrides: column_to_row_result
|
|
2900
|
+
}]]);
|
|
2901
|
+
}
|
|
2773
2902
|
function $3e17e871e9d0911d$export$d9f36cf74e24d595(media_query) {
|
|
2774
2903
|
const signal = $52FdA$solidjs.createSignal(false);
|
|
2775
2904
|
$52FdA$solidjs.onCleanup($52FdA$depictaiutilishared.javascript_media_query(media_query, _ref => {
|
|
@@ -2828,7 +2957,7 @@ function $476a3dc36afc1938$export$82ed4b28ecb67608(_ref) {
|
|
|
2828
2957
|
});
|
|
2829
2958
|
const rgb_color = $52FdA$solidjs.createMemo(() => $52FdA$depictaiutilishared.hex_to_rgb(hex_color()));
|
|
2830
2959
|
const black_contrast_better = $52FdA$solidjs.createMemo(() => rgb_color() ? $476a3dc36afc1938$var$does_black_contrast_better(rgb_color()) : false);
|
|
2831
|
-
const input_row = $52FdA$solidjsweb.createComponent((0, $
|
|
2960
|
+
const input_row = $52FdA$solidjsweb.createComponent((0, $902a0ca2b52f3898$export$48513f6b9f8ce62d), {
|
|
2832
2961
|
get value_() {
|
|
2833
2962
|
return checkbox().value_;
|
|
2834
2963
|
},
|
package/ES10/index.d.ts
CHANGED
|
@@ -7,7 +7,11 @@ 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.3";
|
|
11
|
+
/**
|
|
12
|
+
* Returns accessor with the size of the provided element, including padding and border (I think)
|
|
13
|
+
*/
|
|
14
|
+
export function make_accurate_size_accessor(what_to_watch: HTMLElement): import("solid-js").Accessor<number | undefined>;
|
|
11
15
|
export type SDKGridSpacing = string | {
|
|
12
16
|
horizontal: string;
|
|
13
17
|
vertical: string;
|