@zengenti/contensis-react-base 3.0.0-beta.70 → 3.0.0-beta.73
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/cjs/{App-0c10c9fa.js → App-80a696bc.js} +2 -6
- package/cjs/App-80a696bc.js.map +1 -0
- package/cjs/client.js +1 -1
- package/cjs/contensis-react-base.js +75 -26
- package/cjs/contensis-react-base.js.map +1 -1
- package/cjs/{sagas-24f5607f.js → sagas-594b5ecd.js} +86 -48
- package/cjs/sagas-594b5ecd.js.map +1 -0
- package/cjs/search.js +19 -12
- package/cjs/search.js.map +1 -1
- package/esm/{App-d7b18a4f.js → App-af0670fa.js} +2 -6
- package/esm/App-af0670fa.js.map +1 -0
- package/esm/client.js +2 -2
- package/esm/contensis-react-base.js +76 -27
- package/esm/contensis-react-base.js.map +1 -1
- package/esm/{sagas-489c29ca.js → sagas-1f2b2aa0.js} +84 -50
- package/esm/sagas-1f2b2aa0.js.map +1 -0
- package/esm/search.js +16 -13
- package/esm/search.js.map +1 -1
- package/models/search/index.d.ts +4 -3
- package/models/search/models/SearchActions.d.ts +5 -2
- package/models/search/redux/actions.d.ts +4 -2
- package/models/search/redux/sagas.d.ts +7 -3
- package/models/search/redux/selectors.d.ts +2 -2
- package/models/search/redux/util.d.ts +1 -0
- package/models/search/search/expressions.d.ts +2 -2
- package/models/search/search/util.d.ts +14 -0
- package/models/server/util/bundles.d.ts +17 -21
- package/package.json +2 -1
- package/CHANGELOG.md +0 -293
- package/cjs/App-0c10c9fa.js.map +0 -1
- package/cjs/sagas-24f5607f.js.map +0 -1
- package/esm/App-d7b18a4f.js.map +0 -1
- package/esm/sagas-489c29ca.js.map +0 -1
- package/package-lock.json +0 -12406
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as log from 'loglevel';
|
|
2
2
|
import { takeEvery, select, put, call, all } from '@redux-saga/core/effects';
|
|
3
3
|
import { Client } from 'contensis-delivery-api';
|
|
4
|
-
import {
|
|
4
|
+
import { parse, stringify } from 'query-string';
|
|
5
5
|
import mapJson, { jpath } from 'jsonpath-mapper';
|
|
6
6
|
import { Op, OrderBy, Query } from 'contensis-core-api';
|
|
7
7
|
import merge from 'deepmerge';
|
|
@@ -102,9 +102,10 @@ const navigate = (path, state) => {
|
|
|
102
102
|
state
|
|
103
103
|
};
|
|
104
104
|
};
|
|
105
|
-
const clearFilters$1 =
|
|
105
|
+
const clearFilters$1 = filterKey => {
|
|
106
106
|
return {
|
|
107
|
-
type: CLEAR_FILTERS
|
|
107
|
+
type: CLEAR_FILTERS,
|
|
108
|
+
filterKey
|
|
108
109
|
};
|
|
109
110
|
};
|
|
110
111
|
const updatePageIndex$1 = (pageIndex, scrollYPos) => {
|
|
@@ -450,6 +451,14 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
450
451
|
selectVersionStatus: selectVersionStatus
|
|
451
452
|
});
|
|
452
453
|
|
|
454
|
+
const now = () => {
|
|
455
|
+
if (typeof window == 'undefined') {
|
|
456
|
+
return Date.now();
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return window.performance.now();
|
|
460
|
+
};
|
|
461
|
+
|
|
453
462
|
const getClientConfig = (project, env) => {
|
|
454
463
|
let config = DELIVERY_API_CONFIG;
|
|
455
464
|
/* global DELIVERY_API_CONFIG */
|
|
@@ -614,14 +623,6 @@ class CachedSearch {
|
|
|
614
623
|
|
|
615
624
|
const cachedSearch = new CachedSearch();
|
|
616
625
|
|
|
617
|
-
const now = () => {
|
|
618
|
-
if (typeof window == 'undefined') {
|
|
619
|
-
return Date.now();
|
|
620
|
-
}
|
|
621
|
-
|
|
622
|
-
return window.performance.now();
|
|
623
|
-
};
|
|
624
|
-
|
|
625
626
|
// eslint-disable-next-line import/default
|
|
626
627
|
function fixFreeTextForElastic(s) {
|
|
627
628
|
const illegalChars = ['>', '<', '=', '|', '!', '{', '}', '[', ']', '^', '~', '*', '?', ':', '\\', '/'];
|
|
@@ -664,6 +665,26 @@ const buildUrl = (route, params) => {
|
|
|
664
665
|
const path = qs ? `${route}${route.includes('?') ? '&' : '?'}${qs}` : route;
|
|
665
666
|
return path;
|
|
666
667
|
};
|
|
668
|
+
/**
|
|
669
|
+
* Returns all params from the current route query string or static route
|
|
670
|
+
* Supply static route argument if reading parameters from the route path
|
|
671
|
+
* Supply location argument for the params to be read in SSR
|
|
672
|
+
* @param staticRoute Matched static route from react-router 5 or 6
|
|
673
|
+
* @param location location object containing at least pathname and search
|
|
674
|
+
* @returns Keyed params object
|
|
675
|
+
*/
|
|
676
|
+
|
|
677
|
+
const routeParams = (staticRoute, location) => {
|
|
678
|
+
var _staticRoute$match;
|
|
679
|
+
|
|
680
|
+
// match.params is react-router-config/react-router@5 style
|
|
681
|
+
// params is supplied with RouteObject in react-router@6
|
|
682
|
+
const pathParams = (staticRoute === null || staticRoute === void 0 ? void 0 : (_staticRoute$match = staticRoute.match) === null || _staticRoute$match === void 0 ? void 0 : _staticRoute$match.params) || (staticRoute === null || staticRoute === void 0 ? void 0 : staticRoute.params) || {};
|
|
683
|
+
const queryParams = parse(typeof window !== 'undefined' ? window.location.search : (location === null || location === void 0 ? void 0 : location.search) || '');
|
|
684
|
+
return { ...pathParams,
|
|
685
|
+
...queryParams
|
|
686
|
+
};
|
|
687
|
+
};
|
|
667
688
|
const callCustomApi = async (customApi, filters) => {
|
|
668
689
|
const apiUri = customApi.uri || '';
|
|
669
690
|
let uri = buildUrl(apiUri, filters);
|
|
@@ -705,6 +726,43 @@ const areArraysEqualSets = (a1, a2) => {
|
|
|
705
726
|
return true;
|
|
706
727
|
};
|
|
707
728
|
|
|
729
|
+
const searchUriTemplate = {
|
|
730
|
+
path: ({
|
|
731
|
+
state,
|
|
732
|
+
facet,
|
|
733
|
+
pageIndex
|
|
734
|
+
}) => {
|
|
735
|
+
const currentFacet = getSearchContext(state) !== Context.listings && (facet || getCurrentFacet(state));
|
|
736
|
+
const currentPath = selectCurrentPath(state) || '/search';
|
|
737
|
+
const newPath = currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
|
|
738
|
+
if (pageIndex) return `${newPath}/${pageIndex + 1}`;
|
|
739
|
+
return newPath;
|
|
740
|
+
},
|
|
741
|
+
search: ({
|
|
742
|
+
state,
|
|
743
|
+
facet,
|
|
744
|
+
orderBy,
|
|
745
|
+
term
|
|
746
|
+
}) => {
|
|
747
|
+
const searchContext = getSearchContext(state); // Lose stateFilters and currentSearch if a new
|
|
748
|
+
// term is passed via an argument
|
|
749
|
+
|
|
750
|
+
const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')]));
|
|
751
|
+
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
752
|
+
const currentQs = removeEmptyAttributes(parse(currentSearch));
|
|
753
|
+
if (orderBy) currentQs.orderBy = orderBy;
|
|
754
|
+
const searchTerm = getSearchTerm(state); // Merge the stateFilters with any current qs to build the new qs
|
|
755
|
+
|
|
756
|
+
const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
|
|
757
|
+
term: searchTerm
|
|
758
|
+
});
|
|
759
|
+
return stringify(mergedSearch);
|
|
760
|
+
},
|
|
761
|
+
hash: state => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
|
|
762
|
+
};
|
|
763
|
+
|
|
764
|
+
const mapStateToSearchUri = params => mapJson(params, searchUriTemplate);
|
|
765
|
+
|
|
708
766
|
const DataFormats = {
|
|
709
767
|
asset: 'asset',
|
|
710
768
|
entry: 'entry',
|
|
@@ -1118,43 +1176,6 @@ var queries = /*#__PURE__*/Object.freeze({
|
|
|
1118
1176
|
searchQuery: searchQuery
|
|
1119
1177
|
});
|
|
1120
1178
|
|
|
1121
|
-
const searchUriTemplate = {
|
|
1122
|
-
path: ({
|
|
1123
|
-
state,
|
|
1124
|
-
facet,
|
|
1125
|
-
pageIndex
|
|
1126
|
-
}) => {
|
|
1127
|
-
const currentFacet = getSearchContext(state) !== Context.listings && (facet || getCurrentFacet(state));
|
|
1128
|
-
const currentPath = selectCurrentPath(state) || '/search';
|
|
1129
|
-
const newPath = currentFacet ? `${currentPath}/${currentFacet}` : currentPath;
|
|
1130
|
-
if (pageIndex) return `${newPath}/${pageIndex + 1}`;
|
|
1131
|
-
return newPath;
|
|
1132
|
-
},
|
|
1133
|
-
search: ({
|
|
1134
|
-
state,
|
|
1135
|
-
facet,
|
|
1136
|
-
orderBy,
|
|
1137
|
-
term
|
|
1138
|
-
}) => {
|
|
1139
|
-
const searchContext = getSearchContext(state); // Lose stateFilters and currentSearch if a new
|
|
1140
|
-
// term is passed via an argument
|
|
1141
|
-
|
|
1142
|
-
const stateFilters = term ? {} : Object.fromEntries(Object.entries(getSelectedFilters(state, facet, searchContext, 'js')).map(([key, f]) => [key, f === null || f === void 0 ? void 0 : f.join(',')]));
|
|
1143
|
-
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
1144
|
-
const currentQs = removeEmptyAttributes(parse(currentSearch));
|
|
1145
|
-
if (orderBy) currentQs.orderBy = orderBy;
|
|
1146
|
-
const searchTerm = getSearchTerm(state); // Merge the stateFilters with any current qs to build the new qs
|
|
1147
|
-
|
|
1148
|
-
const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
|
|
1149
|
-
term: searchTerm
|
|
1150
|
-
});
|
|
1151
|
-
return stringify(mergedSearch);
|
|
1152
|
-
},
|
|
1153
|
-
hash: state => getImmutableOrJS(state, ['routing', 'location', 'hash'], '').replace('#', '')
|
|
1154
|
-
};
|
|
1155
|
-
|
|
1156
|
-
const mapStateToSearchUri = params => mapJson(params, searchUriTemplate);
|
|
1157
|
-
|
|
1158
1179
|
const mapEntriesToSearchResults = ({
|
|
1159
1180
|
mappers,
|
|
1160
1181
|
mapper,
|
|
@@ -1962,5 +1983,18 @@ function* buildUri({
|
|
|
1962
1983
|
return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
|
|
1963
1984
|
}
|
|
1964
1985
|
|
|
1965
|
-
|
|
1966
|
-
|
|
1986
|
+
function* triggerMinilistSsr(options) {
|
|
1987
|
+
yield call(doSearch, {
|
|
1988
|
+
type: DO_SEARCH,
|
|
1989
|
+
...options
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
function* triggerListingSsr(options) {
|
|
1993
|
+
yield call(setRouteFilters, options);
|
|
1994
|
+
}
|
|
1995
|
+
function* triggerSearchSsr(options) {
|
|
1996
|
+
yield call(setRouteFilters, options);
|
|
1997
|
+
}
|
|
1998
|
+
|
|
1999
|
+
export { APPLY_CONFIG as $, clearFilters$1 as A, updateCurrentFacet$1 as B, updateCurrentTab$1 as C, updatePageIndex$1 as D, updateSearchTerm$1 as E, updateSelectedFilters as F, updateSortOrder$1 as G, selectListing as H, mapStateToSearchUri as I, Context as J, selectFacets as K, triggerSearch as L, getFilters as M, toArray as N, UPDATE_SELECTED_FILTERS as O, UPDATE_SEARCH_TERM as P, UPDATE_PAGE_INDEX as Q, SET_SEARCH_ENTRIES as R, SET_SEARCH_FILTERS as S, SET_ROUTE_FILTERS as T, UPDATE_SORT_ORDER as U, LOAD_FILTERS_COMPLETE as V, LOAD_FILTERS_ERROR as W, LOAD_FILTERS as X, EXECUTE_SEARCH_ERROR as Y, EXECUTE_SEARCH as Z, CLEAR_FILTERS as _, customWhereExpressions as a, actions as a0, selectors as a1, types as a2, expressions as a3, queries as a4, doSearch as a5, setRouteFilters as a6, searchSagas as a7, triggerListingSsr as a8, triggerMinilistSsr as a9, triggerSearchSsr as aa, routeParams as ab, getPageIndex as b, contentTypeIdExpression as c, defaultExpressions as d, getCurrentTab as e, filterExpressions as f, getCurrentFacet as g, getFacet as h, getTabFacets as i, getFacetsTotalCount as j, getFacetTitles as k, getFeaturedResults as l, getRenderableFilters as m, getIsLoading as n, orderByExpression as o, getPaging as p, getPageIsLoading as q, getResults as r, getSearchTerm as s, termExpressions as t, getSearchTotalCount as u, getSelectedFilters as v, getQueryParameter as w, getTabsAndFacets as x, getTotalCount as y, withMappers as z };
|
|
2000
|
+
//# sourceMappingURL=sagas-1f2b2aa0.js.map
|