instantsearch.js 4.52.0 → 4.54.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 (30) hide show
  1. package/README.md +1 -16
  2. package/cjs/connectors/current-refinements/connectCurrentRefinements.js +4 -0
  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/lib/version.js +1 -1
  8. package/cjs/widgets/panel/panel.js +1 -1
  9. package/cjs/widgets/places/places.js +1 -0
  10. package/cjs/widgets/search-box/defaultTemplates.js +6 -3
  11. package/dist/instantsearch.development.d.ts +4 -0
  12. package/dist/instantsearch.development.js +34 -6
  13. package/dist/instantsearch.development.js.map +1 -1
  14. package/dist/instantsearch.production.d.ts +4 -0
  15. package/dist/instantsearch.production.min.d.ts +4 -0
  16. package/dist/instantsearch.production.min.js +2 -2
  17. package/dist/instantsearch.production.min.js.map +1 -1
  18. package/es/connectors/current-refinements/connectCurrentRefinements.d.ts +4 -0
  19. package/es/connectors/current-refinements/connectCurrentRefinements.js +4 -0
  20. package/es/connectors/hierarchical-menu/connectHierarchicalMenu.js +4 -0
  21. package/es/connectors/menu/connectMenu.js +5 -1
  22. package/es/connectors/refinement-list/connectRefinementList.js +9 -1
  23. package/es/connectors/toggle-refinement/connectToggleRefinement.js +5 -1
  24. package/es/lib/version.d.ts +1 -1
  25. package/es/lib/version.js +1 -1
  26. package/es/widgets/panel/panel.js +1 -1
  27. package/es/widgets/places/places.d.ts +1 -1
  28. package/es/widgets/places/places.js +1 -0
  29. package/es/widgets/search-box/defaultTemplates.js +6 -3
  30. package/package.json +5 -5
