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.
Files changed (63) hide show
  1. package/cjs/connectors/chat/connectChat.js +200 -0
  2. package/cjs/connectors/index.js +7 -0
  3. package/cjs/connectors/index.umd.js +239 -0
  4. package/cjs/index.js +2 -2
  5. package/cjs/lib/chat/chat.js +177 -0
  6. package/cjs/lib/chat/index.js +27 -0
  7. package/cjs/lib/useStickToBottom.js +20 -0
  8. package/cjs/lib/version.js +1 -1
  9. package/cjs/templates/carousel/carousel.js +31 -4
  10. package/cjs/widgets/chat/chat.js +615 -0
  11. package/cjs/widgets/index/index.js +6 -1
  12. package/cjs/widgets/index.js +7 -0
  13. package/cjs/widgets/index.umd.js +267 -0
  14. package/dist/instantsearch.development.d.ts +75 -11
  15. package/dist/instantsearch.development.js +111 -57
  16. package/dist/instantsearch.development.js.map +1 -1
  17. package/dist/instantsearch.production.d.ts +75 -11
  18. package/dist/instantsearch.production.min.d.ts +75 -11
  19. package/dist/instantsearch.production.min.js +2 -2
  20. package/dist/instantsearch.production.min.js.map +1 -1
  21. package/es/connectors/chat/connectChat.d.ts +413 -0
  22. package/es/connectors/chat/connectChat.js +194 -0
  23. package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +2 -0
  24. package/es/connectors/geo-search/connectGeoSearch.d.ts +1 -0
  25. package/es/connectors/hits/connectHits.d.ts +1 -0
  26. package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -0
  27. package/es/connectors/index.d.ts +1 -0
  28. package/es/connectors/index.js +2 -1
  29. package/es/connectors/index.umd.d.ts +39 -0
  30. package/es/connectors/index.umd.js +47 -0
  31. package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +1 -0
  32. package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.d.ts +1 -0
  33. package/es/connectors/looking-similar/connectLookingSimilar.d.ts +2 -0
  34. package/es/connectors/related-products/connectRelatedProducts.d.ts +2 -0
  35. package/es/connectors/trending-items/connectTrendingItems.d.ts +2 -0
  36. package/es/lib/chat/chat.d.ts +40 -0
  37. package/es/lib/chat/chat.js +166 -0
  38. package/es/lib/chat/index.d.ts +7 -0
  39. package/es/lib/chat/index.js +5 -0
  40. package/es/lib/useStickToBottom.d.ts +1 -0
  41. package/es/lib/useStickToBottom.js +14 -0
  42. package/es/lib/version.d.ts +1 -1
  43. package/es/lib/version.js +1 -1
  44. package/es/templates/carousel/carousel.d.ts +10 -3
  45. package/es/templates/carousel/carousel.js +32 -5
  46. package/es/types/render-state.d.ts +2 -1
  47. package/es/types/templates.d.ts +1 -1
  48. package/es/types/widget.d.ts +2 -2
  49. package/es/widgets/chat/chat.d.ts +555 -0
  50. package/es/widgets/chat/chat.js +597 -0
  51. package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +3 -1
  52. package/es/widgets/geo-search/geo-search.d.ts +1 -0
  53. package/es/widgets/hits/hits.d.ts +1 -0
  54. package/es/widgets/index/index.js +6 -1
  55. package/es/widgets/index.d.ts +1 -0
  56. package/es/widgets/index.js +2 -1
  57. package/es/widgets/index.umd.d.ts +44 -0
  58. package/es/widgets/index.umd.js +51 -0
  59. package/es/widgets/infinite-hits/infinite-hits.d.ts +1 -0
  60. package/es/widgets/looking-similar/looking-similar.d.ts +3 -1
  61. package/es/widgets/related-products/related-products.d.ts +3 -1
  62. package/es/widgets/trending-items/trending-items.d.ts +3 -1
  63. package/package.json +11 -7
@@ -1,4 +1,4 @@
1
- /*! InstantSearch.js 4.80.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
1
+ /*! InstantSearch.js 4.81.0 | © Algolia, Inc. and contributors; MIT License | https://github.com/algolia/instantsearch */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -13827,6 +13827,9 @@
13827
13827
 
