react-instantsearch 7.40.0 → 7.41.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/widgets/Autocomplete.js +22 -13
- package/dist/cjs/widgets/Chat.js +1 -1
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +14 -86
- package/dist/es/index.js +1 -1
- package/dist/es/widgets/Autocomplete.d.ts +3 -1
- package/dist/es/widgets/Autocomplete.js +12 -11
- package/dist/es/widgets/Chat.js +2 -2
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +16 -88
- package/dist/es/widgets/index.js +1 -1
- package/dist/umd/ReactInstantSearch.js +854 -509
- package/dist/umd/ReactInstantSearch.min.js +3 -3
- package/package.json +5 -5
|
@@ -3,9 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
function _export(target, all) {
|
|
7
|
+
for(var name in all)Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: Object.getOwnPropertyDescriptor(all, name).get
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
_export(exports, {
|
|
13
|
+
get Autocomplete () {
|
|
14
|
+
return Autocomplete;
|
|
15
|
+
},
|
|
16
|
+
get EXPERIMENTAL_Autocomplete () {
|
|
9
17
|
return EXPERIMENTAL_Autocomplete;
|
|
10
18
|
}
|
|
11
19
|
});
|
|
@@ -18,13 +26,13 @@ var _to_consumable_array = require("@swc/helpers/_/_to_consumable_array");
|
|
|
18
26
|
var _type_of = require("@swc/helpers/_/_type_of");
|
|
19
27
|
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
20
28
|
var _chat = require("instantsearch.js/cjs/lib/chat");
|
|
21
|
-
require("instantsearch.js/cjs/lib/utils");
|
|
29
|
+
var _utils = require("instantsearch.js/cjs/lib/utils");
|
|
22
30
|
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
23
31
|
var _reactinstantsearchcore = require("react-instantsearch-core");
|
|
24
32
|
var _AutocompleteSearch = require("../components/AutocompleteSearch");
|
|
25
33
|
var _Highlight = require("./Highlight");
|
|
26
34
|
var _ReverseHighlight = require("./ReverseHighlight");
|
|
27
|
-
var
|
|
35
|
+
var AutocompleteUiComponent = (0, _instantsearchuicomponents.createAutocompleteComponent)({
|
|
28
36
|
createElement: _react.createElement,
|
|
29
37
|
Fragment: _react.Fragment
|
|
30
38
|
});
|
|
@@ -210,7 +218,7 @@ function getMediaQueryList(mediaQuery) {
|
|
|
210
218
|
setIsModalOpen: setIsModalOpen
|
|
211
219
|
};
|
|
212
220
|
}
|
|
213
|
-
function
|
|
221
|
+
function Autocomplete(props) {
|
|
214
222
|
var _showRecent_classNames, _showRecent_classNames1, _showRecent_classNames2, _showRecent_classNames3;
|
|
215
223
|
var indices = 'indices' in props ? props.indices : undefined;
|
|
216
224
|
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
@@ -243,10 +251,10 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
243
251
|
var domId = useAutocompleteId();
|
|
244
252
|
var instanceKey = domId.replace(/:/g, '');
|
|
245
253
|
if (isFeedsMode && indices !== undefined) {
|
|
246
|
-
throw new Error('
|
|
254
|
+
throw new Error('Autocomplete: `feeds` and `indices` are mutually exclusive.');
|
|
247
255
|
}
|
|
248
256
|
if (isFeedsMode && !compositionID) {
|
|
249
|
-
throw new Error('
|
|
257
|
+
throw new Error('Autocomplete in feeds-mode requires a composition-based <InstantSearch> (compositionID must be set).');
|
|
250
258
|
}
|
|
251
259
|
var isSearchStalled = status === 'stalled';
|
|
252
260
|
var searchParameters = _object_spread._({
|
|
@@ -461,7 +469,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
461
469
|
}
|
|
462
470
|
setActivated(true);
|
|
463
471
|
};
|
|
464
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
472
|
+
return /*#__PURE__*/ _react.default.createElement(AutocompleteUiComponent, _object_spread_props._(_object_spread._({}, shellRootProps), {
|
|
465
473
|
classNames: classNames
|
|
466
474
|
}), isDetached ? /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedSearchButton, {
|
|
467
475
|
query: (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '',
|
|
@@ -504,7 +512,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
504
512
|
}));
|
|
505
513
|
if (isFeedsMode) {
|
|
506
514
|
return /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Index, {
|
|
507
|
-
|
|
515
|
+
isolated: true,
|
|
508
516
|
indexName: compositionID,
|
|
509
517
|
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
510
518
|
}, /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Configure, searchParameters), /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Feeds, {
|
|
@@ -515,7 +523,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
515
523
|
}), innerAutocomplete);
|
|
516
524
|
}
|
|
517
525
|
return /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Index, {
|
|
518
|
-
|
|
526
|
+
isolated: true,
|
|
519
527
|
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
520
528
|
}, /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Configure, searchParameters), indicesConfig.map(function(index) {
|
|
521
529
|
return /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Index, {
|
|
@@ -525,6 +533,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
525
533
|
}, /*#__PURE__*/ _react.default.createElement(_reactinstantsearchcore.Configure, index.searchParameters));
|
|
526
534
|
}), innerAutocomplete);
|
|
527
535
|
}
|
|
536
|
+
var EXPERIMENTAL_Autocomplete = (0, _utils.deprecate)(Autocomplete, 'EXPERIMENTAL_Autocomplete is no longer experimental. Please use Autocomplete instead.');
|
|
528
537
|
function InnerAutocomplete(_0) {
|
|
529
538
|
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, translations = _0.translations, classNames = _0.classNames, aiMode = _0.aiMode, domId = _0.domId, detached = _0.detached, props = _object_without_properties._(_0, [
|
|
530
539
|
"indicesConfig",
|
|
@@ -810,7 +819,7 @@ function InnerAutocomplete(_0) {
|
|
|
810
819
|
"ref"
|
|
811
820
|
]);
|
|
812
821
|
if (isDetached) {
|
|
813
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
822
|
+
return /*#__PURE__*/ _react.default.createElement(AutocompleteUiComponent, _object_spread_props._(_object_spread._({}, props, rootProps), {
|
|
814
823
|
rootRef: rootRef,
|
|
815
824
|
classNames: classNames
|
|
816
825
|
}), /*#__PURE__*/ _react.default.createElement(AutocompleteDetachedSearchButton, {
|
|
@@ -836,7 +845,7 @@ function InnerAutocomplete(_0) {
|
|
|
836
845
|
}, searchBoxContent), panelContent)));
|
|
837
846
|
}
|
|
838
847
|
// Normal (non-detached) rendering
|
|
839
|
-
return /*#__PURE__*/ _react.default.createElement(
|
|
848
|
+
return /*#__PURE__*/ _react.default.createElement(AutocompleteUiComponent, _object_spread_props._(_object_spread._({}, props, rootProps), {
|
|
840
849
|
rootRef: rootRef,
|
|
841
850
|
classNames: classNames
|
|
842
851
|
}), searchBoxContent, panelContent);
|
package/dist/cjs/widgets/Chat.js
CHANGED
|
@@ -52,7 +52,7 @@ var _SearchIndexTool = require("./chat/tools/SearchIndexTool");
|
|
|
52
52
|
var ChatUiComponent = (0, _instantsearchuicomponents.createChatComponent)({
|
|
53
53
|
createElement: _react.createElement,
|
|
54
54
|
Fragment: _react.Fragment,
|
|
55
|
-
|
|
55
|
+
useMemo: _react.useMemo,
|
|
56
56
|
useState: _react.useState
|
|
57
57
|
});
|
|
58
58
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
@@ -10,98 +10,26 @@ Object.defineProperty(exports, "createCarouselTool", {
|
|
|
10
10
|
}
|
|
11
11
|
});
|
|
12
12
|
var _interop_require_wildcard = require("@swc/helpers/_/_interop_require_wildcard");
|
|
13
|
-
var _object_spread = require("@swc/helpers/_/_object_spread");
|
|
14
13
|
var _instantsearchuicomponents = require("instantsearch-ui-components");
|
|
15
|
-
var _utils = require("instantsearch.js/cjs/lib/utils");
|
|
16
14
|
var _react = /*#__PURE__*/ _interop_require_wildcard._(require("react"));
|
|
17
|
-
var _components = require("../../../components");
|
|
18
15
|
function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
19
|
-
var
|
|
20
|
-
createElement: _react.createElement
|
|
16
|
+
var SearchLayoutUIComponent = (0, _instantsearchuicomponents.createCarouselToolComponent)({
|
|
17
|
+
createElement: _react.createElement,
|
|
18
|
+
Fragment: _react.Fragment,
|
|
19
|
+
useMemo: _react.useMemo,
|
|
20
|
+
useRef: _react.useRef,
|
|
21
|
+
useState: _react.useState
|
|
21
22
|
});
|
|
22
|
-
function SearchLayoutComponent(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
var hitsWithAbsolutePosition = (0, _utils.addAbsolutePosition)((output === null || output === void 0 ? void 0 : output.hits) || [], 0, ((_ref = input === null || input === void 0 ? void 0 : input.number_of_results) !== null && _ref !== void 0 ? _ref : output === null || output === void 0 ? void 0 : (_output_hits = output.hits) === null || _output_hits === void 0 ? void 0 : _output_hits.length) || 5);
|
|
29
|
-
var items = (0, _utils.addQueryID)(hitsWithAbsolutePosition, output === null || output === void 0 ? void 0 : output.queryID);
|
|
30
|
-
var MemoedHeaderComponent = _react.default.useMemo(function() {
|
|
31
|
-
return function(props) {
|
|
32
|
-
return /*#__PURE__*/ _react.default.createElement(HeaderComponent, _object_spread._({
|
|
33
|
-
nbHits: output === null || output === void 0 ? void 0 : output.nbHits,
|
|
34
|
-
input: input,
|
|
35
|
-
hitsPerPage: items.length,
|
|
36
|
-
onClose: onClose,
|
|
37
|
-
applyFilters: applyFilters
|
|
38
|
-
}, props));
|
|
39
|
-
};
|
|
40
|
-
}, [
|
|
41
|
-
items.length,
|
|
42
|
-
input,
|
|
43
|
-
output === null || output === void 0 ? void 0 : output.nbHits,
|
|
44
|
-
applyFilters,
|
|
45
|
-
onClose
|
|
46
|
-
]);
|
|
47
|
-
return /*#__PURE__*/ _react.default.createElement(_components.Carousel, {
|
|
48
|
-
items: items,
|
|
23
|
+
var SearchLayoutComponent = function SearchLayoutComponent(toolProps) {
|
|
24
|
+
return /*#__PURE__*/ _react.default.createElement(SearchLayoutUIComponent, {
|
|
25
|
+
getSearchPageURL: getSearchPageURL,
|
|
26
|
+
headerProps: {
|
|
27
|
+
showViewAll: showViewAll
|
|
28
|
+
},
|
|
49
29
|
itemComponent: itemComponent,
|
|
50
|
-
|
|
51
|
-
showNavigation: false,
|
|
52
|
-
headerComponent: MemoedHeaderComponent
|
|
30
|
+
toolProps: toolProps
|
|
53
31
|
});
|
|
54
|
-
}
|
|
55
|
-
function HeaderComponent(param) {
|
|
56
|
-
var canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight, nbHits = param.nbHits, input = param.input, hitsPerPage = param.hitsPerPage, applyFilters = param.applyFilters, onClose = param.onClose;
|
|
57
|
-
if ((hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) < 1) {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
return /*#__PURE__*/ _react.default.createElement("div", {
|
|
61
|
-
className: "ais-ChatToolSearchIndexCarouselHeader"
|
|
62
|
-
}, /*#__PURE__*/ _react.default.createElement("div", {
|
|
63
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderResults"
|
|
64
|
-
}, nbHits && /*#__PURE__*/ _react.default.createElement("div", {
|
|
65
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderCount"
|
|
66
|
-
}, hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0, " of ", nbHits.toLocaleString(), " result", nbHits > 1 ? 's' : ''), showViewAll && /*#__PURE__*/ _react.default.createElement(Button, {
|
|
67
|
-
variant: "ghost",
|
|
68
|
-
size: "sm",
|
|
69
|
-
onClick: function onClick() {
|
|
70
|
-
if (!input || !applyFilters) return;
|
|
71
|
-
var params = applyFilters({
|
|
72
|
-
query: input.query,
|
|
73
|
-
facetFilters: (0, _instantsearchuicomponents.getFacetFiltersFromToolInput)(input)
|
|
74
|
-
});
|
|
75
|
-
if (getSearchPageURL && new URL(getSearchPageURL(params)).pathname !== window.location.pathname) {
|
|
76
|
-
window.location.href = getSearchPageURL(params);
|
|
77
|
-
}
|
|
78
|
-
onClose();
|
|
79
|
-
},
|
|
80
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
|
|
81
|
-
}, "View all", /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ArrowRightIcon, {
|
|
82
|
-
createElement: _react.createElement
|
|
83
|
-
}))), (hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) > 2 && /*#__PURE__*/ _react.default.createElement("div", {
|
|
84
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
|
|
85
|
-
}, /*#__PURE__*/ _react.default.createElement(Button, {
|
|
86
|
-
variant: "outline",
|
|
87
|
-
size: "sm",
|
|
88
|
-
iconOnly: true,
|
|
89
|
-
onClick: scrollLeft,
|
|
90
|
-
disabled: !canScrollLeft,
|
|
91
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
92
|
-
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronLeftIcon, {
|
|
93
|
-
createElement: _react.createElement
|
|
94
|
-
})), /*#__PURE__*/ _react.default.createElement(Button, {
|
|
95
|
-
variant: "outline",
|
|
96
|
-
size: "sm",
|
|
97
|
-
iconOnly: true,
|
|
98
|
-
onClick: scrollRight,
|
|
99
|
-
disabled: !canScrollRight,
|
|
100
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
101
|
-
}, /*#__PURE__*/ _react.default.createElement(_instantsearchuicomponents.ChevronRightIcon, {
|
|
102
|
-
createElement: _react.createElement
|
|
103
|
-
}))));
|
|
104
|
-
}
|
|
32
|
+
};
|
|
105
33
|
return {
|
|
106
34
|
layoutComponent: SearchLayoutComponent
|
|
107
35
|
};
|
package/dist/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export * from 'react-instantsearch-core';
|
|
2
2
|
export { useStickToBottom } from './lib/useStickToBottom.js';
|
|
3
|
-
export { EXPERIMENTAL_Autocomplete } from './widgets/Autocomplete.js';
|
|
3
|
+
export { Autocomplete, EXPERIMENTAL_Autocomplete } from './widgets/Autocomplete.js';
|
|
4
4
|
export { Breadcrumb } from './widgets/Breadcrumb.js';
|
|
5
5
|
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
6
6
|
export { Chat, createDefaultTools } from './widgets/Chat.js';
|
|
@@ -142,5 +142,7 @@ export type AutocompleteFeedsProps<TItem extends BaseHit> = AutocompleteCommonPr
|
|
|
142
142
|
showPromptSuggestions?: FeedsShowPromptSuggestionsConfig;
|
|
143
143
|
};
|
|
144
144
|
export type AutocompleteProps<TItem extends BaseHit> = AutocompleteIndicesProps<TItem> | AutocompleteFeedsProps<TItem>;
|
|
145
|
-
export declare function
|
|
145
|
+
export declare function Autocomplete<TItem extends BaseHit = BaseHit>(props: AutocompleteProps<TItem>): React.JSX.Element;
|
|
146
|
+
/** @deprecated use Autocomplete instead */
|
|
147
|
+
export declare const EXPERIMENTAL_Autocomplete: typeof Autocomplete;
|
|
146
148
|
export {};
|
|
@@ -6,14 +6,14 @@ import { _ as _$3 } from '@swc/helpers/esm/_to_consumable_array.js';
|
|
|
6
6
|
import { _ as _$5 } from '@swc/helpers/esm/_type_of.js';
|
|
7
7
|
import { createAutocompleteComponent, createAutocompletePanelComponent, createAutocompleteIndexComponent, createAutocompleteSuggestionComponent, createAutocompletePromptSuggestionComponent, createAutocompleteRecentSearchComponent, createAutocompleteDetachedContainerComponent, createAutocompleteDetachedOverlayComponent, createAutocompleteDetachedFormContainerComponent, createAutocompleteDetachedSearchButtonComponent, createAutocompletePropGetters, createAutocompleteStorage, cx, getPromptSuggestionHits, isPromptSuggestion } from 'instantsearch-ui-components';
|
|
8
8
|
import { openChat, isChatBusy } from 'instantsearch.js/es/lib/chat/index.js';
|
|
9
|
-
import 'instantsearch.js/es/lib/utils/index.js';
|
|
9
|
+
import { deprecate } from 'instantsearch.js/es/lib/utils/index.js';
|
|
10
10
|
import React, { createElement, Fragment, useEffect, useMemo, useRef, useState, useLayoutEffect } from 'react';
|
|
11
11
|
import { useInstantSearch, useInstantSearchContext, useSearchBox, Index, Configure, Feeds, useAutocomplete } from 'react-instantsearch-core';
|
|
12
12
|
import { AutocompleteSearch } from '../components/AutocompleteSearch.js';
|
|
13
13
|
import { Highlight } from './Highlight.js';
|
|
14
14
|
import { ReverseHighlight } from './ReverseHighlight.js';
|
|
15
15
|
|
|
16
|
-
var
|
|
16
|
+
var AutocompleteUiComponent = createAutocompleteComponent({
|
|
17
17
|
createElement: createElement,
|
|
18
18
|
Fragment: Fragment
|
|
19
19
|
});
|
|
@@ -199,7 +199,7 @@ function getMediaQueryList(mediaQuery) {
|
|
|
199
199
|
setIsModalOpen: setIsModalOpen
|
|
200
200
|
};
|
|
201
201
|
}
|
|
202
|
-
function
|
|
202
|
+
function Autocomplete(props) {
|
|
203
203
|
var _showRecent_classNames, _showRecent_classNames1, _showRecent_classNames2, _showRecent_classNames3;
|
|
204
204
|
var indices = 'indices' in props ? props.indices : undefined;
|
|
205
205
|
var feeds = 'feeds' in props ? props.feeds : undefined;
|
|
@@ -232,10 +232,10 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
232
232
|
var domId = useAutocompleteId();
|
|
233
233
|
var instanceKey = domId.replace(/:/g, '');
|
|
234
234
|
if (isFeedsMode && indices !== undefined) {
|
|
235
|
-
throw new Error('
|
|
235
|
+
throw new Error('Autocomplete: `feeds` and `indices` are mutually exclusive.');
|
|
236
236
|
}
|
|
237
237
|
if (isFeedsMode && !compositionID) {
|
|
238
|
-
throw new Error('
|
|
238
|
+
throw new Error('Autocomplete in feeds-mode requires a composition-based <InstantSearch> (compositionID must be set).');
|
|
239
239
|
}
|
|
240
240
|
var isSearchStalled = status === 'stalled';
|
|
241
241
|
var searchParameters = _$2({
|
|
@@ -450,7 +450,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
450
450
|
}
|
|
451
451
|
setActivated(true);
|
|
452
452
|
};
|
|
453
|
-
return /*#__PURE__*/ React.createElement(
|
|
453
|
+
return /*#__PURE__*/ React.createElement(AutocompleteUiComponent, _$4(_$2({}, shellRootProps), {
|
|
454
454
|
classNames: classNames
|
|
455
455
|
}), isDetached ? /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
456
456
|
query: (_indexUiState_query = indexUiState.query) !== null && _indexUiState_query !== void 0 ? _indexUiState_query : '',
|
|
@@ -493,7 +493,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
493
493
|
}));
|
|
494
494
|
if (isFeedsMode) {
|
|
495
495
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
496
|
-
|
|
496
|
+
isolated: true,
|
|
497
497
|
indexName: compositionID,
|
|
498
498
|
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
499
499
|
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), /*#__PURE__*/ React.createElement(Feeds, {
|
|
@@ -504,7 +504,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
504
504
|
}), innerAutocomplete);
|
|
505
505
|
}
|
|
506
506
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
507
|
-
|
|
507
|
+
isolated: true,
|
|
508
508
|
indexId: "ais-autocomplete-".concat(instanceKey)
|
|
509
509
|
}, /*#__PURE__*/ React.createElement(Configure, searchParameters), indicesConfig.map(function(index) {
|
|
510
510
|
return /*#__PURE__*/ React.createElement(Index, {
|
|
@@ -514,6 +514,7 @@ function EXPERIMENTAL_Autocomplete(props) {
|
|
|
514
514
|
}, /*#__PURE__*/ React.createElement(Configure, index.searchParameters));
|
|
515
515
|
}), innerAutocomplete);
|
|
516
516
|
}
|
|
517
|
+
/** @deprecated use Autocomplete instead */ var EXPERIMENTAL_Autocomplete = deprecate(Autocomplete, 'EXPERIMENTAL_Autocomplete is no longer experimental. Please use Autocomplete instead.');
|
|
517
518
|
function InnerAutocomplete(_0) {
|
|
518
519
|
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, translations = _0.translations, classNames = _0.classNames, aiMode = _0.aiMode, domId = _0.domId, detached = _0.detached, props = _(_0, [
|
|
519
520
|
"indicesConfig",
|
|
@@ -799,7 +800,7 @@ function InnerAutocomplete(_0) {
|
|
|
799
800
|
"ref"
|
|
800
801
|
]);
|
|
801
802
|
if (isDetached) {
|
|
802
|
-
return /*#__PURE__*/ React.createElement(
|
|
803
|
+
return /*#__PURE__*/ React.createElement(AutocompleteUiComponent, _$4(_$2({}, props, rootProps), {
|
|
803
804
|
rootRef: rootRef,
|
|
804
805
|
classNames: classNames
|
|
805
806
|
}), /*#__PURE__*/ React.createElement(AutocompleteDetachedSearchButton, {
|
|
@@ -825,7 +826,7 @@ function InnerAutocomplete(_0) {
|
|
|
825
826
|
}, searchBoxContent), panelContent)));
|
|
826
827
|
}
|
|
827
828
|
// Normal (non-detached) rendering
|
|
828
|
-
return /*#__PURE__*/ React.createElement(
|
|
829
|
+
return /*#__PURE__*/ React.createElement(AutocompleteUiComponent, _$4(_$2({}, props, rootProps), {
|
|
829
830
|
rootRef: rootRef,
|
|
830
831
|
classNames: classNames
|
|
831
832
|
}), searchBoxContent, panelContent);
|
|
@@ -855,4 +856,4 @@ function ConditionalHighlight(param) {
|
|
|
855
856
|
});
|
|
856
857
|
}
|
|
857
858
|
|
|
858
|
-
export { EXPERIMENTAL_Autocomplete };
|
|
859
|
+
export { Autocomplete, EXPERIMENTAL_Autocomplete };
|
package/dist/es/widgets/Chat.js
CHANGED
|
@@ -7,7 +7,7 @@ import { _ as _$1 } from '@swc/helpers/esm/_to_array.js';
|
|
|
7
7
|
import { createChatComponent } from 'instantsearch-ui-components';
|
|
8
8
|
import { SearchIndexToolType, RecommendToolType, DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
9
9
|
export { DisplayResultsToolType, MemorizeToolType, MemorySearchToolType, PonderToolType, RecommendToolType, SearchIndexToolType } from 'instantsearch.js/es/lib/chat/index.js';
|
|
10
|
-
import React, { createElement, Fragment,
|
|
10
|
+
import React, { createElement, Fragment, useMemo, useState, useRef, useImperativeHandle, useEffect } from 'react';
|
|
11
11
|
import { useInstantSearch, useChat } from 'react-instantsearch-core';
|
|
12
12
|
import { useStickToBottom } from '../lib/useStickToBottom.js';
|
|
13
13
|
import { createDisplayResultsTool } from './chat/tools/DisplayResultsTool.js';
|
|
@@ -16,7 +16,7 @@ import { createCarouselTool } from './chat/tools/SearchIndexTool.js';
|
|
|
16
16
|
var ChatUiComponent = createChatComponent({
|
|
17
17
|
createElement: createElement,
|
|
18
18
|
Fragment: Fragment,
|
|
19
|
-
|
|
19
|
+
useMemo: useMemo,
|
|
20
20
|
useState: useState
|
|
21
21
|
});
|
|
22
22
|
function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
@@ -1,96 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { addAbsolutePosition, addQueryID } from 'instantsearch.js/es/lib/utils/index.js';
|
|
4
|
-
import React, { createElement } from 'react';
|
|
5
|
-
import { Carousel } from '../../../components/Carousel.js';
|
|
1
|
+
import { createCarouselToolComponent } from 'instantsearch-ui-components';
|
|
2
|
+
import React, { createElement, Fragment, useMemo, useRef, useState } from 'react';
|
|
6
3
|
|
|
7
4
|
function createCarouselTool(showViewAll, itemComponent, getSearchPageURL) {
|
|
8
|
-
var
|
|
9
|
-
createElement: createElement
|
|
5
|
+
var SearchLayoutUIComponent = createCarouselToolComponent({
|
|
6
|
+
createElement: createElement,
|
|
7
|
+
Fragment: Fragment,
|
|
8
|
+
useMemo: useMemo,
|
|
9
|
+
useRef: useRef,
|
|
10
|
+
useState: useState
|
|
10
11
|
});
|
|
11
|
-
function SearchLayoutComponent(
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var hitsWithAbsolutePosition = addAbsolutePosition((output === null || output === void 0 ? void 0 : output.hits) || [], 0, ((_ref = input === null || input === void 0 ? void 0 : input.number_of_results) !== null && _ref !== void 0 ? _ref : output === null || output === void 0 ? void 0 : (_output_hits = output.hits) === null || _output_hits === void 0 ? void 0 : _output_hits.length) || 5);
|
|
18
|
-
var items = addQueryID(hitsWithAbsolutePosition, output === null || output === void 0 ? void 0 : output.queryID);
|
|
19
|
-
var MemoedHeaderComponent = React.useMemo(function() {
|
|
20
|
-
return function(props) {
|
|
21
|
-
return /*#__PURE__*/ React.createElement(HeaderComponent, _({
|
|
22
|
-
nbHits: output === null || output === void 0 ? void 0 : output.nbHits,
|
|
23
|
-
input: input,
|
|
24
|
-
hitsPerPage: items.length,
|
|
25
|
-
onClose: onClose,
|
|
26
|
-
applyFilters: applyFilters
|
|
27
|
-
}, props));
|
|
28
|
-
};
|
|
29
|
-
}, [
|
|
30
|
-
items.length,
|
|
31
|
-
input,
|
|
32
|
-
output === null || output === void 0 ? void 0 : output.nbHits,
|
|
33
|
-
applyFilters,
|
|
34
|
-
onClose
|
|
35
|
-
]);
|
|
36
|
-
return /*#__PURE__*/ React.createElement(Carousel, {
|
|
37
|
-
items: items,
|
|
12
|
+
var SearchLayoutComponent = function SearchLayoutComponent(toolProps) {
|
|
13
|
+
return /*#__PURE__*/ React.createElement(SearchLayoutUIComponent, {
|
|
14
|
+
getSearchPageURL: getSearchPageURL,
|
|
15
|
+
headerProps: {
|
|
16
|
+
showViewAll: showViewAll
|
|
17
|
+
},
|
|
38
18
|
itemComponent: itemComponent,
|
|
39
|
-
|
|
40
|
-
showNavigation: false,
|
|
41
|
-
headerComponent: MemoedHeaderComponent
|
|
19
|
+
toolProps: toolProps
|
|
42
20
|
});
|
|
43
|
-
}
|
|
44
|
-
function HeaderComponent(param) {
|
|
45
|
-
var canScrollLeft = param.canScrollLeft, canScrollRight = param.canScrollRight, scrollLeft = param.scrollLeft, scrollRight = param.scrollRight, nbHits = param.nbHits, input = param.input, hitsPerPage = param.hitsPerPage, applyFilters = param.applyFilters, onClose = param.onClose;
|
|
46
|
-
if ((hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) < 1) {
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
return /*#__PURE__*/ React.createElement("div", {
|
|
50
|
-
className: "ais-ChatToolSearchIndexCarouselHeader"
|
|
51
|
-
}, /*#__PURE__*/ React.createElement("div", {
|
|
52
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderResults"
|
|
53
|
-
}, nbHits && /*#__PURE__*/ React.createElement("div", {
|
|
54
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderCount"
|
|
55
|
-
}, hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0, " of ", nbHits.toLocaleString(), " result", nbHits > 1 ? 's' : ''), showViewAll && /*#__PURE__*/ React.createElement(Button, {
|
|
56
|
-
variant: "ghost",
|
|
57
|
-
size: "sm",
|
|
58
|
-
onClick: function onClick() {
|
|
59
|
-
if (!input || !applyFilters) return;
|
|
60
|
-
var params = applyFilters({
|
|
61
|
-
query: input.query,
|
|
62
|
-
facetFilters: getFacetFiltersFromToolInput(input)
|
|
63
|
-
});
|
|
64
|
-
if (getSearchPageURL && new URL(getSearchPageURL(params)).pathname !== window.location.pathname) {
|
|
65
|
-
window.location.href = getSearchPageURL(params);
|
|
66
|
-
}
|
|
67
|
-
onClose();
|
|
68
|
-
},
|
|
69
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
|
|
70
|
-
}, "View all", /*#__PURE__*/ React.createElement(ArrowRightIcon, {
|
|
71
|
-
createElement: createElement
|
|
72
|
-
}))), (hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) > 2 && /*#__PURE__*/ React.createElement("div", {
|
|
73
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
|
|
74
|
-
}, /*#__PURE__*/ React.createElement(Button, {
|
|
75
|
-
variant: "outline",
|
|
76
|
-
size: "sm",
|
|
77
|
-
iconOnly: true,
|
|
78
|
-
onClick: scrollLeft,
|
|
79
|
-
disabled: !canScrollLeft,
|
|
80
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
81
|
-
}, /*#__PURE__*/ React.createElement(ChevronLeftIcon, {
|
|
82
|
-
createElement: createElement
|
|
83
|
-
})), /*#__PURE__*/ React.createElement(Button, {
|
|
84
|
-
variant: "outline",
|
|
85
|
-
size: "sm",
|
|
86
|
-
iconOnly: true,
|
|
87
|
-
onClick: scrollRight,
|
|
88
|
-
disabled: !canScrollRight,
|
|
89
|
-
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
90
|
-
}, /*#__PURE__*/ React.createElement(ChevronRightIcon, {
|
|
91
|
-
createElement: createElement
|
|
92
|
-
}))));
|
|
93
|
-
}
|
|
21
|
+
};
|
|
94
22
|
return {
|
|
95
23
|
layoutComponent: SearchLayoutComponent
|
|
96
24
|
};
|
package/dist/es/widgets/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { EXPERIMENTAL_Autocomplete } from './Autocomplete.js';
|
|
1
|
+
export { Autocomplete, EXPERIMENTAL_Autocomplete } from './Autocomplete.js';
|
|
2
2
|
export { Breadcrumb } from './Breadcrumb.js';
|
|
3
3
|
export { Chat, createDefaultTools } from './Chat.js';
|
|
4
4
|
export { ChatTrigger } from './ChatTrigger.js';
|