react-instantsearch-core 7.24.0 → 7.26.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/dist/cjs/components/Configure.js +11 -17
- package/dist/cjs/components/DynamicWidgets.js +46 -53
- package/dist/cjs/components/Index.js +19 -22
- package/dist/cjs/components/InstantSearch.js +34 -36
- package/dist/cjs/components/InstantSearchSSRProvider.js +31 -41
- package/dist/cjs/components/InstantSearchServerContext.js +6 -10
- package/dist/cjs/connectors/useAutocomplete.js +8 -10
- package/dist/cjs/connectors/useBreadcrumb.js +8 -10
- package/dist/cjs/connectors/useChat.js +8 -10
- package/dist/cjs/connectors/useClearRefinements.js +8 -10
- package/dist/cjs/connectors/useConfigure.js +10 -12
- package/dist/cjs/connectors/useCurrentRefinements.js +8 -10
- package/dist/cjs/connectors/useDynamicWidgets.js +14 -20
- package/dist/cjs/connectors/useFilterSuggestions.js +8 -10
- package/dist/cjs/connectors/useFrequentlyBoughtTogether.js +8 -10
- package/dist/cjs/connectors/useGeoSearch.js +8 -10
- package/dist/cjs/connectors/useHierarchicalMenu.js +8 -10
- package/dist/cjs/connectors/useHits.js +8 -10
- package/dist/cjs/connectors/useHitsPerPage.js +8 -10
- package/dist/cjs/connectors/useInfiniteHits.js +8 -10
- package/dist/cjs/connectors/useLookingSimilar.js +8 -10
- package/dist/cjs/connectors/useMenu.js +8 -10
- package/dist/cjs/connectors/useNumericMenu.js +8 -10
- package/dist/cjs/connectors/usePagination.js +8 -10
- package/dist/cjs/connectors/usePoweredBy.js +18 -19
- package/dist/cjs/connectors/useQueryRules.js +8 -10
- package/dist/cjs/connectors/useRange.js +8 -10
- package/dist/cjs/connectors/useRefinementList.js +8 -10
- package/dist/cjs/connectors/useRelatedProducts.js +8 -10
- package/dist/cjs/connectors/useSearchBox.js +8 -10
- package/dist/cjs/connectors/useSortBy.js +8 -10
- package/dist/cjs/connectors/useStats.js +8 -10
- package/dist/cjs/connectors/useToggleRefinement.js +8 -10
- package/dist/cjs/connectors/useTrendingItems.js +8 -10
- package/dist/cjs/hooks/useConnector.js +123 -139
- package/dist/cjs/hooks/useInstantSearch.js +59 -59
- package/dist/cjs/index.js +90 -519
- package/dist/cjs/lib/IndexContext.js +6 -10
- package/dist/cjs/lib/InstantSearchContext.js +6 -10
- package/dist/cjs/lib/InstantSearchRSCContext.js +11 -12
- package/dist/cjs/lib/InstantSearchSSRContext.js +6 -10
- package/dist/cjs/lib/createSearchResults.js +24 -25
- package/dist/cjs/lib/dequal.js +33 -40
- package/dist/cjs/lib/getIndexSearchResults.js +23 -30
- package/dist/cjs/lib/invariant.js +11 -17
- package/dist/cjs/lib/noop.js +8 -6
- package/dist/cjs/lib/use.js +26 -11
- package/dist/cjs/lib/useAppIdAndApiKey.js +10 -12
- package/dist/cjs/lib/useForceUpdate.js +12 -21
- package/dist/cjs/lib/useIndex.js +40 -37
- package/dist/cjs/lib/useIndexContext.js +11 -12
- package/dist/cjs/lib/useInstantSearchApi.js +174 -197
- package/dist/cjs/lib/useInstantSearchContext.js +11 -12
- package/dist/cjs/lib/useInstantSearchSSRContext.js +8 -9
- package/dist/cjs/lib/useInstantSearchServerContext.js +8 -9
- package/dist/cjs/lib/useIsomorphicLayoutEffect.js +6 -8
- package/dist/cjs/lib/useRSCContext.js +8 -9
- package/dist/cjs/lib/useSearchResults.js +54 -62
- package/dist/cjs/lib/useSearchState.js +53 -60
- package/dist/cjs/lib/useStableValue.js +15 -24
- package/dist/cjs/lib/useWidget.js +99 -95
- package/dist/cjs/lib/warn.js +11 -35
- package/dist/cjs/lib/wrapPromiseWithState.js +23 -26
- package/dist/cjs/package.json +4 -1
- package/dist/cjs/server/getServerState.js +81 -91
- package/dist/cjs/server/index.js +6 -15
- package/dist/cjs/version.js +6 -6
- package/dist/es/components/Configure.js +11 -13
- package/dist/es/components/DynamicWidgets.js +45 -47
- package/dist/es/components/Index.js +19 -17
- package/dist/es/components/InstantSearch.js +33 -29
- package/dist/es/components/InstantSearchSSRProvider.js +30 -35
- package/dist/es/components/InstantSearchServerContext.js +4 -4
- package/dist/es/connectors/useAutocomplete.js +8 -5
- package/dist/es/connectors/useBreadcrumb.js +8 -5
- package/dist/es/connectors/useChat.js +8 -5
- package/dist/es/connectors/useClearRefinements.js +8 -5
- package/dist/es/connectors/useConfigure.js +10 -7
- package/dist/es/connectors/useCurrentRefinements.js +8 -5
- package/dist/es/connectors/useDynamicWidgets.js +14 -15
- package/dist/es/connectors/useFilterSuggestions.js +8 -5
- package/dist/es/connectors/useFrequentlyBoughtTogether.js +8 -5
- package/dist/es/connectors/useGeoSearch.js +8 -5
- package/dist/es/connectors/useHierarchicalMenu.js +8 -5
- package/dist/es/connectors/useHits.js +8 -5
- package/dist/es/connectors/useHitsPerPage.js +8 -5
- package/dist/es/connectors/useInfiniteHits.js +8 -5
- package/dist/es/connectors/useLookingSimilar.js +8 -5
- package/dist/es/connectors/useMenu.js +8 -5
- package/dist/es/connectors/useNumericMenu.js +8 -5
- package/dist/es/connectors/usePagination.js +8 -5
- package/dist/es/connectors/usePoweredBy.js +18 -15
- package/dist/es/connectors/useQueryRules.js +8 -5
- package/dist/es/connectors/useRange.js +8 -5
- package/dist/es/connectors/useRefinementList.js +8 -5
- package/dist/es/connectors/useRelatedProducts.js +8 -5
- package/dist/es/connectors/useSearchBox.js +8 -5
- package/dist/es/connectors/useSortBy.js +8 -5
- package/dist/es/connectors/useStats.js +8 -5
- package/dist/es/connectors/useToggleRefinement.js +8 -5
- package/dist/es/connectors/useTrendingItems.js +8 -5
- package/dist/es/hooks/useConnector.js +122 -134
- package/dist/es/hooks/useInstantSearch.js +58 -54
- package/dist/es/index.js +43 -43
- package/dist/es/lib/IndexContext.js +4 -4
- package/dist/es/lib/InstantSearchContext.js +4 -4
- package/dist/es/lib/InstantSearchRSCContext.js +10 -7
- package/dist/es/lib/InstantSearchSSRContext.js +4 -4
- package/dist/es/lib/createSearchResults.js +23 -19
- package/dist/es/lib/dequal.js +33 -36
- package/dist/es/lib/getIndexSearchResults.js +23 -26
- package/dist/es/lib/invariant.js +10 -12
- package/dist/es/lib/noop.js +7 -1
- package/dist/es/lib/use.js +4 -2
- package/dist/es/lib/useAppIdAndApiKey.js +9 -7
- package/dist/es/lib/useForceUpdate.js +9 -15
- package/dist/es/lib/useIndex.js +39 -31
- package/dist/es/lib/useIndexContext.js +10 -7
- package/dist/es/lib/useInstantSearchApi.js +174 -191
- package/dist/es/lib/useInstantSearchContext.js +10 -7
- package/dist/es/lib/useInstantSearchSSRContext.js +7 -4
- package/dist/es/lib/useInstantSearchServerContext.js +7 -4
- package/dist/es/lib/useIsomorphicLayoutEffect.js +4 -3
- package/dist/es/lib/useRSCContext.js +7 -4
- package/dist/es/lib/useSearchResults.js +53 -57
- package/dist/es/lib/useSearchState.js +52 -55
- package/dist/es/lib/useStableValue.js +14 -19
- package/dist/es/lib/useWidget.js +98 -90
- package/dist/es/lib/warn.js +9 -29
- package/dist/es/lib/wrapPromiseWithState.js +23 -22
- package/dist/es/package.json +4 -0
- package/dist/es/server/getServerState.js +80 -85
- package/dist/es/server/index.js +1 -1
- package/dist/es/version.d.ts +1 -1
- package/dist/es/version.js +3 -1
- package/dist/umd/ReactInstantSearchCore.js +17488 -22329
- package/dist/umd/ReactInstantSearchCore.min.js +3 -3
- package/package.json +7 -11
- package/dist/umd/ReactInstantSearchCore.js.map +0 -1
- package/dist/umd/ReactInstantSearchCore.min.js.map +0 -1
|
@@ -1,98 +1,88 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var server = require('instantsearch.js/cjs/lib/server');
|
|
4
|
+
var utils = require('instantsearch.js/cjs/lib/utils');
|
|
5
|
+
var React = require('react');
|
|
6
|
+
var InstantSearchServerContext = require('../components/InstantSearchServerContext.js');
|
|
7
|
+
var InstantSearchSSRProvider = require('../components/InstantSearchSSRProvider.js');
|
|
2
8
|
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getServerState = getServerState;
|
|
7
|
-
var _server = require("instantsearch.js/cjs/lib/server");
|
|
8
|
-
var _utils = require("instantsearch.js/cjs/lib/utils");
|
|
9
|
-
var _react = _interopRequireDefault(require("react"));
|
|
10
|
-
var _InstantSearchServerContext = require("../components/InstantSearchServerContext");
|
|
11
|
-
var _InstantSearchSSRProvider = require("../components/InstantSearchSSRProvider");
|
|
12
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
9
|
/**
|
|
14
10
|
* Returns the InstantSearch server state from a component.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
current: undefined
|
|
20
|
-
};
|
|
21
|
-
(0, _utils.resetWidgetId)();
|
|
22
|
-
var createNotifyServer = function createNotifyServer() {
|
|
23
|
-
var hasBeenNotified = false;
|
|
24
|
-
var notifyServer = function notifyServer(_ref2) {
|
|
25
|
-
var search = _ref2.search;
|
|
26
|
-
if (hasBeenNotified) {
|
|
27
|
-
throw new Error('getServerState should be called with a single InstantSearchSSRProvider and a single InstantSearch component.');
|
|
28
|
-
}
|
|
29
|
-
hasBeenNotified = true;
|
|
30
|
-
searchRef.current = search;
|
|
11
|
+
*/ function getServerState(children, param) {
|
|
12
|
+
var renderToString = param.renderToString;
|
|
13
|
+
var searchRef = {
|
|
14
|
+
current: undefined
|
|
31
15
|
};
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
if (shouldRefetch) {
|
|
50
|
-
(0, _utils.resetWidgetId)();
|
|
51
|
-
return execute({
|
|
52
|
-
children: /*#__PURE__*/_react.default.createElement(_InstantSearchSSRProvider.InstantSearchSSRProvider, serverState, children),
|
|
16
|
+
utils.resetWidgetId();
|
|
17
|
+
var createNotifyServer = function createNotifyServer() {
|
|
18
|
+
var hasBeenNotified = false;
|
|
19
|
+
var notifyServer = function notifyServer(param) {
|
|
20
|
+
var search = param.search;
|
|
21
|
+
if (hasBeenNotified) {
|
|
22
|
+
throw new Error('getServerState should be called with a single InstantSearchSSRProvider and a single InstantSearch component.');
|
|
23
|
+
}
|
|
24
|
+
hasBeenNotified = true;
|
|
25
|
+
searchRef.current = search;
|
|
26
|
+
};
|
|
27
|
+
return notifyServer;
|
|
28
|
+
};
|
|
29
|
+
return execute({
|
|
30
|
+
children: children,
|
|
53
31
|
renderToString: renderToString,
|
|
54
32
|
searchRef: searchRef,
|
|
55
|
-
notifyServer: createNotifyServer()
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
33
|
+
notifyServer: createNotifyServer()
|
|
34
|
+
}).then(function(serverState) {
|
|
35
|
+
var shouldRefetch = false;
|
|
36
|
+
// <DynamicWidgets> requires another query to retrieve the dynamic widgets
|
|
37
|
+
// to render.
|
|
38
|
+
utils.walkIndex(searchRef.current.mainIndex, function(index) {
|
|
39
|
+
shouldRefetch = shouldRefetch || index.getWidgets().some(function(widget) {
|
|
40
|
+
return widget.$$type === 'ais.dynamicWidgets';
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
if (shouldRefetch) {
|
|
44
|
+
utils.resetWidgetId();
|
|
45
|
+
return execute({
|
|
46
|
+
children: /*#__PURE__*/ React.createElement(InstantSearchSSRProvider.InstantSearchSSRProvider, serverState, children),
|
|
47
|
+
renderToString: renderToString,
|
|
48
|
+
searchRef: searchRef,
|
|
49
|
+
notifyServer: createNotifyServer(),
|
|
50
|
+
skipRecommend: true
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return serverState;
|
|
54
|
+
});
|
|
61
55
|
}
|
|
62
|
-
function execute(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
notifyServer
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
initialResults: (0, _server.getInitialResults)(searchRef.current.mainIndex, requestParamsList)
|
|
96
|
-
};
|
|
97
|
-
});
|
|
98
|
-
}
|
|
56
|
+
function execute(param) {
|
|
57
|
+
var children = param.children, renderToString = param.renderToString, notifyServer = param.notifyServer, searchRef = param.searchRef, skipRecommend = param.skipRecommend;
|
|
58
|
+
return Promise.resolve().then(function() {
|
|
59
|
+
renderToString(/*#__PURE__*/ React.createElement(InstantSearchServerContext.InstantSearchServerContext.Provider, {
|
|
60
|
+
value: {
|
|
61
|
+
notifyServer: notifyServer
|
|
62
|
+
}
|
|
63
|
+
}, children));
|
|
64
|
+
}).then(function() {
|
|
65
|
+
return(// We wait for the component to mount so that `notifyServer()` is called.
|
|
66
|
+
new Promise(function(resolve) {
|
|
67
|
+
return setTimeout(resolve, 0);
|
|
68
|
+
}));
|
|
69
|
+
}).then(function() {
|
|
70
|
+
// If `notifyServer()` is not called by then, it means that <InstantSearch>
|
|
71
|
+
// wasn't within the `children`.
|
|
72
|
+
// We decide to go with a strict behavior in that case; throwing. If users have
|
|
73
|
+
// some routes that don't mount the <InstantSearch> component, they would need
|
|
74
|
+
// to try/catch the `getServerState()` call.
|
|
75
|
+
// If this behavior turns out to be too strict for many users, we can decide
|
|
76
|
+
// to warn instead of throwing.
|
|
77
|
+
if (!searchRef.current) {
|
|
78
|
+
throw new Error("Unable to retrieve InstantSearch's server state in `getServerState()`. Did you mount the <InstantSearch> component?");
|
|
79
|
+
}
|
|
80
|
+
return server.waitForResults(searchRef.current, skipRecommend);
|
|
81
|
+
}).then(function(requestParamsList) {
|
|
82
|
+
return {
|
|
83
|
+
initialResults: server.getInitialResults(searchRef.current.mainIndex, requestParamsList)
|
|
84
|
+
};
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
exports.getServerState = getServerState;
|
package/dist/cjs/server/index.js
CHANGED
|
@@ -1,16 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] === _getServerState[key]) return;
|
|
10
|
-
Object.defineProperty(exports, key, {
|
|
11
|
-
enumerable: true,
|
|
12
|
-
get: function get() {
|
|
13
|
-
return _getServerState[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
3
|
+
var getServerState = require('./getServerState.js');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
exports.getServerState = getServerState.getServerState;
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var version = '7.26.0';
|
|
6
|
+
|
|
7
|
+
exports.default = version;
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
function
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
1
|
+
import { _ } from '@swc/helpers/cjs/_object_spread.cjs';
|
|
2
|
+
import { useConfigure } from '../connectors/useConfigure.js';
|
|
3
|
+
|
|
4
|
+
function Configure(props) {
|
|
5
|
+
useConfigure(_({}, props), {
|
|
6
|
+
$$widgetType: 'ais.configure'
|
|
7
|
+
});
|
|
8
|
+
return null;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export { Configure };
|
|
@@ -1,55 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
import { invariant } from "../lib/invariant.js";
|
|
8
|
-
import { warn } from "../lib/warn.js";
|
|
1
|
+
import { _ } from '@swc/helpers/cjs/_object_without_properties.cjs';
|
|
2
|
+
import { _ as _$1 } from '@swc/helpers/cjs/_type_of.cjs';
|
|
3
|
+
import React__default, { Fragment } from 'react';
|
|
4
|
+
import { useDynamicWidgets } from '../connectors/useDynamicWidgets.js';
|
|
5
|
+
import { invariant } from '../lib/invariant.js';
|
|
6
|
+
|
|
9
7
|
function DefaultFallbackComponent() {
|
|
10
|
-
|
|
8
|
+
return null;
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
attribute: attribute
|
|
10
|
+
function DynamicWidgets(_0) {
|
|
11
|
+
var children = _0.children, tmp = _0.fallbackComponent, Fallback = tmp === void 0 ? DefaultFallbackComponent : tmp, props = _(_0, [
|
|
12
|
+
"children",
|
|
13
|
+
"fallbackComponent"
|
|
14
|
+
]);
|
|
15
|
+
var FallbackComponent = React__default.useRef(Fallback);
|
|
16
|
+
var attributesToRender = useDynamicWidgets(props, {
|
|
17
|
+
$$widgetType: 'ais.dynamicWidgets'
|
|
18
|
+
}).attributesToRender;
|
|
19
|
+
var widgets = new Map();
|
|
20
|
+
React__default.Children.forEach(children, function(child) {
|
|
21
|
+
var attribute = getWidgetAttribute(child);
|
|
22
|
+
invariant(attribute !== undefined);
|
|
23
|
+
widgets.set(attribute, child);
|
|
24
|
+
});
|
|
25
|
+
return /*#__PURE__*/ React__default.createElement(React__default.Fragment, null, attributesToRender.map(function(attribute) {
|
|
26
|
+
return /*#__PURE__*/ React__default.createElement(Fragment, {
|
|
27
|
+
key: attribute
|
|
28
|
+
}, widgets.get(attribute) || /*#__PURE__*/ React__default.createElement(FallbackComponent.current, {
|
|
29
|
+
attribute: attribute
|
|
30
|
+
}));
|
|
34
31
|
}));
|
|
35
|
-
}));
|
|
36
32
|
}
|
|
37
33
|
function isReactElement(element) {
|
|
38
|
-
|
|
34
|
+
return (typeof element === "undefined" ? "undefined" : _$1(element)) === 'object' && element.props;
|
|
39
35
|
}
|
|
40
36
|
function getWidgetAttribute(element) {
|
|
41
|
-
|
|
37
|
+
if (!isReactElement(element)) {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
if (element.props.attribute) {
|
|
41
|
+
return element.props.attribute;
|
|
42
|
+
}
|
|
43
|
+
if (Array.isArray(element.props.attributes)) {
|
|
44
|
+
return element.props.attributes[0];
|
|
45
|
+
}
|
|
46
|
+
if (element.props.children) {
|
|
47
|
+
invariant(React__default.Children.count(element.props.children) === 1);
|
|
48
|
+
return getWidgetAttribute(React__default.Children.only(element.props.children));
|
|
49
|
+
}
|
|
42
50
|
return undefined;
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
if (Array.isArray(element.props.attributes)) {
|
|
48
|
-
return element.props.attributes[0];
|
|
49
|
-
}
|
|
50
|
-
if (element.props.children) {
|
|
51
|
-
invariant(React.Children.count(element.props.children) === 1, "<DynamicWidgets> only supports a single component in nested components. Make sure to not render multiple children in a parent component.\n\nExample of an unsupported scenario:\n\n```\n<DynamicWidgets>\n <MyComponent>\n <RefinementList attribute=\"brand\" />\n <Menu attribute=\"categories\" />\n </MyComponent>\n</DynamicWidgets>\n```\n");
|
|
52
|
-
return getWidgetAttribute(React.Children.only(element.props.children));
|
|
53
|
-
}
|
|
54
|
-
return undefined;
|
|
55
|
-
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { DynamicWidgets };
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
1
|
+
import { _ } from '@swc/helpers/cjs/_object_without_properties.cjs';
|
|
2
|
+
import React__default from 'react';
|
|
3
|
+
import { IndexContext } from '../lib/IndexContext.js';
|
|
4
|
+
import { useIndex } from '../lib/useIndex.js';
|
|
5
|
+
|
|
6
|
+
function Index(_0) {
|
|
7
|
+
var children = _0.children, props = _(_0, [
|
|
8
|
+
"children"
|
|
9
|
+
]);
|
|
10
|
+
var index = useIndex(props);
|
|
11
|
+
if (index.getHelper() === null) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
return /*#__PURE__*/ React__default.createElement(IndexContext.Provider, {
|
|
15
|
+
value: index
|
|
16
|
+
}, children);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export { Index };
|
|
@@ -1,31 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import { _ } from '@swc/helpers/cjs/_object_without_properties.cjs';
|
|
2
|
+
import React__default, { useEffect } from 'react';
|
|
3
|
+
import { IndexContext } from '../lib/IndexContext.js';
|
|
4
|
+
import { InstantSearchContext } from '../lib/InstantSearchContext.js';
|
|
5
|
+
import { useInstantSearchApi } from '../lib/useInstantSearchApi.js';
|
|
6
|
+
|
|
7
|
+
function InstantSearch(_0) {
|
|
8
|
+
var children = _0.children, props = _(_0, [
|
|
9
|
+
"children"
|
|
10
|
+
]);
|
|
11
|
+
var search = useInstantSearchApi(props);
|
|
12
|
+
if (!search.started) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return /*#__PURE__*/ React__default.createElement(InstantSearchContext.Provider, {
|
|
16
|
+
value: search
|
|
17
|
+
}, /*#__PURE__*/ React__default.createElement(IndexContext.Provider, {
|
|
18
|
+
value: search.mainIndex
|
|
19
|
+
}, children, /*#__PURE__*/ React__default.createElement(ResetScheduleSearch, {
|
|
20
|
+
search: search
|
|
21
|
+
})));
|
|
22
|
+
}
|
|
23
|
+
function ResetScheduleSearch(param) {
|
|
24
|
+
var search = param.search;
|
|
25
|
+
useEffect(function() {
|
|
26
|
+
if (search._resetScheduleSearch) {
|
|
27
|
+
search._resetScheduleSearch();
|
|
28
|
+
}
|
|
29
|
+
}, [
|
|
30
|
+
search
|
|
31
|
+
]);
|
|
13
32
|
return null;
|
|
14
|
-
}
|
|
15
|
-
return /*#__PURE__*/React.createElement(InstantSearchContext.Provider, {
|
|
16
|
-
value: search
|
|
17
|
-
}, /*#__PURE__*/React.createElement(IndexContext.Provider, {
|
|
18
|
-
value: search.mainIndex
|
|
19
|
-
}, children, /*#__PURE__*/React.createElement(ResetScheduleSearch, {
|
|
20
|
-
search: search
|
|
21
|
-
})));
|
|
22
33
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
useEffect(function () {
|
|
26
|
-
if (search._resetScheduleSearch) {
|
|
27
|
-
search._resetScheduleSearch();
|
|
28
|
-
}
|
|
29
|
-
}, [search]);
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
34
|
+
|
|
35
|
+
export { InstantSearch };
|
|
@@ -1,39 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
-
function _objectWithoutProperties(e, t) { if (null == e) return {}; var o, r, i = _objectWithoutPropertiesLoose(e, t); if (Object.getOwnPropertySymbols) { var n = Object.getOwnPropertySymbols(e); for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]); } return i; }
|
|
9
|
-
function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; }
|
|
10
|
-
import React from 'react';
|
|
11
|
-
import { InstantSearchSSRContext } from "../lib/InstantSearchSSRContext.js";
|
|
1
|
+
import { _ as _$2 } from '@swc/helpers/cjs/_object_spread.cjs';
|
|
2
|
+
import { _ as _$1 } from '@swc/helpers/cjs/_object_spread_props.cjs';
|
|
3
|
+
import { _ } from '@swc/helpers/cjs/_object_without_properties.cjs';
|
|
4
|
+
import React__default from 'react';
|
|
5
|
+
import { InstantSearchSSRContext } from '../lib/InstantSearchSSRContext.js';
|
|
6
|
+
|
|
12
7
|
/**
|
|
13
8
|
* Provider to pass the server state retrieved from `getServerState()` to
|
|
14
9
|
* <InstantSearch>.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
10
|
+
*/ function InstantSearchSSRProvider(_0) {
|
|
11
|
+
var children = _0.children, props = _(_0, [
|
|
12
|
+
"children"
|
|
13
|
+
]);
|
|
14
|
+
// This is used in `useInstantSearchApi()` to avoid creating and starting multiple instances of
|
|
15
|
+
// `InstantSearch` on mount.
|
|
16
|
+
var ssrSearchRef = React__default.useRef(null);
|
|
17
|
+
// This is used to re-map the result index to the requesting widget
|
|
18
|
+
var recommendIdx = React__default.useRef(0);
|
|
19
|
+
// When <DynamicWidgets> is mounted, a second provider is used above the user-land
|
|
20
|
+
// <InstantSearchSSRProvider> in `getServerState()`.
|
|
21
|
+
// To avoid the user's provider overriding the context value with an empty object,
|
|
22
|
+
// we skip this provider.
|
|
23
|
+
if (Object.keys(props).length === 0) {
|
|
24
|
+
return /*#__PURE__*/ React__default.createElement(React__default.Fragment, null, children);
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/ React__default.createElement(InstantSearchSSRContext.Provider, {
|
|
27
|
+
value: _$1(_$2({}, props), {
|
|
28
|
+
ssrSearchRef: ssrSearchRef,
|
|
29
|
+
recommendIdx: recommendIdx
|
|
30
|
+
})
|
|
31
|
+
}, children);
|
|
32
|
+
}
|
|
25
33
|
|
|
26
|
-
|
|
27
|
-
// <InstantSearchSSRProvider> in `getServerState()`.
|
|
28
|
-
// To avoid the user's provider overriding the context value with an empty object,
|
|
29
|
-
// we skip this provider.
|
|
30
|
-
if (Object.keys(props).length === 0) {
|
|
31
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, children);
|
|
32
|
-
}
|
|
33
|
-
return /*#__PURE__*/React.createElement(InstantSearchSSRContext.Provider, {
|
|
34
|
-
value: _objectSpread(_objectSpread({}, props), {}, {
|
|
35
|
-
ssrSearchRef: ssrSearchRef,
|
|
36
|
-
recommendIdx: recommendIdx
|
|
37
|
-
})
|
|
38
|
-
}, children);
|
|
39
|
-
}
|
|
34
|
+
export { InstantSearchSSRProvider };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
2
|
+
|
|
3
|
+
var InstantSearchServerContext = createContext(null);
|
|
4
|
+
|
|
5
|
+
export { InstantSearchServerContext };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import connectAutocomplete from
|
|
2
|
-
import { useConnector } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import connectAutocomplete from 'instantsearch.js/es/connectors/autocomplete/connectAutocomplete.js';
|
|
2
|
+
import { useConnector } from '../hooks/useConnector.js';
|
|
3
|
+
|
|
4
|
+
function useAutocomplete(props, additionalWidgetProperties) {
|
|
5
|
+
return useConnector(connectAutocomplete, props, additionalWidgetProperties);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { useAutocomplete };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import connectBreadcrumb from
|
|
2
|
-
import { useConnector } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import connectBreadcrumb from 'instantsearch.js/es/connectors/breadcrumb/connectBreadcrumb.js';
|
|
2
|
+
import { useConnector } from '../hooks/useConnector.js';
|
|
3
|
+
|
|
4
|
+
function useBreadcrumb(props, additionalWidgetProperties) {
|
|
5
|
+
return useConnector(connectBreadcrumb, props, additionalWidgetProperties);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { useBreadcrumb };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import connectChat from
|
|
2
|
-
import { useConnector } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import connectChat from 'instantsearch.js/es/connectors/chat/connectChat.js';
|
|
2
|
+
import { useConnector } from '../hooks/useConnector.js';
|
|
3
|
+
|
|
4
|
+
function useChat(props, additionalWidgetProperties) {
|
|
5
|
+
return useConnector(connectChat, props, additionalWidgetProperties);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { useChat };
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import connectClearRefinements from
|
|
2
|
-
import { useConnector } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import connectClearRefinements from 'instantsearch.js/es/connectors/clear-refinements/connectClearRefinements.js';
|
|
2
|
+
import { useConnector } from '../hooks/useConnector.js';
|
|
3
|
+
|
|
4
|
+
function useClearRefinements(props, additionalWidgetProperties) {
|
|
5
|
+
return useConnector(connectClearRefinements, props, additionalWidgetProperties);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export { useClearRefinements };
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
-
import connectConfigure from
|
|
2
|
-
import { useConnector } from
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
1
|
+
import connectConfigure from 'instantsearch.js/es/connectors/configure/connectConfigure.js';
|
|
2
|
+
import { useConnector } from '../hooks/useConnector.js';
|
|
3
|
+
|
|
4
|
+
function useConfigure(props, additionalWidgetProperties) {
|
|
5
|
+
return useConnector(connectConfigure, {
|
|
6
|
+
searchParameters: props
|
|
7
|
+
}, additionalWidgetProperties);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export { useConfigure };
|