13828
13828
  /** @deprecated use connectDynamicWidgets */
13829
13829
  var EXPERIMENTAL_connectDynamicWidgets = deprecate(connectDynamicWidgets, 'use connectDynamicWidgets');
13830
+ var connectChat = function connectChat() {
13831
+ throw new Error("\"connectChat\" is not available from the UMD build.\n\nPlease use InstantSearch.js with a packaging system:\nhttps://www.algolia.com/doc/guides/building-search-ui/installation/js/#with-a-packaging-system");
13832
+ };
13830
13833
 
13831
13834
  var connectors = /*#__PURE__*/Object.freeze({
13832
13835
  __proto__: null,
@@ -13834,6 +13837,7 @@
13834
13837
  EXPERIMENTAL_connectConfigureRelatedItems: EXPERIMENTAL_connectConfigureRelatedItems,
13835
13838
  EXPERIMENTAL_connectDynamicWidgets: EXPERIMENTAL_connectDynamicWidgets,
13836
13839
  connectDynamicWidgets: connectDynamicWidgets,
13840
+ connectChat: connectChat,
13837
13841
  connectClearRefinements: connectClearRefinements,
13838
13842
  connectCurrentRefinements: connectCurrentRefinements,
13839
13843
  connectHierarchicalMenu: connectHierarchicalMenu,
@@ -16312,7 +16316,9 @@
16312
16316
  // This makes sure `render` is never called with `results` being `null`.
16313
16317
  // If it's an isolated index without an index name, we render all widgets,
16314
16318
  // as there are no results to display for the isolated index itself.
16315
- var widgetsToRender = this.getResults() || (_derivedHelper2 = derivedHelper) !== null && _derivedHelper2 !== void 0 && _derivedHelper2.lastRecommendResults || isolated && !indexName ? localWidgets : localWidgets.filter(isIndexWidget);
16319
+ var widgetsToRender = this.getResults() || (_derivedHelper2 = derivedHelper) !== null && _derivedHelper2 !== void 0 && _derivedHelper2.lastRecommendResults || isolated && !indexName ? localWidgets : localWidgets.filter(function (widget) {
16320
+ return widget.shouldRender;
16321
+ });
16316
16322
  widgetsToRender = widgetsToRender.filter(function (widget) {
16317
16323
  if (!widget.shouldRender) {
16318
16324
  return true;
@@ -16389,6 +16395,9 @@
16389
16395
  initialSearchParameters: searchParameters
16390
16396
  });
16391
16397
  },
16398
+ shouldRender: function shouldRender() {
16399
+ return true;
16400
+ },
16392
16401
  refreshUiState: function refreshUiState() {
16393
16402
  localUiState = getLocalWidgetsUiState(localWidgets, {
16394
16403
  searchParameters: this.getHelper().state,
@@ -16489,7 +16498,7 @@
16489
16498
  };
16490
16499
  }
16491
16500
 
16492
- var version$1 = '4.80.0';
16501
+ var version$1 = '4.81.0';
16493
16502
 
16494
16503
  var withUsage$v = createDocumentationMessageGenerator({
16495
16504
  name: 'instantsearch'
@@ -17183,6 +17192,50 @@
17183
17192
 
17184
17193
  var _extends$1 = unwrapExports(_extends_1);
17185
17194
 
17195
+ var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
17196
+ function _objectWithoutPropertiesLoose(r, e) {
17197
+ if (null == r) return {};
17198
+ var t = {};
17199
+ for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
17200
+ if (-1 !== e.indexOf(n)) continue;
17201
+ t[n] = r[n];
17202
+ }
17203
+ return t;
17204
+ }
17205
+ module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
17206
+ });
17207
+
17208
+ unwrapExports(objectWithoutPropertiesLoose);
17209
+
17210
+ var objectWithoutProperties = createCommonjsModule(function (module) {
17211
+ function _objectWithoutProperties(e, t) {
17212
+ if (null == e) return {};
17213
+ var o,
17214
+ r,
17215
+ i = objectWithoutPropertiesLoose(e, t);
17216
+ if (Object.getOwnPropertySymbols) {
17217
+ var n = Object.getOwnPropertySymbols(e);
17218
+ for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
17219
+ }
17220
+ return i;
17221
+ }
17222
+ module.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports["default"] = module.exports;
17223
+ });
17224
+
17225
+ var _objectWithoutProperties$1 = unwrapExports(objectWithoutProperties);
17226
+
17227
+ function cx() {
17228
+ for (var _len = arguments.length, classNames = new Array(_len), _key = 0; _key < _len; _key++) {
17229
+ classNames[_key] = arguments[_key];
17230
+ }
17231
+ return classNames.reduce(function (acc, className) {
17232
+ if (Array.isArray(className)) {
17233
+ return acc.concat(className);
17234
+ }
17235
+ return acc.concat([className]);
17236
+ }, []).filter(Boolean).join(' ');
17237
+ }
17238
+
17186
17239
  var _typeof_1 = createCommonjsModule(function (module) {
17187
17240
  function _typeof(o) {
17188
17241
  "@babel/helpers - typeof";
@@ -17241,50 +17294,6 @@
17241
17294
 
17242
17295
  var _defineProperty$1 = unwrapExports(defineProperty);
17243
17296
 
17244
- var objectWithoutPropertiesLoose = createCommonjsModule(function (module) {
17245
- function _objectWithoutPropertiesLoose(r, e) {
17246
- if (null == r) return {};
17247
- var t = {};
17248
- for (var n in r) if ({}.hasOwnProperty.call(r, n)) {
17249
- if (-1 !== e.indexOf(n)) continue;
17250
- t[n] = r[n];
17251
- }
17252
- return t;
17253
- }
17254
- module.exports = _objectWithoutPropertiesLoose, module.exports.__esModule = true, module.exports["default"] = module.exports;
17255
- });
17256
-
17257
- unwrapExports(objectWithoutPropertiesLoose);
17258
-
17259
- var objectWithoutProperties = createCommonjsModule(function (module) {
17260
- function _objectWithoutProperties(e, t) {
17261
- if (null == e) return {};
17262
- var o,
17263
- r,
17264
- i = objectWithoutPropertiesLoose(e, t);
17265
- if (Object.getOwnPropertySymbols) {
17266
- var n = Object.getOwnPropertySymbols(e);
17267
- for (r = 0; r < n.length; r++) o = n[r], -1 === t.indexOf(o) && {}.propertyIsEnumerable.call(e, o) && (i[o] = e[o]);
17268
- }
17269
- return i;
17270
- }
17271
- module.exports = _objectWithoutProperties, module.exports.__esModule = true, module.exports["default"] = module.exports;
17272
- });
17273
-
17274
- var _objectWithoutProperties$1 = unwrapExports(objectWithoutProperties);
17275
-
17276
- function cx() {
17277
- for (var _len = arguments.length, classNames = new Array(_len), _key = 0; _key < _len; _key++) {
17278
- classNames[_key] = arguments[_key];
17279
- }
17280
- return classNames.reduce(function (acc, className) {
17281
- if (Array.isArray(className)) {
17282
- return acc.concat(className);
17283
- }
17284
- return acc.concat([className]);
17285
- }, []).filter(Boolean).join(' ');
17286
- }
17287
-
17288
17297
  function createDefaultEmptyComponent(_ref) {
17289
17298
  var createElement = _ref.createElement,
17290
17299
  Fragment = _ref.Fragment;
@@ -17350,7 +17359,7 @@
17350
17359
  };
17351
17360
  }
17352
17361
 
17353
- var _excluded$9 = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "items", "translations", "sendEvent"];
17362
+ var _excluded$9 = ["listRef", "nextButtonRef", "previousButtonRef", "carouselIdRef", "canScrollLeft", "canScrollRight", "setCanScrollLeft", "setCanScrollRight", "classNames", "itemComponent", "previousIconComponent", "nextIconComponent", "headerComponent", "showNavigation", "items", "translations", "sendEvent"];
17354
17363
  function ownKeys$1(e, r) {
17355
17364
  var t = Object.keys(e);
17356
17365
  if (Object.getOwnPropertySymbols) {
@@ -17412,6 +17421,10 @@
17412
17421
  nextButtonRef = userProps.nextButtonRef,
17413
17422
  previousButtonRef = userProps.previousButtonRef,
17414
17423
  carouselIdRef = userProps.carouselIdRef,
17424
+ canScrollLeft = userProps.canScrollLeft,
17425
+ canScrollRight = userProps.canScrollRight,
17426
+ setCanScrollLeft = userProps.setCanScrollLeft,
17427
+ setCanScrollRight = userProps.setCanScrollRight,
17415
17428
  _userProps$classNames = userProps.classNames,
17416
17429
  classNames = _userProps$classNames === void 0 ? {} : _userProps$classNames,
17417
17430
  _userProps$itemCompon = userProps.itemComponent,
@@ -17423,6 +17436,9 @@
17423
17436
  PreviousIconComponent = _userProps$previousIc === void 0 ? PreviousIconDefaultComponent : _userProps$previousIc,
17424
17437
  _userProps$nextIconCo = userProps.nextIconComponent,
17425
17438
  NextIconComponent = _userProps$nextIconCo === void 0 ? NextIconDefaultComponent : _userProps$nextIconCo,
17439
+ HeaderComponent = userProps.headerComponent,
17440
+ _userProps$showNaviga = userProps.showNavigation,
17441
+ showNavigation = _userProps$showNaviga === void 0 ? true : _userProps$showNaviga,
17426
17442
  items = userProps.items,
17427
17443
  userTranslations = userProps.translations,
17428
17444
  sendEvent = userProps.sendEvent,
@@ -17453,18 +17469,31 @@
17453
17469
  }
17454
17470
  }
17455
17471
  function updateNavigationButtonsProps() {
17456
- if (!listRef.current || !previousButtonRef.current || !nextButtonRef.current) {
17472
+ if (!listRef.current) {
17457
17473
  return;
17458
17474
  }
17459
- previousButtonRef.current.hidden = listRef.current.scrollLeft <= 0;
17460
- nextButtonRef.current.hidden = listRef.current.scrollLeft + listRef.current.clientWidth >= listRef.current.scrollWidth;
17475
+ var isLeftHidden = listRef.current.scrollLeft <= 0;
17476
+ var isRightHidden = listRef.current.scrollLeft + listRef.current.clientWidth >= listRef.current.scrollWidth;
17477
+ setCanScrollLeft(!isLeftHidden);
17478
+ setCanScrollRight(!isRightHidden);
17479
+ if (previousButtonRef.current) {
17480
+ previousButtonRef.current.hidden = isLeftHidden;
17481
+ }
17482
+ if (nextButtonRef.current) {
17483
+ nextButtonRef.current.hidden = isRightHidden;
17484
+ }
17461
17485
  }
17462
17486
  if (items.length === 0) {
17463
17487
  return null;
17464
17488
  }
17465
17489
  return createElement("div", _extends$1({}, props, {
17466
17490
  className: cx(cssClasses.root)
17467
- }), createElement("button", {
17491
+ }), HeaderComponent && createElement(HeaderComponent, {
17492
+ canScrollLeft: canScrollLeft,
17493
+ canScrollRight: canScrollRight,
17494
+ scrollLeft: scrollLeft,
17495
+ scrollRight: scrollRight
17496
+ }), showNavigation && createElement("button", {
17468
17497
  ref: previousButtonRef,
17469
17498
  title: translations.previousButtonTitle,
17470
17499
  "aria-label": translations.previousButtonLabel,
@@ -17511,7 +17540,7 @@
17511
17540
  item: item,
17512
17541
  sendEvent: sendEvent
17513
17542
  }));
17514
- })), createElement("button", {
17543
+ })), showNavigation && createElement("button", {
17515
17544
  ref: nextButtonRef,
17516
17545
  title: translations.nextButtonTitle,
17517
17546
  "aria-label": translations.nextButtonLabel,
@@ -18002,11 +18031,23 @@
18002
18031
  Fragment: p
18003
18032
  });
