react-instantsearch 7.16.3 → 7.17.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/Autocomplete.js +114 -0
- package/dist/cjs/components/Carousel.js +19 -1
- package/dist/cjs/components/useAutocomplete.js +237 -0
- package/dist/cjs/index.umd.js +38 -0
- package/dist/cjs/lib/useStickToBottom.js +20 -0
- package/dist/cjs/ui/SearchBox.js +5 -4
- package/dist/cjs/widgets/Chat.js +258 -0
- package/dist/cjs/widgets/chat/tools/SearchIndexTool.js +120 -0
- package/dist/cjs/widgets/index.js +22 -11
- package/dist/cjs/widgets/index.umd.js +282 -0
- package/dist/es/components/Autocomplete.d.ts +20 -0
- package/dist/es/components/Autocomplete.js +106 -0
- package/dist/es/components/Carousel.d.ts +1 -1
- package/dist/es/components/Carousel.js +20 -2
- package/dist/es/components/useAutocomplete.d.ts +35 -0
- package/dist/es/components/useAutocomplete.js +231 -0
- package/dist/es/index.umd.d.ts +3 -0
- package/dist/es/index.umd.js +3 -0
- package/dist/es/lib/useStickToBottom.d.ts +1 -0
- package/dist/es/lib/useStickToBottom.js +14 -0
- package/dist/es/ui/SearchBox.d.ts +2 -1
- package/dist/es/ui/SearchBox.js +5 -4
- package/dist/es/widgets/Chat.d.ts +45 -0
- package/dist/es/widgets/Chat.js +238 -0
- package/dist/es/widgets/chat/tools/SearchIndexTool.d.ts +5 -0
- package/dist/es/widgets/chat/tools/SearchIndexTool.js +113 -0
- package/dist/es/widgets/index.d.ts +2 -1
- package/dist/es/widgets/index.js +3 -2
- package/dist/es/widgets/index.umd.d.ts +26 -0
- package/dist/es/widgets/index.umd.js +28 -0
- package/dist/umd/ReactInstantSearch.js +216 -162
- package/dist/umd/ReactInstantSearch.js.map +1 -1
- package/dist/umd/ReactInstantSearch.min.js +1 -1
- package/dist/umd/ReactInstantSearch.min.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
3
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
4
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
5
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
6
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
7
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
9
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
10
|
+
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); }
|
|
11
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
12
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
13
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
14
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
15
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
import { connectAutocomplete } from "instantsearch.js/es/connectors/index.js";
|
|
18
|
+
import { useId, useLayoutEffect, useRef, useState } from 'react';
|
|
19
|
+
import { useConnector, useInstantSearch } from 'react-instantsearch-core';
|
|
20
|
+
export function useAutocomplete(_ref) {
|
|
21
|
+
var indices = _ref.indices;
|
|
22
|
+
var _useConnector = useConnector(connectAutocomplete, {}),
|
|
23
|
+
connectorIndices = _useConnector.indices,
|
|
24
|
+
refine = _useConnector.refine;
|
|
25
|
+
var _useInstantSearch = useInstantSearch(),
|
|
26
|
+
setUiState = _useInstantSearch.setUiState;
|
|
27
|
+
var getElementId = createGetElementId(useId());
|
|
28
|
+
var rootRef = useRef(null);
|
|
29
|
+
var panelRef = useRef(null);
|
|
30
|
+
var _useState = useState(false),
|
|
31
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
32
|
+
isOpen = _useState2[0],
|
|
33
|
+
setIsOpen = _useState2[1];
|
|
34
|
+
var _useState3 = useState(undefined),
|
|
35
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
36
|
+
activeDescendent = _useState4[0],
|
|
37
|
+
setActiveDescendent = _useState4[1];
|
|
38
|
+
var items = indices.reduce(function (itemsAcc, index) {
|
|
39
|
+
var _connectorIndices$fin;
|
|
40
|
+
var indexItems = ((_connectorIndices$fin = connectorIndices.find(function (_ref2) {
|
|
41
|
+
var indexName = _ref2.indexName;
|
|
42
|
+
return index.indexName === indexName;
|
|
43
|
+
})) === null || _connectorIndices$fin === void 0 ? void 0 : _connectorIndices$fin.hits.reduce(function (indexItemsAcc, item, i) {
|
|
44
|
+
return _objectSpread(_objectSpread({}, indexItemsAcc), {}, _defineProperty({}, getElementId('item', index.indexName, i), {
|
|
45
|
+
item: item,
|
|
46
|
+
indexName: index.indexName,
|
|
47
|
+
getQuery: function getQuery() {
|
|
48
|
+
var _index$getQuery;
|
|
49
|
+
return ((_index$getQuery = index.getQuery) === null || _index$getQuery === void 0 ? void 0 : _index$getQuery.call(index, item)) || '';
|
|
50
|
+
},
|
|
51
|
+
getURL: function getURL() {
|
|
52
|
+
var _index$getURL;
|
|
53
|
+
return ((_index$getURL = index.getURL) === null || _index$getURL === void 0 ? void 0 : _index$getURL.call(index, item)) || '';
|
|
54
|
+
},
|
|
55
|
+
onSelect: index.onSelect
|
|
56
|
+
}));
|
|
57
|
+
}, {})) || {};
|
|
58
|
+
return _objectSpread(_objectSpread({}, itemsAcc), indexItems);
|
|
59
|
+
}, {});
|
|
60
|
+
useLayoutEffect(function () {
|
|
61
|
+
var onBodyClick = function onBodyClick(event) {
|
|
62
|
+
var _rootRef$current;
|
|
63
|
+
if ((_rootRef$current = rootRef.current) !== null && _rootRef$current !== void 0 && _rootRef$current.contains(event.target)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
setIsOpen(false);
|
|
67
|
+
};
|
|
68
|
+
document.body.addEventListener('click', onBodyClick);
|
|
69
|
+
return function () {
|
|
70
|
+
document.body.removeEventListener('click', onBodyClick);
|
|
71
|
+
};
|
|
72
|
+
}, [rootRef]);
|
|
73
|
+
var getNextActiveDescendent = function getNextActiveDescendent(key) {
|
|
74
|
+
if (!panelRef.current) {
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
var rows = _toConsumableArray(panelRef.current.querySelectorAll('[role="row"]'));
|
|
78
|
+
switch (key) {
|
|
79
|
+
case 'ArrowLeft':
|
|
80
|
+
case 'ArrowUp':
|
|
81
|
+
{
|
|
82
|
+
var prevIndex = rows.findIndex(function (row) {
|
|
83
|
+
return row.id === activeDescendent;
|
|
84
|
+
}) - 1;
|
|
85
|
+
if (rows[prevIndex]) {
|
|
86
|
+
return rows[prevIndex].id;
|
|
87
|
+
}
|
|
88
|
+
return rows[rows.length - 1].id;
|
|
89
|
+
}
|
|
90
|
+
case 'ArrowRight':
|
|
91
|
+
case 'ArrowDown':
|
|
92
|
+
{
|
|
93
|
+
var nextIndex = rows.findIndex(function (row) {
|
|
94
|
+
return row.id === activeDescendent;
|
|
95
|
+
}) + 1;
|
|
96
|
+
if (rows[nextIndex]) {
|
|
97
|
+
return rows[nextIndex].id;
|
|
98
|
+
}
|
|
99
|
+
return rows[0].id;
|
|
100
|
+
}
|
|
101
|
+
default:
|
|
102
|
+
return undefined;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
var submit = function submit() {
|
|
106
|
+
setIsOpen(false);
|
|
107
|
+
if (activeDescendent && items[activeDescendent]) {
|
|
108
|
+
var _items$activeDescende = items[activeDescendent],
|
|
109
|
+
_item = _items$activeDescende.item,
|
|
110
|
+
onSelect = _items$activeDescende.onSelect,
|
|
111
|
+
getQuery = _items$activeDescende.getQuery,
|
|
112
|
+
getURL = _items$activeDescende.getURL;
|
|
113
|
+
onSelect === null || onSelect === void 0 ? void 0 : onSelect({
|
|
114
|
+
item: _item,
|
|
115
|
+
getQuery: getQuery,
|
|
116
|
+
getURL: getURL,
|
|
117
|
+
setQuery: function setQuery(query) {
|
|
118
|
+
refine(query);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
setUiState(function (uiState) {
|
|
122
|
+
return _objectSpread(_objectSpread({}, uiState), {}, _defineProperty({}, getElementId('index'), {
|
|
123
|
+
query: getQuery()
|
|
124
|
+
}));
|
|
125
|
+
});
|
|
126
|
+
setActiveDescendent(undefined);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
getIndexProps: function getIndexProps() {
|
|
131
|
+
return {
|
|
132
|
+
indexId: getElementId('index')
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
getInputProps: function getInputProps() {
|
|
136
|
+
return {
|
|
137
|
+
id: getElementId('input'),
|
|
138
|
+
role: 'combobox',
|
|
139
|
+
'aria-autocomplete': 'list',
|
|
140
|
+
'aria-expanded': isOpen,
|
|
141
|
+
'aria-haspopup': 'grid',
|
|
142
|
+
'aria-controls': getElementId('panel'),
|
|
143
|
+
'aria-activedescendant': activeDescendent,
|
|
144
|
+
onFocus: function onFocus() {
|
|
145
|
+
return setIsOpen(true);
|
|
146
|
+
},
|
|
147
|
+
onKeyDown: function onKeyDown(event) {
|
|
148
|
+
if (event.key === 'Escape') {
|
|
149
|
+
setActiveDescendent(undefined);
|
|
150
|
+
setIsOpen(false);
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
switch (event.key) {
|
|
154
|
+
case 'ArrowLeft':
|
|
155
|
+
case 'ArrowUp':
|
|
156
|
+
case 'ArrowRight':
|
|
157
|
+
case 'ArrowDown':
|
|
158
|
+
setActiveDescendent(getNextActiveDescendent(event.key));
|
|
159
|
+
event.preventDefault();
|
|
160
|
+
break;
|
|
161
|
+
case 'Enter':
|
|
162
|
+
{
|
|
163
|
+
submit();
|
|
164
|
+
break;
|
|
165
|
+
}
|
|
166
|
+
case 'Tab':
|
|
167
|
+
setIsOpen(false);
|
|
168
|
+
break;
|
|
169
|
+
default:
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
onKeyUp: function onKeyUp(event) {
|
|
174
|
+
switch (event.key) {
|
|
175
|
+
case 'ArrowLeft':
|
|
176
|
+
case 'ArrowUp':
|
|
177
|
+
case 'ArrowRight':
|
|
178
|
+
case 'ArrowDown':
|
|
179
|
+
case 'Escape':
|
|
180
|
+
case 'Return':
|
|
181
|
+
event.preventDefault();
|
|
182
|
+
return;
|
|
183
|
+
default:
|
|
184
|
+
setActiveDescendent(undefined);
|
|
185
|
+
break;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
},
|
|
190
|
+
getItemProps: function getItemProps(item, index) {
|
|
191
|
+
var id = getElementId('item', item.__indexName, index);
|
|
192
|
+
return {
|
|
193
|
+
id: id,
|
|
194
|
+
role: 'row',
|
|
195
|
+
'aria-selected': id === activeDescendent,
|
|
196
|
+
onMouseEnter: function onMouseEnter() {
|
|
197
|
+
return setActiveDescendent(id);
|
|
198
|
+
},
|
|
199
|
+
onMouseLeave: function onMouseLeave() {
|
|
200
|
+
return setActiveDescendent(undefined);
|
|
201
|
+
},
|
|
202
|
+
onSelect: function onSelect() {
|
|
203
|
+
return submit();
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
},
|
|
207
|
+
getPanelProps: function getPanelProps() {
|
|
208
|
+
return {
|
|
209
|
+
ref: panelRef,
|
|
210
|
+
hidden: !isOpen,
|
|
211
|
+
id: getElementId('panel'),
|
|
212
|
+
role: 'grid',
|
|
213
|
+
'aria-labelledby': getElementId('input')
|
|
214
|
+
};
|
|
215
|
+
},
|
|
216
|
+
getRootProps: function getRootProps() {
|
|
217
|
+
return {
|
|
218
|
+
ref: rootRef
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
function createGetElementId(autocompleteId) {
|
|
224
|
+
return function getElementId() {
|
|
225
|
+
var prefix = 'autocomplete';
|
|
226
|
+
for (var _len = arguments.length, suffixes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
227
|
+
suffixes[_key] = arguments[_key];
|
|
228
|
+
}
|
|
229
|
+
return "".concat(prefix).concat(autocompleteId).concat(suffixes.join(':'));
|
|
230
|
+
};
|
|
231
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useStickToBottom: (options?: import("instantsearch-ui-components").StickToBottomOptions) => import("instantsearch-ui-components").StickToBottomInstance;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* !---------------------------------------------------------------------------------------------
|
|
2
|
+
* Copyright (c) StackBlitz. All rights reserved.
|
|
3
|
+
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
4
|
+
*--------------------------------------------------------------------------------------------*/
|
|
5
|
+
|
|
6
|
+
import { createStickToBottom } from 'instantsearch-ui-components';
|
|
7
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
8
|
+
export var useStickToBottom = createStickToBottom({
|
|
9
|
+
useCallback: useCallback,
|
|
10
|
+
useEffect: useEffect,
|
|
11
|
+
useMemo: useMemo,
|
|
12
|
+
useRef: useRef,
|
|
13
|
+
useState: useState
|
|
14
|
+
});
|
|
@@ -54,6 +54,7 @@ export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onR
|
|
|
54
54
|
onChange?: (event: React.ChangeEvent<HTMLInputElement> | React.CompositionEvent<HTMLInputElement>) => void;
|
|
55
55
|
formRef?: React.RefObject<HTMLFormElement | null>;
|
|
56
56
|
inputRef: React.RefObject<HTMLInputElement | null>;
|
|
57
|
+
inputProps?: Omit<React.ComponentProps<'input'>, 'placeholder' | 'value' | 'onChange' | 'onCompositionEnd' | 'autoFocus'>;
|
|
57
58
|
isSearchStalled: boolean;
|
|
58
59
|
value: string;
|
|
59
60
|
resetIconComponent?: React.JSXElementConstructor<IconProps>;
|
|
@@ -62,4 +63,4 @@ export type SearchBoxProps = Omit<React.ComponentProps<'div'>, 'onSubmit' | 'onR
|
|
|
62
63
|
classNames?: Partial<SearchBoxClassNames>;
|
|
63
64
|
translations: SearchBoxTranslations;
|
|
64
65
|
};
|
|
65
|
-
export declare function SearchBox({ formRef, inputRef, isSearchStalled, onChange, onReset, onSubmit, placeholder, value, autoFocus, resetIconComponent: ResetIcon, submitIconComponent: SubmitIcon, loadingIconComponent: LoadingIcon, classNames, translations, ...props }: SearchBoxProps): React.JSX.Element;
|
|
66
|
+
export declare function SearchBox({ formRef, inputRef, inputProps, isSearchStalled, onChange, onReset, onSubmit, placeholder, value, autoFocus, resetIconComponent: ResetIcon, submitIconComponent: SubmitIcon, loadingIconComponent: LoadingIcon, classNames, translations, ...props }: SearchBoxProps): React.JSX.Element;
|
package/dist/es/ui/SearchBox.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["formRef", "inputRef", "isSearchStalled", "onChange", "onReset", "onSubmit", "placeholder", "value", "autoFocus", "resetIconComponent", "submitIconComponent", "loadingIconComponent", "classNames", "translations"];
|
|
1
|
+
var _excluded = ["formRef", "inputRef", "inputProps", "isSearchStalled", "onChange", "onReset", "onSubmit", "placeholder", "value", "autoFocus", "resetIconComponent", "submitIconComponent", "loadingIconComponent", "classNames", "translations"];
|
|
2
2
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
3
3
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
4
4
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
@@ -66,6 +66,7 @@ function DefaultLoadingIcon(_ref5) {
|
|
|
66
66
|
export function SearchBox(_ref7) {
|
|
67
67
|
var formRef = _ref7.formRef,
|
|
68
68
|
inputRef = _ref7.inputRef,
|
|
69
|
+
inputProps = _ref7.inputProps,
|
|
69
70
|
isSearchStalled = _ref7.isSearchStalled,
|
|
70
71
|
onChange = _ref7.onChange,
|
|
71
72
|
onReset = _ref7.onReset,
|
|
@@ -112,9 +113,9 @@ export function SearchBox(_ref7) {
|
|
|
112
113
|
onSubmit: handleSubmit,
|
|
113
114
|
onReset: handleReset,
|
|
114
115
|
role: "search"
|
|
115
|
-
}, /*#__PURE__*/React.createElement("input", {
|
|
116
|
+
}, /*#__PURE__*/React.createElement("input", _extends({}, inputProps, {
|
|
116
117
|
ref: inputRef,
|
|
117
|
-
className: cx('ais-SearchBox-input', classNames.input),
|
|
118
|
+
className: cx('ais-SearchBox-input', classNames.input, inputProps === null || inputProps === void 0 ? void 0 : inputProps.className),
|
|
118
119
|
"aria-label": "Search",
|
|
119
120
|
autoComplete: "off",
|
|
120
121
|
autoCorrect: "off",
|
|
@@ -127,7 +128,7 @@ export function SearchBox(_ref7) {
|
|
|
127
128
|
onChange: onChange,
|
|
128
129
|
onCompositionEnd: onChange,
|
|
129
130
|
autoFocus: autoFocus
|
|
130
|
-
}), /*#__PURE__*/React.createElement("button", {
|
|
131
|
+
})), /*#__PURE__*/React.createElement("button", {
|
|
131
132
|
className: cx('ais-SearchBox-submit', classNames.submit),
|
|
132
133
|
type: "submit",
|
|
133
134
|
title: translations.submitButtonTitle
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { SearchIndexToolType, RecommendToolType } from 'instantsearch.js/es/lib/chat';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export { SearchIndexToolType, RecommendToolType };
|
|
4
|
+
import type { ChatProps as ChatUiProps, RecommendComponentProps, RecordWithObjectID, UserClientSideTool, UserClientSideTools } from 'instantsearch-ui-components';
|
|
5
|
+
import type { IndexUiState } from 'instantsearch.js';
|
|
6
|
+
import type { UIMessage } from 'instantsearch.js/es/lib/chat';
|
|
7
|
+
import type { UseChatOptions } from 'react-instantsearch-core';
|
|
8
|
+
export declare function createDefaultTools<TObject extends RecordWithObjectID>(itemComponent?: ItemComponent<TObject>, getSearchPageURL?: (nextUiState: IndexUiState) => string): UserClientSideTools;
|
|
9
|
+
type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
|
|
10
|
+
type UiProps = Pick<ChatUiProps, 'open' | 'headerProps' | 'toggleButtonProps' | 'messagesProps' | 'promptProps' | 'headerComponent' | 'promptComponent'>;
|
|
11
|
+
type UserToggleButtonProps = Omit<ChatUiProps['toggleButtonProps'], 'open' | 'onClick'>;
|
|
12
|
+
type UserHeaderProps = Omit<ChatUiProps['headerProps'], 'onClose'>;
|
|
13
|
+
type UserMessagesProps = Omit<ChatUiProps['messagesProps'], 'messages' | 'tools' | 'indexUiState' | 'setIndexUiState' | 'scrollRef' | 'contentRef'>;
|
|
14
|
+
type UserPromptProps = Omit<ChatUiProps['promptProps'], 'value' | 'onInput' | 'onSubmit' | 'headerComponent' | 'footerComponent'>;
|
|
15
|
+
export type Tool = UserClientSideTool;
|
|
16
|
+
export type Tools = UserClientSideTools;
|
|
17
|
+
export type ChatProps<TObject, TUiMessage extends UIMessage = UIMessage> = Omit<ChatUiProps, keyof UiProps> & UseChatOptions<TUiMessage> & {
|
|
18
|
+
itemComponent?: ItemComponent<TObject>;
|
|
19
|
+
tools?: UserClientSideTools;
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
getSearchPageURL?: (nextUiState: IndexUiState) => string;
|
|
22
|
+
toggleButtonProps?: UserToggleButtonProps;
|
|
23
|
+
headerProps?: UserHeaderProps;
|
|
24
|
+
messagesProps?: UserMessagesProps;
|
|
25
|
+
promptProps?: UserPromptProps;
|
|
26
|
+
toggleButtonComponent?: ChatUiProps['toggleButtonComponent'];
|
|
27
|
+
toggleButtonIconComponent?: ChatUiProps['toggleButtonProps']['toggleIconComponent'];
|
|
28
|
+
headerComponent?: ChatUiProps['headerComponent'];
|
|
29
|
+
headerTitleIconComponent?: ChatUiProps['headerProps']['titleIconComponent'];
|
|
30
|
+
headerCloseIconComponent?: ChatUiProps['headerProps']['closeIconComponent'];
|
|
31
|
+
headerMinimizeIconComponent?: ChatUiProps['headerProps']['minimizeIconComponent'];
|
|
32
|
+
headerMaximizeIconComponent?: ChatUiProps['headerProps']['maximizeIconComponent'];
|
|
33
|
+
messagesLoaderComponent?: ChatUiProps['messagesProps']['loaderComponent'];
|
|
34
|
+
messagesErrorComponent?: ChatUiProps['messagesProps']['errorComponent'];
|
|
35
|
+
promptComponent?: ChatUiProps['promptComponent'];
|
|
36
|
+
promptHeaderComponent?: ChatUiProps['promptProps']['headerComponent'];
|
|
37
|
+
promptFooterComponent?: ChatUiProps['promptProps']['footerComponent'];
|
|
38
|
+
actionsComponent?: ChatUiProps['messagesProps']['actionsComponent'];
|
|
39
|
+
translations?: Partial<{
|
|
40
|
+
prompt: ChatUiProps['promptProps']['translations'];
|
|
41
|
+
header: ChatUiProps['headerProps']['translations'];
|
|
42
|
+
messages: ChatUiProps['messagesProps']['translations'];
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
export declare function Chat<TObject extends RecordWithObjectID, TUiMessage extends UIMessage>({ tools: userTools, defaultOpen, toggleButtonProps, headerProps, messagesProps, promptProps, itemComponent, toggleButtonComponent, toggleButtonIconComponent, headerComponent, headerTitleIconComponent, headerCloseIconComponent, headerMinimizeIconComponent, headerMaximizeIconComponent, messagesLoaderComponent, messagesErrorComponent, promptComponent, promptHeaderComponent, promptFooterComponent, actionsComponent, classNames, translations, title, getSearchPageURL, ...props }: ChatProps<TObject, TUiMessage>): React.JSX.Element;
|
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
var _excluded = ["tools", "defaultOpen", "toggleButtonProps", "headerProps", "messagesProps", "promptProps", "itemComponent", "toggleButtonComponent", "toggleButtonIconComponent", "headerComponent", "headerTitleIconComponent", "headerCloseIconComponent", "headerMinimizeIconComponent", "headerMaximizeIconComponent", "messagesLoaderComponent", "messagesErrorComponent", "promptComponent", "promptHeaderComponent", "promptFooterComponent", "actionsComponent", "classNames", "translations", "title", "getSearchPageURL"];
|
|
2
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
6
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
7
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
8
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
9
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
10
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
11
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
12
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
13
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
15
|
+
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); }
|
|
16
|
+
import { lastAssistantMessageIsCompleteWithToolCalls } from 'ai';
|
|
17
|
+
import { createChatComponent } from 'instantsearch-ui-components';
|
|
18
|
+
import { SearchIndexToolType, RecommendToolType } from "instantsearch.js/es/lib/chat/index.js";
|
|
19
|
+
import React, { createElement, Fragment } from 'react';
|
|
20
|
+
import { useInstantSearch, useChat } from 'react-instantsearch-core';
|
|
21
|
+
import { useStickToBottom } from "../lib/useStickToBottom.js";
|
|
22
|
+
import { createCarouselTool } from "./chat/tools/SearchIndexTool.js";
|
|
23
|
+
export { SearchIndexToolType, RecommendToolType };
|
|
24
|
+
var ChatUiComponent = createChatComponent({
|
|
25
|
+
createElement: createElement,
|
|
26
|
+
Fragment: Fragment
|
|
27
|
+
});
|
|
28
|
+
export function createDefaultTools(itemComponent, getSearchPageURL) {
|
|
29
|
+
var _ref;
|
|
30
|
+
return _ref = {}, _defineProperty(_ref, SearchIndexToolType, createCarouselTool(true, itemComponent, getSearchPageURL)), _defineProperty(_ref, RecommendToolType, createCarouselTool(false, itemComponent, getSearchPageURL)), _ref;
|
|
31
|
+
}
|
|
32
|
+
export function Chat(_ref2) {
|
|
33
|
+
var userTools = _ref2.tools,
|
|
34
|
+
_ref2$defaultOpen = _ref2.defaultOpen,
|
|
35
|
+
defaultOpen = _ref2$defaultOpen === void 0 ? false : _ref2$defaultOpen,
|
|
36
|
+
toggleButtonProps = _ref2.toggleButtonProps,
|
|
37
|
+
headerProps = _ref2.headerProps,
|
|
38
|
+
messagesProps = _ref2.messagesProps,
|
|
39
|
+
promptProps = _ref2.promptProps,
|
|
40
|
+
itemComponent = _ref2.itemComponent,
|
|
41
|
+
toggleButtonComponent = _ref2.toggleButtonComponent,
|
|
42
|
+
toggleButtonIconComponent = _ref2.toggleButtonIconComponent,
|
|
43
|
+
headerComponent = _ref2.headerComponent,
|
|
44
|
+
headerTitleIconComponent = _ref2.headerTitleIconComponent,
|
|
45
|
+
headerCloseIconComponent = _ref2.headerCloseIconComponent,
|
|
46
|
+
headerMinimizeIconComponent = _ref2.headerMinimizeIconComponent,
|
|
47
|
+
headerMaximizeIconComponent = _ref2.headerMaximizeIconComponent,
|
|
48
|
+
messagesLoaderComponent = _ref2.messagesLoaderComponent,
|
|
49
|
+
messagesErrorComponent = _ref2.messagesErrorComponent,
|
|
50
|
+
promptComponent = _ref2.promptComponent,
|
|
51
|
+
promptHeaderComponent = _ref2.promptHeaderComponent,
|
|
52
|
+
promptFooterComponent = _ref2.promptFooterComponent,
|
|
53
|
+
actionsComponent = _ref2.actionsComponent,
|
|
54
|
+
classNames = _ref2.classNames,
|
|
55
|
+
_ref2$translations = _ref2.translations,
|
|
56
|
+
translations = _ref2$translations === void 0 ? {} : _ref2$translations,
|
|
57
|
+
title = _ref2.title,
|
|
58
|
+
getSearchPageURL = _ref2.getSearchPageURL,
|
|
59
|
+
props = _objectWithoutProperties(_ref2, _excluded);
|
|
60
|
+
var promptTranslations = translations.prompt,
|
|
61
|
+
headerTranslations = translations.header,
|
|
62
|
+
messagesTranslations = translations.messages;
|
|
63
|
+
var _useInstantSearch = useInstantSearch(),
|
|
64
|
+
indexUiState = _useInstantSearch.indexUiState,
|
|
65
|
+
setIndexUiState = _useInstantSearch.setIndexUiState;
|
|
66
|
+
var _React$useState = React.useState(defaultOpen),
|
|
67
|
+
_React$useState2 = _slicedToArray(_React$useState, 2),
|
|
68
|
+
open = _React$useState2[0],
|
|
69
|
+
setOpen = _React$useState2[1];
|
|
70
|
+
var _React$useState3 = React.useState(false),
|
|
71
|
+
_React$useState4 = _slicedToArray(_React$useState3, 2),
|
|
72
|
+
maximized = _React$useState4[0],
|
|
73
|
+
setMaximized = _React$useState4[1];
|
|
74
|
+
var _React$useState5 = React.useState(''),
|
|
75
|
+
_React$useState6 = _slicedToArray(_React$useState5, 2),
|
|
76
|
+
input = _React$useState6[0],
|
|
77
|
+
setInput = _React$useState6[1];
|
|
78
|
+
var _React$useState7 = React.useState(false),
|
|
79
|
+
_React$useState8 = _slicedToArray(_React$useState7, 2),
|
|
80
|
+
isClearing = _React$useState8[0],
|
|
81
|
+
setIsClearing = _React$useState8[1];
|
|
82
|
+
var promptRef = React.useRef(null);
|
|
83
|
+
var _useStickToBottom = useStickToBottom({
|
|
84
|
+
initial: 'smooth',
|
|
85
|
+
resize: 'smooth'
|
|
86
|
+
}),
|
|
87
|
+
scrollRef = _useStickToBottom.scrollRef,
|
|
88
|
+
contentRef = _useStickToBottom.contentRef,
|
|
89
|
+
scrollToBottom = _useStickToBottom.scrollToBottom,
|
|
90
|
+
isAtBottom = _useStickToBottom.isAtBottom;
|
|
91
|
+
var tools = React.useMemo(function () {
|
|
92
|
+
var defaults = createDefaultTools(itemComponent, getSearchPageURL);
|
|
93
|
+
return _objectSpread(_objectSpread({}, defaults), userTools);
|
|
94
|
+
}, [getSearchPageURL, itemComponent, userTools]);
|
|
95
|
+
var _useChat = useChat(_objectSpread(_objectSpread({}, props), {}, {
|
|
96
|
+
sendAutomaticallyWhen: lastAssistantMessageIsCompleteWithToolCalls,
|
|
97
|
+
onToolCall: function onToolCall(_ref3) {
|
|
98
|
+
var toolCall = _ref3.toolCall;
|
|
99
|
+
var tool = tools[toolCall.toolName];
|
|
100
|
+
if (!tool) {
|
|
101
|
+
if (process.env.NODE_ENV === 'development') {
|
|
102
|
+
throw new Error("No tool implementation found for \"".concat(toolCall.toolName, "\". Please provide a tool implementation in the `tools` prop."));
|
|
103
|
+
}
|
|
104
|
+
addToolResult({
|
|
105
|
+
output: "No tool implemented for \"".concat(toolCall.toolName, "\"."),
|
|
106
|
+
tool: toolCall.toolName,
|
|
107
|
+
toolCallId: toolCall.toolCallId
|
|
108
|
+
});
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (tool.onToolCall) {
|
|
112
|
+
var scopedAddToolResult = function scopedAddToolResult(_ref4) {
|
|
113
|
+
var output = _ref4.output;
|
|
114
|
+
return addToolResult({
|
|
115
|
+
output: output,
|
|
116
|
+
tool: toolCall.toolName,
|
|
117
|
+
toolCallId: toolCall.toolCallId
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
tool.onToolCall(_objectSpread(_objectSpread({}, toolCall), {}, {
|
|
121
|
+
addToolResult: scopedAddToolResult
|
|
122
|
+
}));
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
})),
|
|
126
|
+
messages = _useChat.messages,
|
|
127
|
+
sendMessage = _useChat.sendMessage,
|
|
128
|
+
addToolResult = _useChat.addToolResult,
|
|
129
|
+
status = _useChat.status,
|
|
130
|
+
regenerate = _useChat.regenerate,
|
|
131
|
+
stop = _useChat.stop,
|
|
132
|
+
setMessages = _useChat.setMessages,
|
|
133
|
+
clearError = _useChat.clearError,
|
|
134
|
+
error = _useChat.error;
|
|
135
|
+
var toolsForUi = React.useMemo(function () {
|
|
136
|
+
var result = {};
|
|
137
|
+
Object.entries(tools).forEach(function (_ref5) {
|
|
138
|
+
var _ref6 = _slicedToArray(_ref5, 2),
|
|
139
|
+
key = _ref6[0],
|
|
140
|
+
tool = _ref6[1];
|
|
141
|
+
result[key] = _objectSpread(_objectSpread({}, tool), {}, {
|
|
142
|
+
addToolResult: addToolResult
|
|
143
|
+
});
|
|
144
|
+
});
|
|
145
|
+
return result;
|
|
146
|
+
}, [tools, addToolResult]);
|
|
147
|
+
var handleClear = React.useCallback(function () {
|
|
148
|
+
if (!messages || messages.length === 0) return;
|
|
149
|
+
setIsClearing(true);
|
|
150
|
+
}, [messages]);
|
|
151
|
+
var handleClearTransitionEnd = React.useCallback(function () {
|
|
152
|
+
setMessages([]);
|
|
153
|
+
clearError();
|
|
154
|
+
setIsClearing(false);
|
|
155
|
+
}, [setMessages, clearError]);
|
|
156
|
+
if (process.env.NODE_ENV === 'development' && error) {
|
|
157
|
+
throw error;
|
|
158
|
+
}
|
|
159
|
+
return /*#__PURE__*/React.createElement(ChatUiComponent, {
|
|
160
|
+
title: title,
|
|
161
|
+
open: open,
|
|
162
|
+
maximized: maximized,
|
|
163
|
+
headerComponent: headerComponent,
|
|
164
|
+
promptComponent: promptComponent,
|
|
165
|
+
toggleButtonComponent: toggleButtonComponent,
|
|
166
|
+
toggleButtonProps: _objectSpread({
|
|
167
|
+
open: open,
|
|
168
|
+
onClick: function onClick() {
|
|
169
|
+
return setOpen(!open);
|
|
170
|
+
},
|
|
171
|
+
toggleIconComponent: toggleButtonIconComponent
|
|
172
|
+
}, toggleButtonProps),
|
|
173
|
+
headerProps: _objectSpread({
|
|
174
|
+
onClose: function onClose() {
|
|
175
|
+
return setOpen(false);
|
|
176
|
+
},
|
|
177
|
+
maximized: maximized,
|
|
178
|
+
onToggleMaximize: function onToggleMaximize() {
|
|
179
|
+
return setMaximized(!maximized);
|
|
180
|
+
},
|
|
181
|
+
onClear: handleClear,
|
|
182
|
+
canClear: Boolean(messages === null || messages === void 0 ? void 0 : messages.length) && !isClearing,
|
|
183
|
+
titleIconComponent: headerTitleIconComponent,
|
|
184
|
+
closeIconComponent: headerCloseIconComponent,
|
|
185
|
+
minimizeIconComponent: headerMinimizeIconComponent,
|
|
186
|
+
maximizeIconComponent: headerMaximizeIconComponent,
|
|
187
|
+
translations: headerTranslations
|
|
188
|
+
}, headerProps),
|
|
189
|
+
messagesProps: _objectSpread({
|
|
190
|
+
status: status,
|
|
191
|
+
onReload: function onReload(messageId) {
|
|
192
|
+
return regenerate({
|
|
193
|
+
messageId: messageId
|
|
194
|
+
});
|
|
195
|
+
},
|
|
196
|
+
onClose: function onClose() {
|
|
197
|
+
return setOpen(false);
|
|
198
|
+
},
|
|
199
|
+
messages: messages,
|
|
200
|
+
tools: toolsForUi,
|
|
201
|
+
indexUiState: indexUiState,
|
|
202
|
+
setIndexUiState: setIndexUiState,
|
|
203
|
+
isClearing: isClearing,
|
|
204
|
+
onClearTransitionEnd: handleClearTransitionEnd,
|
|
205
|
+
isScrollAtBottom: isAtBottom,
|
|
206
|
+
scrollRef: scrollRef,
|
|
207
|
+
contentRef: contentRef,
|
|
208
|
+
onScrollToBottom: scrollToBottom,
|
|
209
|
+
loaderComponent: messagesLoaderComponent,
|
|
210
|
+
errorComponent: messagesErrorComponent,
|
|
211
|
+
actionsComponent: actionsComponent,
|
|
212
|
+
translations: messagesTranslations
|
|
213
|
+
}, messagesProps),
|
|
214
|
+
promptProps: _objectSpread({
|
|
215
|
+
promptRef: promptRef,
|
|
216
|
+
status: status,
|
|
217
|
+
value: input,
|
|
218
|
+
translations: promptTranslations,
|
|
219
|
+
// Explicit event type is required to prevent TypeScript error
|
|
220
|
+
// where parameter would implicitly have 'any' type without type annotation
|
|
221
|
+
onInput: function onInput(event) {
|
|
222
|
+
setInput(event.currentTarget.value);
|
|
223
|
+
},
|
|
224
|
+
onSubmit: function onSubmit() {
|
|
225
|
+
sendMessage({
|
|
226
|
+
text: input
|
|
227
|
+
});
|
|
228
|
+
setInput('');
|
|
229
|
+
},
|
|
230
|
+
onStop: function onStop() {
|
|
231
|
+
stop();
|
|
232
|
+
},
|
|
233
|
+
headerComponent: promptHeaderComponent,
|
|
234
|
+
footerComponent: promptFooterComponent
|
|
235
|
+
}, promptProps),
|
|
236
|
+
classNames: classNames
|
|
237
|
+
});
|
|
238
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { RecommendComponentProps, RecordWithObjectID, UserClientSideTool } from 'instantsearch-ui-components';
|
|
2
|
+
import type { IndexUiState } from 'instantsearch.js';
|
|
3
|
+
type ItemComponent<TObject> = RecommendComponentProps<TObject>['itemComponent'];
|
|
4
|
+
declare function createCarouselTool<TObject extends RecordWithObjectID>(showViewAll: boolean, itemComponent?: ItemComponent<TObject>, getSearchPageURL?: (nextUiState: IndexUiState) => string): UserClientSideTool;
|
|
5
|
+
export { createCarouselTool };
|