instantsearch.js 4.46.0 → 4.46.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 (165) hide show
  1. package/CHANGELOG.md +12 -1
  2. package/cjs/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
  3. package/cjs/helpers/components/Highlight.js +7 -7
  4. package/cjs/helpers/components/ReverseHighlight.js +7 -7
  5. package/cjs/helpers/components/ReverseSnippet.js +7 -7
  6. package/cjs/helpers/components/Snippet.js +7 -7
  7. package/cjs/lib/InstantSearch.js +33 -24
  8. package/cjs/lib/utils/capitalize.js +2 -5
  9. package/cjs/lib/utils/checkIndexUiState.js +3 -5
  10. package/cjs/lib/utils/checkRendering.js +4 -9
  11. package/cjs/lib/utils/clearRefinements.js +3 -9
  12. package/cjs/lib/utils/concatHighlightedParts.js +1 -1
  13. package/cjs/lib/utils/createSendEventForFacet.js +2 -4
  14. package/cjs/lib/utils/defer.js +3 -6
  15. package/cjs/lib/utils/detect-insights-client.js +1 -1
  16. package/cjs/lib/utils/documentation.js +6 -9
  17. package/cjs/lib/utils/escape-highlight.js +4 -6
  18. package/cjs/lib/utils/escape-html.js +60 -0
  19. package/cjs/lib/utils/find.js +2 -5
  20. package/cjs/lib/utils/findIndex.js +2 -5
  21. package/cjs/lib/utils/getContainerNode.js +4 -9
  22. package/cjs/lib/utils/getHighlightFromSiblings.js +3 -5
  23. package/cjs/lib/utils/getHighlightedParts.js +1 -1
  24. package/cjs/lib/utils/getObjectType.js +2 -5
  25. package/cjs/lib/utils/getPropertyByPath.js +2 -5
  26. package/cjs/lib/utils/getRefinements.js +4 -6
  27. package/cjs/lib/utils/index.js +562 -440
  28. package/cjs/lib/utils/isDomElement.js +2 -5
  29. package/cjs/lib/utils/isEqual.js +2 -5
  30. package/cjs/lib/utils/isFacetRefined.js +1 -1
  31. package/cjs/lib/utils/isFiniteNumber.js +3 -5
  32. package/cjs/lib/utils/isIndexWidget.js +10 -0
  33. package/cjs/lib/utils/isPlainObject.js +2 -5
  34. package/cjs/lib/utils/isSpecialClick.js +2 -5
  35. package/cjs/lib/utils/logger.js +3 -5
  36. package/cjs/lib/utils/mergeSearchParameters.js +7 -10
  37. package/cjs/lib/utils/noop.js +2 -5
  38. package/cjs/lib/utils/prepareTemplateProps.js +4 -9
  39. package/cjs/lib/utils/range.js +2 -5
  40. package/cjs/lib/utils/renderTemplate.js +2 -5
  41. package/cjs/lib/utils/resolveSearchParameters.js +3 -6
  42. package/cjs/lib/utils/reverseHighlightedParts.js +3 -5
  43. package/cjs/lib/utils/setIndexHelperState.js +28 -0
  44. package/cjs/lib/utils/toArray.js +2 -5
  45. package/cjs/lib/utils/uniq.js +2 -5
  46. package/cjs/lib/version.js +1 -1
  47. package/cjs/middlewares/createInsightsMiddleware.js +23 -30
  48. package/cjs/middlewares/createMetadataMiddleware.js +1 -0
  49. package/cjs/middlewares/createRouterMiddleware.js +1 -0
  50. package/cjs/widgets/index/index.js +8 -12
  51. package/dist/instantsearch.development.d.ts +11 -3
  52. package/dist/instantsearch.development.js +2242 -2181
  53. package/dist/instantsearch.development.js.map +1 -1
  54. package/dist/instantsearch.production.d.ts +11 -3
  55. package/dist/instantsearch.production.min.d.ts +11 -3
  56. package/dist/instantsearch.production.min.js +2 -2
  57. package/dist/instantsearch.production.min.js.map +1 -1
  58. package/es/components/Breadcrumb/Breadcrumb.d.ts +1 -1
  59. package/es/components/ClearRefinements/ClearRefinements.d.ts +1 -1
  60. package/es/components/GeoSearchControls/GeoSearchControls.d.ts +1 -1
  61. package/es/components/Hits/Hits.d.ts +1 -2
  62. package/es/components/RefinementList/RefinementList.d.ts +1 -1
  63. package/es/components/Template/Template.d.ts +1 -2
  64. package/es/components/ToggleRefinement/ToggleRefinement.d.ts +1 -4
  65. package/es/components/ToggleRefinement/ToggleRefinement.js +0 -4
  66. package/es/connectors/toggle-refinement/connectToggleRefinement.d.ts +3 -2
  67. package/es/connectors/toggle-refinement/connectToggleRefinement.js +3 -1
  68. package/es/helpers/components/Highlight.js +7 -5
  69. package/es/helpers/components/ReverseHighlight.js +7 -5
  70. package/es/helpers/components/ReverseSnippet.js +7 -5
  71. package/es/helpers/components/Snippet.js +7 -5
  72. package/es/lib/InstantSearch.d.ts +6 -1
  73. package/es/lib/InstantSearch.js +34 -21
  74. package/es/lib/utils/capitalize.d.ts +1 -2
  75. package/es/lib/utils/capitalize.js +2 -4
  76. package/es/lib/utils/checkIndexUiState.js +1 -1
  77. package/es/lib/utils/checkRendering.d.ts +1 -2
  78. package/es/lib/utils/checkRendering.js +3 -6
  79. package/es/lib/utils/clearRefinements.d.ts +4 -8
  80. package/es/lib/utils/clearRefinements.js +3 -8
  81. package/es/lib/utils/concatHighlightedParts.d.ts +1 -1
  82. package/es/lib/utils/concatHighlightedParts.js +1 -1
  83. package/es/lib/utils/createSendEventForFacet.js +1 -1
  84. package/es/lib/utils/createSendEventForHits.d.ts +0 -3
  85. package/es/lib/utils/createSendEventForHits.js +0 -3
  86. package/es/lib/utils/defer.d.ts +2 -2
  87. package/es/lib/utils/defer.js +2 -5
  88. package/es/lib/utils/detect-insights-client.d.ts +1 -1
  89. package/es/lib/utils/detect-insights-client.js +1 -1
  90. package/es/lib/utils/documentation.d.ts +2 -2
  91. package/es/lib/utils/documentation.js +4 -4
  92. package/es/lib/utils/escape-highlight.js +2 -2
  93. package/es/lib/utils/{escape.d.ts → escape-html.d.ts} +6 -2
  94. package/es/lib/utils/escape-html.js +51 -0
  95. package/es/lib/utils/escapeFacetValue.d.ts +1 -1
  96. package/es/lib/utils/find.d.ts +1 -2
  97. package/es/lib/utils/find.js +2 -4
  98. package/es/lib/utils/findIndex.d.ts +1 -2
  99. package/es/lib/utils/findIndex.js +2 -4
  100. package/es/lib/utils/getContainerNode.d.ts +1 -2
  101. package/es/lib/utils/getContainerNode.js +3 -5
  102. package/es/lib/utils/getHighlightFromSiblings.d.ts +1 -1
  103. package/es/lib/utils/getHighlightFromSiblings.js +2 -2
  104. package/es/lib/utils/getHighlightedParts.d.ts +1 -1
  105. package/es/lib/utils/getHighlightedParts.js +1 -1
  106. package/es/lib/utils/getObjectType.d.ts +1 -2
  107. package/es/lib/utils/getObjectType.js +2 -4
  108. package/es/lib/utils/getPropertyByPath.d.ts +1 -2
  109. package/es/lib/utils/getPropertyByPath.js +2 -4
  110. package/es/lib/utils/getRefinements.d.ts +1 -1
  111. package/es/lib/utils/getRefinements.js +2 -2
  112. package/es/lib/utils/index.d.ts +46 -46
  113. package/es/lib/utils/index.js +46 -46
  114. package/es/lib/utils/isDomElement.d.ts +1 -2
  115. package/es/lib/utils/isDomElement.js +2 -4
  116. package/es/lib/utils/isEqual.d.ts +1 -2
  117. package/es/lib/utils/isEqual.js +2 -4
  118. package/es/lib/utils/isFacetRefined.d.ts +1 -1
  119. package/es/lib/utils/isFacetRefined.js +1 -1
  120. package/es/lib/utils/isFiniteNumber.d.ts +1 -2
  121. package/es/lib/utils/isFiniteNumber.js +3 -4
  122. package/es/lib/utils/isIndexWidget.d.ts +3 -0
  123. package/es/lib/utils/isIndexWidget.js +3 -0
  124. package/es/lib/utils/isPlainObject.d.ts +1 -2
  125. package/es/lib/utils/isPlainObject.js +2 -4
  126. package/es/lib/utils/isSpecialClick.d.ts +1 -2
  127. package/es/lib/utils/isSpecialClick.js +2 -4
  128. package/es/lib/utils/logger.js +1 -1
  129. package/es/lib/utils/mergeSearchParameters.d.ts +1 -2
  130. package/es/lib/utils/mergeSearchParameters.js +4 -6
  131. package/es/lib/utils/noop.d.ts +1 -2
  132. package/es/lib/utils/noop.js +1 -3
  133. package/es/lib/utils/prepareTemplateProps.d.ts +2 -2
  134. package/es/lib/utils/prepareTemplateProps.js +3 -5
  135. package/es/lib/utils/range.d.ts +2 -2
  136. package/es/lib/utils/range.js +2 -4
  137. package/es/lib/utils/renderTemplate.d.ts +1 -2
  138. package/es/lib/utils/renderTemplate.js +2 -4
  139. package/es/lib/utils/resolveSearchParameters.d.ts +1 -2
  140. package/es/lib/utils/resolveSearchParameters.js +2 -4
  141. package/es/lib/utils/reverseHighlightedParts.d.ts +1 -1
  142. package/es/lib/utils/reverseHighlightedParts.js +2 -2
  143. package/es/lib/utils/setIndexHelperState.d.ts +3 -0
  144. package/es/lib/utils/setIndexHelperState.js +19 -0
  145. package/es/lib/utils/toArray.d.ts +3 -2
  146. package/es/lib/utils/toArray.js +2 -4
  147. package/es/lib/utils/uniq.d.ts +1 -2
  148. package/es/lib/utils/uniq.js +2 -4
  149. package/es/lib/version.d.ts +1 -1
  150. package/es/lib/version.js +1 -1
  151. package/es/middlewares/createInsightsMiddleware.js +23 -27
  152. package/es/middlewares/createMetadataMiddleware.js +1 -0
  153. package/es/middlewares/createRouterMiddleware.js +1 -0
  154. package/es/types/middleware.d.ts +1 -0
  155. package/es/widgets/index/index.d.ts +0 -1
  156. package/es/widgets/index/index.js +5 -6
  157. package/package.json +5 -5
  158. package/cjs/lib/utils/convertNumericRefinementsToFilters.js +0 -31
  159. package/cjs/lib/utils/escape.js +0 -35
  160. package/cjs/lib/utils/unescape.js +0 -32
  161. package/es/lib/utils/convertNumericRefinementsToFilters.d.ts +0 -2
  162. package/es/lib/utils/convertNumericRefinementsToFilters.js +0 -24
  163. package/es/lib/utils/escape.js +0 -27
  164. package/es/lib/utils/unescape.d.ts +0 -9
  165. package/es/lib/utils/unescape.js +0 -25