18004
18033
  function CarouselWithRefs(props) {
18034
+ var _useState = y$1(false),
18035
+ _useState2 = _slicedToArray(_useState, 2),
18036
+ canScrollLeft = _useState2[0],
18037
+ setCanScrollLeft = _useState2[1];
18038
+ var _useState3 = y$1(true),
18039
+ _useState4 = _slicedToArray(_useState3, 2),
18040
+ canScrollRight = _useState4[0],
18041
+ setCanScrollRight = _useState4[1];
18005
18042
  var carouselRefs = {
18006
18043
  listRef: A$1(null),
18007
18044
  nextButtonRef: A$1(null),
18008
18045
  previousButtonRef: A$1(null),
18009
- carouselIdRef: A$1(generateCarouselId())
18046
+ carouselIdRef: A$1(generateCarouselId()),
18047
+ canScrollLeft: canScrollLeft,
18048
+ canScrollRight: canScrollRight,
18049
+ setCanScrollLeft: setCanScrollLeft,
18050
+ setCanScrollRight: setCanScrollRight
18010
18051
  };
18011
18052
  return h(Carousel, _extends({}, carouselRefs, props));
18012
18053
  }
@@ -18014,7 +18055,9 @@
18014
18055
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
18015
18056
  cssClasses = _ref.cssClasses,
