instantsearch.js 4.53.0 → 4.54.1

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 (53) hide show
  1. package/cjs/components/Pagination/Pagination.js +35 -17
  2. package/cjs/components/Template/Template.js +6 -3
  3. package/cjs/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -0
  4. package/cjs/connectors/menu/connectMenu.js +4 -0
  5. package/cjs/connectors/refinement-list/connectRefinementList.js +8 -0
  6. package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +4 -0
  7. package/cjs/helpers/highlight.js +5 -0
  8. package/cjs/helpers/reverseHighlight.js +5 -0
  9. package/cjs/helpers/reverseSnippet.js +5 -0
  10. package/cjs/helpers/snippet.js +5 -0
  11. package/cjs/lib/server.js +60 -0
  12. package/cjs/lib/utils/index.js +11 -0
  13. package/cjs/lib/utils/walkIndex.js +18 -0
  14. package/cjs/lib/version.js +1 -1
  15. package/cjs/widgets/pagination/pagination.js +51 -39
  16. package/cjs/widgets/panel/panel.js +0 -2
  17. package/cjs/widgets/places/places.js +1 -0
  18. package/dist/instantsearch.development.d.ts +27 -4
  19. package/dist/instantsearch.development.js +133 -63
  20. package/dist/instantsearch.development.js.map +1 -1
  21. package/dist/instantsearch.production.d.ts +27 -4
  22. package/dist/instantsearch.production.min.d.ts +27 -4
  23. package/dist/instantsearch.production.min.js +2 -2
  24. package/dist/instantsearch.production.min.js.map +1 -1
  25. package/es/components/Pagination/Pagination.js +34 -17
  26. package/es/components/Panel/Panel.d.ts +1 -1
  27. package/es/components/Template/Template.js +6 -3
  28. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -0
  29. package/es/connectors/menu/connectMenu.js +5 -1
  30. package/es/connectors/refinement-list/connectRefinementList.js +9 -1
  31. package/es/connectors/toggle-refinement/connectToggleRefinement.js +5 -1
  32. package/es/helpers/highlight.d.ts +3 -0
  33. package/es/helpers/highlight.js +5 -0
  34. package/es/helpers/reverseHighlight.d.ts +3 -0
  35. package/es/helpers/reverseHighlight.js +5 -0
  36. package/es/helpers/reverseSnippet.d.ts +3 -0
  37. package/es/helpers/reverseSnippet.js +5 -0
  38. package/es/helpers/snippet.d.ts +3 -0
  39. package/es/helpers/snippet.js +5 -0
  40. package/es/lib/server.d.ts +10 -0
  41. package/es/lib/server.js +53 -0
  42. package/es/lib/utils/index.d.ts +1 -0
  43. package/es/lib/utils/index.js +1 -0
  44. package/es/lib/utils/walkIndex.d.ts +5 -0
  45. package/es/lib/utils/walkIndex.js +12 -0
  46. package/es/lib/version.d.ts +1 -1
  47. package/es/lib/version.js +1 -1
  48. package/es/widgets/pagination/pagination.d.ts +12 -5
  49. package/es/widgets/pagination/pagination.js +51 -39
  50. package/es/widgets/panel/panel.js +0 -2
  51. package/es/widgets/places/places.d.ts +1 -1
  52. package/es/widgets/places/places.js +1 -0
  53. package/package.json +5 -5
@@ -7,6 +7,8 @@ exports.default = void 0;
7
7
  var _uiComponentsShared = require("@algolia/ui-components-shared");
8
8
  var _preact = require("preact");
9
9
  var _utils = require("../../lib/utils");
