@depict-ai/ui 2.1.1 → 2.1.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 +26 -30
- package/ES10/index.d.ts +4 -4
- package/ES10/index.js +26 -30
- package/latest/index.cjs +26 -30
- package/latest/index.d.ts +4 -4
- package/latest/index.js +26 -30
- package/package.json +1 -1
- package/server/ES10/index.cjs +29 -31
- package/server/ES10/index.d.ts +4 -4
- package/server/ES10/index.js +29 -31
- package/server/latest/index.cjs +29 -31
- package/server/latest/index.d.ts +4 -4
- package/server/latest/index.js +29 -31
package/server/latest/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/ap
|
|
|
6
6
|
import { CategorySuggestion, SearchSuggestionsResponse } from "@depict-ai/types/api/SearchSuggestionsResponse";
|
|
7
7
|
import { BaseSearchRequest } from "@depict-ai/types/api/BaseSearchRequest";
|
|
8
8
|
import { SearchSuggestionsRequest } from "@depict-ai/types/api/SearchSuggestionsRequest";
|
|
9
|
-
import {
|
|
10
|
-
export const version = "2.1.
|
|
9
|
+
import { ProductListingRequestV2 } from "@depict-ai/types/api/ProductListingRequestV2";
|
|
10
|
+
export const version = "2.1.2";
|
|
11
11
|
/**
|
|
12
12
|
* Use `javascript_media_query` but return a reactive accessor instead of taking a callback function
|
|
13
13
|
*/
|
|
@@ -55,7 +55,7 @@ export function ImagePlaceholder(props: ImagePlaceholderBaseOptions & (ImagePlac
|
|
|
55
55
|
* The interface for a content block.
|
|
56
56
|
* Please make sure that you don't have content blocks overlap as that will cause undefined behavior.
|
|
57
57
|
* The height of the content block will be the height of the tallest item in a row, so if there are no products in a row the content block needs to "bring its own height".
|
|
58
|
-
* If you need to load any data in the content block, please make sure to return a placeholder while you're doing so, to avoid layout shifts and ensure scroll restoration works correctly.
|
|
58
|
+
* If you need to load any data in the content block, please make sure to return a placeholder while you're doing so (see `ImagePlaceholder`), to avoid layout shifts and ensure scroll restoration works correctly.
|
|
59
59
|
*
|
|
60
60
|
* - `span_columns`: How many columns the block should span. This will be capped to the number of columns available.
|
|
61
61
|
* - `span_rows`: How many rows the block should span.
|
|
@@ -670,7 +670,7 @@ export class DepictAPI<InputDisplay extends Display, OutputDisplay extends Moder
|
|
|
670
670
|
query(input_req: SearchRequest): Promise<SearchResponseAfterURLCreator & {
|
|
671
671
|
failed?: true;
|
|
672
672
|
}>;
|
|
673
|
-
list(input_req:
|
|
673
|
+
list(input_req: ProductListingRequestV2): Promise<ProductListingResponseAfterURLCreator & {
|
|
674
674
|
failed?: true;
|
|
675
675
|
}>;
|
|
676
676
|
get_recommended<T extends Display>(input_req: BaseSearchRequest): Promise<{
|
package/server/latest/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createStore as $i7OB2$createStore, reconcile as $i7OB2$reconcile } from
|
|
|
6
6
|
/*! Depict.ai search and product listing SDK */
|
|
7
7
|
import { register_es_version } from "../../multi_import_deduplicator.mjs";
|
|
8
8
|
register_es_version("ui", "latest");
|
|
9
|
-
const $ec291e0010116877$export$83d89fbfd8236492 = "2.1.
|
|
9
|
+
const $ec291e0010116877$export$83d89fbfd8236492 = "2.1.2";
|
|
10
10
|
const $4147651646da990a$var$fallback_operator = "in";
|
|
11
11
|
const $4147651646da990a$var$fallback_token = "";
|
|
12
12
|
const $4147651646da990a$var$legacy_filter_prefix = "filter_";
|
|
@@ -3691,8 +3691,7 @@ function $0449e7d49398c077$export$a1fd619a4743ca08({
|
|
|
3691
3691
|
query_base_: query_base_,
|
|
3692
3692
|
depict_api_: depict_api_,
|
|
3693
3693
|
is_loading_: is_loading_,
|
|
3694
|
-
content_blocks_: content_blocks_
|
|
3695
|
-
set_number_loaded_displays_: set_number_loaded_displays_
|
|
3694
|
+
content_blocks_: content_blocks_
|
|
3696
3695
|
}) {
|
|
3697
3696
|
// The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator and knowing when to load more
|
|
3698
3697
|
const target_to_index_map = new Map();
|
|
@@ -3736,7 +3735,6 @@ function $0449e7d49398c077$export$a1fd619a4743ca08({
|
|
|
3736
3735
|
query_base_: query_base_,
|
|
3737
3736
|
depict_api_: depict_api_
|
|
3738
3737
|
});
|
|
3739
|
-
$i7OB2$createComputed(() => set_number_loaded_displays_(displays_by_key_().size));
|
|
3740
3738
|
return $29ec7cddbe1d3484$export$43f0fb951fcb0c54({
|
|
3741
3739
|
displays_by_key_: displays_by_key_,
|
|
3742
3740
|
merchant_: merchant_,
|
|
@@ -3919,26 +3917,18 @@ const $e7a7eb102ddc0c79$var$_tmpl$ = ["<div", ' class="content-block-wrapper" st
|
|
|
3919
3917
|
function $e7a7eb102ddc0c79$export$791ef57e62e21c3f({
|
|
3920
3918
|
content_blocks_: incoming_content_blocks,
|
|
3921
3919
|
cols_at_size_: cols_at_size_,
|
|
3922
|
-
number_of_items_shown_: number_of_items_shown_,
|
|
3923
3920
|
set_top_row_shortened_by_: set_top_row_shortened_by_
|
|
3924
3921
|
}) {
|
|
3925
3922
|
// these are by row
|
|
3926
3923
|
const [content_blocks, set_content_blocks] = $i7OB2$createStore([]);
|
|
3927
3924
|
const n_cols_currently_showing_ = $bed740eef1769419$export$a79e666719b3647c(cols_at_size_);
|
|
3928
|
-
const products_to_rows = products => {
|
|
3929
|
-
const cols_currently_showing = n_cols_currently_showing_();
|
|
3930
|
-
if (cols_currently_showing === null) return 0;
|
|
3931
|
-
return Math.ceil(products / cols_currently_showing);
|
|
3932
|
-
};
|
|
3933
|
-
const showing_rows = $i7OB2$createMemo(() => products_to_rows(number_of_items_shown_()));
|
|
3934
3925
|
$i7OB2$createEffect(() => {
|
|
3935
3926
|
const incoming_value = incoming_content_blocks();
|
|
3936
3927
|
if (!incoming_value) {
|
|
3937
3928
|
set_content_blocks([]);
|
|
3938
3929
|
return;
|
|
3939
3930
|
}
|
|
3940
|
-
|
|
3941
|
-
set_content_blocks($i7OB2$reconcile(capped_value, {
|
|
3931
|
+
set_content_blocks($i7OB2$reconcile(incoming_value, {
|
|
3942
3932
|
key: "content"
|
|
3943
3933
|
})); // key: Make moving blocks faster, see https://github.com/solidjs/solid/issues/1925#issuecomment-1769671596
|
|
3944
3934
|
});
|
|
@@ -3995,12 +3985,12 @@ function $e7a7eb102ddc0c79$var$remap_blocks_to_index({
|
|
|
3995
3985
|
for (let j = 0; j < i; j++) {
|
|
3996
3986
|
const row = displaced_products[j];
|
|
3997
3987
|
if (row === undefined) continue; // there were no blocks in this row
|
|
3998
|
-
let
|
|
3999
|
-
if (typeof row === "number")
|
|
4000
|
-
|
|
4001
|
-
displaced_products[j] =
|
|
3988
|
+
let displaced_items_in_row;
|
|
3989
|
+
if (typeof row === "number") displaced_items_in_row = row;else {
|
|
3990
|
+
displaced_items_in_row = row.filter(item => item).length;
|
|
3991
|
+
displaced_products[j] = displaced_items_in_row;
|
|
4002
3992
|
}
|
|
4003
|
-
displacement_by_added_blocks +=
|
|
3993
|
+
displacement_by_added_blocks += displaced_items_in_row;
|
|
4004
3994
|
}
|
|
4005
3995
|
const index_of_us_in_row = target_index - index_of_first_item_in_row;
|
|
4006
3996
|
for (let j = 0; j < index_of_us_in_row; j++) if (displaced_products[i]?.[j])
|
|
@@ -4038,13 +4028,27 @@ function $e7a7eb102ddc0c79$var$wrap_blocks_in_div(rendered_content_blocks, max_s
|
|
|
4038
4028
|
const get_wrapped_blocks = $i7OB2$mapArray(() => rendered_content_blocks, block => {
|
|
4039
4029
|
if (!block) return;
|
|
4040
4030
|
const get_span_columns = () => Math.min(block.span_columns, max_span_columns() ?? Infinity);
|
|
4031
|
+
const [rendering_delayed, set_rendering_delayed_] = $i7OB2$createSignal(true);
|
|
4032
|
+
const content = $i7OB2$createComponent((0, $i7OB2$Show), {
|
|
4033
|
+
get when() {
|
|
4034
|
+
return !rendering_delayed();
|
|
4035
|
+
},
|
|
4036
|
+
get children() {
|
|
4037
|
+
return $i7OB2$ssr($e7a7eb102ddc0c79$var$_tmpl$, $i7OB2$ssrHydrationKey(), "grid-column:" + `span ${$i7OB2$escape(get_span_columns(), true)}` + (";grid-row:" + `span ${$i7OB2$escape(block.span_rows, true)}`) + (";spans_columns_variable_name:" + $i7OB2$escape(get_span_columns(), true)), $i7OB2$escape($i7OB2$createComponent($e7a7eb102ddc0c79$var$RenderContent, {
|
|
4038
|
+
get content() {
|
|
4039
|
+
return block.content;
|
|
4040
|
+
}
|
|
4041
|
+
})));
|
|
4042
|
+
}
|
|
4043
|
+
});
|
|
4041
4044
|
return $i7OB2$mergeProps1(block, {
|
|
4042
4045
|
// Create content divs for the blocks with as much fine-grained diffing as possible?
|
|
4043
|
-
content:
|
|
4044
|
-
|
|
4045
|
-
|
|
4046
|
-
|
|
4047
|
-
|
|
4046
|
+
content: () => {
|
|
4047
|
+
// Sneaky on-demand rendering, so we don't render more blocks than we can show: we have the rendered value here and don't return a function that renders because if our block would be moved around we'd be guaranteed to re-render
|
|
4048
|
+
// However, no need to count products to know if we should render: the <For> loops in Placeholders and render_displays will only call this function if there's actually a product here that wants to display this block
|
|
4049
|
+
set_rendering_delayed_(false);
|
|
4050
|
+
return content;
|
|
4051
|
+
},
|
|
4048
4052
|
get span_columns() {
|
|
4049
4053
|
// Cap max width of block to the number of columns available, for everyone downstream
|
|
4050
4054
|
return get_span_columns();
|
|
@@ -4132,8 +4136,7 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
|
|
|
4132
4136
|
let fallback_is_alive = false;
|
|
4133
4137
|
const [get_should_have_placeholders_rendered, set_should_have_placeholders_rendered] = $i7OB2$createSignal(true);
|
|
4134
4138
|
const [top_row_shortened_by_, set_top_row_shortened_by_] = $i7OB2$createSignal(0);
|
|
4135
|
-
|
|
4136
|
-
const [number_loaded_displays, set_number_loaded_displays_] = $i7OB2$createSignal(0);
|
|
4139
|
+
$i7OB2$createSignal(false);
|
|
4137
4140
|
const modified_cols_at_size = $15aa76e6da02e5c2$export$cb5808ba002cdeed({
|
|
4138
4141
|
layout_options_: layout_options_,
|
|
4139
4142
|
sort_or_filter_open_: sort_or_filter_open_
|
|
@@ -4144,12 +4147,10 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
|
|
|
4144
4147
|
for_id: for_id
|
|
4145
4148
|
}) => for_id === id_currently_querying_for_())?.min_results_loaded ?? min_products_to_fetch_);
|
|
4146
4149
|
});
|
|
4147
|
-
const number_of_items_shown_ = $i7OB2$createMemo(() => is_loading_() || product_card_suspense_is_in_fallback() ? num_placeholders_() : number_loaded_displays());
|
|
4148
4150
|
const doesnt_have_content_blocks = $i7OB2$createMemo(() => !content_blocks_by_row_());
|
|
4149
4151
|
const content_blocks_ = $i7OB2$createMemo(() => doesnt_have_content_blocks() ? () => [] : $e7a7eb102ddc0c79$export$791ef57e62e21c3f({
|
|
4150
4152
|
content_blocks_: content_blocks_by_row_,
|
|
4151
4153
|
cols_at_size_: modified_cols_at_size,
|
|
4152
|
-
number_of_items_shown_: number_of_items_shown_,
|
|
4153
4154
|
set_top_row_shortened_by_: set_top_row_shortened_by_
|
|
4154
4155
|
}));
|
|
4155
4156
|
const rendered_placeholders = $i7OB2$createMemo(() => get_should_have_placeholders_rendered() ? $6e41f1fde994db72$export$f33414a4df0afd3f({
|
|
@@ -4189,8 +4190,6 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
|
|
|
4189
4190
|
get fallback() {
|
|
4190
4191
|
fallback_is_alive = true;
|
|
4191
4192
|
$i7OB2$onCleanup(block_suspense_if_needed); // Block suspense after initial run every time after we fetch
|
|
4192
|
-
set_product_card_suspense_is_in_fallback(true); // Here for the content block code that needs to know how many items we're displaying
|
|
4193
|
-
$i7OB2$onCleanup(() => set_product_card_suspense_is_in_fallback(false));
|
|
4194
4193
|
return $i7OB2$createMemo(() => {
|
|
4195
4194
|
// We need to be able to block the suspense since when async product cards are *rendering* we want to show the placeholders on initial load but not when loading more
|
|
4196
4195
|
// In future we could have individual suspense's for each product card, but that's too much for now
|
|
@@ -4215,8 +4214,7 @@ function $2d25e42846eac370$export$3925f87b1545cfc6({
|
|
|
4215
4214
|
query_base_: query_base_,
|
|
4216
4215
|
depict_api_: depict_api_,
|
|
4217
4216
|
is_loading_: is_loading_,
|
|
4218
|
-
content_blocks_: content_blocks_
|
|
4219
|
-
set_number_loaded_displays_: set_number_loaded_displays_
|
|
4217
|
+
content_blocks_: content_blocks_
|
|
4220
4218
|
});
|
|
4221
4219
|
$i7OB2$onCleanup(() => suspense_contents = undefined);
|
|
4222
4220
|
return suspense_contents;
|