@fluid-topics/ft-search-results-spellcheck 1.1.10 → 1.1.12
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,18 +1,16 @@
|
|
|
1
|
-
import { nothing
|
|
1
|
+
import { nothing } from "lit";
|
|
2
2
|
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { FtSearchResultsSpellcheckProperties } from "./ft-search-results-spellcheck.properties";
|
|
4
|
+
import { FtSearchRequest, FtSpellcheck } from "@fluid-topics/public-api";
|
|
4
5
|
import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
|
|
5
|
-
declare const FtSearchResultsSpellcheck_base: typeof FtSearchComponent &
|
|
6
|
+
declare const FtSearchResultsSpellcheck_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
6
7
|
export declare class FtSearchResultsSpellcheck extends FtSearchResultsSpellcheck_base implements FtSearchResultsSpellcheckProperties {
|
|
7
8
|
static elementDefinitions: ElementDefinitionsMap;
|
|
8
9
|
static styles: import("lit").CSSResult;
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
request?: FtSearchRequest;
|
|
12
|
+
autocorrect?: FtSpellcheck;
|
|
12
13
|
constructor();
|
|
13
|
-
getSpellcheckedUrl(newQuery: string): string;
|
|
14
|
-
protected update(props: PropertyValues): void;
|
|
15
|
-
renderSpellcheck(newQuery: string, oldQuery: string): import("lit").TemplateResult<1>;
|
|
16
14
|
protected render(): import("lit").TemplateResult<1> | typeof nothing;
|
|
17
15
|
}
|
|
18
16
|
export {};
|
|
@@ -5,58 +5,41 @@ 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 { redux, serializeRequest,
|
|
8
|
+
import { redux, serializeRequest, } from "@fluid-topics/ft-wc-utils";
|
|
9
9
|
import { styles } from "./ft-search-results-spellcheck.css";
|
|
10
10
|
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
11
11
|
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
12
12
|
import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
|
|
13
13
|
import { defaultSpellcheckMessages, spellcheck } from "./SpellcheckComponentMessages";
|
|
14
14
|
import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
|
|
15
|
-
class FtSearchResultsSpellcheck extends
|
|
15
|
+
class FtSearchResultsSpellcheck extends withI18n(FtSearchComponent) {
|
|
16
16
|
constructor() {
|
|
17
17
|
super();
|
|
18
|
-
this.editorMode = false;
|
|
19
18
|
this.addStore(ftAppInfoStore);
|
|
20
19
|
this.addI18nContext(spellcheck, defaultSpellcheckMessages);
|
|
21
20
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
renderSpellcheck(newQuery, oldQuery) {
|
|
33
|
-
return html `
|
|
34
|
-
<div class="ft-search-results-spellcheck--spellcheck">
|
|
35
|
-
<div>
|
|
36
|
-
<ft-typography variant="subtitle1">
|
|
37
|
-
${spellcheck.messages.resultsFor()}
|
|
38
|
-
</ft-typography>
|
|
39
|
-
<a href="${this.getSpellcheckedUrl(newQuery)}"
|
|
40
|
-
@click=${(e) => { var _a, _b; return (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setQuery((_b = this.autocorrect) === null || _b === void 0 ? void 0 : _b.suggestedQuery); }}>
|
|
41
|
-
<ft-typography variant="subtitle1" class="link ft-search-results-spellcheck--new-query">
|
|
42
|
-
${newQuery}
|
|
21
|
+
render() {
|
|
22
|
+
var _a;
|
|
23
|
+
if (this.autocorrect && this.request) {
|
|
24
|
+
const suggestedUrl = serializeRequest((_a = this.baseUrl) !== null && _a !== void 0 ? _a : "", { ...this.request, query: this.autocorrect.suggestedQuery });
|
|
25
|
+
return html `
|
|
26
|
+
<div class="ft-search-results-spellcheck--spellcheck">
|
|
27
|
+
<div>
|
|
28
|
+
<ft-typography variant="subtitle1">
|
|
29
|
+
${spellcheck.messages.resultsFor()}
|
|
43
30
|
</ft-typography>
|
|
44
|
-
|
|
45
|
-
|
|
31
|
+
<a href="${suggestedUrl}">
|
|
32
|
+
<ft-typography variant="subtitle1" class="link ft-search-results-spellcheck--new-query">
|
|
33
|
+
${this.autocorrect.suggestedQuery}
|
|
34
|
+
</ft-typography>
|
|
35
|
+
</a>
|
|
36
|
+
</div>
|
|
46
37
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
render() {
|
|
54
|
-
var _a, _b;
|
|
55
|
-
if (this.autocorrect) {
|
|
56
|
-
return this.renderSpellcheck((_a = this.autocorrect) === null || _a === void 0 ? void 0 : _a.suggestedQuery, (_b = this.request) === null || _b === void 0 ? void 0 : _b.query);
|
|
57
|
-
}
|
|
58
|
-
if (this.editorMode) {
|
|
59
|
-
return this.renderSpellcheck("new-query", "old-query");
|
|
38
|
+
<ft-typography variant="subtitle2" class="ft-search-results-spellcheck--old-query">
|
|
39
|
+
${spellcheck.messages.noResultsForQuery(this.request.query)}
|
|
40
|
+
</ft-typography>
|
|
41
|
+
</div>
|
|
42
|
+
`;
|
|
60
43
|
}
|
|
61
44
|
return nothing;
|
|
62
45
|
}
|
|
@@ -67,7 +50,7 @@ FtSearchResultsSpellcheck.elementDefinitions = {
|
|
|
67
50
|
FtSearchResultsSpellcheck.styles = styles;
|
|
68
51
|
__decorate([
|
|
69
52
|
redux({ store: ftAppInfoStore.name })
|
|
70
|
-
], FtSearchResultsSpellcheck.prototype, "
|
|
53
|
+
], FtSearchResultsSpellcheck.prototype, "baseUrl", void 0);
|
|
71
54
|
__decorate([
|
|
72
55
|
redux({ store: "search" })
|
|
73
56
|
], FtSearchResultsSpellcheck.prototype, "request", void 0);
|