@fluid-topics/ft-search-results-spellcheck 1.1.113 → 1.1.115
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { nothing } from "lit";
|
|
1
|
+
import { nothing, PropertyValues } from "lit";
|
|
2
2
|
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtSearchResultsSpellcheckProperties } from "./ft-search-results-spellcheck.properties";
|
|
4
4
|
import { FtSearchRequest, FtSpellcheck } from "@fluid-topics/public-api";
|
|
@@ -10,7 +10,9 @@ export declare class FtSearchResultsSpellcheck extends FtSearchResultsSpellcheck
|
|
|
10
10
|
baseUrl?: string;
|
|
11
11
|
request?: FtSearchRequest;
|
|
12
12
|
autocorrect?: FtSpellcheck;
|
|
13
|
+
autocorrectLink?: string;
|
|
13
14
|
constructor();
|
|
14
15
|
protected render(): import("lit").TemplateResult<1> | typeof nothing;
|
|
16
|
+
protected update(props: PropertyValues): void;
|
|
15
17
|
}
|
|
16
18
|
export {};
|
|
@@ -5,7 +5,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
7
|
import { html, nothing, } from "lit";
|
|
8
|
-
import {
|
|
8
|
+
import { state } from "lit/decorators.js";
|
|
9
|
+
import { redux, SearchPlaceConverter, } from "@fluid-topics/ft-wc-utils";
|
|
9
10
|
import { styles } from "./ft-search-results-spellcheck.styles";
|
|
10
11
|
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
11
12
|
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
@@ -19,16 +20,14 @@ class FtSearchResultsSpellcheck extends withI18n(FtSearchComponent) {
|
|
|
19
20
|
this.addI18nContext(spellcheck, defaultSpellcheckMessages);
|
|
20
21
|
}
|
|
21
22
|
render() {
|
|
22
|
-
|
|
23
|
-
if (this.autocorrect && this.request) {
|
|
24
|
-
const suggestedUrl = serializeRequest((_a = this.baseUrl) !== null && _a !== void 0 ? _a : "", { ...this.request, query: this.autocorrect.suggestedQuery });
|
|
23
|
+
if (this.autocorrect && this.request && this.autocorrectLink) {
|
|
25
24
|
return html `
|
|
26
25
|
<div class="ft-search-results-spellcheck--spellcheck">
|
|
27
26
|
<div>
|
|
28
27
|
<ft-typography variant="subtitle1">
|
|
29
28
|
${spellcheck.messages.resultsFor()}
|
|
30
29
|
</ft-typography>
|
|
31
|
-
<a href="${
|
|
30
|
+
<a href="${this.autocorrectLink}">
|
|
32
31
|
<ft-typography variant="subtitle1" class="link ft-search-results-spellcheck--new-query">
|
|
33
32
|
${this.autocorrect.suggestedQuery}
|
|
34
33
|
</ft-typography>
|
|
@@ -43,6 +42,13 @@ class FtSearchResultsSpellcheck extends withI18n(FtSearchComponent) {
|
|
|
43
42
|
}
|
|
44
43
|
return nothing;
|
|
45
44
|
}
|
|
45
|
+
update(props) {
|
|
46
|
+
super.update(props);
|
|
47
|
+
if (["baseUrl", "request", "autocorrect"].some(k => props.has(k))
|
|
48
|
+
&& this.baseUrl && this.request && this.autocorrect) {
|
|
49
|
+
this.autocorrectLink = new SearchPlaceConverter(this.baseUrl, {}).serialize({ ...this.request, query: this.autocorrect.suggestedQuery });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
46
52
|
}
|
|
47
53
|
FtSearchResultsSpellcheck.elementDefinitions = {
|
|
48
54
|
"ft-typography": FtTypography
|
|
@@ -57,4 +63,7 @@ __decorate([
|
|
|
57
63
|
__decorate([
|
|
58
64
|
redux({ store: "search", selector: (s) => s.spellcheck })
|
|
59
65
|
], FtSearchResultsSpellcheck.prototype, "autocorrect", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
state()
|
|
68
|
+
], FtSearchResultsSpellcheck.prototype, "autocorrectLink", void 0);
|
|
60
69
|
export { FtSearchResultsSpellcheck };
|