instantsearch.js 4.42.0 → 4.44.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 (53) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/cjs/components/Highlight/Highlight.js +33 -0
  3. package/cjs/components/InternalHighlight/InternalHighlight.js +16 -0
  4. package/cjs/components/ReverseHighlight/ReverseHighlight.js +33 -0
  5. package/cjs/components/ReverseSnippet/ReverseSnippet.js +33 -0
  6. package/cjs/components/Snippet/Snippet.js +33 -0
  7. package/cjs/connectors/rating-menu/connectRatingMenu.js +1 -1
  8. package/cjs/helpers/components/Highlight.js +45 -0
  9. package/cjs/helpers/components/ReverseHighlight.js +58 -0
  10. package/cjs/helpers/components/ReverseSnippet.js +58 -0
  11. package/cjs/helpers/components/Snippet.js +45 -0
  12. package/cjs/helpers/components/index.js +57 -0
  13. package/cjs/lib/InstantSearch.js +11 -1
  14. package/cjs/lib/version.js +1 -1
  15. package/cjs/types/algoliasearch.js +18 -1
  16. package/dist/instantsearch.development.d.ts +12 -31
  17. package/dist/instantsearch.development.js +20 -10
  18. package/dist/instantsearch.development.js.map +1 -1
  19. package/dist/instantsearch.production.d.ts +12 -31
  20. package/dist/instantsearch.production.min.d.ts +12 -31
  21. package/dist/instantsearch.production.min.js +2 -2
  22. package/dist/instantsearch.production.min.js.map +1 -1
  23. package/es/components/Highlight/Highlight.d.ts +7 -0
  24. package/es/components/Highlight/Highlight.js +24 -0
  25. package/es/components/InternalHighlight/InternalHighlight.d.ts +2 -0
  26. package/es/components/InternalHighlight/InternalHighlight.js +6 -0
  27. package/es/components/ReverseHighlight/ReverseHighlight.d.ts +7 -0
  28. package/es/components/ReverseHighlight/ReverseHighlight.js +24 -0
  29. package/es/components/ReverseSnippet/ReverseSnippet.d.ts +7 -0
  30. package/es/components/ReverseSnippet/ReverseSnippet.js +24 -0
  31. package/es/components/Snippet/Snippet.d.ts +7 -0
  32. package/es/components/Snippet/Snippet.js +24 -0
  33. package/es/connectors/geo-search/connectGeoSearch.d.ts +10 -10
  34. package/es/connectors/rating-menu/connectRatingMenu.js +1 -1
  35. package/es/helpers/components/Highlight.d.ts +10 -0
  36. package/es/helpers/components/Highlight.js +31 -0
  37. package/es/helpers/components/ReverseHighlight.d.ts +10 -0
  38. package/es/helpers/components/ReverseHighlight.js +44 -0
  39. package/es/helpers/components/ReverseSnippet.d.ts +10 -0
  40. package/es/helpers/components/ReverseSnippet.js +44 -0
  41. package/es/helpers/components/Snippet.d.ts +10 -0
  42. package/es/helpers/components/Snippet.js +31 -0
  43. package/es/helpers/components/index.d.ts +4 -0
  44. package/es/helpers/components/index.js +4 -0
  45. package/es/lib/InstantSearch.js +11 -1
  46. package/es/lib/version.d.ts +1 -1
  47. package/es/lib/version.js +1 -1
  48. package/es/types/algoliasearch.d.ts +1 -40
  49. package/es/types/algoliasearch.js +2 -0
  50. package/es/types/index.js +1 -0
  51. package/es/types/results.d.ts +1 -1
  52. package/es/types/utils.d.ts +4 -0
  53. package/package.json +6 -3
@@ -1,14 +1,14 @@
1
1
  /// <reference types="google.maps" />
2
2
 
3
- import type algoliasearch from 'algoliasearch/lite';
4
3
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
5
- import type * as ClientSearch from '@algolia/client-search';
6
4
  import EventEmitter from '@algolia/events';
5
+ import { FindAnswersOptions } from 'algoliasearch-helper/types/algoliasearch.js';
7
6
  import type { InsightsClient as InsightsClient_2 } from 'search-insights';
8
7
  import type { InsightsMethodMap } from 'search-insights';
9
8
  import type * as Places from 'places.js';
10
9
  import type { PlainSearchParameters } from 'algoliasearch-helper';
