@zengenti/contensis-react-base 3.0.0-beta.37 → 3.0.0-beta.40
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/Search.d.ts +2 -0
- package/models/search/models/SearchProps.d.ts +23 -0
- package/models/search/models/SearchState.d.ts +2 -1
- package/models/search/redux/reducers.d.ts +3 -0
- package/models/search/transformations/index.d.ts +3 -0
- package/package-lock.json +2 -2
- package/package.json +1 -1
package/esm/search.js
CHANGED
|
@@ -219,7 +219,7 @@ const getImmutableOrJS = (state, stateKey, fallbackValue, returnType = globalThi
|
|
|
219
219
|
};
|
|
220
220
|
|
|
221
221
|
const getSearchContext = state => getImmutableOrJS(state, ['search', 'context'], Context$1.facets);
|
|
222
|
-
const getCurrent = (state, context = Context$1.facets) => context === Context$1.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
222
|
+
const getCurrent$1 = (state, context = Context$1.facets) => context === Context$1.facets ? getCurrentFacet(state) : getCurrentListing(state);
|
|
223
223
|
const getCurrentFacet = state => getImmutableOrJS(state, ['search', 'currentFacet']);
|
|
224
224
|
const getCurrentListing = state => getImmutableOrJS(state, ['search', 'currentListing']);
|
|
225
225
|
const getCurrentTab = state => getImmutableOrJS(state, ['search', Context$1.facets, getCurrentFacet(state), 'tabId'], 0);
|
|
@@ -238,14 +238,14 @@ const getFacet = (state, facetName = '', context = Context$1.facets, returnType)
|
|
|
238
238
|
const currentFacet = facetName || getCurrentFacet(state);
|
|
239
239
|
return getImmutableOrJS(state, ['search', context, currentFacet], {}, returnType);
|
|
240
240
|
};
|
|
241
|
-
const getListing = (state, listing = '') => {
|
|
241
|
+
const getListing$1 = (state, listing = '') => {
|
|
242
242
|
const currentListing = listing || getCurrentListing(state);
|
|
243
243
|
return getImmutableOrJS(state, ['search', Context$1.listings, currentListing], {});
|
|
244
244
|
};
|
|
245
245
|
const getFilters = (state, facet, context = Context$1.facets, returnType) => {
|
|
246
|
-
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'filters'], {}, returnType);
|
|
246
|
+
return getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'filters'], {}, returnType);
|
|
247
247
|
};
|
|
248
|
-
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));
|
|
248
|
+
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));
|
|
249
249
|
const getFiltersToLoad = (state, facet, context = Context$1.facets, returnType) => {
|
|
250
250
|
const filters = getFilters(state, facet, context, returnType);
|
|
251
251
|
const loadedFilters = Object.entries(filters).map(([key, f = {}]) => [key, (f.items || []).filter(i => {
|
|
@@ -261,51 +261,51 @@ const getSelectedFilters = (state, facet = '', context = Context$1.facets, retur
|
|
|
261
261
|
const selectedFilters = Object.fromEntries(Object.entries(filters).map(([key, filter = {}]) => [key, (filter.items || []).filter(item => !!(item.isSelected || false)).map(item => {
|
|
262
262
|
const key = (item === null || item === void 0 ? void 0 : item.key) || '';
|
|
263
263
|
const isIsoDate = isoDateRegex.test(key);
|
|
264
|
-
return isIsoDate ? key : key.toLowerCase();
|
|
264
|
+
return isIsoDate ? key : typeof key.toLowerCase !== 'undefined' ? key.toLowerCase() : key;
|
|
265
265
|
})]));
|
|
266
266
|
const fromJS = makeFromJS(returnType);
|
|
267
267
|
return fromJS(selectedFilters);
|
|
268
268
|
};
|
|
269
|
-
const getResults = (state, current = '', context = Context$1.facets, returnType) => {
|
|
270
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'results'], [], returnType);
|
|
269
|
+
const getResults$1 = (state, current = '', context = Context$1.facets, returnType) => {
|
|
270
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'results'], [], returnType);
|
|
271
271
|
};
|
|
272
272
|
const getIsInternalPaging = (state, current, context = Context$1.facets) => {
|
|
273
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams', 'internalPaging'], false);
|
|
273
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'queryParams', 'internalPaging'], false);
|
|
274
274
|
};
|
|
275
275
|
const getIsLoaded = (state, context = Context$1.facets, facet) => {
|
|
276
|
-
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'queryDuration'], 0);
|
|
276
|
+
return !!getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'queryDuration'], 0);
|
|
277
277
|
};
|
|
278
|
-
const getIsLoading = (state, context = Context$1.facets, facet) => {
|
|
279
|
-
return getImmutableOrJS(state, ['search', context, facet || getCurrent(state, context), 'entries', 'isLoading']);
|
|
278
|
+
const getIsLoading$1 = (state, context = Context$1.facets, facet) => {
|
|
279
|
+
return getImmutableOrJS(state, ['search', context, facet || getCurrent$1(state, context), 'entries', 'isLoading']);
|
|
280
280
|
};
|
|
281
281
|
const getIsSsr = state => getImmutableOrJS(state, ['search', 'config', 'ssr'], false);
|
|
282
|
-
const getFeaturedResults = (state, current = '', context = Context$1.facets) => {
|
|
283
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'featuredResults'], []);
|
|
282
|
+
const getFeaturedResults$1 = (state, current = '', context = Context$1.facets) => {
|
|
283
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'featuredResults'], []);
|
|
284
284
|
};
|
|
285
|
-
const getPaging = (state, current = '', context = Context$1.facets, returnType) => {
|
|
286
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo'], {}, returnType);
|
|
285
|
+
const getPaging$1 = (state, current = '', context = Context$1.facets, returnType) => {
|
|
286
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo'], {}, returnType);
|
|
287
287
|
};
|
|
288
|
-
const getPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
289
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pageIndex']);
|
|
288
|
+
const getPageIndex$1 = (state, current = '', context = Context$1.facets) => {
|
|
289
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'pageIndex']);
|
|
290
290
|
};
|
|
291
291
|
const getPrevPageIndex = (state, current = '', context = Context$1.facets) => {
|
|
292
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
292
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'prevPageIndex']);
|
|
293
293
|
};
|
|
294
|
-
const getPageIsLoading = (state, current = '', context = Context$1.facets) => {
|
|
295
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'isLoading']);
|
|
294
|
+
const getPageIsLoading$1 = (state, current = '', context = Context$1.facets) => {
|
|
295
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'isLoading']);
|
|
296
296
|
};
|
|
297
297
|
const getPagesLoaded = (state, current = '', context = Context$1.facets) => {
|
|
298
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
298
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'pagesLoaded'], [], 'js');
|
|
299
299
|
};
|
|
300
300
|
const getTotalCount = (state, current = '', context = Context$1.facets) => {
|
|
301
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'pagingInfo', 'totalCount']);
|
|
301
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'pagingInfo', 'totalCount']);
|
|
302
302
|
};
|
|
303
|
-
const getSearchTerm = state => getImmutableOrJS(state, ['search', 'term']);
|
|
303
|
+
const getSearchTerm$1 = state => getImmutableOrJS(state, ['search', 'term']);
|
|
304
304
|
const getSearchTabs = (state, returnType) => getImmutableOrJS(state, ['search', 'tabs'], [], returnType);
|
|
305
305
|
const getQueryParams = (state, current = '', context = Context$1.facets) => {
|
|
306
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'queryParams'], {}, 'js');
|
|
306
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'queryParams'], {}, 'js');
|
|
307
307
|
};
|
|
308
|
-
const getQueryParameter = ({
|
|
308
|
+
const getQueryParameter$1 = ({
|
|
309
309
|
state,
|
|
310
310
|
facet,
|
|
311
311
|
context = Context$1.facets
|
|
@@ -313,10 +313,10 @@ const getQueryParameter = ({
|
|
|
313
313
|
return getImmutableOrJS(getQueryParams(state, facet, context), key, ifnull, 'js');
|
|
314
314
|
};
|
|
315
315
|
const getCustomApi = (state, current, context = Context$1.facets, returnType) => {
|
|
316
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'customApi'], null, returnType);
|
|
316
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'customApi'], null, returnType);
|
|
317
317
|
};
|
|
318
318
|
const getCustomEnv = (state, current, context = Context$1.facets) => {
|
|
319
|
-
return getImmutableOrJS(state, ['search', context, current || getCurrent(state, context), 'env']);
|
|
319
|
+
return getImmutableOrJS(state, ['search', context, current || getCurrent$1(state, context), 'env']);
|
|
320
320
|
};
|
|
321
321
|
const getTabsAndFacets = (state, returnType) => {
|
|
322
322
|
const tabs = getSearchTabs(state, 'js');
|
|
@@ -362,59 +362,59 @@ const selectFacets = {
|
|
|
362
362
|
getFacetTitles,
|
|
363
363
|
getFacets,
|
|
364
364
|
getFacetsTotalCount,
|
|
365
|
-
getFeaturedResults,
|
|
365
|
+
getFeaturedResults: getFeaturedResults$1,
|
|
366
366
|
getFilters,
|
|
367
367
|
getFiltersToLoad,
|
|
368
368
|
getIsLoaded,
|
|
369
|
-
getIsLoading,
|
|
370
|
-
getPageIndex,
|
|
371
|
-
getPageIsLoading,
|
|
369
|
+
getIsLoading: getIsLoading$1,
|
|
370
|
+
getPageIndex: getPageIndex$1,
|
|
371
|
+
getPageIsLoading: getPageIsLoading$1,
|
|
372
372
|
getPagesLoaded,
|
|
373
|
-
getPaging,
|
|
373
|
+
getPaging: getPaging$1,
|
|
374
374
|
getQueryParams: (state, facet) => getQueryParams(state, facet, Context$1.facets),
|
|
375
375
|
getQueryParameter: ({
|
|
376
376
|
state,
|
|
377
377
|
facet
|
|
378
|
-
}, key, ifnull) => getQueryParameter({
|
|
378
|
+
}, key, ifnull) => getQueryParameter$1({
|
|
379
379
|
state,
|
|
380
380
|
facet,
|
|
381
381
|
context: Context$1.facets
|
|
382
382
|
}, key, ifnull),
|
|
383
|
-
getRenderableFilters,
|
|
384
|
-
getResults,
|
|
383
|
+
getRenderableFilters: getRenderableFilters$1,
|
|
384
|
+
getResults: getResults$1,
|
|
385
385
|
getTabFacets,
|
|
386
386
|
getTabsAndFacets,
|
|
387
387
|
getTotalCount,
|
|
388
388
|
getSearchTabs,
|
|
389
|
-
getSearchTerm,
|
|
389
|
+
getSearchTerm: getSearchTerm$1,
|
|
390
390
|
getSearchTotalCount,
|
|
391
391
|
getSelectedFilters
|
|
392
392
|
}; // An exported copy of the relevant selectors pre-scoped to a listing context
|
|
393
393
|
|
|
394
394
|
const selectListing = {
|
|
395
395
|
getCurrent: getCurrentListing,
|
|
396
|
-
getFeaturedResults: (state, listing = '') => getFeaturedResults(state, listing, Context$1.listings),
|
|
396
|
+
getFeaturedResults: (state, listing = '') => getFeaturedResults$1(state, listing, Context$1.listings),
|
|
397
397
|
getFilters: (state, listing = '') => getFilters(state, listing, Context$1.listings),
|
|
398
398
|
getFiltersToLoad: (state, listing = '') => getFiltersToLoad(state, listing, Context$1.listings),
|
|
399
|
-
getListing,
|
|
399
|
+
getListing: getListing$1,
|
|
400
400
|
getIsLoaded: state => getIsLoaded(state, Context$1.listings),
|
|
401
|
-
getIsLoading: state => getIsLoading(state, Context$1.listings),
|
|
402
|
-
getPageIndex: (state, listing = '') => getPageIndex(state, listing, Context$1.listings),
|
|
403
|
-
getPaging: (state, listing = '') => getPaging(state, listing, Context$1.listings),
|
|
404
|
-
getPageIsLoading: (state, listing = '') => getPageIsLoading(state, listing, Context$1.listings),
|
|
401
|
+
getIsLoading: state => getIsLoading$1(state, Context$1.listings),
|
|
402
|
+
getPageIndex: (state, listing = '') => getPageIndex$1(state, listing, Context$1.listings),
|
|
403
|
+
getPaging: (state, listing = '') => getPaging$1(state, listing, Context$1.listings),
|
|
404
|
+
getPageIsLoading: (state, listing = '') => getPageIsLoading$1(state, listing, Context$1.listings),
|
|
405
405
|
getPagesLoaded: (state, listing = '') => getPagesLoaded(state, listing, Context$1.listings),
|
|
406
406
|
getQueryParams: (state, listing = '') => getQueryParams(state, listing, Context$1.listings),
|
|
407
407
|
getQueryParameter: ({
|
|
408
408
|
state,
|
|
409
409
|
facet
|
|
410
|
-
}, key, ifnull) => getQueryParameter({
|
|
410
|
+
}, key, ifnull) => getQueryParameter$1({
|
|
411
411
|
state,
|
|
412
412
|
facet,
|
|
413
413
|
context: Context$1.listings
|
|
414
414
|
}, key, ifnull),
|
|
415
|
-
getRenderableFilters: (state, listing = '') => getRenderableFilters(state, listing, Context$1.listings),
|
|
416
|
-
getResults: (state, listing = '') => getResults(state, listing, Context$1.listings),
|
|
417
|
-
getSearchTerm,
|
|
415
|
+
getRenderableFilters: (state, listing = '') => getRenderableFilters$1(state, listing, Context$1.listings),
|
|
416
|
+
getResults: (state, listing = '') => getResults$1(state, listing, Context$1.listings),
|
|
417
|
+
getSearchTerm: getSearchTerm$1,
|
|
418
418
|
getTotalCount: (state, listing = '') => getTotalCount(state, listing, Context$1.listings),
|
|
419
419
|
getSelectedFilters: (state, listing = '') => getSelectedFilters(state, listing, Context$1.listings)
|
|
420
420
|
};
|
|
@@ -425,7 +425,7 @@ const selectVersionStatus = state => getImmutableOrJS(state, ['version', 'conten
|
|
|
425
425
|
var selectors = /*#__PURE__*/Object.freeze({
|
|
426
426
|
__proto__: null,
|
|
427
427
|
getSearchContext: getSearchContext,
|
|
428
|
-
getCurrent: getCurrent,
|
|
428
|
+
getCurrent: getCurrent$1,
|
|
429
429
|
getCurrentFacet: getCurrentFacet,
|
|
430
430
|
getCurrentListing: getCurrentListing,
|
|
431
431
|
getCurrentTab: getCurrentTab,
|
|
@@ -433,27 +433,27 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
433
433
|
getTabFacets: getTabFacets,
|
|
434
434
|
getFacetTitles: getFacetTitles,
|
|
435
435
|
getFacet: getFacet,
|
|
436
|
-
getListing: getListing,
|
|
436
|
+
getListing: getListing$1,
|
|
437
437
|
getFilters: getFilters,
|
|
438
|
-
getRenderableFilters: getRenderableFilters,
|
|
438
|
+
getRenderableFilters: getRenderableFilters$1,
|
|
439
439
|
getFiltersToLoad: getFiltersToLoad,
|
|
440
440
|
getSelectedFilters: getSelectedFilters,
|
|
441
|
-
getResults: getResults,
|
|
441
|
+
getResults: getResults$1,
|
|
442
442
|
getIsInternalPaging: getIsInternalPaging,
|
|
443
443
|
getIsLoaded: getIsLoaded,
|
|
444
|
-
getIsLoading: getIsLoading,
|
|
444
|
+
getIsLoading: getIsLoading$1,
|
|
445
445
|
getIsSsr: getIsSsr,
|
|
446
|
-
getFeaturedResults: getFeaturedResults,
|
|
447
|
-
getPaging: getPaging,
|
|
448
|
-
getPageIndex: getPageIndex,
|
|
446
|
+
getFeaturedResults: getFeaturedResults$1,
|
|
447
|
+
getPaging: getPaging$1,
|
|
448
|
+
getPageIndex: getPageIndex$1,
|
|
449
449
|
getPrevPageIndex: getPrevPageIndex,
|
|
450
|
-
getPageIsLoading: getPageIsLoading,
|
|
450
|
+
getPageIsLoading: getPageIsLoading$1,
|
|
451
451
|
getPagesLoaded: getPagesLoaded,
|
|
452
452
|
getTotalCount: getTotalCount,
|
|
453
|
-
getSearchTerm: getSearchTerm,
|
|
453
|
+
getSearchTerm: getSearchTerm$1,
|
|
454
454
|
getSearchTabs: getSearchTabs,
|
|
455
455
|
getQueryParams: getQueryParams,
|
|
456
|
-
getQueryParameter: getQueryParameter,
|
|
456
|
+
getQueryParameter: getQueryParameter$1,
|
|
457
457
|
getCustomApi: getCustomApi,
|
|
458
458
|
getCustomEnv: getCustomEnv,
|
|
459
459
|
getTabsAndFacets: getTabsAndFacets,
|
|
@@ -468,7 +468,6 @@ var selectors = /*#__PURE__*/Object.freeze({
|
|
|
468
468
|
|
|
469
469
|
// eslint-disable-next-line import/default
|
|
470
470
|
|
|
471
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
472
471
|
const withSearch = mappers => SearchComponent => {
|
|
473
472
|
const Wrapper = props => {
|
|
474
473
|
return /*#__PURE__*/React.createElement(SearchComponent, props);
|
|
@@ -479,22 +478,22 @@ const withSearch = mappers => SearchComponent => {
|
|
|
479
478
|
const mapStateToProps = state => {
|
|
480
479
|
return {
|
|
481
480
|
currentFacet: getCurrentFacet(state),
|
|
482
|
-
currentPageIndex: getPageIndex(state),
|
|
481
|
+
currentPageIndex: getPageIndex$1(state),
|
|
483
482
|
currentTabIndex: getCurrentTab(state),
|
|
484
483
|
facet: getFacet(state),
|
|
485
484
|
facets: getTabFacets(state),
|
|
486
485
|
facetsTotalCount: getFacetsTotalCount(state),
|
|
487
486
|
facetTitles: getFacetTitles(state),
|
|
488
|
-
featuredResults: getFeaturedResults(state),
|
|
489
|
-
filters: getRenderableFilters(state),
|
|
490
|
-
isLoading: getIsLoading(state),
|
|
491
|
-
paging: getPaging(state),
|
|
492
|
-
pageIsLoading: getPageIsLoading(state),
|
|
493
|
-
results: getResults(state),
|
|
487
|
+
featuredResults: getFeaturedResults$1(state),
|
|
488
|
+
filters: getRenderableFilters$1(state),
|
|
489
|
+
isLoading: getIsLoading$1(state),
|
|
490
|
+
paging: getPaging$1(state),
|
|
491
|
+
pageIsLoading: getPageIsLoading$1(state),
|
|
492
|
+
results: getResults$1(state),
|
|
494
493
|
resultsInfo: (mappers === null || mappers === void 0 ? void 0 : mappers.resultsInfo) && mappers.resultsInfo(state),
|
|
495
|
-
searchTerm: getSearchTerm(state),
|
|
494
|
+
searchTerm: getSearchTerm$1(state),
|
|
496
495
|
searchTotalCount: getSearchTotalCount(state),
|
|
497
|
-
sortOrder: getQueryParameter({
|
|
496
|
+
sortOrder: getQueryParameter$1({
|
|
498
497
|
state
|
|
499
498
|
}, 'dynamicOrderBy', []),
|
|
500
499
|
tabsAndFacets: getTabsAndFacets(state),
|
|
@@ -1199,7 +1198,7 @@ const searchUriTemplate = {
|
|
|
1199
1198
|
const currentSearch = !term && getImmutableOrJS(state, ['routing', 'location', 'search']);
|
|
1200
1199
|
const currentQs = removeEmptyAttributes(parse(currentSearch));
|
|
1201
1200
|
if (orderBy) currentQs.orderBy = orderBy;
|
|
1202
|
-
const searchTerm = getSearchTerm(state); // Merge the stateFilters with any current qs to build the new qs
|
|
1201
|
+
const searchTerm = getSearchTerm$1(state); // Merge the stateFilters with any current qs to build the new qs
|
|
1203
1202
|
|
|
1204
1203
|
const mergedSearch = removeEmptyAttributes({ ...merge(currentQs, stateFilters),
|
|
1205
1204
|
term: searchTerm
|
|
@@ -1386,10 +1385,10 @@ const mapFiltersToFilterExpression = (filters, selectedFilters) => {
|
|
|
1386
1385
|
};
|
|
1387
1386
|
|
|
1388
1387
|
const queryParamsTemplate = {
|
|
1389
|
-
assetTypes: root => getQueryParameter(root, 'assetTypes', []),
|
|
1390
|
-
contentTypeIds: root => getQueryParameter(root, 'contentTypeIds', []),
|
|
1391
|
-
customWhere: root => getQueryParameter(root, 'customWhere', []),
|
|
1392
|
-
dynamicOrderBy: root => getQueryParameter(root, 'dynamicOrderBy', []),
|
|
1388
|
+
assetTypes: root => getQueryParameter$1(root, 'assetTypes', []),
|
|
1389
|
+
contentTypeIds: root => getQueryParameter$1(root, 'contentTypeIds', []),
|
|
1390
|
+
customWhere: root => getQueryParameter$1(root, 'customWhere', []),
|
|
1391
|
+
dynamicOrderBy: root => getQueryParameter$1(root, 'dynamicOrderBy', []),
|
|
1393
1392
|
env: ({
|
|
1394
1393
|
state,
|
|
1395
1394
|
facet,
|
|
@@ -1404,8 +1403,8 @@ const queryParamsTemplate = {
|
|
|
1404
1403
|
if (excludeIds) return Array.isArray(excludeIds) ? excludeIds : excludeIds.split(',').map(id => id.trim());
|
|
1405
1404
|
return null;
|
|
1406
1405
|
},
|
|
1407
|
-
featuredResults: root => getQueryParameter(root, 'featuredResults', null),
|
|
1408
|
-
fields: root => getQueryParameter(root, 'fields', []),
|
|
1406
|
+
featuredResults: root => getQueryParameter$1(root, 'featuredResults', null),
|
|
1407
|
+
fields: root => getQueryParameter$1(root, 'fields', []),
|
|
1409
1408
|
filters: ({
|
|
1410
1409
|
state,
|
|
1411
1410
|
facet,
|
|
@@ -1417,28 +1416,28 @@ const queryParamsTemplate = {
|
|
|
1417
1416
|
const filterParams = mapFiltersToFilterExpression(stateFilters, selectedFilters);
|
|
1418
1417
|
return filterParams;
|
|
1419
1418
|
},
|
|
1420
|
-
includeInSearchFields: root => getQueryParameter(root, 'includeInSearch', []),
|
|
1419
|
+
includeInSearchFields: root => getQueryParameter$1(root, 'includeInSearch', []),
|
|
1421
1420
|
internalPageIndex: ({
|
|
1422
1421
|
action,
|
|
1423
1422
|
state
|
|
1424
|
-
}) => getPageIndex(state, '', action.context),
|
|
1425
|
-
internalPaging: root => getQueryParameter(root, 'internalPaging', false),
|
|
1423
|
+
}) => getPageIndex$1(state, '', action.context),
|
|
1424
|
+
internalPaging: root => getQueryParameter$1(root, 'internalPaging', false),
|
|
1426
1425
|
languages: ({
|
|
1427
1426
|
action
|
|
1428
1427
|
}) => action.defaultLang ? [action.defaultLang] : [],
|
|
1429
|
-
linkDepth: root => getQueryParameter(root, 'linkDepth', 0),
|
|
1430
|
-
loadMorePaging: root => getQueryParameter(root, 'loadMorePaging', false),
|
|
1431
|
-
orderBy: root => getQueryParameter(root, 'orderBy', []),
|
|
1428
|
+
linkDepth: root => getQueryParameter$1(root, 'linkDepth', 0),
|
|
1429
|
+
loadMorePaging: root => getQueryParameter$1(root, 'loadMorePaging', false),
|
|
1430
|
+
orderBy: root => getQueryParameter$1(root, 'orderBy', []),
|
|
1432
1431
|
pageIndex: root => {
|
|
1433
1432
|
const {
|
|
1434
1433
|
action,
|
|
1435
1434
|
state
|
|
1436
1435
|
} = root;
|
|
1437
|
-
if (getQueryParameter(root, 'internalPaging', false)) return 0;
|
|
1436
|
+
if (getQueryParameter$1(root, 'internalPaging', false)) return 0;
|
|
1438
1437
|
if (action.type === UPDATE_PAGE_INDEX) return action.params.pageIndex;
|
|
1439
|
-
return !action.preload ? getPageIndex(state, '', action.context) : 0;
|
|
1438
|
+
return !action.preload ? getPageIndex$1(state, '', action.context) : 0;
|
|
1440
1439
|
},
|
|
1441
|
-
pageSize: root => getQueryParameter(root, 'pageSize'),
|
|
1440
|
+
pageSize: root => getQueryParameter$1(root, 'pageSize'),
|
|
1442
1441
|
pagesLoaded: ({
|
|
1443
1442
|
state,
|
|
1444
1443
|
facet,
|
|
@@ -1458,7 +1457,7 @@ const queryParamsTemplate = {
|
|
|
1458
1457
|
|
|
1459
1458
|
return ((_getFacet = getFacet(state, facet, context)) === null || _getFacet === void 0 ? void 0 : _getFacet.projectId) || selectCurrentProject(state);
|
|
1460
1459
|
},
|
|
1461
|
-
searchTerm: root => root.context !== Context$1.minilist || getQueryParameter(root, 'useSearchTerm', false) ? getSearchTerm(root.state) : '',
|
|
1460
|
+
searchTerm: root => root.context !== Context$1.minilist || getQueryParameter$1(root, 'useSearchTerm', false) ? getSearchTerm$1(root.state) : '',
|
|
1462
1461
|
selectedFilters: ({
|
|
1463
1462
|
state,
|
|
1464
1463
|
facet,
|
|
@@ -1468,11 +1467,11 @@ const queryParamsTemplate = {
|
|
|
1468
1467
|
state
|
|
1469
1468
|
}) => selectVersionStatus(state),
|
|
1470
1469
|
weightedSearchFields: root => {
|
|
1471
|
-
const wsf = getQueryParameter(root, 'weightedSearchFields', []);
|
|
1470
|
+
const wsf = getQueryParameter$1(root, 'weightedSearchFields', []);
|
|
1472
1471
|
const deduped = wsf.filter((v, i, a) => a.findIndex(t => t.fieldId === v.fieldId) === i);
|
|
1473
1472
|
return deduped; // return wsf;
|
|
1474
1473
|
},
|
|
1475
|
-
webpageTemplates: root => getQueryParameter(root, 'webpageTemplates', [])
|
|
1474
|
+
webpageTemplates: root => getQueryParameter$1(root, 'webpageTemplates', [])
|
|
1476
1475
|
};
|
|
1477
1476
|
|
|
1478
1477
|
const mapStateToQueryParams = sourceJson => mapJson(sourceJson, queryParamsTemplate);
|
|
@@ -1518,8 +1517,8 @@ const runSearch = (action, state, queryParams) => {
|
|
|
1518
1517
|
const facetIsLoaded = defaultLang ? false : getIsLoaded(state, context, facet);
|
|
1519
1518
|
const stateParams = { ...getQueryParams(ogState, facet, context)
|
|
1520
1519
|
};
|
|
1521
|
-
stateParams.pageIndex = getPageIndex(ogState, facet, context);
|
|
1522
|
-
stateParams.searchTerm = getSearchTerm(ogState);
|
|
1520
|
+
stateParams.pageIndex = getPageIndex$1(ogState, facet, context);
|
|
1521
|
+
stateParams.searchTerm = getSearchTerm$1(ogState);
|
|
1523
1522
|
|
|
1524
1523
|
if (context === Context$1.facets && ssr || // context === Context.minilist ||
|
|
1525
1524
|
preload || !facetIsLoaded || filterParamsChanged(action) || defaultLang) {
|
|
@@ -1571,8 +1570,8 @@ const debugExecuteSearch = (action, state) => {
|
|
|
1571
1570
|
const [queryParams, runSearch] = generateQueryParams(action, state);
|
|
1572
1571
|
console.log('runSearch', runSearch, 'action', action, 'filterParamsChanged', filterParamsChanged(action, state), 'getIsLoaded(state, context, facet)', getIsLoaded(state, action.context, action.facet));
|
|
1573
1572
|
const stateParams = { ...getQueryParams(action.ogState || state, action.facet, action.context),
|
|
1574
|
-
pageIndex: getPageIndex(action.ogState || state, action.facet, action.context),
|
|
1575
|
-
searchTerm: getSearchTerm(action.ogState || state)
|
|
1573
|
+
pageIndex: getPageIndex$1(action.ogState || state, action.facet, action.context),
|
|
1574
|
+
searchTerm: getSearchTerm$1(action.ogState || state)
|
|
1576
1575
|
};
|
|
1577
1576
|
console.log(stateParams, queryParams);
|
|
1578
1577
|
console.log('getSelectedFilters', getSelectedFilters(action.ogState || state, action.facet, action.context, 'js'), 'params', action.params);
|
|
@@ -1638,14 +1637,20 @@ function* setRouteFilters(action) {
|
|
|
1638
1637
|
ssr,
|
|
1639
1638
|
debug
|
|
1640
1639
|
};
|
|
1641
|
-
yield put(nextAction); //
|
|
1640
|
+
yield put(nextAction); // keep track of this state ref for comparing changes to params later
|
|
1641
|
+
|
|
1642
|
+
const ogState = {
|
|
1643
|
+
search: state.search
|
|
1644
|
+
}; // Using call instead of triggering from the put
|
|
1642
1645
|
// to allow this exported saga to continue during SSR
|
|
1643
1646
|
|
|
1644
1647
|
yield call(ensureSearch, { ...nextAction,
|
|
1645
|
-
ogState
|
|
1648
|
+
ogState
|
|
1646
1649
|
});
|
|
1647
1650
|
}
|
|
1648
1651
|
function* doSearch(action) {
|
|
1652
|
+
var _action$params;
|
|
1653
|
+
|
|
1649
1654
|
const state = toJS(yield select());
|
|
1650
1655
|
|
|
1651
1656
|
if (action.config) {
|
|
@@ -1658,11 +1663,16 @@ function* doSearch(action) {
|
|
|
1658
1663
|
|
|
1659
1664
|
const nextAction = { ...action,
|
|
1660
1665
|
type: SET_SEARCH_FILTERS,
|
|
1661
|
-
ssr: getIsSsr(state)
|
|
1666
|
+
ssr: getIsSsr(state),
|
|
1667
|
+
facet: action.facet || ((_action$params = action.params) === null || _action$params === void 0 ? void 0 : _action$params.facet)
|
|
1668
|
+
};
|
|
1669
|
+
yield put(nextAction); // keep track of this state ref for comparing changes to params later
|
|
1670
|
+
|
|
1671
|
+
const ogState = {
|
|
1672
|
+
search: state.search
|
|
1662
1673
|
};
|
|
1663
|
-
yield put(nextAction);
|
|
1664
1674
|
yield call(ensureSearch, { ...nextAction,
|
|
1665
|
-
ogState
|
|
1675
|
+
ogState
|
|
1666
1676
|
});
|
|
1667
1677
|
}
|
|
1668
1678
|
|
|
@@ -1761,7 +1771,9 @@ function* ensureSearch(action) {
|
|
|
1761
1771
|
try {
|
|
1762
1772
|
const state = yield select();
|
|
1763
1773
|
const nextAction = { ...action,
|
|
1764
|
-
ogState: action.ogState ||
|
|
1774
|
+
ogState: action.ogState || {
|
|
1775
|
+
search: state.search
|
|
1776
|
+
}
|
|
1765
1777
|
};
|
|
1766
1778
|
const [queryParams, runSearch] = generateQueryParams(nextAction, state);
|
|
1767
1779
|
if (debug && (debug === true || debug.executeSearch)) debugExecuteSearch(nextAction, state);
|
|
@@ -1824,7 +1836,7 @@ function* executeSearch(action) {
|
|
|
1824
1836
|
action,
|
|
1825
1837
|
featuredResult,
|
|
1826
1838
|
pageIndex: queryParams.internalPaging && queryParams.internalPageIndex || queryParams.pageIndex,
|
|
1827
|
-
prevResults: getResults(state, facet, action.context, 'js'),
|
|
1839
|
+
prevResults: getResults$1(state, facet, action.context, 'js'),
|
|
1828
1840
|
result,
|
|
1829
1841
|
state
|
|
1830
1842
|
};
|
|
@@ -1901,7 +1913,7 @@ function* updateCurrentFacet(action) {
|
|
|
1901
1913
|
facet,
|
|
1902
1914
|
mappers
|
|
1903
1915
|
} = action;
|
|
1904
|
-
const pageIndex = yield select(getPageIndex, facet);
|
|
1916
|
+
const pageIndex = yield select(getPageIndex$1, facet);
|
|
1905
1917
|
const uri = yield buildUri({
|
|
1906
1918
|
facet,
|
|
1907
1919
|
pageIndex
|
|
@@ -1959,7 +1971,7 @@ function* buildUri({
|
|
|
1959
1971
|
term
|
|
1960
1972
|
}, mappers) {
|
|
1961
1973
|
const state = yield select();
|
|
1962
|
-
const mapUri = mappers
|
|
1974
|
+
const mapUri = (mappers === null || mappers === void 0 ? void 0 : mappers.navigate) || mapStateToSearchUri;
|
|
1963
1975
|
const uri = mapUri({
|
|
1964
1976
|
state,
|
|
1965
1977
|
facet,
|
|
@@ -1971,13 +1983,97 @@ function* buildUri({
|
|
|
1971
1983
|
return `${uri.path}${uri.search && `?${uri.search}` || ''}${uri.hash && `#${uri.hash}` || ''}`;
|
|
1972
1984
|
}
|
|
1973
1985
|
|
|
1986
|
+
var defaultMappers = {
|
|
1987
|
+
results: entries => entries,
|
|
1988
|
+
navigate: mapStateToSearchUri
|
|
1989
|
+
};
|
|
1990
|
+
|
|
1991
|
+
const {
|
|
1992
|
+
getCurrent,
|
|
1993
|
+
getFeaturedResults,
|
|
1994
|
+
getIsLoading,
|
|
1995
|
+
getListing,
|
|
1996
|
+
getPageIndex,
|
|
1997
|
+
getPageIsLoading,
|
|
1998
|
+
getPaging,
|
|
1999
|
+
getQueryParameter,
|
|
2000
|
+
getRenderableFilters,
|
|
2001
|
+
getResults,
|
|
2002
|
+
getSearchTerm
|
|
2003
|
+
} = selectListing;
|
|
2004
|
+
|
|
2005
|
+
const makeSelectListingProps = () => createSelector(state => state, (_, mappers) => mappers, (state, mappers) => ({
|
|
2006
|
+
currentListing: getCurrent(state),
|
|
2007
|
+
currentPageIndex: getPageIndex(state),
|
|
2008
|
+
listing: getListing(state),
|
|
2009
|
+
featured: getFeaturedResults(state),
|
|
2010
|
+
filters: getRenderableFilters(state),
|
|
2011
|
+
isLoading: getIsLoading(state),
|
|
2012
|
+
pageIsLoading: getPageIsLoading(state),
|
|
2013
|
+
paging: getPaging(state),
|
|
2014
|
+
results: getResults(state),
|
|
2015
|
+
resultsInfo: mappers && typeof mappers.resultsInfo === 'function' && mappers.resultsInfo(state),
|
|
2016
|
+
searchTerm: getSearchTerm(state),
|
|
2017
|
+
sortOrder: getQueryParameter({
|
|
2018
|
+
state
|
|
2019
|
+
}, 'dynamicOrderBy', [])
|
|
2020
|
+
}));
|
|
2021
|
+
|
|
2022
|
+
const useListing = ({
|
|
2023
|
+
mappers
|
|
2024
|
+
} = {
|
|
2025
|
+
id: ''
|
|
2026
|
+
}) => {
|
|
2027
|
+
const dispatch = useDispatch();
|
|
2028
|
+
const m = mappers || defaultMappers;
|
|
2029
|
+
const selectListingProps = useMemo(makeSelectListingProps, [m]);
|
|
2030
|
+
const dispatchProps = {
|
|
2031
|
+
clearFilters: () => dispatch(withMappers(clearFilters$1(), m)),
|
|
2032
|
+
updateCurrentFacet: facet => dispatch(withMappers(updateCurrentFacet$1(facet), m)),
|
|
2033
|
+
updatePageIndex: pageIndex => dispatch(withMappers(updatePageIndex$1(pageIndex), m)),
|
|
2034
|
+
updateSearchTerm: term => dispatch(withMappers(updateSearchTerm$1(term), m)),
|
|
2035
|
+
updateSelectedFilters: (filter, key, isUnknownItem = false) => dispatch(withMappers(updateSelectedFilters(filter, key, isUnknownItem), m)),
|
|
2036
|
+
updateSortOrder: orderBy => dispatch(withMappers(updateSortOrder$1(orderBy), m))
|
|
2037
|
+
};
|
|
2038
|
+
const {
|
|
2039
|
+
currentListing,
|
|
2040
|
+
currentPageIndex,
|
|
2041
|
+
featured,
|
|
2042
|
+
filters,
|
|
2043
|
+
isLoading,
|
|
2044
|
+
listing,
|
|
2045
|
+
paging,
|
|
2046
|
+
pageIsLoading,
|
|
2047
|
+
results,
|
|
2048
|
+
resultsInfo,
|
|
2049
|
+
searchTerm,
|
|
2050
|
+
sortOrder
|
|
2051
|
+
} = useSelector(state => selectListingProps(state, m));
|
|
2052
|
+
return {
|
|
2053
|
+
currentListing,
|
|
2054
|
+
currentPageIndex,
|
|
2055
|
+
featured,
|
|
2056
|
+
filters,
|
|
2057
|
+
isLoading,
|
|
2058
|
+
listing,
|
|
2059
|
+
pageIsLoading,
|
|
2060
|
+
paging,
|
|
2061
|
+
results,
|
|
2062
|
+
resultsInfo,
|
|
2063
|
+
searchTerm,
|
|
2064
|
+
sortOrder,
|
|
2065
|
+
title: listing.title,
|
|
2066
|
+
...dispatchProps
|
|
2067
|
+
};
|
|
2068
|
+
};
|
|
2069
|
+
|
|
1974
2070
|
const makeSelectMinilistProps = () => createSelector(state => state, (_, id) => id, (state, id) => ({
|
|
1975
2071
|
facet: getFacet(state, id, Context$1.minilist, 'js'),
|
|
1976
2072
|
filters: getFilters(state, id, Context$1.minilist, 'js'),
|
|
1977
|
-
isLoading: getIsLoading(state, Context$1.minilist, id),
|
|
1978
|
-
pagingInfo: getPaging(state, id, Context$1.minilist, 'js'),
|
|
1979
|
-
results: getResults(state, id, Context$1.minilist, 'js'),
|
|
1980
|
-
searchTerm: getSearchTerm(state)
|
|
2073
|
+
isLoading: getIsLoading$1(state, Context$1.minilist, id),
|
|
2074
|
+
pagingInfo: getPaging$1(state, id, Context$1.minilist, 'js'),
|
|
2075
|
+
results: getResults$1(state, id, Context$1.minilist, 'js'),
|
|
2076
|
+
searchTerm: getSearchTerm$1(state)
|
|
1981
2077
|
}));
|
|
1982
2078
|
|
|
1983
2079
|
const useMinilist = ({
|
|
@@ -2028,7 +2124,7 @@ const useMinilist = ({
|
|
|
2028
2124
|
return {
|
|
2029
2125
|
filters,
|
|
2030
2126
|
isLoading,
|
|
2031
|
-
pagingInfo,
|
|
2127
|
+
paging: pagingInfo,
|
|
2032
2128
|
results,
|
|
2033
2129
|
searchTerm,
|
|
2034
2130
|
title: facet.title
|
|
@@ -2212,7 +2308,10 @@ const generateFiltersState = ({
|
|
|
2212
2308
|
// the search results during SSR without needing to fetch the filters first
|
|
2213
2309
|
|
|
2214
2310
|
|
|
2215
|
-
Object.entries(filterParams).map(([paramName = '', paramValue]) =>
|
|
2311
|
+
Object.entries(filterParams).map(([paramName = '', paramValue]) => {
|
|
2312
|
+
if (typeof paramValue === 'string') return paramValue.split(',').map(pVal => filters = addFilterItem(filters, paramName, pVal));
|
|
2313
|
+
if (typeof paramValue === 'boolean') filters = addFilterItem(filters, paramName, paramValue);
|
|
2314
|
+
});
|
|
2216
2315
|
return Object.fromEntries(filters);
|
|
2217
2316
|
};
|
|
2218
2317
|
|
|
@@ -2474,12 +2573,11 @@ var reducers = (config => {
|
|
|
2474
2573
|
}, initState);
|
|
2475
2574
|
});
|
|
2476
2575
|
|
|
2477
|
-
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
2478
2576
|
const Context = {
|
|
2479
2577
|
facets: 'facets',
|
|
2480
2578
|
listings: 'listings',
|
|
2481
2579
|
minilist: 'minilist'
|
|
2482
2580
|
};
|
|
2483
2581
|
|
|
2484
|
-
export { Context, actions, doSearch, queries, reducers as reducer, searchSagas as sagas, schema, selectors, setRouteFilters, types, useMinilist, withListing, withSearch };
|
|
2582
|
+
export { Context, actions, doSearch, queries, reducers as reducer, searchSagas as sagas, schema, selectors, setRouteFilters, types, useListing, useMinilist, withListing, withSearch };
|
|
2485
2583
|
//# sourceMappingURL=search.js.map
|