algolia-experiences 1.8.14 → 1.8.16

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.14 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! algolia-experiences 1.8.16 | © 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();
@@ -6886,7 +6886,7 @@
6886
6886
  });
6887
6887
  }
6888
6888
 
6889
- var version = '4.105.0';
6889
+ var version = '4.107.0';
6890
6890
 
6891
6891
  var ANONYMOUS_TOKEN_COOKIE_KEY = '_ALGOLIA';
6892
6892
  function getCookie(name) {
@@ -9290,6 +9290,39 @@
9290
9290
  ].concat(_to_consumable_array(resolveScopedResultsFromWidgets(current.getWidgets()))));
9291
9291
  }, []);
9292
9292
  }
9293
+ function getWidgetsRequestDependencies(widgets) {
9294
+ return widgets.reduce(function(dependencies, widget) {
9295
+ if (isIndexWidget(widget)) {
9296
+ if (widget._isolated) {
9297
+ return dependencies;
9298
+ }
9299
+ var childDependencies = getWidgetsRequestDependencies(widget.getWidgets());
9300
+ return {
9301
+ hasSearchWidget: dependencies.hasSearchWidget || childDependencies.hasSearchWidget,
9302
+ hasRecommendWidget: dependencies.hasRecommendWidget || childDependencies.hasRecommendWidget
9303
+ };
9304
+ }
9305
+ if (widget.dependsOn === 'recommend') {
9306
+ return _object_spread_props(_object_spread({}, dependencies), {
9307
+ hasRecommendWidget: true
9308
+ });
9309
+ }
9310
+ if (widget.dependsOn === 'none') {
9311
+ return dependencies;
9312
+ }
9313
+ return _object_spread_props(_object_spread({}, dependencies), {
9314
+ hasSearchWidget: true
9315
+ });
9316
+ }, {
9317
+ hasSearchWidget: false,
9318
+ hasRecommendWidget: false
9319
+ });
9320
+ }
9321
+ function recomputeInstantSearchRequestDependencies(instantSearchInstance) {
9322
+ var _getWidgetsRequestDependencies = getWidgetsRequestDependencies(instantSearchInstance.mainIndex.getWidgets()), hasSearchWidget = _getWidgetsRequestDependencies.hasSearchWidget, hasRecommendWidget = _getWidgetsRequestDependencies.hasRecommendWidget;
9323
+ instantSearchInstance._hasSearchWidget = hasSearchWidget;
9324
+ instantSearchInstance._hasRecommendWidget = hasRecommendWidget;
9325
+ }
9293
9326
  var index = function index(widgetParams) {
9294
9327
  if (widgetParams === undefined || widgetParams.indexName === undefined && !widgetParams.EXPERIMENTAL_isolated) {
9295
9328
  throw new Error(withUsage$K('The `indexName` option is required.'));
@@ -9304,8 +9337,11 @@
9304
9337
  var helper = null;
9305
9338
  var derivedHelper = null;
9306
9339
  var lastValidSearchParameters = null;
9307
- var hasRecommendWidget = false;
9308
- var hasSearchWidget = false;
9340
+ var recomputeLocalRequestDependencies = function recomputeLocalRequestDependencies() {
9341
+ if (localInstantSearchInstance) {
9342
+ recomputeInstantSearchRequestDependencies(localInstantSearchInstance);
9343
+ }
9344
+ };
9309
9345
  return {
9310
9346
  $$type: 'ais.index',
9311
9347
  $$widgetType: 'ais.index',
@@ -9396,21 +9432,12 @@
9396
9432
  }
9397
9433
  flatWidgets.forEach(function(widget) {
9398
9434
  widget.parent = _this;
9399
- if (isIndexWidget(widget)) {
9400
- return;
9435
+ if (!isIndexWidget(widget)) {
9436
+ addWidgetId(widget);
9401
9437
  }
9402
- if (localInstantSearchInstance && widget.dependsOn === 'recommend') {
9403
- localInstantSearchInstance._hasRecommendWidget = true;
9404
- } else if (localInstantSearchInstance) {
9405
- localInstantSearchInstance._hasSearchWidget = true;
9406
- } else if (widget.dependsOn === 'recommend') {
9407
- hasRecommendWidget = true;
9408
- } else {
9409
- hasSearchWidget = true;
9410
- }
9411
- addWidgetId(widget);
9412
9438
  });
9413
9439
  localWidgets = localWidgets.concat(flatWidgets);
9440
+ recomputeLocalRequestDependencies();
9414
9441
  if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
9415
9442
  privateHelperSetState(helper, {
9416
9443
  state: getLocalWidgetsSearchParameters(localWidgets, {
@@ -9467,21 +9494,10 @@
9467
9494
  localWidgets = localWidgets.filter(function(widget) {
9468
9495
  return flatWidgets.indexOf(widget) === -1;
9469
9496
  });
9470
- localWidgets.forEach(function(widget) {
9497
+ flatWidgets.forEach(function(widget) {
9471
9498
  widget.parent = undefined;
9472
- if (isIndexWidget(widget)) {
9473
- return;
9474
- }
9475
- if (localInstantSearchInstance && widget.dependsOn === 'recommend') {
9476
- localInstantSearchInstance._hasRecommendWidget = true;
9477
- } else if (localInstantSearchInstance) {
9478
- localInstantSearchInstance._hasSearchWidget = true;
9479
- } else if (widget.dependsOn === 'recommend') {
9480
- hasRecommendWidget = true;
9481
- } else {
9482
- hasSearchWidget = true;
9483
- }
9484
9499
  });
9500
+ recomputeLocalRequestDependencies();
9485
9501
  if (localInstantSearchInstance && Boolean(flatWidgets.length)) {
9486
9502
  var _flatWidgets_reduce = flatWidgets.reduce(function(states, widget) {
9487
9503
  // the `dispose` method exists at this point we already assert it
@@ -9704,12 +9720,7 @@
9704
9720
  // schedule a render that will render the results injected on the helper.
9705
9721
  instantSearchInstance.scheduleRender();
9706
9722
  }
9707
- if (hasRecommendWidget) {
9708
- instantSearchInstance._hasRecommendWidget = true;
9709
- }
9710
- if (hasSearchWidget) {
9711
- instantSearchInstance._hasSearchWidget = true;
9712
- }
9723
+ recomputeLocalRequestDependencies();
9713
9724
  },
9714
9725
  render: function render(param) {
9715
9726
  var _this = this;
@@ -10600,8 +10611,11 @@
10600
10611
  mainHelper.searchForFacetValues = mainHelper.searchForCompositionFacetValues.bind(mainHelper);
10601
10612
  }
10602
10613
  mainHelper.search = function() {
10603
- _this.status = 'loading';
10604
- _this.scheduleRender(false);
10614
+ var hasSearchOrRecommendWidget = _this._hasSearchWidget || _this._hasRecommendWidget;
10615
+ if (hasSearchOrRecommendWidget) {
10616
+ _this.status = 'loading';
10617
+ }
10618
+ _this.scheduleRender(!hasSearchOrRecommendWidget);
10605
10619
  // This solution allows us to keep the exact same API for the users but
10606
10620
  // under the hood, we have a different implementation. It should be
10607
10621
  // completely transparent for the rest of the codebase. Only this module
@@ -10665,7 +10679,7 @@
10665
10679
  error.error = error;
10666
10680
  _this.error = error;
10667
10681
  _this.status = 'error';
10668
- _this.scheduleRender(false);
10682
+ _this.scheduleRender(!_this._hasSearchWidget && !_this._hasRecommendWidget);
10669
10683
  // This needs to execute last because it throws the error.
10670
10684
  _this.emit('error', error);
10671
10685
  });
@@ -13260,6 +13274,41 @@
13260
13274
  });
13261
13275
  };
13262
13276
 
13277
+ // Centralizes the "open the chat from an entry point" behavior shared by the
13278
+ // SearchBox AI button, the Autocomplete AI button, prompt suggestions, and any
13279
+ // future entry point. The chat is always opened; the message is only sent when
13280
+ // it is non-empty and the chat is not already processing a message.
13281
+ // Returns true when a message was submitted, so callers can clear their input.
13282
+ function openChat(chatRenderState) {
13283
+ var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, message = _ref.message, referer = _ref.referer;
13284
+ var _ref1;
13285
+ var _chatRenderState_setOpen;
13286
+ if (!chatRenderState) {
13287
+ return false;
13288
+ }
13289
+ (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
13290
+ var trimmed = (_ref1 = message === null || message === void 0 ? void 0 : message.trim()) !== null && _ref1 !== void 0 ? _ref1 : '';
13291
+ if (!trimmed) {
13292
+ var _chatRenderState_focusInput;
13293
+ (_chatRenderState_focusInput = chatRenderState.focusInput) === null || _chatRenderState_focusInput === void 0 ? void 0 : _chatRenderState_focusInput.call(chatRenderState);
13294
+ return false;
13295
+ }
13296
+ if (isChatBusy(chatRenderState) || !chatRenderState.sendMessage) {
13297
+ return false;
13298
+ }
13299
+ chatRenderState.sendMessage({
13300
+ text: trimmed
13301
+ }, referer ? {
13302
+ headers: {
13303
+ 'x-algolia-referer': referer
13304
+ }
13305
+ } : undefined);
13306
+ return true;
13307
+ }
13308
+ function isChatBusy(chatRenderState) {
13309
+ return (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'submitted' || (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'streaming';
13310
+ }
13311
+
13263
13312
  var withUsage$H = createDocumentationMessageGenerator({
13264
13313
  name: 'search-box',
13265
13314
  connector: true
@@ -13341,41 +13390,6 @@
13341
13390
  };
13342
13391
  };
13343
13392
 
13344
- // Centralizes the "open the chat from an entry point" behavior shared by the
13345
- // SearchBox AI button, the Autocomplete AI button, prompt suggestions, and any
13346
- // future entry point. The chat is always opened; the message is only sent when
13347
- // it is non-empty and the chat is not already processing a message.
13348
- // Returns true when a message was submitted, so callers can clear their input.
13349
- function openChat(chatRenderState) {
13350
- var _ref = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, message = _ref.message, referer = _ref.referer;
13351
- var _ref1;
13352
- var _chatRenderState_setOpen;
13353
- if (!chatRenderState) {
13354
- return false;
13355
- }
13356
- (_chatRenderState_setOpen = chatRenderState.setOpen) === null || _chatRenderState_setOpen === void 0 ? void 0 : _chatRenderState_setOpen.call(chatRenderState, true);
13357
- var trimmed = (_ref1 = message === null || message === void 0 ? void 0 : message.trim()) !== null && _ref1 !== void 0 ? _ref1 : '';
13358
- if (!trimmed) {
13359
- var _chatRenderState_focusInput;
13360
- (_chatRenderState_focusInput = chatRenderState.focusInput) === null || _chatRenderState_focusInput === void 0 ? void 0 : _chatRenderState_focusInput.call(chatRenderState);
13361
- return false;
13362
- }
13363
- if (isChatBusy(chatRenderState) || !chatRenderState.sendMessage) {
13364
- return false;
13365
- }
13366
- chatRenderState.sendMessage({
13367
- text: trimmed
13368
- }, referer ? {
13369
- headers: {
13370
- 'x-algolia-referer': referer
13371
- }
13372
- } : undefined);
13373
- return true;
13374
- }
13375
- function isChatBusy(chatRenderState) {
13376
- return (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'submitted' || (chatRenderState === null || chatRenderState === void 0 ? void 0 : chatRenderState.status) === 'streaming';
13377
- }
13378
-
13379
13393
  var Breadcrumb = function Breadcrumb(param) {
13380
13394
  var items = param.items, cssClasses = param.cssClasses, templateProps = param.templateProps, createURL = param.createURL, refine = param.refine;
13381
13395
  return /*#__PURE__*/ h$1("div", {