@depict-ai/ui 2.0.1 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ES10/index.cjs +207 -79
- package/ES10/index.d.ts +1 -1
- package/ES10/index.js +207 -79
- package/latest/index.cjs +201 -76
- package/latest/index.d.ts +1 -1
- package/latest/index.js +201 -76
- package/package.json +2 -2
- package/server/ES10/index.cjs +162 -27
- package/server/ES10/index.d.ts +1 -1
- package/server/ES10/index.js +162 -27
- package/server/latest/index.cjs +156 -24
- package/server/latest/index.d.ts +1 -1
- package/server/latest/index.js +156 -24
package/server/latest/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import { createMemo as $i7OB2$createMemo, createResource as $i7OB2$createResourc
|
|
|
5
5
|
/*! Depict.ai search and product listing SDK */
|
|
6
6
|
import { register_es_version } from "../../multi_import_deduplicator.mjs";
|
|
7
7
|
register_es_version("ui", "latest");
|
|
8
|
-
const $ec291e0010116877$export$83d89fbfd8236492 = "2.0.
|
|
8
|
+
const $ec291e0010116877$export$83d89fbfd8236492 = "2.0.2";
|
|
9
9
|
const $b5cccc8ee7d24677$var$transform_elements = sorted_cols_at_size => {
|
|
10
10
|
const cols_at_size = [];
|
|
11
11
|
for (let i = 0; i < sorted_cols_at_size.length; i++) {
|
|
@@ -1006,9 +1006,9 @@ function $1adfe60f3a14a1d7$export$fecbb157621501bd({
|
|
|
1006
1006
|
}));
|
|
1007
1007
|
return outmost_element;
|
|
1008
1008
|
}
|
|
1009
|
-
const $
|
|
1010
|
-
$
|
|
1011
|
-
const $
|
|
1009
|
+
const $49b79728e7d9e2a1$var$_tmpl$ = ["<span", ' class="count">', "</span>"],
|
|
1010
|
+
$49b79728e7d9e2a1$var$_tmpl$2 = ["<label", ' class="', '"', '><div class="left"><input type="checkbox"', "", "", '><span class="custom-indicator"></span><span class="text line-clamp">', "</span></div><!--#-->", "<!--/--></label>"];
|
|
1011
|
+
const $49b79728e7d9e2a1$export$48513f6b9f8ce62d = props => {
|
|
1012
1012
|
// 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
|
|
1013
1013
|
const count = $i7OB2$createMemo(() => props.count_);
|
|
1014
1014
|
const label = $i7OB2$createMemo(() => props.label_);
|
|
@@ -1016,12 +1016,12 @@ const $87c712b5b33f24f7$export$48513f6b9f8ce62d = props => {
|
|
|
1016
1016
|
const value = $i7OB2$createMemo(() => props.value_);
|
|
1017
1017
|
const is_count_zero = $i7OB2$createMemo(() => props.is_count_zero_ || count() === 0);
|
|
1018
1018
|
const id = $i7OB2$make_random_classname();
|
|
1019
|
-
return (/* We can't use actual margin because ExpandingContainer gets messed up */$i7OB2$ssr($
|
|
1019
|
+
return (/* We can't use actual margin because ExpandingContainer gets messed up */$i7OB2$ssr($49b79728e7d9e2a1$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `input-row ${is_count_zero() ? "count-0" : ""}`, $i7OB2$ssrAttribute("for", $i7OB2$escape(id, true), false), $i7OB2$ssrAttribute("name", $i7OB2$escape(value(), true), false) + $i7OB2$ssrAttribute("id", $i7OB2$escape(id, true), false), $i7OB2$ssrAttribute("checked", checked(), true), $i7OB2$ssrAttribute("disabled", !checked() && is_count_zero(), true), $i7OB2$escape(label()) || $i7OB2$escape(value()), $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
|
|
1020
1020
|
get when() {
|
|
1021
1021
|
return count() != undefined;
|
|
1022
1022
|
},
|
|
1023
1023
|
get children() {
|
|
1024
|
-
return $i7OB2$ssr($
|
|
1024
|
+
return $i7OB2$ssr($49b79728e7d9e2a1$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(count()));
|
|
1025
1025
|
}
|
|
1026
1026
|
})))
|
|
1027
1027
|
);
|
|
@@ -1072,7 +1072,7 @@ function $a4601e6bea3ed1e6$export$dd948f91abc3a1c4({
|
|
|
1072
1072
|
});
|
|
1073
1073
|
const render_checkbox = checkbox => {
|
|
1074
1074
|
// Checkbox always calls the getters in props, so we don't wrap these values into memos
|
|
1075
|
-
return $i7OB2$createComponent((0, $
|
|
1075
|
+
return $i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
|
|
1076
1076
|
get value_() {
|
|
1077
1077
|
return checkbox().value_;
|
|
1078
1078
|
},
|
|
@@ -1546,7 +1546,7 @@ function $1c8cac76cb67e9af$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
1546
1546
|
// 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
|
|
1547
1547
|
const value = $i7OB2$createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
|
|
1548
1548
|
const has_expandable = $i7OB2$createMemo(() => !!Object.keys(value()?.children_ || {}).length);
|
|
1549
|
-
return $i7OB2$ssr($1c8cac76cb67e9af$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `checkbox-details ${has_expandable() ? "expandable" : ""}`, $i7OB2$escape($i7OB2$createComponent((0, $
|
|
1549
|
+
return $i7OB2$ssr($1c8cac76cb67e9af$var$_tmpl$2, $i7OB2$ssrHydrationKey(), `checkbox-details ${has_expandable() ? "expandable" : ""}`, $i7OB2$escape($i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
|
|
1550
1550
|
get value_() {
|
|
1551
1551
|
return JSON.stringify(value()?.value_);
|
|
1552
1552
|
},
|
|
@@ -1786,9 +1786,25 @@ function $1c8cac76cb67e9af$var$expand_until_choice(data_structure) {
|
|
|
1786
1786
|
}
|
|
1787
1787
|
});
|
|
1788
1788
|
}
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1789
|
+
|
|
1790
|
+
/** @jsxImportSource solid-js */
|
|
1791
|
+
|
|
1792
|
+
function $0fdb37d8ddabef25$export$9f191182275e9ef(what_to_watch) {
|
|
1793
|
+
const [size, setSize] = $i7OB2$createSignal();
|
|
1794
|
+
const resizeObserver = new ResizeObserver($i7OB2$catchify(records => {
|
|
1795
|
+
for (let j = 0; j < records.length; j++) {
|
|
1796
|
+
const width = records[j].borderBoxSize?.[0]?.inlineSize ?? what_to_watch.getBoundingClientRect().width;
|
|
1797
|
+
setSize(width);
|
|
1798
|
+
}
|
|
1799
|
+
}));
|
|
1800
|
+
resizeObserver.observe(what_to_watch);
|
|
1801
|
+
$i7OB2$onCleanup(() => resizeObserver.disconnect());
|
|
1802
|
+
return size;
|
|
1803
|
+
}
|
|
1804
|
+
const $93716a9ad0dea854$var$_tmpl$ = ["<div", ' class="checkbox-grid" style="position:absolute;z-index:-1;pointer-events:none;opacity:0">', "</div>"],
|
|
1805
|
+
$93716a9ad0dea854$var$_tmpl$2 = ["<span", ' class="count-wrapper"><span class="count">', "</span></span>"];
|
|
1806
|
+
const $93716a9ad0dea854$var$gap_px = 5;
|
|
1807
|
+
const $93716a9ad0dea854$var$max_columns = 3;
|
|
1792
1808
|
const $93716a9ad0dea854$export$414f6a19d38e655c = ({
|
|
1793
1809
|
filter_: filter_,
|
|
1794
1810
|
selected_filters_: [get_selected_filters, set_selected_filters]
|
|
@@ -1811,23 +1827,139 @@ const $93716a9ad0dea854$export$414f6a19d38e655c = ({
|
|
|
1811
1827
|
count_: meta.counts?.[index]
|
|
1812
1828
|
}));
|
|
1813
1829
|
});
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1830
|
+
const [sizes_set, set_sizes_set] = $i7OB2$createSignal(new Set(), {
|
|
1831
|
+
equals: false
|
|
1832
|
+
});
|
|
1833
|
+
const [cols_at_size, set_cols_at_size] = $i7OB2$createSignal([[1, "0px", ""]]);
|
|
1834
|
+
const [container, set_container] = $i7OB2$createSignal();
|
|
1835
|
+
const container_width_accessor = $i7OB2$createMemo(() => {
|
|
1836
|
+
const element = container();
|
|
1837
|
+
if (!element) return;
|
|
1838
|
+
return $0fdb37d8ddabef25$export$9f191182275e9ef(element);
|
|
1839
|
+
});
|
|
1840
|
+
const [shadow_children, set_shadow_children] = $i7OB2$createSignal(new Set(), {
|
|
1841
|
+
equals: false
|
|
1842
|
+
});
|
|
1843
|
+
const shadow_grid = $i7OB2$ssr($93716a9ad0dea854$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape([...shadow_children()])); // for getting the smallest possible sizes of all the items
|
|
1844
|
+
$i7OB2$createEffect(() => {
|
|
1845
|
+
const container_width = container_width_accessor()?.();
|
|
1846
|
+
if (container_width == undefined) return;
|
|
1847
|
+
$93716a9ad0dea854$var$adjust_sizes(container_width, sizes_set(), set_cols_at_size);
|
|
1848
|
+
});
|
|
1849
|
+
return [shadow_grid, $i7OB2$createComponent((0, $c8d5ff4524619fcd$export$d21e32dfedac04be), {
|
|
1850
|
+
get cols_at_size() {
|
|
1851
|
+
return cols_at_size();
|
|
1817
1852
|
},
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1853
|
+
grid_spacing: $93716a9ad0dea854$var$gap_px + "px",
|
|
1854
|
+
rows: "all",
|
|
1855
|
+
layout: "grid",
|
|
1856
|
+
element_attributes: {
|
|
1857
|
+
class: "checkbox-grid",
|
|
1858
|
+
ref: el => set_container(el)
|
|
1859
|
+
},
|
|
1860
|
+
get children() {
|
|
1861
|
+
return $i7OB2$createComponent((0, $i7OB2$Index), {
|
|
1862
|
+
get each() {
|
|
1863
|
+
return buttons();
|
|
1823
1864
|
},
|
|
1824
|
-
|
|
1825
|
-
|
|
1865
|
+
children: value => {
|
|
1866
|
+
const is_selected = $i7OB2$createMemo(() => existing_filter()?.data?.includes(value().value_));
|
|
1867
|
+
const MakeButton = attributes => $i7OB2$ssrElement("button", () => ({
|
|
1868
|
+
...attributes,
|
|
1869
|
+
"disabled": value().count_ === 0 && !is_selected(),
|
|
1870
|
+
"classList": {
|
|
1871
|
+
minor: !is_selected(),
|
|
1872
|
+
major: is_selected(),
|
|
1873
|
+
"major-minor-transition": true
|
|
1874
|
+
}
|
|
1875
|
+
}), () => ["<!--#-->", $i7OB2$escape(value().value_), "<!--/-->", "<!--#-->", $i7OB2$escape($i7OB2$createComponent((0, $i7OB2$Show), {
|
|
1876
|
+
get when() {
|
|
1877
|
+
return value().count_ != undefined;
|
|
1878
|
+
},
|
|
1879
|
+
get children() {
|
|
1880
|
+
return $i7OB2$ssr($93716a9ad0dea854$var$_tmpl$2, $i7OB2$ssrHydrationKey(), $i7OB2$escape(value().count_));
|
|
1881
|
+
}
|
|
1882
|
+
})), "<!--/-->"], true);
|
|
1883
|
+
const invisible_size_button = $i7OB2$createComponent(MakeButton, {});
|
|
1884
|
+
const smallest_possible_size = $0fdb37d8ddabef25$export$9f191182275e9ef(invisible_size_button); // create ResizeObserver for the invisible size button where the div hugs its content
|
|
1885
|
+
const sizes_value = $i7OB2$untrack(sizes_set);
|
|
1886
|
+
const shadow_children_value = $i7OB2$untrack(shadow_children);
|
|
1887
|
+
sizes_value.add(smallest_possible_size);
|
|
1888
|
+
set_sizes_set(sizes_value);
|
|
1889
|
+
shadow_children_value.add(invisible_size_button);
|
|
1890
|
+
set_shadow_children(shadow_children_value);
|
|
1891
|
+
$i7OB2$onCleanup(() => {
|
|
1892
|
+
const sizes_value = $i7OB2$untrack(sizes_set);
|
|
1893
|
+
const shadow_children_value = $i7OB2$untrack(shadow_children);
|
|
1894
|
+
sizes_value.delete(smallest_possible_size);
|
|
1895
|
+
set_sizes_set(sizes_value);
|
|
1896
|
+
shadow_children_value.delete(invisible_size_button);
|
|
1897
|
+
set_shadow_children(shadow_children_value);
|
|
1898
|
+
});
|
|
1899
|
+
// The actual button that will be visible
|
|
1900
|
+
return $i7OB2$createComponent(MakeButton, {});
|
|
1826
1901
|
}
|
|
1827
|
-
})
|
|
1902
|
+
});
|
|
1828
1903
|
}
|
|
1829
|
-
})
|
|
1904
|
+
})];
|
|
1830
1905
|
};
|
|
1906
|
+
/**
|
|
1907
|
+
* Calculate and apply cols_at_size overrides to fit as many items as possible in a row, evenly spaced
|
|
1908
|
+
*/
|
|
1909
|
+
function $93716a9ad0dea854$var$adjust_sizes(container_width, sizes, set_cols_at_size) {
|
|
1910
|
+
let current_row_index = 0;
|
|
1911
|
+
let current_row_items = [];
|
|
1912
|
+
const column_to_row_result = {};
|
|
1913
|
+
const check_would_fit_evenly = (min_size_of_item, at_number_of_columnns) => {
|
|
1914
|
+
const would_have_even_size = container_width / at_number_of_columnns - (at_number_of_columnns * 2 - 2) * ($93716a9ad0dea854$var$gap_px / 2) / at_number_of_columnns; // What size would our element have (without gaps), given that now every column had the same width (equation from Layout.tsx)
|
|
1915
|
+
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
|
|
1916
|
+
};
|
|
1917
|
+
|
|
1918
|
+
for (const size_item of sizes) {
|
|
1919
|
+
const size = size_item();
|
|
1920
|
+
if (size == undefined) return; // Only do stuff if we know all the sizes
|
|
1921
|
+
const current_row_length = current_row_items.length;
|
|
1922
|
+
const can_add_another_column_initial_val = current_row_length < $93716a9ad0dea854$var$max_columns; // allow max 4 items per row
|
|
1923
|
+
let can_add_another_column = can_add_another_column_initial_val;
|
|
1924
|
+
if (can_add_another_column)
|
|
1925
|
+
// can we actually? Since adding another column changes the size of all elements in the row we need to check all of them
|
|
1926
|
+
for (let i = -1; i < current_row_length; i++) {
|
|
1927
|
+
// -1 is for the new item we're adding and every item is guaranteed to exist
|
|
1928
|
+
const size_to_check = current_row_items[i] ?? size;
|
|
1929
|
+
const would_have_columns = current_row_length + 1; // if we added another column
|
|
1930
|
+
const would_fit_evenly = check_would_fit_evenly(size_to_check, would_have_columns); // see comments in check_would_fit_evenly
|
|
1931
|
+
if (!would_fit_evenly) {
|
|
1932
|
+
can_add_another_column = false;
|
|
1933
|
+
break;
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
if (can_add_another_column) current_row_items.push(size);else {
|
|
1937
|
+
column_to_row_result[++current_row_index] = current_row_length || 1; // overrides is indexed by 1 it seems, therefore ++curent_row_index
|
|
1938
|
+
current_row_items = [size]; // save current item for next row
|
|
1939
|
+
}
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
const items_left_to_add = current_row_items.length;
|
|
1943
|
+
if (items_left_to_add) {
|
|
1944
|
+
let num_columns = 1; // We want to have as close to max_columns as possible in the last row
|
|
1945
|
+
let fits = true;
|
|
1946
|
+
do
|
|
1947
|
+
// Check if more columns would fit
|
|
1948
|
+
for (let i = 0; i < items_left_to_add; i++) {
|
|
1949
|
+
const item = current_row_items[i];
|
|
1950
|
+
const would_fit_evenly = check_would_fit_evenly(item, num_columns + 1);
|
|
1951
|
+
if (!would_fit_evenly) {
|
|
1952
|
+
fits = false;
|
|
1953
|
+
break;
|
|
1954
|
+
}
|
|
1955
|
+
} while (fits && ++num_columns < $93716a9ad0dea854$var$max_columns);
|
|
1956
|
+
column_to_row_result[++current_row_index] = num_columns; // Add last row that's left after loop finished
|
|
1957
|
+
}
|
|
1958
|
+
|
|
1959
|
+
set_cols_at_size([[1, "0px", "", null, {
|
|
1960
|
+
overrides: column_to_row_result
|
|
1961
|
+
}]]);
|
|
1962
|
+
}
|
|
1831
1963
|
function $dc9262ef6f786812$export$d9f36cf74e24d595(media_query) {
|
|
1832
1964
|
const signal = $i7OB2$createSignal(false);
|
|
1833
1965
|
$i7OB2$onCleanup($i7OB2$javascript_media_query(media_query, ({
|
|
@@ -1872,7 +2004,7 @@ function $e731d52d97444b7c$export$82ed4b28ecb67608({
|
|
|
1872
2004
|
const hex_color = $i7OB2$createMemo(() => checkbox().value_.split(";")?.[1] || "");
|
|
1873
2005
|
const rgb_color = $i7OB2$createMemo(() => $i7OB2$hex_to_rgb(hex_color()));
|
|
1874
2006
|
const black_contrast_better = $i7OB2$createMemo(() => rgb_color() ? $e731d52d97444b7c$var$does_black_contrast_better(rgb_color()) : false);
|
|
1875
|
-
const input_row = $i7OB2$createComponent((0, $
|
|
2007
|
+
const input_row = $i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
|
|
1876
2008
|
get value_() {
|
|
1877
2009
|
return checkbox().value_;
|
|
1878
2010
|
},
|