@zengenti/contensis-react-base 3.0.0-beta.38 → 3.0.0-beta.41
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 => {
|
|
@@ -291,51 +291,51 @@ const getSelectedFilters = (state, facet = '', context = Context$1.facets, retur
|
|
|
291
291
|
const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
|
|
292
292
|
const key = (item === null || item === void 0 ? void 0 : item.key) || '';
|
|
293
293
|
const isIsoDate = isoDateRegex.test(key);
|
|
294
|
-
return isIsoDate ? key : key.toLowerCase();
|
|
294
|
+
return isIsoDate ? key : typeof key.toLowerCase !== 'undefined' ? key.toLowerCase() : key;
|
|
295
295
|
})]));
|
|
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,11 +1693,16 @@ 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)
|
|
1698
|
+
};
|
|
1699
|
+
yield effects.put(nextAction); // keep track of this state ref for comparing changes to params later
|
|
1700
|
+
|
|
1701
|
+
const ogState = {
|
|
1702
|
+
search: state.search
|
|
1692
1703
|
};
|
|
1693
|
-
yield effects.put(nextAction);
|
|
1694
1704
|
yield effects.call(ensureSearch, { ...nextAction,
|
|
1695
|
-
ogState
|
|
1705
|
+
ogState
|
|
1696
1706
|
});
|
|
1697
1707
|
}
|
|
1698
1708
|
|
|
@@ -1791,7 +1801,9 @@ function* ensureSearch(action) {
|
|
|
1791
1801
|
try {
|
|
1792
1802
|
const state = yield effects.select();
|
|
1793
1803
|
const nextAction = { ...action,
|
|
1794
|
-
ogState: action.ogState ||
|
|
1804
|
+
ogState: action.ogState || {
|
|
1805
|
+
search: state.search
|
|
1806
|
+
}
|
|
1795
1807
|
};
|
|
1796
1808
|
const [queryParams, runSearch] = generateQueryParams(nextAction, state);
|
|
1797
1809
|
if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
|
|
@@ -1854,7 +1866,7 @@ function* executeSearch(action) {
|
|
|
1854
1866
|
action,
|
|
1855
1867
|
featuredResult,
|
|
1856
1868
|
pageIndex: queryParams.internalPaging && queryParams.internalPageIndex || queryParams.pageIndex,
|
|
1857
|
-
prevResults: getResults(state, facet, action.context, 'js'),
|
|
1869
|
+
prevResults: getResults$1(state, facet, action.context, 'js'),
|
|
1858
1870
|
result,
|
|
1859
1871
|
state
|
|
1860
1872
|
};
|
|
@@ -1931,7 +1943,7 @@ function* updateCurrentFacet(action) {
|
|
|
1931
1943
|
facet,
|
|
1932
1944
|
mappers
|
|
1933
1945
|
} = action;
|
|
1934
|
-
const pageIndex = yield effects.select(getPageIndex, facet);
|
|
1946
|
+
const pageIndex = yield effects.select(getPageIndex$1, facet);
|
|
1935
1947
|
const uri = yield buildUri({
|
|
1936
1948
|
facet,
|
|
1937
1949
|
pageIndex
|
|
@@ -1989,7 +2001,7 @@ function* buildUri({
|
|
|
1989
2001
|
term
|
|
1990
2002
|
}, mappers) {
|
|
1991
2003
|
const state = yield effects.select();
|
|
1992
|
-
const mapUri = mappers
|
|
2004
|
+
const mapUri = (mappers === null || mappers === void 0 ? void 0 : mappers.navigate) || mapStateToSearchUri;
|
|
1993
2005
|
const uri = mapUri({
|
|
1994
2006
|
state,
|
|
1995
2007
|
facet,
|
|
@@ -2001,13 +2013,97 @@ function* buildUri({
|
|
|
2001
2013
|
return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
|
|
2002
2014
|
}
|
|
2003
2015
|
|
|
2016
|
+
var defaultMappers = {
|
|
2017
|
+
results: entries => entries,
|
|
2018
|
+
navigate: mapStateToSearchUri
|
|
2019
|
+
};
|
|
2020
|
+
|
|
2021
|
+
const {
|
|
2022
|
+
getCurrent,
|
|
2023
|
+
getFeaturedResults,
|
|
2024
|
+
getIsLoading,
|
|
2025
|
+
getListing,
|
|
2026
|
+
getPageIndex,
|
|
2027
|
+
getPageIsLoading,
|
|
2028
|
+
getPaging,
|
|
2029
|
+
getQueryParameter,
|
|
2030
|
+
getRenderableFilters,
|
|
2031
|
+
getResults,
|
|
2032
|
+
getSearchTerm
|
|
2033
|
+
} = selectListing;
|
|
2034
|
+
|
|
2035
|
+
const makeSelectListingProps = () => reselect.createSelector(state => state, (_, mappers) => mappers, (state, mappers) => ({
|
|
2036
|
+
currentListing: getCurrent(state),
|
|
2037
|
+
currentPageIndex: getPageIndex(state),
|
|
2038
|
+
listing: getListing(state),
|
|
2039
|
+
featured: getFeaturedResults(state),
|
|
2040
|
+
filters: getRenderableFilters(state),
|
|
2041
|
+
isLoading: getIsLoading(state),
|
|
2042
|
+
pageIsLoading: getPageIsLoading(state),
|
|
2043
|
+
paging: getPaging(state),
|
|
2044
|
+
results: getResults(state),
|
|
2045
|
+
resultsInfo: mappers && typeof mappers.resultsInfo === 'function' && mappers.resultsInfo(state),
|
|
2046
|
+
searchTerm: getSearchTerm(state),
|
|
2047
|
+
sortOrder: getQueryParameter({
|
|
2048
|
+
state
|
|
2049
|
+
}, 'dynamicOrderBy', [])
|
|
2050
|
+
}));
|
|
2051
|
+
|
|
2052
|
+
const useListing = ({
|
|
2053
|
+
mappers
|
|
2054
|
+
} = {
|
|
2055
|
+
id: ''
|
|
2056
|
+
}) => {
|
|
2057
|
+
const dispatch = reactRedux.useDispatch();
|
|
2058
|
+
const m = mappers || defaultMappers;
|
|
2059
|
+
const selectListingProps = React.useMemo(makeSelectListingProps, [m]);
|
|
2060
|
+
const dispatchProps = {
|
|
2061
|
+
clearFilters: () => dispatch(withMappers(clearFilters$1(), m)),
|
|
2062
|
+
updateCurrentFacet: facet => dispatch(withMappers(updateCurrentFacet$1(facet), m)),
|
|
2063
|
+
updatePageIndex: pageIndex => dispatch(withMappers(updatePageIndex$1(pageIndex), m)),
|
|
2064
|
+
updateSearchTerm: term => dispatch(withMappers(updateSearchTerm$1(term), m)),
|
|
2065
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => dispatch(withMappers(updateSelectedFilters(filter, key, isUnknownItem), m)),
|
|
2066
|
+
updateSortOrder: orderBy => dispatch(withMappers(updateSortOrder$1(orderBy), m))
|
|
2067
|
+
};
|
|
2068
|
+
const {
|
|
2069
|
+
currentListing,
|
|
2070
|
+
currentPageIndex,
|
|
2071
|
+
featured,
|
|
2072
|
+
filters,
|
|
2073
|
+
isLoading,
|
|
2074
|
+
listing,
|
|
2075
|
+
paging,
|
|
2076
|
+
pageIsLoading,
|
|
2077
|
+
results,
|
|
2078
|
+
resultsInfo,
|
|
2079
|
+
searchTerm,
|
|
2080
|
+
sortOrder
|
|
2081
|
+
} = reactRedux.useSelector(state => selectListingProps(state, m));
|
|
2082
|
+
return {
|
|
2083
|
+
currentListing,
|
|
2084
|
+
currentPageIndex,
|
|
2085
|
+
featured,
|
|
2086
|
+
filters,
|
|
2087
|
+
isLoading,
|
|
2088
|
+
listing,
|
|
2089
|
+
pageIsLoading,
|
|
2090
|
+
paging,
|
|
2091
|
+
results,
|
|
2092
|
+
resultsInfo,
|
|
2093
|
+
searchTerm,
|
|
2094
|
+
sortOrder,
|
|
2095
|
+
title: listing.title,
|
|
2096
|
+
...dispatchProps
|
|
2097
|
+
};
|
|
2098
|
+
};
|
|
2099
|
+
|
|
2004
2100
|
const makeSelectMinilistProps = () => reselect.createSelector(state => state, (_, id) => id, (state, id) => ({
|
|
2005
2101
|
facet: getFacet(state, id, Context$1.minilist, 'js'),
|
|
2006
2102
|
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)
|
|
2103
|
+
isLoading: getIsLoading$1(state, Context$1.minilist, id),
|
|
2104
|
+
pagingInfo: getPaging$1(state, id, Context$1.minilist, 'js'),
|
|
2105
|
+
results: getResults$1(state, id, Context$1.minilist, 'js'),
|
|
2106
|
+
searchTerm: getSearchTerm$1(state)
|
|
2011
2107
|
}));
|
|
2012
2108
|
|
|
2013
2109
|
const useMinilist = ({
|
|
@@ -2058,7 +2154,7 @@ const useMinilist = ({
|
|
|
2058
2154
|
return {
|
|
2059
2155
|
filters,
|
|
2060
2156
|
isLoading,
|
|
2061
|
-
pagingInfo,
|
|
2157
|
+
paging: pagingInfo,
|
|
2062
2158
|
results,
|
|
2063
2159
|
searchTerm,
|
|
2064
2160
|
title: facet.title
|
|
@@ -2242,7 +2338,10 @@ const generateFiltersState = ({
|
|
|
2242
2338
|
// the search results during SSR without needing to fetch the filters first
|
|
2243
2339
|
|
|
2244
2340
|
|
|
2245
|
-
Object.entries(filterParams).map(([paramName = '', paramValue]) =>
|
|
2341
|
+
Object.entries(filterParams).map(([paramName = '', paramValue]) => {
|
|
2342
|
+
if (typeof paramValue === 'string') return paramValue.split(',').map(pVal => filters = addFilterItem(filters, paramName, pVal));
|
|
2343
|
+
if (typeof paramValue === 'boolean') filters = addFilterItem(filters, paramName, paramValue);
|
|
2344
|
+
});
|
|
2246
2345
|
return Object.fromEntries(filters);
|
|
2247
2346
|
};
|
|
2248
2347
|
|
|
@@ -2504,7 +2603,6 @@ var reducers = (config => {
|
|
|
2504
2603
|
}, initState);
|
|
2505
2604
|
});
|
|
2506
2605
|
|
|
2507
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2508
2606
|
const Context = {
|
|
2509
2607
|
facets: 'facets',
|
|
2510
2608
|
listings: 'listings',
|
|
@@ -2521,6 +2619,7 @@ exports.schema = schema;
|
|
|
2521
2619
|
exports.selectors = selectors;
|
|
2522
2620
|
exports.setRouteFilters = setRouteFilters;
|
|
2523
2621
|
exports.types = types;
|
|
2622
|
+
exports.useListing = useListing;
|
|
2524
2623
|
exports.useMinilist = useMinilist;
|
|
2525
2624
|
exports.withListing = withListing;
|
|
2526
2625
|
exports.withSearch = withSearch;
|