@fluid-topics/ft-search-context 2.0.16 → 2.0.17
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/build/ft-search-context.light.js +6 -6
- package/build/ft-search-context.min.js +14 -14
- package/build/store/FtSearchStateManager.d.ts +5 -4
- package/build/store/FtSearchStateManager.js +50 -38
- package/build/store/redux.d.ts +0 -26
- package/build/store/redux.js +1 -43
- package/build/utils.d.ts +2 -1
- package/package.json +4 -4
|
@@ -18,6 +18,7 @@ export declare class FtSearchStateManager extends FtStateManager {
|
|
|
18
18
|
constructor(store: FtReduxStore<FtSearchPageState, FtSearchPageStateReducers>, service?: FtSearchService);
|
|
19
19
|
onNewNeededRequest: (neededRequest: string) => void;
|
|
20
20
|
initService(): Promise<boolean>;
|
|
21
|
+
private updateSearchRequest;
|
|
21
22
|
setQuery(query: string): void;
|
|
22
23
|
setContentLocale(contentLocale?: string): string | undefined;
|
|
23
24
|
forceContentLocale(contentLocale?: string): void;
|
|
@@ -25,11 +26,11 @@ export declare class FtSearchStateManager extends FtStateManager {
|
|
|
25
26
|
setPageNumber(pageNumber: number): void;
|
|
26
27
|
get sortOptions(): import("@fluid-topics/public-api").FtSearchSortOption[];
|
|
27
28
|
setSort(sort: FtSearchSortCriterion[]): void;
|
|
28
|
-
setSortId(sortId?: string): string | undefined;
|
|
29
|
+
setSortId(sortId?: string, automaticallyChangedByConfiguraiton?: boolean): string | undefined;
|
|
29
30
|
setFilters(filters: FtMetadataFilter[]): void;
|
|
30
|
-
setClusterSortCriterion(
|
|
31
|
+
setClusterSortCriterion(clusterSortCriterions: FtPublicClusterSortCriterion[]): void;
|
|
31
32
|
setSearchInDocumentTitlesOnly(searchInDocumentTitleOnly: boolean): void;
|
|
32
|
-
setKeywordMatch(
|
|
33
|
+
setKeywordMatch(keywordMatch?: FtSearchKeywordMatch): void;
|
|
33
34
|
setVirtualField(virtualField: FtVirtualField): void;
|
|
34
35
|
get searchInDocumentTitlesOnly(): boolean;
|
|
35
36
|
get keywordMatch(): boolean;
|
|
@@ -48,7 +49,7 @@ export declare class FtSearchStateManager extends FtStateManager {
|
|
|
48
49
|
setLiveQuery(query: string): void;
|
|
49
50
|
setRequest(request: FtSearchRequest): void;
|
|
50
51
|
setScope(scope: FtSearchScope): void;
|
|
51
|
-
setOtherQueryParams(
|
|
52
|
+
setOtherQueryParams(otherQueryParams: Record<string, string>): void;
|
|
52
53
|
setIgnoreEmptyQuery(ignoreEmptyQuery: boolean): void;
|
|
53
54
|
setOpenExternalDocumentInNewTab(openExternalDocumentInNewTab: boolean): void;
|
|
54
55
|
setCanUpdateUiLocale(canUpdateUiLocale: boolean): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FtSearchStateResourceRequest, } from "./model";
|
|
2
|
-
import { cancelable, CanceledPromiseError, Debouncer, FtStateManager, watch, } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { cancelable, CanceledPromiseError, Debouncer, deepCopy, FtStateManager, minmax, watch, } from "@fluid-topics/ft-wc-utils";
|
|
3
3
|
import { createSearchPageStore, } from "./redux";
|
|
4
4
|
import { FtSearchKeywordMatch, FtSearchScope, FtVirtualField, } from "@fluid-topics/public-api";
|
|
5
5
|
import { FtSearchService } from "./utils/FtSearchService";
|
|
@@ -67,10 +67,20 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
67
67
|
});
|
|
68
68
|
return this.launchSearch();
|
|
69
69
|
}
|
|
70
|
+
updateSearchRequest(partialRequest, resetPaging = false) {
|
|
71
|
+
const request = deepCopy(this.store.getState().request);
|
|
72
|
+
delete request.changedByConfiguration;
|
|
73
|
+
this.store.actions.setRequest({
|
|
74
|
+
...request,
|
|
75
|
+
paging: {
|
|
76
|
+
perPage: request.paging.perPage,
|
|
77
|
+
page: resetPaging ? 1 : request.paging.page,
|
|
78
|
+
},
|
|
79
|
+
...partialRequest,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
70
82
|
setQuery(query) {
|
|
71
|
-
this.
|
|
72
|
-
this.store.actions.liveQuery(query);
|
|
73
|
-
this.store.actions.setPageNumber(1);
|
|
83
|
+
this.updateSearchRequest({ query }, true);
|
|
74
84
|
}
|
|
75
85
|
setContentLocale(contentLocale) {
|
|
76
86
|
var _a, _b;
|
|
@@ -83,9 +93,7 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
83
93
|
contentLocale = isKnown(previousContentLocale) ? previousContentLocale : locales[0].lang;
|
|
84
94
|
}
|
|
85
95
|
}
|
|
86
|
-
this.
|
|
87
|
-
this.store.actions.setPageNumber(1);
|
|
88
|
-
this.store.actions.setRequestFilters([]);
|
|
96
|
+
this.updateSearchRequest({ contentLocale, metadataFilters: [] }, true);
|
|
89
97
|
if (this.canUpdateUiLocale && ((_b = ftAppStateManager.localesConfiguration) === null || _b === void 0 ? void 0 : _b.searchLanguageSetsUiLanguage) && contentLocale) {
|
|
90
98
|
ftAppStateManager.requestUiLocaleUpdate(contentLocale);
|
|
91
99
|
}
|
|
@@ -93,58 +101,64 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
93
101
|
return contentLocale;
|
|
94
102
|
}
|
|
95
103
|
forceContentLocale(contentLocale) {
|
|
96
|
-
this.
|
|
104
|
+
this.updateSearchRequest({ contentLocale });
|
|
97
105
|
}
|
|
98
106
|
setPageSize(pageSize) {
|
|
99
|
-
this.store.
|
|
107
|
+
const request = this.store.getState().request;
|
|
108
|
+
this.updateSearchRequest({
|
|
109
|
+
paging: {
|
|
110
|
+
...request.paging,
|
|
111
|
+
perPage: isNaN(pageSize) ? 20 : minmax(1, pageSize, 1000),
|
|
112
|
+
},
|
|
113
|
+
});
|
|
100
114
|
}
|
|
101
115
|
setPageNumber(pageNumber) {
|
|
102
|
-
this.store.
|
|
116
|
+
const request = this.store.getState().request;
|
|
117
|
+
this.updateSearchRequest({
|
|
118
|
+
paging: {
|
|
119
|
+
...request.paging,
|
|
120
|
+
page: isNaN(pageNumber) ? 1 : Math.max(1, pageNumber),
|
|
121
|
+
},
|
|
122
|
+
});
|
|
103
123
|
}
|
|
104
124
|
get sortOptions() {
|
|
105
125
|
var _a, _b;
|
|
106
126
|
return (_b = (_a = this.store.getState().configuration) === null || _a === void 0 ? void 0 : _a.sortOptions) !== null && _b !== void 0 ? _b : [];
|
|
107
127
|
}
|
|
108
128
|
setSort(sort) {
|
|
109
|
-
this.
|
|
110
|
-
this.store.actions.setPageNumber(1);
|
|
129
|
+
this.updateSearchRequest({ sort }, true);
|
|
111
130
|
}
|
|
112
|
-
setSortId(sortId) {
|
|
131
|
+
setSortId(sortId, automaticallyChangedByConfiguraiton = false) {
|
|
113
132
|
var _a;
|
|
114
|
-
|
|
133
|
+
const changedByConfiguration = automaticallyChangedByConfiguraiton ? { changedByConfiguration: true } : {};
|
|
115
134
|
if (sortId == undefined || this.sortOptions.length == 0) {
|
|
116
|
-
this.
|
|
135
|
+
this.updateSearchRequest({ sortId: sortId, ...changedByConfiguration }, true);
|
|
117
136
|
return sortId;
|
|
118
137
|
}
|
|
119
138
|
const selectedSort = (_a = this.sortOptions.find((option) => option.id == sortId)) !== null && _a !== void 0 ? _a : this.sortOptions[0];
|
|
120
|
-
this.
|
|
139
|
+
this.updateSearchRequest({ sortId: selectedSort.id, ...changedByConfiguration }, true);
|
|
121
140
|
return selectedSort.id;
|
|
122
141
|
}
|
|
123
142
|
setFilters(filters) {
|
|
124
143
|
const cleanFilters = filters.filter((f) => !f.valueFilter || f.valueFilter.values.length > 0);
|
|
125
|
-
this.
|
|
126
|
-
this.store.actions.setPageNumber(1);
|
|
144
|
+
this.updateSearchRequest({ metadataFilters: cleanFilters }, true);
|
|
127
145
|
}
|
|
128
|
-
setClusterSortCriterion(
|
|
129
|
-
this.
|
|
146
|
+
setClusterSortCriterion(clusterSortCriterions) {
|
|
147
|
+
this.updateSearchRequest({ clusterSortCriterions });
|
|
130
148
|
}
|
|
131
149
|
setSearchInDocumentTitlesOnly(searchInDocumentTitleOnly) {
|
|
132
150
|
if (searchInDocumentTitleOnly) {
|
|
133
|
-
this.
|
|
134
|
-
this.store.actions.setRequestScope(FtSearchScope.DOCUMENTS);
|
|
151
|
+
this.updateSearchRequest({ virtualField: FtVirtualField.TITLE_ONLY, scope: FtSearchScope.DOCUMENTS }, true);
|
|
135
152
|
}
|
|
136
153
|
else {
|
|
137
|
-
this.
|
|
138
|
-
this.store.actions.setRequestScope(FtSearchScope.DEFAULT);
|
|
154
|
+
this.updateSearchRequest({ virtualField: FtVirtualField.EVERYWHERE, scope: FtSearchScope.DEFAULT }, true);
|
|
139
155
|
}
|
|
140
|
-
this.store.actions.setPageNumber(1);
|
|
141
156
|
}
|
|
142
|
-
setKeywordMatch(
|
|
143
|
-
this.
|
|
144
|
-
this.store.actions.setPageNumber(1);
|
|
157
|
+
setKeywordMatch(keywordMatch) {
|
|
158
|
+
this.updateSearchRequest({ keywordMatch }, true);
|
|
145
159
|
}
|
|
146
160
|
setVirtualField(virtualField) {
|
|
147
|
-
this.
|
|
161
|
+
this.updateSearchRequest({ virtualField }, true);
|
|
148
162
|
}
|
|
149
163
|
get searchInDocumentTitlesOnly() {
|
|
150
164
|
return searchInDocumentTitlesOnlySelector(this.store.getState());
|
|
@@ -179,8 +193,8 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
179
193
|
}
|
|
180
194
|
set facetIds(ids) {
|
|
181
195
|
const uniqIds = [...new Set(ids)];
|
|
182
|
-
const
|
|
183
|
-
this.
|
|
196
|
+
const facets = uniqIds.map((id) => ({ id: id }));
|
|
197
|
+
this.updateSearchRequest({ facets });
|
|
184
198
|
}
|
|
185
199
|
/** @deprecated */
|
|
186
200
|
setFilter(key, values) {
|
|
@@ -253,18 +267,16 @@ export class FtSearchStateManager extends FtStateManager {
|
|
|
253
267
|
this.store.actions.liveQuery(query);
|
|
254
268
|
}
|
|
255
269
|
setRequest(request) {
|
|
256
|
-
this.
|
|
270
|
+
this.updateSearchRequest({
|
|
257
271
|
...request,
|
|
258
272
|
facets: this.store.getState().request.facets,
|
|
259
|
-
});
|
|
260
|
-
this.store.actions.liveQuery(request.query);
|
|
261
|
-
this.store.actions.setPageNumber(1);
|
|
273
|
+
}, true);
|
|
262
274
|
}
|
|
263
275
|
setScope(scope) {
|
|
264
|
-
this.
|
|
276
|
+
this.updateSearchRequest({ scope });
|
|
265
277
|
}
|
|
266
|
-
setOtherQueryParams(
|
|
267
|
-
this.
|
|
278
|
+
setOtherQueryParams(otherQueryParams) {
|
|
279
|
+
this.updateSearchRequest({ otherQueryParams });
|
|
268
280
|
}
|
|
269
281
|
setIgnoreEmptyQuery(ignoreEmptyQuery) {
|
|
270
282
|
this.ignoreEmptyQuery = ignoreEmptyQuery;
|
package/build/store/redux.d.ts
CHANGED
|
@@ -3,35 +3,9 @@ import { FtSearchPageState } from "./model";
|
|
|
3
3
|
import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
|
|
4
4
|
declare const searchPageStateReducers: {
|
|
5
5
|
setRequest: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]>) => void;
|
|
6
|
-
setRequestQuery: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["query"]>) => void;
|
|
7
|
-
setRequestContentLocale: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["contentLocale"]>) => void;
|
|
8
|
-
setPageSize: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["perPage"]>) => void;
|
|
9
|
-
setPageNumber: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["page"]>) => void;
|
|
10
|
-
setRequestSort: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sort"]>) => void;
|
|
11
|
-
setRequestSortId: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sortId"]>) => void;
|
|
12
|
-
setRequestFilters: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["metadataFilters"]>) => void;
|
|
13
|
-
setRequestFacets: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["facets"]>) => void;
|
|
14
|
-
setRequestVirtualField: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["virtualField"]>) => void;
|
|
15
|
-
setRequestScope: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["scope"]>) => void;
|
|
16
|
-
setOtherQueryParams: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["otherQueryParams"]>) => void;
|
|
17
|
-
setRequestClusterSortCriterion: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["clusterSortCriterions"]>) => void;
|
|
18
|
-
setKeywordMatch: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["keywordMatch"]>) => void;
|
|
19
6
|
};
|
|
20
7
|
export type FtSearchPageStateReducers = typeof searchPageStateReducers;
|
|
21
8
|
export declare const createSearchPageStore: (id: string) => FtReduxStore<FtSearchPageState, {
|
|
22
9
|
setRequest: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]>) => void;
|
|
23
|
-
setRequestQuery: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["query"]>) => void;
|
|
24
|
-
setRequestContentLocale: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["contentLocale"]>) => void;
|
|
25
|
-
setPageSize: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["perPage"]>) => void;
|
|
26
|
-
setPageNumber: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["paging"]["page"]>) => void;
|
|
27
|
-
setRequestSort: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sort"]>) => void;
|
|
28
|
-
setRequestSortId: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["sortId"]>) => void;
|
|
29
|
-
setRequestFilters: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["metadataFilters"]>) => void;
|
|
30
|
-
setRequestFacets: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["facets"]>) => void;
|
|
31
|
-
setRequestVirtualField: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["virtualField"]>) => void;
|
|
32
|
-
setRequestScope: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["scope"]>) => void;
|
|
33
|
-
setOtherQueryParams: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["otherQueryParams"]>) => void;
|
|
34
|
-
setRequestClusterSortCriterion: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["clusterSortCriterions"]>) => void;
|
|
35
|
-
setKeywordMatch: (state: FtSearchPageState, action: PayloadAction<FtSearchPageState["request"]["keywordMatch"]>) => void;
|
|
36
10
|
}, import("redux").AnyAction>;
|
|
37
11
|
export {};
|
package/build/store/redux.js
CHANGED
|
@@ -1,50 +1,8 @@
|
|
|
1
|
-
import { FtReduxStore
|
|
1
|
+
import { FtReduxStore } from "@fluid-topics/ft-wc-utils";
|
|
2
2
|
const searchPageStateReducers = {
|
|
3
3
|
setRequest: (state, action) => {
|
|
4
4
|
state.request = action.payload;
|
|
5
5
|
},
|
|
6
|
-
setRequestQuery: (state, action) => {
|
|
7
|
-
state.request.query = action.payload;
|
|
8
|
-
},
|
|
9
|
-
setRequestContentLocale: (state, action) => {
|
|
10
|
-
state.request.contentLocale = action.payload;
|
|
11
|
-
},
|
|
12
|
-
setPageSize: (state, action) => {
|
|
13
|
-
var _a;
|
|
14
|
-
const perPage = +((_a = action.payload) !== null && _a !== void 0 ? _a : 20);
|
|
15
|
-
state.request.paging.perPage = isNaN(perPage) ? 20 : minmax(1, perPage, 1000);
|
|
16
|
-
},
|
|
17
|
-
setPageNumber: (state, action) => {
|
|
18
|
-
state.request.paging.page = isNaN(action.payload) ? 1 : Math.max(1, action.payload);
|
|
19
|
-
},
|
|
20
|
-
setRequestSort: (state, action) => {
|
|
21
|
-
state.request.sort = action.payload;
|
|
22
|
-
},
|
|
23
|
-
setRequestSortId: (state, action) => {
|
|
24
|
-
state.request.sortId = action.payload;
|
|
25
|
-
},
|
|
26
|
-
setRequestFilters: (state, action) => {
|
|
27
|
-
state.request.metadataFilters = action.payload;
|
|
28
|
-
},
|
|
29
|
-
setRequestFacets: (state, action) => {
|
|
30
|
-
state.request.facets = action.payload;
|
|
31
|
-
},
|
|
32
|
-
setRequestVirtualField: (state, action) => {
|
|
33
|
-
state.request.virtualField = action.payload;
|
|
34
|
-
},
|
|
35
|
-
setRequestScope: (state, action) => {
|
|
36
|
-
state.request.scope = action.payload;
|
|
37
|
-
},
|
|
38
|
-
setOtherQueryParams: (state, action) => {
|
|
39
|
-
state.request.otherQueryParams = action.payload;
|
|
40
|
-
},
|
|
41
|
-
setRequestClusterSortCriterion: (state, action) => {
|
|
42
|
-
var _a;
|
|
43
|
-
state.request.clusterSortCriterions = (_a = action.payload) !== null && _a !== void 0 ? _a : [];
|
|
44
|
-
},
|
|
45
|
-
setKeywordMatch: (state, action) => {
|
|
46
|
-
state.request.keywordMatch = action.payload;
|
|
47
|
-
},
|
|
48
6
|
};
|
|
49
7
|
export const createSearchPageStore = (id) => FtReduxStore.get({
|
|
50
8
|
name: "ft-search-" + id,
|
package/build/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { FtSearchRequest, FtSearchResultClusterEntry, FtSearchResultsPageInfo, FtSpellcheck } from "@fluid-topics/public-api";
|
|
2
2
|
import { FtSearchResultsChangeEventDetail } from "./store/model";
|
|
3
|
+
import { EnrichedFtSearchRequest } from "@fluid-topics/ft-wc-utils";
|
|
3
4
|
export declare class SearchResultClickEvent extends CustomEvent<{
|
|
4
5
|
result: FtSearchResultClusterEntry;
|
|
5
6
|
rank: number;
|
|
@@ -15,7 +16,7 @@ export declare class SearchResultOpenContextMenuEvent extends CustomEvent<{
|
|
|
15
16
|
export declare class LoadErrorEvent extends CustomEvent<Error> {
|
|
16
17
|
constructor(e: Error);
|
|
17
18
|
}
|
|
18
|
-
export declare class SearchRequestChangeEvent extends CustomEvent<
|
|
19
|
+
export declare class SearchRequestChangeEvent extends CustomEvent<EnrichedFtSearchRequest> {
|
|
19
20
|
constructor(request: FtSearchRequest);
|
|
20
21
|
}
|
|
21
22
|
export declare class SearchResultsChangeEvent extends CustomEvent<FtSearchResultsChangeEventDetail> {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-search-context",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.17",
|
|
4
4
|
"description": "Context block for integrated search components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,12 +19,12 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "2.0.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "2.0.
|
|
22
|
+
"@fluid-topics/ft-app-context": "2.0.17",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "2.0.17",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
27
|
"@fluid-topics/public-api": "1.0.120"
|
|
28
28
|
},
|
|
29
|
-
"gitHead": "
|
|
29
|
+
"gitHead": "630c12bb34a3f0df02b112fc182bbbb97025d959"
|
|
30
30
|
}
|