@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/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++) {
|
|
@@ -589,9 +589,18 @@ const $9ea5383493360761$var$_tmpl$ = ["<button", ' class="show-more major" type=
|
|
|
589
589
|
function $9ea5383493360761$export$9756467d34d91cdb(props) {
|
|
590
590
|
return $16b52438165aafe2$export$23fca46f3143581f(() => {
|
|
591
591
|
const rows_object_ = $i7OB2$createMemo(() => {
|
|
592
|
-
const
|
|
593
|
-
|
|
592
|
+
const {
|
|
593
|
+
view_more_button: view_more_button,
|
|
594
|
+
max_rows: max_rows
|
|
595
|
+
} = props;
|
|
596
|
+
if (!view_more_button) {
|
|
597
|
+
if (max_rows) return {
|
|
598
|
+
max_rows: max_rows
|
|
599
|
+
};
|
|
600
|
+
return "all";
|
|
601
|
+
}
|
|
594
602
|
return {
|
|
603
|
+
max_rows: max_rows,
|
|
595
604
|
start_rows: view_more_button.start_rows,
|
|
596
605
|
rows_per_click: view_more_button.rows_per_click ?? 2,
|
|
597
606
|
button: $i7OB2$ssr($9ea5383493360761$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(view_more_button.text))
|
|
@@ -997,9 +1006,9 @@ function $1adfe60f3a14a1d7$export$fecbb157621501bd({
|
|
|
997
1006
|
}));
|
|
998
1007
|
return outmost_element;
|
|
999
1008
|
}
|
|
1000
|
-
const $
|
|
1001
|
-
$
|
|
1002
|
-
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 => {
|
|
1003
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
|
|
1004
1013
|
const count = $i7OB2$createMemo(() => props.count_);
|
|
1005
1014
|
const label = $i7OB2$createMemo(() => props.label_);
|
|
@@ -1007,12 +1016,12 @@ const $87c712b5b33f24f7$export$48513f6b9f8ce62d = props => {
|
|
|
1007
1016
|
const value = $i7OB2$createMemo(() => props.value_);
|
|
1008
1017
|
const is_count_zero = $i7OB2$createMemo(() => props.is_count_zero_ || count() === 0);
|
|
1009
1018
|
const id = $i7OB2$make_random_classname();
|
|
1010
|
-
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), {
|
|
1011
1020
|
get when() {
|
|
1012
1021
|
return count() != undefined;
|
|
1013
1022
|
},
|
|
1014
1023
|
get children() {
|
|
1015
|
-
return $i7OB2$ssr($
|
|
1024
|
+
return $i7OB2$ssr($49b79728e7d9e2a1$var$_tmpl$, $i7OB2$ssrHydrationKey(), $i7OB2$escape(count()));
|
|
1016
1025
|
}
|
|
1017
1026
|
})))
|
|
1018
1027
|
);
|
|
@@ -1063,7 +1072,7 @@ function $a4601e6bea3ed1e6$export$dd948f91abc3a1c4({
|
|
|
1063
1072
|
});
|
|
1064
1073
|
const render_checkbox = checkbox => {
|
|
1065
1074
|
// Checkbox always calls the getters in props, so we don't wrap these values into memos
|
|
1066
|
-
return $i7OB2$createComponent((0, $
|
|
1075
|
+
return $i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
|
|
1067
1076
|
get value_() {
|
|
1068
1077
|
return checkbox().value_;
|
|
1069
1078
|
},
|
|
@@ -1537,7 +1546,7 @@ function $1c8cac76cb67e9af$var$render_stuff(data, existing_filter, i18n_) {
|
|
|
1537
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
|
|
1538
1547
|
const value = $i7OB2$createMemo(() => data()[key]); // still sometimes get undefined here even though we have <Show>
|
|
1539
1548
|
const has_expandable = $i7OB2$createMemo(() => !!Object.keys(value()?.children_ || {}).length);
|
|
1540
|
-
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), {
|
|
1541
1550
|
get value_() {
|
|
1542
1551
|
return JSON.stringify(value()?.value_);
|
|
1543
1552
|
},
|
|
@@ -1777,9 +1786,25 @@ function $1c8cac76cb67e9af$var$expand_until_choice(data_structure) {
|
|
|
1777
1786
|
}
|
|
1778
1787
|
});
|
|
1779
1788
|
}
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
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;
|
|
1783
1808
|
const $93716a9ad0dea854$export$414f6a19d38e655c = ({
|
|
1784
1809
|
filter_: filter_,
|
|
1785
1810
|
selected_filters_: [get_selected_filters, set_selected_filters]
|
|
@@ -1802,23 +1827,139 @@ const $93716a9ad0dea854$export$414f6a19d38e655c = ({
|
|
|
1802
1827
|
count_: meta.counts?.[index]
|
|
1803
1828
|
}));
|
|
1804
1829
|
});
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
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();
|
|
1808
1852
|
},
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
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();
|
|
1814
1864
|
},
|
|
1815
|
-
|
|
1816
|
-
|
|
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, {});
|
|
1817
1901
|
}
|
|
1818
|
-
})
|
|
1902
|
+
});
|
|
1819
1903
|
}
|
|
1820
|
-
})
|
|
1904
|
+
})];
|
|
1821
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
|
+
}
|
|
1822
1963
|
function $dc9262ef6f786812$export$d9f36cf74e24d595(media_query) {
|
|
1823
1964
|
const signal = $i7OB2$createSignal(false);
|
|
1824
1965
|
$i7OB2$onCleanup($i7OB2$javascript_media_query(media_query, ({
|
|
@@ -1863,7 +2004,7 @@ function $e731d52d97444b7c$export$82ed4b28ecb67608({
|
|
|
1863
2004
|
const hex_color = $i7OB2$createMemo(() => checkbox().value_.split(";")?.[1] || "");
|
|
1864
2005
|
const rgb_color = $i7OB2$createMemo(() => $i7OB2$hex_to_rgb(hex_color()));
|
|
1865
2006
|
const black_contrast_better = $i7OB2$createMemo(() => rgb_color() ? $e731d52d97444b7c$var$does_black_contrast_better(rgb_color()) : false);
|
|
1866
|
-
const input_row = $i7OB2$createComponent((0, $
|
|
2007
|
+
const input_row = $i7OB2$createComponent((0, $49b79728e7d9e2a1$export$48513f6b9f8ce62d), {
|
|
1867
2008
|
get value_() {
|
|
1868
2009
|
return checkbox().value_;
|
|
1869
2010
|
},
|