@depict-ai/ui 2.0.22 → 2.0.24

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.
@@ -10,6 +10,9 @@ function $parcel$export(e, n, v, s) {
10
10
  configurable: true
11
11
  });
12
12
  }
13
+ $parcel$export(module.exports, "strip_encoded_filter_and_sort", () => $1ab22f2cd39b3061$export$916e6850778505f6);
14
+ $parcel$export(module.exports, "encode_filters", () => $1ab22f2cd39b3061$export$58aa3f171519b6d7);
15
+ $parcel$export(module.exports, "decode_filters", () => $1ab22f2cd39b3061$export$f934fa24c3a86811);
13
16
  $parcel$export(module.exports, "shopifyContainedImageContextSymbol", () => $a33065cfed827fc0$export$d7b7ab832c20e2f4);
14
17
  $parcel$export(module.exports, "ListingProvider", () => $84798aaa863a4909$export$e68cff63f76bd15b);
15
18
  $parcel$export(module.exports, "useListing", () => $84798aaa863a4909$export$8d0c4fdbb05a2f2e);
@@ -66,7 +69,180 @@ $parcel$export(module.exports, "defaultColsAtSize", () => $a3280f0aad997933$expo
66
69
  $parcel$export(module.exports, "defaultCategoryTitlePlugin", () => $a3280f0aad997933$export$7bf543b9d9be2c22);
67
70
  $parcel$export(module.exports, "version", () => $b757f75811f3261f$export$83d89fbfd8236492);
68
71
  /*! Depict.ai search and product listing SDK */
69
- const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.22";
72
+ const $b757f75811f3261f$export$83d89fbfd8236492 = "2.0.24";
73
+ const $1ab22f2cd39b3061$var$fallback_operator = "in";
74
+ const $1ab22f2cd39b3061$var$fallback_token = "";
75
+ const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
76
+ const $1ab22f2cd39b3061$var$operator_map = {
77
+ "eq": "≡",
78
+ "neq": "≠",
79
+ "in": "∈",
80
+ "nin": "∉",
81
+ "leq": "≤",
82
+ "geq": "≥",
83
+ "inrange": "\uD83D\uDD22"
84
+ };
85
+ const $1ab22f2cd39b3061$var$ascending_token = "\uD83D\uDCC8";
86
+ const $1ab22f2cd39b3061$var$descending_token = "\uD83D\uDCC9";
87
+ const $1ab22f2cd39b3061$var$range_delimiter = "-";
88
+ const $1ab22f2cd39b3061$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
89
+ const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
90
+ const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
91
+ const $1ab22f2cd39b3061$var$op_to_token = op => {
92
+ if (op === $1ab22f2cd39b3061$var$fallback_operator) return $1ab22f2cd39b3061$var$fallback_token;
93
+ return $1ab22f2cd39b3061$var$operator_map[op];
94
+ };
95
+ /**
96
+ * Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
97
+ * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
98
+ * No deep or mixed nesting levels are supported.
99
+ */
100
+ function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
101
+ if (array.every(item => Array.isArray(item))) {
102
+ if (!is_root)
103
+ // Deeply nested arrays are not supported, but also don't exist as filters (yet)
104
+ return false;
105
+ return array.every(item => $1ab22f2cd39b3061$var$array_is_serializable(item, false));
106
+ }
107
+ if (array.some(item => typeof item !== "string"))
108
+ // Numbers are not supported, since 1 and "1" would encode to the same thing
109
+ return false;
110
+ // Encoding reserved characters is not supported
111
+ return !array.some(item => item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
112
+ }
113
+ /**
114
+ * Human readable string[] or string[][] serialization for URLs.
115
+ * @param array
116
+ * @returns
117
+ */
118
+ function $1ab22f2cd39b3061$var$encode_array(array) {
119
+ const is_nested = array.every(item => Array.isArray(item));
120
+ if (is_nested) return array.map($1ab22f2cd39b3061$var$encode_array).join($1ab22f2cd39b3061$var$array_item_delimiter) + $1ab22f2cd39b3061$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
121
+ return array.map(item => item === "" ? $1ab22f2cd39b3061$var$empty_item_replacement : item).join($1ab22f2cd39b3061$var$string_item_delimiter);
122
+ }
123
+ function $1ab22f2cd39b3061$var$decode_array(encoded_array) {
124
+ const is_nested = encoded_array.includes($1ab22f2cd39b3061$var$array_item_delimiter);
125
+ if (is_nested) return encoded_array.split($1ab22f2cd39b3061$var$array_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter
126
+ .map($1ab22f2cd39b3061$var$decode_array);
127
+ return encoded_array.split($1ab22f2cd39b3061$var$string_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
128
+ .map(item => item === $1ab22f2cd39b3061$var$empty_item_replacement ? "" : item);
129
+ }
130
+ function $1ab22f2cd39b3061$var$encode_filter_data(op, data) {
131
+ if (data === "true")
132
+ // boolean encoding
133
+ return "1";
134
+ if (data === "false")
135
+ // boolean encoding
136
+ return "0";
137
+ const data_is_array = Array.isArray(data);
138
+ if (op === "inrange" && data_is_array && data.every(item => typeof item === "number"))
139
+ // numeric range filter encoding
140
+ return data.join($1ab22f2cd39b3061$var$range_delimiter);
141
+ if (data_is_array && $1ab22f2cd39b3061$var$array_is_serializable(data)) {
142
+ const encoded_data = $1ab22f2cd39b3061$var$encode_array(data);
143
+ if (!encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter) && !encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter))
144
+ // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
145
+ // In that case we add a delimiter suffix at the end
146
+ return encoded_data + $1ab22f2cd39b3061$var$string_item_delimiter;
147
+ return encoded_data;
148
+ }
149
+ // Fallback encoding
150
+ return $5vyXB$depictaiutilishared.base64_encode_unicode(JSON.stringify(data));
151
+ }
152
+ function $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data) {
153
+ if (encoded_data === "1") return "true";
154
+ if (encoded_data === "0") return "false";
155
+ if (op === "inrange" && encoded_data.includes($1ab22f2cd39b3061$var$range_delimiter)) return encoded_data.split($1ab22f2cd39b3061$var$range_delimiter).map(x => parseFloat(x));
156
+ if (encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter) || encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter)) return $1ab22f2cd39b3061$var$decode_array(encoded_data);
157
+ try {
158
+ return JSON.parse($5vyXB$depictaiutilishared.base64_decode_unicode(encoded_data));
159
+ } catch (e) {
160
+ $5vyXB$depictaiutilishared.dlog("Failed to fallback parse filter data", op, encoded_data, e);
161
+ }
162
+ return null;
163
+ }
164
+ function $1ab22f2cd39b3061$export$58aa3f171519b6d7(filters, search_params, filter_query_param_prefix) {
165
+ for (const filter of filters) {
166
+ const {
167
+ field: field,
168
+ op: op,
169
+ data: data
170
+ } = filter;
171
+ const encoded_data = $1ab22f2cd39b3061$var$encode_filter_data(op, data);
172
+ search_params.set(filter_query_param_prefix + field + $1ab22f2cd39b3061$var$op_to_token(op), encoded_data);
173
+ }
174
+ }
175
+ function $1ab22f2cd39b3061$export$f934fa24c3a86811(search_params, filter_query_param_prefix) {
176
+ const found_filters = [];
177
+ for (const key of search_params.keys()) {
178
+ // Allow for backwards compatibility with the old filter query param prefix
179
+ let chosen_prefix = filter_query_param_prefix;
180
+ if (!key.startsWith(chosen_prefix)) {
181
+ chosen_prefix = $1ab22f2cd39b3061$var$legacy_filter_prefix;
182
+ if (!key.startsWith(chosen_prefix)) continue;
183
+ }
184
+ const encoded_data = search_params.get(key);
185
+ if (!encoded_data) continue;
186
+ const [op, token] = Object.entries($1ab22f2cd39b3061$var$operator_map).find(([, token]) => key.endsWith(token)) || [$1ab22f2cd39b3061$var$fallback_operator, $1ab22f2cd39b3061$var$fallback_token];
187
+ const data = $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data);
188
+ if (!data) continue;
189
+ const field = key.slice(chosen_prefix.length, token ? -token.length : undefined);
190
+ found_filters.push({
191
+ field: field,
192
+ op: op,
193
+ data: data
194
+ });
195
+ }
196
+ return found_filters;
197
+ }
198
+ function $1ab22f2cd39b3061$export$62acb285a7579555(sorting, search_params, sorting_query_param) {
199
+ if (!sorting) return;
200
+ const {
201
+ field: field,
202
+ order: order
203
+ } = sorting;
204
+ const ascending = order === "asc";
205
+ search_params.set(sorting_query_param, field + (ascending ? $1ab22f2cd39b3061$var$ascending_token : $1ab22f2cd39b3061$var$descending_token));
206
+ }
207
+ function $1ab22f2cd39b3061$export$766e9676e74997d3(search_params, sorting_query_param_) {
208
+ const encoded_sorting = search_params.get(sorting_query_param_);
209
+ if (!encoded_sorting) return;
210
+ if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$ascending_token)) return {
211
+ field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$ascending_token.length),
212
+ order: "asc"
213
+ };
214
+ if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$descending_token)) return {
215
+ field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$descending_token.length),
216
+ order: "desc"
217
+ };
218
+ $5vyXB$depictaiutilishared.dlog("Invalid sorting query param value", encoded_sorting);
219
+ return;
220
+ }
221
+ function $1ab22f2cd39b3061$export$916e6850778505f6(search_params, filter_query_param_prefix, sorting_query_param) {
222
+ // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
223
+ const keys = [...search_params.keys()];
224
+ for (const key of keys) if (key.startsWith(filter_query_param_prefix) || key === sorting_query_param || key.startsWith($1ab22f2cd39b3061$var$legacy_filter_prefix)) search_params.delete(key);
225
+ }
226
+ const $1ab22f2cd39b3061$export$cf5feb2102aec7f2 = "went_sideways_clear_filters";
227
+ function $1ab22f2cd39b3061$export$43cd1e747fecd42e({
228
+ to_url_: to_url_,
229
+ set_clearing_flag_: set_clearing_flag_,
230
+ from_search_params_ = new URLSearchParams(location.search),
231
+ sorting_query_param_: sorting_query_param_,
232
+ filter_query_param_prefix_: filter_query_param_prefix_
233
+ }) {
234
+ if (!to_url_) return to_url_;
235
+ const was_url_object = to_url_ instanceof URL;
236
+ const url_object = was_url_object ? to_url_ : new URL(to_url_, location.origin);
237
+ const {
238
+ searchParams: searchParams
239
+ } = url_object;
240
+ if (set_clearing_flag_) searchParams.set($1ab22f2cd39b3061$export$cf5feb2102aec7f2, "true");
241
+ if (from_search_params_.has(sorting_query_param_)) searchParams.set(sorting_query_param_, from_search_params_.get(sorting_query_param_));
242
+ for (const key of from_search_params_.keys()) if (key.startsWith(filter_query_param_prefix_)) searchParams.set(key, from_search_params_.get(key));
243
+ if (was_url_object) return url_object;
244
+ return url_object.href;
245
+ }
70
246
  const $84798aaa863a4909$var$ListingContext = /*@__PURE__*/$5vyXB$solidjs.createContext();