@@ -34,6 +34,10 @@ export type CurrentRefinementsConnectorParamsItem = {
34
34
  * The index name.
35
35
  */
36
36
  indexName: string;
37
+ /**
38
+ * The index id as provided to the index widget.
39
+ */
40
+ indexId: string;
37
41
  /**
38
42
  * The attribute on which the refinement is applied.
39
43
  */
@@ -62,6 +62,7 @@ var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
62
62
  return transformItems(getRefinementsItems({
63
63
  results: {},
64
64
  helper: helper,
65
+ indexId: helper.state.index,
65
66
  includedAttributes: includedAttributes,
66
67
  excludedAttributes: excludedAttributes
67
68
  }), {
@@ -72,6 +73,7 @@ var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
72
73
  return accResults.concat(transformItems(getRefinementsItems({
73
74
  results: scopedResult.results,
74
75
  helper: scopedResult.helper,
76
+ indexId: scopedResult.indexId,
75
77
  includedAttributes: includedAttributes,
76
78
  excludedAttributes: excludedAttributes
77
79
  }), {
@@ -98,6 +100,7 @@ var connectCurrentRefinements = function connectCurrentRefinements(renderFn) {
98
100
  function getRefinementsItems(_ref3) {
99
101
  var results = _ref3.results,
100
102
  helper = _ref3.helper,
103
+ indexId = _ref3.indexId,
101
104
  includedAttributes = _ref3.includedAttributes,
102
105
  excludedAttributes = _ref3.excludedAttributes;
103
106
  var includesQuery = (includedAttributes || []).indexOf('query') !== -1 || (excludedAttributes || []).indexOf('query') === -1;
@@ -112,6 +115,7 @@ function getRefinementsItems(_ref3) {
112
115
  return item.attribute !== currentItem.attribute;
113
116
  })), [{
114
117
  indexName: helper.state.index,
118
+ indexId: indexId,
115
119
  attribute: currentItem.attribute,
116
120
  label: currentItem.attribute,
117
121
  refinements: items.filter(function (result) {
@@ -203,6 +203,10 @@ var connectHierarchicalMenu = function connectHierarchicalMenu(renderFn) {
203
203
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
204
204
  var uiState = _ref6.uiState;
205
205
  var values = uiState.hierarchicalMenu && uiState.hierarchicalMenu[hierarchicalFacetName];
206
+ if (searchParameters.isConjunctiveFacet(hierarchicalFacetName) || searchParameters.isDisjunctiveFacet(hierarchicalFacetName)) {
207
+ process.env.NODE_ENV === 'development' ? 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;
208
+ return searchParameters;
209
+ }
206
210
  if (searchParameters.isHierarchicalFacet(hierarchicalFacetName)) {
207
211
  var facet = searchParameters.getHierarchicalFacetByName(hierarchicalFacetName);
208
212
  process.env.NODE_ENV === 'development' ? warning(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;
@@ -13,7 +13,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
13
13
  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; }
14
14
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
15
15
  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); }
16
- import { checkRendering, createDocumentationMessageGenerator, createSendEventForFacet, noop } from "../../lib/utils/index.js";
16
+ import { checkRendering, createDocumentationMessageGenerator, createSendEventForFacet, noop, warning } from "../../lib/utils/index.js";
17
17
  var withUsage = createDocumentationMessageGenerator({
18
18
  name: 'menu',
19
19
  connector: true
@@ -175,6 +175,10 @@ var connectMenu = function connectMenu(renderFn) {
175
175
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref5) {
176
176
  var uiState = _ref5.uiState;
177
177
  var value = uiState.menu && uiState.menu[attribute];
178
+ if (searchParameters.isConjunctiveFacet(attribute) || searchParameters.isDisjunctiveFacet(attribute)) {
179
+ process.env.NODE_ENV === 'development' ? 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;
180
+ return searchParameters;
181
+ }
178
182
  var withFacetConfiguration = searchParameters.removeHierarchicalFacet(attribute).addHierarchicalFacet({
179
183
  name: attribute,
180
184
  attributes: [attribute]
@@ -8,7 +8,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
8
8
  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); }
9
9
  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; }
10
10
  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; }
11
- import { escapeFacets, TAG_PLACEHOLDER, TAG_REPLACEMENT, checkRendering, createDocumentationMessageGenerator, createSendEventForFacet, noop } from "../../lib/utils/index.js";
11
+ import { escapeFacets, TAG_PLACEHOLDER, TAG_REPLACEMENT, checkRendering, createDocumentationMessageGenerator, createSendEventForFacet, noop, warning } from "../../lib/utils/index.js";
12
12
  var withUsage = createDocumentationMessageGenerator({
13
13
  name: 'refinement-list',
14
14
  connector: true
@@ -247,6 +247,14 @@ var connectRefinementList = function connectRefinementList(renderFn) {
247
247
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref6) {
248
248
  var uiState = _ref6.uiState;
249
249
  var isDisjunctive = operator === 'or';
250
+ if (searchParameters.isHierarchicalFacet(attribute)) {
251
+ process.env.NODE_ENV === 'development' ? 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;
252
+ return searchParameters;
253
+ }
254
+ if (isDisjunctive && searchParameters.isConjunctiveFacet(attribute) || !isDisjunctive && searchParameters.isDisjunctiveFacet(attribute)) {
255
+ process.env.NODE_ENV === 'development' ? 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;
256
+ return searchParameters;
257
+ }
250
258
  var values = uiState.refinementList && uiState.refinementList[attribute];
251
259
  var withoutRefinements = searchParameters.clearRefinements(attribute);
252
260
  var withFacetConfiguration = isDisjunctive ? withoutRefinements.addDisjunctiveFacet(attribute) : withoutRefinements.addFacet(attribute);
@@ -4,7 +4,7 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
  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; }
5
5
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
6
6
  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); }
7
- import { checkRendering, escapeFacetValue, createDocumentationMessageGenerator, find, noop, toArray } from "../../lib/utils/index.js";
7
+ import { checkRendering, escapeFacetValue, createDocumentationMessageGenerator, find, noop, toArray, warning } from "../../lib/utils/index.js";
8
8
  var withUsage = createDocumentationMessageGenerator({
9
9
  name: 'toggle-refinement',
10
10
  connector: true
@@ -251,6 +251,10 @@ var connectToggleRefinement = function connectToggleRefinement(renderFn) {
251
251
  },
252
252
  getWidgetSearchParameters: function getWidgetSearchParameters(searchParameters, _ref11) {
253
253
  var uiState = _ref11.uiState;
254
+ if (searchParameters.isHierarchicalFacet(attribute) || searchParameters.isConjunctiveFacet(attribute)) {
255
+ process.env.NODE_ENV === 'development' ? 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;
256
+ return searchParameters;
257
+ }
254
258
  var withFacetConfiguration = searchParameters.clearRefinements(attribute).addDisjunctiveFacet(attribute);
255
259
  var isRefined = Boolean(uiState.toggle && uiState.toggle[attribute]);
256
260
  if (isRefined) {
@@ -1,2 +1,2 @@
1
- declare const _default: "4.52.0";
1
+ declare const _default: "4.54.0";
2
2
  export default _default;
package/es/lib/version.js CHANGED
@@ -1 +1 @@
1
- export default '4.52.0';
1
+ export default '4.54.0';
@@ -94,7 +94,7 @@ var panel = function panel(panelWidgetParams) {
94
94
  footer: '',
95
95
  collapseButtonText: function collapseButtonText(_ref4) {
96
96
  var isCollapsed = _ref4.collapsed;
97
- return "<svg\n class=\"".concat(cssClasses.collapseIcon, "\"\n width=\"1em\"\n height=\"1em\"\n viewBox=\"0 0 500 500\"\n >\n <path d=\"").concat(isCollapsed ? 'M100 250l300-150v300z' : 'M250 400l150-300H100z', "\" fill=\"currentColor\" />\n </svg>");
97
+ 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>");
98
98
  }
99
99
  };
100
100
  var renderPanel = renderer({
@@ -1,5 +1,5 @@
1
- // @ts-ignore
2
1
  import type { WidgetFactory, WidgetRenderState } from '../../types';
2
+ // @ts-ignore
3
3
  import type * as Places from 'places.js';
4
4
  type StaticOptions = Places.StaticOptions;
5
5
  type PlacesInstance = Places.PlacesInstance;
@@ -8,6 +8,7 @@ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _ty
8
8
  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); }
9
9
  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; }
10
10
  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; }
11
+ /* Places.js is an optional dependency, no error should be reported if the package is missing */
11
12
  /** @ts-ignore */
12
13
 
13
14
  // using the type like this requires only one ts-ignore
@@ -33,7 +33,8 @@ var defaultTemplate = {
33
33
  className: cssClasses.resetIcon,
34
34
  viewBox: "0 0 20 20",
35
35
  width: "10",
36
- height: "10"
36
+ height: "10",
37
+ "aria-hidden": "true"
37
38
  }, _ref2);
38
39
  },
39
40
  submit: function submit(_ref3) {
@@ -42,7 +43,8 @@ var defaultTemplate = {
42
43
  className: cssClasses.submitIcon,
43
44
  width: "10",
44
45
  height: "10",
45
- viewBox: "0 0 40 40"
46
+ viewBox: "0 0 40 40",
47
+ "aria-hidden": "true"
46
48
  }, _ref4);
47
49
  },
48
50
  loadingIndicator: function loadingIndicator(_ref5) {
@@ -52,7 +54,8 @@ var defaultTemplate = {
52
54
  width: "16",
53
55
  height: "16",
54
56
  viewBox: "0 0 38 38",
55
- stroke: "#444"
57
+ stroke: "#444",
58
+ "aria-hidden": "true"
56
59
  }, _ref6);
57
60
  }
58
61
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.52.0",
3
+ "version": "4.54.0",
4
4
  "description": "InstantSearch.js is a JavaScript library for building performant and instant search experiences with Algolia.",
5
5
  "homepage": "https://www.algolia.com/doc/guides/building-search-ui/what-is-instantsearch/js/",
6
6
  "types": "es/index.d.ts",
@@ -55,9 +55,9 @@
55
55
  "version": "./scripts/version/update-version.js"
56
56
  },
57
57
  "devDependencies": {
58
- "@instantsearch/mocks": "1.8.0",
59
- "@instantsearch/tests": "1.8.0",
60
- "@instantsearch/testutils": "1.0.11",
58
+ "@instantsearch/mocks": "1.10.0",
59
+ "@instantsearch/tests": "1.10.0",
60
+ "@instantsearch/testutils": "1.0.13",
61
61
  "@storybook/html": "5.3.9",
62
62
  "@types/scriptjs": "0.0.2",
63
63
  "algoliasearch": "4.14.3",
@@ -65,5 +65,5 @@
65
65
  "scriptjs": "2.5.9",
66
66
  "webpack": "4.41.5"
67
67
  },
68
- "gitHead": "24ab56e4b18d69cc68919f994f8d8a3f1c880d33"
68
+ "gitHead": "419aa9869727dceeb49dfc5289a0b9241e0e5827"
69
69
  }