algolia-experiences 1.8.5 → 1.8.7
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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! algolia-experiences 1.8.
|
|
1
|
+
/*! algolia-experiences 1.8.7 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
|
|
2
2
|
(function (factory) {
|
|
3
3
|
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
4
|
factory();
|
|
@@ -9981,7 +9981,7 @@
|
|
|
9981
9981
|
};
|
|
9982
9982
|
}
|
|
9983
9983
|
|
|
9984
|
-
var version = '4.
|
|
9984
|
+
var version = '4.99.0';
|
|
9985
9985
|
|
|
9986
9986
|
function getServerResults(entry) {
|
|
9987
9987
|
var _entry_compositionFeedsResults;
|
|
@@ -13154,6 +13154,41 @@
|
|
|
13154
13154
|
};
|
|
13155
13155
|
};
|
|
13156
13156
|
|
|
13157
|
+
// Centralizes the "open the chat from an entry point" behavior shared by the
|
|
13158
|
+
// SearchBox AI button, the Autocomplete AI button, prompt suggestions, and any
|
|
13159
|
+
// future entry point. The chat is always opened; the message is only sent when
|
|
13160
|
+
// it is non-empty and the chat is not already processing a message.
|
|
13161
|
+
// Returns true when a message was submitted, so callers can clear their input.
|
|
13162
|
+
function openChat(chatRenderState) {
|
|
13163
|
+
var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, message = _ref.message, referer = _ref.referer;
|
|
13164
|
+
var _ref1;
|
|
13165
|
+
var _chatRenderState_setOpen;
|
|
13166
|
+
if (!chatRenderState) {
|
|
13167
|
+
return false;
|
|
13168
|
+
}
|
|
13169
|
+
(_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
|
|
13170
|
+
var trimmed = (_ref1 = message === null || message === void 0 ? void 0 : message.trim()) !== null && _ref1 !== void 0 ? _ref1 : '';
|
|
13171
|
+
if (!trimmed) {
|
|
13172
|
+
var _chatRenderState_focusInput;
|
|
13173
|
+
(_chatRenderState_focusInput = chatRenderState.focusInput) === null || _chatRenderState_focusInput === void 0 ? void 0 : _chatRenderState_focusInput.call(chatRenderState);
|
|
13174
|
+
return false;
|
|
13175
|
+
}
|
|
13176
|
+
if (isChatBusy(chatRenderState) || !chatRenderState.sendMessage) {
|
|
13177
|
+
return false;
|
|
13178
|
+
}
|
|
13179
|
+
chatRenderState.sendMessage({
|
|
13180
|
+
text: trimmed
|
|
13181
|
+
}, referer ? {
|
|
13182
|
+
headers: {
|
|
13183
|
+
'x-algolia-referer': referer
|
|
13184
|
+
}
|
|
13185
|
+
} : undefined);
|
|
13186
|
+
return true;
|
|
13187
|
+
}
|
|
13188
|
+
function isChatBusy(chatRenderState) {
|
|
13189
|
+
return (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'submitted' || (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'streaming';
|
|
13190
|
+
}
|
|
13191
|
+
|
|
13157
13192
|
var Breadcrumb = function Breadcrumb(param) {
|
|
13158
13193
|
var items = param.items, cssClasses = param.cssClasses, templateProps = param.templateProps, createURL = param.createURL, refine = param.refine;
|
|
13159
13194
|
return /*#__PURE__*/ h$1("div", {
|
|
@@ -14029,7 +14064,7 @@
|
|
|
14029
14064
|
{
|
|
14030
14065
|
key: "render",
|
|
14031
14066
|
value: function render() {
|
|
14032
|
-
var _this_props = this.props, cssClasses = _this_props.cssClasses, placeholder = _this_props.placeholder, autofocus = _this_props.autofocus, showSubmit = _this_props.showSubmit, showReset = _this_props.showReset, showLoadingIndicator = _this_props.showLoadingIndicator, templates = _this_props.templates, isSearchStalled = _this_props.isSearchStalled, ariaLabel = _this_props.ariaLabel, inputProps = _this_props.inputProps, onAiModeClick = _this_props.onAiModeClick;
|
|
14067
|
+
var _this_props = this.props, cssClasses = _this_props.cssClasses, placeholder = _this_props.placeholder, autofocus = _this_props.autofocus, showSubmit = _this_props.showSubmit, showReset = _this_props.showReset, showLoadingIndicator = _this_props.showLoadingIndicator, templates = _this_props.templates, isSearchStalled = _this_props.isSearchStalled, ariaLabel = _this_props.ariaLabel, inputProps = _this_props.inputProps, onAiModeClick = _this_props.onAiModeClick, aiModeButtonDisabled = _this_props.aiModeButtonDisabled;
|
|
14033
14068
|
return /*#__PURE__*/ h$1("div", {
|
|
14034
14069
|
className: cssClasses.root
|
|
14035
14070
|
}, /*#__PURE__*/ h$1("form", {
|
|
@@ -14104,6 +14139,7 @@
|
|
|
14104
14139
|
className: cssClasses.aiModeButton,
|
|
14105
14140
|
type: 'button',
|
|
14106
14141
|
title: 'AI Mode',
|
|
14142
|
+
disabled: aiModeButtonDisabled,
|
|
14107
14143
|
onClick: this.onAiModeClick
|
|
14108
14144
|
},
|
|
14109
14145
|
templates: templates,
|
|
@@ -14268,8 +14304,14 @@
|
|
|
14268
14304
|
* because Preact does not perform it automatically.
|
|
14269
14305
|
* @see https://github.com/preactjs/preact/issues/3242
|
|
14270
14306
|
*/ function componentDidUpdate() {
|
|
14271
|
-
var
|
|
14272
|
-
(_this_listRef_current = this.listRef.current) === null || _this_listRef_current === void 0 ? void 0 :
|
|
14307
|
+
var _this_listRef_current;
|
|
14308
|
+
var inputs = ((_this_listRef_current = this.listRef.current) === null || _this_listRef_current === void 0 ? void 0 : _this_listRef_current.getElementsByTagName('input')) || [];
|
|
14309
|
+
for(var i = 0; i < inputs.length; i++){
|
|
14310
|
+
if (inputs[i].value === this.lastRefinedValue) {
|
|
14311
|
+
inputs[i].focus();
|
|
14312
|
+
break;
|
|
14313
|
+
}
|
|
14314
|
+
}
|
|
14273
14315
|
this.lastRefinedValue = undefined;
|
|
14274
14316
|
}
|
|
14275
14317
|
},
|
|
@@ -19175,21 +19217,20 @@
|
|
|
19175
19217
|
var containerNode = param.containerNode, cssClasses = param.cssClasses, placeholder = param.placeholder, templates = param.templates, autofocus = param.autofocus, searchAsYouType = param.searchAsYouType, ignoreCompositionEvents = param.ignoreCompositionEvents, showReset = param.showReset, showSubmit = param.showSubmit, showLoadingIndicator = param.showLoadingIndicator, aiMode = param.aiMode;
|
|
19176
19218
|
return function(param) {
|
|
19177
19219
|
var refine = param.refine, query = param.query, isSearchStalled = param.isSearchStalled, instantSearchInstance = param.instantSearchInstance;
|
|
19178
|
-
var
|
|
19220
|
+
var getChatRenderState = function getChatRenderState() {
|
|
19179
19221
|
var _instantSearchInstance_renderState_indexId;
|
|
19180
19222
|
var indexId = instantSearchInstance.mainIndex.getIndexId();
|
|
19181
|
-
|
|
19182
|
-
|
|
19183
|
-
|
|
19184
|
-
|
|
19185
|
-
|
|
19186
|
-
|
|
19187
|
-
|
|
19188
|
-
|
|
19189
|
-
});
|
|
19190
|
-
}
|
|
19223
|
+
return (_instantSearchInstance_renderState_indexId = instantSearchInstance.renderState[indexId]) === null || _instantSearchInstance_renderState_indexId === void 0 ? void 0 : _instantSearchInstance_renderState_indexId.chat;
|
|
19224
|
+
};
|
|
19225
|
+
var onAiModeClick = aiMode ? function(currentQuery) {
|
|
19226
|
+
if (openChat(getChatRenderState(), {
|
|
19227
|
+
message: currentQuery,
|
|
19228
|
+
referer: 'ai-mode'
|
|
19229
|
+
})) {
|
|
19230
|
+
refine('');
|
|
19191
19231
|
}
|
|
19192
19232
|
} : undefined;
|
|
19233
|
+
var aiModeButtonDisabled = aiMode ? isChatBusy(getChatRenderState()) : undefined;
|
|
19193
19234
|
P(/*#__PURE__*/ h$1(SearchBox, {
|
|
19194
19235
|
query: query,
|
|
19195
19236
|
placeholder: placeholder,
|
|
@@ -19203,7 +19244,8 @@
|
|
|
19203
19244
|
showLoadingIndicator: showLoadingIndicator,
|
|
19204
19245
|
isSearchStalled: isSearchStalled,
|
|
19205
19246
|
cssClasses: cssClasses,
|
|
19206
|
-
onAiModeClick: onAiModeClick
|
|
19247
|
+
onAiModeClick: onAiModeClick,
|
|
19248
|
+
aiModeButtonDisabled: aiModeButtonDisabled
|
|
19207
19249
|
}), containerNode);
|
|
19208
19250
|
};
|
|
19209
19251
|
};
|