71
247
  function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
72
248
  const our_object = {};
@@ -4439,179 +4615,6 @@ function $2fb324fbcc7b4a7b$var$ActualFloatingButtons({
4439
4615
  }));
4440
4616
  return $5vyXB$solidjsweb.ssr($2fb324fbcc7b4a7b$var$_tmpl$, $5vyXB$solidjsweb.ssrHydrationKey(), `floating-buttons ${is_scrolling_upwards() && modal_is_closed() && !regular_buttons_are_in_view() && !get_is_showing_toast() ? "show-them" : ""}`, $5vyXB$solidjsweb.ssrAttribute("aria-label", $5vyXB$solidjsweb.escape(i18n_.filter_text_(), true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $02215fefc955d01e$export$28f6150e232898de), {})), $5vyXB$solidjsweb.ssrAttribute("aria-label", $5vyXB$solidjsweb.escape(i18n_.sorting_text_(), true), false), current_sorting_[0]()?.order === "asc" ? $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $f958b5ac0e4a78da$export$da32f7add8a22e86), {})) : $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $046db47e0326c715$export$d10e63059ddb9fd4), {})), $5vyXB$solidjsweb.ssrAttribute("aria-label", $5vyXB$solidjsweb.escape(i18n_.scroll_to_top_(), true), false), $5vyXB$solidjsweb.escape($5vyXB$solidjsweb.createComponent((0, $084b6a0ee1d481de$export$2624c5890f1bbcf7), {})));
