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
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "AbstractChat", {
7
+ enumerable: true,
8
+ get: function get() {
9
+ return _chat.AbstractChat;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "Chat", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _chat.Chat;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "ChatState", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _chat.ChatState;
22
+ }
23
+ });
24
+ exports.SearchIndexToolType = exports.RecommendToolType = void 0;
25
+ var _chat = require("./chat");
26
+ var SearchIndexToolType = exports.SearchIndexToolType = 'algolia_search_index';
27
+ var RecommendToolType = exports.RecommendToolType = 'algolia_recommend';
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useStickToBottom = void 0;
7
+ var _instantsearchUiComponents = require("instantsearch-ui-components");
8
+ var _hooks = require("preact/hooks");
9
+ /* !---------------------------------------------------------------------------------------------
10
+ * Copyright (c) StackBlitz. All rights reserved.
11
+ * Licensed under the MIT License. See License.txt in the project root for license information.
12
+ *--------------------------------------------------------------------------------------------*/
13
+
14
+ var useStickToBottom = exports.useStickToBottom = (0, _instantsearchUiComponents.createStickToBottom)({
15
+ useCallback: _hooks.useCallback,
16
+ useEffect: _hooks.useEffect,
17
+ useMemo: _hooks.useMemo,
18
+ useRef: _hooks.useRef,
19
+ useState: _hooks.useState
20
+ });
@@ -4,4 +4,4 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = exports.default = '4.80.0';
7
+ var _default = exports.default = '4.81.0';
@@ -15,16 +15,34 @@ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key i
15
15
  function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
16
16
  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); }
17
17
  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); }
18
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
19
+ 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."); }
20
+ 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); }
21
+ 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; }
22
+ 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; } }
23
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
24
  var Carousel = (0, _instantsearchUiComponents.createCarouselComponent)({
19
25
  createElement: _preact2.h,
20
26
  Fragment: _preact2.Fragment
21
27
  });
22
28
  function CarouselWithRefs(props) {
29
+ var _useState = (0, _hooks.useState)(false),
30
+ _useState2 = _slicedToArray(_useState, 2),
31
+ canScrollLeft = _useState2[0],
32
+ setCanScrollLeft = _useState2[1];
33
+ var _useState3 = (0, _hooks.useState)(true),
34
+ _useState4 = _slicedToArray(_useState3, 2),
35
+ canScrollRight = _useState4[0],
36
+ setCanScrollRight = _useState4[1];
23
37
  var carouselRefs = {
24
38
  listRef: (0, _hooks.useRef)(null),
25
39
  nextButtonRef: (0, _hooks.useRef)(null),
26
40
  previousButtonRef: (0, _hooks.useRef)(null),
27
- carouselIdRef: (0, _hooks.useRef)((0, _instantsearchUiComponents.generateCarouselId)())
41
+ carouselIdRef: (0, _hooks.useRef)((0, _instantsearchUiComponents.generateCarouselId)()),
42
+ canScrollLeft: canScrollLeft,
43
+ canScrollRight: canScrollRight,
44
+ setCanScrollLeft: setCanScrollLeft,
45
+ setCanScrollRight: setCanScrollRight
28
46
  };
29
47
  return (0, _preact2.h)(Carousel, _extends({}, carouselRefs, props));
30
48
  }
@@ -32,7 +50,9 @@ function carousel() {
32
50
  var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
33
51
  cssClasses = _ref.cssClasses,
34
52
  _ref$templates = _ref.templates,
35
- templates = _ref$templates === void 0 ? {} : _ref$templates;
53
+ templates = _ref$templates === void 0 ? {} : _ref$templates,
54
+ _ref$showNavigation = _ref.showNavigation,
55
+ showNavigation = _ref$showNavigation === void 0 ? true : _ref$showNavigation;
36
56
  return function CarouselTemplate(_ref2) {
37
57
  var items = _ref2.items,
38
58
  widgetTemplates = _ref2.templates,
@@ -41,11 +61,17 @@ function carousel() {
41
61
  _ref2$sendEvent = _ref2.sendEvent,
42
62
  sendEvent = _ref2$sendEvent === void 0 ? function () {} : _ref2$sendEvent;
43
63
  var previous = templates.previous,
44
- next = templates.next;
64
+ next = templates.next,
65
+ header = templates.header;
45
66
  return (0, _preact2.h)(CarouselWithRefs, {
46
67
  items: items,
47
68
  sendEvent: sendEvent,
48
69
  itemComponent: widgetTemplates.item,
70
+ headerComponent: header ? function (props) {
71
+ return header(_objectSpread({
72
+ html: _preact.html
73
+ }, props));
74
+ } : undefined,
49
75
  previousIconComponent: previous ? function () {
50
76
  return previous({
51
77
  html: _preact.html
@@ -59,7 +85,8 @@ function carousel() {
59
85
  classNames: _objectSpread(_objectSpread({}, cssClasses), {
60
86
  list: (0, _instantsearchUiComponents.cx)(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.list, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.list),
61
87
  item: (0, _instantsearchUiComponents.cx)(cssClasses === null || cssClasses === void 0 ? void 0 : cssClasses.item, widgetCssClasses === null || widgetCssClasses === void 0 ? void 0 : widgetCssClasses.item)
62
- })
88
+ }),
89
+ showNavigation: showNavigation
63
90
  });
64
91
  };
65
92
  }