18016
18057
  _ref$templates = _ref.templates,
18017
- templates = _ref$templates === void 0 ? {} : _ref$templates;
18058
+ templates = _ref$templates === void 0 ? {} : _ref$templates,
18059
+ _ref$showNavigation = _ref.showNavigation,
18060
+ showNavigation = _ref$showNavigation === void 0 ? true : _ref$showNavigation;
18018
18061
  return function CarouselTemplate(_ref2) {
18019
18062
  var items = _ref2.items,
18020
18063
  widgetTemplates = _ref2.templates,
@@ -18023,11 +18066,17 @@
18023
18066
  _ref2$sendEvent = _ref2.sendEvent,
18024
18067
  sendEvent = _ref2$sendEvent === void 0 ? function () {} : _ref2$sendEvent;
18025
18068
  var previous = templates.previous,
18026
- next = templates.next;
18069
+ next = templates.next,
18070
+ header = templates.header;
18027
18071
  return h(CarouselWithRefs, {
18028
18072
  items: items,
18029
18073
  sendEvent: sendEvent,
18030
18074
  itemComponent: widgetTemplates.item,
18075
+ headerComponent: header ? function (props) {
18076
+ return header(_objectSpread2({
18077
+ html: m$1
18078
+ }, props));
18079
+ } : undefined,
18031
18080
  previousIconComponent: previous ? function () {
18032
18081
  return previous({
18033
18082
  html: m$1
@@ -18041,7 +18090,8 @@
18041
18090
  classNames: _objectSpread2(_objectSpread2({}, cssClasses), {
18042
18091
  list: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.list, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.list),
18043
18092
  item: cx(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.item, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.item)
18044
- })
18093
+ }),
18094
+ showNavigation: showNavigation
18045
18095
  });
18046
18096
  };
18047
18097
  }
@@ -25549,6 +25599,9 @@
25549
25599
 
25550
25600
  /** @deprecated use dynamicWidgets */
25551
25601
  var EXPERIMENTAL_dynamicWidgets = deprecate(dynamicWidgets, 'use dynamicWidgets');
25602
+ var chat = function chat() {
25603
+ throw new Error("\"chat\" is not available from the UMD build.\n\nPlease use InstantSearch.js with a packaging system:\nhttps://www.algolia.com/doc/guides/building-search-ui/installation/js/#with-a-packaging-system");
25604
+ };
25552
25605
 
25553
25606
  var widgets = /*#__PURE__*/Object.freeze({
25554
25607
  __proto__: null,
@@ -25556,6 +25609,7 @@
25556
25609
  EXPERIMENTAL_configureRelatedItems: EXPERIMENTAL_configureRelatedItems,
25557
25610
  EXPERIMENTAL_dynamicWidgets: EXPERIMENTAL_dynamicWidgets,
25558
25611
  dynamicWidgets: dynamicWidgets,
25612
+ chat: chat,
25559
25613
  analytics: analytics,
25560
25614
  breadcrumb: breadcrumb,
25561
25615
  clearRefinements: clearRefinements$1,