react-instantsearch-core 6.40.4 → 7.0.1
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 -87
- 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 +14071 -7955
- 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 +23 -8
- 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,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _connectConfigureRelatedItems = _interopRequireDefault(require("../connectors/connectConfigureRelatedItems"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
10
|
-
function ConfigureRelatedItems() {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
ConfigureRelatedItems.propTypes = {
|
|
14
|
-
hit: _propTypes.default.object.isRequired,
|
|
15
|
-
matchingPatterns: _propTypes.default.object.isRequired,
|
|
16
|
-
transformSearchParameters: _propTypes.default.func
|
|
17
|
-
};
|
|
18
|
-
var _default = (0, _connectConfigureRelatedItems.default)(ConfigureRelatedItems, {
|
|
19
|
-
$$widgetType: 'ais.configureRelatedItems'
|
|
20
|
-
});
|
|
21
|
-
exports.default = _default;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
8
|
-
var _connectDynamicWidgets = _interopRequireDefault(require("../connectors/connectDynamicWidgets"));
|
|
9
|
-
var _utils = require("../core/utils");
|
|
10
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
11
|
-
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); }
|
|
12
|
-
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; }
|
|
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 isReactElement(element) {
|
|
15
|
-
return _typeof(element) === 'object' && element.props;
|
|
16
|
-
}
|
|
17
|
-
function getAttribute(element) {
|
|
18
|
-
if (!isReactElement(element)) {
|
|
19
|
-
return undefined;
|
|
20
|
-
}
|
|
21
|
-
if (element.props.attribute) {
|
|
22
|
-
return element.props.attribute;
|
|
23
|
-
}
|
|
24
|
-
if (Array.isArray(element.props.attributes)) {
|
|
25
|
-
return element.props.attributes[0];
|
|
26
|
-
}
|
|
27
|
-
if (element.props.children) {
|
|
28
|
-
return getAttribute(_react.default.Children.only(element.props.children));
|
|
29
|
-
}
|
|
30
|
-
return undefined;
|
|
31
|
-
}
|
|
32
|
-
function DynamicWidgets(_ref) {
|
|
33
|
-
var children = _ref.children,
|
|
34
|
-
attributesToRender = _ref.attributesToRender,
|
|
35
|
-
_ref$fallbackComponen = _ref.fallbackComponent,
|
|
36
|
-
Fallback = _ref$fallbackComponen === void 0 ? function () {
|
|
37
|
-
return null;
|
|
38
|
-
} : _ref$fallbackComponen;
|
|
39
|
-
var widgets = new Map();
|
|
40
|
-
_react.default.Children.forEach(children, function (child) {
|
|
41
|
-
var attribute = getAttribute(child);
|
|
42
|
-
if (!attribute) {
|
|
43
|
-
throw new Error("Could not find \"attribute\" prop for ".concat((0, _utils.getDisplayName)(child), "."));
|
|
44
|
-
}
|
|
45
|
-
widgets.set(attribute, child);
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
// on initial render this will be empty, but React InstantSearch keeps
|
|
49
|
-
// search state for unmounted components in place, so routing works.
|
|
50
|
-
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, attributesToRender.map(function (attribute) {
|
|
51
|
-
return /*#__PURE__*/_react.default.createElement(_react.Fragment, {
|
|
52
|
-
key: attribute
|
|
53
|
-
}, widgets.get(attribute) || /*#__PURE__*/_react.default.createElement(Fallback, {
|
|
54
|
-
attribute: attribute
|
|
55
|
-
}));
|
|
56
|
-
}));
|
|
57
|
-
}
|
|
58
|
-
var _default = (0, _connectDynamicWidgets.default)(DynamicWidgets, {
|
|
59
|
-
$$widgetType: 'ais.dynamicWidgets'
|
|
60
|
-
});
|
|
61
|
-
exports.default = _default;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = exports.IndexComponentWithoutContext = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _context = require("../core/context");
|
|
10
|
-
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); }
|
|
11
|
-
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; }
|
|
12
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
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 _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); }
|
|
15
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
16
|
-
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); } }
|
|
17
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
18
|
-
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); }
|
|
19
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
20
|
-
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); }; }
|
|
21
|
-
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); }
|
|
22
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
23
|
-
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; } }
|
|
24
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
25
|
-
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; }
|
|
26
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
27
|
-
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); }
|
|
28
|
-
function getIndexContext(props) {
|
|
29
|
-
return {
|
|
30
|
-
targetedIndex: props.indexId
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* The component that allows you to apply widgets to a dedicated index. It's
|
|
35
|
-
* useful if you want to build an interface that targets multiple indices.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* import React from 'react';
|
|
39
|
-
* import algoliasearch from 'algoliasearch/lite';
|
|
40
|
-
* import { InstantSearch, Index, SearchBox, Hits, Configure } from 'react-instantsearch-dom';
|
|
41
|
-
*
|
|
42
|
-
* const searchClient = algoliasearch(
|
|
43
|
-
* 'latency',
|
|
44
|
-
* '6be0576ff61c053d5f9a3225e2a90f76'
|
|
45
|
-
* );
|
|
46
|
-
*
|
|
47
|
-
* const App = () => (
|
|
48
|
-
* <InstantSearch
|
|
49
|
-
* searchClient={searchClient}
|
|
50
|
-
* indexName="instant_search"
|
|
51
|
-
* >
|
|
52
|
-
* <Configure hitsPerPage={5} />
|
|
53
|
-
* <SearchBox />
|
|
54
|
-
* <Index indexName="instant_search">
|
|
55
|
-
* <Hits />
|
|
56
|
-
* </Index>
|
|
57
|
-
* <Index indexName="bestbuy">
|
|
58
|
-
* <Hits />
|
|
59
|
-
* </Index>
|
|
60
|
-
* </InstantSearch>
|
|
61
|
-
* );
|
|
62
|
-
*/
|
|
63
|
-
var Index = /*#__PURE__*/function (_Component) {
|
|
64
|
-
_inherits(Index, _Component);
|
|
65
|
-
var _super = _createSuper(Index);
|
|
66
|
-
function Index(props) {
|
|
67
|
-
var _this;
|
|
68
|
-
_classCallCheck(this, Index);
|
|
69
|
-
_this = _super.call(this, props);
|
|
70
|
-
_defineProperty(_assertThisInitialized(_this), "state", {
|
|
71
|
-
indexContext: getIndexContext(_this.props)
|
|
72
|
-
});
|
|
73
|
-
_defineProperty(_assertThisInitialized(_this), "unregisterWidget", void 0);
|
|
74
|
-
_this.props.contextValue.onSearchParameters(_this.getSearchParameters.bind(_assertThisInitialized(_this)), {
|
|
75
|
-
ais: _this.props.contextValue,
|
|
76
|
-
multiIndexContext: _this.state.indexContext
|
|
77
|
-
}, _this.props, undefined, Index.displayName);
|
|
78
|
-
return _this;
|
|
79
|
-
}
|
|
80
|
-
_createClass(Index, [{
|
|
81
|
-
key: "componentDidMount",
|
|
82
|
-
value: function componentDidMount() {
|
|
83
|
-
this.unregisterWidget = this.props.contextValue.widgetsManager.registerWidget(this);
|
|
84
|
-
}
|
|
85
|
-
}, {
|
|
86
|
-
key: "componentDidUpdate",
|
|
87
|
-
value: function componentDidUpdate(prevProps) {
|
|
88
|
-
if (this.props.indexName !== prevProps.indexName) {
|
|
89
|
-
this.props.contextValue.widgetsManager.update();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}, {
|
|
93
|
-
key: "componentWillUnmount",
|
|
94
|
-
value: function componentWillUnmount() {
|
|
95
|
-
if (typeof this.unregisterWidget === 'function') {
|
|
96
|
-
this.unregisterWidget();
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}, {
|
|
100
|
-
key: "getSearchParameters",
|
|
101
|
-
value: function getSearchParameters(searchParameters, props) {
|
|
102
|
-
return searchParameters.setIndex(this.props ? this.props.indexName : props.indexName);
|
|
103
|
-
}
|
|
104
|
-
}, {
|
|
105
|
-
key: "render",
|
|
106
|
-
value: function render() {
|
|
107
|
-
var childrenCount = _react.Children.count(this.props.children);
|
|
108
|
-
if (childrenCount === 0) {
|
|
109
|
-
return null;
|
|
110
|
-
}
|
|
111
|
-
return /*#__PURE__*/_react.default.createElement(_context.IndexProvider, {
|
|
112
|
-
value: this.state.indexContext
|
|
113
|
-
}, this.props.children);
|
|
114
|
-
}
|
|
115
|
-
}], [{
|
|
116
|
-
key: "getDerivedStateFromProps",
|
|
117
|
-
value: function getDerivedStateFromProps(props) {
|
|
118
|
-
return {
|
|
119
|
-
indexContext: getIndexContext(props)
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}]);
|
|
123
|
-
return Index;
|
|
124
|
-
}(_react.Component);
|
|
125
|
-
_defineProperty(Index, "propTypes", {
|
|
126
|
-
indexName: _propTypes.default.string.isRequired,
|
|
127
|
-
indexId: _propTypes.default.string.isRequired,
|
|
128
|
-
children: _propTypes.default.node
|
|
129
|
-
});
|
|
130
|
-
_defineProperty(Index, "displayName", 'AlgoliaIndex');
|
|
131
|
-
_defineProperty(Index, "$$type", 'ais.index');
|
|
132
|
-
_defineProperty(Index, "$$widgetType", 'ais.index');
|
|
133
|
-
var IndexWrapper = function IndexWrapper(props) {
|
|
134
|
-
var inferredIndexId = props.indexName;
|
|
135
|
-
return /*#__PURE__*/_react.default.createElement(_context.InstantSearchConsumer, null, function (contextValue) {
|
|
136
|
-
return /*#__PURE__*/_react.default.createElement(Index, _extends({
|
|
137
|
-
contextValue: contextValue,
|
|
138
|
-
indexId: inferredIndexId
|
|
139
|
-
}, props));
|
|
140
|
-
});
|
|
141
|
-
};
|
|
142
|
-
IndexWrapper.propTypes = {
|
|
143
|
-
indexName: _propTypes.default.string.isRequired,
|
|
144
|
-
indexId: _propTypes.default.string
|
|
145
|
-
};
|
|
146
|
-
var IndexComponentWithoutContext = Index;
|
|
147
|
-
exports.IndexComponentWithoutContext = IndexComponentWithoutContext;
|
|
148
|
-
var _default = IndexWrapper;
|
|
149
|
-
exports.default = _default;
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
|
-
var _reactFastCompare = _interopRequireDefault(require("react-fast-compare"));
|
|
10
|
-
var _context = require("../core/context");
|
|
11
|
-
var _createInstantSearchManager = _interopRequireDefault(require("../core/createInstantSearchManager"));
|
|
12
|
-
var _metadata = require("../core/metadata");
|
|
13
|
-
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); }
|
|
14
|
-
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; }
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
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); }
|
|
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 _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
20
|
-
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); } }
|
|
21
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
22
|
-
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); }
|
|
23
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
24
|
-
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); }; }
|
|
25
|
-
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); }
|
|
26
|
-
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
27
|
-
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; } }
|
|
28
|
-
function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
|
|
29
|
-
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; }
|
|
30
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
31
|
-
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); }
|
|
32
|
-
function isControlled(props) {
|
|
33
|
-
return Boolean(props.searchState);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* @description
|
|
38
|
-
* `<InstantSearch>` is the root component of all React InstantSearch implementations.
|
|
39
|
-
* It provides all the connected components (aka widgets) a means to interact
|
|
40
|
-
* with the searchState.
|
|
41
|
-
* @kind widget
|
|
42
|
-
* @name <InstantSearch>
|
|
43
|
-
* @requirements You will need to have an Algolia account to be able to use this widget.
|
|
44
|
-
* [Create one now](https://www.algolia.com/users/sign_up).
|
|
45
|
-
* @propType {string} indexName - Main index in which to search.
|
|
46
|
-
* @propType {boolean} [refresh=false] - Flag to activate when the cache needs to be cleared so that the front-end is updated when a change occurs in the index.
|
|
47
|
-
* @propType {object} [searchClient] - Provide a custom search client.
|
|
48
|
-
* @propType {func} [onSearchStateChange] - Function to be called everytime a new search is done. Useful for [URL Routing](guide/Routing.html).
|
|
49
|
-
* @propType {object} [searchState] - Object to inject some search state. Switches the InstantSearch component in controlled mode. Useful for [URL Routing](guide/Routing.html).
|
|
50
|
-
* @propType {func} [createURL] - Function to call when creating links, useful for [URL Routing](guide/Routing.html).
|
|
51
|
-
* @propType {SearchResults|SearchResults[]} [resultsState] - Use this to inject the results that will be used at first rendering. Those results are found by using the `findResultsState` function. Useful for [Server Side Rendering](guide/Server-side_rendering.html).
|
|
52
|
-
* @propType {number} [stalledSearchDelay=200] - The amount of time before considering that the search takes too much time. The time is expressed in milliseconds.
|
|
53
|
-
* @propType {{ Root: string|function, props: object }} [root] - Use this to customize the root element. Default value: `{ Root: 'div' }`
|
|
54
|
-
* @example
|
|
55
|
-
* import React from 'react';
|
|
56
|
-
* import algoliasearch from 'algoliasearch/lite';
|
|
57
|
-
* import { InstantSearch, SearchBox, Hits } from 'react-instantsearch-dom';
|
|
58
|
-
*
|
|
59
|
-
* const searchClient = algoliasearch(
|
|
60
|
-
* 'latency',
|
|
61
|
-
* '6be0576ff61c053d5f9a3225e2a90f76'
|
|
62
|
-
* );
|
|
63
|
-
*
|
|
64
|
-
* const App = () => (
|
|
65
|
-
* <InstantSearch
|
|
66
|
-
* searchClient={searchClient}
|
|
67
|
-
* indexName="instant_search"
|
|
68
|
-
* >
|
|
69
|
-
* <SearchBox />
|
|
70
|
-
* <Hits />
|
|
71
|
-
* </InstantSearch>
|
|
72
|
-
* );
|
|
73
|
-
*/
|
|
74
|
-
var InstantSearch = /*#__PURE__*/function (_Component) {
|
|
75
|
-
_inherits(InstantSearch, _Component);
|
|
76
|
-
var _super = _createSuper(InstantSearch);
|
|
77
|
-
function InstantSearch(props) {
|
|
78
|
-
var _this;
|
|
79
|
-
_classCallCheck(this, InstantSearch);
|
|
80
|
-
_this = _super.call(this, props);
|
|
81
|
-
_defineProperty(_assertThisInitialized(_this), "cleanupTimerRef", null);
|
|
82
|
-
_defineProperty(_assertThisInitialized(_this), "isUnmounting", false);
|
|
83
|
-
var instantSearchManager = (0, _createInstantSearchManager.default)({
|
|
84
|
-
indexName: _this.props.indexName,
|
|
85
|
-
searchClient: _this.props.searchClient,
|
|
86
|
-
initialState: _this.props.searchState || {},
|
|
87
|
-
resultsState: _this.props.resultsState,
|
|
88
|
-
stalledSearchDelay: _this.props.stalledSearchDelay
|
|
89
|
-
});
|
|
90
|
-
var contextValue = {
|
|
91
|
-
store: instantSearchManager.store,
|
|
92
|
-
widgetsManager: instantSearchManager.widgetsManager,
|
|
93
|
-
mainTargetedIndex: _this.props.indexName,
|
|
94
|
-
onInternalStateUpdate: _this.onWidgetsInternalStateUpdate.bind(_assertThisInitialized(_this)),
|
|
95
|
-
createHrefForState: _this.createHrefForState.bind(_assertThisInitialized(_this)),
|
|
96
|
-
onSearchForFacetValues: _this.onSearchForFacetValues.bind(_assertThisInitialized(_this)),
|
|
97
|
-
onSearchStateChange: _this.onSearchStateChange.bind(_assertThisInitialized(_this)),
|
|
98
|
-
onSearchParameters: _this.onSearchParameters.bind(_assertThisInitialized(_this))
|
|
99
|
-
};
|
|
100
|
-
_this.state = {
|
|
101
|
-
isControlled: isControlled(_this.props),
|
|
102
|
-
instantSearchManager: instantSearchManager,
|
|
103
|
-
contextValue: contextValue
|
|
104
|
-
};
|
|
105
|
-
return _this;
|
|
106
|
-
}
|
|
107
|
-
_createClass(InstantSearch, [{
|
|
108
|
-
key: "componentDidUpdate",
|
|
109
|
-
value: function componentDidUpdate(prevProps) {
|
|
110
|
-
var prevIsControlled = isControlled(prevProps);
|
|
111
|
-
if (prevIsControlled && !this.state.isControlled) {
|
|
112
|
-
throw new Error("You can't switch <InstantSearch> from being controlled to uncontrolled");
|
|
113
|
-
}
|
|
114
|
-
if (!prevIsControlled && this.state.isControlled) {
|
|
115
|
-
throw new Error("You can't switch <InstantSearch> from being uncontrolled to controlled");
|
|
116
|
-
}
|
|
117
|
-
if (this.props.refresh !== prevProps.refresh && this.props.refresh) {
|
|
118
|
-
this.state.instantSearchManager.clearCache();
|
|
119
|
-
}
|
|
120
|
-
if (prevProps.indexName !== this.props.indexName) {
|
|
121
|
-
this.state.instantSearchManager.updateIndex(this.props.indexName);
|
|
122
|
-
}
|
|
123
|
-
if (prevProps.searchClient !== this.props.searchClient) {
|
|
124
|
-
this.state.instantSearchManager.updateClient(this.props.searchClient);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "componentDidMount",
|
|
129
|
-
value: function componentDidMount() {
|
|
130
|
-
if (this.cleanupTimerRef) {
|
|
131
|
-
clearTimeout(this.cleanupTimerRef);
|
|
132
|
-
this.cleanupTimerRef = null;
|
|
133
|
-
}
|
|
134
|
-
if ((0, _metadata.isMetadataEnabled)()) {
|
|
135
|
-
(0, _metadata.injectMetadata)(this.state.instantSearchManager.widgetsManager.getWidgets(), this.props.searchClient);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}, {
|
|
139
|
-
key: "componentWillUnmount",
|
|
140
|
-
value: function componentWillUnmount() {
|
|
141
|
-
var _this2 = this;
|
|
142
|
-
this.cleanupTimerRef = setTimeout(function () {
|
|
143
|
-
_this2.isUnmounting = true;
|
|
144
|
-
_this2.state.instantSearchManager.skipSearch();
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}, {
|
|
148
|
-
key: "createHrefForState",
|
|
149
|
-
value: function createHrefForState(searchState) {
|
|
150
|
-
searchState = this.state.instantSearchManager.transitionState(searchState);
|
|
151
|
-
return this.state.isControlled && this.props.createURL ? this.props.createURL(searchState, this.getKnownKeys()) : '#';
|
|
152
|
-
}
|
|
153
|
-
}, {
|
|
154
|
-
key: "onWidgetsInternalStateUpdate",
|
|
155
|
-
value: function onWidgetsInternalStateUpdate(searchState) {
|
|
156
|
-
searchState = this.state.instantSearchManager.transitionState(searchState);
|
|
157
|
-
this.onSearchStateChange(searchState);
|
|
158
|
-
if (!this.state.isControlled) {
|
|
159
|
-
this.state.instantSearchManager.onExternalStateUpdate(searchState);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}, {
|
|
163
|
-
key: "onSearchStateChange",
|
|
164
|
-
value: function onSearchStateChange(searchState) {
|
|
165
|
-
if (this.props.onSearchStateChange && !this.isUnmounting) {
|
|
166
|
-
this.props.onSearchStateChange(searchState);
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
}, {
|
|
170
|
-
key: "onSearchParameters",
|
|
171
|
-
value: function onSearchParameters(getSearchParameters, context, props, getMetadata, displayName) {
|
|
172
|
-
if (this.props.onSearchParameters) {
|
|
173
|
-
var _searchState = this.props.searchState ? this.props.searchState : {};
|
|
174
|
-
this.props.onSearchParameters(getSearchParameters, context, props, _searchState);
|
|
175
|
-
}
|
|
176
|
-
if (this.props.widgetsCollector) {
|
|
177
|
-
var _searchState2 = this.props.searchState ? this.props.searchState : {};
|
|
178
|
-
this.props.widgetsCollector({
|
|
179
|
-
getSearchParameters: getSearchParameters,
|
|
180
|
-
getMetadata: getMetadata,
|
|
181
|
-
context: context,
|
|
182
|
-
props: props,
|
|
183
|
-
searchState: _searchState2,
|
|
184
|
-
displayName: displayName
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}, {
|
|
189
|
-
key: "onSearchForFacetValues",
|
|
190
|
-
value: function onSearchForFacetValues(searchState) {
|
|
191
|
-
this.state.instantSearchManager.onSearchForFacetValues(searchState);
|
|
192
|
-
}
|
|
193
|
-
}, {
|
|
194
|
-
key: "getKnownKeys",
|
|
195
|
-
value: function getKnownKeys() {
|
|
196
|
-
return this.state.instantSearchManager.getWidgetsIds();
|
|
197
|
-
}
|
|
198
|
-
}, {
|
|
199
|
-
key: "render",
|
|
200
|
-
value: function render() {
|
|
201
|
-
if (_react.Children.count(this.props.children) === 0) {
|
|
202
|
-
return null;
|
|
203
|
-
}
|
|
204
|
-
return /*#__PURE__*/_react.default.createElement(_context.InstantSearchProvider, {
|
|
205
|
-
value: this.state.contextValue
|
|
206
|
-
}, this.props.children);
|
|
207
|
-
}
|
|
208
|
-
}], [{
|
|
209
|
-
key: "getDerivedStateFromProps",
|
|
210
|
-
value: function getDerivedStateFromProps(nextProps, prevState) {
|
|
211
|
-
var nextIsControlled = isControlled(nextProps);
|
|
212
|
-
var previousSearchState = prevState.instantSearchManager.store.getState().widgets;
|
|
213
|
-
var nextSearchState = nextProps.searchState;
|
|
214
|
-
if (nextIsControlled && !(0, _reactFastCompare.default)(previousSearchState, nextSearchState)) {
|
|
215
|
-
prevState.instantSearchManager.onExternalStateUpdate(nextProps.searchState);
|
|
216
|
-
}
|
|
217
|
-
return {
|
|
218
|
-
isControlled: nextIsControlled,
|
|
219
|
-
contextValue: _objectSpread(_objectSpread({}, prevState.contextValue), {}, {
|
|
220
|
-
mainTargetedIndex: nextProps.indexName
|
|
221
|
-
})
|
|
222
|
-
};
|
|
223
|
-
}
|
|
224
|
-
}]);
|
|
225
|
-
return InstantSearch;
|
|
226
|
-
}(_react.Component);
|
|
227
|
-
_defineProperty(InstantSearch, "defaultProps", {
|
|
228
|
-
stalledSearchDelay: 200,
|
|
229
|
-
refresh: false
|
|
230
|
-
});
|
|
231
|
-
_defineProperty(InstantSearch, "propTypes", {
|
|
232
|
-
// @TODO: These props are currently constant.
|
|
233
|
-
indexName: _propTypes.default.string.isRequired,
|
|
234
|
-
searchClient: _propTypes.default.shape({
|
|
235
|
-
search: _propTypes.default.func.isRequired,
|
|
236
|
-
searchForFacetValues: _propTypes.default.func,
|
|
237
|
-
addAlgoliaAgent: _propTypes.default.func,
|
|
238
|
-
clearCache: _propTypes.default.func
|
|
239
|
-
}).isRequired,
|
|
240
|
-
createURL: _propTypes.default.func,
|
|
241
|
-
refresh: _propTypes.default.bool,
|
|
242
|
-
searchState: _propTypes.default.object,
|
|
243
|
-
onSearchStateChange: _propTypes.default.func,
|
|
244
|
-
onSearchParameters: _propTypes.default.func,
|
|
245
|
-
widgetsCollector: _propTypes.default.func,
|
|
246
|
-
resultsState: _propTypes.default.oneOfType([_propTypes.default.object, _propTypes.default.array]),
|
|
247
|
-
children: _propTypes.default.node,
|
|
248
|
-
stalledSearchDelay: _propTypes.default.number
|
|
249
|
-
});
|
|
250
|
-
var _default = InstantSearch;
|
|
251
|
-
exports.default = _default;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
var _connectQueryRules = _interopRequireDefault(require("../connectors/connectQueryRules"));
|
|
8
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
9
|
-
var _default = (0, _connectQueryRules.default)(function QueryRuleContext() {
|
|
10
|
-
return null;
|
|
11
|
-
}, {
|
|
12
|
-
$$widgetType: 'ais.queryRuleContext'
|
|
13
|
-
});
|
|
14
|
-
exports.default = _default;
|
|
@@ -1,96 +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 _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; }
|
|
3
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
4
|
-
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); }
|
|
5
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
6
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
9
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
import createConnector from "../core/createConnector.js";
|
|
12
|
-
import { cleanUpValue, refineValue, getCurrentRefinementValue } from "../core/indexUtils.js";
|
|
13
|
-
import { addQueryID, addAbsolutePositions } from "../core/utils.js";
|
|
14
|
-
var getId = function getId() {
|
|
15
|
-
return 'query';
|
|
16
|
-
};
|
|
17
|
-
function getCurrentRefinement(props, searchState, context) {
|
|
18
|
-
var id = getId();
|
|
19
|
-
var currentRefinement = getCurrentRefinementValue(props, searchState, context, id, '');
|
|
20
|
-
if (currentRefinement) {
|
|
21
|
-
return currentRefinement;
|
|
22
|
-
}
|
|
23
|
-
return '';
|
|
24
|
-
}
|
|
25
|
-
function getHits(searchResults) {
|
|
26
|
-
if (searchResults.results) {
|
|
27
|
-
if (searchResults.results.hits && Array.isArray(searchResults.results.hits)) {
|
|
28
|
-
return addAbsolutePositions(addQueryID(searchResults.results.hits, searchResults.results.queryID), searchResults.results.hitsPerPage, searchResults.results.page);
|
|
29
|
-
} else {
|
|
30
|
-
return Object.keys(searchResults.results).reduce(function (hits, index) {
|
|
31
|
-
return [].concat(_toConsumableArray(hits), [{
|
|
32
|
-
index: index,
|
|
33
|
-
hits: addAbsolutePositions(addQueryID(searchResults.results[index].hits, searchResults.results[index].queryID), searchResults.results[index].hitsPerPage, searchResults.results[index].page)
|
|
34
|
-
}]);
|
|
35
|
-
}, []);
|
|
36
|
-
}
|
|
37
|
-
} else {
|
|
38
|
-
return [];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
function _refine(props, searchState, nextRefinement, context) {
|
|
42
|
-
var id = getId();
|
|
43
|
-
var nextValue = _defineProperty({}, id, nextRefinement);
|
|
44
|
-
var resetPage = true;
|
|
45
|
-
return refineValue(searchState, nextValue, context, resetPage);
|
|
46
|
-
}
|
|
47
|
-
function _cleanUp(props, searchState, context) {
|
|
48
|
-
return cleanUpValue(searchState, context, getId());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* connectAutoComplete connector provides the logic to create connected
|
|
53
|
-
* components that will render the results retrieved from
|
|
54
|
-
* Algolia.
|
|
55
|
-
*
|
|
56
|
-
* To configure the number of hits retrieved, use [HitsPerPage widget](widgets/HitsPerPage.html),
|
|
57
|
-
* [connectHitsPerPage connector](connectors/connectHitsPerPage.html) or pass the hitsPerPage
|
|
58
|
-
* prop to a [Configure](guide/Search_parameters.html) widget.
|
|
59
|
-
* @name connectAutoComplete
|
|
60
|
-
* @kind connector
|
|
61
|
-
* @propType {string} [defaultRefinement] - Provide a default value for the query
|
|
62
|
-
* @providedPropType {array.<object>} hits - the records that matched the search state
|
|
63
|
-
* @providedPropType {function} refine - a function to change the query
|
|
64
|
-
* @providedPropType {string} currentRefinement - the query to search for
|
|
65
|
-
*/
|
|
66
|
-
export default createConnector({
|
|
67
|
-
displayName: 'AlgoliaAutoComplete',
|
|
68
|
-
$$type: 'ais.autoComplete',
|
|
69
|
-
getProvidedProps: function getProvidedProps(props, searchState, searchResults) {
|
|
70
|
-
return {
|
|
71
|
-
hits: getHits(searchResults),
|
|
72
|
-
currentRefinement: getCurrentRefinement(props, searchState, {
|
|
73
|
-
ais: props.contextValue,
|
|
74
|
-
multiIndexContext: props.indexContextValue
|
|
75
|
-
})
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
refine: function refine(props, searchState, nextRefinement) {
|
|
79
|
-
return _refine(props, searchState, nextRefinement, {
|
|
80
|
-
ais: props.contextValue,
|
|
81
|
-
multiIndexContext: props.indexContextValue
|
|
82
|
-
});
|
|
83
|
-
},
|
|
84
|
-
cleanUp: function cleanUp(props, searchState) {
|
|
85
|
-
return _cleanUp(props, searchState, {
|
|
86
|
-
ais: props.contextValue,
|
|
87
|
-
multiIndexContext: props.indexContextValue
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
getSearchParameters: function getSearchParameters(searchParameters, props, searchState) {
|
|
91
|
-
return searchParameters.setQuery(getCurrentRefinement(props, searchState, {
|
|
92
|
-
ais: props.contextValue,
|
|
93
|
-
multiIndexContext: props.indexContextValue
|
|
94
|
-
}));
|
|
95
|
-
}
|
|
96
|
-
});
|