4441
4617
  }
4442
- const $1ab22f2cd39b3061$var$fallback_operator = "in";
4443
- const $1ab22f2cd39b3061$var$fallback_token = "";
4444
- const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
4445
- const $1ab22f2cd39b3061$var$operator_map = {
4446
- "eq": "≡",
4447
- "neq": "≠",
4448
- "in": "∈",
4449
- "nin": "∉",
4450
- "leq": "≤",
4451
- "geq": "≥",
4452
- "inrange": "\uD83D\uDD22"
4453
- };
4454
- const $1ab22f2cd39b3061$var$ascending_token = "\uD83D\uDCC8";
4455
- const $1ab22f2cd39b3061$var$descending_token = "\uD83D\uDCC9";
4456
- const $1ab22f2cd39b3061$var$range_delimiter = "-";
4457
- const $1ab22f2cd39b3061$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
4458
- const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
4459
- const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
4460
- const $1ab22f2cd39b3061$var$op_to_token = op => {
4461
- if (op === $1ab22f2cd39b3061$var$fallback_operator) return $1ab22f2cd39b3061$var$fallback_token;
4462
- return $1ab22f2cd39b3061$var$operator_map[op];
4463
- };
4464
- /**
4465
- * Checks if a given array of filter data can be neatly serialized into an URL query parameter, or if it should fall back to JSON+base64.
4466
- * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
4467
- * No deep or mixed nesting levels are supported.
4468
- */
4469
- function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
4470
- if (array.every(item => Array.isArray(item))) {
4471
- if (!is_root)
4472
- // Deeply nested arrays are not supported, but also don't exist as filters (yet)
4473
- return false;
4474
- return array.every(item => $1ab22f2cd39b3061$var$array_is_serializable(item, false));
4475
- }
4476
- if (array.some(item => typeof item !== "string"))
4477
- // Numbers are not supported, since 1 and "1" would encode to the same thing
4478
- return false;
4479
- // Encoding reserved characters is not supported
4480
- return !array.some(item => item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
4481
- }
4482
- /**
4483
- * Human readable string[] or string[][] serialization for URLs.
4484
- * @param array
4485
- * @returns
4486
- */
4487
- function $1ab22f2cd39b3061$var$encode_array(array) {
4488
- const is_nested = array.every(item => Array.isArray(item));
4489
- if (is_nested) return array.map($1ab22f2cd39b3061$var$encode_array).join($1ab22f2cd39b3061$var$array_item_delimiter) + $1ab22f2cd39b3061$var$array_item_delimiter; // Nested arrays require a suffix to close nesting levels
4490
- return array.map(item => item === "" ? $1ab22f2cd39b3061$var$empty_item_replacement : item).join($1ab22f2cd39b3061$var$string_item_delimiter);
4491
- }
4492
- function $1ab22f2cd39b3061$var$decode_array(encoded_array) {
4493
- const is_nested = encoded_array.includes($1ab22f2cd39b3061$var$array_item_delimiter);
4494
- if (is_nested) return encoded_array.split($1ab22f2cd39b3061$var$array_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter
4495
- .map($1ab22f2cd39b3061$var$decode_array);
4496
- return encoded_array.split($1ab22f2cd39b3061$var$string_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter in the single item special case
4497
- .map(item => item === $1ab22f2cd39b3061$var$empty_item_replacement ? "" : item);
4498
- }
4499
- function $1ab22f2cd39b3061$var$encode_filter_data(op, data) {
4500
- if (data === "true")
4501
- // boolean encoding
4502
- return "1";
4503
- if (data === "false")
4504
- // boolean encoding
4505
- return "0";
4506
- const data_is_array = Array.isArray(data);
4507
- if (op === "inrange" && data_is_array && data.every(item => typeof item === "number"))
4508
- // numeric range filter encoding
4509
- return data.join($1ab22f2cd39b3061$var$range_delimiter);
4510
- if (data_is_array && $1ab22f2cd39b3061$var$array_is_serializable(data)) {
4511
- const encoded_data = $1ab22f2cd39b3061$var$encode_array(data);
4512
- if (!encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter) && !encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter))
4513
- // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
4514
- // In that case we add a delimiter suffix at the end
4515
- return encoded_data + $1ab22f2cd39b3061$var$string_item_delimiter;
4516
- return encoded_data;
4517
- }
4518
- // Fallback encoding
4519
- return $5vyXB$depictaiutilishared.base64_encode_unicode(JSON.stringify(data));
4520
- }
4521
- function $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data) {
4522
- if (encoded_data === "1") return "true";
4523
- if (encoded_data === "0") return "false";
4524
- if (op === "inrange" && encoded_data.includes($1ab22f2cd39b3061$var$range_delimiter)) return encoded_data.split($1ab22f2cd39b3061$var$range_delimiter).map(x => parseFloat(x));
4525
- if (encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter) || encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter)) return $1ab22f2cd39b3061$var$decode_array(encoded_data);
4526
- try {
4527
- return JSON.parse($5vyXB$depictaiutilishared.base64_decode_unicode(encoded_data));
4528
- } catch (e) {
4529
- $5vyXB$depictaiutilishared.dlog("Failed to fallback parse filter data", op, encoded_data, e);
4530
- }
4531
- return null;
4532
- }
4533
- function $1ab22f2cd39b3061$export$58aa3f171519b6d7(filters, search_params, filter_query_param_prefix) {
4534
- for (const filter of filters) {
4535
- const {
4536
- field: field,
4537
- op: op,
4538
- data: data
4539
- } = filter;
4540
- const encoded_data = $1ab22f2cd39b3061$var$encode_filter_data(op, data);
4541
- search_params.set(filter_query_param_prefix + field + $1ab22f2cd39b3061$var$op_to_token(op), encoded_data);
4542
- }
4543
- }
4544
- function $1ab22f2cd39b3061$export$f934fa24c3a86811(search_params, filter_query_param_prefix) {
4545
- const found_filters = [];
4546
- for (const key of search_params.keys()) {
4547
- // Allow for backwards compatibility with the old filter query param prefix
4548
- let chosen_prefix = filter_query_param_prefix;
4549
- if (!key.startsWith(chosen_prefix)) {
4550
- chosen_prefix = $1ab22f2cd39b3061$var$legacy_filter_prefix;
4551
- if (!key.startsWith(chosen_prefix)) continue;
4552
- }
4553
- const encoded_data = search_params.get(key);
4554
- if (!encoded_data) continue;
4555
- const [op, token] = Object.entries($1ab22f2cd39b3061$var$operator_map).find(([, token]) => key.endsWith(token)) || [$1ab22f2cd39b3061$var$fallback_operator, $1ab22f2cd39b3061$var$fallback_token];
4556
- const data = $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data);
4557
- if (!data) continue;
4558
- const field = key.slice(chosen_prefix.length, token ? -token.length : undefined);
4559
- found_filters.push({
4560
- field: field,
4561
- op: op,
4562
- data: data
4563
- });
4564
- }
4565
- return found_filters;
4566
- }
4567
- function $1ab22f2cd39b3061$export$62acb285a7579555(sorting, search_params, sorting_query_param) {
4568
- if (!sorting) return;
4569
- const {
4570
- field: field,
4571
- order: order
4572
- } = sorting;
4573
- const ascending = order === "asc";
4574
- search_params.set(sorting_query_param, field + (ascending ? $1ab22f2cd39b3061$var$ascending_token : $1ab22f2cd39b3061$var$descending_token));
4575
- }
4576
- function $1ab22f2cd39b3061$export$766e9676e74997d3(search_params, sorting_query_param_) {
4577
- const encoded_sorting = search_params.get(sorting_query_param_);
4578
- if (!encoded_sorting) return;
4579
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$ascending_token)) return {
4580
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$ascending_token.length),
4581
- order: "asc"
4582
- };
4583
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$descending_token)) return {
4584
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$descending_token.length),
4585
- order: "desc"
4586
- };
4587
- $5vyXB$depictaiutilishared.dlog("Invalid sorting query param value", encoded_sorting);
4588
- return;
4589
- }
4590
- function $1ab22f2cd39b3061$export$916e6850778505f6(search_params, filter_query_param_prefix, sorting_query_param) {
4591
- // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
4592
- const keys = [...search_params.keys()];
4593
- for (const key of keys) if (key.startsWith(filter_query_param_prefix) || key === sorting_query_param || key.startsWith($1ab22f2cd39b3061$var$legacy_filter_prefix)) search_params.delete(key);
4594
- }
4595
- const $1ab22f2cd39b3061$export$cf5feb2102aec7f2 = "went_sideways_clear_filters";
4596
- function $1ab22f2cd39b3061$export$43cd1e747fecd42e({
4597
- to_url_: to_url_,
4598
- set_clearing_flag_: set_clearing_flag_,
4599
- from_search_params_ = new URLSearchParams(location.search),
4600
- sorting_query_param_: sorting_query_param_,
4601
- filter_query_param_prefix_: filter_query_param_prefix_
4602
- }) {
4603
- if (!to_url_) return to_url_;
4604
- const was_url_object = to_url_ instanceof URL;
4605
- const url_object = was_url_object ? to_url_ : new URL(to_url_, location.origin);
4606
- const {
4607
- searchParams: searchParams
4608
- } = url_object;
4609
- if (set_clearing_flag_) searchParams.set($1ab22f2cd39b3061$export$cf5feb2102aec7f2, "true");
4610
- if (from_search_params_.has(sorting_query_param_)) searchParams.set(sorting_query_param_, from_search_params_.get(sorting_query_param_));
4611
- for (const key of from_search_params_.keys()) if (key.startsWith(filter_query_param_prefix_)) searchParams.set(key, from_search_params_.get(key));
4612
- if (was_url_object) return url_object;
4613
- return url_object.href;
4614
- }
4615
4618
  const $e53b2e7e632ac4cb$var$_tmpl$ = ["<nav", ' class="crumbs"', ">", "</nav>"],