@@ -10,7 +10,7 @@ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToAr
10
10
 
11
11
  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; }
12
12
 
13
- function range(_ref) {
13
+ export function range(_ref) {
14
14
  var _ref$start = _ref.start,
15
15
  start = _ref$start === void 0 ? 0 : _ref$start,
16
16
  end = _ref.end,
@@ -27,6 +27,4 @@ function range(_ref) {
27
27
  return _toConsumableArray(Array(arrayLength)).map(function (_, current) {
28
28
  return start + current * limitStep;
29
29
  });
30
- }
31
-
32
- export default range;
30
+ }
@@ -1,7 +1,7 @@
1
1
  import type { HoganOptions } from 'hogan.js';
2
2
  import type { Templates, HoganHelpers } from '../../types';
3
3
  import type { BindEventForHits, SendEventForHits } from './createSendEventForHits';
4
- declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
4
+ export declare function renderTemplate({ templates, templateKey, compileOptions, helpers, data, bindEvent, sendEvent, }: {
5
5
  templates: Templates;
6
6
  templateKey: string;
7
7
  compileOptions?: HoganOptions;
@@ -10,4 +10,3 @@ declare function renderTemplate({ templates, templateKey, compileOptions, helper
10
10
  bindEvent?: BindEventForHits;
11
11
  sendEvent?: SendEventForHits;
12
12
  }): string | import("preact").VNode<{}> | import("preact").VNode<{}>[];
13
- export default renderTemplate;
@@ -33,7 +33,7 @@ function transformHelpersToHogan() {
33
33
  }, {});
34
34
  }
35
35
 
36
- function renderTemplate(_ref) {
36
+ export function renderTemplate(_ref) {
37
37
  var templates = _ref.templates,
38
38
  templateKey = _ref.templateKey,
39
39
  compileOptions = _ref.compileOptions,
@@ -67,6 +67,4 @@ function renderTemplate(_ref) {
67
67
  })).replace(/[ \n\r\t\f\xA0]+/g, function (spaces) {
68
68
  return spaces.replace(/(^|\xA0+)[^\xA0]+/g, '$1 ');
69
69
  }).trim();
70
- }
71
-
72
- export default renderTemplate;
70
+ }
@@ -1,4 +1,3 @@
1
1
  import type { SearchParameters } from 'algoliasearch-helper';
