react-instantsearch 7.27.0 → 7.28.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.
|
@@ -319,7 +319,7 @@ function EXPERIMENTAL_Autocomplete(_0) {
|
|
|
319
319
|
}))));
|
|
320
320
|
}
|
|
321
321
|
function InnerAutocomplete(_0) {
|
|
322
|
-
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _object_without_properties._(_0, [
|
|
322
|
+
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _object_without_properties._(_0, [
|
|
323
323
|
"indicesConfig",
|
|
324
324
|
"refineSearchBox",
|
|
325
325
|
"isSearchStalled",
|
|
@@ -335,6 +335,7 @@ function InnerAutocomplete(_0) {
|
|
|
335
335
|
"chatRenderState",
|
|
336
336
|
"transformItems",
|
|
337
337
|
"placeholder",
|
|
338
|
+
"autoFocus",
|
|
338
339
|
"detachedMediaQuery",
|
|
339
340
|
"translations",
|
|
340
341
|
"classNames"
|
|
@@ -400,6 +401,15 @@ function InnerAutocomplete(_0) {
|
|
|
400
401
|
promptSuggestionsLimit
|
|
401
402
|
]);
|
|
402
403
|
(0, _react.useRef)(false);
|
|
404
|
+
var allIndicesEmpty = indicesForPanel.every(function(param) {
|
|
405
|
+
var hits = param.hits;
|
|
406
|
+
return hits.length === 0;
|
|
407
|
+
});
|
|
408
|
+
var recentEmpty = !storageHits || storageHits.length === 0;
|
|
409
|
+
var hasNoResultsTemplate = indicesConfig.some(function(c) {
|
|
410
|
+
return c.noResultsComponent !== undefined;
|
|
411
|
+
});
|
|
412
|
+
var shouldHideEmptyPanel = allIndicesEmpty && recentEmpty && !hasNoResultsTemplate && !PanelComponent;
|
|
403
413
|
var _usePropGetters = usePropGetters({
|
|
404
414
|
indices: indicesForPropGettersWithPromptSuggestions,
|
|
405
415
|
indicesConfig: indicesConfigForPropGetters,
|
|
@@ -444,7 +454,9 @@ function InnerAutocomplete(_0) {
|
|
|
444
454
|
}
|
|
445
455
|
},
|
|
446
456
|
placeholder: placeholder,
|
|
447
|
-
isDetached: isDetached
|
|
457
|
+
isDetached: isDetached,
|
|
458
|
+
shouldHidePanel: shouldHideEmptyPanel,
|
|
459
|
+
autoFocus: autoFocus
|
|
448
460
|
}), getInputProps = _usePropGetters.getInputProps, getItemProps = _usePropGetters.getItemProps, getPanelProps = _usePropGetters.getPanelProps, getRootProps = _usePropGetters.getRootProps, isOpen = _usePropGetters.isOpen, setIsOpen = _usePropGetters.setIsOpen, focusInput = _usePropGetters.focusInput;
|
|
449
461
|
// Open panel and focus input when modal opens
|
|
450
462
|
(0, _react.useEffect)(function() {
|
|
@@ -517,6 +529,7 @@ function InnerAutocomplete(_0) {
|
|
|
517
529
|
HeaderComponent: currentIndexConfig.headerComponent,
|
|
518
530
|
// @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
|
|
519
531
|
ItemComponent: currentIndexConfig.itemComponent,
|
|
532
|
+
NoResultsComponent: currentIndexConfig.noResultsComponent,
|
|
520
533
|
items: hits.map(function(item) {
|
|
521
534
|
return _object_spread_props._(_object_spread._({}, item), {
|
|
522
535
|
__indexName: indexId
|
|
@@ -548,8 +561,12 @@ function InnerAutocomplete(_0) {
|
|
|
548
561
|
var detachedContainerClassNames = isModalDetached ? _object_spread_props._(_object_spread._({}, classNames), {
|
|
549
562
|
detachedContainer: (0, _instantsearchuicomponents.cx)('ais-AutocompleteDetachedContainer--modal', classNames === null || classNames === void 0 ? void 0 : classNames.detachedContainer)
|
|
550
563
|
}) : classNames;
|
|
564
|
+
var _getRootProps = getRootProps(), rootRef = _getRootProps.ref, rootProps = _object_without_properties._(_getRootProps, [
|
|
565
|
+
"ref"
|
|
566
|
+
]);
|
|
551
567
|
if (isDetached) {
|
|
552
|
-
return /*#__PURE__*/ _react.default.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props,
|
|
568
|
+
return /*#__PURE__*/ _react.default.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props, rootProps), {
|
|
569
|
+
rootRef: rootRef,
|
|
553
570
|
classNames: classNames
|
|
554
571
|
}), /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedSearchButton, {
|
|
555
572
|
query: currentRefinement || indexUiState.query || '',
|
|
@@ -582,7 +599,8 @@ function InnerAutocomplete(_0) {
|
|
|
582
599
|
}, searchBoxContent), panelContent)));
|
|
583
600
|
}
|
|
584
601
|
// Normal (non-detached) rendering
|
|
585
|
-
return /*#__PURE__*/ _react.default.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props,
|
|
602
|
+
return /*#__PURE__*/ _react.default.createElement(Autocomplete, _object_spread_props._(_object_spread._({}, props, rootProps), {
|
|
603
|
+
rootRef: rootRef,
|
|
586
604
|
classNames: classNames
|
|
587
605
|
}), searchBoxContent, panelContent);
|
|
588
606
|
}
|
|
@@ -9,6 +9,7 @@ type AutocompleteSearchParameters = Omit<PlainSearchParameters, 'index'>;
|
|
|
9
9
|
type IndexConfig<TItem extends BaseHit> = AutocompleteIndexConfig<TItem> & {
|
|
10
10
|
headerComponent?: AutocompleteIndexProps<TItem>['HeaderComponent'];
|
|
11
11
|
itemComponent: AutocompleteIndexProps<TItem>['ItemComponent'];
|
|
12
|
+
noResultsComponent?: AutocompleteIndexProps<TItem>['NoResultsComponent'];
|
|
12
13
|
searchParameters?: AutocompleteSearchParameters;
|
|
13
14
|
classNames?: Partial<AutocompleteIndexClassNames>;
|
|
14
15
|
};
|
|
@@ -58,6 +59,10 @@ export type AutocompleteProps<TItem extends BaseHit> = ComponentProps<'div'> & {
|
|
|
58
59
|
searchParameters?: AutocompleteSearchParameters;
|
|
59
60
|
classNames?: Partial<AutocompleteClassNames>;
|
|
60
61
|
placeholder?: string;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the input should be focused and the panel open initially.
|
|
64
|
+
*/
|
|
65
|
+
autoFocus?: boolean;
|
|
61
66
|
/**
|
|
62
67
|
* Media query to enable detached (mobile) mode.
|
|
63
68
|
* When the media query matches, the autocomplete switches to a full-screen overlay.
|
|
@@ -308,7 +308,7 @@ function EXPERIMENTAL_Autocomplete(_0) {
|
|
|
308
308
|
}))));
|
|
309
309
|
}
|
|
310
310
|
function InnerAutocomplete(_0) {
|
|
311
|
-
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _(_0, [
|
|
311
|
+
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _(_0, [
|
|
312
312
|
"indicesConfig",
|
|
313
313
|
"refineSearchBox",
|
|
314
314
|
"isSearchStalled",
|
|
@@ -324,6 +324,7 @@ function InnerAutocomplete(_0) {
|
|
|
324
324
|
"chatRenderState",
|
|
325
325
|
"transformItems",
|
|
326
326
|
"placeholder",
|
|
327
|
+
"autoFocus",
|
|
327
328
|
"detachedMediaQuery",
|
|
328
329
|
"translations",
|
|
329
330
|
"classNames"
|
|
@@ -389,6 +390,15 @@ function InnerAutocomplete(_0) {
|
|
|
389
390
|
promptSuggestionsLimit
|
|
390
391
|
]);
|
|
391
392
|
useRef(false);
|
|
393
|
+
var allIndicesEmpty = indicesForPanel.every(function(param) {
|
|
394
|
+
var hits = param.hits;
|
|
395
|
+
return hits.length === 0;
|
|
396
|
+
});
|
|
397
|
+
var recentEmpty = !storageHits || storageHits.length === 0;
|
|
398
|
+
var hasNoResultsTemplate = indicesConfig.some(function(c) {
|
|
399
|
+
return c.noResultsComponent !== undefined;
|
|
400
|
+
});
|
|
401
|
+
var shouldHideEmptyPanel = allIndicesEmpty && recentEmpty && !hasNoResultsTemplate && !PanelComponent;
|
|
392
402
|
var _usePropGetters = usePropGetters({
|
|
393
403
|
indices: indicesForPropGettersWithPromptSuggestions,
|
|
394
404
|
indicesConfig: indicesConfigForPropGetters,
|
|
@@ -433,7 +443,9 @@ function InnerAutocomplete(_0) {
|
|
|
433
443
|
}
|
|
434
444
|
},
|
|
435
445
|
placeholder: placeholder,
|
|
436
|
-
isDetached: isDetached
|
|
446
|
+
isDetached: isDetached,
|
|
447
|
+
shouldHidePanel: shouldHideEmptyPanel,
|
|
448
|
+
autoFocus: autoFocus
|
|
437
449
|
}), getInputProps = _usePropGetters.getInputProps, getItemProps = _usePropGetters.getItemProps, getPanelProps = _usePropGetters.getPanelProps, getRootProps = _usePropGetters.getRootProps, isOpen = _usePropGetters.isOpen, setIsOpen = _usePropGetters.setIsOpen, focusInput = _usePropGetters.focusInput;
|
|
438
450
|
// Open panel and focus input when modal opens
|
|
439
451
|
useEffect(function() {
|
|
@@ -506,6 +518,7 @@ function InnerAutocomplete(_0) {
|
|
|
506
518
|
HeaderComponent: currentIndexConfig.headerComponent,
|
|
507
519
|
// @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
|
|
508
520
|
ItemComponent: currentIndexConfig.itemComponent,
|
|
521
|
+
NoResultsComponent: currentIndexConfig.noResultsComponent,
|
|
509
522
|
items: hits.map(function(item) {
|
|
510
523
|
return _$4(_$1({}, item), {
|
|
511
524
|
__indexName: indexId
|
|
@@ -537,8 +550,12 @@ function InnerAutocomplete(_0) {
|
|
|
537
550
|
var detachedContainerClassNames = isModalDetached ? _$4(_$1({}, classNames), {
|
|
538
551
|
detachedContainer: cx('ais-AutocompleteDetachedContainer--modal', classNames === null || classNames === void 0 ? void 0 : classNames.detachedContainer)
|
|
539
552
|
}) : classNames;
|
|
553
|
+
var _getRootProps = getRootProps(), rootRef = _getRootProps.ref, rootProps = _(_getRootProps, [
|
|
554
|
+
"ref"
|
|
555
|
+
]);
|
|
540
556
|
if (isDetached) {
|
|
541
|
-
return /*#__PURE__*/ React.createElement(Autocomplete, _$4(_$1({}, props,
|
|
557
|
+
return /*#__PURE__*/ React.createElement(Autocomplete, _$4(_$1({}, props, rootProps), {
|
|
558
|
+
rootRef: rootRef,
|
|
542
559
|
classNames: classNames
|
|
543
560
|
}), /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
544
561
|
query: currentRefinement || indexUiState.query || '',
|
|
@@ -571,7 +588,8 @@ function InnerAutocomplete(_0) {
|
|
|
571
588
|
}, searchBoxContent), panelContent)));
|
|
572
589
|
}
|
|
573
590
|
// Normal (non-detached) rendering
|
|
574
|
-
return /*#__PURE__*/ React.createElement(Autocomplete, _$4(_$1({}, props,
|
|
591
|
+
return /*#__PURE__*/ React.createElement(Autocomplete, _$4(_$1({}, props, rootProps), {
|
|
592
|
+
rootRef: rootRef,
|
|
575
593
|
classNames: classNames
|
|
576
594
|
}), searchBoxContent, panelContent);
|
|
577
595
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! React InstantSearch 7.
|
|
1
|
+
/*! React InstantSearch 7.28.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.28.0';
|
|
28
28
|
|
|
29
29
|
function getDefaultExportFromCjs (x) {
|
|
30
30
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -10081,7 +10081,7 @@
|
|
|
10081
10081
|
};
|
|
10082
10082
|
}
|
|
10083
10083
|
|
|
10084
|
-
var version = '4.
|
|
10084
|
+
var version = '4.92.0';
|
|
10085
10085
|
|
|
10086
10086
|
function hydrateSearchClient(client, results) {
|
|
10087
10087
|
if (!results) {
|
|
@@ -17830,12 +17830,14 @@
|
|
|
17830
17830
|
function createAutocompleteComponent(param) {
|
|
17831
17831
|
var createElement = param.createElement;
|
|
17832
17832
|
return function Autocomplete(userProps) {
|
|
17833
|
-
var children = userProps.children, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, props = _object_without_propertiesExports._(userProps, [
|
|
17833
|
+
var children = userProps.children, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames, rootRef = userProps.rootRef, props = _object_without_propertiesExports._(userProps, [
|
|
17834
17834
|
"children",
|
|
17835
|
-
"classNames"
|
|
17835
|
+
"classNames",
|
|
17836
|
+
"rootRef"
|
|
17836
17837
|
]);
|
|
17837
17838
|
return /*#__PURE__*/ createElement("div", _object_spreadExports._({
|
|
17838
|
-
className: cx('ais-Autocomplete', classNames.root)
|
|
17839
|
+
className: cx('ais-Autocomplete', classNames.root),
|
|
17840
|
+
ref: rootRef
|
|
17839
17841
|
}, props), children);
|
|
17840
17842
|
};
|
|
17841
17843
|
}
|
|
@@ -18020,8 +18022,8 @@
|
|
|
18020
18022
|
function createAutocompleteIndexComponent(param) {
|
|
18021
18023
|
var createElement = param.createElement;
|
|
18022
18024
|
return function AutocompleteIndex(userProps) {
|
|
18023
|
-
var items = userProps.items, HeaderComponent = userProps.HeaderComponent, ItemComponent = userProps.ItemComponent, getItemProps = userProps.getItemProps, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
|
|
18024
|
-
if (items.length === 0) {
|
|
18025
|
+
var items = userProps.items, HeaderComponent = userProps.HeaderComponent, ItemComponent = userProps.ItemComponent, NoResultsComponent = userProps.NoResultsComponent, getItemProps = userProps.getItemProps, _userProps_classNames = userProps.classNames, classNames = _userProps_classNames === void 0 ? {} : _userProps_classNames;
|
|
18026
|
+
if (items.length === 0 && !NoResultsComponent) {
|
|
18025
18027
|
return null;
|
|
18026
18028
|
}
|
|
18027
18029
|
return /*#__PURE__*/ createElement("div", {
|
|
@@ -18030,7 +18032,9 @@
|
|
|
18030
18032
|
className: cx('ais-AutocompleteIndexHeader', classNames.header)
|
|
18031
18033
|
}, /*#__PURE__*/ createElement(HeaderComponent, {
|
|
18032
18034
|
items: items
|
|
18033
|
-
})), /*#__PURE__*/ createElement("
|
|
18035
|
+
})), items.length === 0 && NoResultsComponent ? /*#__PURE__*/ createElement("div", {
|
|
18036
|
+
className: cx('ais-AutocompleteIndexNoResults', classNames.noResults)
|
|
18037
|
+
}, /*#__PURE__*/ createElement(NoResultsComponent, null)) : /*#__PURE__*/ createElement("ol", {
|
|
18034
18038
|
className: cx('ais-AutocompleteIndexList', classNames.list)
|
|
18035
18039
|
}, items.map(function(item, index) {
|
|
18036
18040
|
var _getItemProps = getItemProps(item, index), className = _getItemProps.className, onSelect = _getItemProps.onSelect, onApply = _getItemProps.onApply, itemProps = _object_without_propertiesExports._(_getItemProps, [
|
|
@@ -18491,11 +18495,11 @@
|
|
|
18491
18495
|
function createAutocompletePropGetters(param) {
|
|
18492
18496
|
var useEffect = param.useEffect, useId = param.useId, useMemo = param.useMemo, useRef = param.useRef, useState = param.useState;
|
|
18493
18497
|
return function usePropGetters(param) {
|
|
18494
|
-
var indices = param.indices, indicesConfig = param.indicesConfig, onRefine = param.onRefine, globalOnSelect = param.onSelect, onApply = param.onApply, onSubmit = param.onSubmit, placeholder = param.placeholder, _param_isDetached = param.isDetached, isDetached = _param_isDetached === void 0 ? false : _param_isDetached;
|
|
18498
|
+
var indices = param.indices, indicesConfig = param.indicesConfig, onRefine = param.onRefine, globalOnSelect = param.onSelect, onApply = param.onApply, onSubmit = param.onSubmit, placeholder = param.placeholder, _param_isDetached = param.isDetached, isDetached = _param_isDetached === void 0 ? false : _param_isDetached, _param_shouldHidePanel = param.shouldHidePanel, shouldHidePanel = _param_shouldHidePanel === void 0 ? false : _param_shouldHidePanel, _param_autoFocus = param.autoFocus, autoFocus = _param_autoFocus === void 0 ? false : _param_autoFocus;
|
|
18495
18499
|
var getElementId = createGetElementId(useId());
|
|
18496
18500
|
var inputRef = useRef(null);
|
|
18497
18501
|
var rootRef = useRef(null);
|
|
18498
|
-
var _useState = _sliced_to_arrayExports._(useState(
|
|
18502
|
+
var _useState = _sliced_to_arrayExports._(useState(autoFocus), 2), isOpen = _useState[0], setIsOpen = _useState[1];
|
|
18499
18503
|
var _useState1 = _sliced_to_arrayExports._(useState(undefined), 2), activeDescendant = _useState1[0], setActiveDescendant = _useState1[1];
|
|
18500
18504
|
var _useMemo = useMemo(function() {
|
|
18501
18505
|
return buildItems({
|
|
@@ -18580,6 +18584,7 @@
|
|
|
18580
18584
|
id: getElementId('input'),
|
|
18581
18585
|
ref: inputRef,
|
|
18582
18586
|
role: 'combobox',
|
|
18587
|
+
autoFocus: autoFocus,
|
|
18583
18588
|
'aria-autocomplete': 'list',
|
|
18584
18589
|
'aria-expanded': isOpen,
|
|
18585
18590
|
'aria-haspopup': 'grid',
|
|
@@ -18667,7 +18672,7 @@
|
|
|
18667
18672
|
},
|
|
18668
18673
|
getPanelProps: function getPanelProps() {
|
|
18669
18674
|
return {
|
|
18670
|
-
hidden: !isOpen,
|
|
18675
|
+
hidden: !isOpen || shouldHidePanel,
|
|
18671
18676
|
id: getElementId('panel'),
|
|
18672
18677
|
role: 'grid',
|
|
18673
18678
|
'aria-labelledby': getElementId('input')
|
|
@@ -21179,7 +21184,7 @@
|
|
|
21179
21184
|
}))));
|
|
21180
21185
|
}
|
|
21181
21186
|
function InnerAutocomplete(_0) {
|
|
21182
|
-
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _object_without_properties(_0, [
|
|
21187
|
+
var indicesConfig = _0.indicesConfig, refineSearchBox = _0.refineSearchBox, isSearchStalled = _0.isSearchStalled, getSearchPageURL = _0.getSearchPageURL, userOnSelect = _0.onSelect, indexUiState = _0.indexUiState, isSearchPage = _0.isSearchPage, PanelComponent = _0.panelComponent, showRecent = _0.showRecent, recentSearchConfig = _0.recentSearchConfig, showQuerySuggestions = _0.showQuerySuggestions, showPromptSuggestions = _0.showPromptSuggestions, chatRenderState = _0.chatRenderState, transformItems = _0.transformItems, placeholder = _0.placeholder, autoFocus = _0.autoFocus, _0_detachedMediaQuery = _0.detachedMediaQuery, detachedMediaQuery = _0_detachedMediaQuery === void 0 ? DEFAULT_DETACHED_MEDIA_QUERY : _0_detachedMediaQuery, translations = _0.translations, classNames = _0.classNames, props = _object_without_properties(_0, [
|
|
21183
21188
|
"indicesConfig",
|
|
21184
21189
|
"refineSearchBox",
|
|
21185
21190
|
"isSearchStalled",
|
|
@@ -21195,6 +21200,7 @@
|
|
|
21195
21200
|
"chatRenderState",
|
|
21196
21201
|
"transformItems",
|
|
21197
21202
|
"placeholder",
|
|
21203
|
+
"autoFocus",
|
|
21198
21204
|
"detachedMediaQuery",
|
|
21199
21205
|
"translations",
|
|
21200
21206
|
"classNames"
|
|
@@ -21260,6 +21266,15 @@
|
|
|
21260
21266
|
promptSuggestionsLimit
|
|
21261
21267
|
]);
|
|
21262
21268
|
var hasWarnedMissingPromptSuggestionsChatRef = React.useRef(false);
|
|
21269
|
+
var allIndicesEmpty = indicesForPanel.every(function(param) {
|
|
21270
|
+
var hits = param.hits;
|
|
21271
|
+
return hits.length === 0;
|
|
21272
|
+
});
|
|
21273
|
+
var recentEmpty = !storageHits || storageHits.length === 0;
|
|
21274
|
+
var hasNoResultsTemplate = indicesConfig.some(function(c) {
|
|
21275
|
+
return c.noResultsComponent !== undefined;
|
|
21276
|
+
});
|
|
21277
|
+
var shouldHideEmptyPanel = allIndicesEmpty && recentEmpty && !hasNoResultsTemplate && !PanelComponent;
|
|
21263
21278
|
var _usePropGetters = usePropGetters({
|
|
21264
21279
|
indices: indicesForPropGettersWithPromptSuggestions,
|
|
21265
21280
|
indicesConfig: indicesConfigForPropGetters,
|
|
@@ -21308,7 +21323,9 @@
|
|
|
21308
21323
|
}
|
|
21309
21324
|
},
|
|
21310
21325
|
placeholder: placeholder,
|
|
21311
|
-
isDetached: isDetached
|
|
21326
|
+
isDetached: isDetached,
|
|
21327
|
+
shouldHidePanel: shouldHideEmptyPanel,
|
|
21328
|
+
autoFocus: autoFocus
|
|
21312
21329
|
}), getInputProps = _usePropGetters.getInputProps, getItemProps = _usePropGetters.getItemProps, getPanelProps = _usePropGetters.getPanelProps, getRootProps = _usePropGetters.getRootProps, isOpen = _usePropGetters.isOpen, setIsOpen = _usePropGetters.setIsOpen, focusInput = _usePropGetters.focusInput;
|
|
21313
21330
|
// Open panel and focus input when modal opens
|
|
21314
21331
|
React.useEffect(function() {
|
|
@@ -21381,6 +21398,7 @@
|
|
|
21381
21398
|
HeaderComponent: currentIndexConfig.headerComponent,
|
|
21382
21399
|
// @ts-expect-error - there seems to be problems with React.ComponentType and this, but it's actually correct
|
|
21383
21400
|
ItemComponent: currentIndexConfig.itemComponent,
|
|
21401
|
+
NoResultsComponent: currentIndexConfig.noResultsComponent,
|
|
21384
21402
|
items: hits.map(function(item) {
|
|
21385
21403
|
return _object_spread_props(_object_spread({}, item), {
|
|
21386
21404
|
__indexName: indexId
|
|
@@ -21412,8 +21430,12 @@
|
|
|
21412
21430
|
var detachedContainerClassNames = isModalDetached ? _object_spread_props(_object_spread({}, classNames), {
|
|
21413
21431
|
detachedContainer: cx('ais-AutocompleteDetachedContainer--modal', classNames === null || classNames === void 0 ? void 0 : classNames.detachedContainer)
|
|
21414
21432
|
}) : classNames;
|
|
21433
|
+
var _getRootProps = getRootProps(), rootRef = _getRootProps.ref, rootProps = _object_without_properties(_getRootProps, [
|
|
21434
|
+
"ref"
|
|
21435
|
+
]);
|
|
21415
21436
|
if (isDetached) {
|
|
21416
|
-
return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props(_object_spread({}, props,
|
|
21437
|
+
return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props(_object_spread({}, props, rootProps), {
|
|
21438
|
+
rootRef: rootRef,
|
|
21417
21439
|
classNames: classNames
|
|
21418
21440
|
}), /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
21419
21441
|
query: currentRefinement || indexUiState.query || '',
|
|
@@ -21446,7 +21468,8 @@
|
|
|
21446
21468
|
}, searchBoxContent), panelContent)));
|
|
21447
21469
|
}
|
|
21448
21470
|
// Normal (non-detached) rendering
|
|
21449
|
-
return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props(_object_spread({}, props,
|
|
21471
|
+
return /*#__PURE__*/ React.createElement(Autocomplete, _object_spread_props(_object_spread({}, props, rootProps), {
|
|
21472
|
+
rootRef: rootRef,
|
|
21450
21473
|
classNames: classNames
|
|
21451
21474
|
}), searchBoxContent, panelContent);
|
|
21452
21475
|
}
|