instantsearch.js 4.80.0 → 4.81.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/cjs/connectors/chat/connectChat.js +200 -0
- package/cjs/connectors/index.js +7 -0
- package/cjs/connectors/index.umd.js +239 -0
- package/cjs/index.js +2 -2
- package/cjs/lib/chat/chat.js +177 -0
- package/cjs/lib/chat/index.js +27 -0
- package/cjs/lib/useStickToBottom.js +20 -0
- package/cjs/lib/version.js +1 -1
- package/cjs/templates/carousel/carousel.js +31 -4
- package/cjs/widgets/chat/chat.js +615 -0
- package/cjs/widgets/index/index.js +6 -1
- package/cjs/widgets/index.js +7 -0
- package/cjs/widgets/index.umd.js +267 -0
- package/dist/instantsearch.development.d.ts +75 -11
- package/dist/instantsearch.development.js +111 -57
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +75 -11
- package/dist/instantsearch.production.min.d.ts +75 -11
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/chat/connectChat.d.ts +413 -0
- package/es/connectors/chat/connectChat.js +194 -0
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +2 -0
- package/es/connectors/geo-search/connectGeoSearch.d.ts +1 -0
- package/es/connectors/hits/connectHits.d.ts +1 -0
- package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -0
- package/es/connectors/index.d.ts +1 -0
- package/es/connectors/index.js +2 -1
- package/es/connectors/index.umd.d.ts +39 -0
- package/es/connectors/index.umd.js +47 -0
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +1 -0
- package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.d.ts +1 -0
- package/es/connectors/looking-similar/connectLookingSimilar.d.ts +2 -0
- package/es/connectors/related-products/connectRelatedProducts.d.ts +2 -0
- package/es/connectors/trending-items/connectTrendingItems.d.ts +2 -0
- package/es/lib/chat/chat.d.ts +40 -0
- package/es/lib/chat/chat.js +166 -0
- package/es/lib/chat/index.d.ts +7 -0
- package/es/lib/chat/index.js +5 -0
- package/es/lib/useStickToBottom.d.ts +1 -0
- package/es/lib/useStickToBottom.js +14 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/templates/carousel/carousel.d.ts +10 -3
- package/es/templates/carousel/carousel.js +32 -5
- package/es/types/render-state.d.ts +2 -1
- package/es/types/templates.d.ts +1 -1
- package/es/types/widget.d.ts +2 -2
- package/es/widgets/chat/chat.d.ts +555 -0
- package/es/widgets/chat/chat.js +597 -0
- package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +3 -1
- package/es/widgets/geo-search/geo-search.d.ts +1 -0
- package/es/widgets/hits/hits.d.ts +1 -0
- package/es/widgets/index/index.js +6 -1
- package/es/widgets/index.d.ts +1 -0
- package/es/widgets/index.js +2 -1
- package/es/widgets/index.umd.d.ts +44 -0
- package/es/widgets/index.umd.js +51 -0
- package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -0
- package/es/widgets/looking-similar/looking-similar.d.ts +3 -1
- package/es/widgets/related-products/related-products.d.ts +3 -1
- package/es/widgets/trending-items/trending-items.d.ts +3 -1
- package/package.json +11 -7
|
@@ -0,0 +1,597 @@
|
|
|
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
|
+
var _excluded = ["container", "templates", "cssClasses", "resume", "tools", "getSearchPageURL"];
|
|
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
|
+
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; }
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
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; }
|
|
8
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
|
+
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); }
|
|
10
|
+
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); }
|
|
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 { ArrowRightIconComponent, ChevronLeftIconComponent, ChevronRightIconComponent, createButtonComponent, createChatComponent } from 'instantsearch-ui-components';
|
|
18
|
+
import { Fragment, h, render } from 'preact';
|
|
19
|
+
import { useMemo } from 'preact/hooks';
|
|
20
|
+
import TemplateComponent from "../../components/Template/Template.js";
|
|
21
|
+
import connectChat from "../../connectors/chat/connectChat.js";
|
|
22
|
+
import { SearchIndexToolType, RecommendToolType } from "../../lib/chat/index.js";
|
|
23
|
+
import { prepareTemplateProps } from "../../lib/templating/index.js";
|
|
24
|
+
import { useStickToBottom } from "../../lib/useStickToBottom.js";
|
|
25
|
+
import { getContainerNode, createDocumentationMessageGenerator } from "../../lib/utils/index.js";
|
|
26
|
+
import { carousel } from "../../templates/index.js";
|
|
27
|
+
var withUsage = createDocumentationMessageGenerator({
|
|
28
|
+
name: 'chat'
|
|
29
|
+
});
|
|
30
|
+
var Chat = createChatComponent({
|
|
31
|
+
createElement: h,
|
|
32
|
+
Fragment: Fragment
|
|
33
|
+
});
|
|
34
|
+
export { SearchIndexToolType, RecommendToolType };
|
|
35
|
+
function getDefinedProperties(obj) {
|
|
36
|
+
return Object.fromEntries(Object.entries(obj).filter(function (_ref) {
|
|
37
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
38
|
+
value = _ref2[1];
|
|
39
|
+
return value !== undefined;
|
|
40
|
+
}));
|
|
41
|
+
}
|
|
42
|
+
var _ref6 = h(ArrowRightIconComponent, {
|
|
43
|
+
createElement: h
|
|
44
|
+
});
|
|
45
|
+
var _ref7 = h(ChevronLeftIconComponent, {
|
|
46
|
+
createElement: h
|
|
47
|
+
});
|
|
48
|
+
var _ref8 = h(ChevronRightIconComponent, {
|
|
49
|
+
createElement: h
|
|
50
|
+
});
|
|
51
|
+
function createCarouselTool(showViewAll, templates, getSearchPageURL) {
|
|
52
|
+
var Button = createButtonComponent({
|
|
53
|
+
createElement: h
|
|
54
|
+
});
|
|
55
|
+
function SearchLayoutComponent(_ref3) {
|
|
56
|
+
var message = _ref3.message,
|
|
57
|
+
indexUiState = _ref3.indexUiState,
|
|
58
|
+
setIndexUiState = _ref3.setIndexUiState,
|
|
59
|
+
onClose = _ref3.onClose;
|
|
60
|
+
var input = message === null || message === void 0 ? void 0 : message.input;
|
|
61
|
+
var output = message === null || message === void 0 ? void 0 : message.output;
|
|
62
|
+
var items = (output === null || output === void 0 ? void 0 : output.hits) || [];
|
|
63
|
+
var MemoedHeaderComponent = useMemo(function () {
|
|
64
|
+
return function (props) {
|
|
65
|
+
return h(HeaderComponent, _extends({
|
|
66
|
+
nbHits: output === null || output === void 0 ? void 0 : output.nbHits,
|
|
67
|
+
query: input === null || input === void 0 ? void 0 : input.query,
|
|
68
|
+
hitsPerPage: items.length,
|
|
69
|
+
setIndexUiState: setIndexUiState,
|
|
70
|
+
indexUiState: indexUiState,
|
|
71
|
+
getSearchPageURL: getSearchPageURL,
|
|
72
|
+
onClose: onClose
|
|
73
|
+
}, props));
|
|
74
|
+
};
|
|
75
|
+
}, [items.length, input === null || input === void 0 ? void 0 : input.query, output === null || output === void 0 ? void 0 : output.nbHits, setIndexUiState, indexUiState, onClose]);
|
|
76
|
+
return carousel({
|
|
77
|
+
showNavigation: false,
|
|
78
|
+
templates: {
|
|
79
|
+
header: MemoedHeaderComponent
|
|
80
|
+
}
|
|
81
|
+
})({
|
|
82
|
+
items: items,
|
|
83
|
+
templates: {
|
|
84
|
+
item: function item(_ref4) {
|
|
85
|
+
var _item = _ref4.item;
|
|
86
|
+
return h(TemplateComponent, {
|
|
87
|
+
templates: templates,
|
|
88
|
+
templateKey: "item",
|
|
89
|
+
data: _item,
|
|
90
|
+
rootTagName: "fragment"
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
sendEvent: function sendEvent() {}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
function HeaderComponent(_ref5) {
|
|
98
|
+
var canScrollLeft = _ref5.canScrollLeft,
|
|
99
|
+
canScrollRight = _ref5.canScrollRight,
|
|
100
|
+
scrollLeft = _ref5.scrollLeft,
|
|
101
|
+
scrollRight = _ref5.scrollRight,
|
|
102
|
+
nbHits = _ref5.nbHits,
|
|
103
|
+
query = _ref5.query,
|
|
104
|
+
hitsPerPage = _ref5.hitsPerPage,
|
|
105
|
+
setIndexUiState = _ref5.setIndexUiState,
|
|
106
|
+
indexUiState = _ref5.indexUiState,
|
|
107
|
+
onClose = _ref5.onClose,
|
|
108
|
+
getSearchPageURL = _ref5.getSearchPageURL;
|
|
109
|
+
if ((hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) < 1) {
|
|
110
|
+
return null;
|
|
111
|
+
}
|
|
112
|
+
return h("div", {
|
|
113
|
+
className: "ais-ChatToolSearchIndexCarouselHeader"
|
|
114
|
+
}, h("div", {
|
|
115
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderResults"
|
|
116
|
+
}, nbHits && h("div", {
|
|
117
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderCount"
|
|
118
|
+
}, hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0, " of ", nbHits.toLocaleString(), " result", nbHits > 1 ? 's' : ''), showViewAll && h(Button, {
|
|
119
|
+
variant: "ghost",
|
|
120
|
+
size: "sm",
|
|
121
|
+
onClick: function onClick() {
|
|
122
|
+
if (!query) return;
|
|
123
|
+
var nextUiState = _objectSpread(_objectSpread({}, indexUiState), {}, {
|
|
124
|
+
query: query
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// If no main search page URL or we are on the search page, just update the state
|
|
128
|
+
if (!getSearchPageURL || getSearchPageURL && new URL(getSearchPageURL(nextUiState)).pathname === window.location.pathname) {
|
|
129
|
+
setIndexUiState(nextUiState);
|
|
130
|
+
onClose();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
// Navigate to different page
|
|
135
|
+
window.location.href = getSearchPageURL(nextUiState);
|
|
136
|
+
},
|
|
137
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderViewAll"
|
|
138
|
+
}, "View all", _ref6)), (hitsPerPage !== null && hitsPerPage !== void 0 ? hitsPerPage : 0) > 2 && h("div", {
|
|
139
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButtons"
|
|
140
|
+
}, h(Button, {
|
|
141
|
+
variant: "outline",
|
|
142
|
+
size: "sm",
|
|
143
|
+
iconOnly: true,
|
|
144
|
+
onClick: scrollLeft,
|
|
145
|
+
disabled: !canScrollLeft,
|
|
146
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
147
|
+
}, _ref7), h(Button, {
|
|
148
|
+
variant: "outline",
|
|
149
|
+
size: "sm",
|
|
150
|
+
iconOnly: true,
|
|
151
|
+
onClick: scrollRight,
|
|
152
|
+
disabled: !canScrollRight,
|
|
153
|
+
className: "ais-ChatToolSearchIndexCarouselHeaderScrollButton"
|
|
154
|
+
}, _ref8)));
|
|
155
|
+
}
|
|
156
|
+
return {
|
|
157
|
+
templates: {
|
|
158
|
+
layout: SearchLayoutComponent
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
function createDefaultTools(templates, getSearchPageURL) {
|
|
163
|
+
var _ref9;
|
|
164
|
+
return _ref9 = {}, _defineProperty(_ref9, SearchIndexToolType, createCarouselTool(true, templates, getSearchPageURL)), _defineProperty(_ref9, RecommendToolType, createCarouselTool(false, templates, getSearchPageURL)), _ref9;
|
|
165
|
+
}
|
|
166
|
+
function ChatWrapper(_ref10) {
|
|
167
|
+
var cssClasses = _ref10.cssClasses,
|
|
168
|
+
chatOpen = _ref10.chatOpen,
|
|
169
|
+
setChatOpen = _ref10.setChatOpen,
|
|
170
|
+
chatMessages = _ref10.chatMessages,
|
|
171
|
+
setChatMessages = _ref10.setChatMessages,
|
|
172
|
+
indexUiState = _ref10.indexUiState,
|
|
173
|
+
setIndexUiState = _ref10.setIndexUiState,
|
|
174
|
+
chatStatus = _ref10.chatStatus,
|
|
175
|
+
chatInput = _ref10.chatInput,
|
|
176
|
+
setChatInput = _ref10.setChatInput,
|
|
177
|
+
sendMessage = _ref10.sendMessage,
|
|
178
|
+
regenerate = _ref10.regenerate,
|
|
179
|
+
stop = _ref10.stop,
|
|
180
|
+
toolsForUi = _ref10.toolsForUi,
|
|
181
|
+
toggleButtonProps = _ref10.toggleButtonProps,
|
|
182
|
+
headerProps = _ref10.headerProps,
|
|
183
|
+
messagesProps = _ref10.messagesProps,
|
|
184
|
+
promptProps = _ref10.promptProps,
|
|
185
|
+
state = _ref10.state;
|
|
186
|
+
var _useStickToBottom = useStickToBottom({
|
|
187
|
+
initial: 'smooth',
|
|
188
|
+
resize: 'smooth'
|
|
189
|
+
}),
|
|
190
|
+
scrollRef = _useStickToBottom.scrollRef,
|
|
191
|
+
contentRef = _useStickToBottom.contentRef,
|
|
192
|
+
scrollToBottom = _useStickToBottom.scrollToBottom,
|
|
193
|
+
isAtBottom = _useStickToBottom.isAtBottom;
|
|
194
|
+
state.init();
|
|
195
|
+
var _state$use = state.use(false),
|
|
196
|
+
_state$use2 = _slicedToArray(_state$use, 2),
|
|
197
|
+
isClearing = _state$use2[0],
|
|
198
|
+
setIsClearing = _state$use2[1];
|
|
199
|
+
var _state$use3 = state.use(false),
|
|
200
|
+
_state$use4 = _slicedToArray(_state$use3, 2),
|
|
201
|
+
maximized = _state$use4[0],
|
|
202
|
+
setMaximized = _state$use4[1];
|
|
203
|
+
var onClear = function onClear() {
|
|
204
|
+
return setIsClearing(true);
|
|
205
|
+
};
|
|
206
|
+
var onClearTransitionEnd = function onClearTransitionEnd() {
|
|
207
|
+
setChatMessages([]);
|
|
208
|
+
setIsClearing(false);
|
|
209
|
+
};
|
|
210
|
+
return h(Chat, {
|
|
211
|
+
classNames: cssClasses,
|
|
212
|
+
open: chatOpen,
|
|
213
|
+
maximized: maximized,
|
|
214
|
+
toggleButtonComponent: toggleButtonProps.layoutComponent,
|
|
215
|
+
toggleButtonProps: {
|
|
216
|
+
open: chatOpen,
|
|
217
|
+
onClick: function onClick() {
|
|
218
|
+
return setChatOpen(!chatOpen);
|
|
219
|
+
},
|
|
220
|
+
toggleIconComponent: toggleButtonProps.iconComponent
|
|
221
|
+
},
|
|
222
|
+
headerComponent: headerProps.layoutComponent,
|
|
223
|
+
promptComponent: promptProps.layoutComponent,
|
|
224
|
+
headerProps: {
|
|
225
|
+
onClose: function onClose() {
|
|
226
|
+
return setChatOpen(false);
|
|
227
|
+
},
|
|
228
|
+
maximized: maximized,
|
|
229
|
+
onToggleMaximize: function onToggleMaximize() {
|
|
230
|
+
return setMaximized(!maximized);
|
|
231
|
+
},
|
|
232
|
+
onClear: onClear,
|
|
233
|
+
canClear: Boolean(chatMessages === null || chatMessages === void 0 ? void 0 : chatMessages.length) && !isClearing,
|
|
234
|
+
closeIconComponent: headerProps.closeIconComponent,
|
|
235
|
+
minimizeIconComponent: headerProps.minimizeIconComponent,
|
|
236
|
+
maximizeIconComponent: headerProps.maximizeIconComponent,
|
|
237
|
+
titleIconComponent: headerProps.titleIconComponent,
|
|
238
|
+
translations: headerProps.translations
|
|
239
|
+
},
|
|
240
|
+
messagesProps: {
|
|
241
|
+
status: chatStatus,
|
|
242
|
+
onReload: function onReload(messageId) {
|
|
243
|
+
return regenerate({
|
|
244
|
+
messageId: messageId
|
|
245
|
+
});
|
|
246
|
+
},
|
|
247
|
+
onClose: function onClose() {
|
|
248
|
+
return setChatOpen(false);
|
|
249
|
+
},
|
|
250
|
+
messages: chatMessages,
|
|
251
|
+
indexUiState: indexUiState,
|
|
252
|
+
isClearing: isClearing,
|
|
253
|
+
onClearTransitionEnd: onClearTransitionEnd,
|
|
254
|
+
isScrollAtBottom: isAtBottom,
|
|
255
|
+
scrollRef: scrollRef,
|
|
256
|
+
contentRef: contentRef,
|
|
257
|
+
onScrollToBottom: scrollToBottom,
|
|
258
|
+
setIndexUiState: setIndexUiState,
|
|
259
|
+
tools: toolsForUi,
|
|
260
|
+
loaderComponent: messagesProps.loaderComponent,
|
|
261
|
+
errorComponent: messagesProps.errorComponent,
|
|
262
|
+
actionsComponent: messagesProps.actionsComponent,
|
|
263
|
+
translations: messagesProps.translations
|
|
264
|
+
},
|
|
265
|
+
promptProps: {
|
|
266
|
+
promptRef: promptProps.promptRef,
|
|
267
|
+
status: chatStatus,
|
|
268
|
+
value: chatInput,
|
|
269
|
+
onInput: function onInput(event) {
|
|
270
|
+
setChatInput(event.currentTarget.value);
|
|
271
|
+
},
|
|
272
|
+
onSubmit: function onSubmit() {
|
|
273
|
+
sendMessage({
|
|
274
|
+
text: chatInput
|
|
275
|
+
});
|
|
276
|
+
setChatInput('');
|
|
277
|
+
},
|
|
278
|
+
onStop: function onStop() {
|
|
279
|
+
stop();
|
|
280
|
+
},
|
|
281
|
+
headerComponent: promptProps.headerComponent,
|
|
282
|
+
footerComponent: promptProps.footerComponent,
|
|
283
|
+
translations: promptProps.translations
|
|
284
|
+
}
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
var createRenderer = function createRenderer(_ref11) {
|
|
288
|
+
var renderState = _ref11.renderState,
|
|
289
|
+
cssClasses = _ref11.cssClasses,
|
|
290
|
+
containerNode = _ref11.containerNode,
|
|
291
|
+
templates = _ref11.templates,
|
|
292
|
+
tools = _ref11.tools;
|
|
293
|
+
var state = createLocalState();
|
|
294
|
+
var promptRef = {
|
|
295
|
+
current: null
|
|
296
|
+
};
|
|
297
|
+
return function (props, isFirstRendering) {
|
|
298
|
+
var _templates$header, _templates$header2, _templates$header3, _templates$header4, _templates$header5, _templates$header6, _templates$header7, _templates$header8, _templates$header9, _templates$header10, _templates$messages, _templates$messages2, _templates$messages3, _templates$messages4, _templates$messages5, _templates$messages6, _templates$prompt, _templates$prompt2, _templates$prompt3, _templates$prompt4, _templates$prompt5, _templates$prompt6, _templates$prompt7, _templates$prompt8, _templates$prompt9, _templates$toggleButt, _templates$toggleButt2;
|
|
299
|
+
var indexUiState = props.indexUiState,
|
|
300
|
+
input = props.input,
|
|
301
|
+
instantSearchInstance = props.instantSearchInstance,
|
|
302
|
+
messages = props.messages,
|
|
303
|
+
open = props.open,
|
|
304
|
+
sendMessage = props.sendMessage,
|
|
305
|
+
setIndexUiState = props.setIndexUiState,
|
|
306
|
+
setInput = props.setInput,
|
|
307
|
+
setMessages = props.setMessages,
|
|
308
|
+
setOpen = props.setOpen,
|
|
309
|
+
status = props.status,
|
|
310
|
+
error = props.error,
|
|
311
|
+
addToolResult = props.addToolResult,
|
|
312
|
+
regenerate = props.regenerate,
|
|
313
|
+
stop = props.stop;
|
|
314
|
+
if (process.env.NODE_ENV === 'development' && error) {
|
|
315
|
+
throw error;
|
|
316
|
+
}
|
|
317
|
+
if (isFirstRendering) {
|
|
318
|
+
renderState.templateProps = prepareTemplateProps({
|
|
319
|
+
defaultTemplates: {},
|
|
320
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
321
|
+
templates: templates
|
|
322
|
+
});
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
var toolsForUi = {};
|
|
326
|
+
Object.entries(tools).forEach(function (_ref12) {
|
|
327
|
+
var _ref13 = _slicedToArray(_ref12, 2),
|
|
328
|
+
key = _ref13[0],
|
|
329
|
+
tool = _ref13[1];
|
|
330
|
+
toolsForUi[key] = _objectSpread(_objectSpread({}, tool), {}, {
|
|
331
|
+
addToolResult: addToolResult,
|
|
332
|
+
layoutComponent: function layoutComponent(layoutComponentProps) {
|
|
333
|
+
return h(TemplateComponent, {
|
|
334
|
+
templates: tool.templates,
|
|
335
|
+
rootTagName: "fragment",
|
|
336
|
+
templateKey: "layout",
|
|
337
|
+
data: layoutComponentProps
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
var headerTemplateProps = prepareTemplateProps({
|
|
343
|
+
defaultTemplates: {},
|
|
344
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
345
|
+
templates: templates.header
|
|
346
|
+
});
|
|
347
|
+
var headerLayoutComponent = (_templates$header = templates.header) !== null && _templates$header !== void 0 && _templates$header.layout ? function (headerProps) {
|
|
348
|
+
return h(TemplateComponent, _extends({}, headerTemplateProps, {
|
|
349
|
+
templateKey: "layout",
|
|
350
|
+
rootTagName: "div",
|
|
351
|
+
data: headerProps
|
|
352
|
+
}));
|
|
353
|
+
} : undefined;
|
|
354
|
+
var headerCloseIconComponent = (_templates$header2 = templates.header) !== null && _templates$header2 !== void 0 && _templates$header2.closeIcon ? function () {
|
|
355
|
+
return h(TemplateComponent, _extends({}, headerTemplateProps, {
|
|
356
|
+
templateKey: "closeIcon",
|
|
357
|
+
rootTagName: "span"
|
|
358
|
+
}));
|
|
359
|
+
} : undefined;
|
|
360
|
+
var headerMinimizeIconComponent = (_templates$header3 = templates.header) !== null && _templates$header3 !== void 0 && _templates$header3.minimizeIcon ? function () {
|
|
361
|
+
return h(TemplateComponent, _extends({}, headerTemplateProps, {
|
|
362
|
+
templateKey: "minimizeIcon",
|
|
363
|
+
rootTagName: "span"
|
|
364
|
+
}));
|
|
365
|
+
} : undefined;
|
|
366
|
+
var headerMaximizeIconComponent = (_templates$header4 = templates.header) !== null && _templates$header4 !== void 0 && _templates$header4.maximizeIcon ? function (_ref14) {
|
|
367
|
+
var maximized = _ref14.maximized;
|
|
368
|
+
return h(TemplateComponent, _extends({}, headerTemplateProps, {
|
|
369
|
+
templateKey: "maximizeIcon",
|
|
370
|
+
rootTagName: "span",
|
|
371
|
+
data: {
|
|
372
|
+
maximized: maximized
|
|
373
|
+
}
|
|
374
|
+
}));
|
|
375
|
+
} : undefined;
|
|
376
|
+
var headerTitleIconComponent = (_templates$header5 = templates.header) !== null && _templates$header5 !== void 0 && _templates$header5.titleIcon ? function () {
|
|
377
|
+
return h(TemplateComponent, _extends({}, headerTemplateProps, {
|
|
378
|
+
templateKey: "titleIcon",
|
|
379
|
+
rootTagName: "span"
|
|
380
|
+
}));
|
|
381
|
+
} : undefined;
|
|
382
|
+
var headerTranslations = getDefinedProperties({
|
|
383
|
+
title: (_templates$header6 = templates.header) === null || _templates$header6 === void 0 ? void 0 : _templates$header6.titleText,
|
|
384
|
+
minimizeLabel: (_templates$header7 = templates.header) === null || _templates$header7 === void 0 ? void 0 : _templates$header7.minimizeLabelText,
|
|
385
|
+
maximizeLabel: (_templates$header8 = templates.header) === null || _templates$header8 === void 0 ? void 0 : _templates$header8.maximizeLabelText,
|
|
386
|
+
closeLabel: (_templates$header9 = templates.header) === null || _templates$header9 === void 0 ? void 0 : _templates$header9.closeLabelText,
|
|
387
|
+
clearLabel: (_templates$header10 = templates.header) === null || _templates$header10 === void 0 ? void 0 : _templates$header10.clearLabelText
|
|
388
|
+
});
|
|
389
|
+
var messagesTemplateProps = prepareTemplateProps({
|
|
390
|
+
defaultTemplates: {},
|
|
391
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
392
|
+
templates: templates.messages
|
|
393
|
+
});
|
|
394
|
+
var messagesLoaderComponent = (_templates$messages = templates.messages) !== null && _templates$messages !== void 0 && _templates$messages.loader ? function (loaderProps) {
|
|
395
|
+
return h(TemplateComponent, _extends({}, messagesTemplateProps, {
|
|
396
|
+
templateKey: "loader",
|
|
397
|
+
rootTagName: "div",
|
|
398
|
+
data: loaderProps
|
|
399
|
+
}));
|
|
400
|
+
} : undefined;
|
|
401
|
+
var messagesErrorComponent = (_templates$messages2 = templates.messages) !== null && _templates$messages2 !== void 0 && _templates$messages2.error ? function (errorProps) {
|
|
402
|
+
return h(TemplateComponent, _extends({}, messagesTemplateProps, {
|
|
403
|
+
templateKey: "error",
|
|
404
|
+
rootTagName: "div",
|
|
405
|
+
data: errorProps
|
|
406
|
+
}));
|
|
407
|
+
} : undefined;
|
|
408
|
+
var messagesTranslations = getDefinedProperties({
|
|
409
|
+
scrollToBottomLabel: (_templates$messages3 = templates.messages) === null || _templates$messages3 === void 0 ? void 0 : _templates$messages3.scrollToBottomLabelText,
|
|
410
|
+
loaderText: (_templates$messages4 = templates.messages) === null || _templates$messages4 === void 0 ? void 0 : _templates$messages4.loaderText,
|
|
411
|
+
copyToClipboardLabel: (_templates$messages5 = templates.messages) === null || _templates$messages5 === void 0 ? void 0 : _templates$messages5.copyToClipboardLabelText,
|
|
412
|
+
regenerateLabel: (_templates$messages6 = templates.messages) === null || _templates$messages6 === void 0 ? void 0 : _templates$messages6.regenerateLabelText
|
|
413
|
+
});
|
|
414
|
+
var promptTemplateProps = prepareTemplateProps({
|
|
415
|
+
defaultTemplates: {},
|
|
416
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
417
|
+
templates: templates.prompt
|
|
418
|
+
});
|
|
419
|
+
var promptLayoutComponent = (_templates$prompt = templates.prompt) !== null && _templates$prompt !== void 0 && _templates$prompt.layout ? function (promptProps) {
|
|
420
|
+
return h(TemplateComponent, _extends({}, promptTemplateProps, {
|
|
421
|
+
templateKey: "layout",
|
|
422
|
+
rootTagName: "div",
|
|
423
|
+
data: promptProps
|
|
424
|
+
}));
|
|
425
|
+
} : undefined;
|
|
426
|
+
var promptHeaderComponent = (_templates$prompt2 = templates.prompt) !== null && _templates$prompt2 !== void 0 && _templates$prompt2.header ? function () {
|
|
427
|
+
return h(TemplateComponent, _extends({}, promptTemplateProps, {
|
|
428
|
+
templateKey: "header",
|
|
429
|
+
rootTagName: "fragment"
|
|
430
|
+
}));
|
|
431
|
+
} : undefined;
|
|
432
|
+
var promptFooterComponent = (_templates$prompt3 = templates.prompt) !== null && _templates$prompt3 !== void 0 && _templates$prompt3.footer ? function () {
|
|
433
|
+
return h(TemplateComponent, _extends({}, promptTemplateProps, {
|
|
434
|
+
templateKey: "footer",
|
|
435
|
+
rootTagName: "fragment"
|
|
436
|
+
}));
|
|
437
|
+
} : undefined;
|
|
438
|
+
var promptTranslations = getDefinedProperties({
|
|
439
|
+
textareaLabel: (_templates$prompt4 = templates.prompt) === null || _templates$prompt4 === void 0 ? void 0 : _templates$prompt4.textareaLabelText,
|
|
440
|
+
textareaPlaceholder: (_templates$prompt5 = templates.prompt) === null || _templates$prompt5 === void 0 ? void 0 : _templates$prompt5.textareaPlaceholderText,
|
|
441
|
+
emptyMessageTooltip: (_templates$prompt6 = templates.prompt) === null || _templates$prompt6 === void 0 ? void 0 : _templates$prompt6.emptyMessageTooltipText,
|
|
442
|
+
stopResponseTooltip: (_templates$prompt7 = templates.prompt) === null || _templates$prompt7 === void 0 ? void 0 : _templates$prompt7.stopResponseTooltipText,
|
|
443
|
+
sendMessageTooltip: (_templates$prompt8 = templates.prompt) === null || _templates$prompt8 === void 0 ? void 0 : _templates$prompt8.sendMessageTooltipText,
|
|
444
|
+
disclaimer: (_templates$prompt9 = templates.prompt) === null || _templates$prompt9 === void 0 ? void 0 : _templates$prompt9.disclaimerText
|
|
445
|
+
});
|
|
446
|
+
var actionsComponent = templates.actions ? function (actionsProps) {
|
|
447
|
+
return h(TemplateComponent, _extends({}, renderState.templateProps, {
|
|
448
|
+
templateKey: "actions",
|
|
449
|
+
rootTagName: "div",
|
|
450
|
+
data: actionsProps
|
|
451
|
+
}));
|
|
452
|
+
} : undefined;
|
|
453
|
+
var toggleButtonTemplateProps = prepareTemplateProps({
|
|
454
|
+
defaultTemplates: {},
|
|
455
|
+
templatesConfig: instantSearchInstance.templatesConfig,
|
|
456
|
+
templates: templates.toggleButton
|
|
457
|
+
});
|
|
458
|
+
var toggleButtonLayoutComponent = (_templates$toggleButt = templates.toggleButton) !== null && _templates$toggleButt !== void 0 && _templates$toggleButt.layout ? function (toggleButtonProps) {
|
|
459
|
+
return h(TemplateComponent, _extends({}, toggleButtonTemplateProps, {
|
|
460
|
+
templateKey: "layout",
|
|
461
|
+
rootTagName: "button",
|
|
462
|
+
data: toggleButtonProps
|
|
463
|
+
}));
|
|
464
|
+
} : undefined;
|
|
465
|
+
var toggleButtonIconComponent = (_templates$toggleButt2 = templates.toggleButton) !== null && _templates$toggleButt2 !== void 0 && _templates$toggleButt2.icon ? function (_ref15) {
|
|
466
|
+
var isOpen = _ref15.isOpen;
|
|
467
|
+
return h(TemplateComponent, _extends({}, toggleButtonTemplateProps, {
|
|
468
|
+
templateKey: "icon",
|
|
469
|
+
rootTagName: "span",
|
|
470
|
+
data: {
|
|
471
|
+
isOpen: isOpen
|
|
472
|
+
}
|
|
473
|
+
}));
|
|
474
|
+
} : undefined;
|
|
475
|
+
state.subscribe(rerender);
|
|
476
|
+
function rerender() {
|
|
477
|
+
render(h(ChatWrapper, {
|
|
478
|
+
cssClasses: cssClasses,
|
|
479
|
+
chatOpen: open,
|
|
480
|
+
setChatOpen: setOpen,
|
|
481
|
+
chatMessages: messages,
|
|
482
|
+
setChatMessages: setMessages,
|
|
483
|
+
indexUiState: indexUiState,
|
|
484
|
+
setIndexUiState: setIndexUiState,
|
|
485
|
+
chatStatus: status,
|
|
486
|
+
chatInput: input,
|
|
487
|
+
setChatInput: setInput,
|
|
488
|
+
sendMessage: sendMessage,
|
|
489
|
+
regenerate: regenerate,
|
|
490
|
+
stop: stop,
|
|
491
|
+
toolsForUi: toolsForUi,
|
|
492
|
+
toggleButtonProps: {
|
|
493
|
+
layoutComponent: toggleButtonLayoutComponent,
|
|
494
|
+
iconComponent: toggleButtonIconComponent
|
|
495
|
+
},
|
|
496
|
+
headerProps: {
|
|
497
|
+
layoutComponent: headerLayoutComponent,
|
|
498
|
+
closeIconComponent: headerCloseIconComponent,
|
|
499
|
+
minimizeIconComponent: headerMinimizeIconComponent,
|
|
500
|
+
maximizeIconComponent: headerMaximizeIconComponent,
|
|
501
|
+
titleIconComponent: headerTitleIconComponent,
|
|
502
|
+
translations: headerTranslations
|
|
503
|
+
},
|
|
504
|
+
messagesProps: {
|
|
505
|
+
loaderComponent: messagesLoaderComponent,
|
|
506
|
+
errorComponent: messagesErrorComponent,
|
|
507
|
+
actionsComponent: actionsComponent,
|
|
508
|
+
translations: messagesTranslations
|
|
509
|
+
},
|
|
510
|
+
promptProps: {
|
|
511
|
+
layoutComponent: promptLayoutComponent,
|
|
512
|
+
headerComponent: promptHeaderComponent,
|
|
513
|
+
footerComponent: promptFooterComponent,
|
|
514
|
+
translations: promptTranslations,
|
|
515
|
+
promptRef: promptRef
|
|
516
|
+
},
|
|
517
|
+
state: state
|
|
518
|
+
}), containerNode);
|
|
519
|
+
}
|
|
520
|
+
rerender();
|
|
521
|
+
};
|
|
522
|
+
};
|
|
523
|
+
var defaultTemplates = {
|
|
524
|
+
item: function item(_item2) {
|
|
525
|
+
return JSON.stringify(_item2, null, 2);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
export default (function chat(widgetParams) {
|
|
529
|
+
var _ref16 = widgetParams || {},
|
|
530
|
+
container = _ref16.container,
|
|
531
|
+
_ref16$templates = _ref16.templates,
|
|
532
|
+
userTemplates = _ref16$templates === void 0 ? {} : _ref16$templates,
|
|
533
|
+
_ref16$cssClasses = _ref16.cssClasses,
|
|
534
|
+
cssClasses = _ref16$cssClasses === void 0 ? {} : _ref16$cssClasses,
|
|
535
|
+
_ref16$resume = _ref16.resume,
|
|
536
|
+
resume = _ref16$resume === void 0 ? false : _ref16$resume,
|
|
537
|
+
userTools = _ref16.tools,
|
|
538
|
+
getSearchPageURL = _ref16.getSearchPageURL,
|
|
539
|
+
options = _objectWithoutProperties(_ref16, _excluded);
|
|
540
|
+
if (!container) {
|
|
541
|
+
throw new Error(withUsage('The `container` option is required.'));
|
|
542
|
+
}
|
|
543
|
+
var containerNode = getContainerNode(container);
|
|
544
|
+
var templates = _objectSpread(_objectSpread({}, defaultTemplates), userTemplates);
|
|
545
|
+
var defaultTools = createDefaultTools(templates, getSearchPageURL);
|
|
546
|
+
var tools = _objectSpread(_objectSpread({}, defaultTools), userTools);
|
|
547
|
+
var specializedRenderer = createRenderer({
|
|
548
|
+
containerNode: containerNode,
|
|
549
|
+
cssClasses: cssClasses,
|
|
550
|
+
renderState: {},
|
|
551
|
+
templates: templates,
|
|
552
|
+
tools: tools
|
|
553
|
+
});
|
|
554
|
+
var makeWidget = connectChat(specializedRenderer, function () {
|
|
555
|
+
return render(null, containerNode);
|
|
556
|
+
});
|
|
557
|
+
return _objectSpread(_objectSpread({}, makeWidget(_objectSpread({
|
|
558
|
+
resume: resume,
|
|
559
|
+
tools: tools
|
|
560
|
+
}, options))), {}, {
|
|
561
|
+
$$widgetType: 'ais.chat'
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
function createLocalState() {
|
|
565
|
+
var state = [];
|
|
566
|
+
var subscriptions = new Set();
|
|
567
|
+
var cursor = 0;
|
|
568
|
+
function use(initialValue) {
|
|
569
|
+
var index = cursor++;
|
|
570
|
+
if (state[index] === undefined) {
|
|
571
|
+
state[index] = initialValue;
|
|
572
|
+
}
|
|
573
|
+
return [state[index], function (value) {
|
|
574
|
+
var prev = state[index];
|
|
575
|
+
if (prev === value) {
|
|
576
|
+
return prev;
|
|
577
|
+
}
|
|
578
|
+
state[index] = value;
|
|
579
|
+
subscriptions.forEach(function (fn) {
|
|
580
|
+
return fn();
|
|
581
|
+
});
|
|
582
|
+
return value;
|
|
583
|
+
}];
|
|
584
|
+
}
|
|
585
|
+
return {
|
|
586
|
+
init: function init() {
|
|
587
|
+
cursor = 0;
|
|
588
|
+
},
|
|
589
|
+
subscribe: function subscribe(fn) {
|
|
590
|
+
subscriptions.add(fn);
|
|
591
|
+
return function () {
|
|
592
|
+
return subscriptions.delete(fn);
|
|
593
|
+
};
|
|
594
|
+
},
|
|
595
|
+
use: use
|
|
596
|
+
};
|
|
597
|
+
}
|
|
@@ -52,6 +52,7 @@ declare const _default: <THit extends NonNullable<object> = BaseHit>(widgetParam
|
|
|
52
52
|
init(initOptions: import("../../types").InitOptions): void;
|
|
53
53
|
render(renderOptions: import("../../types").RenderOptions): void;
|
|
54
54
|
getRenderState(renderState: {
|
|
55
|
+
[x: string]: unknown;
|
|
55
56
|
answers?: import("../../types").WidgetRenderState<import("../../connectors/answers/connectAnswers").AnswersRenderState, import("../../connectors/answers/connectAnswers").AnswersConnectorParams> | undefined;
|
|
56
57
|
autocomplete?: import("../../types").WidgetRenderState<import("../../connectors/autocomplete/connectAutocomplete").AutocompleteRenderState, import("../../connectors/autocomplete/connectAutocomplete").AutocompleteConnectorParams> | undefined;
|
|
57
58
|
breadcrumb?: {
|
|
@@ -96,6 +97,7 @@ declare const _default: <THit extends NonNullable<object> = BaseHit>(widgetParam
|
|
|
96
97
|
analytics?: import("../../types").WidgetRenderState<Record<string, unknown>, import("../analytics/analytics").AnalyticsWidgetParams> | undefined;
|
|
97
98
|
places?: import("../../types").WidgetRenderState<Record<string, unknown>, import("../places/places").PlacesWidgetParams> | undefined;
|
|
98
99
|
}): {
|
|
100
|
+
[x: string]: unknown;
|
|
99
101
|
answers?: import("../../types").WidgetRenderState<import("../../connectors/answers/connectAnswers").AnswersRenderState, import("../../connectors/answers/connectAnswers").AnswersConnectorParams> | undefined;
|
|
100
102
|
autocomplete?: import("../../types").WidgetRenderState<import("../../connectors/autocomplete/connectAutocomplete").AutocompleteRenderState, import("../../connectors/autocomplete/connectAutocomplete").AutocompleteConnectorParams> | undefined;
|
|
101
103
|
breadcrumb?: {
|
|
@@ -154,7 +156,7 @@ declare const _default: <THit extends NonNullable<object> = BaseHit>(widgetParam
|
|
|
154
156
|
breadcrumb: {
|
|
155
157
|
[rootAttribute: string]: import("../../types").WidgetRenderState<import("../../connectors/breadcrumb/connectBreadcrumb").BreadcrumbRenderState, import("../../connectors/breadcrumb/connectBreadcrumb").BreadcrumbConnectorParams>;
|
|
156
158
|
};
|
|
157
|
-
} & {
|
|
159
|
+
} & Record<string, unknown> & {
|
|
158
160
|
clearRefinements: import("../../types").WidgetRenderState<import("../../connectors/clear-refinements/connectClearRefinements").ClearRefinementsRenderState, import("../../connectors/clear-refinements/connectClearRefinements").ClearRefinementsConnectorParams>;
|
|
159
161
|
} & {
|
|
160
162
|
configure: import("../../types").WidgetRenderState<import("../../connectors/configure/connectConfigure").ConfigureRenderState, import("../../connectors/configure/connectConfigure").ConfigureConnectorParams>;
|
|
@@ -217,6 +217,7 @@ declare const _default: <THit extends GeoHit = GeoHit>(widgetParams: GeoSearchWi
|
|
|
217
217
|
} & GeoSearchConnectorParams<THit>;
|
|
218
218
|
};
|
|
219
219
|
getRenderState(renderState: {
|
|
220
|
+
[x: string]: unknown;
|
|
220
221
|
answers?: import("../../types").WidgetRenderState<import("../../connectors/answers/connectAnswers").AnswersRenderState, import("../../connectors/answers/connectAnswers").AnswersConnectorParams> | undefined;
|
|
221
222
|
autocomplete?: import("../../types").WidgetRenderState<import("../../connectors/autocomplete/connectAutocomplete").AutocompleteRenderState, import("../../connectors/autocomplete/connectAutocomplete").AutocompleteConnectorParams> | undefined;
|
|
222
223
|
breadcrumb?: {
|
|
@@ -51,6 +51,7 @@ declare const _default: <THit extends NonNullable<object> = BaseHit>(widgetParam
|
|
|
51
51
|
init(initOptions: import("../../types").InitOptions): void;
|
|
52
52
|
render(renderOptions: import("../../types").RenderOptions): void;
|
|
53
53
|
getRenderState(renderState: {
|
|
54
|
+
[x: string]: unknown;
|
|
54
55
|
answers?: import("../../types").WidgetRenderState<import("../../connectors/answers/connectAnswers").AnswersRenderState, import("../../connectors/answers/connectAnswers").AnswersConnectorParams> | undefined;
|
|
55
56
|
autocomplete?: import("../../types").WidgetRenderState<import("../../connectors/autocomplete/connectAutocomplete").AutocompleteRenderState, import("../../connectors/autocomplete/connectAutocomplete").AutocompleteConnectorParams> | undefined;
|
|
56
57
|
breadcrumb?: {
|
|
@@ -565,7 +565,9 @@ var index = function index(widgetParams) {
|
|
|
565
565
|
// This makes sure `render` is never called with `results` being `null`.
|
|
566
566
|
// If it's an isolated index without an index name, we render all widgets,
|
|
567
567
|
// as there are no results to display for the isolated index itself.
|
|
568
|
-
var widgetsToRender = this.getResults() || (_derivedHelper2 = derivedHelper) !== null && _derivedHelper2 !== void 0 && _derivedHelper2.lastRecommendResults || isolated && !indexName ? localWidgets : localWidgets.filter(
|
|
568
|
+
var widgetsToRender = this.getResults() || (_derivedHelper2 = derivedHelper) !== null && _derivedHelper2 !== void 0 && _derivedHelper2.lastRecommendResults || isolated && !indexName ? localWidgets : localWidgets.filter(function (widget) {
|
|
569
|
+
return widget.shouldRender;
|
|
570
|
+
});
|
|
569
571
|
widgetsToRender = widgetsToRender.filter(function (widget) {
|
|
570
572
|
if (!widget.shouldRender) {
|
|
571
573
|
return true;
|
|
@@ -642,6 +644,9 @@ var index = function index(widgetParams) {
|
|
|
642
644
|
initialSearchParameters: searchParameters
|
|
643
645
|
});
|
|
644
646
|
},
|
|
647
|
+
shouldRender: function shouldRender() {
|
|
648
|
+
return true;
|
|
649
|
+
},
|
|
645
650
|
refreshUiState: function refreshUiState() {
|
|
646
651
|
localUiState = getLocalWidgetsUiState(localWidgets, {
|
|
647
652
|
searchParameters: this.getHelper().state,
|
package/es/widgets/index.d.ts
CHANGED
|
@@ -41,3 +41,4 @@ export { default as trendingItems } from './trending-items/trending-items';
|
|
|
41
41
|
export { default as voiceSearch } from './voice-search/voice-search';
|
|
42
42
|
export { default as frequentlyBoughtTogether } from './frequently-bought-together/frequently-bought-together';
|
|
43
43
|
export { default as lookingSimilar } from './looking-similar/looking-similar';
|
|
44
|
+
export { default as chat } from './chat/chat';
|