4616
4619
  $e53b2e7e632ac4cb$var$_tmpl$2 = ["<a", ' class="crumb"', ">", "</a>"],
4617
4620
  $e53b2e7e632ac4cb$var$_tmpl$3 = ["<span", ' class="separator">', "</span>"];
@@ -1,5 +1,5 @@
1
1
  import { JSX, Accessor, Signal, Setter } from "solid-js";
2
- import { Amazing_Slider, Display, ColsAtSize, report, Elem, ModernDisplay, Node_Array } from "@depict-ai/utilishared/latest";
2
+ import { Display, Amazing_Slider, ColsAtSize, report, Elem, ModernDisplay, Node_Array } from "@depict-ai/utilishared/latest";
3
3
  import { SearchFilter, SearchRequest } from "@depict-ai/types/api/SearchRequest";
4
4
  import { SearchFilter as _SearchFilter1, ContentLink, SearchResponse } from "@depict-ai/types/api/SearchResponse";
5
5
  import { BaseCategoryDisplay, ProductListingResponse } from "@depict-ai/types/api/ProductListingResponse";
@@ -7,7 +7,54 @@ 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.22";
10
+ export const version = "2.0.24";
11
+ export type SDKGridSpacing = string | {
12
+ horizontal: string;
13
+ vertical: string;
14
+ };
15
+ export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
16
+ type FilterWithData = WithRequired<SearchFilter, "data">;
17
+ export interface SDKRenderingInfo {
18
+ /**
19
+ * If you call this function with a provided function, the provided function will be called whenever the index of the currently displayed product changes.
20
+ */
21
+ set_on_index_change: (fn: (index: number) => void) => void;
22
+ merchant: string;
23
+ market: string;
24
+ }
25
+ export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
26
+ type WithoutMerchant<T> = T extends {
27
+ merchant: string;
28
+ } ? Omit<T, "merchant"> : T;
29
+ type WithoutMarket<T> = T extends {
30
+ market: string;
31
+ } ? Omit<T, "market"> : T;
32
+ export type ProductCardTemplateWithoutMerchantAndMarket<T extends Display> = (display: Parameters<ProductCardTemplate<T>>[0], info?: WithoutMerchant<WithoutMarket<SDKRenderingInfo>>) => ReturnType<ProductCardTemplate<T>>;
33
+ /**
34
+ * Will be sent to backend to indicate whether the query_id_ is for a collection or category.
35
+ * Backend defaults to category if not specified.
36
+ */
37
+ export type ListingType = "collection" | "category";
38
+ type AddActualFieldToArray<T> = T extends Array<infer U> ? (U & {
39
+ actual_field?: string;
40
+ })[] : never;
41
+ type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends undefined ? undefined : AddActualFieldToArray<T>;
42
+ /**
43
+ * Function that encodes a filter object into query parameters and sets them on the given URLSearchParams object.
44
+ */
45
+ export function encode_filters(filters: FilterWithData[], search_params: URLSearchParams, filter_query_param_prefix: string): void;
46
+ /**
47
+ * Function that decodes the filters from the provided query parameters and returns them as an array of filter objects.
48
+ */
49
+ export function decode_filters(search_params: URLSearchParams, filter_query_param_prefix: string): FilterWithData[];
50
+ /**
51
+ * Remove all Depict filter/sorting query parameters from the given URLSearchParams object.
52
+ * Used to reset the URLSearchParams object to a clean state, before adding new filters/sorting.
53
+ * @param search_params
54
+ * @param filter_query_param_prefix Prefix of the filter query parameters
55
+ * @param sorting_query_param
56
+ */
57
+ export function strip_encoded_filter_and_sort(search_params: URLSearchParams, filter_query_param_prefix: string, sorting_query_param: string): void;
11
58
  /**
12
59
  * Provider to wrap every listing (group of products) in
13
60
  * Used for example for deduplicating ResizeObservers for responsive images
@@ -84,37 +131,6 @@ export function SlidableItems({
84
131
  * Returns accessor with the size of the provided element, including padding and border (I think)
85
132
  */
