@fluid-topics/ft-search-facet 0.3.62

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 ADDED
@@ -0,0 +1,21 @@
1
+ Search facet for integrated search component
2
+
3
+ ## Install
4
+
5
+ ```shell
6
+ npm install @fluid-topics/ft-search-facet
7
+ yarn add @fluid-topics/ft-search-facet
8
+ ```
9
+
10
+ ## Usage
11
+
12
+ ```typescript
13
+ import { html } from "lit"
14
+ import "@fluid-topics/ft-search-facet"
15
+
16
+ function render() {
17
+ return html`<ft-search-context>
18
+ <ft-search-facet facetId="author"></ft-search-facet>
19
+ </ft-search-context>`
20
+ }
21
+ ```
@@ -0,0 +1,10 @@
1
+ import { I18nMessageContext, I18nMessages } from "@fluid-topics/ft-i18n";
2
+ export interface SearchFacetMessages extends I18nMessages {
3
+ filterInputPlaceHolder(label: string): string;
4
+ clearFilterButton(): string;
5
+ displayMoreFilterValuesButton(): string;
6
+ noFilterValuesAvailable(): string;
7
+ noMetadataSelected(): string;
8
+ }
9
+ export declare const searchFacetContext: I18nMessageContext<SearchFacetMessages>;
10
+ //# sourceMappingURL=SearchFacetMessages.d.ts.map
@@ -0,0 +1,3 @@
1
+ import { I18nMessageContext } from "@fluid-topics/ft-i18n";
2
+ export const searchFacetContext = I18nMessageContext.build("designedSearchFacet");
3
+ //# sourceMappingURL=SearchFacetMessages.js.map
@@ -0,0 +1,4 @@
1
+ import { FtSearchFacet } from "@fluid-topics/public-api/dist/mjs/types/ft-common/public";
2
+ import { FtFilterOptionProperties } from "@fluid-topics/ft-filter";
3
+ export declare function convertFacetToFilterOptions(facet: FtSearchFacet): Array<FtFilterOptionProperties>;
4
+ //# sourceMappingURL=converter.d.ts.map
@@ -0,0 +1,12 @@
1
+ export function convertFacetToFilterOptions(facet) {
2
+ return facet.rootNodes.map(node => convertFacetNodeToFilterOptions(node));
3
+ }
4
+ function convertFacetNodeToFilterOptions(facetNode) {
5
+ return {
6
+ label: facetNode.label,
7
+ value: facetNode.value,
8
+ selected: facetNode.selected,
9
+ subOptions: facetNode.childNodes.map(node => convertFacetNodeToFilterOptions(node)),
10
+ };
11
+ }
12
+ //# sourceMappingURL=converter.js.map
@@ -0,0 +1,3 @@
1
+ export declare const FtSearchFacetCssVariables: {};
2
+ export declare const styles: import("lit").CSSResult;
3
+ //# sourceMappingURL=ft-search-facet.css.d.ts.map
@@ -0,0 +1,6 @@
1
+ import { css } from "lit";
2
+ export const FtSearchFacetCssVariables = {};
3
+ // language=CSS
4
+ export const styles = css `
5
+ `;
6
+ //# sourceMappingURL=ft-search-facet.css.js.map
@@ -0,0 +1,20 @@
1
+ import { nothing, PropertyValues } from "lit";
2
+ import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
3
+ import { FtSearchFacetProperties } from "./ft-search-facet.properties";
4
+ import { FtSearchComponent, FtSearchStateManager } from "@fluid-topics/ft-search-context/build/registration";
5
+ declare const FtSearchFacet_base: typeof FtSearchComponent & (new (...args: any[]) => import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface);
6
+ export declare class FtSearchFacet extends FtSearchFacet_base implements FtSearchFacetProperties {
7
+ static elementDefinitions: ElementDefinitionsMap;
8
+ static styles: import("lit").CSSResult;
9
+ facetId: string;
10
+ maxValues: number;
11
+ private request?;
12
+ private facets;
13
+ private editorMode?;
14
+ setSearchStateManager(stateManager: FtSearchStateManager): void;
15
+ protected render(): import("lit-html").TemplateResult<1> | typeof nothing;
16
+ protected updated(props: PropertyValues): void;
17
+ private onFacetValueSelected;
18
+ }
19
+ export {};
20
+ //# sourceMappingURL=ft-search-facet.d.ts.map
@@ -0,0 +1,93 @@
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 { redux } from "@fluid-topics/ft-wc-utils";
9
+ import { property } from "lit/decorators.js";
10
+ import { styles } from "./ft-search-facet.css";
11
+ import { FtFilter } from "@fluid-topics/ft-filter";
12
+ import { FtSearchComponent } from "@fluid-topics/ft-search-context/build/registration";
13
+ import { convertFacetToFilterOptions } from "./converter";
14
+ import { FtTypography } from "@fluid-topics/ft-typography";
15
+ import { withI18n } from "@fluid-topics/ft-i18n";
16
+ import { searchFacetContext } from "./SearchFacetMessages";
17
+ import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
18
+ export class FtSearchFacet extends withI18n(FtSearchComponent) {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.facetId = "";
22
+ this.maxValues = 7;
23
+ this.facets = [];
24
+ }
25
+ setSearchStateManager(stateManager) {
26
+ super.setSearchStateManager(stateManager);
27
+ if (this.facetId) {
28
+ stateManager.addFacet(this.facetId);
29
+ }
30
+ this.addI18nContext(searchFacetContext);
31
+ this.addStore(ftAppInfoStore);
32
+ }
33
+ render() {
34
+ let facet = this.facets.find(f => f.key == this.facetId);
35
+ if (facet) {
36
+ return html `
37
+ <div class="ft-search-facet--label">
38
+ <ft-typography variant="button">${facet.label}</ft-typography>
39
+ </div>
40
+ <ft-filter
41
+ part="filter"
42
+ .exportpartsPrefixes=${["filter"]}
43
+ id="${this.facetId}"
44
+ ?multivalued=${facet.multiSelectionable}
45
+ raiseSelectedOptions
46
+ .options=${convertFacetToFilterOptions(facet)}
47
+ .displayedValuesLimit=${this.maxValues}
48
+ filterPlaceHolder="${searchFacetContext.messages.filterInputPlaceHolder(facet.label)}"
49
+ clearButtonLabel="${searchFacetContext.messages.clearFilterButton()}"
50
+ moreValuesButtonLabel="${searchFacetContext.messages.displayMoreFilterValuesButton()}"
51
+ noValuesLabel="${searchFacetContext.messages.noFilterValuesAvailable()}"
52
+ @change=${this.onFacetValueSelected}
53
+ ></ft-filter>
54
+ `;
55
+ }
56
+ if (!this.facetId && this.editorMode) {
57
+ return html `${searchFacetContext.messages.noMetadataSelected()}`;
58
+ }
59
+ return nothing;
60
+ }
61
+ updated(props) {
62
+ var _a;
63
+ super.updated(props);
64
+ if (props.has("facetId")) {
65
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.replaceFacet(props.get("facetId"), this.facetId);
66
+ }
67
+ }
68
+ onFacetValueSelected(event) {
69
+ var _a;
70
+ (_a = this.stateManager) === null || _a === void 0 ? void 0 : _a.setFilter(this.facetId, event.detail);
71
+ }
72
+ }
73
+ FtSearchFacet.elementDefinitions = {
74
+ "ft-filter": FtFilter,
75
+ "ft-typography": FtTypography,
76
+ };
77
+ FtSearchFacet.styles = styles;
78
+ __decorate([
79
+ property()
80
+ ], FtSearchFacet.prototype, "facetId", void 0);
81
+ __decorate([
82
+ property({ type: Number })
83
+ ], FtSearchFacet.prototype, "maxValues", void 0);
84
+ __decorate([
85
+ redux({ store: "search" })
86
+ ], FtSearchFacet.prototype, "request", void 0);
87
+ __decorate([
88
+ redux({ store: "search" })
89
+ ], FtSearchFacet.prototype, "facets", void 0);
90
+ __decorate([
91
+ redux({ store: ftAppInfoStore.name })
92
+ ], FtSearchFacet.prototype, "editorMode", void 0);
93
+ //# sourceMappingURL=ft-search-facet.js.map