@zengenti/contensis-react-base 3.0.0-beta.39 → 3.0.0-beta.42
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/search.js +205 -106
- package/cjs/search.js.map +1 -1
- package/cjs/util.js +1 -1
- package/cjs/util.js.map +1 -1
- package/esm/search.js +205 -107
- package/esm/search.js.map +1 -1
- package/esm/util.js +1 -1
- package/esm/util.js.map +1 -1
- package/models/search/containers/withListing.d.ts +1 -1
- package/models/search/containers/withSearch.d.ts +1 -1
- package/models/search/hooks/useListing.hook.d.ts +3 -0
- package/models/search/hooks/useMinilist.hook.d.ts +2 -9
- package/models/search/index.d.ts +1 -0
- package/models/search/models/SearchProps.d.ts +23 -0
- package/models/search/transformations/index.d.ts +3 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
package/cjs/search.js
CHANGED
|
@@ -249,7 +249,7 @@ const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThi
|
|
|
249
249
|
};
|
|
250
250
|
|
|
251
251
|
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context$1.facets);
|
|
252
|
-
const getCurrent = (state, context = Context$1.facets) => context === Context$1.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
252
|
+
const getCurrent$1 = (state, context = Context$1.facets) => context === Context$1.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
253
253
|
const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
|
|
254
254
|
const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
|
|
255
255
|
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context$1.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
@@ -268,14 +268,14 @@ const getFacet = (state, facetName = '', context = Context$1.facets, returnType)
|
|
|
268
268
|
const currentFacet = facetName || getCurrentFacet(state);
|
|
269
269
|
return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
|
|
270
270
|
};
|
|
271
|
-
const getListing = (state, listing = '') => {
|
|
271
|
+
const getListing$1 = (state, listing = '') => {
|
|
272
272
|
const currentListing = listing || getCurrentListing(state);
|
|
273
273
|
return getImmutableOrJS(state, ['search', Context$1.listings, currentListing], {});
|
|
274
274
|
};
|
|
275
275
|
const getFilters = (state, facet, context = Context$1.facets, returnType) => {
|
|
276
|
-
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
|
|
276
|
+
return getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'filters'], {}, returnType);
|
|
277
277
|
};
|
|
278
|
-
const getRenderableFilters = (state, facet = '', context = Context$1.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
|
|
278
|
+
const getRenderableFilters$1 = (state, facet = '', context = Context$1.facets) => Object.fromEntries(Object.entries(getFilters(state, facet, context, 'js')).filter(([, f = {}]) => typeof f.renderable !== 'boolean' ? true : f.renderable));
|
|
279
279
|
const getFiltersToLoad = (state, facet, context = Context$1.facets, returnType) => {
|
|
280
280
|
const filters = getFilters(state, facet, context, returnType);
|
|
281
281
|
const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
|
|
@@ -296,46 +296,46 @@ const getSelectedFilters = (state, facet = '', context = Context$1.facets, retur
|
|
|
296
296
|
const fromJS = makeFromJS(returnType);
|
|
297
297
|
return fromJS(selectedFilters);
|
|
298
298
|
};
|
|
299
|
-
const getResults = (state, current = '', context = Context$1.facets, returnType) => {
|
|
300
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
|
|
299
|
+
const getResults$1 = (state, current = '', context = Context$1.facets, returnType) => {
|
|
300
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'results'], [], returnType);
|
|
301
301
|
};
|
|
302
302
|
const getIsInternalPaging = (state, current, context = Context$1.facets) => {
|
|
303
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
|
|
303
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'queryParams', 'internalPaging'], false);
|
|
304
304
|
};
|
|
305
305
|
const getIsLoaded = (state, context = Context$1.facets, facet) => {
|
|
306
|
-
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
|
|
306
|
+
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'queryDuration'], 0);
|
|
307
307
|
};
|
|
308
|
-
const getIsLoading = (state, context = Context$1.facets, facet) => {
|
|
309
|
-
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
|
|
308
|
+
const getIsLoading$1 = (state, context = Context$1.facets, facet) => {
|
|
309
|
+
return getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'entries', 'isLoading']);
|
|
310
310
|
};
|
|
311
311
|
const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
|
|
312
|
-
const getFeaturedResults = (state, current = '', context = Context$1.facets) => {
|
|
313
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], []);
|
|
312
|
+
const getFeaturedResults$1 = (state, current = '', context = Context$1.facets) => {
|
|
313
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'featuredResults'], []);
|
|
314
314
|
};
|
|
315
|
-
const getPaging = (state, current = '', context = Context$1.facets, returnType) => {
|
|
316
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
|
|
315
|
+
const getPaging$1 = (state, current = '', context = Context$1.facets, returnType) => {
|
|
316
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo'], {}, returnType);
|
|
317
317
|
};
|
|
318
|
-
const getPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
319
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
|
|
318
|
+
const getPageIndex$1 = (state, current = '', context = Context$1.facets) => {
|
|
319
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'pageIndex']);
|
|
320
320
|
};
|
|
321
321
|
const getPrevPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
322
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
322
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
323
323
|
};
|
|
324
|
-
const getPageIsLoading = (state, current = '', context = Context$1.facets) => {
|
|
325
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
|
|
324
|
+
const getPageIsLoading$1 = (state, current = '', context = Context$1.facets) => {
|
|
325
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'isLoading']);
|
|
326
326
|
};
|
|
327
327
|
const getPagesLoaded = (state, current = '', context = Context$1.facets) => {
|
|
328
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
328
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
329
329
|
};
|
|
330
330
|
const getTotalCount = (state, current = '', context = Context$1.facets) => {
|
|
331
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
|
|
331
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'totalCount']);
|
|
332
332
|
};
|
|
333
|
-
const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
|
|
333
|
+
const getSearchTerm$1 = state => getImmutableOrJS(state, ['search', 'term']);
|
|
334
334
|
const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
|
|
335
335
|
const getQueryParams = (state, current = '', context = Context$1.facets) => {
|
|
336
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
|
|
336
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'queryParams'], {}, 'js');
|
|
337
337
|
};
|
|
338
|
-
const getQueryParameter = ({
|
|
338
|
+
const getQueryParameter$1 = ({
|
|
339
339
|
state,
|
|
340
340
|
facet,
|
|
341
341
|
context = Context$1.facets
|
|
@@ -343,10 +343,10 @@ const getQueryParameter = ({
|
|
|
343
343
|
return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
|
|
344
344
|
};
|
|
345
345
|
const getCustomApi = (state, current, context = Context$1.facets, returnType) => {
|
|
346
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
|
|
346
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'customApi'], null, returnType);
|
|
347
347
|
};
|
|
348
348
|
const getCustomEnv = (state, current, context = Context$1.facets) => {
|
|
349
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
|
|
349
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'env']);
|
|
350
350
|
};
|
|
351
351
|
const getTabsAndFacets = (state, returnType) => {
|
|
352
352
|
const tabs = getSearchTabs(state, 'js');
|
|
@@ -392,59 +392,59 @@ const selectFacets = {
|
|
|
392
392
|
getFacetTitles,
|
|
393
393
|
getFacets,
|
|
394
394
|
getFacetsTotalCount,
|
|
395
|
-
getFeaturedResults,
|
|
395
|
+
getFeaturedResults: getFeaturedResults$1,
|
|
396
396
|
getFilters,
|
|
397
397
|
getFiltersToLoad,
|
|
398
398
|
getIsLoaded,
|
|
399
|
-
getIsLoading,
|
|
400
|
-
getPageIndex,
|
|
401
|
-
getPageIsLoading,
|
|
399
|
+
getIsLoading: getIsLoading$1,
|
|
400
|
+
getPageIndex: getPageIndex$1,
|
|
401
|
+
getPageIsLoading: getPageIsLoading$1,
|
|
402
402
|
getPagesLoaded,
|
|
403
|
-
getPaging,
|
|
403
|
+
getPaging: getPaging$1,
|
|
404
404
|
getQueryParams: (state, facet) => getQueryParams(state, facet, Context$1.facets),
|
|
405
405
|
getQueryParameter: ({
|
|
406
406
|
state,
|
|
407
407
|
facet
|
|
408
|
-
}, key, ifnull) => getQueryParameter({
|
|
408
|
+
}, key, ifnull) => getQueryParameter$1({
|
|
409
409
|
state,
|
|
410
410
|
facet,
|
|
411
411
|
context: Context$1.facets
|
|
412
412
|
}, key, ifnull),
|
|
413
|
-
getRenderableFilters,
|
|
414
|
-
getResults,
|
|
413
|
+
getRenderableFilters: getRenderableFilters$1,
|
|
414
|
+
getResults: getResults$1,
|
|
415
415
|
getTabFacets,
|
|
416
416
|
getTabsAndFacets,
|
|
417
417
|
getTotalCount,
|
|
418
418
|
getSearchTabs,
|
|
419
|
-
getSearchTerm,
|
|
419
|
+
getSearchTerm: getSearchTerm$1,
|
|
420
420
|
getSearchTotalCount,
|
|
421
421
|
getSelectedFilters
|
|
422
422
|
}; // An exported copy of the relevant selectors pre-scoped to a listing context
|
|
423
423
|
|
|
424
424
|
const selectListing = {
|
|
425
425
|
getCurrent: getCurrentListing,
|
|
426
|
-
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context$1.listings),
|
|
426
|
+
getFeaturedResults: (state, listing = '') => getFeaturedResults$1(state, listing, Context$1.listings),
|
|
427
427
|
getFilters: (state, listing = '') => getFilters(state, listing, Context$1.listings),
|
|
428
428
|
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context$1.listings),
|
|
429
|
-
getListing,
|
|
429
|
+
getListing: getListing$1,
|
|
430
430
|
getIsLoaded: state => getIsLoaded(state, Context$1.listings),
|
|
431
|
-
getIsLoading: state => getIsLoading(state, Context$1.listings),
|
|
432
|
-
getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context$1.listings),
|
|
433
|
-
getPaging: (state, listing = '') => getPaging(state, listing, Context$1.listings),
|
|
434
|
-
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context$1.listings),
|
|
431
|
+
getIsLoading: state => getIsLoading$1(state, Context$1.listings),
|
|
432
|
+
getPageIndex: (state, listing = '') => getPageIndex$1(state, listing, Context$1.listings),
|
|
433
|
+
getPaging: (state, listing = '') => getPaging$1(state, listing, Context$1.listings),
|
|
434
|
+
getPageIsLoading: (state, listing = '') => getPageIsLoading$1(state, listing, Context$1.listings),
|
|
435
435
|
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context$1.listings),
|
|
436
436
|
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context$1.listings),
|
|
437
437
|
getQueryParameter: ({
|
|
438
438
|
state,
|
|
439
439
|
facet
|
|
440
|
-
}, key, ifnull) => getQueryParameter({
|
|
440
|
+
}, key, ifnull) => getQueryParameter$1({
|
|
441
441
|
state,
|
|
442
442
|
facet,
|
|
443
443
|
context: Context$1.listings
|
|
444
444
|
}, key, ifnull),
|
|
445
|
-
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context$1.listings),
|
|
446
|
-
getResults: (state, listing = '') => getResults(state, listing, Context$1.listings),
|
|
447
|
-
getSearchTerm,
|
|
445
|
+
getRenderableFilters: (state, listing = '') => getRenderableFilters$1(state, listing, Context$1.listings),
|
|
446
|
+
getResults: (state, listing = '') => getResults$1(state, listing, Context$1.listings),
|
|
447
|
+
getSearchTerm: getSearchTerm$1,
|
|
448
448
|
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context$1.listings),
|
|
449
449
|
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context$1.listings)
|
|
450
450
|
};
|
|
@@ -455,7 +455,7 @@ const selectVersionStatus = state => getImmutableOrJS(state, ['version', 'conten
|
|
|
455
455
|
var selectors = /*#__PURE__*/Object.freeze({
|
|
456
456
|
__proto__: null,
|
|
457
457
|
getSearchContext: getSearchContext,
|
|
458
|
-
getCurrent: getCurrent,
|
|
458
|
+
getCurrent: getCurrent$1,
|
|
459
459
|
getCurrentFacet: getCurrentFacet,
|
|
460
460
|
getCurrentListing: getCurrentListing,
|
|
461
461
|
getCurrentTab: getCurrentTab,
|
|
@@ -463,27 +463,27 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
463
463
|
getTabFacets: getTabFacets,
|
|
464
464
|
getFacetTitles: getFacetTitles,
|
|
465
465
|
getFacet: getFacet,
|
|
466
|
-
getListing: getListing,
|
|
466
|
+
getListing: getListing$1,
|
|
467
467
|
getFilters: getFilters,
|
|
468
|
-
getRenderableFilters: getRenderableFilters,
|
|
468
|
+
getRenderableFilters: getRenderableFilters$1,
|
|
469
469
|
getFiltersToLoad: getFiltersToLoad,
|
|
470
470
|
getSelectedFilters: getSelectedFilters,
|
|
471
|
-
getResults: getResults,
|
|
471
|
+
getResults: getResults$1,
|
|
472
472
|
getIsInternalPaging: getIsInternalPaging,
|
|
473
473
|
getIsLoaded: getIsLoaded,
|
|
474
|
-
getIsLoading: getIsLoading,
|
|
474
|
+
getIsLoading: getIsLoading$1,
|
|
475
475
|
getIsSsr: getIsSsr,
|
|
476
|
-
getFeaturedResults: getFeaturedResults,
|
|
477
|
-
getPaging: getPaging,
|
|
478
|
-
getPageIndex: getPageIndex,
|
|
476
|
+
getFeaturedResults: getFeaturedResults$1,
|
|
477
|
+
getPaging: getPaging$1,
|
|
478
|
+
getPageIndex: getPageIndex$1,
|
|
479
479
|
getPrevPageIndex: getPrevPageIndex,
|
|
480
|
-
getPageIsLoading: getPageIsLoading,
|
|
480
|
+
getPageIsLoading: getPageIsLoading$1,
|
|
481
481
|
getPagesLoaded: getPagesLoaded,
|
|
482
482
|
getTotalCount: getTotalCount,
|
|
483
|
-
getSearchTerm: getSearchTerm,
|
|
483
|
+
getSearchTerm: getSearchTerm$1,
|
|
484
484
|
getSearchTabs: getSearchTabs,
|
|
485
485
|
getQueryParams: getQueryParams,
|
|
486
|
-
getQueryParameter: getQueryParameter,
|
|
486
|
+
getQueryParameter: getQueryParameter$1,
|
|
487
487
|
getCustomApi: getCustomApi,
|
|
488
488
|
getCustomEnv: getCustomEnv,
|
|
489
489
|
getTabsAndFacets: getTabsAndFacets,
|
|
@@ -498,7 +498,6 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
498
498
|
|
|
499
499
|
// eslint-disable-next-line import/default
|
|
500
500
|
|
|
501
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
502
501
|
const withSearch = mappers => SearchComponent => {
|
|
503
502
|
const Wrapper = props => {
|
|
504
503
|
return /*#__PURE__*/React__default["default"].createElement(SearchComponent, props);
|
|
@@ -509,22 +508,22 @@ const withSearch = mappers => SearchComponent => {
|
|
|
509
508
|
const mapStateToProps = state => {
|
|
510
509
|
return {
|
|
511
510
|
currentFacet: getCurrentFacet(state),
|
|
512
|
-
currentPageIndex: getPageIndex(state),
|
|
511
|
+
currentPageIndex: getPageIndex$1(state),
|
|
513
512
|
currentTabIndex: getCurrentTab(state),
|
|
514
513
|
facet: getFacet(state),
|
|
515
514
|
facets: getTabFacets(state),
|
|
516
515
|
facetsTotalCount: getFacetsTotalCount(state),
|
|
517
516
|
facetTitles: getFacetTitles(state),
|
|
518
|
-
featuredResults: getFeaturedResults(state),
|
|
519
|
-
filters: getRenderableFilters(state),
|
|
520
|
-
isLoading: getIsLoading(state),
|
|
521
|
-
paging: getPaging(state),
|
|
522
|
-
pageIsLoading: getPageIsLoading(state),
|
|
523
|
-
results: getResults(state),
|
|
517
|
+
featuredResults: getFeaturedResults$1(state),
|
|
518
|
+
filters: getRenderableFilters$1(state),
|
|
519
|
+
isLoading: getIsLoading$1(state),
|
|
520
|
+
paging: getPaging$1(state),
|
|
521
|
+
pageIsLoading: getPageIsLoading$1(state),
|
|
522
|
+
results: getResults$1(state),
|
|
524
523
|
resultsInfo: (mappers === null || mappers === void 0 ? void 0 : mappers.resultsInfo) && mappers.resultsInfo(state),
|
|
525
|
-
searchTerm: getSearchTerm(state),
|
|
524
|
+
searchTerm: getSearchTerm$1(state),
|
|
526
525
|
searchTotalCount: getSearchTotalCount(state),
|
|
527
|
-
sortOrder: getQueryParameter({
|
|
526
|
+
sortOrder: getQueryParameter$1({
|
|
528
527
|
state
|
|
529
528
|
}, 'dynamicOrderBy', []),
|
|
530
529
|
tabsAndFacets: getTabsAndFacets(state),
|
|
@@ -1229,7 +1228,7 @@ const searchUriTemplate = {
|
|
|
1229
1228
|
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
1230
1229
|
const currentQs = removeEmptyAttributes(queryString.parse(currentSearch));
|
|
1231
1230
|
if (orderBy) currentQs.orderBy = orderBy;
|
|
1232
|
-
const searchTerm = getSearchTerm(state); // Merge the stateFilters with any current qs to build the new qs
|
|
1231
|
+
const searchTerm = getSearchTerm$1(state); // Merge the stateFilters with any current qs to build the new qs
|
|
1233
1232
|
|
|
1234
1233
|
const mergedSearch = removeEmptyAttributes({ ...merge__default["default"](currentQs, stateFilters),
|
|
1235
1234
|
term: searchTerm
|
|
@@ -1416,10 +1415,10 @@ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
|
|
|
1416
1415
|
};
|
|
1417
1416
|
|
|
1418
1417
|
const queryParamsTemplate = {
|
|
1419
|
-
assetTypes: root => getQueryParameter(root, 'assetTypes', []),
|
|
1420
|
-
contentTypeIds: root => getQueryParameter(root, 'contentTypeIds', []),
|
|
1421
|
-
customWhere: root => getQueryParameter(root, 'customWhere', []),
|
|
1422
|
-
dynamicOrderBy: root => getQueryParameter(root, 'dynamicOrderBy', []),
|
|
1418
|
+
assetTypes: root => getQueryParameter$1(root, 'assetTypes', []),
|
|
1419
|
+
contentTypeIds: root => getQueryParameter$1(root, 'contentTypeIds', []),
|
|
1420
|
+
customWhere: root => getQueryParameter$1(root, 'customWhere', []),
|
|
1421
|
+
dynamicOrderBy: root => getQueryParameter$1(root, 'dynamicOrderBy', []),
|
|
1423
1422
|
env: ({
|
|
1424
1423
|
state,
|
|
1425
1424
|
facet,
|
|
@@ -1434,8 +1433,8 @@ const queryParamsTemplate = {
|
|
|
1434
1433
|
if (excludeIds) return Array.isArray(excludeIds) ? excludeIds : excludeIds.split(',').map(id => id.trim());
|
|
1435
1434
|
return null;
|
|
1436
1435
|
},
|
|
1437
|
-
featuredResults: root => getQueryParameter(root, 'featuredResults', null),
|
|
1438
|
-
fields: root => getQueryParameter(root, 'fields', []),
|
|
1436
|
+
featuredResults: root => getQueryParameter$1(root, 'featuredResults', null),
|
|
1437
|
+
fields: root => getQueryParameter$1(root, 'fields', []),
|
|
1439
1438
|
filters: ({
|
|
1440
1439
|
state,
|
|
1441
1440
|
facet,
|
|
@@ -1447,28 +1446,28 @@ const queryParamsTemplate = {
|
|
|
1447
1446
|
const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
|
|
1448
1447
|
return filterParams;
|
|
1449
1448
|
},
|
|
1450
|
-
includeInSearchFields: root => getQueryParameter(root, 'includeInSearch', []),
|
|
1449
|
+
includeInSearchFields: root => getQueryParameter$1(root, 'includeInSearch', []),
|
|
1451
1450
|
internalPageIndex: ({
|
|
1452
1451
|
action,
|
|
1453
1452
|
state
|
|
1454
|
-
}) => getPageIndex(state, '', action.context),
|
|
1455
|
-
internalPaging: root => getQueryParameter(root, 'internalPaging', false),
|
|
1453
|
+
}) => getPageIndex$1(state, '', action.context),
|
|
1454
|
+
internalPaging: root => getQueryParameter$1(root, 'internalPaging', false),
|
|
1456
1455
|
languages: ({
|
|
1457
1456
|
action
|
|
1458
1457
|
}) => action.defaultLang ? [action.defaultLang] : [],
|
|
1459
|
-
linkDepth: root => getQueryParameter(root, 'linkDepth', 0),
|
|
1460
|
-
loadMorePaging: root => getQueryParameter(root, 'loadMorePaging', false),
|
|
1461
|
-
orderBy: root => getQueryParameter(root, 'orderBy', []),
|
|
1458
|
+
linkDepth: root => getQueryParameter$1(root, 'linkDepth', 0),
|
|
1459
|
+
loadMorePaging: root => getQueryParameter$1(root, 'loadMorePaging', false),
|
|
1460
|
+
orderBy: root => getQueryParameter$1(root, 'orderBy', []),
|
|
1462
1461
|
pageIndex: root => {
|
|
1463
1462
|
const {
|
|
1464
1463
|
action,
|
|
1465
1464
|
state
|
|
1466
1465
|
} = root;
|
|
1467
|
-
if (getQueryParameter(root, 'internalPaging', false)) return 0;
|
|
1466
|
+
if (getQueryParameter$1(root, 'internalPaging', false)) return 0;
|
|
1468
1467
|
if (action.type === UPDATE_PAGE_INDEX) return action.params.pageIndex;
|
|
1469
|
-
return !action.preload ? getPageIndex(state,
|
|
1468
|
+
return !action.preload ? getPageIndex$1(state, action.facet, action.context) : 0;
|
|
1470
1469
|
},
|
|
1471
|
-
pageSize: root => getQueryParameter(root, 'pageSize'),
|
|
1470
|
+
pageSize: root => getQueryParameter$1(root, 'pageSize'),
|
|
1472
1471
|
pagesLoaded: ({
|
|
1473
1472
|
state,
|
|
1474
1473
|
facet,
|
|
@@ -1488,7 +1487,7 @@ const queryParamsTemplate = {
|
|
|
1488
1487
|
|
|
1489
1488
|
return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
|
|
1490
1489
|
},
|
|
1491
|
-
searchTerm: root => root.context !== Context$1.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1490
|
+
searchTerm: root => root.context !== Context$1.minilist || getQueryParameter$1(root, 'useSearchTerm', false) ? getSearchTerm$1(root.state) : '',
|
|
1492
1491
|
selectedFilters: ({
|
|
1493
1492
|
state,
|
|
1494
1493
|
facet,
|
|
@@ -1498,11 +1497,11 @@ const queryParamsTemplate = {
|
|
|
1498
1497
|
state
|
|
1499
1498
|
}) => selectVersionStatus(state),
|
|
1500
1499
|
weightedSearchFields: root => {
|
|
1501
|
-
const wsf = getQueryParameter(root, 'weightedSearchFields', []);
|
|
1500
|
+
const wsf = getQueryParameter$1(root, 'weightedSearchFields', []);
|
|
1502
1501
|
const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
|
|
1503
1502
|
return deduped; // return wsf;
|
|
1504
1503
|
},
|
|
1505
|
-
webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
|
|
1504
|
+
webpageTemplates: root => getQueryParameter$1(root, 'webpageTemplates', [])
|
|
1506
1505
|
};
|
|
1507
1506
|
|
|
1508
1507
|
const mapStateToQueryParams = sourceJson => mapJson__default["default"](sourceJson, queryParamsTemplate);
|
|
@@ -1548,8 +1547,8 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1548
1547
|
const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
|
|
1549
1548
|
const stateParams = { ...getQueryParams(ogState, facet, context)
|
|
1550
1549
|
};
|
|
1551
|
-
stateParams.pageIndex = getPageIndex(ogState, facet, context);
|
|
1552
|
-
stateParams.searchTerm = getSearchTerm(ogState);
|
|
1550
|
+
stateParams.pageIndex = getPageIndex$1(ogState, facet, context);
|
|
1551
|
+
stateParams.searchTerm = getSearchTerm$1(ogState);
|
|
1553
1552
|
|
|
1554
1553
|
if (context === Context$1.facets && ssr || // context === Context.minilist ||
|
|
1555
1554
|
preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
|
|
@@ -1601,8 +1600,8 @@ const debugExecuteSearch = (action, state) => {
|
|
|
1601
1600
|
const [queryParams, runSearch] = generateQueryParams(action, state);
|
|
1602
1601
|
console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
|
|
1603
1602
|
const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
|
|
1604
|
-
pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
|
|
1605
|
-
searchTerm: getSearchTerm(action.ogState || state)
|
|
1603
|
+
pageIndex: getPageIndex$1(action.ogState || state, action.facet, action.context),
|
|
1604
|
+
searchTerm: getSearchTerm$1(action.ogState || state)
|
|
1606
1605
|
};
|
|
1607
1606
|
console.log(stateParams, queryParams);
|
|
1608
1607
|
console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
|
|
@@ -1668,14 +1667,20 @@ function* setRouteFilters(action) {
|
|
|
1668
1667
|
ssr,
|
|
1669
1668
|
debug
|
|
1670
1669
|
};
|
|
1671
|
-
yield effects.put(nextAction); //
|
|
1670
|
+
yield effects.put(nextAction); // keep track of this state ref for comparing changes to params later
|
|
1671
|
+
|
|
1672
|
+
const ogState = {
|
|
1673
|
+
search: state.search
|
|
1674
|
+
}; // Using call instead of triggering from the put
|
|
1672
1675
|
// to allow this exported saga to continue during SSR
|
|
1673
1676
|
|
|
1674
1677
|
yield effects.call(ensureSearch, { ...nextAction,
|
|
1675
|
-
ogState
|
|
1678
|
+
ogState
|
|
1676
1679
|
});
|
|
1677
1680
|
}
|
|
1678
1681
|
function* doSearch(action) {
|
|
1682
|
+
var _action$params;
|
|
1683
|
+
|
|
1679
1684
|
const state = toJS(yield effects.select());
|
|
1680
1685
|
|
|
1681
1686
|
if (action.config) {
|
|
@@ -1688,12 +1693,20 @@ function* doSearch(action) {
|
|
|
1688
1693
|
|
|
1689
1694
|
const nextAction = { ...action,
|
|
1690
1695
|
type: SET_SEARCH_FILTERS,
|
|
1691
|
-
ssr: getIsSsr(state)
|
|
1696
|
+
ssr: getIsSsr(state),
|
|
1697
|
+
facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
|
|
1692
1698
|
};
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1699
|
+
|
|
1700
|
+
if (nextAction.facet) {
|
|
1701
|
+
yield effects.put(nextAction); // keep track of this state ref for comparing changes to params later
|
|
1702
|
+
|
|
1703
|
+
const ogState = {
|
|
1704
|
+
search: state.search
|
|
1705
|
+
};
|
|
1706
|
+
yield effects.call(ensureSearch, { ...nextAction,
|
|
1707
|
+
ogState
|
|
1708
|
+
});
|
|
1709
|
+
}
|
|
1697
1710
|
}
|
|
1698
1711
|
|
|
1699
1712
|
function* loadFilters(action) {
|
|
@@ -1791,7 +1804,9 @@ function* ensureSearch(action) {
|
|
|
1791
1804
|
try {
|
|
1792
1805
|
const state = yield effects.select();
|
|
1793
1806
|
const nextAction = { ...action,
|
|
1794
|
-
ogState: action.ogState ||
|
|
1807
|
+
ogState: action.ogState || {
|
|
1808
|
+
search: state.search
|
|
1809
|
+
}
|
|
1795
1810
|
};
|
|
1796
1811
|
const [queryParams, runSearch] = generateQueryParams(nextAction, state);
|
|
1797
1812
|
if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
|
|
@@ -1854,7 +1869,7 @@ function* executeSearch(action) {
|
|
|
1854
1869
|
action,
|
|
1855
1870
|
featuredResult,
|
|
1856
1871
|
pageIndex: queryParams.internalPaging && queryParams.internalPageIndex || queryParams.pageIndex,
|
|
1857
|
-
prevResults: getResults(state, facet, action.context, 'js'),
|
|
1872
|
+
prevResults: getResults$1(state, facet, action.context, 'js'),
|
|
1858
1873
|
result,
|
|
1859
1874
|
state
|
|
1860
1875
|
};
|
|
@@ -1931,7 +1946,7 @@ function* updateCurrentFacet(action) {
|
|
|
1931
1946
|
facet,
|
|
1932
1947
|
mappers
|
|
1933
1948
|
} = action;
|
|
1934
|
-
const pageIndex = yield effects.select(getPageIndex, facet);
|
|
1949
|
+
const pageIndex = yield effects.select(getPageIndex$1, facet);
|
|
1935
1950
|
const uri = yield buildUri({
|
|
1936
1951
|
facet,
|
|
1937
1952
|
pageIndex
|
|
@@ -1989,7 +2004,7 @@ function* buildUri({
|
|
|
1989
2004
|
term
|
|
1990
2005
|
}, mappers) {
|
|
1991
2006
|
const state = yield effects.select();
|
|
1992
|
-
const mapUri = mappers
|
|
2007
|
+
const mapUri = (mappers === null || mappers === void 0 ? void 0 : mappers.navigate) || mapStateToSearchUri;
|
|
1993
2008
|
const uri = mapUri({
|
|
1994
2009
|
state,
|
|
1995
2010
|
facet,
|
|
@@ -2001,13 +2016,97 @@ function* buildUri({
|
|
|
2001
2016
|
return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
|
|
2002
2017
|
}
|
|
2003
2018
|
|
|
2019
|
+
var defaultMappers = {
|
|
2020
|
+
results: entries => entries,
|
|
2021
|
+
navigate: mapStateToSearchUri
|
|
2022
|
+
};
|
|
2023
|
+
|
|
2024
|
+
const {
|
|
2025
|
+
getCurrent,
|
|
2026
|
+
getFeaturedResults,
|
|
2027
|
+
getIsLoading,
|
|
2028
|
+
getListing,
|
|
2029
|
+
getPageIndex,
|
|
2030
|
+
getPageIsLoading,
|
|
2031
|
+
getPaging,
|
|
2032
|
+
getQueryParameter,
|
|
2033
|
+
getRenderableFilters,
|
|
2034
|
+
getResults,
|
|
2035
|
+
getSearchTerm
|
|
2036
|
+
} = selectListing;
|
|
2037
|
+
|
|
2038
|
+
const makeSelectListingProps = () => reselect.createSelector(state => state, (_, mappers) => mappers, (state, mappers) => ({
|
|
2039
|
+
currentListing: getCurrent(state),
|
|
2040
|
+
currentPageIndex: getPageIndex(state),
|
|
2041
|
+
listing: getListing(state),
|
|
2042
|
+
featured: getFeaturedResults(state),
|
|
2043
|
+
filters: getRenderableFilters(state),
|
|
2044
|
+
isLoading: getIsLoading(state),
|
|
2045
|
+
pageIsLoading: getPageIsLoading(state),
|
|
2046
|
+
paging: getPaging(state),
|
|
2047
|
+
results: getResults(state),
|
|
2048
|
+
resultsInfo: mappers && typeof mappers.resultsInfo === 'function' && mappers.resultsInfo(state),
|
|
2049
|
+
searchTerm: getSearchTerm(state),
|
|
2050
|
+
sortOrder: getQueryParameter({
|
|
2051
|
+
state
|
|
2052
|
+
}, 'dynamicOrderBy', [])
|
|
2053
|
+
}));
|
|
2054
|
+
|
|
2055
|
+
const useListing = ({
|
|
2056
|
+
mappers
|
|
2057
|
+
} = {
|
|
2058
|
+
id: ''
|
|
2059
|
+
}) => {
|
|
2060
|
+
const dispatch = reactRedux.useDispatch();
|
|
2061
|
+
const m = mappers || defaultMappers;
|
|
2062
|
+
const selectListingProps = React.useMemo(makeSelectListingProps, [m]);
|
|
2063
|
+
const dispatchProps = {
|
|
2064
|
+
clearFilters: () => dispatch(withMappers(clearFilters$1(), m)),
|
|
2065
|
+
updateCurrentFacet: facet => dispatch(withMappers(updateCurrentFacet$1(facet), m)),
|
|
2066
|
+
updatePageIndex: pageIndex => dispatch(withMappers(updatePageIndex$1(pageIndex), m)),
|
|
2067
|
+
updateSearchTerm: term => dispatch(withMappers(updateSearchTerm$1(term), m)),
|
|
2068
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => dispatch(withMappers(updateSelectedFilters(filter, key, isUnknownItem), m)),
|
|
2069
|
+
updateSortOrder: orderBy => dispatch(withMappers(updateSortOrder$1(orderBy), m))
|
|
2070
|
+
};
|
|
2071
|
+
const {
|
|
2072
|
+
currentListing,
|
|
2073
|
+
currentPageIndex,
|
|
2074
|
+
featured,
|
|
2075
|
+
filters,
|
|
2076
|
+
isLoading,
|
|
2077
|
+
listing,
|
|
2078
|
+
paging,
|
|
2079
|
+
pageIsLoading,
|
|
2080
|
+
results,
|
|
2081
|
+
resultsInfo,
|
|
2082
|
+
searchTerm,
|
|
2083
|
+
sortOrder
|
|
2084
|
+
} = reactRedux.useSelector(state => selectListingProps(state, m));
|
|
2085
|
+
return {
|
|
2086
|
+
currentListing,
|
|
2087
|
+
currentPageIndex,
|
|
2088
|
+
featured,
|
|
2089
|
+
filters,
|
|
2090
|
+
isLoading,
|
|
2091
|
+
listing,
|
|
2092
|
+
pageIsLoading,
|
|
2093
|
+
paging,
|
|
2094
|
+
results,
|
|
2095
|
+
resultsInfo,
|
|
2096
|
+
searchTerm,
|
|
2097
|
+
sortOrder,
|
|
2098
|
+
title: listing.title,
|
|
2099
|
+
...dispatchProps
|
|
2100
|
+
};
|
|
2101
|
+
};
|
|
2102
|
+
|
|
2004
2103
|
const makeSelectMinilistProps = () => reselect.createSelector(state => state, (_, id) => id, (state, id) => ({
|
|
2005
2104
|
facet: getFacet(state, id, Context$1.minilist, 'js'),
|
|
2006
2105
|
filters: getFilters(state, id, Context$1.minilist, 'js'),
|
|
2007
|
-
isLoading: getIsLoading(state, Context$1.minilist, id),
|
|
2008
|
-
pagingInfo: getPaging(state, id, Context$1.minilist, 'js'),
|
|
2009
|
-
results: getResults(state, id, Context$1.minilist, 'js'),
|
|
2010
|
-
searchTerm: getSearchTerm(state)
|
|
2106
|
+
isLoading: getIsLoading$1(state, Context$1.minilist, id),
|
|
2107
|
+
pagingInfo: getPaging$1(state, id, Context$1.minilist, 'js'),
|
|
2108
|
+
results: getResults$1(state, id, Context$1.minilist, 'js'),
|
|
2109
|
+
searchTerm: getSearchTerm$1(state)
|
|
2011
2110
|
}));
|
|
2012
2111
|
|
|
2013
2112
|
const useMinilist = ({
|
|
@@ -2058,7 +2157,7 @@ const useMinilist = ({
|
|
|
2058
2157
|
return {
|
|
2059
2158
|
filters,
|
|
2060
2159
|
isLoading,
|
|
2061
|
-
pagingInfo,
|
|
2160
|
+
paging: pagingInfo,
|
|
2062
2161
|
results,
|
|
2063
2162
|
searchTerm,
|
|
2064
2163
|
title: facet.title
|
|
@@ -2507,7 +2606,6 @@ var reducers = (config => {
|
|
|
2507
2606
|
}, initState);
|
|
2508
2607
|
});
|
|
2509
2608
|
|
|
2510
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2511
2609
|
const Context = {
|
|
2512
2610
|
facets: 'facets',
|
|
2513
2611
|
listings: 'listings',
|
|
@@ -2524,6 +2622,7 @@ exports.schema = schema;
|
|
|
2524
2622
|
exports.selectors = selectors;
|
|
2525
2623
|
exports.setRouteFilters = setRouteFilters;
|
|
2526
2624
|
exports.types = types;
|
|
2625
|
+
exports.useListing = useListing;
|
|
2527
2626
|
exports.useMinilist = useMinilist;
|
|
2528
2627
|
exports.withListing = withListing;
|
|
2529
2628
|
exports.withSearch = withSearch;
|