2
2
  import type { IndexWidget } from '../../widgets/index/index';
3
- declare const resolveSearchParameters: (current: IndexWidget) => SearchParameters[];
4
- export default resolveSearchParameters;
3
+ export declare function resolveSearchParameters(current: IndexWidget): SearchParameters[];
@@ -1,4 +1,4 @@
1
- var resolveSearchParameters = function resolveSearchParameters(current) {
1
+ export function resolveSearchParameters(current) {
2
2
  var parent = current.getParent();
3
3
  var states = [current.getHelper().state];
4
4
 
@@ -8,6 +8,4 @@ var resolveSearchParameters = function resolveSearchParameters(current) {
8
8
  }
9
9
 
10
10
  return states;
11
- };
12
-
13
- export default resolveSearchParameters;
11
+ }
@@ -1,5 +1,5 @@
1
1
  import type { HighlightedParts } from '../../types';
2
- export default function reverseHighlightedParts(parts: HighlightedParts[]): {
2
+ export declare function reverseHighlightedParts(parts: HighlightedParts[]): {
3
3
  isHighlighted: boolean;
4
4
  value: string;
5
5
  }[];
@@ -4,8 +4,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
4
4
 
5
5
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
6
 
7
- import getHighlightFromSiblings from "./getHighlightFromSiblings.js";
8
- export default function reverseHighlightedParts(parts) {
7
+ import { getHighlightFromSiblings } from "./getHighlightFromSiblings.js";
8
+ export function reverseHighlightedParts(parts) {
9
9
  if (!parts.some(function (part) {
10
10
  return part.isHighlighted;
11
11
  })) {
@@ -0,0 +1,3 @@
1
+ import type { UiState } from '../../types';
2
+ import type { IndexWidget } from '../../widgets/index/index';
3
+ export declare function setIndexHelperState<TUiState extends UiState>(finalUiState: TUiState, indexWidget: IndexWidget): void;
@@ -0,0 +1,19 @@
1
+ import { isIndexWidget } from "./isIndexWidget.js";
2
+ import { checkIndexUiState } from "./checkIndexUiState.js";
3
+ export function setIndexHelperState(finalUiState, indexWidget) {
4
+ var nextIndexUiState = finalUiState[indexWidget.getIndexId()] || {};
5
+
6
+ if (process.env.NODE_ENV === 'development') {
7
+ checkIndexUiState({
8
+ index: indexWidget,
9
+ indexUiState: nextIndexUiState
10
+ });
11
+ }
12
+
13
+ indexWidget.getHelper().setState(indexWidget.getWidgetSearchParameters(indexWidget.getHelper().state, {
14
+ uiState: nextIndexUiState
15
+ }));
16
+ indexWidget.getWidgets().filter(isIndexWidget).forEach(function (widget) {
17
+ return setIndexHelperState(finalUiState, widget);
18
+ });
19
+ }
@@ -1,2 +1,3 @@
1
- declare function toArray(value: any): any[];
2
- export default toArray;
1
+ declare type ToArray<T> = T extends unknown[] ? T : T[];
2
+ export declare function toArray<T>(value: T): ToArray<T>;
3
+ export {};
@@ -1,5 +1,3 @@
1
- function toArray(value) {
1
+ export function toArray(value) {
2
2
  return Array.isArray(value) ? value : [value];
3
- }
4
-
5
- export default toArray;
3
+ }
@@ -1,2 +1 @@
1
- declare function uniq<TItem>(array: TItem[]): TItem[];
2
- export default uniq;
1
+ export declare function uniq<TItem>(array: TItem[]): TItem[];
@@ -1,7 +1,5 @@
1
- function uniq(array) {
1
+ export function uniq(array) {
2
2
  return array.filter(function (value, index, self) {
3
3
  return self.indexOf(value) === index;
4
4
  });
5
- }
6
-
7
- export default uniq;
5
+ }
@@ -1,2 +1,2 @@
1
- declare const _default: "4.46.0";
1
+ declare const _default: "4.46.1";
2
2
  export default _default;
package/es/lib/version.js CHANGED
@@ -1 +1 @@
1
- export default '4.46.0';
1
+ export default '4.46.1';
@@ -18,7 +18,6 @@ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
18
 
19
19
  import { getInsightsAnonymousUserTokenInternal } from "../helpers/index.js";
20
20
  import { warning, noop, getAppIdAndApiKey, find } from "../lib/utils/index.js";
21
- import connectConfigure from "../connectors/configure/connectConfigure.js";
22
21
  export var createInsightsMiddleware = function createInsightsMiddleware(props) {
23
22
  var _ref = props || {},
24
23
  _insightsClient = _ref.insightsClient,
@@ -86,31 +85,28 @@ export var createInsightsMiddleware = function createInsightsMiddleware(props) {
86
85
  appId: appId,
87
86
  apiKey: apiKey
88
87
  }, insightsInitParams));
89
- var createWidget = connectConfigure(noop);
90
- var configureClickAnalytics;
91
- var configureUserToken;
88
+ var initialParameters;
89
+ var helper;
92
90
  return {
93
91
  onStateChange: function onStateChange() {},
94
- subscribe: function subscribe() {
92
+ subscribe: function subscribe() {},
93
+ started: function started() {
95
94
  insightsClient('addAlgoliaAgent', 'insights-middleware');
96
- configureClickAnalytics = createWidget({
97
- searchParameters: {
98
- clickAnalytics: true
99
- }
100
- });
101
- instantSearchInstance.addWidgets([configureClickAnalytics]);
95
+ helper = instantSearchInstance.helper;
96
+ initialParameters = {
97
+ userToken: helper.state.userToken,
98
+ clickAnalytics: helper.state.clickAnalytics
99
+ };
100
+ helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread(_objectSpread({}, helper.state), {}, {
101
+ clickAnalytics: true
102
+ }));
103
+ instantSearchInstance.scheduleSearch();
102
104
 
103
105
  var setUserTokenToSearch = function setUserTokenToSearch(userToken) {
104
- if (configureUserToken) {
105
- instantSearchInstance.removeWidgets([configureUserToken]);
106
- }
107
-
108
- configureUserToken = createWidget({
109
- searchParameters: {
110
- userToken: userToken
111
- }
112
- });
113
- instantSearchInstance.addWidgets([configureUserToken]);
106
+ helper.overrideStateWithoutTriggeringChangeEvent(_objectSpread(_objectSpread({}, helper.state), {}, {
107
+ userToken: userToken
108
+ }));
109
+ instantSearchInstance.scheduleSearch();
114
110
  };
115
111
 
116
112
  var anonymousUserToken = getInsightsAnonymousUserTokenInternal();
@@ -138,9 +134,7 @@ export var createInsightsMiddleware = function createInsightsMiddleware(props) {
138
134
  if (onEvent) {
139
135
  onEvent(event, _insightsClient);
140
136
  } else if (event.insightsMethod) {
141
- // At this point, instantSearchInstance must be started and
142
- // it means there is a configure widget (added above).
143
- var hasUserToken = Boolean(instantSearchInstance.renderState[instantSearchInstance.indexName].configure.widgetParams.searchParameters.userToken);
137
+ var hasUserToken = Boolean(helper.state.userToken);
144
138
 
145
139
  if (hasUserToken) {
146
140
  insightsClient(event.insightsMethod, event.payload);
@@ -154,10 +148,12 @@ export var createInsightsMiddleware = function createInsightsMiddleware(props) {
154
148
  },
155
149
  unsubscribe: function unsubscribe() {
156
150
  insightsClient('onUserTokenChange', undefined);
157
- instantSearchInstance.removeWidgets([configureClickAnalytics, configureUserToken]);
158
- configureClickAnalytics = undefined;
159
- configureUserToken = undefined;
160
151
  instantSearchInstance.sendEventToInsights = noop;
152
+
153
+ if (helper && initialParameters) {
154
+ helper.setState(_objectSpread(_objectSpread({}, helper.state), initialParameters));
155
+ instantSearchInstance.scheduleSearch();
156
+ }
161
157
  }
162
158
  };
163
159
  };
@@ -85,6 +85,7 @@ export function createMetadataMiddleware() {
85
85
  refNode.appendChild(payloadContainer);
86
86
  }, 0);
87
87
  },
88
+ started: function started() {},
88
89
  unsubscribe: function unsubscribe() {
89
90
  payloadContainer.remove();
90
91
  }
@@ -45,6 +45,7 @@ export var createRouterMiddleware = function createRouterMiddleware() {
45
45
  instantSearchInstance.setUiState(stateMapping.routeToState(route));
46
46
  });
47
47
  },
48
+ started: function started() {},
48
49
  unsubscribe: function unsubscribe() {
49
50
  router.dispose();
50
51
  }
@@ -6,6 +6,7 @@ export declare type MiddlewareDefinition<TUiState extends UiState = UiState> = {
6
6
  uiState: TUiState;
7
7
  }): void;
8
8
  subscribe(): void;
9
+ started(): void;
9
10
  unsubscribe(): void;
10
11
  };
