react-instantsearch 7.39.1 → 7.40.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.
|
@@ -215,14 +215,15 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
215
215
|
var indices = 'indices' in props ? props.indices : undefined;
|
|
216
216
|
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
217
217
|
var isFeedsMode = feeds !== undefined;
|
|
218
|
-
var showQuerySuggestions = props.showQuerySuggestions, showPromptSuggestions = props.showPromptSuggestions, showRecent = props.showRecent, userSearchParameters = props.searchParameters, detachedMediaQuery = props.detachedMediaQuery, tmp = props.translations, userTranslations = tmp === void 0 ? {} : tmp, transformItems = props.transformItems, restProps = _object_without_properties._(props, [
|
|
218
|
+
var showQuerySuggestions = props.showQuerySuggestions, showPromptSuggestions = props.showPromptSuggestions, showRecent = props.showRecent, userSearchParameters = props.searchParameters, detachedMediaQuery = props.detachedMediaQuery, tmp = props.translations, userTranslations = tmp === void 0 ? {} : tmp, transformItems = props.transformItems, _props_requiresSearch = props.requiresSearch, requiresSearch = _props_requiresSearch === void 0 ? true : _props_requiresSearch, restProps = _object_without_properties._(props, [
|
|
219
219
|
"showQuerySuggestions",
|
|
220
220
|
"showPromptSuggestions",
|
|
221
221
|
"showRecent",
|
|
222
222
|
"searchParameters",
|
|
223
223
|
"detachedMediaQuery",
|
|
224
224
|
"translations",
|
|
225
|
-
"transformItems"
|
|
225
|
+
"transformItems",
|
|
226
|
+
"requiresSearch"
|
|
226
227
|
]);
|
|
227
228
|
var autoFocus = restProps.autoFocus, placeholder = restProps.placeholder, classNames = restProps.classNames;
|
|
228
229
|
// Eager-mount only when `autoFocus` is set — otherwise wait for first focus
|
|
@@ -231,9 +232,11 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
231
232
|
var translations = _object_spread._({}, DEFAULT_TRANSLATIONS, userTranslations);
|
|
232
233
|
var _useInstantSearch = (0, _reactinstantsearchcore.useInstantSearch)(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
|
|
233
234
|
var compositionID = (0, _reactinstantsearchcore.useInstantSearchContext)().compositionID;
|
|
235
|
+
var dependsOn = requiresSearch ? 'search' : 'none';
|
|
234
236
|
var refine = (0, _reactinstantsearchcore.useSearchBox)({}, _object_spread._({
|
|
235
237
|
$$type: 'ais.autocomplete',
|
|
236
|
-
$$widgetType: 'ais.autocomplete'
|
|
238
|
+
$$widgetType: 'ais.autocomplete',
|
|
239
|
+
dependsOn: dependsOn
|
|
237
240
|
}, props.aiMode ? {
|
|
238
241
|
opensChat: true
|
|
239
242
|
} : {})).refine;
|
|
@@ -92,6 +92,13 @@ type AutocompleteCommonProps<TItem extends BaseHit> = ComponentProps<'div'> & {
|
|
|
92
92
|
getSearchPageURL?: (nextUiState: IndexUiState) => string;
|
|
93
93
|
onSelect?: AutocompleteIndexConfig<TItem>['onSelect'];
|
|
94
94
|
transformItems?: (indices: TransformItemsIndicesConfig[]) => TransformItemsIndicesConfig[];
|
|
95
|
+
/**
|
|
96
|
+
* Whether this widget should make InstantSearch require a main search request.
|
|
97
|
+
* If this is the only widget, and you mark `requiresSearch: false`, no search request will happen.
|
|
98
|
+
*
|
|
99
|
+
* @default true
|
|
100
|
+
*/
|
|
101
|
+
requiresSearch?: boolean;
|
|
95
102
|
panelComponent?: (props: {
|
|
96
103
|
elements: PanelElements;
|
|
97
104
|
indices: ReturnType<typeof useAutocomplete>['indices'];
|
|
@@ -204,14 +204,15 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
204
204
|
var indices = 'indices' in props ? props.indices : undefined;
|
|
205
205
|
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
206
206
|
var isFeedsMode = feeds !== undefined;
|
|
207
|
-
var showQuerySuggestions = props.showQuerySuggestions, showPromptSuggestions = props.showPromptSuggestions, showRecent = props.showRecent, userSearchParameters = props.searchParameters, detachedMediaQuery = props.detachedMediaQuery, tmp = props.translations, userTranslations = tmp === void 0 ? {} : tmp, transformItems = props.transformItems, restProps = _(props, [
|
|
207
|
+
var showQuerySuggestions = props.showQuerySuggestions, showPromptSuggestions = props.showPromptSuggestions, showRecent = props.showRecent, userSearchParameters = props.searchParameters, detachedMediaQuery = props.detachedMediaQuery, tmp = props.translations, userTranslations = tmp === void 0 ? {} : tmp, transformItems = props.transformItems, _props_requiresSearch = props.requiresSearch, requiresSearch = _props_requiresSearch === void 0 ? true : _props_requiresSearch, restProps = _(props, [
|
|
208
208
|
"showQuerySuggestions",
|
|
209
209
|
"showPromptSuggestions",
|
|
210
210
|
"showRecent",
|
|
211
211
|
"searchParameters",
|
|
212
212
|
"detachedMediaQuery",
|
|
213
213
|
"translations",
|
|
214
|
-
"transformItems"
|
|
214
|
+
"transformItems",
|
|
215
|
+
"requiresSearch"
|
|
215
216
|
]);
|
|
216
217
|
var autoFocus = restProps.autoFocus, placeholder = restProps.placeholder, classNames = restProps.classNames;
|
|
217
218
|
// Eager-mount only when `autoFocus` is set — otherwise wait for first focus
|
|
@@ -220,9 +221,11 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
220
221
|
var translations = _$2({}, DEFAULT_TRANSLATIONS, userTranslations);
|
|
221
222
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
|
|
222
223
|
var compositionID = useInstantSearchContext().compositionID;
|
|
224
|
+
var dependsOn = requiresSearch ? 'search' : 'none';
|
|
223
225
|
var refine = useSearchBox({}, _$2({
|
|
224
226
|
$$type: 'ais.autocomplete',
|
|
225
|
-
$$widgetType: 'ais.autocomplete'
|
|
227
|
+
$$widgetType: 'ais.autocomplete',
|
|
228
|
+
dependsOn: dependsOn
|
|
226
229
|
}, props.aiMode ? {
|
|
227
230
|
opensChat: true
|
|
228
231
|
} : {})).refine;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearch 7.
|
|
1
|
+
/*! React InstantSearch 7.40.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['exports', 'react'], factory) :
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
|
|
26
26
|
|
|
27
|
-
var version$2 = '7.
|
|
27
|
+
var version$2 = '7.40.0';
|
|
28
28
|
|
|
29
29
|
function _define_property(obj, key, value) {
|
|
30
30
|
if (key in obj) {
|
|
@@ -7520,6 +7520,9 @@
|
|
|
7520
7520
|
current: 0
|
|
7521
7521
|
},
|
|
7522
7522
|
waitForResultsRef: null,
|
|
7523
|
+
resolveWaitForResultsRef: {
|
|
7524
|
+
current: null
|
|
7525
|
+
},
|
|
7523
7526
|
ignoreMultipleHooksWarning: false
|
|
7524
7527
|
});
|
|
7525
7528
|
|
|
@@ -7731,7 +7734,10 @@
|
|
|
7731
7734
|
useWidget({
|
|
7732
7735
|
widget: widget,
|
|
7733
7736
|
parentIndex: parentIndex,
|
|
7734
|
-
props:
|
|
7737
|
+
props: [
|
|
7738
|
+
stableProps,
|
|
7739
|
+
stableAdditionalWidgetProperties
|
|
7740
|
+
],
|
|
7735
7741
|
shouldSsr: Boolean(serverContext),
|
|
7736
7742
|
skipSuspense: skipSuspense
|
|
7737
7743
|
});
|
|
@@ -8467,6 +8473,39 @@
|
|
|
8467
8473
|
].concat(_to_consumable_array(resolveScopedResultsFromWidgets(current.getWidgets()))));
|
|
8468
8474
|
}, []);
|
|
8469
8475
|
}
|
|
8476
|
+
function getWidgetsRequestDependencies(widgets) {
|
|
8477
|
+
return widgets.reduce(function(dependencies, widget) {
|
|
8478
|
+
if (isIndexWidget(widget)) {
|
|
8479
|
+
if (widget._isolated) {
|
|
8480
|
+
return dependencies;
|
|
8481
|
+
}
|
|
8482
|
+
var childDependencies = getWidgetsRequestDependencies(widget.getWidgets());
|
|
8483
|
+
return {
|
|
8484
|
+
hasSearchWidget: dependencies.hasSearchWidget || childDependencies.hasSearchWidget,
|
|
8485
|
+
hasRecommendWidget: dependencies.hasRecommendWidget || childDependencies.hasRecommendWidget
|
|
8486
|
+
};
|
|
8487
|
+
}
|
|
8488
|
+
if (widget.dependsOn === 'recommend') {
|
|
8489
|
+
return _object_spread_props(_object_spread({}, dependencies), {
|
|
8490
|
+
hasRecommendWidget: true
|
|
8491
|
+
});
|
|
8492
|
+
}
|
|
8493
|
+
if (widget.dependsOn === 'none') {
|
|
8494
|
+
return dependencies;
|
|
8495
|
+
}
|
|
8496
|
+
return _object_spread_props(_object_spread({}, dependencies), {
|
|
8497
|
+
hasSearchWidget: true
|
|
8498
|
+
});
|
|
8499
|
+
}, {
|
|
8500
|
+
hasSearchWidget: false,
|
|
8501
|
+
hasRecommendWidget: false
|
|
8502
|
+
});
|
|
8503
|
+
}
|
|
8504
|
+
function recomputeInstantSearchRequestDependencies(instantSearchInstance) {
|
|
8505
|
+
var _getWidgetsRequestDependencies = getWidgetsRequestDependencies(instantSearchInstance.mainIndex.getWidgets()), hasSearchWidget = _getWidgetsRequestDependencies.hasSearchWidget, hasRecommendWidget = _getWidgetsRequestDependencies.hasRecommendWidget;
|
|
8506
|
+
instantSearchInstance._hasSearchWidget = hasSearchWidget;
|
|
8507
|
+
instantSearchInstance._hasRecommendWidget = hasRecommendWidget;
|
|
8508
|
+
}
|
|
8470
8509
|
var index = function index(widgetParams) {
|
|
8471
8510
|
if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.EXPERIMENTAL_isolated) {
|
|
8472
8511
|
throw new Error(withUsage$s('The `indexName` option is required.'));
|
|
@@ -8481,8 +8520,11 @@
|
|
|
8481
8520
|
var helper = null;
|
|
8482
8521
|
var derivedHelper = null;
|
|
8483
8522
|
var lastValidSearchParameters = null;
|
|
8484
|
-
var
|
|
8485
|
-
|
|
8523
|
+
var recomputeLocalRequestDependencies = function recomputeLocalRequestDependencies() {
|
|
8524
|
+
if (localInstantSearchInstance) {
|
|
8525
|
+
recomputeInstantSearchRequestDependencies(localInstantSearchInstance);
|
|
8526
|
+
}
|
|
8527
|
+
};
|
|
8486
8528
|
return {
|
|
8487
8529
|
$$type: 'ais.index',
|
|
8488
8530
|
$$widgetType: 'ais.index',
|
|
@@ -8573,21 +8615,12 @@
|
|
|
8573
8615
|
}
|
|
8574
8616
|
flatWidgets.forEach(function(widget) {
|
|
8575
8617
|
widget.parent = _this;
|
|
8576
|
-
if (isIndexWidget(widget)) {
|
|
8577
|
-
|
|
8578
|
-
}
|
|
8579
|
-
if (localInstantSearchInstance && widget.dependsOn === 'recommend') {
|
|
8580
|
-
localInstantSearchInstance._hasRecommendWidget = true;
|
|
8581
|
-
} else if (localInstantSearchInstance) {
|
|
8582
|
-
localInstantSearchInstance._hasSearchWidget = true;
|
|
8583
|
-
} else if (widget.dependsOn === 'recommend') {
|
|
8584
|
-
hasRecommendWidget = true;
|
|
8585
|
-
} else {
|
|
8586
|
-
hasSearchWidget = true;
|
|
8618
|
+
if (!isIndexWidget(widget)) {
|
|
8619
|
+
addWidgetId(widget);
|
|
8587
8620
|
}
|
|
8588
|
-
addWidgetId(widget);
|
|
8589
8621
|
});
|
|
8590
8622
|
localWidgets = localWidgets.concat(flatWidgets);
|
|
8623
|
+
recomputeLocalRequestDependencies();
|
|
8591
8624
|
if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
|
|
8592
8625
|
privateHelperSetState(helper, {
|
|
8593
8626
|
state: getLocalWidgetsSearchParameters(localWidgets, {
|
|
@@ -8644,21 +8677,10 @@
|
|
|
8644
8677
|
localWidgets = localWidgets.filter(function(widget) {
|
|
8645
8678
|
return flatWidgets.indexOf(widget) === -1;
|
|
8646
8679
|
});
|
|
8647
|
-
|
|
8680
|
+
flatWidgets.forEach(function(widget) {
|
|
8648
8681
|
widget.parent = undefined;
|
|
8649
|
-
if (isIndexWidget(widget)) {
|
|
8650
|
-
return;
|
|
8651
|
-
}
|
|
8652
|
-
if (localInstantSearchInstance && widget.dependsOn === 'recommend') {
|
|
8653
|
-
localInstantSearchInstance._hasRecommendWidget = true;
|
|
8654
|
-
} else if (localInstantSearchInstance) {
|
|
8655
|
-
localInstantSearchInstance._hasSearchWidget = true;
|
|
8656
|
-
} else if (widget.dependsOn === 'recommend') {
|
|
8657
|
-
hasRecommendWidget = true;
|
|
8658
|
-
} else {
|
|
8659
|
-
hasSearchWidget = true;
|
|
8660
|
-
}
|
|
8661
8682
|
});
|
|
8683
|
+
recomputeLocalRequestDependencies();
|
|
8662
8684
|
if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
|
|
8663
8685
|
var _flatWidgets_reduce = flatWidgets.reduce(function(states, widget) {
|
|
8664
8686
|
// the `dispose` method exists at this point we already assert it
|
|
@@ -8881,12 +8903,7 @@
|
|
|
8881
8903
|
// schedule a render that will render the results injected on the helper.
|
|
8882
8904
|
instantSearchInstance.scheduleRender();
|
|
8883
8905
|
}
|
|
8884
|
-
|
|
8885
|
-
instantSearchInstance._hasRecommendWidget = true;
|
|
8886
|
-
}
|
|
8887
|
-
if (hasSearchWidget) {
|
|
8888
|
-
instantSearchInstance._hasSearchWidget = true;
|
|
8889
|
-
}
|
|
8906
|
+
recomputeLocalRequestDependencies();
|
|
8890
8907
|
},
|
|
8891
8908
|
render: function render(param) {
|
|
8892
8909
|
var _this = this;
|
|
@@ -9160,7 +9177,7 @@
|
|
|
9160
9177
|
});
|
|
9161
9178
|
}
|
|
9162
9179
|
|
|
9163
|
-
var version = '4.
|
|
9180
|
+
var version = '4.107.0';
|
|
9164
9181
|
|
|
9165
9182
|
var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
|
|
9166
9183
|
function getCookie(name) {
|
|
@@ -11301,8 +11318,11 @@
|
|
|
11301
11318
|
mainHelper.searchForFacetValues = mainHelper.searchForCompositionFacetValues.bind(mainHelper);
|
|
11302
11319
|
}
|
|
11303
11320
|
mainHelper.search = function() {
|
|
11304
|
-
_this.
|
|
11305
|
-
|
|
11321
|
+
var hasSearchOrRecommendWidget = _this._hasSearchWidget || _this._hasRecommendWidget;
|
|
11322
|
+
if (hasSearchOrRecommendWidget) {
|
|
11323
|
+
_this.status = 'loading';
|
|
11324
|
+
}
|
|
11325
|
+
_this.scheduleRender(!hasSearchOrRecommendWidget);
|
|
11306
11326
|
// This solution allows us to keep the exact same API for the users but
|
|
11307
11327
|
// under the hood, we have a different implementation. It should be
|
|
11308
11328
|
// completely transparent for the rest of the codebase. Only this module
|
|
@@ -11366,7 +11386,7 @@
|
|
|
11366
11386
|
error.error = error;
|
|
11367
11387
|
_this.error = error;
|
|
11368
11388
|
_this.status = 'error';
|
|
11369
|
-
_this.scheduleRender(
|
|
11389
|
+
_this.scheduleRender(!_this._hasSearchWidget && !_this._hasRecommendWidget);
|
|
11370
11390
|
// This needs to execute last because it throws the error.
|
|
11371
11391
|
_this.emit('error', error);
|
|
11372
11392
|
});
|
|
@@ -12055,10 +12075,14 @@
|
|
|
12055
12075
|
return function(widgetParams) {
|
|
12056
12076
|
var _ref = widgetParams || {}, _ref_escapeHTML = _ref.escapeHTML, escapeHTML = _ref_escapeHTML === void 0 ? true : _ref_escapeHTML, _ref_transformItems = _ref.transformItems, transformItems = _ref_transformItems === void 0 ? function(indices) {
|
|
12057
12077
|
return indices;
|
|
12058
|
-
} : _ref_transformItems, tmp = _ref.future, _ref1 = tmp === void 0 ? {} : tmp, _ref_undefinedEmptyQuery = _ref1.undefinedEmptyQuery, undefinedEmptyQuery = _ref_undefinedEmptyQuery === void 0 ? false : _ref_undefinedEmptyQuery;
|
|
12078
|
+
} : _ref_transformItems, _ref_requiresSearch = _ref.requiresSearch, requiresSearch = _ref_requiresSearch === void 0 ? true : _ref_requiresSearch, tmp = _ref.future, _ref1 = tmp === void 0 ? {} : tmp, _ref_undefinedEmptyQuery = _ref1.undefinedEmptyQuery, undefinedEmptyQuery = _ref_undefinedEmptyQuery === void 0 ? false : _ref_undefinedEmptyQuery;
|
|
12059
12079
|
var connectorState = {};
|
|
12060
12080
|
return {
|
|
12061
12081
|
$$type: 'ais.autocomplete',
|
|
12082
|
+
dependsOn: requiresSearch ? 'search' : 'none',
|
|
12083
|
+
shouldRender: requiresSearch ? undefined : function() {
|
|
12084
|
+
return true;
|
|
12085
|
+
},
|
|
12062
12086
|
init: function init(initOptions) {
|
|
12063
12087
|
var instantSearchInstance = initOptions.instantSearchInstance;
|
|
12064
12088
|
renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
|
|
@@ -14097,14 +14121,16 @@
|
|
|
14097
14121
|
var unmountFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : noop;
|
|
14098
14122
|
checkRendering(renderFn, withUsage$o());
|
|
14099
14123
|
return function(widgetParams) {
|
|
14100
|
-
var _ref = widgetParams || {}, _ref_resume = _ref.resume, resume = _ref_resume === void 0 ? false : _ref_resume, _ref_tools = _ref.tools, tools = _ref_tools === void 0 ? {} : _ref_tools, _ref_type = _ref.type, type = _ref_type === void 0 ? 'chat' : _ref_type, context = _ref.context, initialUserMessage = _ref.initialUserMessage, initialMessages = _ref.initialMessages, _ref_disableTriggerValidation = _ref.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, options = _object_without_properties(_ref, [
|
|
14124
|
+
var _ref = widgetParams || {}, _ref_resume = _ref.resume, resume = _ref_resume === void 0 ? false : _ref_resume, _ref_tools = _ref.tools, tools = _ref_tools === void 0 ? {} : _ref_tools, _ref_type = _ref.type, type = _ref_type === void 0 ? 'chat' : _ref_type, context = _ref.context, initialUserMessage = _ref.initialUserMessage, initialMessages = _ref.initialMessages, _ref_disableTriggerValidation = _ref.disableTriggerValidation, disableTriggerValidation = _ref_disableTriggerValidation === void 0 ? false : _ref_disableTriggerValidation, _ref_sendAutomaticallyWhen = _ref.sendAutomaticallyWhen, sendAutomaticallyWhen = _ref_sendAutomaticallyWhen === void 0 ? lastAssistantMessageIsCompleteWithToolCalls : _ref_sendAutomaticallyWhen, _ref_requiresSearch = _ref.requiresSearch, requiresSearch = _ref_requiresSearch === void 0 ? true : _ref_requiresSearch, options = _object_without_properties(_ref, [
|
|
14101
14125
|
"resume",
|
|
14102
14126
|
"tools",
|
|
14103
14127
|
"type",
|
|
14104
14128
|
"context",
|
|
14105
14129
|
"initialUserMessage",
|
|
14106
14130
|
"initialMessages",
|
|
14107
|
-
"disableTriggerValidation"
|
|
14131
|
+
"disableTriggerValidation",
|
|
14132
|
+
"sendAutomaticallyWhen",
|
|
14133
|
+
"requiresSearch"
|
|
14108
14134
|
]);
|
|
14109
14135
|
var _chatInstance;
|
|
14110
14136
|
var input = '';
|
|
@@ -14265,8 +14291,8 @@
|
|
|
14265
14291
|
return options.chat;
|
|
14266
14292
|
}
|
|
14267
14293
|
return new Chat$1(_object_spread_props(_object_spread({}, options), {
|
|
14294
|
+
sendAutomaticallyWhen: sendAutomaticallyWhen,
|
|
14268
14295
|
transport: transport,
|
|
14269
|
-
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
|
|
14270
14296
|
shouldRepairToolInput: function shouldRepairToolInput(toolName) {
|
|
14271
14297
|
var tool = tools[toolName];
|
|
14272
14298
|
if (!tool && toolName.startsWith("".concat(SearchIndexToolType$2, "_"))) {
|
|
@@ -14308,6 +14334,7 @@
|
|
|
14308
14334
|
};
|
|
14309
14335
|
return {
|
|
14310
14336
|
$$type: 'ais.chat',
|
|
14337
|
+
dependsOn: requiresSearch ? 'search' : 'none',
|
|
14311
14338
|
init: function init(initOptions) {
|
|
14312
14339
|
var _this = this;
|
|
14313
14340
|
var instantSearchInstance = initOptions.instantSearchInstance;
|
|
@@ -14520,6 +14547,7 @@
|
|
|
14520
14547
|
return {
|
|
14521
14548
|
$$type: 'ais.chatTrigger',
|
|
14522
14549
|
opensChat: true,
|
|
14550
|
+
dependsOn: 'none',
|
|
14523
14551
|
init: function init(initOptions) {
|
|
14524
14552
|
lastOptions = initOptions;
|
|
14525
14553
|
renderFn(_object_spread_props(_object_spread({}, this.getWidgetRenderState(initOptions)), {
|
|
@@ -14548,6 +14576,9 @@
|
|
|
14548
14576
|
return _object_spread_props(_object_spread({}, renderState), {
|
|
14549
14577
|
chatTrigger: this.getWidgetRenderState(renderOptions)
|
|
14550
14578
|
});
|
|
14579
|
+
},
|
|
14580
|
+
shouldRender: function shouldRender() {
|
|
14581
|
+
return true;
|
|
14551
14582
|
}
|
|
14552
14583
|
};
|
|
14553
14584
|
};
|
|
@@ -18488,6 +18519,8 @@
|
|
|
18488
18519
|
// later during hydration.
|
|
18489
18520
|
var requestParamsList;
|
|
18490
18521
|
var client = helper.getClient();
|
|
18522
|
+
var waitsForSearch = search._hasSearchWidget;
|
|
18523
|
+
var waitsForRecommend = !skipRecommend && search._hasRecommendWidget;
|
|
18491
18524
|
if (search.compositionID) {
|
|
18492
18525
|
helper.setClient(_object_spread_props(_object_spread({}, client), {
|
|
18493
18526
|
search: function search(query) {
|
|
@@ -18508,17 +18541,22 @@
|
|
|
18508
18541
|
}
|
|
18509
18542
|
}));
|
|
18510
18543
|
}
|
|
18511
|
-
if (
|
|
18544
|
+
if (waitsForSearch) {
|
|
18512
18545
|
if (search.compositionID) {
|
|
18513
18546
|
helper.searchWithComposition();
|
|
18514
18547
|
} else {
|
|
18515
18548
|
helper.searchOnlyWithDerivedHelpers();
|
|
18516
18549
|
}
|
|
18517
18550
|
}
|
|
18518
|
-
|
|
18551
|
+
if (waitsForRecommend) {
|
|
18552
|
+
helper.recommend();
|
|
18553
|
+
}
|
|
18554
|
+
if (!waitsForSearch && !waitsForRecommend) {
|
|
18555
|
+
return Promise.resolve([]);
|
|
18556
|
+
}
|
|
18519
18557
|
return new Promise(function(resolve, reject) {
|
|
18520
|
-
var searchResultsReceived = !
|
|
18521
|
-
var recommendResultsReceived = !
|
|
18558
|
+
var searchResultsReceived = !waitsForSearch;
|
|
18559
|
+
var recommendResultsReceived = !waitsForRecommend;
|
|
18522
18560
|
// All derived helpers resolve in the same tick so we're safe only relying
|
|
18523
18561
|
// on the first one.
|
|
18524
18562
|
helper.derivedHelpers[0].on('result', function() {
|
|
@@ -18558,6 +18596,13 @@
|
|
|
18558
18596
|
var requestParamsIndex = 0;
|
|
18559
18597
|
walkIndex(rootIndex, function(widget) {
|
|
18560
18598
|
var _widget_getHelper;
|
|
18599
|
+
var currentIndex = widget;
|
|
18600
|
+
while(currentIndex){
|
|
18601
|
+
if (currentIndex._isolated) {
|
|
18602
|
+
return;
|
|
18603
|
+
}
|
|
18604
|
+
currentIndex = currentIndex.getParent();
|
|
18605
|
+
}
|
|
18561
18606
|
var searchResults = widget.getResults();
|
|
18562
18607
|
var recommendResults = (_widget_getHelper = widget.getHelper()) === null || _widget_getHelper === void 0 ? void 0 : _widget_getHelper.lastRecommendResults;
|
|
18563
18608
|
if (searchResults || recommendResults) {
|
|
@@ -18588,7 +18633,7 @@
|
|
|
18588
18633
|
});
|
|
18589
18634
|
}
|
|
18590
18635
|
});
|
|
18591
|
-
if (Object.keys(initialResults).length === 0) {
|
|
18636
|
+
if (Object.keys(initialResults).length === 0 && (requestParamsList === null || requestParamsList === void 0 ? void 0 : requestParamsList.length) !== 0) {
|
|
18592
18637
|
throw new Error('The root index does not have any results. Make sure you have at least one widget that provides results.');
|
|
18593
18638
|
}
|
|
18594
18639
|
return initialResults;
|
|
@@ -18623,6 +18668,13 @@
|
|
|
18623
18668
|
var shouldRefetch = false;
|
|
18624
18669
|
// Two-pass widgets require another query to discover and mount child widgets.
|
|
18625
18670
|
walkIndex(searchRef.current.mainIndex, function(index) {
|
|
18671
|
+
var current = index;
|
|
18672
|
+
while(current){
|
|
18673
|
+
if (current._isolated) {
|
|
18674
|
+
return;
|
|
18675
|
+
}
|
|
18676
|
+
current = current.getParent();
|
|
18677
|
+
}
|
|
18626
18678
|
shouldRefetch = shouldRefetch || index.getWidgets().some(isTwoPassWidget);
|
|
18627
18679
|
});
|
|
18628
18680
|
if (shouldRefetch) {
|
|
@@ -22719,14 +22771,15 @@
|
|
|
22719
22771
|
var indices = 'indices' in props ? props.indices : undefined;
|
|
22720
22772
|
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
22721
22773
|
var isFeedsMode = feeds !== undefined;
|
|
22722
|
-
var showQuerySuggestions = props.showQuerySuggestions, showPromptSuggestions = props.showPromptSuggestions, showRecent = props.showRecent, userSearchParameters = props.searchParameters, detachedMediaQuery = props.detachedMediaQuery, tmp = props.translations, userTranslations = tmp === void 0 ? {} : tmp, transformItems = props.transformItems, restProps = _object_without_properties(props, [
|
|
22774
|
+
var showQuerySuggestions = props.showQuerySuggestions, showPromptSuggestions = props.showPromptSuggestions, showRecent = props.showRecent, userSearchParameters = props.searchParameters, detachedMediaQuery = props.detachedMediaQuery, tmp = props.translations, userTranslations = tmp === void 0 ? {} : tmp, transformItems = props.transformItems, _props_requiresSearch = props.requiresSearch, requiresSearch = _props_requiresSearch === void 0 ? true : _props_requiresSearch, restProps = _object_without_properties(props, [
|
|
22723
22775
|
"showQuerySuggestions",
|
|
22724
22776
|
"showPromptSuggestions",
|
|
22725
22777
|
"showRecent",
|
|
22726
22778
|
"searchParameters",
|
|
22727
22779
|
"detachedMediaQuery",
|
|
22728
22780
|
"translations",
|
|
22729
|
-
"transformItems"
|
|
22781
|
+
"transformItems",
|
|
22782
|
+
"requiresSearch"
|
|
22730
22783
|
]);
|
|
22731
22784
|
var autoFocus = restProps.autoFocus, placeholder = restProps.placeholder, classNames = restProps.classNames;
|
|
22732
22785
|
// Eager-mount only when `autoFocus` is set — otherwise wait for first focus
|
|
@@ -22735,9 +22788,11 @@
|
|
|
22735
22788
|
var translations = _object_spread({}, DEFAULT_TRANSLATIONS, userTranslations);
|
|
22736
22789
|
var _useInstantSearch = useInstantSearch(), indexUiState = _useInstantSearch.indexUiState, indexRenderState = _useInstantSearch.indexRenderState, status = _useInstantSearch.status;
|
|
22737
22790
|
var compositionID = useInstantSearchContext().compositionID;
|
|
22791
|
+
var dependsOn = requiresSearch ? 'search' : 'none';
|
|
22738
22792
|
var refine = useSearchBox({}, _object_spread({
|
|
22739
22793
|
$$type: 'ais.autocomplete',
|
|
22740
|
-
$$widgetType: 'ais.autocomplete'
|
|
22794
|
+
$$widgetType: 'ais.autocomplete',
|
|
22795
|
+
dependsOn: dependsOn
|
|
22741
22796
|
}, props.aiMode ? {
|
|
22742
22797
|
opensChat: true
|
|
22743
22798
|
} : {})).refine;
|