@fluid-topics/ft-wc-utils 2.0.13 → 2.0.15
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.
|
@@ -24,6 +24,7 @@ export declare class ClusteringHelper {
|
|
|
24
24
|
private clusteringMetadata;
|
|
25
25
|
private metadataDescriptors;
|
|
26
26
|
constructor(allResults: Array<FtSearchResultClusterEntry>, selectedResult: FtSearchResultClusterEntry, clusteringMetadata: Set<string>, metadataDescriptors: Array<FtMetadataDescriptor>);
|
|
27
|
+
static findResultWithMetadataValue(results: FtSearchResultClusterEntry[], metadataKey: string, metadataValue: string): FtSearchResultClusterEntry | undefined;
|
|
27
28
|
static extractResultMetadata(options: Omit<ExtractResultMetadataOptions, "key">): FlatMetadata[];
|
|
28
29
|
static extractResultMetadata(options: ExtractResultMetadataOptions): Optional<FlatMetadata>;
|
|
29
30
|
static flattenMetadata(metadata: Optional<FtMetadata>[], hierarchicalValueTruncatingLevel?: number, dateFormatter?: ((value: string) => string)): FlatMetadata[];
|
|
@@ -12,6 +12,9 @@ export class ClusteringHelper {
|
|
|
12
12
|
this.clusteringMetadata = clusteringMetadata;
|
|
13
13
|
this.metadataDescriptors = metadataDescriptors;
|
|
14
14
|
}
|
|
15
|
+
static findResultWithMetadataValue(results, metadataKey, metadataValue) {
|
|
16
|
+
return results === null || results === void 0 ? void 0 : results.find((result) => { var _a; return ((_a = this.extractResultMetadata({ result }).find((meta) => meta.key == metadataKey)) === null || _a === void 0 ? void 0 : _a.value) == metadataValue; });
|
|
17
|
+
}
|
|
15
18
|
static extractResultMetadata(options) {
|
|
16
19
|
const metadata = accessResult(options.result).metadata;
|
|
17
20
|
if (options.key == null) {
|
|
@@ -42,4 +42,6 @@ export declare class SearchPlaceConverter {
|
|
|
42
42
|
private superEscapeFilters;
|
|
43
43
|
private unescapeFilterValue;
|
|
44
44
|
private parseLegacyPeriodFilter;
|
|
45
|
+
static clearSearchParamsInUrl(href: string): string;
|
|
46
|
+
static updateLocaleParamInUrl(href: string, locale?: string): string;
|
|
45
47
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FtDateFilterType, FtSearchKeywordMatch, isFtDateFilterType, isFtVirtualField } from "@fluid-topics/public-api";
|
|
1
|
+
import { FtDateFilterType, FtSearchKeywordMatch, isFtDateFilterType, isFtVirtualField, } from "@fluid-topics/public-api";
|
|
2
2
|
import { minmax } from "./helpers";
|
|
3
3
|
function quote(value) {
|
|
4
4
|
return `"${value}"`;
|
|
@@ -285,4 +285,26 @@ export class SearchPlaceConverter {
|
|
|
285
285
|
}
|
|
286
286
|
return [];
|
|
287
287
|
}
|
|
288
|
+
static clearSearchParamsInUrl(href) {
|
|
289
|
+
const url = new URL(href);
|
|
290
|
+
const paramsToClear = [
|
|
291
|
+
SearchPlaceQueryParams.LOCALE,
|
|
292
|
+
SearchPlaceQueryParams.FILTERS,
|
|
293
|
+
SearchPlaceQueryParams.VALUE_FILTERS,
|
|
294
|
+
SearchPlaceQueryParams.DATE_FILTERS,
|
|
295
|
+
SearchPlaceQueryParams.RANGE_FILTERS,
|
|
296
|
+
];
|
|
297
|
+
paramsToClear.forEach((param) => {
|
|
298
|
+
url.searchParams.delete(param);
|
|
299
|
+
});
|
|
300
|
+
return url.toString();
|
|
301
|
+
}
|
|
302
|
+
static updateLocaleParamInUrl(href, locale) {
|
|
303
|
+
const url = new URL(href);
|
|
304
|
+
url.searchParams.delete(SearchPlaceQueryParams.LOCALE);
|
|
305
|
+
if (locale !== undefined) {
|
|
306
|
+
url.searchParams.append(SearchPlaceQueryParams.LOCALE, locale);
|
|
307
|
+
}
|
|
308
|
+
return url.toString();
|
|
309
|
+
}
|
|
288
310
|
}
|