11
12
  export declare type MiddlewareOptions = {
@@ -42,6 +42,5 @@ export declare type IndexWidget = Omit<Widget<IndexWidgetDescription & {
42
42
  }): SearchParameters;
43
43
  refreshUiState(): void;
44
44
  };
45
- export declare function isIndexWidget(widget: Widget | IndexWidget): widget is IndexWidget;
46
45
  declare const index: (widgetParams: IndexWidgetParams) => IndexWidget;
47
46
  export default index;
@@ -21,19 +21,16 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
21
21
  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; }
22
22
 
23
23
  import algoliasearchHelper from 'algoliasearch-helper';
24
- import { checkIndexUiState, createDocumentationMessageGenerator, resolveSearchParameters, mergeSearchParameters, warning } from "../../lib/utils/index.js";
24
+ import { checkIndexUiState, createDocumentationMessageGenerator, resolveSearchParameters, mergeSearchParameters, warning, isIndexWidget } from "../../lib/utils/index.js";
25
25
  var withUsage = createDocumentationMessageGenerator({
26
26
  name: 'index-widget'
27
27
  });
28
- export function isIndexWidget(widget) {
29
- return widget.$$type === 'ais.index';
30
- }
28
+
31
29
  /**
32
30
  * This is the same content as helper._change / setState, but allowing for extra
33
31
  * UiState to be synchronized.
34
32
  * see: https://github.com/algolia/algoliasearch-helper-js/blob/6b835ffd07742f2d6b314022cce6848f5cfecd4a/src/algoliasearch.helper.js#L1311-L1324
35
33
  */
