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,104 +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 _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; }
|
|
13
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
14
|
-
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); }
|
|
15
|
-
function getId() {
|
|
16
|
-
return 'query';
|
|
17
|
-
}
|
|
18
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
19
|
-
var id = getId(props);
|
|
20
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
|
|
21
|
-
if (currentRefinement) {
|
|
22
|
-
return currentRefinement;
|
|
23
|
-
}
|
|
24
|
-
return '';
|
|
25
|
-
}
|
|
26
|
-
function _refine(props, searchState, nextRefinement, context) {
|
|
27
|
-
var id = getId();
|
|
28
|
-
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
29
|
-
var resetPage = true;
|
|
30
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage);
|
|
31
|
-
}
|
|
32
|
-
function _cleanUp(props, searchState, context) {
|
|
33
|
-
return (0, _indexUtils.cleanUpValue)(searchState, context, getId());
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* connectSearchBox connector provides the logic to build a widget that will
|
|
38
|
-
* let the user search for a query
|
|
39
|
-
* @name connectSearchBox
|
|
40
|
-
* @kind connector
|
|
41
|
-
* @propType {string} [defaultRefinement] - Provide a default value for the query
|
|
42
|
-
* @providedPropType {function} refine - a function to change the current query
|
|
43
|
-
* @providedPropType {string} currentRefinement - the current query used
|
|
44
|
-
* @providedPropType {boolean} isSearchStalled - a flag that indicates if InstantSearch has detected that searches are stalled
|
|
45
|
-
*/
|
|
46
|
-
var _default = (0, _createConnector.default)({
|
|
47
|
-
displayName: 'AlgoliaSearchBox',
|
|
48
|
-
$$type: 'ais.searchBox',
|
|
49
|
-
propTypes: {
|
|
50
|
-
defaultRefinement: _propTypes.default.string
|
|
51
|
-
},
|
|
52
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
53
|
-
return {
|
|
54
|
-
currentRefinement: getCurrentRefinement(props, searchState, {
|
|
55
|
-
ais: props.contextValue,
|
|
56
|
-
multiIndexContext: props.indexContextValue
|
|
57
|
-
}),
|
|
58
|
-
isSearchStalled: searchResults.isSearchStalled
|
|
59
|
-
};
|
|
60
|
-
},
|
|
61
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
62
|
-
return _refine(props, searchState, nextRefinement, {
|
|
63
|
-
ais: props.contextValue,
|
|
64
|
-
multiIndexContext: props.indexContextValue
|
|
65
|
-
});
|
|
66
|
-
},
|
|
67
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
68
|
-
return _cleanUp(props, searchState, {
|
|
69
|
-
ais: props.contextValue,
|
|
70
|
-
multiIndexContext: props.indexContextValue
|
|
71
|
-
});
|
|
72
|
-
},
|
|
73
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
74
|
-
return searchParameters.setQuery(getCurrentRefinement(props, searchState, {
|
|
75
|
-
ais: props.contextValue,
|
|
76
|
-
multiIndexContext: props.indexContextValue
|
|
77
|
-
}));
|
|
78
|
-
},
|
|
79
|
-
getMetadata: function getMetadata(props, searchState) {
|
|
80
|
-
var id = getId(props);
|
|
81
|
-
var currentRefinement = getCurrentRefinement(props, searchState, {
|
|
82
|
-
ais: props.contextValue,
|
|
83
|
-
multiIndexContext: props.indexContextValue
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
id: id,
|
|
87
|
-
index: (0, _indexUtils.getIndexId)({
|
|
88
|
-
ais: props.contextValue,
|
|
89
|
-
multiIndexContext: props.indexContextValue
|
|
90
|
-
}),
|
|
91
|
-
items: currentRefinement === null ? [] : [{
|
|
92
|
-
label: "".concat(id, ": ").concat(currentRefinement),
|
|
93
|
-
value: function value(nextState) {
|
|
94
|
-
return _refine(props, nextState, '', {
|
|
95
|
-
ais: props.contextValue,
|
|
96
|
-
multiIndexContext: props.indexContextValue
|
|
97
|
-
});
|
|
98
|
-
},
|
|
99
|
-
currentRefinement: currentRefinement
|
|
100
|
-
}]
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
exports.default = _default;
|
|
@@ -1,100 +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 'sortBy';
|
|
19
|
-
}
|
|
20
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
21
|
-
var id = getId(props);
|
|
22
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, null);
|
|
23
|
-
if (currentRefinement) {
|
|
24
|
-
return currentRefinement;
|
|
25
|
-
}
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The connectSortBy connector provides the logic to build a widget that will
|
|
31
|
-
* display a list of indices. This allows a user to change how the hits are being sorted.
|
|
32
|
-
* @name connectSortBy
|
|
33
|
-
* @requirements Algolia handles sorting by creating replica indices. [Read more about sorting](https://www.algolia.com/doc/guides/relevance/sorting/) on
|
|
34
|
-
* the Algolia website.
|
|
35
|
-
* @kind connector
|
|
36
|
-
* @propType {string} defaultRefinement - The default selected index.
|
|
37
|
-
* @propType {{value: string, label: string}[]} items - The list of indexes to search in.
|
|
38
|
-
* @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.
|
|
39
|
-
* @providedPropType {function} refine - a function to remove a single filter
|
|
40
|
-
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
41
|
-
* @providedPropType {string[]} currentRefinement - the refinement currently applied
|
|
42
|
-
* @providedPropType {array.<{isRefined: boolean, label?: string, value: string}>} items - the list of items the HitsPerPage can display. If no label provided, the value will be displayed.
|
|
43
|
-
*/
|
|
44
|
-
var _default = (0, _createConnector.default)({
|
|
45
|
-
displayName: 'AlgoliaSortBy',
|
|
46
|
-
$$type: 'ais.sortBy',
|
|
47
|
-
propTypes: {
|
|
48
|
-
defaultRefinement: _propTypes.default.string,
|
|
49
|
-
items: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
50
|
-
label: _propTypes.default.string,
|
|
51
|
-
value: _propTypes.default.string.isRequired
|
|
52
|
-
})).isRequired,
|
|
53
|
-
transformItems: _propTypes.default.func
|
|
54
|
-
},
|
|
55
|
-
getProvidedProps: function getProvidedProps(props, searchState) {
|
|
56
|
-
var currentRefinement = getCurrentRefinement(props, searchState, {
|
|
57
|
-
ais: props.contextValue,
|
|
58
|
-
multiIndexContext: props.indexContextValue
|
|
59
|
-
});
|
|
60
|
-
var items = props.items.map(function (item) {
|
|
61
|
-
return item.value === currentRefinement ? _objectSpread(_objectSpread({}, item), {}, {
|
|
62
|
-
isRefined: true
|
|
63
|
-
}) : _objectSpread(_objectSpread({}, item), {}, {
|
|
64
|
-
isRefined: false
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
items: props.transformItems ? props.transformItems(items) : items,
|
|
69
|
-
currentRefinement: currentRefinement
|
|
70
|
-
};
|
|
71
|
-
},
|
|
72
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
73
|
-
var id = getId();
|
|
74
|
-
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
75
|
-
var resetPage = true;
|
|
76
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, {
|
|
77
|
-
ais: props.contextValue,
|
|
78
|
-
multiIndexContext: props.indexContextValue
|
|
79
|
-
}, resetPage);
|
|
80
|
-
},
|
|
81
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
82
|
-
return (0, _indexUtils.cleanUpValue)(searchState, {
|
|
83
|
-
ais: props.contextValue,
|
|
84
|
-
multiIndexContext: props.indexContextValue
|
|
85
|
-
}, getId());
|
|
86
|
-
},
|
|
87
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
88
|
-
var selectedIndex = getCurrentRefinement(props, searchState, {
|
|
89
|
-
ais: props.contextValue,
|
|
90
|
-
multiIndexContext: props.indexContextValue
|
|
91
|
-
});
|
|
92
|
-
return searchParameters.setIndex(selectedIndex);
|
|
93
|
-
},
|
|
94
|
-
getMetadata: function getMetadata() {
|
|
95
|
-
return {
|
|
96
|
-
id: getId()
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
exports.default = _default;
|
|
@@ -1,79 +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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
/**
|
|
11
|
-
* The `connectStateResults` connector provides a way to access the `searchState` and the `searchResults`
|
|
12
|
-
* of InstantSearch.
|
|
13
|
-
* For instance this connector allows you to create results/noResults or query/noQuery pages.
|
|
14
|
-
* @name connectStateResults
|
|
15
|
-
* @kind connector
|
|
16
|
-
* @providedPropType {object} searchState - The search state of the instant search component. <br/><br/> See: [Search state structure](https://community.algolia.com/react-instantsearch/guide/Search_state.html)
|
|
17
|
-
* @providedPropType {object} searchResults - The search results. <br/><br/> In case of multiple indices: if used under `<Index>`, results will be those of the corresponding index otherwise it'll be those of the root index See: [Search results structure](https://community.algolia.com/algoliasearch-helper-js/reference.html#searchresults)
|
|
18
|
-
* @providedPropType {object} allSearchResults - In case of multiple indices you can retrieve all the results
|
|
19
|
-
* @providedPropType {string} error - If the search failed, the error will be logged here.
|
|
20
|
-
* @providedPropType {boolean} searching - If there is a search in progress.
|
|
21
|
-
* @providedPropType {boolean} isSearchStalled - Flag that indicates if React InstantSearch has detected that searches are stalled.
|
|
22
|
-
* @providedPropType {boolean} searchingForFacetValues - If there is a search in a list in progress.
|
|
23
|
-
* @providedPropType {object} props - component props.
|
|
24
|
-
* @example
|
|
25
|
-
* import React from 'react';
|
|
26
|
-
* import algoliasearch from 'algoliasearch/lite';
|
|
27
|
-
* import { InstantSearch, SearchBox, Hits, connectStateResults } from 'react-instantsearch-dom';
|
|
28
|
-
*
|
|
29
|
-
* const searchClient = algoliasearch(
|
|
30
|
-
* 'latency',
|
|
31
|
-
* '6be0576ff61c053d5f9a3225e2a90f76'
|
|
32
|
-
* );
|
|
33
|
-
*
|
|
34
|
-
* const Content = connectStateResults(({ searchState, searchResults }) => {
|
|
35
|
-
* const hasResults = searchResults && searchResults.nbHits !== 0;
|
|
36
|
-
*
|
|
37
|
-
* return (
|
|
38
|
-
* <div>
|
|
39
|
-
* <div hidden={!hasResults}>
|
|
40
|
-
* <Hits />
|
|
41
|
-
* </div>
|
|
42
|
-
* <div hidden={hasResults}>
|
|
43
|
-
* <div>No results has been found for {searchState.query}</div>
|
|
44
|
-
* </div>
|
|
45
|
-
* </div>
|
|
46
|
-
* );
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
* const App = () => (
|
|
50
|
-
* <InstantSearch
|
|
51
|
-
* searchClient={searchClient}
|
|
52
|
-
* indexName="instant_search"
|
|
53
|
-
* >
|
|
54
|
-
* <SearchBox />
|
|
55
|
-
* <Content />
|
|
56
|
-
* </InstantSearch>
|
|
57
|
-
* );
|
|
58
|
-
*/
|
|
59
|
-
var _default = (0, _createConnector.default)({
|
|
60
|
-
displayName: 'AlgoliaStateResults',
|
|
61
|
-
$$type: 'ais.stateResults',
|
|
62
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
63
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
64
|
-
ais: props.contextValue,
|
|
65
|
-
multiIndexContext: props.indexContextValue
|
|
66
|
-
});
|
|
67
|
-
return {
|
|
68
|
-
searchState: searchState,
|
|
69
|
-
searchResults: results,
|
|
70
|
-
allSearchResults: searchResults.results,
|
|
71
|
-
searching: searchResults.searching,
|
|
72
|
-
isSearchStalled: searchResults.isSearchStalled,
|
|
73
|
-
error: searchResults.error,
|
|
74
|
-
searchingForFacetValues: searchResults.searchingForFacetValues,
|
|
75
|
-
props: props
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
exports.default = _default;
|
|
@@ -1,39 +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
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
/**
|
|
12
|
-
* connectStats connector provides the logic to build a widget that will
|
|
13
|
-
* displays algolia search statistics (hits number and processing time).
|
|
14
|
-
* @name connectStats
|
|
15
|
-
* @kind connector
|
|
16
|
-
* @providedPropType {number} nbHits - number of hits returned by Algolia.
|
|
17
|
-
* @providedPropType {number} nbSortedHits - number of sorted hits returned by Algolia.
|
|
18
|
-
* @providedPropType {number} processingTimeMS - the time in ms took by Algolia to search for results.
|
|
19
|
-
*/
|
|
20
|
-
var _default = (0, _createConnector.default)({
|
|
21
|
-
displayName: 'AlgoliaStats',
|
|
22
|
-
$$type: 'ais.stats',
|
|
23
|
-
getProvidedProps: function getProvidedProps(props, _searchState, searchResults) {
|
|
24
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
25
|
-
ais: props.contextValue,
|
|
26
|
-
multiIndexContext: props.indexContextValue
|
|
27
|
-
});
|
|
28
|
-
if (!results) {
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
return {
|
|
32
|
-
areHitsSorted: results.appliedRelevancyStrictness !== undefined && results.appliedRelevancyStrictness > 0 && results.nbHits !== results.nbSortedHits,
|
|
33
|
-
nbHits: results.nbHits,
|
|
34
|
-
nbSortedHits: results.nbSortedHits,
|
|
35
|
-
processingTimeMS: results.processingTimeMS
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
exports.default = _default;
|
|
@@ -1,163 +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 _utils = require("../core/utils");
|
|
9
|
-
var _createConnector = _interopRequireDefault(require("../core/createConnector"));
|
|
10
|
-
var _indexUtils = require("../core/indexUtils");
|
|
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
|
-
function getId(props) {
|
|
17
|
-
return props.attribute;
|
|
18
|
-
}
|
|
19
|
-
var namespace = 'toggle';
|
|
20
|
-
var falsyStrings = ['0', 'false', 'null', 'undefined'];
|
|
21
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
22
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, "".concat(namespace, ".").concat(getId(props)), false);
|
|
23
|
-
if (falsyStrings.indexOf(currentRefinement) !== -1) {
|
|
24
|
-
return false;
|
|
25
|
-
}
|
|
26
|
-
return Boolean(currentRefinement);
|
|
27
|
-
}
|
|
28
|
-
function _refine(props, searchState, nextRefinement, context) {
|
|
29
|
-
var id = getId(props);
|
|
30
|
-
var nextValue = _defineProperty({}, id, nextRefinement ? nextRefinement : false);
|
|
31
|
-
var resetPage = true;
|
|
32
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage, namespace);
|
|
33
|
-
}
|
|
34
|
-
function _cleanUp(props, searchState, context) {
|
|
35
|
-
return (0, _indexUtils.cleanUpValue)(searchState, context, "".concat(namespace, ".").concat(getId(props)));
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* connectToggleRefinement connector provides the logic to build a widget that will
|
|
40
|
-
* provides an on/off filtering feature based on an attribute value.
|
|
41
|
-
* @name connectToggleRefinement
|
|
42
|
-
* @kind connector
|
|
43
|
-
* @requirements To use this widget, you'll need an attribute to toggle on.
|
|
44
|
-
*
|
|
45
|
-
* You can't toggle on null or not-null values. If you want to address this particular use-case you'll need to compute an
|
|
46
|
-
* extra boolean attribute saying if the value exists or not. See this [thread](https://discourse.algolia.com/t/how-to-create-a-toggle-for-the-absence-of-a-string-attribute/2460) for more details.
|
|
47
|
-
*
|
|
48
|
-
* @propType {string} attribute - Name of the attribute on which to apply the `value` refinement. Required when `value` is present.
|
|
49
|
-
* @propType {string} label - Label for the toggle.
|
|
50
|
-
* @propType {string} value - Value of the refinement to apply on `attribute`.
|
|
51
|
-
* @propType {boolean} [defaultRefinement=false] - Default searchState of the widget. Should the toggle be checked by default?
|
|
52
|
-
* @providedPropType {boolean} currentRefinement - `true` when the refinement is applied, `false` otherwise
|
|
53
|
-
* @providedPropType {object} count - an object that contains the count for `checked` and `unchecked` state
|
|
54
|
-
* @providedPropType {function} refine - a function to toggle a refinement
|
|
55
|
-
* @providedPropType {function} createURL - a function to generate a URL for the corresponding search state
|
|
56
|
-
*/
|
|
57
|
-
var _default = (0, _createConnector.default)({
|
|
58
|
-
displayName: 'AlgoliaToggle',
|
|
59
|
-
$$type: 'ais.toggle',
|
|
60
|
-
propTypes: {
|
|
61
|
-
label: _propTypes.default.string.isRequired,
|
|
62
|
-
attribute: _propTypes.default.string.isRequired,
|
|
63
|
-
value: _propTypes.default.any.isRequired,
|
|
64
|
-
filter: _propTypes.default.func,
|
|
65
|
-
defaultRefinement: _propTypes.default.bool
|
|
66
|
-
},
|
|
67
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
68
|
-
var attribute = props.attribute,
|
|
69
|
-
value = props.value;
|
|
70
|
-
var results = (0, _indexUtils.getResults)(searchResults, {
|
|
71
|
-
ais: props.contextValue,
|
|
72
|
-
multiIndexContext: props.indexContextValue
|
|
73
|
-
});
|
|
74
|
-
var currentRefinement = getCurrentRefinement(props, searchState, {
|
|
75
|
-
ais: props.contextValue,
|
|
76
|
-
multiIndexContext: props.indexContextValue
|
|
77
|
-
});
|
|
78
|
-
var allFacetValues = results && results.getFacetByName(attribute) ? results.getFacetValues(attribute) : null;
|
|
79
|
-
var facetValue =
|
|
80
|
-
// Use null to always be consistent with type of the value
|
|
81
|
-
// count: number | null
|
|
82
|
-
allFacetValues && allFacetValues.length ? (0, _utils.find)(allFacetValues, function (item) {
|
|
83
|
-
return item.name === value.toString();
|
|
84
|
-
}) : null;
|
|
85
|
-
var facetValueCount = facetValue && facetValue.count;
|
|
86
|
-
var allFacetValuesCount =
|
|
87
|
-
// Use null to always be consistent with type of the value
|
|
88
|
-
// count: number | null
|
|
89
|
-
allFacetValues && allFacetValues.length ? allFacetValues.reduce(function (acc, item) {
|
|
90
|
-
return acc + item.count;
|
|
91
|
-
}, 0) : null;
|
|
92
|
-
var canRefine = currentRefinement ? allFacetValuesCount !== null && allFacetValuesCount > 0 : facetValueCount !== null && facetValueCount > 0;
|
|
93
|
-
var count = {
|
|
94
|
-
checked: allFacetValuesCount,
|
|
95
|
-
unchecked: facetValueCount
|
|
96
|
-
};
|
|
97
|
-
return {
|
|
98
|
-
currentRefinement: currentRefinement,
|
|
99
|
-
canRefine: canRefine,
|
|
100
|
-
count: count
|
|
101
|
-
};
|
|
102
|
-
},
|
|
103
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
104
|
-
return _refine(props, searchState, nextRefinement, {
|
|
105
|
-
ais: props.contextValue,
|
|
106
|
-
multiIndexContext: props.indexContextValue
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
110
|
-
return _cleanUp(props, searchState, {
|
|
111
|
-
ais: props.contextValue,
|
|
112
|
-
multiIndexContext: props.indexContextValue
|
|
113
|
-
});
|
|
114
|
-
},
|
|
115
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
116
|
-
var attribute = props.attribute,
|
|
117
|
-
value = props.value,
|
|
118
|
-
filter = props.filter;
|
|
119
|
-
var checked = getCurrentRefinement(props, searchState, {
|
|
120
|
-
ais: props.contextValue,
|
|
121
|
-
multiIndexContext: props.indexContextValue
|
|
122
|
-
});
|
|
123
|
-
var nextSearchParameters = searchParameters.addDisjunctiveFacet(attribute);
|
|
124
|
-
if (checked) {
|
|
125
|
-
nextSearchParameters = nextSearchParameters.addDisjunctiveFacetRefinement(attribute, value);
|
|
126
|
-
if (filter) {
|
|
127
|
-
nextSearchParameters = filter(nextSearchParameters);
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return nextSearchParameters;
|
|
131
|
-
},
|
|
132
|
-
getMetadata: function getMetadata(props, searchState) {
|
|
133
|
-
var id = getId(props);
|
|
134
|
-
var checked = getCurrentRefinement(props, searchState, {
|
|
135
|
-
ais: props.contextValue,
|
|
136
|
-
multiIndexContext: props.indexContextValue
|
|
137
|
-
});
|
|
138
|
-
var items = [];
|
|
139
|
-
var index = (0, _indexUtils.getIndexId)({
|
|
140
|
-
ais: props.contextValue,
|
|
141
|
-
multiIndexContext: props.indexContextValue
|
|
142
|
-
});
|
|
143
|
-
if (checked) {
|
|
144
|
-
items.push({
|
|
145
|
-
label: props.label,
|
|
146
|
-
currentRefinement: checked,
|
|
147
|
-
attribute: props.attribute,
|
|
148
|
-
value: function value(nextState) {
|
|
149
|
-
return _refine(props, nextState, false, {
|
|
150
|
-
ais: props.contextValue,
|
|
151
|
-
multiIndexContext: props.indexContextValue
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
});
|
|
155
|
-
}
|
|
156
|
-
return {
|
|
157
|
-
id: id,
|
|
158
|
-
index: index,
|
|
159
|
-
items: items
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
exports.default = _default;
|
|
@@ -1,124 +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 'query';
|
|
19
|
-
}
|
|
20
|
-
function getAdditionalId() {
|
|
21
|
-
return 'additionalVoiceParameters';
|
|
22
|
-
}
|
|
23
|
-
function getCurrentRefinementQuery(props, searchState, context) {
|
|
24
|
-
var id = getId();
|
|
25
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
|
|
26
|
-
if (currentRefinement) {
|
|
27
|
-
return currentRefinement;
|
|
28
|
-
}
|
|
29
|
-
return '';
|
|
30
|
-
}
|
|
31
|
-
function getCurrentRefinementAdditional(props, searchState, context) {
|
|
32
|
-
var id = getAdditionalId();
|
|
33
|
-
var currentRefinement = (0, _indexUtils.getCurrentRefinementValue)(props, searchState, context, id, '');
|
|
34
|
-
if (currentRefinement) {
|
|
35
|
-
return currentRefinement;
|
|
36
|
-
}
|
|
37
|
-
return {};
|
|
38
|
-
}
|
|
39
|
-
function _refine(props, searchState, nextRefinement, context) {
|
|
40
|
-
var _nextValue;
|
|
41
|
-
var id = getId();
|
|
42
|
-
var voiceParams = getAdditionalId();
|
|
43
|
-
var queryLanguages = props.language ? {
|
|
44
|
-
queryLanguages: [props.language.split('-')[0]]
|
|
45
|
-
} : {};
|
|
46
|
-
var additionalQueryParameters = typeof props.additionalQueryParameters === 'function' ? _objectSpread({
|
|
47
|
-
ignorePlurals: true,
|
|
48
|
-
removeStopWords: true,
|
|
49
|
-
optionalWords: nextRefinement
|
|
50
|
-
}, props.additionalQueryParameters({
|
|
51
|
-
query: nextRefinement
|
|
52
|
-
})) : {};
|
|
53
|
-
var nextValue = (_nextValue = {}, _defineProperty(_nextValue, id, nextRefinement), _defineProperty(_nextValue, voiceParams, _objectSpread(_objectSpread({}, queryLanguages), additionalQueryParameters)), _nextValue);
|
|
54
|
-
var resetPage = true;
|
|
55
|
-
return (0, _indexUtils.refineValue)(searchState, nextValue, context, resetPage);
|
|
56
|
-
}
|
|
57
|
-
function _cleanUp(props, searchState, context) {
|
|
58
|
-
var interimState = (0, _indexUtils.cleanUpValue)(searchState, context, getId());
|
|
59
|
-
return (0, _indexUtils.cleanUpValue)(interimState, context, getAdditionalId());
|
|
60
|
-
}
|
|
61
|
-
var _default = (0, _createConnector.default)({
|
|
62
|
-
displayName: 'AlgoliaVoiceSearch',
|
|
63
|
-
$$type: 'ais.voiceSearch',
|
|
64
|
-
propTypes: {
|
|
65
|
-
defaultRefinement: _propTypes.default.string
|
|
66
|
-
},
|
|
67
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
68
|
-
return {
|
|
69
|
-
currentRefinement: getCurrentRefinementQuery(props, searchState, {
|
|
70
|
-
ais: props.contextValue,
|
|
71
|
-
multiIndexContext: props.indexContextValue
|
|
72
|
-
}),
|
|
73
|
-
isSearchStalled: searchResults.isSearchStalled
|
|
74
|
-
};
|
|
75
|
-
},
|
|
76
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
77
|
-
return _refine(props, searchState, nextRefinement, {
|
|
78
|
-
ais: props.contextValue,
|
|
79
|
-
multiIndexContext: props.indexContextValue
|
|
80
|
-
});
|
|
81
|
-
},
|
|
82
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
83
|
-
return _cleanUp(props, searchState, {
|
|
84
|
-
ais: props.contextValue,
|
|
85
|
-
multiIndexContext: props.indexContextValue
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
89
|
-
var query = getCurrentRefinementQuery(props, searchState, {
|
|
90
|
-
ais: props.contextValue,
|
|
91
|
-
multiIndexContext: props.indexContextValue
|
|
92
|
-
});
|
|
93
|
-
var additionalParams = getCurrentRefinementAdditional(props, searchState, {
|
|
94
|
-
ais: props.contextValue,
|
|
95
|
-
multiIndexContext: props.indexContextValue
|
|
96
|
-
});
|
|
97
|
-
return searchParameters.setQuery(query).setQueryParameters(additionalParams);
|
|
98
|
-
},
|
|
99
|
-
getMetadata: function getMetadata(props, searchState) {
|
|
100
|
-
var id = getId();
|
|
101
|
-
var currentRefinement = getCurrentRefinementQuery(props, searchState, {
|
|
102
|
-
ais: props.contextValue,
|
|
103
|
-
multiIndexContext: props.indexContextValue
|
|
104
|
-
});
|
|
105
|
-
return {
|
|
106
|
-
id: id,
|
|
107
|
-
index: (0, _indexUtils.getIndexId)({
|
|
108
|
-
ais: props.contextValue,
|
|
109
|
-
multiIndexContext: props.indexContextValue
|
|
110
|
-
}),
|
|
111
|
-
items: currentRefinement === null ? [] : [{
|
|
112
|
-
label: "".concat(id, ": ").concat(currentRefinement),
|
|
113
|
-
value: function value(nextState) {
|
|
114
|
-
return _refine(props, nextState, '', {
|
|
115
|
-
ais: props.contextValue,
|
|
116
|
-
multiIndexContext: props.indexContextValue
|
|
117
|
-
});
|
|
118
|
-
},
|
|
119
|
-
currentRefinement: currentRefinement
|
|
120
|
-
}]
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
});
|
|
124
|
-
exports.default = _default;
|
package/dist/cjs/core/context.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.instantSearchContext = exports.InstantSearchProvider = exports.InstantSearchConsumer = exports.IndexProvider = exports.IndexConsumer = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
|
-
var instantSearchContext = /*#__PURE__*/(0, _react.createContext)({
|
|
9
|
-
onInternalStateUpdate: function onInternalStateUpdate() {
|
|
10
|
-
return undefined;
|
|
11
|
-
},
|
|
12
|
-
createHrefForState: function createHrefForState() {
|
|
13
|
-
return '#';
|
|
14
|
-
},
|
|
15
|
-
onSearchForFacetValues: function onSearchForFacetValues() {
|
|
16
|
-
return undefined;
|
|
17
|
-
},
|
|
18
|
-
onSearchStateChange: function onSearchStateChange() {
|
|
19
|
-
return undefined;
|
|
20
|
-
},
|
|
21
|
-
onSearchParameters: function onSearchParameters() {
|
|
22
|
-
return undefined;
|
|
23
|
-
},
|
|
24
|
-
store: {},
|
|
25
|
-
widgetsManager: {},
|
|
26
|
-
mainTargetedIndex: ''
|
|
27
|
-
});
|
|
28
|
-
exports.instantSearchContext = instantSearchContext;
|
|
29
|
-
var InstantSearchConsumer = instantSearchContext.Consumer,
|
|
30
|
-
InstantSearchProvider = instantSearchContext.Provider;
|
|
31
|
-
exports.InstantSearchProvider = InstantSearchProvider;
|
|
32
|
-
exports.InstantSearchConsumer = InstantSearchConsumer;
|
|
33
|
-
var _createContext = /*#__PURE__*/(0, _react.createContext)(undefined),
|
|
34
|
-
IndexConsumer = _createContext.Consumer,
|
|
35
|
-
IndexProvider = _createContext.Provider;
|
|
36
|
-
exports.IndexProvider = IndexProvider;
|
|
37
|
-
exports.IndexConsumer = IndexConsumer;
|