@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.
package/latest/index.cjs CHANGED
@@ -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 $gVhhF$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($gVhhF$depictaiutilishared.base64_decode_unicode(encoded_data));
159
+ } catch (e) {
160
+ $gVhhF$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
+ $gVhhF$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__*/$gVhhF$solidjs.createContext();
71
247
  function $84798aaa863a4909$export$e68cff63f76bd15b(props) {
72
248
  const our_object = {};
@@ -5648,179 +5824,6 @@ function $2fb324fbcc7b4a7b$var$ActualFloatingButtons({
5648
5824
  })();
5649
5825
  }
5650
5826
  $gVhhF$solidjsweb.delegateEvents(["click"]);
5651
- const $1ab22f2cd39b3061$var$fallback_operator = "in";
5652
- const $1ab22f2cd39b3061$var$fallback_token = "";
5653
- const $1ab22f2cd39b3061$var$legacy_filter_prefix = "filter_";
5654
- const $1ab22f2cd39b3061$var$operator_map = {
5655
- "eq": "≡",
5656
- "neq": "≠",
5657
- "in": "∈",
5658
- "nin": "∉",
5659
- "leq": "≤",
5660
- "geq": "≥",
5661
- "inrange": "\uD83D\uDD22"
5662
- };
5663
- const $1ab22f2cd39b3061$var$ascending_token = "\uD83D\uDCC8";
5664
- const $1ab22f2cd39b3061$var$descending_token = "\uD83D\uDCC9";
5665
- const $1ab22f2cd39b3061$var$range_delimiter = "-";
5666
- const $1ab22f2cd39b3061$var$string_item_delimiter = "‚"; // This is not a comma but a comma-like character that browsers will render in the URL bar.
5667
- const $1ab22f2cd39b3061$var$array_item_delimiter = "‣"; // FIXME: decide on a character. Could theoretically be a double string delimiter.
5668
- const $1ab22f2cd39b3061$var$empty_item_replacement = "0️⃣";
5669
- const $1ab22f2cd39b3061$var$op_to_token = op => {
5670
- if (op === $1ab22f2cd39b3061$var$fallback_operator) return $1ab22f2cd39b3061$var$fallback_token;
5671
- return $1ab22f2cd39b3061$var$operator_map[op];
5672
- };
5673
- /**
5674
- * 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.
5675
- * The requirements are either an array of strings, containing no reserved characters, or an array of arrays of strings, containing no reserved characters.
5676
- * No deep or mixed nesting levels are supported.
5677
- */
5678
- function $1ab22f2cd39b3061$var$array_is_serializable(array, is_root = true) {
5679
- if (array.every(item => Array.isArray(item))) {
5680
- if (!is_root)
5681
- // Deeply nested arrays are not supported, but also don't exist as filters (yet)
5682
- return false;
5683
- return array.every(item => $1ab22f2cd39b3061$var$array_is_serializable(item, false));
5684
- }
5685
- if (array.some(item => typeof item !== "string"))
5686
- // Numbers are not supported, since 1 and "1" would encode to the same thing
5687
- return false;
5688
- // Encoding reserved characters is not supported
5689
- return !array.some(item => item.includes($1ab22f2cd39b3061$var$array_item_delimiter) || item.includes($1ab22f2cd39b3061$var$string_item_delimiter) || item === $1ab22f2cd39b3061$var$empty_item_replacement);
5690
- }
5691
- /**
5692
- * Human readable string[] or string[][] serialization for URLs.
5693
- * @param array
5694
- * @returns
5695
- */
5696
- function $1ab22f2cd39b3061$var$encode_array(array) {
5697
- const is_nested = array.every(item => Array.isArray(item));
5698
- 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
5699
- return array.map(item => item === "" ? $1ab22f2cd39b3061$var$empty_item_replacement : item).join($1ab22f2cd39b3061$var$string_item_delimiter);
5700
- }
5701
- function $1ab22f2cd39b3061$var$decode_array(encoded_array) {
5702
- const is_nested = encoded_array.includes($1ab22f2cd39b3061$var$array_item_delimiter);
5703
- if (is_nested) return encoded_array.split($1ab22f2cd39b3061$var$array_item_delimiter).filter(s => s !== "") // Remove empty segments, caused by trailing delimiter
5704
- .map($1ab22f2cd39b3061$var$decode_array);
5705
- 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
5706
- .map(item => item === $1ab22f2cd39b3061$var$empty_item_replacement ? "" : item);
5707
- }
5708
- function $1ab22f2cd39b3061$var$encode_filter_data(op, data) {
5709
- if (data === "true")
5710
- // boolean encoding
5711
- return "1";
5712
- if (data === "false")
5713
- // boolean encoding
5714
- return "0";
5715
- const data_is_array = Array.isArray(data);
5716
- if (op === "inrange" && data_is_array && data.every(item => typeof item === "number"))
5717
- // numeric range filter encoding
5718
- return data.join($1ab22f2cd39b3061$var$range_delimiter);
5719
- if (data_is_array && $1ab22f2cd39b3061$var$array_is_serializable(data)) {
5720
- const encoded_data = $1ab22f2cd39b3061$var$encode_array(data);
5721
- if (!encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter) && !encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter))
5722
- // A string[] with only one item will encode without delimiters, which is indistinguishable from a plain string during decoding
5723
- // In that case we add a delimiter suffix at the end
5724
- return encoded_data + $1ab22f2cd39b3061$var$string_item_delimiter;
5725
- return encoded_data;
5726
- }
5727
- // Fallback encoding
5728
- return $gVhhF$depictaiutilishared.base64_encode_unicode(JSON.stringify(data));
5729
- }
5730
- function $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data) {
5731
- if (encoded_data === "1") return "true";
5732
- if (encoded_data === "0") return "false";
5733
- if (op === "inrange" && encoded_data.includes($1ab22f2cd39b3061$var$range_delimiter)) return encoded_data.split($1ab22f2cd39b3061$var$range_delimiter).map(x => parseFloat(x));
5734
- if (encoded_data.includes($1ab22f2cd39b3061$var$string_item_delimiter) || encoded_data.includes($1ab22f2cd39b3061$var$array_item_delimiter)) return $1ab22f2cd39b3061$var$decode_array(encoded_data);
5735
- try {
5736
- return JSON.parse($gVhhF$depictaiutilishared.base64_decode_unicode(encoded_data));
5737
- } catch (e) {
5738
- $gVhhF$depictaiutilishared.dlog("Failed to fallback parse filter data", op, encoded_data, e);
5739
- }
5740
- return null;
5741
- }
5742
- function $1ab22f2cd39b3061$export$58aa3f171519b6d7(filters, search_params, filter_query_param_prefix) {
5743
- for (const filter of filters) {
5744
- const {
5745
- field: field,
5746
- op: op,
5747
- data: data
5748
- } = filter;
5749
- const encoded_data = $1ab22f2cd39b3061$var$encode_filter_data(op, data);
5750
- search_params.set(filter_query_param_prefix + field + $1ab22f2cd39b3061$var$op_to_token(op), encoded_data);
5751
- }
5752
- }
5753
- function $1ab22f2cd39b3061$export$f934fa24c3a86811(search_params, filter_query_param_prefix) {
5754
- const found_filters = [];
5755
- for (const key of search_params.keys()) {
5756
- // Allow for backwards compatibility with the old filter query param prefix
5757
- let chosen_prefix = filter_query_param_prefix;
5758
- if (!key.startsWith(chosen_prefix)) {
5759
- chosen_prefix = $1ab22f2cd39b3061$var$legacy_filter_prefix;
5760
- if (!key.startsWith(chosen_prefix)) continue;
5761
- }
5762
- const encoded_data = search_params.get(key);
5763
- if (!encoded_data) continue;
5764
- const [op, token] = Object.entries($1ab22f2cd39b3061$var$operator_map).find(([, token]) => key.endsWith(token)) || [$1ab22f2cd39b3061$var$fallback_operator, $1ab22f2cd39b3061$var$fallback_token];
5765
- const data = $1ab22f2cd39b3061$var$decode_filter_data(op, encoded_data);
5766
- if (!data) continue;
5767
- const field = key.slice(chosen_prefix.length, token ? -token.length : undefined);
5768
- found_filters.push({
5769
- field: field,
5770
- op: op,
5771
- data: data
5772
- });
5773
- }
5774
- return found_filters;
5775
- }
5776
- function $1ab22f2cd39b3061$export$62acb285a7579555(sorting, search_params, sorting_query_param) {
5777
- if (!sorting) return;
5778
- const {
5779
- field: field,
5780
- order: order
5781
- } = sorting;
5782
- const ascending = order === "asc";
5783
- search_params.set(sorting_query_param, field + (ascending ? $1ab22f2cd39b3061$var$ascending_token : $1ab22f2cd39b3061$var$descending_token));
5784
- }
5785
- function $1ab22f2cd39b3061$export$766e9676e74997d3(search_params, sorting_query_param_) {
5786
- const encoded_sorting = search_params.get(sorting_query_param_);
5787
- if (!encoded_sorting) return;
5788
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$ascending_token)) return {
5789
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$ascending_token.length),
5790
- order: "asc"
5791
- };
5792
- if (encoded_sorting.endsWith($1ab22f2cd39b3061$var$descending_token)) return {
5793
- field: encoded_sorting.slice(0, -$1ab22f2cd39b3061$var$descending_token.length),
5794
- order: "desc"
5795
- };
5796
- $gVhhF$depictaiutilishared.dlog("Invalid sorting query param value", encoded_sorting);
5797
- return;
5798
- }
5799
- function $1ab22f2cd39b3061$export$916e6850778505f6(search_params, filter_query_param_prefix, sorting_query_param) {
5800
- // We'll be modifying the URLSearchParams object, so we need to make a copy of the keys first
5801
- const keys = [...search_params.keys()];
5802
- 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);
5803
- }
5804
- const $1ab22f2cd39b3061$export$cf5feb2102aec7f2 = "went_sideways_clear_filters";
5805
- function $1ab22f2cd39b3061$export$43cd1e747fecd42e({
5806
- to_url_: to_url_,
5807
- set_clearing_flag_: set_clearing_flag_,
5808
- from_search_params_ = new URLSearchParams(location.search),
5809
- sorting_query_param_: sorting_query_param_,
5810
- filter_query_param_prefix_: filter_query_param_prefix_
5811
- }) {
5812
- if (!to_url_) return to_url_;
5813
- const was_url_object = to_url_ instanceof URL;
5814
- const url_object = was_url_object ? to_url_ : new URL(to_url_, location.origin);
5815
- const {
5816
- searchParams: searchParams
5817
- } = url_object;
5818
- if (set_clearing_flag_) searchParams.set($1ab22f2cd39b3061$export$cf5feb2102aec7f2, "true");
5819
- if (from_search_params_.has(sorting_query_param_)) searchParams.set(sorting_query_param_, from_search_params_.get(sorting_query_param_));
5820
- for (const key of from_search_params_.keys()) if (key.startsWith(filter_query_param_prefix_)) searchParams.set(key, from_search_params_.get(key));
5821
- if (was_url_object) return url_object;
5822
- return url_object.href;
5823
- }
5824
5827
  const $e53b2e7e632ac4cb$var$_tmpl$ = /*#__PURE__*/$gVhhF$solidjsweb.template(`<nav class="crumbs"></nav>`, 2),
5825
5828
  $e53b2e7e632ac4cb$var$_tmpl$2 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<a class="crumb"></a>`, 2),
5826
5829
  $e53b2e7e632ac4cb$var$_tmpl$3 = /*#__PURE__*/$gVhhF$solidjsweb.template(`<span class="separator"></span>`, 2);
package/latest/index.d.ts CHANGED
@@ -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