@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/server/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.
|
package/server/ES10/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import $b8hua$babelruntimehelpersdefineProperty from "@babel/runtime/helpers/def
|
|
|
8
8
|
/*! Depict.ai search and product listing SDK */
|
|
9
9
|
import { register_es_version } from "../../multi_import_deduplicator.mjs";
|
|
10
10
|
register_es_version("ui", "ES10");
|
|
11
|
-
const $8db9a15135765c11$export$83d89fbfd8236492 = "2.0.
|
|
11
|
+
const $8db9a15135765c11$export$83d89fbfd8236492 = "2.0.2";
|
|
12
12
|
const $a9c7ba6087881ac2$var$transform_elements = sorted_cols_at_size => {
|
|
13
13
|
const cols_at_size = [];
|
|
14
14
|
for (let i = 0; i < sorted_cols_at_size.length; i++) {
|
|
@@ -634,9 +634,18 @@ function $b432b11321ad4c97$export$9756467d34d91cdb(props) {
|
|
|
634
634
|
return $83e8cf2c0b87a58a$export$23fca46f3143581f(() => {
|
|
635
635
|
const rows_object_ = $b8hua$createMemo(() => {
|
|
636
636
|
var _view_more_button$row;
|
|
637
|
-
const
|
|
638
|
-
|
|
637
|
+
const {
|
|
638
|
+
view_more_button: view_more_button,
|
|
639
|
+
max_rows: max_rows
|
|
640
|
+
} = props;
|
|
641
|
+
if (!view_more_button) {
|
|
642
|
+
if (max_rows) return {
|
|
643
|
+
max_rows: max_rows
|
|
644
|
+
};
|
|
645
|
+
return "all";
|
|
646
|
+
}
|
|
639
647
|
return {
|
|
648
|
+
max_rows: max_rows,
|
|
640
649
|
start_rows: view_more_button.start_rows,
|
|
641
650
|
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,
|
|
642
651
|
button: $b8hua$ssr($b432b11321ad4c97$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(view_more_button.text))
|
|
@@ -1061,9 +1070,9 @@ function $4711a82d08d2021b$export$fecbb157621501bd(_ref) {
|
|
|
1061
1070
|
}));
|
|
1062
1071
|
return outmost_element;
|
|
1063
1072
|
}
|
|
1064
|
-
const $
|
|
1065
|
-
$
|
|
1066
|
-
const $
|
|
1073
|
+
const $19e828709c7723a0$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
|
|
1074
|
+
$19e828709c7723a0$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--#-->", "<!--/--></label>"];
|
|
1075
|
+
const $19e828709c7723a0$export$48513f6b9f8ce62d = props => {
|
|
1067
1076
|
// 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
|
|
1068
1077
|
const count = $b8hua$createMemo(() => props.count_);
|
|
1069
1078
|
const label = $b8hua$createMemo(() => props.label_);
|
|
@@ -1071,12 +1080,12 @@ const $6b73914551534ea8$export$48513f6b9f8ce62d = props => {
|
|
|
1071
1080
|
const value = $b8hua$createMemo(() => props.value_);
|
|
1072
1081
|
const is_count_zero = $b8hua$createMemo(() => props.is_count_zero_ || count() === 0);
|
|
1073
1082
|
const id = $b8hua$make_random_classname();
|
|
1074
|
-
return (/* We can't use actual margin because ExpandingContainer gets messed up */$b8hua$ssr($
|
|
1083
|
+
return (/* We can't use actual margin because ExpandingContainer gets messed up */$b8hua$ssr($19e828709c7723a0$var$_tmpl$2, $b8hua$ssrHydrationKey(), "input-row ".concat(is_count_zero() ? "count-0" : ""), $b8hua$ssrAttribute("for", $b8hua$escape(id, true), false), $b8hua$ssrAttribute("name", $b8hua$escape(value(), true), false) + $b8hua$ssrAttribute("id", $b8hua$escape(id, true), false), $b8hua$ssrAttribute("checked", checked(), true), $b8hua$ssrAttribute("disabled", !checked() && is_count_zero(), true), $b8hua$escape(label()) || $b8hua$escape(value()), $b8hua$escape($b8hua$createComponent((0, $b8hua$Show), {
|
|
1075
1084
|
get when() {
|
|
1076
1085
|
return count() != undefined;
|
|
1077
1086
|
},
|
|
1078
1087
|
get children() {
|
|
1079
|
-
return $b8hua$ssr($
|
|
1088
|
+
return $b8hua$ssr($19e828709c7723a0$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape(count()));
|
|
1080
1089
|
}
|
|
1081
1090
|
})))
|
|
1082
1091
|
);
|
|
@@ -1135,7 +1144,7 @@ function $133484ef10e4e954$export$dd948f91abc3a1c4(_ref) {
|
|
|
1135
1144
|
});
|
|
1136
1145
|
const render_checkbox = checkbox => {
|
|
1137
1146
|
// Checkbox always calls the getters in props, so we don't wrap these values into memos
|
|
1138
|
-
return $b8hua$createComponent((0, $
|
|
1147
|
+
return $b8hua$createComponent((0, $19e828709c7723a0$export$48513f6b9f8ce62d), {
|
|
1139
1148
|
get value_() {
|
|
1140
1149
|
return checkbox().value_;
|
|
1141
1150
|
},
|
|
@@ -1643,7 +1652,7 @@ function $0ae614c5c7babb43$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
1643
1652
|
var _value;
|
|
1644
1653
|
return !!Object.keys(((_value = value()) === null || _value === void 0 ? void 0 : _value.children_) || {}).length;
|
|
1645
1654
|
});
|
|
1646
|
-
return $b8hua$ssr($0ae614c5c7babb43$var$_tmpl$2, $b8hua$ssrHydrationKey(), "checkbox-details ".concat(has_expandable() ? "expandable" : ""), $b8hua$escape($b8hua$createComponent((0, $
|
|
1655
|
+
return $b8hua$ssr($0ae614c5c7babb43$var$_tmpl$2, $b8hua$ssrHydrationKey(), "checkbox-details ".concat(has_expandable() ? "expandable" : ""), $b8hua$escape($b8hua$createComponent((0, $19e828709c7723a0$export$48513f6b9f8ce62d), {
|
|
1647
1656
|
get value_() {
|
|
1648
1657
|
var _value2;
|
|
1649
1658
|
return JSON.stringify((_value2 = value()) === null || _value2 === void 0 ? void 0 : _value2.value_);
|
|
@@ -1914,9 +1923,26 @@ function $0ae614c5c7babb43$var$expand_until_choice(data_structure) {
|
|
|
1914
1923
|
}
|
|
1915
1924
|
});
|
|
1916
1925
|
}
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1926
|
+
|
|
1927
|
+
/** @jsxImportSource solid-js */
|
|
1928
|
+
|
|
1929
|
+
function $0dc044cffe1e825b$export$9f191182275e9ef(what_to_watch) {
|
|
1930
|
+
const [size, setSize] = $b8hua$createSignal();
|
|
1931
|
+
const resizeObserver = new ResizeObserver($b8hua$catchify(records => {
|
|
1932
|
+
for (let j = 0; j < records.length; j++) {
|
|
1933
|
+
var _records$j$borderBoxS, _records$j$borderBoxS2, _records$j$borderBoxS3;
|
|
1934
|
+
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;
|
|
1935
|
+
setSize(width);
|
|
1936
|
+
}
|
|
1937
|
+
}));
|
|
1938
|
+
resizeObserver.observe(what_to_watch);
|
|
1939
|
+
$b8hua$onCleanup(() => resizeObserver.disconnect());
|
|
1940
|
+
return size;
|
|
1941
|
+
}
|
|
1942
|
+
const $830ea8efda59884e$var$_tmpl$ = ["<div", ' class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0">', "</div>"],
|
|
1943
|
+
$830ea8efda59884e$var$_tmpl$2 = ["<span", ' class="count-wrapper"><span class="count">', "</span></span>"];
|
|
1944
|
+
const $830ea8efda59884e$var$gap_px = 5;
|
|
1945
|
+
const $830ea8efda59884e$var$max_columns = 3;
|
|
1920
1946
|
const $830ea8efda59884e$export$414f6a19d38e655c = _ref => {
|
|
1921
1947
|
let {
|
|
1922
1948
|
filter_: filter_,
|
|
@@ -1946,26 +1972,144 @@ const $830ea8efda59884e$export$414f6a19d38e655c = _ref => {
|
|
|
1946
1972
|
};
|
|
1947
1973
|
});
|
|
1948
1974
|
});
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1975
|
+
const [sizes_set, set_sizes_set] = $b8hua$createSignal(new Set(), {
|
|
1976
|
+
equals: false
|
|
1977
|
+
});
|
|
1978
|
+
const [cols_at_size, set_cols_at_size] = $b8hua$createSignal([[1, "0px", ""]]);
|
|
1979
|
+
const [container, set_container] = $b8hua$createSignal();
|
|
1980
|
+
const container_width_accessor = $b8hua$createMemo(() => {
|
|
1981
|
+
const element = container();
|
|
1982
|
+
if (!element) return;
|
|
1983
|
+
return $0dc044cffe1e825b$export$9f191182275e9ef(element);
|
|
1984
|
+
});
|
|
1985
|
+
const [shadow_children, set_shadow_children] = $b8hua$createSignal(new Set(), {
|
|
1986
|
+
equals: false
|
|
1987
|
+
});
|
|
1988
|
+
const shadow_grid = $b8hua$ssr($830ea8efda59884e$var$_tmpl$, $b8hua$ssrHydrationKey(), $b8hua$escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
|
|
1989
|
+
$b8hua$createEffect(() => {
|
|
1990
|
+
var _container_width_acce;
|
|
1991
|
+
const container_width = (_container_width_acce = container_width_accessor()) === null || _container_width_acce === void 0 ? void 0 : _container_width_acce();
|
|
1992
|
+
if (container_width == undefined) return;
|
|
1993
|
+
$830ea8efda59884e$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
|
|
1994
|
+
});
|
|
1995
|
+
return [shadow_grid, $b8hua$createComponent((0, $63f1f8dbcd07d3b0$export$d21e32dfedac04be), {
|
|
1996
|
+
get cols_at_size() {
|
|
1997
|
+
return cols_at_size();
|
|
1952
1998
|
},
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
|
|
1959
|
-
|
|
1960
|
-
|
|
1999
|
+
grid_spacing: $830ea8efda59884e$var$gap_px + "px",
|
|
2000
|
+
rows: "all",
|
|
2001
|
+
layout: "grid",
|
|
2002
|
+
element_attributes: {
|
|
2003
|
+
class: "checkbox-grid",
|
|
2004
|
+
ref: el => set_container(el)
|
|
2005
|
+
},
|
|
2006
|
+
get children() {
|
|
2007
|
+
return $b8hua$createComponent((0, $b8hua$Index), {
|
|
2008
|
+
get each() {
|
|
2009
|
+
return buttons();
|
|
1961
2010
|
},
|
|
1962
|
-
|
|
1963
|
-
|
|
2011
|
+
children: value => {
|
|
2012
|
+
const is_selected = $b8hua$createMemo(() => {
|
|
2013
|
+
var _existing_filter, _existing_filter$data;
|
|
2014
|
+
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_);
|
|
2015
|
+
});
|
|
2016
|
+
const MakeButton = attributes => $b8hua$ssrElement("button", () => ({
|
|
2017
|
+
...attributes,
|
|
2018
|
+
"disabled": value().count_ === 0 && !is_selected(),
|
|
2019
|
+
"classList": {
|
|
2020
|
+
minor: !is_selected(),
|
|
2021
|
+
major: is_selected(),
|
|
2022
|
+
"major-minor-transition": true
|
|
2023
|
+
}
|
|
2024
|
+
}), () => ["<!--#-->", $b8hua$escape(value().value_), "<!--/-->", "<!--#-->", $b8hua$escape($b8hua$createComponent((0, $b8hua$Show), {
|
|
2025
|
+
get when() {
|
|
2026
|
+
return value().count_ != undefined;
|
|
2027
|
+
},
|
|
2028
|
+
get children() {
|
|
2029
|
+
return $b8hua$ssr($830ea8efda59884e$var$_tmpl$2, $b8hua$ssrHydrationKey(), $b8hua$escape(value().count_));
|
|
2030
|
+
}
|
|
2031
|
+
})), "<!--/-->"], true);
|
|
2032
|
+
const invisible_size_button = $b8hua$createComponent(MakeButton, {});
|
|
2033
|
+
const smallest_possible_size = $0dc044cffe1e825b$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
|
|
2034
|
+
const sizes_value = $b8hua$untrack(sizes_set);
|
|
2035
|
+
const shadow_children_value = $b8hua$untrack(shadow_children);
|
|
2036
|
+
sizes_value.add(smallest_possible_size);
|
|
2037
|
+
set_sizes_set(sizes_value);
|
|
2038
|
+
shadow_children_value.add(invisible_size_button);
|
|
2039
|
+
set_shadow_children(shadow_children_value);
|
|
2040
|
+
$b8hua$onCleanup(() => {
|
|
2041
|
+
const sizes_value = $b8hua$untrack(sizes_set);
|
|
2042
|
+
const shadow_children_value = $b8hua$untrack(shadow_children);
|
|
2043
|
+
sizes_value.delete(smallest_possible_size);
|
|
2044
|
+
set_sizes_set(sizes_value);
|
|
2045
|
+
shadow_children_value.delete(invisible_size_button);
|
|
2046
|
+
set_shadow_children(shadow_children_value);
|
|
2047
|
+
});
|
|
2048
|
+
// The actual button that will be visible
|
|
2049
|
+
return $b8hua$createComponent(MakeButton, {});
|
|
1964
2050
|
}
|
|
1965
|
-
})
|
|
2051
|
+
});
|
|
1966
2052
|
}
|
|
1967
|
-
})
|
|
2053
|
+
})];
|
|
1968
2054
|
};
|
|
2055
|
+
/**
|
|
2056
|
+
* Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
|
|
2057
|
+
*/
|
|
2058
|
+
function $830ea8efda59884e$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
|
|
2059
|
+
let current_row_index = 0;
|
|
2060
|
+
let current_row_items = [];
|
|
2061
|
+
const column_to_row_result = {};
|
|
2062
|
+
const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
|
|
2063
|
+
const would_have_even_size = container_width / at_number_of_columnns - (at_number_of_columnns * 2 - 2) * ($830ea8efda59884e$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)
|
|
2064
|
+
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
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2067
|
+
for (const size_item of sizes) {
|
|
2068
|
+
const size = size_item();
|
|
2069
|
+
if (size == undefined) return; // Only do stuff if we know all the sizes
|
|
2070
|
+
const current_row_length = current_row_items.length;
|
|
2071
|
+
const can_add_another_column_initial_val = current_row_length < $830ea8efda59884e$var$max_columns; // allow max 4 items per row
|
|
2072
|
+
let can_add_another_column = can_add_another_column_initial_val;
|
|
2073
|
+
if (can_add_another_column)
|
|
2074
|
+
// can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
|
|
2075
|
+
for (let i = -1; i < current_row_length; i++) {
|
|
2076
|
+
var _ref3;
|
|
2077
|
+
// -1 is for the new item we're adding and every item is guaranteed to exist
|
|
2078
|
+
const size_to_check = (_ref3 = current_row_items[i]) !== null && _ref3 !== void 0 ? _ref3 : size;
|
|
2079
|
+
const would_have_columns = current_row_length + 1; // if we added another column
|
|
2080
|
+
const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
|
|
2081
|
+
if (!would_fit_evenly) {
|
|
2082
|
+
can_add_another_column = false;
|
|
2083
|
+
break;
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
if (can_add_another_column) current_row_items.push(size);else {
|
|
2087
|
+
column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
|
|
2088
|
+
current_row_items = [size]; // save current item for next row
|
|
2089
|
+
}
|
|
2090
|
+
}
|
|
2091
|
+
|
|
2092
|
+
const items_left_to_add = current_row_items.length;
|
|
2093
|
+
if (items_left_to_add) {
|
|
2094
|
+
let num_columns = 1; // We want to have as close to max_columns as possible in the last row
|
|
2095
|
+
let fits = true;
|
|
2096
|
+
do
|
|
2097
|
+
// Check if more columns would fit
|
|
2098
|
+
for (let i = 0; i < items_left_to_add; i++) {
|
|
2099
|
+
const item = current_row_items[i];
|
|
2100
|
+
const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
|
|
2101
|
+
if (!would_fit_evenly) {
|
|
2102
|
+
fits = false;
|
|
2103
|
+
break;
|
|
2104
|
+
}
|
|
2105
|
+
} while (fits && ++num_columns < $830ea8efda59884e$var$max_columns);
|
|
2106
|
+
column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
|
|
2107
|
+
}
|
|
2108
|
+
|
|
2109
|
+
set_cols_at_size([[1, "0px", "", null, {
|
|
2110
|
+
overrides: column_to_row_result
|
|
2111
|
+
}]]);
|
|
2112
|
+
}
|
|
1969
2113
|
function $00a5b94f0c11efbb$export$d9f36cf74e24d595(media_query) {
|
|
1970
2114
|
const signal = $b8hua$createSignal(false);
|
|
1971
2115
|
$b8hua$onCleanup($b8hua$javascript_media_query(media_query, _ref => {
|
|
@@ -2024,7 +2168,7 @@ function $2cb856c297c53e6c$export$82ed4b28ecb67608(_ref) {
|
|
|
2024
2168
|
});
|
|
2025
2169
|
const rgb_color = $b8hua$createMemo(() => $b8hua$hex_to_rgb(hex_color()));
|
|
2026
2170
|
const black_contrast_better = $b8hua$createMemo(() => rgb_color() ? $2cb856c297c53e6c$var$does_black_contrast_better(rgb_color()) : false);
|
|
2027
|
-
const input_row = $b8hua$createComponent((0, $
|
|
2171
|
+
const input_row = $b8hua$createComponent((0, $19e828709c7723a0$export$48513f6b9f8ce62d), {
|
|
2028
2172
|
get value_() {
|
|
2029
2173
|
return checkbox().value_;
|
|
2030
2174
|
},
|
package/server/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++) {
|
|
@@ -644,9 +644,18 @@ const $1f8dbf7e28b3eff2$var$_tmpl$ = ["<button", ' class="show-more major" type=
|
|
|
644
644
|
function $1f8dbf7e28b3eff2$export$9756467d34d91cdb(props) {
|
|
645
645
|
return $95837413165cc2df$export$23fca46f3143581f(() => {
|
|
646
646
|
const rows_object_ = $5vyXB$solidjs.createMemo(() => {
|
|
647
|
-
const
|
|
648
|
-
|
|
647
|
+
const {
|
|
648
|
+
view_more_button: view_more_button,
|
|
649
|
+
max_rows: max_rows
|
|
650
|
+
} = props;
|
|
651
|
+
if (!view_more_button) {
|
|
652
|
+
if (max_rows) return {
|
|
653
|
+
max_rows: max_rows
|
|
654
|
+
};
|
|
655
|
+
return "all";
|
|
656
|
+
}
|
|
649
657
|
return {
|
|
658
|
+
max_rows: max_rows,
|
|
650
659
|
start_rows: view_more_button.start_rows,
|
|
651
660
|
rows_per_click: view_more_button.rows_per_click ?? 2,
|
|
652
661
|
button: $5vyXB$solidjsweb.ssr($1f8dbf7e28b3eff2$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(view_more_button.text))
|
|
@@ -1052,9 +1061,9 @@ function $235a2771a44e28e9$export$fecbb157621501bd({
|
|
|
1052
1061
|
}));
|
|
1053
1062
|
return outmost_element;
|
|
1054
1063
|
}
|
|
1055
|
-
const $
|
|
1056
|
-
$
|
|
1057
|
-
const $
|
|
1064
|
+
const $1c63082b2da848ad$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
|
|
1065
|
+
$1c63082b2da848ad$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--#-->", "<!--/--></label>"];
|
|
1066
|
+
const $1c63082b2da848ad$export$48513f6b9f8ce62d = props => {
|
|
1058
1067
|
// 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
|
|
1059
1068
|
const count = $5vyXB$solidjs.createMemo(() => props.count_);
|
|
1060
1069
|
const label = $5vyXB$solidjs.createMemo(() => props.label_);
|
|
@@ -1062,12 +1071,12 @@ const $b3cf6ca8dc0e9998$export$48513f6b9f8ce62d = props => {
|
|
|
1062
1071
|
const value = $5vyXB$solidjs.createMemo(() => props.value_);
|
|
1063
1072
|
const is_count_zero = $5vyXB$solidjs.createMemo(() => props.is_count_zero_ || count() === 0);
|
|
1064
1073
|
const id = $5vyXB$depictaiutilishared.make_random_classname();
|
|
1065
|
-
return (/* We can't use actual margin because ExpandingContainer gets messed up */$5vyXB$solidjsweb.ssr($
|
|
1074
|
+
return (/* We can't use actual margin because ExpandingContainer gets messed up */$5vyXB$solidjsweb.ssr($1c63082b2da848ad$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `input-row ${is_count_zero() ? "count-0" : ""}`, $5vyXB$solidjsweb.ssrAttribute("for", $5vyXB$solidjsweb.escape(id, true), false), $5vyXB$solidjsweb.ssrAttribute("name", $5vyXB$solidjsweb.escape(value(), true), false) + $5vyXB$solidjsweb.ssrAttribute("id", $5vyXB$solidjsweb.escape(id, true), false), $5vyXB$solidjsweb.ssrAttribute("checked", checked(), true), $5vyXB$solidjsweb.ssrAttribute("disabled", !checked() && is_count_zero(), true), $5vyXB$solidjsweb.escape(label()) || $5vyXB$solidjsweb.escape(value()), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
1066
1075
|
get when() {
|
|
1067
1076
|
return count() != undefined;
|
|
1068
1077
|
},
|
|
1069
1078
|
get children() {
|
|
1070
|
-
return $5vyXB$solidjsweb.ssr($
|
|
1079
|
+
return $5vyXB$solidjsweb.ssr($1c63082b2da848ad$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(count()));
|
|
1071
1080
|
}
|
|
1072
1081
|
})))
|
|
1073
1082
|
);
|
|
@@ -1118,7 +1127,7 @@ function $d94869c80e337a3d$export$dd948f91abc3a1c4({
|
|
|
1118
1127
|
});
|
|
1119
1128
|
const render_checkbox = checkbox => {
|
|
1120
1129
|
// Checkbox always calls the getters in props, so we don't wrap these values into memos
|
|
1121
|
-
return $5vyXB$solidjsweb.createComponent((0, $
|
|
1130
|
+
return $5vyXB$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
1122
1131
|
get value_() {
|
|
1123
1132
|
return checkbox().value_;
|
|
1124
1133
|
},
|
|
@@ -1592,7 +1601,7 @@ function $3bdc00a1353c1150$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
1592
1601
|
// for some reason the for thing doesn't dispose of us if the key no longer exists?? so I'm doing it with show instead
|
|
1593
1602
|
const value = $5vyXB$solidjs.createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
|
|
1594
1603
|
const has_expandable = $5vyXB$solidjs.createMemo(() => !!Object.keys(value()?.children_ || {}).length);
|
|
1595
|
-
return $5vyXB$solidjsweb.ssr($3bdc00a1353c1150$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `checkbox-details ${has_expandable() ? "expandable" : ""}`, $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $
|
|
1604
|
+
return $5vyXB$solidjsweb.ssr($3bdc00a1353c1150$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), `checkbox-details ${has_expandable() ? "expandable" : ""}`, $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
1596
1605
|
get value_() {
|
|
1597
1606
|
return JSON.stringify(value()?.value_);
|
|
1598
1607
|
},
|
|
@@ -1832,9 +1841,25 @@ function $3bdc00a1353c1150$var$expand_until_choice(data_structure) {
|
|
|
1832
1841
|
}
|
|
1833
1842
|
});
|
|
1834
1843
|
}
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1844
|
+
|
|
1845
|
+
/** @jsxImportSource solid-js */
|
|
1846
|
+
|
|
1847
|
+
function $e5f442fb78c98741$export$9f191182275e9ef(what_to_watch) {
|
|
1848
|
+
const [size, setSize] = $5vyXB$solidjs.createSignal();
|
|
1849
|
+
const resizeObserver = new ResizeObserver($5vyXB$depictaiutilishared.catchify(records => {
|
|
1850
|
+
for (let j = 0; j < records.length; j++) {
|
|
1851
|
+
const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
|
|
1852
|
+
setSize(width);
|
|
1853
|
+
}
|
|
1854
|
+
}));
|
|
1855
|
+
resizeObserver.observe(what_to_watch);
|
|
1856
|
+
$5vyXB$solidjs.onCleanup(() => resizeObserver.disconnect());
|
|
1857
|
+
return size;
|
|
1858
|
+
}
|
|
1859
|
+
const $0ef1681699140f1a$var$_tmpl$ = ["<div", ' class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0">', "</div>"],
|
|
1860
|
+
$0ef1681699140f1a$var$_tmpl$2 = ["<span", ' class="count-wrapper"><span class="count">', "</span></span>"];
|
|
1861
|
+
const $0ef1681699140f1a$var$gap_px = 5;
|
|
1862
|
+
const $0ef1681699140f1a$var$max_columns = 3;
|
|
1838
1863
|
const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
1839
1864
|
filter_: filter_,
|
|
1840
1865
|
selected_filters_: [get_selected_filters, set_selected_filters]
|
|
@@ -1857,23 +1882,139 @@ const $0ef1681699140f1a$export$414f6a19d38e655c = ({
|
|
|
1857
1882
|
count_: meta.counts?.[index]
|
|
1858
1883
|
}));
|
|
1859
1884
|
});
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1885
|
+
const [sizes_set, set_sizes_set] = $5vyXB$solidjs.createSignal(new Set(), {
|
|
1886
|
+
equals: false
|
|
1887
|
+
});
|
|
1888
|
+
const [cols_at_size, set_cols_at_size] = $5vyXB$solidjs.createSignal([[1, "0px", ""]]);
|
|
1889
|
+
const [container, set_container] = $5vyXB$solidjs.createSignal();
|
|
1890
|
+
const container_width_accessor = $5vyXB$solidjs.createMemo(() => {
|
|
1891
|
+
const element = container();
|
|
1892
|
+
if (!element) return;
|
|
1893
|
+
return $e5f442fb78c98741$export$9f191182275e9ef(element);
|
|
1894
|
+
});
|
|
1895
|
+
const [shadow_children, set_shadow_children] = $5vyXB$solidjs.createSignal(new Set(), {
|
|
1896
|
+
equals: false
|
|
1897
|
+
});
|
|
1898
|
+
const shadow_grid = $5vyXB$solidjsweb.ssr($0ef1681699140f1a$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
|
|
1899
|
+
$5vyXB$solidjs.createEffect(() => {
|
|
1900
|
+
const container_width = container_width_accessor()?.();
|
|
1901
|
+
if (container_width == undefined) return;
|
|
1902
|
+
$0ef1681699140f1a$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
|
|
1903
|
+
});
|
|
1904
|
+
return [shadow_grid, $5vyXB$solidjsweb.createComponent((0, $f48d0fbb00835aaa$export$d21e32dfedac04be), {
|
|
1905
|
+
get cols_at_size() {
|
|
1906
|
+
return cols_at_size();
|
|
1863
1907
|
},
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1908
|
+
grid_spacing: $0ef1681699140f1a$var$gap_px + "px",
|
|
1909
|
+
rows: "all",
|
|
1910
|
+
layout: "grid",
|
|
1911
|
+
element_attributes: {
|
|
1912
|
+
class: "checkbox-grid",
|
|
1913
|
+
ref: el => set_container(el)
|
|
1914
|
+
},
|
|
1915
|
+
get children() {
|
|
1916
|
+
return $5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Index), {
|
|
1917
|
+
get each() {
|
|
1918
|
+
return buttons();
|
|
1869
1919
|
},
|
|
1870
|
-
|
|
1871
|
-
|
|
1920
|
+
children: value => {
|
|
1921
|
+
const is_selected = $5vyXB$solidjs.createMemo(() => existing_filter()?.data?.includes(value().value_));
|
|
1922
|
+
const MakeButton = attributes => $5vyXB$solidjsweb.ssrElement("button", () => ({
|
|
1923
|
+
...attributes,
|
|
1924
|
+
"disabled": value().count_ === 0 && !is_selected(),
|
|
1925
|
+
"classList": {
|
|
1926
|
+
minor: !is_selected(),
|
|
1927
|
+
major: is_selected(),
|
|
1928
|
+
"major-minor-transition": true
|
|
1929
|
+
}
|
|
1930
|
+
}), () => ["<!--#-->", $5vyXB$solidjsweb.escape(value().value_), "<!--/-->", "<!--#-->", $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $5vyXB$solidjs.Show), {
|
|
1931
|
+
get when() {
|
|
1932
|
+
return value().count_ != undefined;
|
|
1933
|
+
},
|
|
1934
|
+
get children() {
|
|
1935
|
+
return $5vyXB$solidjsweb.ssr($0ef1681699140f1a$var$_tmpl$2, $5vyXB$solidjsweb.ssrHydrationKey(), $5vyXB$solidjsweb.escape(value().count_));
|
|
1936
|
+
}
|
|
1937
|
+
})), "<!--/-->"], true);
|
|
1938
|
+
const invisible_size_button = $5vyXB$solidjsweb.createComponent(MakeButton, {});
|
|
1939
|
+
const smallest_possible_size = $e5f442fb78c98741$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
|
|
1940
|
+
const sizes_value = $5vyXB$solidjs.untrack(sizes_set);
|
|
1941
|
+
const shadow_children_value = $5vyXB$solidjs.untrack(shadow_children);
|
|
1942
|
+
sizes_value.add(smallest_possible_size);
|
|
1943
|
+
set_sizes_set(sizes_value);
|
|
1944
|
+
shadow_children_value.add(invisible_size_button);
|
|
1945
|
+
set_shadow_children(shadow_children_value);
|
|
1946
|
+
$5vyXB$solidjs.onCleanup(() => {
|
|
1947
|
+
const sizes_value = $5vyXB$solidjs.untrack(sizes_set);
|
|
1948
|
+
const shadow_children_value = $5vyXB$solidjs.untrack(shadow_children);
|
|
1949
|
+
sizes_value.delete(smallest_possible_size);
|
|
1950
|
+
set_sizes_set(sizes_value);
|
|
1951
|
+
shadow_children_value.delete(invisible_size_button);
|
|
1952
|
+
set_shadow_children(shadow_children_value);
|
|
1953
|
+
});
|
|
1954
|
+
// The actual button that will be visible
|
|
1955
|
+
return $5vyXB$solidjsweb.createComponent(MakeButton, {});
|
|
1872
1956
|
}
|
|
1873
|
-
})
|
|
1957
|
+
});
|
|
1874
1958
|
}
|
|
1875
|
-
})
|
|
1959
|
+
})];
|
|
1876
1960
|
};
|
|
1961
|
+
/**
|
|
1962
|
+
* Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
|
|
1963
|
+
*/
|
|
1964
|
+
function $0ef1681699140f1a$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
|
|
1965
|
+
let current_row_index = 0;
|
|
1966
|
+
let current_row_items = [];
|
|
1967
|
+
const column_to_row_result = {};
|
|
1968
|
+
const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
|
|
1969
|
+
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)
|
|
1970
|
+
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
|
|
1971
|
+
};
|
|
1972
|
+
|
|
1973
|
+
for (const size_item of sizes) {
|
|
1974
|
+
const size = size_item();
|
|
1975
|
+
if (size == undefined) return; // Only do stuff if we know all the sizes
|
|
1976
|
+
const current_row_length = current_row_items.length;
|
|
1977
|
+
const can_add_another_column_initial_val = current_row_length < $0ef1681699140f1a$var$max_columns; // allow max 4 items per row
|
|
1978
|
+
let can_add_another_column = can_add_another_column_initial_val;
|
|
1979
|
+
if (can_add_another_column)
|
|
1980
|
+
// can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
|
|
1981
|
+
for (let i = -1; i < current_row_length; i++) {
|
|
1982
|
+
// -1 is for the new item we're adding and every item is guaranteed to exist
|
|
1983
|
+
const size_to_check = current_row_items[i] ?? size;
|
|
1984
|
+
const would_have_columns = current_row_length + 1; // if we added another column
|
|
1985
|
+
const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
|
|
1986
|
+
if (!would_fit_evenly) {
|
|
1987
|
+
can_add_another_column = false;
|
|
1988
|
+
break;
|
|
1989
|
+
}
|
|
1990
|
+
}
|
|
1991
|
+
if (can_add_another_column) current_row_items.push(size);else {
|
|
1992
|
+
column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
|
|
1993
|
+
current_row_items = [size]; // save current item for next row
|
|
1994
|
+
}
|
|
1995
|
+
}
|
|
1996
|
+
|
|
1997
|
+
const items_left_to_add = current_row_items.length;
|
|
1998
|
+
if (items_left_to_add) {
|
|
1999
|
+
let num_columns = 1; // We want to have as close to max_columns as possible in the last row
|
|
2000
|
+
let fits = true;
|
|
2001
|
+
do
|
|
2002
|
+
// Check if more columns would fit
|
|
2003
|
+
for (let i = 0; i < items_left_to_add; i++) {
|
|
2004
|
+
const item = current_row_items[i];
|
|
2005
|
+
const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
|
|
2006
|
+
if (!would_fit_evenly) {
|
|
2007
|
+
fits = false;
|
|
2008
|
+
break;
|
|
2009
|
+
}
|
|
2010
|
+
} while (fits && ++num_columns < $0ef1681699140f1a$var$max_columns);
|
|
2011
|
+
column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
|
|
2012
|
+
}
|
|
2013
|
+
|
|
2014
|
+
set_cols_at_size([[1, "0px", "", null, {
|
|
2015
|
+
overrides: column_to_row_result
|
|
2016
|
+
}]]);
|
|
2017
|
+
}
|
|
1877
2018
|
function $b54e6192d0caa293$export$d9f36cf74e24d595(media_query) {
|
|
1878
2019
|
const signal = $5vyXB$solidjs.createSignal(false);
|
|
1879
2020
|
$5vyXB$solidjs.onCleanup($5vyXB$depictaiutilishared.javascript_media_query(media_query, ({
|
|
@@ -1918,7 +2059,7 @@ function $b51a2b8b9355e66c$export$82ed4b28ecb67608({
|
|
|
1918
2059
|
const hex_color = $5vyXB$solidjs.createMemo(() => checkbox().value_.split(";")?.[1] || "");
|
|
1919
2060
|
const rgb_color = $5vyXB$solidjs.createMemo(() => $5vyXB$depictaiutilishared.hex_to_rgb(hex_color()));
|
|
1920
2061
|
const black_contrast_better = $5vyXB$solidjs.createMemo(() => rgb_color() ? $b51a2b8b9355e66c$var$does_black_contrast_better(rgb_color()) : false);
|
|
1921
|
-
const input_row = $5vyXB$solidjsweb.createComponent((0, $
|
|
2062
|
+
const input_row = $5vyXB$solidjsweb.createComponent((0, $1c63082b2da848ad$export$48513f6b9f8ce62d), {
|
|
1922
2063
|
get value_() {
|
|
1923
2064
|
return checkbox().value_;
|
|
1924
2065
|
},
|
package/server/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.
|