@fluid-topics/ft-search-language-filter 1.2.65
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/README.md +19 -0
- package/build/SearchLanguageFilterMessages.d.ts +6 -0
- package/build/SearchLanguageFilterMessages.js +5 -0
- package/build/ft-search-language-filter.d.ts +18 -0
- package/build/ft-search-language-filter.js +72 -0
- package/build/ft-search-language-filter.light.js +668 -0
- package/build/ft-search-language-filter.min.js +859 -0
- package/build/ft-search-language-filter.properties.d.ts +2 -0
- package/build/ft-search-language-filter.properties.js +1 -0
- package/build/ft-search-language-filter.styles.d.ts +2 -0
- package/build/ft-search-language-filter.styles.js +5 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +6 -0
- package/package.json +29 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Content language filter for integrated fluid-topics search pages
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ft-search-language-filter
|
|
7
|
+
yarn add @fluid-topics/ft-search-language-filter
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import {html} from "lit"
|
|
14
|
+
import "@fluid-topics/ft-search-language-filter"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ft-search-language-filter></ft-search-language-filter> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DefaultI18nMessages, I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n/build/generator/I18nMessageContext";
|
|
2
|
+
export interface SearchLanguageFilterMessages extends I18nMessages {
|
|
3
|
+
label(): string;
|
|
4
|
+
}
|
|
5
|
+
export declare const selectorContext: I18nMessageContext<SearchLanguageFilterMessages>;
|
|
6
|
+
export declare const selectorDefaultMessages: DefaultI18nMessages<SearchLanguageFilterMessages>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { nothing, PropertyValues } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtSearchLanguageFilterProperties } from "./ft-search-language-filter.properties";
|
|
4
|
+
import { FtSearchLocale } from "@fluid-topics/public-api";
|
|
5
|
+
import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
|
|
6
|
+
declare const FtSearchLanguageFilter_base: typeof FtSearchComponent & import("@fluid-topics/ft-wc-utils").Constructor<import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface>;
|
|
7
|
+
export declare class FtSearchLanguageFilter extends FtSearchLanguageFilter_base implements FtSearchLanguageFilterProperties {
|
|
8
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
9
|
+
static styles: import("lit").CSSResult;
|
|
10
|
+
locales?: Array<FtSearchLocale>;
|
|
11
|
+
currentSearchLocale?: string;
|
|
12
|
+
selectedSearchLocale?: string;
|
|
13
|
+
constructor();
|
|
14
|
+
protected render(): typeof nothing | import("lit-html").TemplateResult<1>;
|
|
15
|
+
private setContentLocale;
|
|
16
|
+
protected update(props: PropertyValues): void;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing } from "lit";
|
|
8
|
+
import { state } from "lit/decorators.js";
|
|
9
|
+
import { redux } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { styles } from "./ft-search-language-filter.styles";
|
|
11
|
+
import { repeat } from "lit/directives/repeat.js";
|
|
12
|
+
import { FtSelect, FtSelectOption } from "@fluid-topics/ft-select";
|
|
13
|
+
import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
|
|
14
|
+
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
15
|
+
import { selectorContext, selectorDefaultMessages } from "./SearchLanguageFilterMessages";
|
|
16
|
+
class FtSearchLanguageFilter extends withI18n(FtSearchComponent) {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
this.addI18nContext(selectorContext, selectorDefaultMessages);
|
|
20
|
+
}
|
|
21
|
+
render() {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
if (((_b = (_a = this.locales) === null || _a === void 0 ? void 0 : _a.length) !== null && _b !== void 0 ? _b : 0) <= 1) {
|
|
24
|
+
return nothing;
|
|
25
|
+
}
|
|
26
|
+
return html `
|
|
27
|
+
<div part="container">
|
|
28
|
+
<ft-select
|
|
29
|
+
aria-labelledby="language-filter-label"
|
|
30
|
+
outlined
|
|
31
|
+
@change=${(e) => this.setContentLocale(e)}>
|
|
32
|
+
${repeat(((_c = this.locales) !== null && _c !== void 0 ? _c : []), (locale) => locale.lang, (locale) => {
|
|
33
|
+
var _a;
|
|
34
|
+
return html `
|
|
35
|
+
<ft-select-option value="${(_a = locale.lang) !== null && _a !== void 0 ? _a : "all"}"
|
|
36
|
+
label="${locale.label}"
|
|
37
|
+
?selected=${locale.lang == this.selectedSearchLocale}
|
|
38
|
+
>
|
|
39
|
+
</ft-select-option>
|
|
40
|
+
`;
|
|
41
|
+
})}
|
|
42
|
+
</ft-select>
|
|
43
|
+
</div>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
setContentLocale(e) {
|
|
47
|
+
var _a;
|
|
48
|
+
this.selectedSearchLocale = (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setContentLocale(e.detail === "all" ? undefined : e.detail);
|
|
49
|
+
}
|
|
50
|
+
update(props) {
|
|
51
|
+
super.update(props);
|
|
52
|
+
if (props.has("currentSearchLocale")) {
|
|
53
|
+
this.selectedSearchLocale = this.currentSearchLocale;
|
|
54
|
+
this.dispatchEvent(new CustomEvent("current-search-locale-change", { detail: this.currentSearchLocale }));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
FtSearchLanguageFilter.elementDefinitions = {
|
|
59
|
+
"ft-select": FtSelect,
|
|
60
|
+
"ft-select-option": FtSelectOption,
|
|
61
|
+
};
|
|
62
|
+
FtSearchLanguageFilter.styles = styles;
|
|
63
|
+
__decorate([
|
|
64
|
+
redux({ store: "search" })
|
|
65
|
+
], FtSearchLanguageFilter.prototype, "locales", void 0);
|
|
66
|
+
__decorate([
|
|
67
|
+
redux({ store: "search", selector: (state) => state.request.contentLocale })
|
|
68
|
+
], FtSearchLanguageFilter.prototype, "currentSearchLocale", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
state()
|
|
71
|
+
], FtSearchLanguageFilter.prototype, "selectedSearchLocale", void 0);
|
|
72
|
+
export { FtSearchLanguageFilter };
|