@depict-ai/ui 4.7.14 → 4.7.16
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 +310 -242
- package/ES10/index.d.ts +27 -23
- package/ES10/index.js +312 -245
- package/latest/index.cjs +293 -226
- package/latest/index.d.ts +27 -23
- package/latest/index.js +295 -229
- package/package.json +1 -1
- package/server/ES10/index.cjs +310 -242
- package/server/ES10/index.d.ts +27 -23
- package/server/ES10/index.js +312 -245
- package/server/latest/index.cjs +293 -226
- package/server/latest/index.d.ts +27 -23
- package/server/latest/index.js +295 -229
package/latest/index.cjs
CHANGED
|
@@ -12,6 +12,7 @@ function $parcel$export(e, n, v, s) {
|
|
|
12
12
|
configurable: true
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
|
+
$parcel$export(module.exports, "useProductCardIsVisible", () => $67155e1aeb7073f6$export$80bb7300ce6a8be3);
|
|
15
16
|
$parcel$export(module.exports, "useExpandingContainerReactive", () => $4b455f60dadde8b8$export$5bad61ecde080b1f);
|
|
16
17
|
$parcel$export(module.exports, "LooksSliderOrGrid", () => $a3bbfa5fdaa39f3a$export$2c9f9bf2092486aa);
|
|
17
18
|
$parcel$export(module.exports, "LookCard", () => $ad882bbe664dbd53$export$44809a8a3e867e30);
|
|
@@ -98,71 +99,18 @@ $parcel$export(module.exports, "BreadCrumbs", () => $1f4925833f07df29$export$5b7
|
|
|
98
99
|
$parcel$export(module.exports, "QuickLinks", () => $1f4925833f07df29$export$de035477d6fef996);
|
|
99
100
|
$parcel$export(module.exports, "CategoryPage", () => $14f289047713d67a$export$e2bf8ce7779e827e);
|
|
100
101
|
/*! Depict.ai search and product listing SDK */
|
|
101
|
-
const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
expand: expand,
|
|
111
|
-
ExpandingContainer: ({
|
|
112
|
-
children: children
|
|
113
|
-
}) => {
|
|
114
|
-
// get reactive signals/solid's jsx elements into `ExpandingContainer`
|
|
115
|
-
const fake_div = document.createElement("div");
|
|
116
|
-
const outer_expanding = $gVhhF$solidjsweb.createComponent(ExpandingContainer, {
|
|
117
|
-
children: [fake_div]
|
|
118
|
-
});
|
|
119
|
-
const parent = fake_div.parentElement;
|
|
120
|
-
fake_div.remove();
|
|
121
|
-
$gVhhF$solidjsweb.insert(parent, children);
|
|
122
|
-
return outer_expanding;
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
|
|
127
|
-
const cols_at_size = [];
|
|
128
|
-
for (let i = 0; i < sorted_cols_at_size.length; i++) {
|
|
129
|
-
const [nb_cols, width] = sorted_cols_at_size[i];
|
|
130
|
-
const next_width = sorted_cols_at_size[i + 1]?.[1];
|
|
131
|
-
const max_width = i === 0 ? "" : `${width}px`;
|
|
132
|
-
const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
|
|
133
|
-
const col_at_size = [nb_cols, min_width, max_width];
|
|
134
|
-
cols_at_size.push(col_at_size);
|
|
135
|
-
}
|
|
136
|
-
return cols_at_size;
|
|
137
|
-
};
|
|
138
|
-
const $4e04be41243c3d80$export$6daf8749b65a1b77 = cols_at_size => {
|
|
139
|
-
// Check that every element is an array
|
|
140
|
-
const are_arrays = cols_at_size?.every?.(element => Array.isArray(element));
|
|
141
|
-
if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
|
|
142
|
-
// Check width duplicates
|
|
143
|
-
const widths = cols_at_size.map(([_, width]) => width);
|
|
144
|
-
const widths_set = new Set(widths);
|
|
145
|
-
if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
|
|
146
|
-
if (cols_at_size.length === 1) {
|
|
147
|
-
const [nb_cols, width] = cols_at_size[0];
|
|
148
|
-
const max_width = width !== undefined ? `${width}px` : "";
|
|
149
|
-
return [[nb_cols, "", max_width]];
|
|
102
|
+
const $b757f75811f3261f$export$83d89fbfd8236492 = "4.7.16";
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Gets product_id (the thing we key the rendering on) from a display
|
|
106
|
+
*/
|
|
107
|
+
function $a5871dacf261adf8$export$548d053aba053d79(display) {
|
|
108
|
+
if ("variant_index" in display) {
|
|
109
|
+
const actual_display = display.variant_displays[display.variant_index];
|
|
110
|
+
return actual_display.product_id;
|
|
150
111
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
const [_b, width_A] = a;
|
|
154
|
-
const [_a, width_b] = b;
|
|
155
|
-
if (width_A === undefined) return -1;
|
|
156
|
-
if (width_b === undefined) return 1;
|
|
157
|
-
return width_b - width_A;
|
|
158
|
-
});
|
|
159
|
-
return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
|
|
160
|
-
};
|
|
161
|
-
function $fc23d7668ae0011d$export$a2cc176055f8f08(what = "grid") {
|
|
162
|
-
const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
|
|
163
|
-
return (0, $gVhhF$solidjsweb.isServer) ? {
|
|
164
|
-
t: `<!-- ${text} -->`
|
|
165
|
-
} : document.createComment(text);
|
|
112
|
+
if ("listing_id" in display) return display.listing_id;
|
|
113
|
+
return display.product_id;
|
|
166
114
|
}
|
|
167
115
|
function $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(elements) {
|
|
168
116
|
// FYI this probably doesn't work on hugely deep nestings or large amount of elements
|
|
@@ -176,112 +124,6 @@ function $5f7d55c710fd1bc2$var$unwrapping_helper(elements) {
|
|
|
176
124
|
} else if (typeof elements == "function") result.push(...$5f7d55c710fd1bc2$var$unwrapping_helper(elements()));else if (elements != undefined && typeof elements != "boolean") result.push(elements);
|
|
177
125
|
return result;
|
|
178
126
|
}
|
|
179
|
-
let $0caf87eaa19079da$var$cached_placeholder_element;
|
|
180
|
-
let $0caf87eaa19079da$var$rendering_cached_placeholder_element;
|
|
181
|
-
function $0caf87eaa19079da$export$f33414a4df0afd3f({
|
|
182
|
-
product_card_template_: product_card_template_,
|
|
183
|
-
num_placeholders_: num_placeholders_,
|
|
184
|
-
content_blocks_: content_blocks_
|
|
185
|
-
}) {
|
|
186
|
-
const [num_to_actually_show, set_num_to_actually_show] = $gVhhF$solidjs.createSignal($gVhhF$solidjs.untrack(num_placeholders_));
|
|
187
|
-
if (0, $gVhhF$solidjsweb.isServer)
|
|
188
|
-
// want to render simple placeholders on server, effects don't run there
|
|
189
|
-
// FIXME when adding proper SSR: also SSR content blocks
|
|
190
|
-
return $gVhhF$solidjs.createMemo(() => Array.from({
|
|
191
|
-
length: num_placeholders_()
|
|
192
|
-
}).map(() => {
|
|
193
|
-
const template_result = product_card_template_(null, undefined);
|
|
194
|
-
// @ts-ignore
|
|
195
|
-
if (typeof template_result?.then !== "function") return template_result;
|
|
196
|
-
}));
|
|
197
|
-
$gVhhF$solidjs.createRenderEffect(() => {
|
|
198
|
-
const existing_num = num_to_actually_show();
|
|
199
|
-
const to_add = num_placeholders_() - existing_num;
|
|
200
|
-
if (to_add <= 0) return;
|
|
201
|
-
// Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
|
|
202
|
-
// We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
|
|
203
|
-
// The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
|
|
204
|
-
// Above comments were from when we added elements in this createRenderEffect. Now I changed it to just increment the number and render them from an <Index> instead, so I can add content blocks better
|
|
205
|
-
// Functionality should be the same
|
|
206
|
-
set_num_to_actually_show(existing_num + to_add);
|
|
207
|
-
});
|
|
208
|
-
return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
|
|
209
|
-
get each() {
|
|
210
|
-
return Array.from({
|
|
211
|
-
length: num_to_actually_show()
|
|
212
|
-
});
|
|
213
|
-
},
|
|
214
|
-
children: (_item, index) => {
|
|
215
|
-
const possible_content_block = $gVhhF$solidjs.createMemo(() => content_blocks_?.()?.()?.[index]);
|
|
216
|
-
// Show content block before product card, so it's *at* that index
|
|
217
|
-
return [possible_content_block, $0caf87eaa19079da$var$Placeholder({
|
|
218
|
-
product_card_template_: product_card_template_
|
|
219
|
-
})]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
|
|
220
|
-
}
|
|
221
|
-
});
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
|
|
225
|
-
*/
|
|
226
|
-
function $0caf87eaa19079da$var$Placeholder({
|
|
227
|
-
product_card_template_: product_card_template_
|
|
228
|
-
}) {
|
|
229
|
-
const get_cloned_placeholders = (element_to_clone = $0caf87eaa19079da$var$cached_placeholder_element) => Array.isArray(element_to_clone) ? element_to_clone.map(el => el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
|
|
230
|
-
if ($0caf87eaa19079da$var$cached_placeholder_element) return get_cloned_placeholders();
|
|
231
|
-
let dispose_original_copy;
|
|
232
|
-
const get_unwrapped_element = $gVhhF$solidjs.createRoot(dispose => {
|
|
233
|
-
dispose_original_copy = dispose;
|
|
234
|
-
// if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
|
|
235
|
-
const [resource] = $gVhhF$solidjs.createResource(() => {
|
|
236
|
-
if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) return $0caf87eaa19079da$var$rendering_cached_placeholder_element;
|
|
237
|
-
const return_value = product_card_template_(null, undefined);
|
|
238
|
-
if (typeof return_value === "object" && typeof return_value?.then === "function")
|
|
239
|
-
// Is Promise or promise-like object
|
|
240
|
-
$0caf87eaa19079da$var$rendering_cached_placeholder_element = return_value;
|
|
241
|
-
return return_value;
|
|
242
|
-
});
|
|
243
|
-
return $gVhhF$solidjs.createMemo(() => {
|
|
244
|
-
if (resource.loading) return () => [];
|
|
245
|
-
return $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(resource);
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
$gVhhF$solidjs.onCleanup(() => {
|
|
249
|
-
if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) {
|
|
250
|
-
// If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
|
|
251
|
-
const unset_current_rendering = () => {
|
|
252
|
-
dispose_original_copy();
|
|
253
|
-
$0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
|
|
254
|
-
};
|
|
255
|
-
$0caf87eaa19079da$var$rendering_cached_placeholder_element?.then(unset_current_rendering, unset_current_rendering);
|
|
256
|
-
} else
|
|
257
|
-
// Otherwise, just make sure we've disposed our root
|
|
258
|
-
dispose_original_copy();
|
|
259
|
-
});
|
|
260
|
-
return $gVhhF$solidjs.createMemo(() => {
|
|
261
|
-
const unwrapped_array = get_unwrapped_element()();
|
|
262
|
-
if (!unwrapped_array?.length || !unwrapped_array.every(item => item))
|
|
263
|
-
// Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
|
|
264
|
-
return;
|
|
265
|
-
// placeholders have finished rendering, freeze the elements
|
|
266
|
-
// here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
|
|
267
|
-
$0caf87eaa19079da$var$cached_placeholder_element ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
|
|
268
|
-
$0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
|
|
269
|
-
dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
|
|
270
|
-
return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
/**
|
|
275
|
-
* Gets product_id (the thing we key the rendering on) from a display
|
|
276
|
-
*/
|
|
277
|
-
function $a5871dacf261adf8$export$548d053aba053d79(display) {
|
|
278
|
-
if ("variant_index" in display) {
|
|
279
|
-
const actual_display = display.variant_displays[display.variant_index];
|
|
280
|
-
return actual_display.product_id;
|
|
281
|
-
}
|
|
282
|
-
if ("listing_id" in display) return display.listing_id;
|
|
283
|
-
return display.product_id;
|
|
284
|
-
}
|
|
285
127
|
const $129b9b9c010039d0$var$ProductCardIndexContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
|
|
286
128
|
function $129b9b9c010039d0$export$11354f017ddc9790(props) {
|
|
287
129
|
return $gVhhF$solidjsweb.createComponent($129b9b9c010039d0$var$ProductCardIndexContext.Provider, {
|
|
@@ -495,6 +337,249 @@ function $a73063cc642f3e5f$var$deep_equal(obj1, obj2) {
|
|
|
495
337
|
}
|
|
496
338
|
return true;
|
|
497
339
|
}
|
|
340
|
+
const $67155e1aeb7073f6$var$CurrentlyIntersectingContext = /*@__PURE__*/$gVhhF$solidjs.createContext();
|
|
341
|
+
function $67155e1aeb7073f6$export$4a14175d33d81a96({
|
|
342
|
+
displays_by_key_: displays_by_key_,
|
|
343
|
+
product_card_template_: product_card_template_,
|
|
344
|
+
content_blocks_: content_blocks_,
|
|
345
|
+
alwaysObserveCards_: alwaysObserveCards_
|
|
346
|
+
}) {
|
|
347
|
+
// The following sets up an intersection observer to determine which results are in the viewport, used for the ScrollStatus indicator, knowing when to load more and any other consumer of the useProductCardIsVisible hook.
|
|
348
|
+
const targetToIndexMap_ = new Map();
|
|
349
|
+
const indexToTargetMap_ = new Map();
|
|
350
|
+
const [listenersForIntersecting, setListenersForIntersecting] = $gVhhF$solidjs.createSignal(0);
|
|
351
|
+
const [currentlyIntersecting, setCurrentlyIntersecting] = $gVhhF$solidjs.createSignal(new Set(), {
|
|
352
|
+
equals: false
|
|
353
|
+
});
|
|
354
|
+
const shouldObserve = $gVhhF$solidjs.createMemo(() => alwaysObserveCards_ || listenersForIntersecting() > 0);
|
|
355
|
+
const intersection_observer = new IntersectionObserver($gVhhF$depictaiutilishared.catchify(records => {
|
|
356
|
+
const intersectingValue = currentlyIntersecting();
|
|
357
|
+
for (let i = 0; i < records.length; i++) {
|
|
358
|
+
const record = records[i];
|
|
359
|
+
const {
|
|
360
|
+
target: target,
|
|
361
|
+
intersectionRatio: intersectionRatio
|
|
362
|
+
} = record;
|
|
363
|
+
const index_of_target = targetToIndexMap_.get(target);
|
|
364
|
+
if (index_of_target == undefined) return; // It seems like it can happen that we get IntersectionObserverEntries after the onCleanup function for a recommendation card has run, in Firefox. Probably a bug in Firefox? If I understood the bug correctly, this is a workaround.
|
|
365
|
+
const is_in_set = intersectingValue.has(index_of_target);
|
|
366
|
+
if (intersectionRatio > 0) {
|
|
367
|
+
if (!is_in_set) intersectingValue.add(index_of_target);
|
|
368
|
+
} else if (is_in_set) intersectingValue.delete(index_of_target);
|
|
369
|
+
}
|
|
370
|
+
setCurrentlyIntersecting(intersectingValue);
|
|
371
|
+
}, "renderDisplays IO failed"));
|
|
372
|
+
const renderedDisplays_ = $gVhhF$solidjsweb.createComponent($67155e1aeb7073f6$var$CurrentlyIntersectingContext.Provider, {
|
|
373
|
+
value: {
|
|
374
|
+
currentlyIntersecting_: currentlyIntersecting,
|
|
375
|
+
setIsListening_: setListenersForIntersecting
|
|
376
|
+
},
|
|
377
|
+
get children() {
|
|
378
|
+
return $a73063cc642f3e5f$export$43f0fb951fcb0c54({
|
|
379
|
+
displays_by_key_: displays_by_key_,
|
|
380
|
+
product_card_template_: product_card_template_,
|
|
381
|
+
content_blocks_: content_blocks_,
|
|
382
|
+
do_per_elements_: (elements, index_accessor) =>
|
|
383
|
+
// Adds/removes elements from the "results in viewport" intersection observer above
|
|
384
|
+
$gVhhF$solidjs.createEffect(() => {
|
|
385
|
+
if (!shouldObserve()) return;
|
|
386
|
+
const display_index = index_accessor();
|
|
387
|
+
// Nested createEffect because we only want to re-run this when the index changes (or we should/shouldn't observe)
|
|
388
|
+
// We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
|
|
389
|
+
for (let i = 0; i < elements.length; i++) {
|
|
390
|
+
const element = elements[i];
|
|
391
|
+
targetToIndexMap_.set(element, display_index);
|
|
392
|
+
intersection_observer.observe(element);
|
|
393
|
+
$gVhhF$solidjs.onCleanup(() => {
|
|
394
|
+
intersection_observer.unobserve(element);
|
|
395
|
+
targetToIndexMap_.delete(element);
|
|
396
|
+
const intersecting = $gVhhF$solidjs.untrack(currentlyIntersecting);
|
|
397
|
+
const wasDeleted = intersecting.delete(display_index);
|
|
398
|
+
if (wasDeleted) setCurrentlyIntersecting(intersecting);
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
indexToTargetMap_.set(display_index, elements);
|
|
402
|
+
$gVhhF$solidjs.onCleanup(() => indexToTargetMap_.delete(display_index));
|
|
403
|
+
})
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
return {
|
|
408
|
+
renderedDisplays_: renderedDisplays_,
|
|
409
|
+
indexToTargetMap_: indexToTargetMap_,
|
|
410
|
+
currentlyIntersecting: currentlyIntersecting
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
function $67155e1aeb7073f6$export$80bb7300ce6a8be3() {
|
|
414
|
+
const {
|
|
415
|
+
setIsListening_: setIsListening_,
|
|
416
|
+
currentlyIntersecting_: currentlyIntersecting_
|
|
417
|
+
} = $gVhhF$solidjs.useContext($67155e1aeb7073f6$var$CurrentlyIntersectingContext) || {};
|
|
418
|
+
const getOurIndex = $129b9b9c010039d0$export$e3faf4d95300054f();
|
|
419
|
+
const isVisible = $gVhhF$solidjs.createMemo(() => currentlyIntersecting_?.().has(getOurIndex?.()));
|
|
420
|
+
setIsListening_?.(prev => prev + 1);
|
|
421
|
+
$gVhhF$solidjs.onCleanup(() => setIsListening_?.(prev => prev + 1));
|
|
422
|
+
return isVisible;
|
|
423
|
+
}
|
|
424
|
+
function $4b455f60dadde8b8$export$5bad61ecde080b1f(...params) {
|
|
425
|
+
const {
|
|
426
|
+
collapse: collapse,
|
|
427
|
+
expand: expand,
|
|
428
|
+
ExpandingContainer: ExpandingContainer
|
|
429
|
+
} = $gVhhF$depictaiutilishared.useExpandingContainer(...params);
|
|
430
|
+
return {
|
|
431
|
+
collapse: collapse,
|
|
432
|
+
expand: expand,
|
|
433
|
+
ExpandingContainer: ({
|
|
434
|
+
children: children
|
|
435
|
+
}) => {
|
|
436
|
+
// get reactive signals/solid's jsx elements into `ExpandingContainer`
|
|
437
|
+
const fake_div = document.createElement("div");
|
|
438
|
+
const outer_expanding = $gVhhF$solidjsweb.createComponent(ExpandingContainer, {
|
|
439
|
+
children: [fake_div]
|
|
440
|
+
});
|
|
441
|
+
const parent = fake_div.parentElement;
|
|
442
|
+
fake_div.remove();
|
|
443
|
+
$gVhhF$solidjsweb.insert(parent, children);
|
|
444
|
+
return outer_expanding;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
const $4e04be41243c3d80$var$transform_elements = sorted_cols_at_size => {
|
|
449
|
+
const cols_at_size = [];
|
|
450
|
+
for (let i = 0; i < sorted_cols_at_size.length; i++) {
|
|
451
|
+
const [nb_cols, width] = sorted_cols_at_size[i];
|
|
452
|
+
const next_width = sorted_cols_at_size[i + 1]?.[1];
|
|
453
|
+
const max_width = i === 0 ? "" : `${width}px`;
|
|
454
|
+
const min_width = next_width !== undefined ? `${next_width + 1}px` : "";
|
|
455
|
+
const col_at_size = [nb_cols, min_width, max_width];
|
|
456
|
+
cols_at_size.push(col_at_size);
|
|
457
|
+
}
|
|
458
|
+
return cols_at_size;
|
|
459
|
+
};
|
|
460
|
+
const $4e04be41243c3d80$export$6daf8749b65a1b77 = cols_at_size => {
|
|
461
|
+
// Check that every element is an array
|
|
462
|
+
const are_arrays = cols_at_size?.every?.(element => Array.isArray(element));
|
|
463
|
+
if (!are_arrays) throw new Error("Every element in cols_at_size must be an array");
|
|
464
|
+
// Check width duplicates
|
|
465
|
+
const widths = cols_at_size.map(([_, width]) => width);
|
|
466
|
+
const widths_set = new Set(widths);
|
|
467
|
+
if (widths_set.size < widths.length) throw new Error("There are duplicate widths in cols_at_size");
|
|
468
|
+
if (cols_at_size.length === 1) {
|
|
469
|
+
const [nb_cols, width] = cols_at_size[0];
|
|
470
|
+
const max_width = width !== undefined ? `${width}px` : "";
|
|
471
|
+
return [[nb_cols, "", max_width]];
|
|
472
|
+
}
|
|
473
|
+
// Sort widths in ascending order
|
|
474
|
+
const sorted_cols_at_size = [...cols_at_size].sort((a, b) => {
|
|
475
|
+
const [_b, width_A] = a;
|
|
476
|
+
const [_a, width_b] = b;
|
|
477
|
+
if (width_A === undefined) return -1;
|
|
478
|
+
if (width_b === undefined) return 1;
|
|
479
|
+
return width_b - width_A;
|
|
480
|
+
});
|
|
481
|
+
return $4e04be41243c3d80$var$transform_elements(sorted_cols_at_size);
|
|
482
|
+
};
|
|
483
|
+
function $fc23d7668ae0011d$export$a2cc176055f8f08(what = "grid") {
|
|
484
|
+
const text = "Please try setting `columnsAtSize`/`gridSpacing` on the `SearchPage`/`CategoryPage` components to change the " + what + " before setting it with CSS. If you do with CSS, set `columnsAtSize` to an empty array to ensure no declarations created by the SDK leak through.";
|
|
485
|
+
return (0, $gVhhF$solidjsweb.isServer) ? {
|
|
486
|
+
t: `<!-- ${text} -->`
|
|
487
|
+
} : document.createComment(text);
|
|
488
|
+
}
|
|
489
|
+
let $0caf87eaa19079da$var$cached_placeholder_element;
|
|
490
|
+
let $0caf87eaa19079da$var$rendering_cached_placeholder_element;
|
|
491
|
+
function $0caf87eaa19079da$export$f33414a4df0afd3f({
|
|
492
|
+
product_card_template_: product_card_template_,
|
|
493
|
+
num_placeholders_: num_placeholders_,
|
|
494
|
+
content_blocks_: content_blocks_
|
|
495
|
+
}) {
|
|
496
|
+
const [num_to_actually_show, set_num_to_actually_show] = $gVhhF$solidjs.createSignal($gVhhF$solidjs.untrack(num_placeholders_));
|
|
497
|
+
if (0, $gVhhF$solidjsweb.isServer)
|
|
498
|
+
// want to render simple placeholders on server, effects don't run there
|
|
499
|
+
// FIXME when adding proper SSR: also SSR content blocks
|
|
500
|
+
return $gVhhF$solidjs.createMemo(() => Array.from({
|
|
501
|
+
length: num_placeholders_()
|
|
502
|
+
}).map(() => {
|
|
503
|
+
const template_result = product_card_template_(null, undefined);
|
|
504
|
+
// @ts-ignore
|
|
505
|
+
if (typeof template_result?.then !== "function") return template_result;
|
|
506
|
+
}));
|
|
507
|
+
$gVhhF$solidjs.createRenderEffect(() => {
|
|
508
|
+
const existing_num = num_to_actually_show();
|
|
509
|
+
const to_add = num_placeholders_() - existing_num;
|
|
510
|
+
if (to_add <= 0) return;
|
|
511
|
+
// Below comment is from when we used recommendation renderer and manual DOM manipulation for this, but I'm still scared to remove placeholders and mess up scroll restoration, so I'm keeping the way it worked. Otherwise, <Index> could be used which would be far more elegant.
|
|
512
|
+
// We don't need to remove placeholders, only need to add. The reason for that is that chrome restores the scroll position once all tasks queued as reaction of the "popstate" events have been completed in the task queue. That means that we need to get the placeholders in fast, or we might lose scroll position if the previous site was shorter.
|
|
513
|
+
// The query id and the amount might update in separate tasks because one comes from href_change_ipns and the other one from another "popstate" listener. Therefore, we need to be able to dynamically add more placeholders. I'm not entirely sure about this anymore though, since we have the scroll position on a per-id basis it might work anyway but THIS WORKS, and I've been working on this bug for 3 hours so let's just keep it this way.
|
|
514
|
+
// Above comments were from when we added elements in this createRenderEffect. Now I changed it to just increment the number and render them from an <Index> instead, so I can add content blocks better
|
|
515
|
+
// Functionality should be the same
|
|
516
|
+
set_num_to_actually_show(existing_num + to_add);
|
|
517
|
+
});
|
|
518
|
+
return $gVhhF$solidjsweb.createComponent((0, $gVhhF$solidjs.Index), {
|
|
519
|
+
get each() {
|
|
520
|
+
return Array.from({
|
|
521
|
+
length: num_to_actually_show()
|
|
522
|
+
});
|
|
523
|
+
},
|
|
524
|
+
children: (_item, index) => {
|
|
525
|
+
const possible_content_block = $gVhhF$solidjs.createMemo(() => content_blocks_?.()?.()?.[index]);
|
|
526
|
+
// Show content block before product card, so it's *at* that index
|
|
527
|
+
return [possible_content_block, $0caf87eaa19079da$var$Placeholder({
|
|
528
|
+
product_card_template_: product_card_template_
|
|
529
|
+
})]; // https://github.com/solidjs/solid/releases/tag/v1.7.0
|
|
530
|
+
}
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
/**
|
|
534
|
+
* Get one placeholder element. It will be cloned for each placeholder for ultimate performance even when solid-js isn't rendering the placeholders.
|
|
535
|
+
*/
|
|
536
|
+
function $0caf87eaa19079da$var$Placeholder({
|
|
537
|
+
product_card_template_: product_card_template_
|
|
538
|
+
}) {
|
|
539
|
+
const get_cloned_placeholders = (element_to_clone = $0caf87eaa19079da$var$cached_placeholder_element) => Array.isArray(element_to_clone) ? element_to_clone.map(el => el instanceof Node ? el.cloneNode(true) : el) : element_to_clone;
|
|
540
|
+
if ($0caf87eaa19079da$var$cached_placeholder_element) return get_cloned_placeholders();
|
|
541
|
+
let dispose_original_copy;
|
|
542
|
+
const get_unwrapped_element = $gVhhF$solidjs.createRoot(dispose => {
|
|
543
|
+
dispose_original_copy = dispose;
|
|
544
|
+
// if product_card_template_ is async and rejects the resource will take care of throwing upwards here in the solid-js error handling system
|
|
545
|
+
const [resource] = $gVhhF$solidjs.createResource(() => {
|
|
546
|
+
if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) return $0caf87eaa19079da$var$rendering_cached_placeholder_element;
|
|
547
|
+
const return_value = product_card_template_(null, undefined);
|
|
548
|
+
if (typeof return_value === "object" && typeof return_value?.then === "function")
|
|
549
|
+
// Is Promise or promise-like object
|
|
550
|
+
$0caf87eaa19079da$var$rendering_cached_placeholder_element = return_value;
|
|
551
|
+
return return_value;
|
|
552
|
+
});
|
|
553
|
+
return $gVhhF$solidjs.createMemo(() => {
|
|
554
|
+
if (resource.loading) return () => [];
|
|
555
|
+
return $5f7d55c710fd1bc2$export$2f0cbfbb4354bb52(resource);
|
|
556
|
+
});
|
|
557
|
+
});
|
|
558
|
+
$gVhhF$solidjs.onCleanup(() => {
|
|
559
|
+
if ($0caf87eaa19079da$var$rendering_cached_placeholder_element) {
|
|
560
|
+
// If we're still rendering in our separate root, let the rendering finish or other <Placeholder> components waiting for it might get an incomplete result
|
|
561
|
+
const unset_current_rendering = () => {
|
|
562
|
+
dispose_original_copy();
|
|
563
|
+
$0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
|
|
564
|
+
};
|
|
565
|
+
$0caf87eaa19079da$var$rendering_cached_placeholder_element?.then(unset_current_rendering, unset_current_rendering);
|
|
566
|
+
} else
|
|
567
|
+
// Otherwise, just make sure we've disposed our root
|
|
568
|
+
dispose_original_copy();
|
|
569
|
+
});
|
|
570
|
+
return $gVhhF$solidjs.createMemo(() => {
|
|
571
|
+
const unwrapped_array = get_unwrapped_element()();
|
|
572
|
+
if (!unwrapped_array?.length || !unwrapped_array.every(item => item))
|
|
573
|
+
// Haven't finished rendering yet in case of "async" rendering, so don't freeze the elements yet
|
|
574
|
+
return;
|
|
575
|
+
// placeholders have finished rendering, freeze the elements
|
|
576
|
+
// here we might receive the result of a promise that has already been received, tore down and put into cached_placeholder_element, so don't overwrite that more valid result if it's already set
|
|
577
|
+
$0caf87eaa19079da$var$cached_placeholder_element ||= get_cloned_placeholders(unwrapped_array); // Clone initial return value so that who gave us the elements can't mutate them, which has caused issues before with react
|
|
578
|
+
$0caf87eaa19079da$var$rendering_cached_placeholder_element = undefined;
|
|
579
|
+
dispose_original_copy(); // So that this memo will never re-run and the placeholder rendering function can clean up
|
|
580
|
+
return get_cloned_placeholders(); // clone, just in case. If we wouldn't, someone could modify the copy in the DOM, and it would affect the cached version
|
|
581
|
+
});
|
|
582
|
+
}
|
|
498
583
|
|
|
499
584
|
// Errors caused by SDK consuming code interfacing with the SDK, not the SDK itself or other Depict packages
|
|
500
585
|
class $7dd1edb2ee2b43ad$export$e1d52e4f0c7557a1 extends Error {}
|
|
@@ -832,10 +917,13 @@ function $363ce4d1d71041aa$export$d41d19e89346fa2({
|
|
|
832
917
|
return (() => {
|
|
833
918
|
// IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
|
|
834
919
|
const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
|
|
835
|
-
|
|
920
|
+
const {
|
|
921
|
+
renderedDisplays_: renderedDisplays_
|
|
922
|
+
} = $67155e1aeb7073f6$export$4a14175d33d81a96({
|
|
836
923
|
displays_by_key_: displays_by_key_,
|
|
837
924
|
product_card_template_: product_card_template_
|
|
838
925
|
});
|
|
926
|
+
return renderedDisplays_;
|
|
839
927
|
})();
|
|
840
928
|
}
|
|
841
929
|
});
|
|
@@ -2004,10 +2092,13 @@ function $b8e79813f4f7ebe4$export$7da560f849543dff({
|
|
|
2004
2092
|
return (() => {
|
|
2005
2093
|
// IIFE to make sure we access both the recommendations_resource and the resources containing the product card rendering results themselves within the Suspense boundary
|
|
2006
2094
|
const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => recommendations_resource_() || []));
|
|
2007
|
-
|
|
2095
|
+
const {
|
|
2096
|
+
renderedDisplays_: renderedDisplays_
|
|
2097
|
+
} = $67155e1aeb7073f6$export$4a14175d33d81a96({
|
|
2008
2098
|
displays_by_key_: displays_by_key_,
|
|
2009
2099
|
product_card_template_: product_card_template_
|
|
2010
2100
|
});
|
|
2101
|
+
return renderedDisplays_;
|
|
2011
2102
|
})();
|
|
2012
2103
|
}
|
|
2013
2104
|
});
|
|
@@ -10129,10 +10220,13 @@ function $fb29c6201c369e39$export$7de92c4c2205ebf3({
|
|
|
10129
10220
|
if (!should_show() && prev) return prev; // When we're invisible, don't update what we're rendering to be possibly undefined to preserve the same products if possible
|
|
10130
10221
|
return recommendations_resource() || [];
|
|
10131
10222
|
}));
|
|
10132
|
-
|
|
10223
|
+
const {
|
|
10224
|
+
renderedDisplays_: renderedDisplays_
|
|
10225
|
+
} = $67155e1aeb7073f6$export$4a14175d33d81a96({
|
|
10133
10226
|
displays_by_key_: displays_by_key_,
|
|
10134
10227
|
product_card_template_: product_card_template_
|
|
10135
10228
|
});
|
|
10229
|
+
return renderedDisplays_;
|
|
10136
10230
|
})();
|
|
10137
10231
|
}
|
|
10138
10232
|
});
|
|
@@ -10765,8 +10859,8 @@ function $4117463e2939f5f4$export$63dd0350f8559dda({
|
|
|
10765
10859
|
function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
|
|
10766
10860
|
plp_results_: plp_results_,
|
|
10767
10861
|
product_card_template_: product_card_template_,
|
|
10768
|
-
first_result_in_viewport_: [,
|
|
10769
|
-
last_result_in_viewport_: [
|
|
10862
|
+
first_result_in_viewport_: [, setFirstResultInViewport],
|
|
10863
|
+
last_result_in_viewport_: [lastResultInViewport, setLastResultsInViewport],
|
|
10770
10864
|
all_products_loaded_: all_products_loaded_,
|
|
10771
10865
|
min_products_to_fetch_: min_products_to_fetch_,
|
|
10772
10866
|
query_base_: query_base_,
|
|
@@ -10774,36 +10868,25 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
|
|
|
10774
10868
|
is_loading_: is_loading_,
|
|
10775
10869
|
content_blocks_: content_blocks_
|
|
10776
10870
|
}) {
|
|
10777
|
-
// 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
|
|
10778
|
-
const target_to_index_map = new Map();
|
|
10779
|
-
const index_to_target_map_ = new Map();
|
|
10780
|
-
const currently_intersecting = new Set();
|
|
10781
|
-
const intersection_observer = new IntersectionObserver($gVhhF$depictaiutilishared.catchify(records => {
|
|
10782
|
-
for (let i = 0; i < records.length; i++) {
|
|
10783
|
-
const record = records[i];
|
|
10784
|
-
const {
|
|
10785
|
-
target: target,
|
|
10786
|
-
intersectionRatio: intersectionRatio
|
|
10787
|
-
} = record;
|
|
10788
|
-
const index_of_target = target_to_index_map.get(target);
|
|
10789
|
-
if (index_of_target == undefined) return; // It seems like it can happen that we get IntersectionObserverEntries after the onCleanup function for a recommendation card has run, in Firefox. Probably a bug in Firefox? If I understood the bug correctly, this is a workaround.
|
|
10790
|
-
const is_in_set = currently_intersecting.has(index_of_target);
|
|
10791
|
-
if (intersectionRatio > 0) {
|
|
10792
|
-
if (!is_in_set) currently_intersecting.add(index_of_target);
|
|
10793
|
-
} else if (is_in_set) currently_intersecting.delete(index_of_target);
|
|
10794
|
-
}
|
|
10795
|
-
set_first_result_in_viewport(Math.min(...currently_intersecting) + 1); // +1 because we want to start counting at 1
|
|
10796
|
-
set_last_result_in_viewport(Math.max(...currently_intersecting) + 1);
|
|
10797
|
-
}, "PLPResults IO failed"));
|
|
10798
10871
|
// Although typing doesn't reflect it, plp_results is guaranteed to contain an array of at least one display at this point
|
|
10799
10872
|
const [get_extra_displays, set_extra_displays_] = $gVhhF$solidjs.createSignal([], {
|
|
10800
10873
|
equals: false
|
|
10801
10874
|
});
|
|
10802
10875
|
const displays_by_key_ = $a73063cc642f3e5f$export$7f8bd308237ab5a5($gVhhF$solidjs.createMemo(() => [...(plp_results_()?.displays || []), ...get_extra_displays()]));
|
|
10876
|
+
const {
|
|
10877
|
+
indexToTargetMap_: indexToTargetMap_,
|
|
10878
|
+
renderedDisplays_: renderedDisplays_,
|
|
10879
|
+
currentlyIntersecting: currentlyIntersecting
|
|
10880
|
+
} = $67155e1aeb7073f6$export$4a14175d33d81a96({
|
|
10881
|
+
displays_by_key_: displays_by_key_,
|
|
10882
|
+
product_card_template_: product_card_template_,
|
|
10883
|
+
content_blocks_: content_blocks_,
|
|
10884
|
+
alwaysObserveCards_: true
|
|
10885
|
+
});
|
|
10803
10886
|
const percentage_in_view_ = $4117463e2939f5f4$export$63dd0350f8559dda({
|
|
10804
|
-
get_last_result_in_viewport_:
|
|
10887
|
+
get_last_result_in_viewport_: lastResultInViewport,
|
|
10805
10888
|
displays_by_key_: displays_by_key_,
|
|
10806
|
-
index_to_target_map_:
|
|
10889
|
+
index_to_target_map_: indexToTargetMap_,
|
|
10807
10890
|
is_loading_: is_loading_,
|
|
10808
10891
|
get_extra_displays: get_extra_displays
|
|
10809
10892
|
});
|
|
@@ -10816,30 +10899,12 @@ function $ac167f6af6a48fc3$export$a1fd619a4743ca08({
|
|
|
10816
10899
|
query_base_: query_base_,
|
|
10817
10900
|
depict_api_: depict_api_
|
|
10818
10901
|
});
|
|
10819
|
-
|
|
10820
|
-
|
|
10821
|
-
|
|
10822
|
-
|
|
10823
|
-
do_per_elements_: (elements, index_accessor) =>
|
|
10824
|
-
// Adds/removes elements from the "results in viewport" intersection observer above
|
|
10825
|
-
$gVhhF$solidjs.createEffect(() => {
|
|
10826
|
-
const display_index = index_accessor();
|
|
10827
|
-
// Nested createEffect because we only want to re-run this when the index changes
|
|
10828
|
-
// We need to save in a map which index the elements of this template are so that we can know that in the IntersectionObserver callback
|
|
10829
|
-
for (let i = 0; i < elements.length; i++) {
|
|
10830
|
-
const element = elements[i];
|
|
10831
|
-
target_to_index_map.set(element, display_index);
|
|
10832
|
-
intersection_observer.observe(element);
|
|
10833
|
-
$gVhhF$solidjs.onCleanup(() => {
|
|
10834
|
-
intersection_observer.unobserve(element);
|
|
10835
|
-
target_to_index_map.delete(element);
|
|
10836
|
-
currently_intersecting.delete(display_index);
|
|
10837
|
-
});
|
|
10838
|
-
}
|
|
10839
|
-
index_to_target_map_.set(display_index, elements);
|
|
10840
|
-
$gVhhF$solidjs.onCleanup(() => index_to_target_map_.delete(display_index));
|
|
10841
|
-
})
|
|
10902
|
+
$gVhhF$solidjs.createEffect(() => {
|
|
10903
|
+
const intersecting = currentlyIntersecting();
|
|
10904
|
+
setFirstResultInViewport(Math.min(...intersecting) + 1); // +1 because we want to start counting at 1
|
|
10905
|
+
setLastResultsInViewport(Math.max(...intersecting) + 1);
|
|
10842
10906
|
});
|
|
10907
|
+
return renderedDisplays_;
|
|
10843
10908
|
}
|
|
10844
10909
|
var $75777da1687ba3f6$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<div>`),
|
|
10845
10910
|
$75777da1687ba3f6$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<style type=text/css>`);
|
|
@@ -11243,11 +11308,13 @@ function $fe76fb463cc60b89$export$3925f87b1545cfc6({
|
|
|
11243
11308
|
cols_at_size_: modified_cols_at_size,
|
|
11244
11309
|
set_top_row_shortened_by_: set_top_row_shortened_by_
|
|
11245
11310
|
}));
|
|
11246
|
-
const rendered_placeholders = $gVhhF$solidjs.createMemo(() =>
|
|
11247
|
-
|
|
11248
|
-
|
|
11249
|
-
|
|
11250
|
-
|
|
11311
|
+
const rendered_placeholders = $gVhhF$solidjs.createMemo(() => {
|
|
11312
|
+
if (get_should_have_placeholders_rendered()) return $0caf87eaa19079da$export$f33414a4df0afd3f({
|
|
11313
|
+
content_blocks_: content_blocks_,
|
|
11314
|
+
product_card_template_: product_card_template_,
|
|
11315
|
+
num_placeholders_: num_placeholders_
|
|
11316
|
+
});
|
|
11317
|
+
});
|
|
11251
11318
|
const layout = $gVhhF$solidjs.createMemo(() => {
|
|
11252
11319
|
const incoming_layout = layout_options_().layout;
|
|
11253
11320
|
if (incoming_layout === "slider-without-filters") return "slider";
|