react-instantsearch-core 6.40.3 → 7.0.0
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/README.md +70 -2
- package/dist/cjs/components/Configure.js +13 -0
- package/dist/cjs/components/DynamicWidgets.js +63 -0
- package/dist/cjs/components/Index.js +24 -0
- package/dist/cjs/components/InstantSearch.js +27 -0
- package/dist/cjs/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +27 -63
- package/dist/cjs/components/InstantSearchServerContext.js +12 -0
- package/dist/cjs/connectors/useBreadcrumb.js +12 -0
- package/dist/cjs/connectors/useClearRefinements.js +12 -0
- package/dist/cjs/connectors/useConfigure.js +14 -0
- package/dist/cjs/connectors/useCurrentRefinements.js +12 -0
- package/dist/cjs/connectors/useDynamicWidgets.js +22 -0
- package/dist/cjs/connectors/useGeoSearch.js +12 -0
- package/dist/cjs/connectors/useHierarchicalMenu.js +12 -0
- package/dist/cjs/connectors/useHits.js +12 -0
- package/dist/cjs/connectors/useHitsPerPage.js +12 -0
- package/dist/cjs/connectors/useInfiniteHits.js +12 -0
- package/dist/cjs/connectors/useMenu.js +12 -0
- package/dist/cjs/connectors/useNumericMenu.js +12 -0
- package/dist/cjs/connectors/usePagination.js +12 -0
- package/dist/cjs/connectors/usePoweredBy.js +21 -0
- package/dist/cjs/connectors/useQueryRules.js +12 -0
- package/dist/cjs/connectors/useRange.js +12 -0
- package/dist/cjs/connectors/useRefinementList.js +12 -0
- package/dist/cjs/connectors/useSearchBox.js +12 -0
- package/dist/cjs/connectors/useSortBy.js +12 -0
- package/dist/cjs/connectors/useStats.js +12 -0
- package/dist/cjs/connectors/useToggleRefinement.js +12 -0
- package/dist/cjs/hooks/useConnector.js +136 -0
- package/dist/cjs/hooks/useInstantSearch.js +58 -0
- package/dist/cjs/index.js +328 -320
- package/dist/cjs/lib/IndexContext.js +12 -0
- package/dist/cjs/lib/InstantSearchContext.js +12 -0
- package/dist/cjs/lib/InstantSearchSSRContext.js +12 -0
- package/dist/cjs/lib/createSearchResults.js +27 -0
- package/dist/cjs/lib/dequal.js +53 -0
- package/dist/cjs/lib/getIndexSearchResults.js +32 -0
- package/dist/cjs/lib/invariant.js +25 -0
- package/dist/cjs/lib/noop.js +8 -0
- package/dist/cjs/lib/useForceUpdate.js +25 -0
- package/dist/cjs/lib/useIndex.js +38 -0
- package/dist/cjs/lib/useIndexContext.js +14 -0
- package/dist/cjs/lib/useInstantSearchApi.js +191 -0
- package/dist/cjs/lib/useInstantSearchContext.js +14 -0
- package/dist/cjs/lib/useInstantSearchSSRContext.js +11 -0
- package/dist/cjs/lib/useInstantSearchServerContext.js +11 -0
- package/dist/cjs/lib/useIsomorphicLayoutEffect.js +14 -0
- package/dist/cjs/lib/useSearchResults.js +46 -0
- package/dist/cjs/lib/useSearchState.js +48 -0
- package/dist/cjs/lib/useStableValue.js +26 -0
- package/dist/cjs/lib/useWidget.js +78 -0
- package/dist/cjs/lib/warn.js +41 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/server/getServerState.js +93 -0
- package/dist/cjs/{types → server}/index.js +4 -4
- package/dist/cjs/{core/version.js → version.js} +1 -1
- package/dist/es/components/Configure.d.ts +3 -0
- package/dist/es/components/Configure.js +7 -0
- package/dist/es/components/DynamicWidgets.d.ts +13 -0
- package/dist/es/components/DynamicWidgets.js +55 -0
- package/dist/es/components/Index.d.ts +6 -0
- package/dist/es/components/Index.js +17 -0
- package/dist/es/components/InstantSearch.d.ts +7 -0
- package/dist/es/components/InstantSearch.js +20 -0
- package/dist/es/components/InstantSearchSSRProvider.d.ts +13 -0
- package/dist/es/{connectors/connectConfigure.js → components/InstantSearchSSRProvider.js} +26 -61
- package/dist/es/components/InstantSearchServerContext.d.ts +12 -0
- package/dist/es/components/InstantSearchServerContext.js +5 -0
- package/dist/es/connectors/useBreadcrumb.d.ts +4 -0
- package/dist/es/connectors/useBreadcrumb.js +5 -0
- package/dist/es/connectors/useClearRefinements.d.ts +4 -0
- package/dist/es/connectors/useClearRefinements.js +5 -0
- package/dist/es/connectors/useConfigure.d.ts +4 -0
- package/dist/es/connectors/useConfigure.js +7 -0
- package/dist/es/connectors/useCurrentRefinements.d.ts +4 -0
- package/dist/es/connectors/useCurrentRefinements.js +5 -0
- package/dist/es/connectors/useDynamicWidgets.d.ts +4 -0
- package/dist/es/connectors/useDynamicWidgets.js +15 -0
- package/dist/es/connectors/useGeoSearch.d.ts +6 -0
- package/dist/es/connectors/useGeoSearch.js +5 -0
- package/dist/es/connectors/useHierarchicalMenu.d.ts +4 -0
- package/dist/es/connectors/useHierarchicalMenu.js +5 -0
- package/dist/es/connectors/useHits.d.ts +5 -0
- package/dist/es/connectors/useHits.js +5 -0
- package/dist/es/connectors/useHitsPerPage.d.ts +4 -0
- package/dist/es/connectors/useHitsPerPage.js +5 -0
- package/dist/es/connectors/useInfiniteHits.d.ts +5 -0
- package/dist/es/connectors/useInfiniteHits.js +5 -0
- package/dist/es/connectors/useMenu.d.ts +4 -0
- package/dist/es/connectors/useMenu.js +5 -0
- package/dist/es/connectors/useNumericMenu.d.ts +4 -0
- package/dist/es/connectors/useNumericMenu.js +5 -0
- package/dist/es/connectors/usePagination.d.ts +4 -0
- package/dist/es/connectors/usePagination.js +5 -0
- package/dist/es/connectors/usePoweredBy.d.ts +2 -0
- package/dist/es/connectors/usePoweredBy.js +15 -0
- package/dist/es/connectors/useQueryRules.d.ts +4 -0
- package/dist/es/connectors/useQueryRules.js +5 -0
- package/dist/es/connectors/useRange.d.ts +4 -0
- package/dist/es/connectors/useRange.js +5 -0
- package/dist/es/connectors/useRefinementList.d.ts +4 -0
- package/dist/es/connectors/useRefinementList.js +5 -0
- package/dist/es/connectors/useSearchBox.d.ts +4 -0
- package/dist/es/connectors/useSearchBox.js +5 -0
- package/dist/es/connectors/useSortBy.d.ts +4 -0
- package/dist/es/connectors/useSortBy.js +5 -0
- package/dist/es/connectors/useStats.d.ts +4 -0
- package/dist/es/connectors/useStats.js +5 -0
- package/dist/es/connectors/useToggleRefinement.d.ts +4 -0
- package/dist/es/connectors/useToggleRefinement.js +5 -0
- package/dist/es/hooks/useConnector.d.ts +3 -0
- package/dist/es/hooks/useConnector.js +130 -0
- package/dist/es/hooks/useInstantSearch.d.ts +32 -0
- package/dist/es/hooks/useInstantSearch.js +52 -0
- package/dist/es/index.d.ts +31 -0
- package/dist/es/index.js +31 -86
- package/dist/es/lib/IndexContext.d.ts +3 -0
- package/dist/es/lib/IndexContext.js +5 -0
- package/dist/es/lib/InstantSearchContext.d.ts +3 -0
- package/dist/es/lib/InstantSearchContext.js +5 -0
- package/dist/es/lib/InstantSearchSSRContext.d.ts +8 -0
- package/dist/es/lib/InstantSearchSSRContext.js +5 -0
- package/dist/es/lib/createSearchResults.d.ts +3 -0
- package/dist/es/lib/createSearchResults.js +20 -0
- package/dist/es/lib/dequal.d.ts +1 -0
- package/dist/es/lib/dequal.js +47 -0
- package/dist/es/lib/getIndexSearchResults.d.ts +9 -0
- package/dist/es/lib/getIndexSearchResults.js +26 -0
- package/dist/es/lib/invariant.d.ts +9 -0
- package/dist/es/lib/invariant.js +19 -0
- package/dist/es/lib/noop.d.ts +1 -0
- package/dist/es/lib/noop.js +1 -0
- package/dist/es/lib/useForceUpdate.d.ts +6 -0
- package/dist/es/lib/useForceUpdate.js +20 -0
- package/dist/es/lib/useIndex.d.ts +3 -0
- package/dist/es/lib/useIndex.js +31 -0
- package/dist/es/lib/useIndexContext.d.ts +2 -0
- package/dist/es/lib/useIndexContext.js +8 -0
- package/dist/es/lib/useInstantSearchApi.d.ts +21 -0
- package/dist/es/lib/useInstantSearchApi.js +184 -0
- package/dist/es/lib/useInstantSearchContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchContext.js +8 -0
- package/dist/es/lib/useInstantSearchSSRContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchSSRContext.js +5 -0
- package/dist/es/lib/useInstantSearchServerContext.d.ts +3 -0
- package/dist/es/lib/useInstantSearchServerContext.js +5 -0
- package/dist/es/lib/useIsomorphicLayoutEffect.d.ts +7 -0
- package/dist/es/lib/useIsomorphicLayoutEffect.js +8 -0
- package/dist/es/lib/useSearchResults.d.ts +7 -0
- package/dist/es/lib/useSearchResults.js +40 -0
- package/dist/es/lib/useSearchState.d.ts +8 -0
- package/dist/es/lib/useSearchState.js +42 -0
- package/dist/es/lib/useStableValue.d.ts +1 -0
- package/dist/es/lib/useStableValue.js +20 -0
- package/dist/es/lib/useWidget.d.ts +8 -0
- package/dist/es/lib/useWidget.js +72 -0
- package/dist/es/lib/warn.d.ts +10 -0
- package/dist/es/lib/warn.js +33 -0
- package/dist/es/server/getServerState.d.ts +10 -0
- package/dist/es/server/getServerState.js +86 -0
- package/dist/es/server/index.d.ts +1 -0
- package/dist/es/server/index.js +1 -0
- package/dist/es/version.d.ts +2 -0
- package/dist/es/version.js +1 -0
- package/dist/umd/ReactInstantSearchCore.js +16316 -10183
- package/dist/umd/ReactInstantSearchCore.js.map +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js +1 -1
- package/dist/umd/ReactInstantSearchCore.min.js.map +1 -1
- package/package.json +24 -9
- package/dist/cjs/connectors/connectAutoComplete.js +0 -104
- package/dist/cjs/connectors/connectBreadcrumb.js +0 -123
- package/dist/cjs/connectors/connectConfigureRelatedItems.js +0 -127
- package/dist/cjs/connectors/connectCurrentRefinements.js +0 -69
- package/dist/cjs/connectors/connectDynamicWidgets.js +0 -65
- package/dist/cjs/connectors/connectGeoSearch.js +0 -189
- package/dist/cjs/connectors/connectHierarchicalMenu.js +0 -273
- package/dist/cjs/connectors/connectHighlight.js +0 -87
- package/dist/cjs/connectors/connectHitInsights.js +0 -76
- package/dist/cjs/connectors/connectHits.js +0 -88
- package/dist/cjs/connectors/connectHitsPerPage.js +0 -97
- package/dist/cjs/connectors/connectInfiniteHits.js +0 -154
- package/dist/cjs/connectors/connectMenu.js +0 -221
- package/dist/cjs/connectors/connectNumericMenu.js +0 -215
- package/dist/cjs/connectors/connectPagination.js +0 -94
- package/dist/cjs/connectors/connectPoweredBy.js +0 -27
- package/dist/cjs/connectors/connectQueryRules.js +0 -129
- package/dist/cjs/connectors/connectRange.js +0 -287
- package/dist/cjs/connectors/connectRefinementList.js +0 -243
- package/dist/cjs/connectors/connectRelevantSort.js +0 -56
- package/dist/cjs/connectors/connectScrollTo.js +0 -70
- package/dist/cjs/connectors/connectSearchBox.js +0 -104
- package/dist/cjs/connectors/connectSortBy.js +0 -100
- package/dist/cjs/connectors/connectStateResults.js +0 -79
- package/dist/cjs/connectors/connectStats.js +0 -39
- package/dist/cjs/connectors/connectToggleRefinement.js +0 -163
- package/dist/cjs/connectors/connectVoiceSearch.js +0 -124
- package/dist/cjs/core/context.js +0 -37
- package/dist/cjs/core/createConnector.js +0 -268
- package/dist/cjs/core/createInstantSearchManager.d.js +0 -1
- package/dist/cjs/core/createInstantSearchManager.js +0 -541
- package/dist/cjs/core/createStore.js +0 -27
- package/dist/cjs/core/createWidgetsManager.js +0 -39
- package/dist/cjs/core/highlight.js +0 -102
- package/dist/cjs/core/indexUtils.js +0 -214
- package/dist/cjs/core/metadata.js +0 -46
- package/dist/cjs/core/translatable.js +0 -82
- package/dist/cjs/core/utils.js +0 -161
- package/dist/cjs/types/algoliasearch.js +0 -1
- package/dist/cjs/types/translatable.js +0 -1
- package/dist/cjs/widgets/Configure.js +0 -48
- package/dist/cjs/widgets/ConfigureRelatedItems.js +0 -21
- package/dist/cjs/widgets/DynamicWidgets.js +0 -61
- package/dist/cjs/widgets/Index.js +0 -149
- package/dist/cjs/widgets/InstantSearch.js +0 -251
- package/dist/cjs/widgets/QueryRuleContext.js +0 -14
- package/dist/es/connectors/connectAutoComplete.js +0 -96
- package/dist/es/connectors/connectBreadcrumb.js +0 -115
- package/dist/es/connectors/connectConfigureRelatedItems.js +0 -121
- package/dist/es/connectors/connectCurrentRefinements.js +0 -62
- package/dist/es/connectors/connectDynamicWidgets.js +0 -56
- package/dist/es/connectors/connectGeoSearch.js +0 -182
- package/dist/es/connectors/connectHierarchicalMenu.js +0 -264
- package/dist/es/connectors/connectHighlight.js +0 -79
- package/dist/es/connectors/connectHitInsights.js +0 -69
- package/dist/es/connectors/connectHits.js +0 -81
- package/dist/es/connectors/connectHitsPerPage.js +0 -89
- package/dist/es/connectors/connectInfiniteHits.js +0 -146
- package/dist/es/connectors/connectMenu.js +0 -213
- package/dist/es/connectors/connectNumericMenu.js +0 -207
- package/dist/es/connectors/connectPagination.js +0 -86
- package/dist/es/connectors/connectPoweredBy.js +0 -20
- package/dist/es/connectors/connectQueryRules.js +0 -122
- package/dist/es/connectors/connectRange.js +0 -280
- package/dist/es/connectors/connectRefinementList.js +0 -235
- package/dist/es/connectors/connectRelevantSort.js +0 -50
- package/dist/es/connectors/connectScrollTo.js +0 -63
- package/dist/es/connectors/connectSearchBox.js +0 -96
- package/dist/es/connectors/connectSortBy.js +0 -92
- package/dist/es/connectors/connectStateResults.js +0 -72
- package/dist/es/connectors/connectStats.js +0 -32
- package/dist/es/connectors/connectToggleRefinement.js +0 -155
- package/dist/es/connectors/connectVoiceSearch.js +0 -116
- package/dist/es/core/context.js +0 -28
- package/dist/es/core/createConnector.js +0 -257
- package/dist/es/core/createInstantSearchManager.d.js +0 -0
- package/dist/es/core/createInstantSearchManager.js +0 -534
- package/dist/es/core/createStore.js +0 -21
- package/dist/es/core/createWidgetsManager.js +0 -33
- package/dist/es/core/highlight.js +0 -94
- package/dist/es/core/indexUtils.js +0 -203
- package/dist/es/core/metadata.js +0 -38
- package/dist/es/core/translatable.js +0 -74
- package/dist/es/core/utils.js +0 -139
- package/dist/es/core/version.js +0 -1
- package/dist/es/types/algoliasearch.js +0 -1
- package/dist/es/types/index.js +0 -1
- package/dist/es/types/translatable.js +0 -1
- package/dist/es/widgets/Configure.js +0 -42
- package/dist/es/widgets/ConfigureRelatedItems.js +0 -13
- package/dist/es/widgets/DynamicWidgets.js +0 -51
- package/dist/es/widgets/Index.js +0 -138
- package/dist/es/widgets/InstantSearch.js +0 -241
- package/dist/es/widgets/QueryRuleContext.js +0 -6
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
8
|
-
var _indexUtils = require("../core/indexUtils");
|
|
9
|
-
var _utils = require("../core/utils");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
/**
|
|
12
|
-
* connectHits connector provides the logic to create connected
|
|
13
|
-
* components that will render the results retrieved from
|
|
14
|
-
* Algolia.
|
|
15
|
-
*
|
|
16
|
-
* To configure the number of hits retrieved, use [HitsPerPage widget](widgets/HitsPerPage.html),
|
|
17
|
-
* [connectHitsPerPage connector](connectors/connectHitsPerPage.html) or pass the hitsPerPage
|
|
18
|
-
* prop to a [Configure](guide/Search_parameters.html) widget.
|
|
19
|
-
*
|
|
20
|
-
* **Warning:** you will need to use the **objectID** property available on every hit as a key
|
|
21
|
-
* when iterating over them. This will ensure you have the best possible UI experience
|
|
22
|
-
* especially on slow networks.
|
|
23
|
-
* @name connectHits
|
|
24
|
-
* @kind connector
|
|
25
|
-
* @providedPropType {array.<object>} hits - the records that matched the search state
|
|
26
|
-
* @example
|
|
27
|
-
* import React from 'react';
|
|
28
|
-
* import algoliasearch from 'algoliasearch/lite';
|
|
29
|
-
* import { InstantSearch, Highlight, connectHits } from 'react-instantsearch-dom';
|
|
30
|
-
*
|
|
31
|
-
* const searchClient = algoliasearch(
|
|
32
|
-
* 'latency',
|
|
33
|
-
* '6be0576ff61c053d5f9a3225e2a90f76'
|
|
34
|
-
* );
|
|
35
|
-
* const CustomHits = connectHits(({ hits }) => (
|
|
36
|
-
* <div>
|
|
37
|
-
* {hits.map(hit =>
|
|
38
|
-
* <p key={hit.objectID}>
|
|
39
|
-
* <Highlight attribute="name" hit={hit} />
|
|
40
|
-
* </p>
|
|
41
|
-
* )}
|
|
42
|
-
* </div>
|
|
43
|
-
* ));
|
|
44
|
-
*
|
|
45
|
-
* const App = () => (
|
|
46
|
-
* <InstantSearch
|
|
47
|
-
* searchClient={searchClient}
|
|
48
|
-
* indexName="instant_search"
|
|
49
|
-
* >
|
|
50
|
-
* <CustomHits />
|
|
51
|
-
* </InstantSearch>
|
|
52
|
-
* );
|
|
53
|
-
*/
|
|
54
|
-
var _default = (0, _createConnector.default)({
|
|
55
|
-
displayName: 'AlgoliaHits',
|
|
56
|
-
$$type: 'ais.hits',
|
|
57
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
58
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
59
|
-
ais: props.contextValue,
|
|
60
|
-
multiIndexContext: props.indexContextValue
|
|
61
|
-
});
|
|
62
|
-
if (!results) {
|
|
63
|
-
return {
|
|
64
|
-
hits: []
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
var hitsWithPositions = (0, _utils.addAbsolutePositions)(results.hits, results.hitsPerPage, results.page);
|
|
68
|
-
var hitsWithPositionsAndQueryID = (0, _utils.addQueryID)(hitsWithPositions, results.queryID);
|
|
69
|
-
return {
|
|
70
|
-
hits: hitsWithPositionsAndQueryID
|
|
71
|
-
};
|
|
72
|
-
},
|
|
73
|
-
/*
|
|
74
|
-
* Hits needs to be considered as a widget to trigger a search,
|
|
75
|
-
* even if no other widgets are used.
|
|
76
|
-
*
|
|
77
|
-
* To be considered as a widget you need either:
|
|
78
|
-
* - getSearchParameters
|
|
79
|
-
* - getMetadata
|
|
80
|
-
* - transitionState
|
|
81
|
-
*
|
|
82
|
-
* See: createConnector.tsx
|
|
83
|
-
*/
|
|
84
|
-
getSearchParameters: function getSearchParameters(searchParameters) {
|
|
85
|
-
return searchParameters;
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
exports.default = _default;
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
9
|
-
var _indexUtils = require("../core/indexUtils");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
12
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
|
-
function getId() {
|
|
18
|
-
return 'hitsPerPage';
|
|
19
|
-
}
|
|
20
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
21
|
-
var id = getId();
|
|
22
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, null);
|
|
23
|
-
if (typeof currentRefinement === 'string') {
|
|
24
|
-
return parseInt(currentRefinement, 10);
|
|
25
|
-
}
|
|
26
|
-
return currentRefinement;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* connectHitsPerPage connector provides the logic to create connected
|
|
31
|
-
* components that will allow a user to choose to display more or less results from Algolia.
|
|
32
|
-
* @name connectHitsPerPage
|
|
33
|
-
* @kind connector
|
|
34
|
-
* @propType {number} defaultRefinement - The number of items selected by default
|
|
35
|
-
* @propType {{value: number, label: string}[]} items - List of hits per page options.
|
|
36
|
-
* @propType {function} [transformItems] - Function to modify the items being displayed, e.g. for filtering or sorting them. Takes an items as parameter and expects it back in return.
|
|
37
|
-
* @providedPropType {function} refine - a function to remove a single filter
|
|
38
|
-
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
39
|
-
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
40
|
-
* @providedPropType {array.<{isRefined: boolean, label?: string, value: number}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.
|
|
41
|
-
*/
|
|
42
|
-
var _default = (0, _createConnector.default)({
|
|
43
|
-
displayName: 'AlgoliaHitsPerPage',
|
|
44
|
-
$$type: 'ais.hitsPerPage',
|
|
45
|
-
propTypes: {
|
|
46
|
-
defaultRefinement: _propTypes.default.number.isRequired,
|
|
47
|
-
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
48
|
-
label: _propTypes.default.string,
|
|
49
|
-
value: _propTypes.default.number.isRequired
|
|
50
|
-
})).isRequired,
|
|
51
|
-
transformItems: _propTypes.default.func
|
|
52
|
-
},
|
|
53
|
-
getProvidedProps: function getProvidedProps(props, searchState) {
|
|
54
|
-
var currentRefinement = getCurrentRefinement(props, searchState, {
|
|
55
|
-
ais: props.contextValue,
|
|
56
|
-
multiIndexContext: props.indexContextValue
|
|
57
|
-
});
|
|
58
|
-
var items = props.items.map(function (item) {
|
|
59
|
-
return item.value === currentRefinement ? _objectSpread(_objectSpread({}, item), {}, {
|
|
60
|
-
isRefined: true
|
|
61
|
-
}) : _objectSpread(_objectSpread({}, item), {}, {
|
|
62
|
-
isRefined: false
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
return {
|
|
66
|
-
items: props.transformItems ? props.transformItems(items) : items,
|
|
67
|
-
currentRefinement: currentRefinement
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
71
|
-
var id = getId();
|
|
72
|
-
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
73
|
-
var resetPage = true;
|
|
74
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, {
|
|
75
|
-
ais: props.contextValue,
|
|
76
|
-
multiIndexContext: props.indexContextValue
|
|
77
|
-
}, resetPage);
|
|
78
|
-
},
|
|
79
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
80
|
-
return (0, _indexUtils.cleanUpValue)(searchState, {
|
|
81
|
-
ais: props.contextValue,
|
|
82
|
-
multiIndexContext: props.indexContextValue
|
|
83
|
-
}, getId());
|
|
84
|
-
},
|
|
85
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
86
|
-
return searchParameters.setHitsPerPage(getCurrentRefinement(props, searchState, {
|
|
87
|
-
ais: props.contextValue,
|
|
88
|
-
multiIndexContext: props.indexContextValue
|
|
89
|
-
}));
|
|
90
|
-
},
|
|
91
|
-
getMetadata: function getMetadata() {
|
|
92
|
-
return {
|
|
93
|
-
id: getId()
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
exports.default = _default;
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.default = void 0;
|
|
8
|
-
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
9
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
10
|
-
var _indexUtils = require("../core/indexUtils");
|
|
11
|
-
var _utils = require("../core/utils");
|
|
12
|
-
var _excluded = ["page"];
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
15
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
17
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
18
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
21
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
22
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
23
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
24
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
25
|
-
function getId() {
|
|
26
|
-
return 'page';
|
|
27
|
-
}
|
|
28
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
29
|
-
var id = getId();
|
|
30
|
-
var page = 1;
|
|
31
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, page);
|
|
32
|
-
if (typeof currentRefinement === 'string') {
|
|
33
|
-
return parseInt(currentRefinement, 10);
|
|
34
|
-
}
|
|
35
|
-
return currentRefinement;
|
|
36
|
-
}
|
|
37
|
-
function getStateWithoutPage(state) {
|
|
38
|
-
var _ref = state || {},
|
|
39
|
-
page = _ref.page,
|
|
40
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
41
|
-
return rest;
|
|
42
|
-
}
|
|
43
|
-
function getInMemoryCache() {
|
|
44
|
-
var cachedHits = undefined;
|
|
45
|
-
var cachedState = undefined;
|
|
46
|
-
return {
|
|
47
|
-
read: function read(_ref2) {
|
|
48
|
-
var state = _ref2.state;
|
|
49
|
-
return (0, _reactFastCompare.default)(cachedState, getStateWithoutPage(state)) ? cachedHits : null;
|
|
50
|
-
},
|
|
51
|
-
write: function write(_ref3) {
|
|
52
|
-
var state = _ref3.state,
|
|
53
|
-
hits = _ref3.hits;
|
|
54
|
-
cachedState = getStateWithoutPage(state);
|
|
55
|
-
cachedHits = hits;
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
function extractHitsFromCachedHits(cachedHits) {
|
|
60
|
-
return Object.keys(cachedHits).map(Number).sort(function (a, b) {
|
|
61
|
-
return a - b;
|
|
62
|
-
}).reduce(function (acc, page) {
|
|
63
|
-
return acc.concat(cachedHits[page]);
|
|
64
|
-
}, []);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* InfiniteHits connector provides the logic to create connected
|
|
69
|
-
* components that will render an continuous list of results retrieved from
|
|
70
|
-
* Algolia. This connector provides a function to load more results.
|
|
71
|
-
* @name connectInfiniteHits
|
|
72
|
-
* @kind connector
|
|
73
|
-
* @providedPropType {array.<object>} hits - the records that matched the search state
|
|
74
|
-
* @providedPropType {boolean} hasMore - indicates if there are more pages to load
|
|
75
|
-
* @providedPropType {function} refine - call to load more results
|
|
76
|
-
*/
|
|
77
|
-
var _default = (0, _createConnector.default)({
|
|
78
|
-
displayName: 'AlgoliaInfiniteHits',
|
|
79
|
-
$$type: 'ais.infiniteHits',
|
|
80
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
81
|
-
var _this = this;
|
|
82
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
83
|
-
ais: props.contextValue,
|
|
84
|
-
multiIndexContext: props.indexContextValue
|
|
85
|
-
});
|
|
86
|
-
if (!results) {
|
|
87
|
-
return {
|
|
88
|
-
hits: [],
|
|
89
|
-
hasPrevious: false,
|
|
90
|
-
hasMore: false,
|
|
91
|
-
refine: function refine() {},
|
|
92
|
-
refinePrevious: function refinePrevious() {},
|
|
93
|
-
refineNext: function refineNext() {}
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
var page = results.page,
|
|
97
|
-
hits = results.hits,
|
|
98
|
-
hitsPerPage = results.hitsPerPage,
|
|
99
|
-
nbPages = results.nbPages,
|
|
100
|
-
state = results._state;
|
|
101
|
-
this._cache = props.cache ? props.cache : this._cache || getInMemoryCache();
|
|
102
|
-
var cachedHits = this._cache.read({
|
|
103
|
-
state: state
|
|
104
|
-
}) || {};
|
|
105
|
-
var hitsWithPositions = (0, _utils.addAbsolutePositions)(hits, hitsPerPage, page);
|
|
106
|
-
var hitsWithPositionsAndQueryID = (0, _utils.addQueryID)(hitsWithPositions, results.queryID);
|
|
107
|
-
cachedHits[page] = hitsWithPositionsAndQueryID;
|
|
108
|
-
this._cache.write({
|
|
109
|
-
state: state,
|
|
110
|
-
hits: cachedHits
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
/*
|
|
114
|
-
Math.min() and Math.max() returns Infinity or -Infinity when no argument is given.
|
|
115
|
-
But there is always something in this point because of `cachedHits[page]`.
|
|
116
|
-
*/
|
|
117
|
-
var firstReceivedPage = Math.min.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
|
|
118
|
-
var lastReceivedPage = Math.max.apply(Math, _toConsumableArray(Object.keys(cachedHits).map(Number)));
|
|
119
|
-
var hasPrevious = firstReceivedPage > 0;
|
|
120
|
-
var lastPageIndex = nbPages - 1;
|
|
121
|
-
var hasMore = lastReceivedPage < lastPageIndex;
|
|
122
|
-
var refinePrevious = function refinePrevious(event) {
|
|
123
|
-
return _this.refine(event, firstReceivedPage - 1);
|
|
124
|
-
};
|
|
125
|
-
var refineNext = function refineNext(event) {
|
|
126
|
-
return _this.refine(event, lastReceivedPage + 1);
|
|
127
|
-
};
|
|
128
|
-
return {
|
|
129
|
-
hits: extractHitsFromCachedHits(cachedHits),
|
|
130
|
-
hasPrevious: hasPrevious,
|
|
131
|
-
hasMore: hasMore,
|
|
132
|
-
refinePrevious: refinePrevious,
|
|
133
|
-
refineNext: refineNext
|
|
134
|
-
};
|
|
135
|
-
},
|
|
136
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
137
|
-
return searchParameters.setQueryParameters({
|
|
138
|
-
page: getCurrentRefinement(props, searchState, {
|
|
139
|
-
ais: props.contextValue,
|
|
140
|
-
multiIndexContext: props.indexContextValue
|
|
141
|
-
}) - 1
|
|
142
|
-
});
|
|
143
|
-
},
|
|
144
|
-
refine: function refine(props, searchState, event, index) {
|
|
145
|
-
var id = getId();
|
|
146
|
-
var nextValue = _defineProperty({}, id, index + 1);
|
|
147
|
-
var resetPage = false;
|
|
148
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, {
|
|
149
|
-
ais: props.contextValue,
|
|
150
|
-
multiIndexContext: props.indexContextValue
|
|
151
|
-
}, resetPage);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
exports.default = _default;
|
|
@@ -1,221 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
9
|
-
var _indexUtils = require("../core/indexUtils");
|
|
10
|
-
var _utils = require("../core/utils");
|
|
11
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
12
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
13
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
-
var namespace = 'menu';
|
|
17
|
-
function getId(props) {
|
|
18
|
-
return props.attribute;
|
|
19
|
-
}
|
|
20
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
21
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), null);
|
|
22
|
-
if (currentRefinement === '') {
|
|
23
|
-
return null;
|
|
24
|
-
}
|
|
25
|
-
return currentRefinement;
|
|
26
|
-
}
|
|
27
|
-
function getValue(value, props, searchState, context) {
|
|
28
|
-
var currentRefinement = getCurrentRefinement(props, searchState, context);
|
|
29
|
-
return value === currentRefinement ? '' : value;
|
|
30
|
-
}
|
|
31
|
-
function getLimit(_ref) {
|
|
32
|
-
var showMore = _ref.showMore,
|
|
33
|
-
limit = _ref.limit,
|
|
34
|
-
showMoreLimit = _ref.showMoreLimit;
|
|
35
|
-
return showMore ? showMoreLimit : limit;
|
|
36
|
-
}
|
|
37
|
-
function _refine(props, searchState, nextRefinement, context) {
|
|
38
|
-
var id = getId(props);
|
|
39
|
-
var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : '');
|
|
40
|
-
var resetPage = true;
|
|
41
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
|
|
42
|
-
}
|
|
43
|
-
function _cleanUp(props, searchState, context) {
|
|
44
|
-
return (0, _indexUtils.cleanUpValue)(searchState, context, "".concat(namespace, ".").concat(getId(props)));
|
|
45
|
-
}
|
|
46
|
-
var defaultSortBy = ['count:desc', 'name:asc'];
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* connectMenu connector provides the logic to build a widget that will
|
|
50
|
-
* give the user the ability to choose a single value for a specific facet.
|
|
51
|
-
* @name connectMenu
|
|
52
|
-
* @requirements The attribute passed to the `attribute` prop must be present in "attributes for faceting"
|
|
53
|
-
* on the Algolia dashboard or configured as `attributesForFaceting` via a set settings call to the Algolia API.
|
|
54
|
-
* @kind connector
|
|
55
|
-
* @propType {string} attribute - the name of the attribute in the record
|
|
56
|
-
* @propType {boolean} [showMore=false] - true if the component should display a button that will expand the number of items
|
|
57
|
-
* @propType {number} [limit=10] - the minimum number of diplayed items
|
|
58
|
-
* @propType {number} [showMoreLimit=20] - the maximun number of displayed items. Only used when showMore is set to `true`
|
|
59
|
-
* @propType {string} [defaultRefinement] - the value of the item selected by default
|
|
60
|
-
* @propType {boolean} [searchable=false] - allow search inside values
|
|
61
|
-
* @providedPropType {function} refine - a function to toggle a refinement
|
|
62
|
-
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
63
|
-
* @providedPropType {string} currentRefinement - the refinement currently applied
|
|
64
|
-
* @providedPropType {array.<{count: number, isRefined: boolean, label: string, value: string}>} items - the list of items the Menu can display.
|
|
65
|
-
* @providedPropType {function} searchForItems - a function to toggle a search inside items values
|
|
66
|
-
* @providedPropType {boolean} isFromSearch - a boolean that says if the `items` props contains facet values from the global search or from the search inside items.
|
|
67
|
-
*/
|
|
68
|
-
var _default = (0, _createConnector.default)({
|
|
69
|
-
displayName: 'AlgoliaMenu',
|
|
70
|
-
$$type: 'ais.menu',
|
|
71
|
-
propTypes: {
|
|
72
|
-
attribute: _propTypes.default.string.isRequired,
|
|
73
|
-
showMore: _propTypes.default.bool,
|
|
74
|
-
limit: _propTypes.default.number,
|
|
75
|
-
showMoreLimit: _propTypes.default.number,
|
|
76
|
-
defaultRefinement: _propTypes.default.string,
|
|
77
|
-
transformItems: _propTypes.default.func,
|
|
78
|
-
searchable: _propTypes.default.bool,
|
|
79
|
-
facetOrdering: _propTypes.default.bool
|
|
80
|
-
},
|
|
81
|
-
defaultProps: {
|
|
82
|
-
showMore: false,
|
|
83
|
-
limit: 10,
|
|
84
|
-
showMoreLimit: 20,
|
|
85
|
-
facetOrdering: true
|
|
86
|
-
},
|
|
87
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults, meta, searchForFacetValuesResults) {
|
|
88
|
-
var attribute = props.attribute,
|
|
89
|
-
searchable = props.searchable,
|
|
90
|
-
indexContextValue = props.indexContextValue,
|
|
91
|
-
facetOrdering = props.facetOrdering;
|
|
92
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
93
|
-
ais: props.contextValue,
|
|
94
|
-
multiIndexContext: props.indexContextValue
|
|
95
|
-
});
|
|
96
|
-
var canRefine = Boolean(results) && Boolean(results.getFacetByName(attribute));
|
|
97
|
-
var isFromSearch = Boolean(searchForFacetValuesResults && searchForFacetValuesResults[attribute] && searchForFacetValuesResults.query !== '');
|
|
98
|
-
|
|
99
|
-
// Search For Facet Values is not available with derived helper (used for multi index search)
|
|
100
|
-
if (searchable && indexContextValue) {
|
|
101
|
-
throw new Error('react-instantsearch: searching in *List is not available when used inside a' + ' multi index context');
|
|
102
|
-
}
|
|
103
|
-
if (!canRefine) {
|
|
104
|
-
return {
|
|
105
|
-
items: [],
|
|
106
|
-
currentRefinement: getCurrentRefinement(props, searchState, {
|
|
107
|
-
ais: props.contextValue,
|
|
108
|
-
multiIndexContext: props.indexContextValue
|
|
109
|
-
}),
|
|
110
|
-
isFromSearch: isFromSearch,
|
|
111
|
-
searchable: searchable,
|
|
112
|
-
canRefine: canRefine
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
var items;
|
|
116
|
-
if (isFromSearch) {
|
|
117
|
-
items = searchForFacetValuesResults[attribute].map(function (v) {
|
|
118
|
-
return {
|
|
119
|
-
label: v.value,
|
|
120
|
-
value: getValue(v.escapedValue, props, searchState, {
|
|
121
|
-
ais: props.contextValue,
|
|
122
|
-
multiIndexContext: props.indexContextValue
|
|
123
|
-
}),
|
|
124
|
-
_highlightResult: {
|
|
125
|
-
label: {
|
|
126
|
-
value: v.highlighted
|
|
127
|
-
}
|
|
128
|
-
},
|
|
129
|
-
count: v.count,
|
|
130
|
-
isRefined: v.isRefined
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
} else {
|
|
134
|
-
items = results.getFacetValues(attribute, {
|
|
135
|
-
sortBy: searchable ? undefined : defaultSortBy,
|
|
136
|
-
facetOrdering: facetOrdering
|
|
137
|
-
}).map(function (v) {
|
|
138
|
-
return {
|
|
139
|
-
label: v.name,
|
|
140
|
-
value: getValue(v.escapedValue, props, searchState, {
|
|
141
|
-
ais: props.contextValue,
|
|
142
|
-
multiIndexContext: props.indexContextValue
|
|
143
|
-
}),
|
|
144
|
-
count: v.count,
|
|
145
|
-
isRefined: v.isRefined
|
|
146
|
-
};
|
|
147
|
-
});
|
|
148
|
-
}
|
|
149
|
-
var transformedItems = props.transformItems ? props.transformItems(items) : items;
|
|
150
|
-
return {
|
|
151
|
-
items: transformedItems.slice(0, getLimit(props)),
|
|
152
|
-
currentRefinement: getCurrentRefinement(props, searchState, {
|
|
153
|
-
ais: props.contextValue,
|
|
154
|
-
multiIndexContext: props.indexContextValue
|
|
155
|
-
}),
|
|
156
|
-
isFromSearch: isFromSearch,
|
|
157
|
-
searchable: searchable,
|
|
158
|
-
canRefine: transformedItems.length > 0
|
|
159
|
-
};
|
|
160
|
-
},
|
|
161
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
162
|
-
return _refine(props, searchState, nextRefinement, {
|
|
163
|
-
ais: props.contextValue,
|
|
164
|
-
multiIndexContext: props.indexContextValue
|
|
165
|
-
});
|
|
166
|
-
},
|
|
167
|
-
searchForFacetValues: function searchForFacetValues(props, searchState, nextRefinement) {
|
|
168
|
-
return {
|
|
169
|
-
facetName: props.attribute,
|
|
170
|
-
query: nextRefinement,
|
|
171
|
-
maxFacetHits: getLimit(props)
|
|
172
|
-
};
|
|
173
|
-
},
|
|
174
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
175
|
-
return _cleanUp(props, searchState, {
|
|
176
|
-
ais: props.contextValue,
|
|
177
|
-
multiIndexContext: props.indexContextValue
|
|
178
|
-
});
|
|
179
|
-
},
|
|
180
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
181
|
-
var attribute = props.attribute;
|
|
182
|
-
searchParameters = searchParameters.setQueryParameters({
|
|
183
|
-
maxValuesPerFacet: Math.max(searchParameters.maxValuesPerFacet || 0, getLimit(props))
|
|
184
|
-
});
|
|
185
|
-
searchParameters = searchParameters.addDisjunctiveFacet(attribute);
|
|
186
|
-
var currentRefinement = getCurrentRefinement(props, searchState, {
|
|
187
|
-
ais: props.contextValue,
|
|
188
|
-
multiIndexContext: props.indexContextValue
|
|
189
|
-
});
|
|
190
|
-
if (currentRefinement !== null) {
|
|
191
|
-
searchParameters = searchParameters.addDisjunctiveFacetRefinement(attribute, currentRefinement);
|
|
192
|
-
}
|
|
193
|
-
return searchParameters;
|
|
194
|
-
},
|
|
195
|
-
getMetadata: function getMetadata(props, searchState) {
|
|
196
|
-
var id = getId(props);
|
|
197
|
-
var currentRefinement = getCurrentRefinement(props, searchState, {
|
|
198
|
-
ais: props.contextValue,
|
|
199
|
-
multiIndexContext: props.indexContextValue
|
|
200
|
-
});
|
|
201
|
-
return {
|
|
202
|
-
id: id,
|
|
203
|
-
index: (0, _indexUtils.getIndexId)({
|
|
204
|
-
ais: props.contextValue,
|
|
205
|
-
multiIndexContext: props.indexContextValue
|
|
206
|
-
}),
|
|
207
|
-
items: currentRefinement === null ? [] : [{
|
|
208
|
-
label: "".concat(props.attribute, ": ").concat((0, _utils.unescapeFacetValue)(currentRefinement)),
|
|
209
|
-
attribute: props.attribute,
|
|
210
|
-
value: function value(nextState) {
|
|
211
|
-
return _refine(props, nextState, '', {
|
|
212
|
-
ais: props.contextValue,
|
|
213
|
-
multiIndexContext: props.indexContextValue
|
|
214
|
-
});
|
|
215
|
-
},
|
|
216
|
-
currentRefinement: currentRefinement
|
|
217
|
-
}]
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
});
|
|
221
|
-
exports.default = _default;
|