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,102 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.HIGHLIGHT_TAGS = void 0;
|
|
7
|
-
exports.parseAlgoliaHit = parseAlgoliaHit;
|
|
8
|
-
var _utils = require("./utils");
|
|
9
|
-
var HIGHLIGHT_TAGS = {
|
|
10
|
-
highlightPreTag: "<ais-highlight-0000000000>",
|
|
11
|
-
highlightPostTag: "</ais-highlight-0000000000>"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Parses an highlighted attribute into an array of objects with the string value, and
|
|
16
|
-
* a boolean that indicated if this part is highlighted.
|
|
17
|
-
*
|
|
18
|
-
* @param {string} preTag - string used to identify the start of an highlighted value
|
|
19
|
-
* @param {string} postTag - string used to identify the end of an highlighted value
|
|
20
|
-
* @param {string} highlightedValue - highlighted attribute as returned by Algolia highlight feature
|
|
21
|
-
* @return {object[]} - An array of {value: string, isHighlighted: boolean}.
|
|
22
|
-
*/
|
|
23
|
-
exports.HIGHLIGHT_TAGS = HIGHLIGHT_TAGS;
|
|
24
|
-
function parseHighlightedAttribute(_ref) {
|
|
25
|
-
var preTag = _ref.preTag,
|
|
26
|
-
postTag = _ref.postTag,
|
|
27
|
-
_ref$highlightedValue = _ref.highlightedValue,
|
|
28
|
-
highlightedValue = _ref$highlightedValue === void 0 ? '' : _ref$highlightedValue;
|
|
29
|
-
var splitByPreTag = highlightedValue.split(preTag);
|
|
30
|
-
var firstValue = splitByPreTag.shift();
|
|
31
|
-
var elements = firstValue === '' ? [] : [{
|
|
32
|
-
value: firstValue,
|
|
33
|
-
isHighlighted: false
|
|
34
|
-
}];
|
|
35
|
-
if (postTag === preTag) {
|
|
36
|
-
var isHighlighted = true;
|
|
37
|
-
splitByPreTag.forEach(function (split) {
|
|
38
|
-
elements.push({
|
|
39
|
-
value: split,
|
|
40
|
-
isHighlighted: isHighlighted
|
|
41
|
-
});
|
|
42
|
-
isHighlighted = !isHighlighted;
|
|
43
|
-
});
|
|
44
|
-
} else {
|
|
45
|
-
splitByPreTag.forEach(function (split) {
|
|
46
|
-
var splitByPostTag = split.split(postTag);
|
|
47
|
-
elements.push({
|
|
48
|
-
value: splitByPostTag[0],
|
|
49
|
-
isHighlighted: true
|
|
50
|
-
});
|
|
51
|
-
if (splitByPostTag[1] !== '') {
|
|
52
|
-
elements.push({
|
|
53
|
-
value: splitByPostTag[1],
|
|
54
|
-
isHighlighted: false
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
return elements;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* Find an highlighted attribute given an `attribute` and an `highlightProperty`, parses it,
|
|
64
|
-
* and provided an array of objects with the string value and a boolean if this
|
|
65
|
-
* value is highlighted.
|
|
66
|
-
*
|
|
67
|
-
* In order to use this feature, highlight must be activated in the configuration of
|
|
68
|
-
* the index. The `preTag` and `postTag` attributes are respectively highlightPreTag and
|
|
69
|
-
* highlightPostTag in Algolia configuration.
|
|
70
|
-
*
|
|
71
|
-
* @param {string} preTag - string used to identify the start of an highlighted value
|
|
72
|
-
* @param {string} postTag - string used to identify the end of an highlighted value
|
|
73
|
-
* @param {string} highlightProperty - the property that contains the highlight structure in the results
|
|
74
|
-
* @param {string} attribute - the highlighted attribute to look for
|
|
75
|
-
* @param {object} hit - the actual hit returned by Algolia.
|
|
76
|
-
* @return {object[]} - An array of {value: string, isHighlighted: boolean}.
|
|
77
|
-
*/
|
|
78
|
-
function parseAlgoliaHit(_ref2) {
|
|
79
|
-
var _ref2$preTag = _ref2.preTag,
|
|
80
|
-
preTag = _ref2$preTag === void 0 ? '<em>' : _ref2$preTag,
|
|
81
|
-
_ref2$postTag = _ref2.postTag,
|
|
82
|
-
postTag = _ref2$postTag === void 0 ? '</em>' : _ref2$postTag,
|
|
83
|
-
highlightProperty = _ref2.highlightProperty,
|
|
84
|
-
attribute = _ref2.attribute,
|
|
85
|
-
hit = _ref2.hit;
|
|
86
|
-
if (!hit) throw new Error('`hit`, the matching record, must be provided');
|
|
87
|
-
var highlightObject = (0, _utils.getPropertyByPath)(hit[highlightProperty], attribute) || {};
|
|
88
|
-
if (Array.isArray(highlightObject)) {
|
|
89
|
-
return highlightObject.map(function (item) {
|
|
90
|
-
return parseHighlightedAttribute({
|
|
91
|
-
preTag: preTag,
|
|
92
|
-
postTag: postTag,
|
|
93
|
-
highlightedValue: item.value
|
|
94
|
-
});
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
return parseHighlightedAttribute({
|
|
98
|
-
preTag: preTag,
|
|
99
|
-
postTag: postTag,
|
|
100
|
-
highlightedValue: highlightObject.value
|
|
101
|
-
});
|
|
102
|
-
}
|
|
@@ -1,214 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.cleanUpValue = cleanUpValue;
|
|
7
|
-
exports.getCurrentRefinementValue = getCurrentRefinementValue;
|
|
8
|
-
exports.getIndexId = getIndexId;
|
|
9
|
-
exports.getResults = getResults;
|
|
10
|
-
exports.hasMultipleIndices = hasMultipleIndices;
|
|
11
|
-
exports.refineValue = refineValue;
|
|
12
|
-
var _utils = require("./utils");
|
|
13
|
-
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); }
|
|
14
|
-
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; }
|
|
15
|
-
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; }
|
|
16
|
-
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; }
|
|
17
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
-
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); }
|
|
19
|
-
function getIndexId(context) {
|
|
20
|
-
return hasMultipleIndices(context) ? context.multiIndexContext.targetedIndex : context.ais.mainTargetedIndex;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// eslint-disable-next-line valid-jsdoc
|
|
24
|
-
/**
|
|
25
|
-
* @returns {import('algoliasearch-helper').SearchResults} results
|
|
26
|
-
*/
|
|
27
|
-
function getResults(searchResults, context) {
|
|
28
|
-
if (searchResults.results) {
|
|
29
|
-
if (searchResults.results.hits) {
|
|
30
|
-
return searchResults.results;
|
|
31
|
-
}
|
|
32
|
-
var indexId = getIndexId(context);
|
|
33
|
-
if (searchResults.results[indexId]) {
|
|
34
|
-
return searchResults.results[indexId];
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
function hasMultipleIndices(context) {
|
|
40
|
-
return context && context.multiIndexContext;
|
|
41
|
-
}
|
|
42
|
-
function refineValue(searchState, nextRefinement, context, resetPage, namespace) {
|
|
43
|
-
if (hasMultipleIndices(context)) {
|
|
44
|
-
var indexId = getIndexId(context);
|
|
45
|
-
return namespace ? refineMultiIndexWithNamespace(searchState, nextRefinement, indexId, resetPage, namespace) : refineMultiIndex(searchState, nextRefinement, indexId, resetPage);
|
|
46
|
-
} else {
|
|
47
|
-
// When we have a multi index page with shared widgets we should also
|
|
48
|
-
// reset their page to 1 if the resetPage is provided. Otherwise the
|
|
49
|
-
// indices will always be reset
|
|
50
|
-
// see: https://github.com/algolia/react-instantsearch/issues/310
|
|
51
|
-
// see: https://github.com/algolia/react-instantsearch/issues/637
|
|
52
|
-
if (searchState.indices && resetPage) {
|
|
53
|
-
Object.keys(searchState.indices).forEach(function (targetedIndex) {
|
|
54
|
-
searchState = refineValue(searchState, {
|
|
55
|
-
page: 1
|
|
56
|
-
}, {
|
|
57
|
-
multiIndexContext: {
|
|
58
|
-
targetedIndex: targetedIndex
|
|
59
|
-
}
|
|
60
|
-
}, true, namespace);
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return namespace ? refineSingleIndexWithNamespace(searchState, nextRefinement, resetPage, namespace) : refineSingleIndex(searchState, nextRefinement, resetPage);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
function refineMultiIndex(searchState, nextRefinement, indexId, resetPage) {
|
|
67
|
-
var page = resetPage ? {
|
|
68
|
-
page: 1
|
|
69
|
-
} : undefined;
|
|
70
|
-
var state = searchState.indices && searchState.indices[indexId] ? _objectSpread(_objectSpread({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread(_objectSpread(_objectSpread({}, searchState.indices[indexId]), nextRefinement), page))) : _objectSpread(_objectSpread({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread(_objectSpread({}, nextRefinement), page)));
|
|
71
|
-
return _objectSpread(_objectSpread({}, searchState), {}, {
|
|
72
|
-
indices: state
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
function refineSingleIndex(searchState, nextRefinement, resetPage) {
|
|
76
|
-
var page = resetPage ? {
|
|
77
|
-
page: 1
|
|
78
|
-
} : undefined;
|
|
79
|
-
return _objectSpread(_objectSpread(_objectSpread({}, searchState), nextRefinement), page);
|
|
80
|
-
}
|
|
81
|
-
function refineMultiIndexWithNamespace(searchState, nextRefinement, indexId, resetPage, namespace) {
|
|
82
|
-
var _objectSpread4;
|
|
83
|
-
var page = resetPage ? {
|
|
84
|
-
page: 1
|
|
85
|
-
} : undefined;
|
|
86
|
-
var state = searchState.indices && searchState.indices[indexId] ? _objectSpread(_objectSpread({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread(_objectSpread({}, searchState.indices[indexId]), {}, (_objectSpread4 = {}, _defineProperty(_objectSpread4, namespace, _objectSpread(_objectSpread({}, searchState.indices[indexId][namespace]), nextRefinement)), _defineProperty(_objectSpread4, "page", 1), _objectSpread4)))) : _objectSpread(_objectSpread({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread(_defineProperty({}, namespace, nextRefinement), page)));
|
|
87
|
-
return _objectSpread(_objectSpread({}, searchState), {}, {
|
|
88
|
-
indices: state
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
function refineSingleIndexWithNamespace(searchState, nextRefinement, resetPage, namespace) {
|
|
92
|
-
var page = resetPage ? {
|
|
93
|
-
page: 1
|
|
94
|
-
} : undefined;
|
|
95
|
-
return _objectSpread(_objectSpread({}, searchState), {}, _defineProperty({}, namespace, _objectSpread(_objectSpread({}, searchState[namespace]), nextRefinement)), page);
|
|
96
|
-
}
|
|
97
|
-
function getNamespaceAndAttributeName(id) {
|
|
98
|
-
var parts = id.match(/^([^.]*)\.(.*)/);
|
|
99
|
-
var namespace = parts && parts[1];
|
|
100
|
-
var attributeName = parts && parts[2];
|
|
101
|
-
return {
|
|
102
|
-
namespace: namespace,
|
|
103
|
-
attributeName: attributeName
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function hasRefinements(_ref) {
|
|
107
|
-
var multiIndex = _ref.multiIndex,
|
|
108
|
-
indexId = _ref.indexId,
|
|
109
|
-
namespace = _ref.namespace,
|
|
110
|
-
attributeName = _ref.attributeName,
|
|
111
|
-
id = _ref.id,
|
|
112
|
-
searchState = _ref.searchState;
|
|
113
|
-
if (multiIndex && namespace) {
|
|
114
|
-
return searchState.indices && searchState.indices[indexId] && searchState.indices[indexId][namespace] && Object.hasOwnProperty.call(searchState.indices[indexId][namespace], attributeName);
|
|
115
|
-
}
|
|
116
|
-
if (multiIndex) {
|
|
117
|
-
return searchState.indices && searchState.indices[indexId] && Object.hasOwnProperty.call(searchState.indices[indexId], id);
|
|
118
|
-
}
|
|
119
|
-
if (namespace) {
|
|
120
|
-
return searchState[namespace] && Object.hasOwnProperty.call(searchState[namespace], attributeName);
|
|
121
|
-
}
|
|
122
|
-
return Object.hasOwnProperty.call(searchState, id);
|
|
123
|
-
}
|
|
124
|
-
function getRefinements(_ref2) {
|
|
125
|
-
var multiIndex = _ref2.multiIndex,
|
|
126
|
-
indexId = _ref2.indexId,
|
|
127
|
-
namespace = _ref2.namespace,
|
|
128
|
-
attributeName = _ref2.attributeName,
|
|
129
|
-
id = _ref2.id,
|
|
130
|
-
searchState = _ref2.searchState;
|
|
131
|
-
if (multiIndex && namespace) {
|
|
132
|
-
return searchState.indices[indexId][namespace][attributeName];
|
|
133
|
-
}
|
|
134
|
-
if (multiIndex) {
|
|
135
|
-
return searchState.indices[indexId][id];
|
|
136
|
-
}
|
|
137
|
-
if (namespace) {
|
|
138
|
-
return searchState[namespace][attributeName];
|
|
139
|
-
}
|
|
140
|
-
return searchState[id];
|
|
141
|
-
}
|
|
142
|
-
function getCurrentRefinementValue(props, searchState, context, id, defaultValue) {
|
|
143
|
-
var indexId = getIndexId(context);
|
|
144
|
-
var _getNamespaceAndAttri = getNamespaceAndAttributeName(id),
|
|
145
|
-
namespace = _getNamespaceAndAttri.namespace,
|
|
146
|
-
attributeName = _getNamespaceAndAttri.attributeName;
|
|
147
|
-
var multiIndex = hasMultipleIndices(context);
|
|
148
|
-
var args = {
|
|
149
|
-
multiIndex: multiIndex,
|
|
150
|
-
indexId: indexId,
|
|
151
|
-
namespace: namespace,
|
|
152
|
-
attributeName: attributeName,
|
|
153
|
-
id: id,
|
|
154
|
-
searchState: searchState
|
|
155
|
-
};
|
|
156
|
-
var hasRefinementsValue = hasRefinements(args);
|
|
157
|
-
if (hasRefinementsValue) {
|
|
158
|
-
return getRefinements(args);
|
|
159
|
-
}
|
|
160
|
-
if (props.defaultRefinement) {
|
|
161
|
-
return props.defaultRefinement;
|
|
162
|
-
}
|
|
163
|
-
return defaultValue;
|
|
164
|
-
}
|
|
165
|
-
function cleanUpValue(searchState, context, id) {
|
|
166
|
-
var indexId = getIndexId(context);
|
|
167
|
-
var _getNamespaceAndAttri2 = getNamespaceAndAttributeName(id),
|
|
168
|
-
namespace = _getNamespaceAndAttri2.namespace,
|
|
169
|
-
attributeName = _getNamespaceAndAttri2.attributeName;
|
|
170
|
-
if (hasMultipleIndices(context) && Boolean(searchState.indices)) {
|
|
171
|
-
return cleanUpValueWithMultiIndex({
|
|
172
|
-
attribute: attributeName,
|
|
173
|
-
searchState: searchState,
|
|
174
|
-
indexId: indexId,
|
|
175
|
-
id: id,
|
|
176
|
-
namespace: namespace
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
return cleanUpValueWithSingleIndex({
|
|
180
|
-
attribute: attributeName,
|
|
181
|
-
searchState: searchState,
|
|
182
|
-
id: id,
|
|
183
|
-
namespace: namespace
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
function cleanUpValueWithSingleIndex(_ref3) {
|
|
187
|
-
var searchState = _ref3.searchState,
|
|
188
|
-
id = _ref3.id,
|
|
189
|
-
namespace = _ref3.namespace,
|
|
190
|
-
attribute = _ref3.attribute;
|
|
191
|
-
if (namespace) {
|
|
192
|
-
return _objectSpread(_objectSpread({}, searchState), {}, _defineProperty({}, namespace, (0, _utils.omit)(searchState[namespace], [attribute])));
|
|
193
|
-
}
|
|
194
|
-
return (0, _utils.omit)(searchState, [id]);
|
|
195
|
-
}
|
|
196
|
-
function cleanUpValueWithMultiIndex(_ref4) {
|
|
197
|
-
var searchState = _ref4.searchState,
|
|
198
|
-
indexId = _ref4.indexId,
|
|
199
|
-
id = _ref4.id,
|
|
200
|
-
namespace = _ref4.namespace,
|
|
201
|
-
attribute = _ref4.attribute;
|
|
202
|
-
var indexSearchState = searchState.indices[indexId];
|
|
203
|
-
if (namespace && indexSearchState) {
|
|
204
|
-
return _objectSpread(_objectSpread({}, searchState), {}, {
|
|
205
|
-
indices: _objectSpread(_objectSpread({}, searchState.indices), {}, _defineProperty({}, indexId, _objectSpread(_objectSpread({}, indexSearchState), {}, _defineProperty({}, namespace, (0, _utils.omit)(indexSearchState[namespace], [attribute])))))
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
if (indexSearchState) {
|
|
209
|
-
return _objectSpread(_objectSpread({}, searchState), {}, {
|
|
210
|
-
indices: _objectSpread(_objectSpread({}, searchState.indices), {}, _defineProperty({}, indexId, (0, _utils.omit)(indexSearchState, [id])))
|
|
211
|
-
});
|
|
212
|
-
}
|
|
213
|
-
return searchState;
|
|
214
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getMetadataPayload = getMetadataPayload;
|
|
7
|
-
exports.injectMetadata = injectMetadata;
|
|
8
|
-
exports.isMetadataEnabled = isMetadataEnabled;
|
|
9
|
-
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); }
|
|
10
|
-
function isMetadataEnabled() {
|
|
11
|
-
return (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && _typeof(window.navigator) === 'object' && typeof window.navigator.userAgent === 'string' && window.navigator.userAgent.includes('Algolia Crawler') && _typeof(window.document) === 'object';
|
|
12
|
-
}
|
|
13
|
-
function getMetadataPayload(widgets, searchClient) {
|
|
14
|
-
var internalProps = ['contextValue', 'indexContextValue'];
|
|
15
|
-
var widgetsPayload = widgets.map(function (_ref) {
|
|
16
|
-
var props = _ref.props,
|
|
17
|
-
constructor = _ref.constructor;
|
|
18
|
-
var _ref2 = constructor._connectorDesc || {},
|
|
19
|
-
_ref2$defaultProps = _ref2.defaultProps,
|
|
20
|
-
defaultProps = _ref2$defaultProps === void 0 ? {} : _ref2$defaultProps,
|
|
21
|
-
_ref2$displayName = _ref2.displayName,
|
|
22
|
-
displayName = _ref2$displayName === void 0 ? constructor.displayName : _ref2$displayName;
|
|
23
|
-
return {
|
|
24
|
-
displayName: displayName,
|
|
25
|
-
$$type: constructor.$$type,
|
|
26
|
-
$$widgetType: constructor.$$widgetType,
|
|
27
|
-
params: Object.keys(props).filter(function (prop) {
|
|
28
|
-
return !internalProps.includes(prop) && defaultProps[prop] !== props[prop] && props[prop] !== undefined;
|
|
29
|
-
})
|
|
30
|
-
};
|
|
31
|
-
});
|
|
32
|
-
var client = searchClient;
|
|
33
|
-
var ua = client.transporter && client.transporter.userAgent ? client.transporter.userAgent.value : client._ua;
|
|
34
|
-
return {
|
|
35
|
-
ua: ua,
|
|
36
|
-
widgets: widgetsPayload
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function injectMetadata(widgets, searchClient) {
|
|
40
|
-
var payloadContainer = document.createElement('meta');
|
|
41
|
-
var refNode = document.querySelector('head');
|
|
42
|
-
payloadContainer.name = 'algolia:metadata';
|
|
43
|
-
var payload = getMetadataPayload(widgets, searchClient);
|
|
44
|
-
payloadContainer.content = JSON.stringify(payload);
|
|
45
|
-
refNode.appendChild(payloadContainer);
|
|
46
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = translatable;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
9
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
10
|
-
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); }
|
|
11
|
-
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
12
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
13
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
14
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
15
|
-
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
|
|
16
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
17
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
18
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
19
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
20
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
21
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
22
|
-
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; }
|
|
23
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
24
|
-
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); }
|
|
25
|
-
var withKeysPropType = function withKeysPropType(keys) {
|
|
26
|
-
return function (props, propName, componentName) {
|
|
27
|
-
var prop = props[propName];
|
|
28
|
-
if (prop) {
|
|
29
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
30
|
-
for (var _i = 0, _Object$keys = Object.keys(prop); _i < _Object$keys.length; _i++) {
|
|
31
|
-
var key = _Object$keys[_i];
|
|
32
|
-
if (keys.indexOf(key) === -1) {
|
|
33
|
-
return new Error("Unknown `".concat(propName, "` key `").concat(key, "`. Check the render method ") + "of `".concat(componentName, "`."));
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
function translatable(defaultTranslations) {
|
|
41
|
-
return function (Composed) {
|
|
42
|
-
var Translatable = /*#__PURE__*/function (_Component) {
|
|
43
|
-
_inherits(Translatable, _Component);
|
|
44
|
-
var _super = _createSuper(Translatable);
|
|
45
|
-
function Translatable() {
|
|
46
|
-
var _this;
|
|
47
|
-
_classCallCheck(this, Translatable);
|
|
48
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
49
|
-
args[_key] = arguments[_key];
|
|
50
|
-
}
|
|
51
|
-
_this = _super.call.apply(_super, [this].concat(args));
|
|
52
|
-
_defineProperty(_assertThisInitialized(_this), "translate", function (key) {
|
|
53
|
-
var translations = _this.props.translations;
|
|
54
|
-
var translation = translations && translations.hasOwnProperty(key) ? translations[key] : defaultTranslations[key];
|
|
55
|
-
if (typeof translation === 'function') {
|
|
56
|
-
for (var _len2 = arguments.length, params = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
57
|
-
params[_key2 - 1] = arguments[_key2];
|
|
58
|
-
}
|
|
59
|
-
return translation.apply(void 0, params);
|
|
60
|
-
}
|
|
61
|
-
return translation;
|
|
62
|
-
});
|
|
63
|
-
return _this;
|
|
64
|
-
}
|
|
65
|
-
_createClass(Translatable, [{
|
|
66
|
-
key: "render",
|
|
67
|
-
value: function render() {
|
|
68
|
-
return /*#__PURE__*/_react.default.createElement(Composed, _extends({
|
|
69
|
-
translate: this.translate
|
|
70
|
-
}, this.props));
|
|
71
|
-
}
|
|
72
|
-
}]);
|
|
73
|
-
return Translatable;
|
|
74
|
-
}(_react.Component);
|
|
75
|
-
var name = Composed.displayName || Composed.name || 'UnknownComponent';
|
|
76
|
-
Translatable.displayName = "Translatable(".concat(name, ")");
|
|
77
|
-
Translatable.propTypes = {
|
|
78
|
-
translations: withKeysPropType(Object.keys(defaultTranslations))
|
|
79
|
-
};
|
|
80
|
-
return Translatable;
|
|
81
|
-
};
|
|
82
|
-
}
|
package/dist/cjs/core/utils.js
DELETED
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.addAbsolutePositions = addAbsolutePositions;
|
|
7
|
-
exports.addQueryID = addQueryID;
|
|
8
|
-
exports.defer = void 0;
|
|
9
|
-
exports.find = find;
|
|
10
|
-
exports.getDisplayName = void 0;
|
|
11
|
-
exports.getObjectType = getObjectType;
|
|
12
|
-
exports.getPropertyByPath = void 0;
|
|
13
|
-
exports.objectHasKeys = objectHasKeys;
|
|
14
|
-
exports.omit = omit;
|
|
15
|
-
exports.shallowEqual = exports.removeEmptyKey = exports.removeEmptyArraysFromObject = void 0;
|
|
16
|
-
exports.unescapeFacetValue = unescapeFacetValue;
|
|
17
|
-
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; }
|
|
18
|
-
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; }
|
|
19
|
-
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; }
|
|
20
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
21
|
-
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); }
|
|
22
|
-
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); }
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/unbound-method
|
|
24
|
-
var hasOwn = Object.prototype.hasOwnProperty;
|
|
25
|
-
|
|
26
|
-
// From https://github.com/reactjs/react-redux/blob/master/src/utils/shallowEqual.js
|
|
27
|
-
var shallowEqual = function shallowEqual(objA, objB) {
|
|
28
|
-
if (objA === objB) {
|
|
29
|
-
return true;
|
|
30
|
-
}
|
|
31
|
-
var keysA = Object.keys(objA);
|
|
32
|
-
var keysB = Object.keys(objB);
|
|
33
|
-
if (keysA.length !== keysB.length) {
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Test for A's keys different from B.
|
|
38
|
-
for (var i = 0; i < keysA.length; i++) {
|
|
39
|
-
if (!hasOwn.call(objB, keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return true;
|
|
44
|
-
};
|
|
45
|
-
exports.shallowEqual = shallowEqual;
|
|
46
|
-
var getDisplayName = function getDisplayName(Component) {
|
|
47
|
-
return Component.displayName || Component.name || 'UnknownComponent';
|
|
48
|
-
};
|
|
49
|
-
exports.getDisplayName = getDisplayName;
|
|
50
|
-
var resolved = Promise.resolve();
|
|
51
|
-
var defer = function defer(f) {
|
|
52
|
-
resolved.then(f);
|
|
53
|
-
};
|
|
54
|
-
exports.defer = defer;
|
|
55
|
-
var isPlainObject = function isPlainObject(value) {
|
|
56
|
-
return _typeof(value) === 'object' && value !== null && !Array.isArray(value);
|
|
57
|
-
};
|
|
58
|
-
var removeEmptyKey = function removeEmptyKey(obj) {
|
|
59
|
-
Object.keys(obj).forEach(function (key) {
|
|
60
|
-
var value = obj[key];
|
|
61
|
-
if (!isPlainObject(value)) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
if (!objectHasKeys(value)) {
|
|
65
|
-
delete obj[key];
|
|
66
|
-
} else {
|
|
67
|
-
removeEmptyKey(value);
|
|
68
|
-
}
|
|
69
|
-
});
|
|
70
|
-
return obj;
|
|
71
|
-
};
|
|
72
|
-
exports.removeEmptyKey = removeEmptyKey;
|
|
73
|
-
var removeEmptyArraysFromObject = function removeEmptyArraysFromObject(obj) {
|
|
74
|
-
Object.keys(obj).forEach(function (key) {
|
|
75
|
-
var value = obj[key];
|
|
76
|
-
if (Array.isArray(value) && value.length === 0) {
|
|
77
|
-
delete obj[key];
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
return obj;
|
|
81
|
-
};
|
|
82
|
-
exports.removeEmptyArraysFromObject = removeEmptyArraysFromObject;
|
|
83
|
-
function addAbsolutePositions(hits, hitsPerPage, page) {
|
|
84
|
-
return hits.map(function (hit, index) {
|
|
85
|
-
return _objectSpread(_objectSpread({}, hit), {}, {
|
|
86
|
-
__position: hitsPerPage * page + index + 1
|
|
87
|
-
});
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
function addQueryID(hits, queryID) {
|
|
91
|
-
if (!queryID) {
|
|
92
|
-
return hits;
|
|
93
|
-
}
|
|
94
|
-
return hits.map(function (hit) {
|
|
95
|
-
return _objectSpread(_objectSpread({}, hit), {}, {
|
|
96
|
-
__queryID: queryID
|
|
97
|
-
});
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
function find(array, comparator) {
|
|
101
|
-
if (!Array.isArray(array)) {
|
|
102
|
-
return undefined;
|
|
103
|
-
}
|
|
104
|
-
for (var i = 0; i < array.length; i++) {
|
|
105
|
-
if (comparator(array[i])) {
|
|
106
|
-
return array[i];
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
return undefined;
|
|
110
|
-
}
|
|
111
|
-
function objectHasKeys(object) {
|
|
112
|
-
return object && Object.keys(object).length > 0;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// https://github.com/babel/babel/blob/3aaafae053fa75febb3aa45d45b6f00646e30ba4/packages/babel-helpers/src/helpers.js#L604-L620
|
|
116
|
-
function omit(source, excluded) {
|
|
117
|
-
if (source === null || source === undefined) {
|
|
118
|
-
return {};
|
|
119
|
-
}
|
|
120
|
-
var target = {};
|
|
121
|
-
var sourceKeys = Object.keys(source);
|
|
122
|
-
for (var i = 0; i < sourceKeys.length; i++) {
|
|
123
|
-
var key = sourceKeys[i];
|
|
124
|
-
if (excluded.indexOf(key) >= 0) {
|
|
125
|
-
// eslint-disable-next-line no-continue
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
target[key] = source[key];
|
|
129
|
-
}
|
|
130
|
-
return target;
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Retrieve the value at a path of the object:
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* getPropertyByPath(
|
|
138
|
-
* { test: { this: { function: [{ now: { everyone: true } }] } } },
|
|
139
|
-
* 'test.this.function[0].now.everyone'
|
|
140
|
-
* ); // true
|
|
141
|
-
*
|
|
142
|
-
* getPropertyByPath(
|
|
143
|
-
* { test: { this: { function: [{ now: { everyone: true } }] } } },
|
|
144
|
-
* ['test', 'this', 'function', 0, 'now', 'everyone']
|
|
145
|
-
* ); // true
|
|
146
|
-
*
|
|
147
|
-
* @param object Source object to query
|
|
148
|
-
* @param path either an array of properties, or a string form of the properties, separated by .
|
|
149
|
-
*/
|
|
150
|
-
var getPropertyByPath = function getPropertyByPath(object, path) {
|
|
151
|
-
return (Array.isArray(path) ? path : path.replace(/\[(\d+)]/g, '.$1').split('.')).reduce(function (current, key) {
|
|
152
|
-
return current ? current[key] : undefined;
|
|
153
|
-
}, object);
|
|
154
|
-
};
|
|
155
|
-
exports.getPropertyByPath = getPropertyByPath;
|
|
156
|
-
function getObjectType(object) {
|
|
157
|
-
return Object.prototype.toString.call(object).slice(8, -1);
|
|
158
|
-
}
|
|
159
|
-
function unescapeFacetValue(value) {
|
|
160
|
-
return value.replace(/^\\-/, '-');
|
|
161
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _connectConfigure = _interopRequireDefault(require("../connectors/connectConfigure"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
/**
|
|
10
|
-
* Configure is a widget that lets you provide raw search parameters
|
|
11
|
-
* to the Algolia API.
|
|
12
|
-
*
|
|
13
|
-
* Any of the props added to this widget will be forwarded to Algolia. For more information
|
|
14
|
-
* on the different parameters that can be set, have a look at the
|
|
15
|
-
* [reference](https://www.algolia.com/doc/api-client/javascript/search#search-parameters).
|
|
16
|
-
*
|
|
17
|
-
* This widget can be used either with react-dom and react-native. It will not render anything
|
|
18
|
-
* on screen, only configure some parameters.
|
|
19
|
-
*
|
|
20
|
-
* Read more in the [Search parameters](guide/Search_parameters.html) guide.
|
|
21
|
-
* @name Configure
|
|
22
|
-
* @kind widget
|
|
23
|
-
* @example
|
|
24
|
-
* import React from 'react';
|
|
25
|
-
* import algoliasearch from 'algoliasearch/lite';
|
|
26
|
-
* import { InstantSearch, Configure, Hits } from 'react-instantsearch-dom';
|
|
27
|
-
*
|
|
28
|
-
* const searchClient = algoliasearch(
|
|
29
|
-
* 'latency',
|
|
30
|
-
* '6be0576ff61c053d5f9a3225e2a90f76'
|
|
31
|
-
* );
|
|
32
|
-
*
|
|
33
|
-
* const App = () => (
|
|
34
|
-
* <InstantSearch
|
|
35
|
-
* searchClient={searchClient}
|
|
36
|
-
* indexName="instant_search"
|
|
37
|
-
* >
|
|
38
|
-
* <Configure hitsPerPage={5} />
|
|
39
|
-
* <Hits />
|
|
40
|
-
* </InstantSearch>
|
|
41
|
-
* );
|
|
42
|
-
*/
|
|
43
|
-
var _default = (0, _connectConfigure.default)(function Configure() {
|
|
44
|
-
return null;
|
|
45
|
-
}, {
|
|
46
|
-
$$widgetType: 'ais.configure'
|
|
47
|
-
});
|
|
48
|
-
exports.default = _default;
|