@fluid-topics/ft-reader-search-in-document 1.1.1
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/ft-reader-search-in-document.css.d.ts +18 -0
- package/build/ft-reader-search-in-document.css.js +89 -0
- package/build/ft-reader-search-in-document.d.ts +26 -0
- package/build/ft-reader-search-in-document.js +124 -0
- package/build/ft-reader-search-in-document.light.js +1234 -0
- package/build/ft-reader-search-in-document.min.js +1364 -0
- package/build/ft-reader-search-in-document.properties.d.ts +2 -0
- package/build/ft-reader-search-in-document.properties.js +1 -0
- package/build/index.d.ts +3 -0
- package/build/index.js +6 -0
- package/package.json +27 -0
package/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
A search component to retreive occurences in documents
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ft-reader-search-in-document
|
|
7
|
+
yarn add @fluid-topics/ft-reader-search-in-document
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ft-reader-search-in-document"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ft-search-in-doc foo="bar"></ft-search-in-doc> `
|
|
18
|
+
}
|
|
19
|
+
```
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare const FtReaderSearchInDocumentCssVariables: {
|
|
2
|
+
searchFieldBackgroundColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
3
|
+
searchFieldBorderColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
4
|
+
searchFieldTextColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
5
|
+
searchFieldBorderRadius: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
6
|
+
resultsNumberColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
7
|
+
resultBackgroundColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
8
|
+
resultBorderColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
9
|
+
resultBorderRadius: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
10
|
+
resultTitleTextColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
11
|
+
resultBreadcrumbTextColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
12
|
+
resultContentTextColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
13
|
+
resultHighlightBackgroundColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
14
|
+
resultHoverBackgroundColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
15
|
+
resultHoverBorderColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
16
|
+
};
|
|
17
|
+
export declare const styles: import("lit").CSSResult;
|
|
18
|
+
export declare const resultStyles: import("lit").CSSResult;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { designSystemVariables, FtCssVariableFactory, setVariable } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtCardCssVariables } from "@fluid-topics/ft-card/build/ft-card.css";
|
|
4
|
+
import { FtSearchInputCssVariables } from "@fluid-topics/ft-search-input/build/ft-search-input.css";
|
|
5
|
+
import { FtSearchResultAbstractCssVariables } from "@fluid-topics/ft-search-result-abstract/build/ft-search-result-abstract.css";
|
|
6
|
+
import { FtRippleCssVariables } from "@fluid-topics/ft-ripple/build/ft-ripple.css";
|
|
7
|
+
import { FtSearchResultTitleCssVariables } from "@fluid-topics/ft-search-result-title/build/ft-search-result-title.css";
|
|
8
|
+
export const FtReaderSearchInDocumentCssVariables = {
|
|
9
|
+
searchFieldBackgroundColor: FtCssVariableFactory.extend("--ft-rsid-search-field-background-color", "", designSystemVariables.colorSurface),
|
|
10
|
+
searchFieldBorderColor: FtCssVariableFactory.extend("--ft-rsid-search-field-border-color", "", designSystemVariables.colorOutline),
|
|
11
|
+
searchFieldTextColor: FtCssVariableFactory.extend("--ft-rsid-search-field-text-color", "", designSystemVariables.colorOnSurface),
|
|
12
|
+
searchFieldBorderRadius: FtCssVariableFactory.extend("--ft-rsid-search-field-border-radius", "", designSystemVariables.borderRadiusS),
|
|
13
|
+
resultsNumberColor: FtCssVariableFactory.extend("--ft-rsid-results-number-color", "", designSystemVariables.colorOnSurfaceMedium),
|
|
14
|
+
resultBackgroundColor: FtCssVariableFactory.extend("--ft-rsid-result-background-color", "", designSystemVariables.colorSurface),
|
|
15
|
+
resultBorderColor: FtCssVariableFactory.extend("--ft-rsid-result-border-color", "", designSystemVariables.colorOutline),
|
|
16
|
+
resultBorderRadius: FtCssVariableFactory.extend("--ft-rsid-result-border-radius", "", designSystemVariables.borderRadiusS),
|
|
17
|
+
resultTitleTextColor: FtCssVariableFactory.extend("--ft-rsid-result-title-text-color", "", designSystemVariables.colorOnSurface),
|
|
18
|
+
resultBreadcrumbTextColor: FtCssVariableFactory.extend("--ft-rsid-result-breadcrumb-text-color", "", designSystemVariables.colorOnSurfaceMedium),
|
|
19
|
+
resultContentTextColor: FtCssVariableFactory.extend("--ft-rsid-result-content-text-color", "", designSystemVariables.colorOnSurface),
|
|
20
|
+
resultHighlightBackgroundColor: FtCssVariableFactory.create("--ft-rsid-result-highlight-background-color", "", "COLOR", "#FFF26E"),
|
|
21
|
+
resultHoverBackgroundColor: FtCssVariableFactory.extend("--ft-rsid-result-hover-background-color", "", designSystemVariables.colorPrimary),
|
|
22
|
+
resultHoverBorderColor: FtCssVariableFactory.extend("--ft-rsid-result-hover-border-color", "", designSystemVariables.colorPrimary),
|
|
23
|
+
};
|
|
24
|
+
// language=CSS
|
|
25
|
+
export const styles = css `
|
|
26
|
+
.ft-search-in-doc--container {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: 8px;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
ft-search-input {
|
|
33
|
+
${setVariable(FtSearchInputCssVariables.colorSurface, FtReaderSearchInDocumentCssVariables.searchFieldBackgroundColor)};
|
|
34
|
+
${setVariable(FtSearchInputCssVariables.colorOutline, FtReaderSearchInDocumentCssVariables.searchFieldBorderColor)};
|
|
35
|
+
${setVariable(FtSearchInputCssVariables.colorOnSurface, FtReaderSearchInDocumentCssVariables.searchFieldTextColor)};
|
|
36
|
+
${setVariable(FtSearchInputCssVariables.borderRadius, FtReaderSearchInDocumentCssVariables.searchFieldBorderRadius)};
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
ft-search-results-number {
|
|
40
|
+
margin-left: 12px;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ft-search-results-number, ft-search-results::part(no-results-message) {
|
|
44
|
+
color: ${FtReaderSearchInDocumentCssVariables.resultsNumberColor};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
ft-search-load-more-button {
|
|
48
|
+
margin: auto;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
// language=CSS
|
|
52
|
+
export const resultStyles = css `
|
|
53
|
+
ft-card {
|
|
54
|
+
margin-bottom: 8px;
|
|
55
|
+
${setVariable(FtCardCssVariables.elevation04, "none")};
|
|
56
|
+
${setVariable(FtCardCssVariables.elevation02, "none")};
|
|
57
|
+
${setVariable(FtCardCssVariables.borderStyle, "solid")};
|
|
58
|
+
${setVariable(FtCardCssVariables.borderRadius, designSystemVariables.borderRadiusS)};
|
|
59
|
+
${setVariable(FtCardCssVariables.colorSurface, FtReaderSearchInDocumentCssVariables.resultBackgroundColor)};
|
|
60
|
+
${setVariable(FtCardCssVariables.borderColor, FtReaderSearchInDocumentCssVariables.resultBorderColor)};
|
|
61
|
+
${setVariable(FtCardCssVariables.borderRadius, FtReaderSearchInDocumentCssVariables.resultBorderRadius)};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
ft-search-result-title {
|
|
65
|
+
color: ${FtReaderSearchInDocumentCssVariables.resultTitleTextColor};
|
|
66
|
+
${setVariable(FtSearchResultTitleCssVariables.highlightBackgroundColor, FtReaderSearchInDocumentCssVariables.resultHighlightBackgroundColor)};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.breadcrumb {
|
|
70
|
+
color: ${FtReaderSearchInDocumentCssVariables.resultBreadcrumbTextColor};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
ft-search-result-abstract {
|
|
74
|
+
color: ${FtReaderSearchInDocumentCssVariables.resultContentTextColor};
|
|
75
|
+
${setVariable(FtSearchResultAbstractCssVariables.highlightBackgroundColor, FtReaderSearchInDocumentCssVariables.resultHighlightBackgroundColor)};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
ft-card:hover {
|
|
79
|
+
${setVariable(FtCardCssVariables.hoverBorderColor, FtReaderSearchInDocumentCssVariables.resultHoverBorderColor)};
|
|
80
|
+
${setVariable(FtRippleCssVariables.color, FtReaderSearchInDocumentCssVariables.resultHoverBackgroundColor)};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.result-container {
|
|
84
|
+
display: flex;
|
|
85
|
+
flex-direction: column;
|
|
86
|
+
gap: 4px;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
`;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { nothing, PropertyValues, TemplateResult } from "lit";
|
|
2
|
+
import { ElementDefinitionsMap } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
import { FtReaderSearchInDocumentProperties } from "./ft-reader-search-in-document.properties";
|
|
4
|
+
import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
|
|
5
|
+
import { FtMap } from "@fluid-topics/public-api";
|
|
6
|
+
import "@fluid-topics/ft-card";
|
|
7
|
+
import "@fluid-topics/ft-search-result-title";
|
|
8
|
+
import "@fluid-topics/ft-search-result-abstract";
|
|
9
|
+
declare const FtReaderSearchInDocument_base: typeof FtReaderComponent & (new (...args: any[]) => import("@fluid-topics/ft-i18n").FtLitElementWithI18nInterface);
|
|
10
|
+
export declare class FtReaderSearchInDocument extends FtReaderSearchInDocument_base implements FtReaderSearchInDocumentProperties {
|
|
11
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
12
|
+
static styles: import("lit").CSSResult;
|
|
13
|
+
map?: FtMap;
|
|
14
|
+
private searchContext?;
|
|
15
|
+
private searchResults?;
|
|
16
|
+
private hideResultTitle;
|
|
17
|
+
private hideResultBreadcrumb;
|
|
18
|
+
private hideResultAbstract;
|
|
19
|
+
private hideResultsNumber;
|
|
20
|
+
private uniqueId;
|
|
21
|
+
private get filters();
|
|
22
|
+
private renderResult;
|
|
23
|
+
protected render(): typeof nothing | TemplateResult<1>;
|
|
24
|
+
protected update(props: PropertyValues): void;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,124 @@
|
|
|
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 { resultStyles, styles } from "./ft-reader-search-in-document.css";
|
|
10
|
+
import { FtButton } from "@fluid-topics/ft-button";
|
|
11
|
+
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
12
|
+
import { withI18n } from "@fluid-topics/ft-i18n";
|
|
13
|
+
import { FtSearchContext } from "@fluid-topics/ft-search-context";
|
|
14
|
+
import { FtReaderComponent } from "@fluid-topics/ft-reader-context/build/registration";
|
|
15
|
+
import { FtSearchResultsNumber } from "@fluid-topics/ft-search-results-number";
|
|
16
|
+
import { FtSearchInput } from "@fluid-topics/ft-search-input";
|
|
17
|
+
import { FtSearchResults } from "@fluid-topics/ft-search-results";
|
|
18
|
+
import "@fluid-topics/ft-card";
|
|
19
|
+
import "@fluid-topics/ft-search-result-title";
|
|
20
|
+
import "@fluid-topics/ft-search-result-abstract";
|
|
21
|
+
import { property, query } from "lit/decorators.js";
|
|
22
|
+
import { FtSearchLoadMoreButton } from "@fluid-topics/ft-search-load-more-button";
|
|
23
|
+
class FtReaderSearchInDocument extends withI18n(FtReaderComponent) {
|
|
24
|
+
constructor() {
|
|
25
|
+
super(...arguments);
|
|
26
|
+
this.hideResultTitle = false;
|
|
27
|
+
this.hideResultBreadcrumb = false;
|
|
28
|
+
this.hideResultAbstract = false;
|
|
29
|
+
this.hideResultsNumber = false;
|
|
30
|
+
this.uniqueId = "search-in-document-" + ("" + Math.round(Math.random() * 999000)).padStart(6, "0");
|
|
31
|
+
}
|
|
32
|
+
get filters() {
|
|
33
|
+
return [
|
|
34
|
+
{
|
|
35
|
+
negative: false,
|
|
36
|
+
key: "ft:publicationId",
|
|
37
|
+
values: [this.map.id]
|
|
38
|
+
}
|
|
39
|
+
];
|
|
40
|
+
}
|
|
41
|
+
renderResult(result) {
|
|
42
|
+
var _a;
|
|
43
|
+
return html `
|
|
44
|
+
<style> ${resultStyles}</style>
|
|
45
|
+
<ft-card clickable noheader>
|
|
46
|
+
<div class="result-container">
|
|
47
|
+
${this.hideResultTitle ? nothing : html `
|
|
48
|
+
<ft-search-result-title></ft-search-result-title>`}
|
|
49
|
+
${this.hideResultBreadcrumb ? nothing : html `
|
|
50
|
+
<ft-typography class="breadcrumb" variant="caption">${(_a = result.topic) === null || _a === void 0 ? void 0 : _a.breadcrumb.join(" > ")}</ft-typography>
|
|
51
|
+
`}
|
|
52
|
+
${this.hideResultAbstract ? nothing : html `
|
|
53
|
+
<ft-search-result-abstract></ft-search-result-abstract>
|
|
54
|
+
`}
|
|
55
|
+
</div>
|
|
56
|
+
</ft-card>
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
render() {
|
|
60
|
+
if (!this.map) {
|
|
61
|
+
return nothing;
|
|
62
|
+
}
|
|
63
|
+
return html `
|
|
64
|
+
<ft-search-context id="${this.uniqueId}"
|
|
65
|
+
contentLocale="${this.map.lang}"
|
|
66
|
+
.filters=${this.filters}
|
|
67
|
+
scope="ALL_TOPICS"
|
|
68
|
+
ignoreEmptyQuery>
|
|
69
|
+
<div class="ft-search-in-doc--container">
|
|
70
|
+
<ft-search-input></ft-search-input>
|
|
71
|
+
${this.hideResultsNumber ? nothing : html `
|
|
72
|
+
<ft-search-results-number></ft-search-results-number>
|
|
73
|
+
`}
|
|
74
|
+
<ft-search-results ?displayNoResultsMessage=${this.hideResultsNumber}
|
|
75
|
+
.renderResult=${(result) => this.renderResult(result)}></ft-search-results>
|
|
76
|
+
<slot name="load-more">
|
|
77
|
+
<ft-search-load-more-button></ft-search-load-more-button>
|
|
78
|
+
</slot>
|
|
79
|
+
</div>
|
|
80
|
+
</ft-search-context>
|
|
81
|
+
`;
|
|
82
|
+
}
|
|
83
|
+
update(props) {
|
|
84
|
+
super.update(props);
|
|
85
|
+
if (props.has("map") && this.searchContext) {
|
|
86
|
+
this.searchContext.clear();
|
|
87
|
+
}
|
|
88
|
+
if (["hideResultTitle", "hideResultBreadcrumb", "hideResultAbstract"].some(p => props.has(p)) && this.searchResults) {
|
|
89
|
+
this.searchResults.requestUpdate();
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
FtReaderSearchInDocument.elementDefinitions = {
|
|
94
|
+
"ft-button": FtButton,
|
|
95
|
+
"ft-typography": FtTypography,
|
|
96
|
+
"ft-search-context": FtSearchContext,
|
|
97
|
+
"ft-search-input": FtSearchInput,
|
|
98
|
+
"ft-search-results-number": FtSearchResultsNumber,
|
|
99
|
+
"ft-search-results": FtSearchResults,
|
|
100
|
+
"ft-search-load-more-button": FtSearchLoadMoreButton
|
|
101
|
+
};
|
|
102
|
+
FtReaderSearchInDocument.styles = styles;
|
|
103
|
+
__decorate([
|
|
104
|
+
redux()
|
|
105
|
+
], FtReaderSearchInDocument.prototype, "map", void 0);
|
|
106
|
+
__decorate([
|
|
107
|
+
query("ft-search-context")
|
|
108
|
+
], FtReaderSearchInDocument.prototype, "searchContext", void 0);
|
|
109
|
+
__decorate([
|
|
110
|
+
query("ft-search-results")
|
|
111
|
+
], FtReaderSearchInDocument.prototype, "searchResults", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
property({ type: Boolean })
|
|
114
|
+
], FtReaderSearchInDocument.prototype, "hideResultTitle", void 0);
|
|
115
|
+
__decorate([
|
|
116
|
+
property({ type: Boolean })
|
|
117
|
+
], FtReaderSearchInDocument.prototype, "hideResultBreadcrumb", void 0);
|
|
118
|
+
__decorate([
|
|
119
|
+
property({ type: Boolean })
|
|
120
|
+
], FtReaderSearchInDocument.prototype, "hideResultAbstract", void 0);
|
|
121
|
+
__decorate([
|
|
122
|
+
property({ type: Boolean })
|
|
123
|
+
], FtReaderSearchInDocument.prototype, "hideResultsNumber", void 0);
|
|
124
|
+
export { FtReaderSearchInDocument };
|