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