36
-
37
34
  function privateHelperSetState(helper, _ref) {
38
35
  var state = _ref.state,
39
36
  isPageReset = _ref.isPageReset,
@@ -312,7 +309,9 @@ var index = function index(widgetParams) {
312
309
  if (instantSearchInstance.onStateChange) {
313
310
  instantSearchInstance.onStateChange({
314
311
  uiState: instantSearchInstance.mainIndex.getWidgetUiState({}),
315
- setUiState: instantSearchInstance.setUiState.bind(instantSearchInstance)
312
+ setUiState: function setUiState(nextState) {
313
+ return instantSearchInstance.setUiState(nextState, false);
314
+ }
316
315
  }); // We don't trigger a search when controlled because it becomes the
317
316
  // responsibility of `setUiState`.
318
317
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "instantsearch.js",
3
- "version": "4.46.0",
3
+ "version": "4.46.1",
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",
@@ -59,7 +59,7 @@
59
59
  "@types/google.maps": "^3.45.3",
60
60
  "@types/hogan.js": "^3.0.0",
61
61
  "@types/qs": "^6.5.3",
62
- "algoliasearch-helper": "^3.10.0",
62
+ "algoliasearch-helper": "^3.11.1",
63
63
  "classnames": "^2.2.5",
64
64
  "hogan.js": "^3.0.2",
65
65
  "htm": "^3.0.0",
@@ -117,6 +117,7 @@
117
117
  "eslint": "6.8.0",
118
118
  "eslint-config-algolia": "16.0.0",
119
119
  "eslint-config-prettier": "6.9.0",
120
+ "eslint-plugin-deprecation": "1.3.2",
120
121
  "eslint-plugin-eslint-comments": "3.2.0",
121
122
  "eslint-plugin-import": "2.18.2",
122
123
  "eslint-plugin-jasmine": "4.1.0",
@@ -124,7 +125,6 @@
124
125
  "eslint-plugin-prettier": "3.4.0",
125
126
  "eslint-plugin-react": "7.18.0",
126
127
  "eslint-plugin-react-hooks": "2.3.0",
127
- "eslint-plugin-deprecation": "1.3.2",
128
128
  "instantsearch-e2e-tests": "algolia/instantsearch-e2e-tests#2.0.2",
129
129
  "jest": "27.1.0",
130
130
  "jest-diff": "27.1.0",
@@ -159,11 +159,11 @@
159
159
  "bundlesize": [
160
160
  {
161
161
  "path": "./dist/instantsearch.production.min.js",
162
- "maxSize": "72.25 kB"
162
+ "maxSize": "72.50 kB"
163
163
  },
164
164
  {
165
165
  "path": "./dist/instantsearch.development.js",
166
- "maxSize": "155.25 kB"
166
+ "maxSize": "155.50 kB"
167
167
  }
168
168
  ]
169
169
  }
@@ -1,31 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.convertNumericRefinementsToFilters = convertNumericRefinementsToFilters;
7
-
8
- function convertNumericRefinementsToFilters(state, attribute) {
9
- if (!state) {
10
- return null;
11
- }
12
-
13
- var filtersObj = state.numericRefinements[attribute];
14
- /*
15
- filtersObj === {
16
- "<=": [10],
17
- "=": [],
18
- ">=": [5]
19
- }
20
- */
21
-
22
- var filters = [];
23
- Object.keys(filtersObj).filter(function (operator) {
24
- return Array.isArray(filtersObj[operator]) && filtersObj[operator].length > 0;
25
- }).forEach(function (operator) {
26
- filtersObj[operator].forEach(function (value) {
27
- filters.push("".concat(attribute).concat(operator).concat(value));
28
- });
29
- });
30
- return filters;
31
- }
@@ -1,35 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = void 0;
7
-
8
- /**
9
- * This implementation is taken from Lodash implementation.
10
- * See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
11
- */
12
- // Used to map characters to HTML entities.
13
- var htmlEscapes = {
14
- '&': '&amp;',
15
- '<': '&lt;',
16
- '>': '&gt;',
17
- '"': '&quot;',
18
- "'": '&#39;'
19
- }; // Used to match HTML entities and HTML characters.
20
-
21
- var regexUnescapedHtml = /[&<>"']/g;
22
- var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
23
- /**
24
- * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
25
- * corresponding HTML entities.
26
- */
27
-
28
- function escape(value) {
29
- return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
30
- return htmlEscapes[character];
31
- }) : value;
32
- }
33
-
34
- var _default = escape;
35
- exports.default = _default;
@@ -1,32 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = unescape;
7
-
8
- /**
9
- * This implementation is taken from Lodash implementation.
10
- * See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
11
- */
12
- // Used to map HTML entities to characters.
13
- var htmlEscapes = {
14
- '&amp;': '&',
15
- '&lt;': '<',
16
- '&gt;': '>',
17
- '&quot;': '"',
18
- '&#39;': "'"
19
- }; // Used to match HTML entities and HTML characters.
20
-
21
- var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
22
- var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
23
- /**
24
- * Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
25
- * characters.
26
- */
27
-
28
- function unescape(value) {
29
- return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
30
- return htmlEscapes[character];
31
- }) : value;
32
- }
@@ -1,2 +0,0 @@
1
- import type { SearchParameters } from 'algoliasearch-helper';
2
- export declare function convertNumericRefinementsToFilters(state: SearchParameters | null, attribute: string): string[] | null;
@@ -1,24 +0,0 @@
1
- export function convertNumericRefinementsToFilters(state, attribute) {
2
- if (!state) {
3
- return null;
4
- }
5
-
6
- var filtersObj = state.numericRefinements[attribute];
7
- /*
8
- filtersObj === {
9
- "<=": [10],
10
- "=": [],
11
- ">=": [5]
12
- }
13
- */
14
-
15
- var filters = [];
16
- Object.keys(filtersObj).filter(function (operator) {
17
- return Array.isArray(filtersObj[operator]) && filtersObj[operator].length > 0;
18
- }).forEach(function (operator) {
19
- filtersObj[operator].forEach(function (value) {
20
- filters.push("".concat(attribute).concat(operator).concat(value));
21
- });
22
- });
23
- return filters;
24
- }
@@ -1,27 +0,0 @@
1
- /**
2
- * This implementation is taken from Lodash implementation.
3
- * See: https://github.com/lodash/lodash/blob/4.17.11-npm/escape.js
4
- */
5
- // Used to map characters to HTML entities.
6
- var htmlEscapes = {
7
- '&': '&amp;',
8
- '<': '&lt;',
9
- '>': '&gt;',
10
- '"': '&quot;',
11
- "'": '&#39;'
12
- }; // Used to match HTML entities and HTML characters.
13
-
14
- var regexUnescapedHtml = /[&<>"']/g;
15
- var regexHasUnescapedHtml = RegExp(regexUnescapedHtml.source);
16
- /**
17
- * Converts the characters "&", "<", ">", '"', and "'" in `string` to their
18
- * corresponding HTML entities.
19
- */
20
-
21
- function escape(value) {
22
- return value && regexHasUnescapedHtml.test(value) ? value.replace(regexUnescapedHtml, function (character) {
23
- return htmlEscapes[character];
24
- }) : value;
25
- }
26
-
27
- export default escape;
@@ -1,9 +0,0 @@
1
- /**
2
- * This implementation is taken from Lodash implementation.
3
- * See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
4
- */
5
- /**
6
- * Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
7
- * characters.
8
- */
9
- export default function unescape(value: string): string;
@@ -1,25 +0,0 @@
1
- /**
2
- * This implementation is taken from Lodash implementation.
3
- * See: https://github.com/lodash/lodash/blob/4.17.11-npm/unescape.js
4
- */
5
- // Used to map HTML entities to characters.
6
- var htmlEscapes = {
7
- '&amp;': '&',
8
- '&lt;': '<',
9
- '&gt;': '>',
10
- '&quot;': '"',
11
- '&#39;': "'"
12
- }; // Used to match HTML entities and HTML characters.
13
-
14
- var regexEscapedHtml = /&(amp|quot|lt|gt|#39);/g;
15
- var regexHasEscapedHtml = RegExp(regexEscapedHtml.source);
16
- /**
17
- * Converts the HTML entities "&", "<", ">", '"', and "'" in `string` to their
18
- * characters.
19
- */
20
-
21
- export default function unescape(value) {
22
- return value && regexHasEscapedHtml.test(value) ? value.replace(regexEscapedHtml, function (character) {
23
- return htmlEscapes[character];
24
- }) : value;
25
- }