11
10
  import { default as qs_2 } from 'qs';
11
+ import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
12
12
  import type { SearchParameters } from 'algoliasearch-helper';
13
13
  import type { SearchResults } from 'algoliasearch-helper';
14
14
 
@@ -34,7 +34,7 @@ declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
34
34
  };
35
35
  };
36
36
  _distinctSeqID?: number;
37
- _geoLoc?: GeoLoc;
37
+ _geoloc?: GeoLoc;
38
38
  } & THit;
39
39
 
40
40
  declare const analytics: AnalyticsWidget;
@@ -1075,18 +1075,12 @@ declare type CustomSendEventForHits = (customPayload: any) => void;
1075
1075
 
1076
1076
  declare type CustomSendEventForToggle = (customPayload: any) => void;
1077
1077
 
1078
- declare type DefaultSearchClient = ReturnType<typeof algoliasearch>;
1079
-
1080
1078
  declare type DisposeOptions = {
1081
1079
  helper: AlgoliaSearchHelper;
1082
1080
  state: SearchParameters;
1083
1081
  parent: IndexWidget;
1084
1082
  };
1085
1083
 
1086
- declare type DummySearchClientV4 = {
1087
- readonly transporter: any;
1088
- };
1089
-
1090
1084
  declare const dynamicWidgets: DynamicWidgetsWidget;
1091
1085
 
1092
1086
  declare type DynamicWidgetsConnector = Connector<DynamicWidgetsWidgetDescription, DynamicWidgetsConnectorParams>;
@@ -1175,9 +1169,7 @@ declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector;
1175
1169
  /** @deprecated use dynamicWidgets */
1176
1170
  declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
1177
1171
 
1178
- declare type FindAnswersOptions = DefaultSearchClient extends DummySearchClientV4 ? ClientSearch.FindAnswersOptions : any;
1179
-
1180
- declare type GeoHit = Hit & Required<Pick<Hit, '_geoLoc'>>;
1172
+ declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
1181
1173
 