10
+ var _Template = _interopRequireDefault(require("../Template/Template"));
11
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
10
12
  function Pagination(props) {
11
13
  function createClickHandler(pageNumber) {
12
14
  return function (event) {
@@ -27,7 +29,8 @@ function Pagination(props) {
27
29
  ariaLabel: "First",
28
30
  className: props.cssClasses.firstPageItem,
29
31
  isDisabled: props.isFirstPage,
30
- label: props.templates.first,
32
+ templates: props.templates,
33
+ templateKey: "first",
31
34
  pageNumber: 0,
32
35
  createURL: props.createURL,
33
36
  cssClasses: props.cssClasses,
@@ -36,7 +39,8 @@ function Pagination(props) {
36
39
  ariaLabel: "Previous",
37
40
  className: props.cssClasses.previousPageItem,
38
41
  isDisabled: props.isFirstPage,
39
- label: props.templates.previous,
42
+ templates: props.templates,
43
+ templateKey: "previous",
40
44
  pageNumber: props.currentPage - 1,
41
45
  createURL: props.createURL,
42
46
  cssClasses: props.cssClasses,
@@ -47,7 +51,8 @@ function Pagination(props) {
47
51
  ariaLabel: "Page ".concat(pageNumber + 1),
48
52
  className: props.cssClasses.pageItem,
49
53
  isSelected: pageNumber === props.currentPage,
50
- label: "".concat(pageNumber + 1),
54
+ templates: props.templates,
55
+ templateKey: "page",
51
56
  pageNumber: pageNumber,
52
57
  createURL: props.createURL,
53
58
  cssClasses: props.cssClasses,
@@ -57,7 +62,8 @@ function Pagination(props) {
57
62
  ariaLabel: "Next",
58
63
  className: props.cssClasses.nextPageItem,
59
64
  isDisabled: props.isLastPage,
60
- label: props.templates.next,
65
+ templates: props.templates,
66
+ templateKey: "next",
61
67
  pageNumber: props.currentPage + 1,
62
68
  createURL: props.createURL,
63
69
  cssClasses: props.cssClasses,
@@ -66,7 +72,8 @@ function Pagination(props) {
66
72
  ariaLabel: "Last",
67
73
  className: props.cssClasses.lastPageItem,
68
74
  isDisabled: props.isLastPage,
69
- label: props.templates.last,
75
+ templates: props.templates,
76
+ templateKey: "last",
70
77
  pageNumber: props.nbPages - 1,
71
78
  createURL: props.createURL,
72
79
  cssClasses: props.cssClasses,
@@ -74,7 +81,8 @@ function Pagination(props) {
74
81
  })));
75
82
  }
76
83
  function PaginationLink(_ref) {
77
- var label = _ref.label,
84
+ var templates = _ref.templates,
85
+ templateKey = _ref.templateKey,
78
86
  ariaLabel = _ref.ariaLabel,
79
87
  pageNumber = _ref.pageNumber,
80
88
  className = _ref.className,
@@ -87,18 +95,28 @@ function PaginationLink(_ref) {
87
95
  createClickHandler = _ref.createClickHandler;
88
96
  return (0, _preact.h)("li", {
89
97
  className: (0, _uiComponentsShared.cx)(cssClasses.item, className, isDisabled && cssClasses.disabledItem, isSelected && cssClasses.selectedItem)
90
- }, isDisabled ? (0, _preact.h)("span", {
91
- className: cssClasses.link,
92
- dangerouslySetInnerHTML: {
93
- __html: label
98
+ }, isDisabled ? (0, _preact.h)(_Template.default, {
99
+ rootTagName: "span",
100
+ rootProps: {
101
+ className: cssClasses.link
102
+ },
103
+ templateKey: templateKey,
104
+ templates: templates,
105
+ data: {
106
+ page: pageNumber + 1
94
107
  }
95
- }) : (0, _preact.h)("a", {
96
- className: cssClasses.link,
97
- "aria-label": ariaLabel,
98
- href: createURL(pageNumber),
99
- onClick: createClickHandler(pageNumber),
100
- dangerouslySetInnerHTML: {
101
- __html: label
108
+ }) : (0, _preact.h)(_Template.default, {
109
+ rootTagName: "a",
110
+ rootProps: {
111
+ className: cssClasses.link,
112
+ 'aria-label': ariaLabel,
113
+ href: createURL(pageNumber),
114
+ onClick: createClickHandler(pageNumber)
115
+ },
116
+ templateKey: templateKey,
117
+ templates: templates,
118
+ data: {
119
+ page: pageNumber + 1
102
120
  }
103
121
  }));
104
122
  }
@@ -46,9 +46,12 @@ var Template = /*#__PURE__*/function (_Component) {
46
46
  key: "render",
47
47
  value: function render() {
48
48
  var _this = this;
49
- process.env.NODE_ENV === 'development' ? (0, _utils.warning)(Object.keys(this.props.templates).every(function (key) {
50
- return typeof _this.props.templates[key] === 'function';
51
- }), "Hogan.js and string-based templates are deprecated and will not be supported in InstantSearch.js 5.x.\n\nYou can replace them with function-form templates and use either the provided `html` function or JSX templates.\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#upgrade-templates") : void 0;
49
+ if (process.env.NODE_ENV === 'development') {
50
+ var nonFunctionTemplates = Object.keys(this.props.templates).filter(function (key) {
51
+ return typeof _this.props.templates[key] !== 'function';
52
+ });
53
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(nonFunctionTemplates.length === 0, "Hogan.js and string-based templates are deprecated and will not be supported in InstantSearch.js 5.x.\n\nYou can replace them with function-form templates and use either the provided `html` function or JSX templates.\n\nString-based templates: ".concat(nonFunctionTemplates.join(', '), ".\n\nSee: https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/#upgrade-templates")) : void 0;
54
+ }
52
55
  var RootTagName = this.props.rootTagName;
53
56
  var useCustomCompileOptions = this.props.useCustomCompileOptions[this.props.templateKey];
54
57
  var compileOptions = useCustomCompileOptions ? this.props.templatesConfig.compileOptions : {};
@@ -209,6 +209,10 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
209
209
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
210
210
  var uiState = _ref6.uiState;
211
211
  var values = uiState.hierarchicalMenu && uiState.hierarchicalMenu[hierarchicalFacetName];
212
+ if (searchParameters.isConjunctiveFacet(hierarchicalFacetName) || searchParameters.isDisjunctiveFacet(hierarchicalFacetName)) {
213
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "HierarchicalMenu: Attribute \"".concat(hierarchicalFacetName, "\" is already used by another widget applying conjunctive or disjunctive faceting.\nAs this is not supported, please make sure to remove this other widget or this HierarchicalMenu widget will not work at all.")) : void 0;
214
+ return searchParameters;
215
+ }
212
216
  if (searchParameters.isHierarchicalFacet(hierarchicalFacetName)) {
213
217
  var facet = searchParameters.getHierarchicalFacetByName(hierarchicalFacetName);
214
218
  process.env.NODE_ENV === 'development' ? (0, _utils.warning)((0, _utils.isEqual)(facet.attributes, attributes) && facet.separator === separator && facet.rootPath === rootPath, 'Using Breadcrumb and HierarchicalMenu on the same facet with different options overrides the configuration of the HierarchicalMenu.') : void 0;
@@ -181,6 +181,10 @@ var connectMenu = function connectMenu(renderFn) {
181
181
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) {
182
182
  var uiState = _ref5.uiState;
183
183
  var value = uiState.menu && uiState.menu[attribute];
184
+ if (searchParameters.isConjunctiveFacet(attribute) || searchParameters.isDisjunctiveFacet(attribute)) {
185
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "Menu: Attribute \"".concat(attribute, "\" is already used by another widget applying conjunctive or disjunctive faceting.\nAs this is not supported, please make sure to remove this other widget or this Menu widget will not work at all.")) : void 0;
186
+ return searchParameters;
187
+ }
184
188
  var withFacetConfiguration = searchParameters.removeHierarchicalFacet(attribute).addHierarchicalFacet({
185
189
  name: attribute,
186
190
  attributes: [attribute]
@@ -253,6 +253,14 @@ var connectRefinementList = function connectRefinementList(renderFn) {
253
253
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
254
254
  var uiState = _ref6.uiState;
255
255
  var isDisjunctive = operator === 'or';
256
+ if (searchParameters.isHierarchicalFacet(attribute)) {
257
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "RefinementList: Attribute \"".concat(attribute, "\" is already used by another widget applying hierarchical faceting.\nAs this is not supported, please make sure to remove this other widget or this RefinementList widget will not work at all.")) : void 0;
258
+ return searchParameters;
259
+ }
260
+ if (isDisjunctive && searchParameters.isConjunctiveFacet(attribute) || !isDisjunctive && searchParameters.isDisjunctiveFacet(attribute)) {
261
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "RefinementList: Attribute \"".concat(attribute, "\" is used by another refinement list with a different operator.\nAs this is not supported, please make sure to only use this attribute with one of the two operators.")) : void 0;
262
+ return searchParameters;
263
+ }
256
264
  var values = uiState.refinementList && uiState.refinementList[attribute];
257
265
  var withoutRefinements = searchParameters.clearRefinements(attribute);
258
266
  var withFacetConfiguration = isDisjunctive ? withoutRefinements.addDisjunctiveFacet(attribute) : withoutRefinements.addFacet(attribute);
@@ -257,6 +257,10 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
257
257
  },
258
258
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref11) {
259
259
  var uiState = _ref11.uiState;
260
+ if (searchParameters.isHierarchicalFacet(attribute) || searchParameters.isConjunctiveFacet(attribute)) {
261
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "ToggleRefinement: Attribute \"".concat(attribute, "\" is already used by another widget of a different type.\nAs this is not supported, please make sure to remove this other widget or this ToggleRefinement widget will not work at all.")) : void 0;
262
+ return searchParameters;
263
+ }
260
264
  var withFacetConfiguration = searchParameters.clearRefinements(attribute).addDisjunctiveFacet(attribute);
261
265
  var isRefined = Boolean(uiState.toggle && uiState.toggle[attribute]);
262
266
  if (isRefined) {
@@ -7,6 +7,10 @@ exports.default = highlight;
7
7
  var _suit = require("../lib/suit");
8
8
  var _utils = require("../lib/utils");
9
9
  var suit = (0, _suit.component)('Highlight');
10
+
11
+ /**
12
+ * @deprecated use html tagged templates and the Highlight component instead
13
+ */
10
14
  function highlight(_ref) {
11
15
  var attribute = _ref.attribute,
12
16
  _ref$highlightedTagNa = _ref.highlightedTagName,
@@ -14,6 +18,7 @@ function highlight(_ref) {
14
18
  hit = _ref.hit,
15
19
  _ref$cssClasses = _ref.cssClasses,
16
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`instantsearch.highlight` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `Highlight` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
17
22
  var highlightAttributeResult = (0, _utils.getPropertyByPath)(hit._highlightResult, attribute);
18
23
 
19
24
  // @MAJOR fallback to attribute value if highlight is not found
@@ -7,6 +7,10 @@ exports.default = reverseHighlight;
7
7
  var _suit = require("../lib/suit");
8
8
  var _utils = require("../lib/utils");
9
9
  var suit = (0, _suit.component)('ReverseHighlight');
10
+
11
+ /**
12
+ * @deprecated use html tagged templates and the ReverseHighlight component instead
13
+ */
10
14
  function reverseHighlight(_ref) {
11
15
  var attribute = _ref.attribute,
12
16
  _ref$highlightedTagNa = _ref.highlightedTagName,
@@ -14,6 +18,7 @@ function reverseHighlight(_ref) {
14
18
  hit = _ref.hit,
15
19
  _ref$cssClasses = _ref.cssClasses,
16
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`instantsearch.reverseHighlight` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `ReverseHighlight` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
17
22
  var highlightAttributeResult = (0, _utils.getPropertyByPath)(hit._highlightResult, attribute);
18
23
 
19
24
  // @MAJOR fallback to attribute value if highlight is not found
@@ -7,6 +7,10 @@ exports.default = reverseSnippet;
7
7
  var _suit = require("../lib/suit");
8
8
  var _utils = require("../lib/utils");
9
9
  var suit = (0, _suit.component)('ReverseSnippet');
10
+
11
+ /**
12
+ * @deprecated use html tagged templates and the ReverseSnippet component instead
13
+ */
10
14
  function reverseSnippet(_ref) {
11
15
  var attribute = _ref.attribute,
12
16
  _ref$highlightedTagNa = _ref.highlightedTagName,
@@ -14,6 +18,7 @@ function reverseSnippet(_ref) {
14
18
  hit = _ref.hit,
15
19
  _ref$cssClasses = _ref.cssClasses,
16
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`instantsearch.reverseSnippet` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `ReverseSnippet` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
17
22
  var snippetAttributeResult = (0, _utils.getPropertyByPath)(hit._snippetResult, attribute);
18
23
 
19
24
  // @MAJOR fallback to attribute value if snippet is not found
@@ -7,6 +7,10 @@ exports.default = snippet;
7
7
  var _suit = require("../lib/suit");
8
8
  var _utils = require("../lib/utils");
9
9
  var suit = (0, _suit.component)('Snippet');
10
+
11
+ /**
12
+ * @deprecated use html tagged templates and the Snippet component instead
13
+ */
10
14
  function snippet(_ref) {
11
15
  var attribute = _ref.attribute,
12
16
  _ref$highlightedTagNa = _ref.highlightedTagName,
@@ -14,6 +18,7 @@ function snippet(_ref) {
14
18
  hit = _ref.hit,
15
19
  _ref$cssClasses = _ref.cssClasses,
16
20
  cssClasses = _ref$cssClasses === void 0 ? {} : _ref$cssClasses;
21
+ process.env.NODE_ENV === 'development' ? (0, _utils.warning)(false, "`instantsearch.snippet` function has been deprecated. It is still supported in 4.x releases, but not further. It is replaced by the `Snippet` component.\n\nFor more information, visit https://www.algolia.com/doc/guides/building-search-ui/upgrade-guides/js/?client=html+tagged+templates#upgrade-templates") : void 0;
17
22
  var snippetAttributeResult = (0, _utils.getPropertyByPath)(hit._snippetResult, attribute);
18
23
 
19
24
  // @MAJOR fallback to attribute value if snippet is not found
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getInitialResults = getInitialResults;
7
+ exports.waitForResults = waitForResults;
8
+ var _utils = require("./utils");
9
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
+ 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; }
13
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
14
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
+ /**
16
+ * Waits for the results from the search instance to coordinate the next steps
17
+ * in `getServerState()`.
18
+ */
19
+ function waitForResults(search) {
20
+ var helper = search.mainHelper;
21
+ helper.searchOnlyWithDerivedHelpers();
22
+ return new Promise(function (resolve, reject) {
23
+ // All derived helpers resolve in the same tick so we're safe only relying
24
+ // on the first one.
25
+ helper.derivedHelpers[0].on('result', function () {
26
+ resolve();
27
+ });
28
+
29
+ // However, we listen to errors that can happen on any derived helper because
30
+ // any error is critical.
31
+ helper.on('error', function (error) {
32
+ reject(error);
33
+ });
34
+ search.on('error', function (error) {
35
+ reject(error);
36
+ });
37
+ helper.derivedHelpers.forEach(function (derivedHelper) {
38
+ return derivedHelper.on('error', function (error) {
39
+ reject(error);
40
+ });
41
+ });
42
+ });
43
+ }
44
+
45
+ /**
46
+ * Walks the InstantSearch root index to construct the initial results.
47
+ */
48
+ function getInitialResults(rootIndex) {
49
+ var initialResults = {};
50
+ (0, _utils.walkIndex)(rootIndex, function (widget) {
51
+ var searchResults = widget.getResults();
52
+ initialResults[widget.getIndexId()] = {
53
+ // We convert the Helper state to a plain object to pass parsable data
54
+ // structures from server to client.
55
+ state: _objectSpread({}, searchResults._state),
56
+ results: searchResults._rawResults
57
+ };
58
+ });
59
+ return initialResults;
60
+ }
@@ -388,6 +388,17 @@ Object.keys(_isSpecialClick).forEach(function (key) {
388
388
  }
389
389
  });
390
390
  });
391
+ var _walkIndex = require("./walkIndex");
392
+ Object.keys(_walkIndex).forEach(function (key) {
393
+ if (key === "default" || key === "__esModule") return;
394
+ if (key in exports && exports[key] === _walkIndex[key]) return;
395
+ Object.defineProperty(exports, key, {
396
+ enumerable: true,
397
+ get: function get() {
398
+ return _walkIndex[key];
399
+ }
400
+ });
401
+ });
391
402
  var _logger = require("./logger");
392
403
  Object.keys(_logger).forEach(function (key) {
393
404
  if (key === "default" || key === "__esModule") return;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.walkIndex = walkIndex;
7
+ var _isIndexWidget = require("./isIndexWidget");
8
+ /**
9
+ * Recurse over all child indices
10
+ */
11
+ function walkIndex(indexWidget, callback) {
12
+ callback(indexWidget);
13
+ indexWidget.getWidgets().forEach(function (widget) {
14
+ if ((0, _isIndexWidget.isIndexWidget)(widget)) {
15
+ walkIndex(widget, callback);
16
+ }
17
+ });
18
+ }
@@ -4,5 +4,5 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- var _default = '4.53.0';
7
+ var _default = '4.54.1';
8
8
  exports.default = _default;
@@ -22,28 +22,40 @@ var withUsage = (0, _utils.createDocumentationMessageGenerator)({
22
22
  name: 'pagination'
23
23
  });
24
24
  var defaultTemplates = {
25
- previous: '‹',
26
- next: '',
27
- first: '«',
28
- last: '»'
25
+ previous: function previous() {
26
+ return '';
27
+ },
28
+ next: function next() {
29
+ return '›';
30
+ },
31
+ page: function page(_ref) {
32
+ var _page = _ref.page;
33
+ return "".concat(_page);
34
+ },
35
+ first: function first() {
36
+ return '«';
37
+ },
38
+ last: function last() {
39
+ return '»';
40
+ }
29
41
  };
30
- var renderer = function renderer(_ref) {
31
- var containerNode = _ref.containerNode,
32
- cssClasses = _ref.cssClasses,
33
- templates = _ref.templates,
34
- showFirst = _ref.showFirst,
35
- showLast = _ref.showLast,
36
- showPrevious = _ref.showPrevious,
37
- showNext = _ref.showNext,
38
- scrollToNode = _ref.scrollToNode;
39
- return function (_ref2, isFirstRendering) {
40
- var createURL = _ref2.createURL,
41
- currentRefinement = _ref2.currentRefinement,
42
- nbPages = _ref2.nbPages,
43
- pages = _ref2.pages,
44
- isFirstPage = _ref2.isFirstPage,
45
- isLastPage = _ref2.isLastPage,
46
- refine = _ref2.refine;
42
+ var renderer = function renderer(_ref2) {
43
+ var containerNode = _ref2.containerNode,
44
+ cssClasses = _ref2.cssClasses,
45
+ templates = _ref2.templates,
46
+ showFirst = _ref2.showFirst,
47
+ showLast = _ref2.showLast,
48
+ showPrevious = _ref2.showPrevious,
49
+ showNext = _ref2.showNext,
50
+ scrollToNode = _ref2.scrollToNode;
51
+ return function (_ref3, isFirstRendering) {
52
+ var createURL = _ref3.createURL,
53
+ currentRefinement = _ref3.currentRefinement,
54
+ nbPages = _ref3.nbPages,
55
+ pages = _ref3.pages,
56
+ isFirstPage = _ref3.isFirstPage,
57
+ isLastPage = _ref3.isLastPage,
58
+ refine = _ref3.refine;
47
59
  if (isFirstRendering) return;
48
60
  var setCurrentPage = function setCurrentPage(pageNumber) {
49
61
  refine(pageNumber);
@@ -69,24 +81,24 @@ var renderer = function renderer(_ref) {
69
81
  };
70
82
  };
71
83
  var pagination = function pagination(widgetParams) {
72
- var _ref3 = widgetParams || {},
73
- container = _ref3.container,
74
- _ref3$templates = _ref3.templates,
75
- userTemplates = _ref3$templates === void 0 ? {} : _ref3$templates,
76
- _ref3$cssClasses = _ref3.cssClasses,
77
- userCssClasses = _ref3$cssClasses === void 0 ? {} : _ref3$cssClasses,
78
- totalPages = _ref3.totalPages,
79
- padding = _ref3.padding,
80
- _ref3$showFirst = _ref3.showFirst,
81
- showFirst = _ref3$showFirst === void 0 ? true : _ref3$showFirst,
82
- _ref3$showLast = _ref3.showLast,
83
- showLast = _ref3$showLast === void 0 ? true : _ref3$showLast,
84
- _ref3$showPrevious = _ref3.showPrevious,
85
- showPrevious = _ref3$showPrevious === void 0 ? true : _ref3$showPrevious,
86
- _ref3$showNext = _ref3.showNext,
87
- showNext = _ref3$showNext === void 0 ? true : _ref3$showNext,
88
- _ref3$scrollTo = _ref3.scrollTo,
89
- userScrollTo = _ref3$scrollTo === void 0 ? 'body' : _ref3$scrollTo;
84
+ var _ref4 = widgetParams || {},
85
+ container = _ref4.container,
86
+ _ref4$templates = _ref4.templates,
87
+ userTemplates = _ref4$templates === void 0 ? {} : _ref4$templates,
88
+ _ref4$cssClasses = _ref4.cssClasses,
89
+ userCssClasses = _ref4$cssClasses === void 0 ? {} : _ref4$cssClasses,
90
+ totalPages = _ref4.totalPages,
91
+ padding = _ref4.padding,
92
+ _ref4$showFirst = _ref4.showFirst,
93
+ showFirst = _ref4$showFirst === void 0 ? true : _ref4$showFirst,
94
+ _ref4$showLast = _ref4.showLast,
95
+ showLast = _ref4$showLast === void 0 ? true : _ref4$showLast,
96
+ _ref4$showPrevious = _ref4.showPrevious,
97
+ showPrevious = _ref4$showPrevious === void 0 ? true : _ref4$showPrevious,
98
+ _ref4$showNext = _ref4.showNext,
99
+ showNext = _ref4$showNext === void 0 ? true : _ref4$showNext,
100
+ _ref4$scrollTo = _ref4.scrollTo,
101
+ userScrollTo = _ref4$scrollTo === void 0 ? 'body' : _ref4$scrollTo;
90
102
  if (!container) {
91
103
  throw new Error(withUsage('The `container` option is required.'));
92
104
  }
@@ -97,8 +97,6 @@ var panel = function panel(panelWidgetParams) {
97
97
  }
98
98
  var containerNode = (0, _utils.getContainerNode)(widgetParams.container);
99
99
  var defaultTemplates = {
100
- header: '',
101
- footer: '',
102
100
  collapseButtonText: function collapseButtonText(_ref4) {
103
101
  var isCollapsed = _ref4.collapsed;
104
102
  return "<svg\n class=\"".concat(cssClasses.collapseIcon, "\"\n style=\"width: 1em; height: 1em;\"\n viewBox=\"0 0 500 500\"\n >\n <path d=\"").concat(isCollapsed ? 'M100 250l300-150v300z' : 'M250 400l150-300H100z', "\" fill=\"currentColor\" />\n </svg>");
@@ -14,6 +14,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
14
14
  function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
15
15
  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; }
16
16
  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; }
17
+ /* Places.js is an optional dependency, no error should be reported if the package is missing */
17
18
  /** @ts-ignore */
18
19
 
19
20
  // using the type like this requires only one ts-ignore
@@ -1774,6 +1774,9 @@ declare type HierarchicalMenuWidgetParams = {
1774
1774
 
1775
1775
  declare function Highlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: HighlightProps<THit>): h.JSX.Element;
1776
1776
 
1777
+ /**
1778
+ * @deprecated use html tagged templates and the Highlight component instead
1779
+ */
1777
1780
  declare function highlight({ attribute, highlightedTagName, hit, cssClasses, }: HighlightOptions): string;
1778
1781
 
1779
1782
  declare type HighlightClassNames = HighlightClassNames_2;
@@ -2475,9 +2478,13 @@ declare type InstantSearchModule = {
2475
2478
  routers: typeof routers;
2476
2479
  stateMappings: typeof stateMappings;
2477
2480
  createInfiniteHitsSessionStorageCache: typeof createInfiniteHitsSessionStorageCache;
2481
+ /** @deprecated use html tagged templates and the Highlight component instead */
2478
2482
  highlight: typeof helpers.highlight;
2483
+ /** @deprecated use html tagged templates and the ReverseHighlight component instead */
2479
2484
  reverseHighlight: typeof helpers.reverseHighlight;
2485
+ /** @deprecated use html tagged templates and the Snippet component instead */
2480
2486
  snippet: typeof helpers.snippet;
2487
+ /** @deprecated use html tagged templates and the ReverseSnippet component instead */
2481
2488
  reverseSnippet: typeof helpers.reverseSnippet;
2482
2489
  /**
2483
2490
  * @deprecated use createInsightsMiddleware
@@ -3140,19 +3147,26 @@ declare type PaginationTemplates = Partial<{
3140
3147
  /**
3141
3148
  * Label for the Previous link.
3142
3149
  */
3143
- previous: string;
3150
+ previous: Template;
3144
3151
  /**
3145
3152
  * Label for the Next link.
3146
3153
  */
3147
- next: string;
3154
+ next: Template;
3155
+ /**
3156
+ * Label for the link of a certain page
3157
+ * Page is one-based, so `page` will be `1` for the first page.
3158
+ */
3159
+ page: Template<{
3160
+ page: number;
3161
+ }>;
3148
3162
  /**
3149
3163
  * Label for the First link.
3150
3164
  */
3151
- first: string;
3165
+ first: Template;
3152
3166
  /**
3153
3167
  * Label for the Last link.
3154
3168
  */
3155
- last: string;
3169
+ last: Template;
3156
3170
  }>;
3157
3171
 
3158
3172
  declare type PaginationWidget = WidgetFactory<PaginationWidgetDescription & {
@@ -4459,6 +4473,9 @@ declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> =
4459
4473
 
4460
4474
  declare function ReverseHighlight<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseHighlightProps<THit>): h.JSX.Element;
4461
4475
 
4476
+ /**
4477
+ * @deprecated use html tagged templates and the ReverseHighlight component instead
4478
+ */
4462
4479
  declare function reverseHighlight({ attribute, highlightedTagName, hit, cssClasses, }: ReverseHighlightOptions): string;
4463
4480
 
4464
4481
  declare type ReverseHighlightClassNames = HighlightClassNames_2;
@@ -4484,6 +4501,9 @@ declare type ReverseHighlightProps_2 = Omit<HighlightProps_3, 'classNames'> & {
4484
4501
 
4485
4502
  declare function ReverseSnippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: ReverseSnippetProps<THit>): h.JSX.Element;
4486
4503
 
4504
+ /**
4505
+ * @deprecated use html tagged templates and the ReverseSnippet component instead
4506
+ */
4487
4507
  declare function reverseSnippet({ attribute, highlightedTagName, hit, cssClasses, }: ReverseSnippetOptions): string;
4488
4508
 
4489
4509
  declare type ReverseSnippetClassNames = HighlightClassNames_2;
@@ -4770,6 +4790,9 @@ declare function singleIndexStateMapping<TUiState extends UiState = UiState>(ind
4770
4790
 
4771
4791
  declare function Snippet<THit extends Hit<BaseHit>>({ hit, attribute, cssClasses, ...props }: SnippetProps<THit>): h.JSX.Element;
4772
4792
 
4793
+ /**
4794
+ * @deprecated use html tagged templates and the Snippet component instead
4795
+ */
4773
4796
  declare function snippet({ attribute, highlightedTagName, hit, cssClasses, }: SnippetOptions): string;
4774
4797
 
4775
4798
  declare type SnippetClassNames = HighlightClassNames_2;