86
133
  export function make_accurate_size_accessor(what_to_watch: HTMLElement): import("solid-js").Accessor<number | undefined>;
87
- export type SDKGridSpacing = string | {
88
- horizontal: string;
89
- vertical: string;
90
- };
91
- export type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
92
- type FilterWithData = WithRequired<SearchFilter, "data">;
93
- export interface SDKRenderingInfo {
94
- /**
95
- * If you call this function with a provided function, the provided function will be called whenever the index of the currently displayed product changes.
96
- */
97
- set_on_index_change: (fn: (index: number) => void) => void;
98
- merchant: string;
99
- market: string;
100
- }
101
- export type ProductCardTemplate<T extends Display> = (display: T | null, info?: SDKRenderingInfo) => JSX.Element | Promise<JSX.Element>;
102
- type WithoutMerchant<T> = T extends {
103
- merchant: string;
104
- } ? Omit<T, "merchant"> : T;
105
- type WithoutMarket<T> = T extends {
106
- market: string;
107
- } ? Omit<T, "market"> : T;
108
- export type ProductCardTemplateWithoutMerchantAndMarket<T extends Display> = (display: Parameters<ProductCardTemplate<T>>[0], info?: WithoutMerchant<WithoutMarket<SDKRenderingInfo>>) => ReturnType<ProductCardTemplate<T>>;
109
- /**
110
- * Will be sent to backend to indicate whether the query_id_ is for a collection or category.
111
- * Backend defaults to category if not specified.
112
- */
113
- export type ListingType = "collection" | "category";
114
- type AddActualFieldToArray<T> = T extends Array<infer U> ? (U & {
115
- actual_field?: string;
116
- })[] : never;
117
- type AddActualFieldToFilters<T extends SearchFilter[] | undefined> = T extends undefined ? undefined : AddActualFieldToArray<T>;
118
134
  export type SDKColsAtSize = [number, number?][];
119
135
  /**
120
136
  * Transform SDK ColsAtSize into valid Layout ColsAtSize