1182
1174
  declare type GeoLoc = {
1183
1175
  lat: number;
@@ -1199,9 +1191,9 @@ declare type GeoLoc = {
1199
1191
  */
1200
1192
  declare const geoSearch: GeoSearchWidget;
1201
1193
 
1202
- declare type GeoSearchConnector = Connector<GeoSearchWidgetDescription, GeoSearchConnectorParams>;
1194
+ declare type GeoSearchConnector<THit extends BaseHit = Record<string, any>> = Connector<GeoSearchWidgetDescription<THit>, GeoSearchConnectorParams<THit>>;
1203
1195
 
1204
- declare type GeoSearchConnectorParams = {
1196
+ declare type GeoSearchConnectorParams<THit extends BaseHit = Record<string, any>> = {
1205
1197
  /**
1206
1198
  * If true, refine will be triggered as you move the map.
1207
1199
  * @default true
@@ -1211,7 +1203,7 @@ declare type GeoSearchConnectorParams = {
1211
1203
  * Function to transform the items passed to the templates.
1212
1204
  * @default items => items
1213
1205
  */
1214
- transformItems?: TransformItems<GeoHit>;
1206
+ transformItems?: TransformItems<GeoHit<THit>>;
1215
1207
  };
1216
1208
 
1217
1209
  declare type GeoSearchCSSClasses = Partial<{
@@ -1257,7 +1249,7 @@ declare type GeoSearchMarker<TOptions> = {
1257
1249
  };
1258
1250
  };
1259
1251
 
1260
- declare type GeoSearchRenderState = {
1252
+ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> = {
1261
1253
  /**
1262
1254
  * Reset the current bounding box refinement.
1263
1255
  */
@@ -1281,7 +1273,7 @@ declare type GeoSearchRenderState = {
1281
1273
  /**
1282
1274
  * The matched hits from Algolia API.
1283
1275
  */
1284
- items: GeoHit[];
1276
+ items: Array<GeoHit<THit>>;
1285
1277
  /**
1286
1278
  * The current position of the search.
1287
1279
  */
@@ -1321,11 +1313,11 @@ declare type GeoSearchWidget = WidgetFactory<GeoSearchWidgetDescription & {
1321
1313
  $$widgetType: 'ais.geoSearch';
1322
1314
  }, GeoSearchConnectorParams, GeoSearchWidgetParams>;
1323
1315
 
1324
- declare type GeoSearchWidgetDescription = {
1316
+ declare type GeoSearchWidgetDescription<THit extends BaseHit = Record<string, any>> = {
1325
1317
  $$type: 'ais.geoSearch';
1326
- renderState: GeoSearchRenderState;
1318
+ renderState: GeoSearchRenderState<THit>;
1327
1319
  indexRenderState: {
1328
- geoSearch: WidgetRenderState<GeoSearchRenderState, GeoSearchConnectorParams>;
1320
+ geoSearch: WidgetRenderState<GeoSearchRenderState<THit>, GeoSearchConnectorParams<THit>>;
1329
1321
  };
1330
1322
  indexUiState: {
1331
1323
  geoSearch: {
@@ -4582,17 +4574,6 @@ declare type SearchBoxWidgetParams = {
4582
4574
  queryHook?: (query: string, hook: (value: string) => void) => void;
4583
4575
  };
4584
4576
 
4585
- declare type SearchClient = {
4586
- search: DefaultSearchClient['search'];
4587
- searchForFacetValues: DefaultSearchClient['searchForFacetValues'];
4588
- addAlgoliaAgent?: DefaultSearchClient['addAlgoliaAgent'];
4589
- initIndex?: (indexName: string) => SearchIndex extends {
4590
- findAnswers: any;
4591
- } ? Partial<Pick<SearchIndex, 'findAnswers'>> : SearchIndex;
4592
- };
4593
-
4594
- declare type SearchIndex = ReturnType<DefaultSearchClient['initIndex']>;
4595
-
4596
4577
  declare type SendEvent = (...args: [InsightsEvent] | [string, string, string?]) => void;
4597
4578
 
4598
4579
  declare type SendEventForFacet = BuiltInSendEventForFacet & CustomSendEventForFacet;
@@ -1,14 +1,14 @@
1
1
  /// <reference types="google.maps" />
2
2
 
3
- import type algoliasearch from 'algoliasearch/lite';
4
3
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
5
- import type * as ClientSearch from '@algolia/client-search';
6
4
  import EventEmitter from '@algolia/events';
5
+ import { FindAnswersOptions } from 'algoliasearch-helper/types/algoliasearch.js';
7
6
  import type { InsightsClient as InsightsClient_2 } from 'search-insights';
8
7
  import type { InsightsMethodMap } from 'search-insights';
9
8
  import type * as Places from 'places.js';
10
9
  import type { PlainSearchParameters } from 'algoliasearch-helper';
11
10
  import { default as qs_2 } from 'qs';
11
+ import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
12
12
  import type { SearchParameters } from 'algoliasearch-helper';
13
13
  import type { SearchResults } from 'algoliasearch-helper';
14
14
 
@@ -34,7 +34,7 @@ declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
34
34
  };
35
35
  };
36
36
  _distinctSeqID?: number;
37
- _geoLoc?: GeoLoc;
37
+ _geoloc?: GeoLoc;
38
38
  } & THit;
39
39
 
40
40
  declare const analytics: AnalyticsWidget;
@@ -1075,18 +1075,12 @@ declare type CustomSendEventForHits = (customPayload: any) => void;
1075
1075
 
1076
1076
  declare type CustomSendEventForToggle = (customPayload: any) => void;
1077
1077
 
1078
- declare type DefaultSearchClient = ReturnType<typeof algoliasearch>;
1079
-
1080
1078
  declare type DisposeOptions = {
1081
1079
  helper: AlgoliaSearchHelper;
1082
1080
  state: SearchParameters;
1083
1081
  parent: IndexWidget;
1084
1082
  };
1085
1083
 
1086
- declare type DummySearchClientV4 = {
1087
- readonly transporter: any;
1088
- };
1089
-
1090
1084
  declare const dynamicWidgets: DynamicWidgetsWidget;
1091
1085
 
1092
1086
  declare type DynamicWidgetsConnector = Connector<DynamicWidgetsWidgetDescription, DynamicWidgetsConnectorParams>;
@@ -1175,9 +1169,7 @@ declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector;
1175
1169
  /** @deprecated use dynamicWidgets */
1176
1170
  declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
1177
1171
 
1178
- declare type FindAnswersOptions = DefaultSearchClient extends DummySearchClientV4 ? ClientSearch.FindAnswersOptions : any;
1179
-
1180
- declare type GeoHit = Hit & Required<Pick<Hit, '_geoLoc'>>;
1172
+ declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
1181
1173
 
1182
1174
  declare type GeoLoc = {
1183
1175
  lat: number;
@@ -1199,9 +1191,9 @@ declare type GeoLoc = {
1199
1191
  */
1200
1192
  declare const geoSearch: GeoSearchWidget;
1201
1193
 
1202
- declare type GeoSearchConnector = Connector<GeoSearchWidgetDescription, GeoSearchConnectorParams>;
1194
+ declare type GeoSearchConnector<THit extends BaseHit = Record<string, any>> = Connector<GeoSearchWidgetDescription<THit>, GeoSearchConnectorParams<THit>>;
1203
1195
 
1204
- declare type GeoSearchConnectorParams = {
1196
+ declare type GeoSearchConnectorParams<THit extends BaseHit = Record<string, any>> = {
1205
1197
  /**
1206
1198
  * If true, refine will be triggered as you move the map.
1207
1199
  * @default true
@@ -1211,7 +1203,7 @@ declare type GeoSearchConnectorParams = {
1211
1203
  * Function to transform the items passed to the templates.
1212
1204
  * @default items => items
1213
1205
  */
1214
- transformItems?: TransformItems<GeoHit>;
1206
+ transformItems?: TransformItems<GeoHit<THit>>;
1215
1207
  };
1216
1208
 
1217
1209
  declare type GeoSearchCSSClasses = Partial<{
@@ -1257,7 +1249,7 @@ declare type GeoSearchMarker<TOptions> = {
1257
1249
  };
1258
1250
  };
1259
1251
 
1260
- declare type GeoSearchRenderState = {
1252
+ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> = {
1261
1253
  /**
1262
1254
  * Reset the current bounding box refinement.
1263
1255
  */
@@ -1281,7 +1273,7 @@ declare type GeoSearchRenderState = {
1281
1273
  /**
1282
1274
  * The matched hits from Algolia API.
1283
1275
  */
1284
- items: GeoHit[];
1276
+ items: Array<GeoHit<THit>>;
1285
1277
  /**
1286
1278
  * The current position of the search.
1287
1279
  */
@@ -1321,11 +1313,11 @@ declare type GeoSearchWidget = WidgetFactory<GeoSearchWidgetDescription & {
1321
1313
  $$widgetType: 'ais.geoSearch';
1322
1314
  }, GeoSearchConnectorParams, GeoSearchWidgetParams>;
1323
1315
 
1324
- declare type GeoSearchWidgetDescription = {
1316
+ declare type GeoSearchWidgetDescription<THit extends BaseHit = Record<string, any>> = {
1325
1317
  $$type: 'ais.geoSearch';
1326
- renderState: GeoSearchRenderState;
1318
+ renderState: GeoSearchRenderState<THit>;
1327
1319
  indexRenderState: {
1328
- geoSearch: WidgetRenderState<GeoSearchRenderState, GeoSearchConnectorParams>;
1320
+ geoSearch: WidgetRenderState<GeoSearchRenderState<THit>, GeoSearchConnectorParams<THit>>;
1329
1321
  };
1330
1322
  indexUiState: {
1331
1323
  geoSearch: {
@@ -4582,17 +4574,6 @@ declare type SearchBoxWidgetParams = {
4582
4574
  queryHook?: (query: string, hook: (value: string) => void) => void;
4583
4575
  };
4584
4576
 
4585
- declare type SearchClient = {
4586
- search: DefaultSearchClient['search'];
4587
- searchForFacetValues: DefaultSearchClient['searchForFacetValues'];
4588
- addAlgoliaAgent?: DefaultSearchClient['addAlgoliaAgent'];
4589
- initIndex?: (indexName: string) => SearchIndex extends {
4590
- findAnswers: any;
4591
- } ? Partial<Pick<SearchIndex, 'findAnswers'>> : SearchIndex;
4592
- };
4593
-
4594
- declare type SearchIndex = ReturnType<DefaultSearchClient['initIndex']>;
4595
-
4596
4577
  declare type SendEvent = (...args: [InsightsEvent] | [string, string, string?]) => void;
4597
4578
 
4598
4579
  declare type SendEventForFacet = BuiltInSendEventForFacet & CustomSendEventForFacet;