instantsearch.js 4.43.1 → 4.45.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 (58) hide show
  1. package/CHANGELOG.md +27 -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/hits-per-page/connectHitsPerPage.js +3 -1
  8. package/cjs/connectors/numeric-menu/connectNumericMenu.js +31 -43
  9. package/cjs/connectors/range/connectRange.js +7 -46
  10. package/cjs/connectors/rating-menu/connectRatingMenu.js +8 -2
  11. package/cjs/connectors/sort-by/connectSortBy.js +3 -1
  12. package/cjs/helpers/components/Highlight.js +45 -0
  13. package/cjs/helpers/components/ReverseHighlight.js +58 -0
  14. package/cjs/helpers/components/ReverseSnippet.js +58 -0
  15. package/cjs/helpers/components/Snippet.js +45 -0
  16. package/cjs/helpers/components/index.js +57 -0
  17. package/cjs/lib/version.js +1 -1
  18. package/dist/instantsearch.development.d.ts +29 -9
  19. package/dist/instantsearch.development.js +109 -120
  20. package/dist/instantsearch.development.js.map +1 -1
  21. package/dist/instantsearch.production.d.ts +29 -9
  22. package/dist/instantsearch.production.min.d.ts +29 -9
  23. package/dist/instantsearch.production.min.js +2 -2
  24. package/dist/instantsearch.production.min.js.map +1 -1
  25. package/es/components/Highlight/Highlight.d.ts +7 -0
  26. package/es/components/Highlight/Highlight.js +24 -0
  27. package/es/components/InternalHighlight/InternalHighlight.d.ts +2 -0
  28. package/es/components/InternalHighlight/InternalHighlight.js +6 -0
  29. package/es/components/ReverseHighlight/ReverseHighlight.d.ts +7 -0
  30. package/es/components/ReverseHighlight/ReverseHighlight.js +24 -0
  31. package/es/components/ReverseSnippet/ReverseSnippet.d.ts +7 -0
  32. package/es/components/ReverseSnippet/ReverseSnippet.js +24 -0
  33. package/es/components/Snippet/Snippet.d.ts +7 -0
  34. package/es/components/Snippet/Snippet.js +24 -0
  35. package/es/connectors/geo-search/connectGeoSearch.d.ts +10 -10
  36. package/es/connectors/hits-per-page/connectHitsPerPage.d.ts +5 -0
  37. package/es/connectors/hits-per-page/connectHitsPerPage.js +3 -1
  38. package/es/connectors/numeric-menu/connectNumericMenu.d.ts +8 -0
  39. package/es/connectors/numeric-menu/connectNumericMenu.js +32 -44
  40. package/es/connectors/range/connectRange.js +8 -47
  41. package/es/connectors/rating-menu/connectRatingMenu.d.ts +2 -0
  42. package/es/connectors/rating-menu/connectRatingMenu.js +8 -2
  43. package/es/connectors/sort-by/connectSortBy.d.ts +5 -0
  44. package/es/connectors/sort-by/connectSortBy.js +3 -1
  45. package/es/helpers/components/Highlight.d.ts +10 -0
  46. package/es/helpers/components/Highlight.js +31 -0
  47. package/es/helpers/components/ReverseHighlight.d.ts +10 -0
  48. package/es/helpers/components/ReverseHighlight.js +44 -0
  49. package/es/helpers/components/ReverseSnippet.d.ts +10 -0
  50. package/es/helpers/components/ReverseSnippet.js +44 -0
  51. package/es/helpers/components/Snippet.d.ts +10 -0
  52. package/es/helpers/components/Snippet.js +31 -0
  53. package/es/helpers/components/index.d.ts +4 -0
  54. package/es/helpers/components/index.js +4 -0
  55. package/es/lib/version.d.ts +1 -1
  56. package/es/lib/version.js +1 -1
  57. package/es/types/utils.d.ts +4 -0
  58. package/package.json +6 -3
@@ -1169,7 +1169,7 @@ declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector;
1169
1169
  /** @deprecated use dynamicWidgets */
1170
1170
  declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
1171
1171
 
1172
- declare type GeoHit = Hit & Required<Pick<Hit, '_geoloc'>>;
1172
+ declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
1173
1173
 
1174
1174
  declare type GeoLoc = {
1175
1175
  lat: number;
@@ -1191,9 +1191,9 @@ declare type GeoLoc = {
1191
1191
  */
1192
1192
  declare const geoSearch: GeoSearchWidget;
1193
1193
 
1194
- declare type GeoSearchConnector = Connector<GeoSearchWidgetDescription, GeoSearchConnectorParams>;
1194
+ declare type GeoSearchConnector<THit extends BaseHit = Record<string, any>> = Connector<GeoSearchWidgetDescription<THit>, GeoSearchConnectorParams<THit>>;
1195
1195
 
1196
- declare type GeoSearchConnectorParams = {
1196
+ declare type GeoSearchConnectorParams<THit extends BaseHit = Record<string, any>> = {
1197
1197
  /**
1198
1198
  * If true, refine will be triggered as you move the map.
1199
1199
  * @default true
@@ -1203,7 +1203,7 @@ declare type GeoSearchConnectorParams = {
1203
1203
  * Function to transform the items passed to the templates.
1204
1204
  * @default items => items
1205
1205
  */
1206
- transformItems?: TransformItems<GeoHit>;
1206
+ transformItems?: TransformItems<GeoHit<THit>>;
1207
1207
  };
1208
1208
 
1209
1209
  declare type GeoSearchCSSClasses = Partial<{
@@ -1249,7 +1249,7 @@ declare type GeoSearchMarker<TOptions> = {
1249
1249
  };
1250
1250
  };
1251
1251
 
1252
- declare type GeoSearchRenderState = {
1252
+ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> = {
1253
1253
  /**
1254
1254
  * Reset the current bounding box refinement.
1255
1255
  */
@@ -1273,7 +1273,7 @@ declare type GeoSearchRenderState = {
1273
1273
  /**
1274
1274
  * The matched hits from Algolia API.
1275
1275
  */
1276
- items: GeoHit[];
1276
+ items: Array<GeoHit<THit>>;
1277
1277
  /**
1278
1278
  * The current position of the search.
1279
1279
  */
@@ -1313,11 +1313,11 @@ declare type GeoSearchWidget = WidgetFactory<GeoSearchWidgetDescription & {
1313
1313
  $$widgetType: 'ais.geoSearch';
1314
1314
  }, GeoSearchConnectorParams, GeoSearchWidgetParams>;
1315
1315
 
1316
- declare type GeoSearchWidgetDescription = {
1316
+ declare type GeoSearchWidgetDescription<THit extends BaseHit = Record<string, any>> = {
1317
1317
  $$type: 'ais.geoSearch';
1318
- renderState: GeoSearchRenderState;
1318
+ renderState: GeoSearchRenderState<THit>;
1319
1319
  indexRenderState: {
1320
- geoSearch: WidgetRenderState<GeoSearchRenderState, GeoSearchConnectorParams>;
1320
+ geoSearch: WidgetRenderState<GeoSearchRenderState<THit>, GeoSearchConnectorParams<THit>>;
1321
1321
  };
1322
1322
  indexUiState: {
1323
1323
  geoSearch: {
@@ -1872,8 +1872,13 @@ declare type HitsPerPageRenderState = {
1872
1872
  refine: (value: number) => void;
1873
1873
  /**
1874
1874
  * Indicates whether or not the search has results.
1875
+ * @deprecated Use `canRefine` instead.
1875
1876
  */
1876
1877
  hasNoResults: boolean;
1878
+ /**
1879
+ * Indicates if search state can be refined.
1880
+ */
1881
+ canRefine: boolean;
1877
1882
  };
1878
1883
 
1879
1884
  declare type HitsPerPageRenderStateItem = {
@@ -2855,8 +2860,16 @@ declare type NumericMenuRenderState = {
2855
2860
  createURL: CreateURL<NumericMenuRenderStateItem['value']>;
2856
2861
  /**
2857
2862
  * `true` if the last search contains no result
2863
+ * @deprecated Use `canRefine` instead.
2858
2864
  */
2859
2865
  hasNoResults: boolean;
2866
+ /**
2867
+ * Indicates if search state can be refined.
2868
+ *
2869
+ * This is `true` if the last search contains no result and
2870
+ * "All" range is selected
2871
+ */
2872
+ canRefine: boolean;
2860
2873
  /**
2861
2874
  * Sets the selected value and trigger a new search
2862
2875
  */
@@ -3721,6 +3734,8 @@ declare type RatingMenuRenderState = {
3721
3734
  refine: (value: string) => void;
3722
3735
  /**
3723
3736
  * `true` if the last search contains no result.
3737
+ *
3738
+ * @deprecated Use `canRefine` instead.
3724
3739
  */
3725
3740
  hasNoResults: boolean;
3726
3741
  /**
@@ -4683,8 +4698,13 @@ declare type SortByRenderState = {
4683
4698
  refine: (value: string) => void;
4684
4699
  /**
4685
4700
  * `true` if the last search contains no result.
4701
+ * @deprecated Use `canRefine` instead.
4686
4702
  */
4687
4703
  hasNoResults: boolean;
4704
+ /**
4705
+ * `true` if we can refine.
4706
+ */
4707
+ canRefine: boolean;
4688
4708
  };
4689
4709
 
4690
4710
  declare type SortByWidget = WidgetFactory<SortByWidgetDescription & {
@@ -1169,7 +1169,7 @@ declare const EXPERIMENTAL_connectDynamicWidgets: DynamicWidgetsConnector;
1169
1169
  /** @deprecated use dynamicWidgets */
1170
1170
  declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
1171
1171
 
1172
- declare type GeoHit = Hit & Required<Pick<Hit, '_geoloc'>>;
1172
+ declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
1173
1173
 
1174
1174
  declare type GeoLoc = {
1175
1175
  lat: number;
@@ -1191,9 +1191,9 @@ declare type GeoLoc = {
1191
1191
  */
1192
1192
  declare const geoSearch: GeoSearchWidget;
1193
1193
 
1194
- declare type GeoSearchConnector = Connector<GeoSearchWidgetDescription, GeoSearchConnectorParams>;
1194
+ declare type GeoSearchConnector<THit extends BaseHit = Record<string, any>> = Connector<GeoSearchWidgetDescription<THit>, GeoSearchConnectorParams<THit>>;
1195
1195
 
1196
- declare type GeoSearchConnectorParams = {
1196
+ declare type GeoSearchConnectorParams<THit extends BaseHit = Record<string, any>> = {
1197
1197
  /**
1198
1198
  * If true, refine will be triggered as you move the map.
1199
1199
  * @default true
@@ -1203,7 +1203,7 @@ declare type GeoSearchConnectorParams = {
1203
1203
  * Function to transform the items passed to the templates.
1204
1204
  * @default items => items
1205
1205
  */
1206
- transformItems?: TransformItems<GeoHit>;
1206
+ transformItems?: TransformItems<GeoHit<THit>>;
1207
1207
  };
1208
1208
 
1209
1209
  declare type GeoSearchCSSClasses = Partial<{
@@ -1249,7 +1249,7 @@ declare type GeoSearchMarker<TOptions> = {
1249
1249
  };
1250
1250
  };
1251
1251
 
1252
- declare type GeoSearchRenderState = {
1252
+ declare type GeoSearchRenderState<THit extends BaseHit = Record<string, any>> = {
1253
1253
  /**
1254
1254
  * Reset the current bounding box refinement.
1255
1255
  */
@@ -1273,7 +1273,7 @@ declare type GeoSearchRenderState = {
1273
1273
  /**
1274
1274
  * The matched hits from Algolia API.
1275
1275
  */
1276
- items: GeoHit[];
1276
+ items: Array<GeoHit<THit>>;
1277
1277
  /**
1278
1278
  * The current position of the search.
1279
1279
  */
@@ -1313,11 +1313,11 @@ declare type GeoSearchWidget = WidgetFactory<GeoSearchWidgetDescription & {
1313
1313
  $$widgetType: 'ais.geoSearch';
1314
1314
  }, GeoSearchConnectorParams, GeoSearchWidgetParams>;
1315
1315
 
1316
- declare type GeoSearchWidgetDescription = {
1316
+ declare type GeoSearchWidgetDescription<THit extends BaseHit = Record<string, any>> = {
1317
1317
  $$type: 'ais.geoSearch';
1318
- renderState: GeoSearchRenderState;
1318
+ renderState: GeoSearchRenderState<THit>;
1319
1319
  indexRenderState: {
1320
- geoSearch: WidgetRenderState<GeoSearchRenderState, GeoSearchConnectorParams>;
1320
+ geoSearch: WidgetRenderState<GeoSearchRenderState<THit>, GeoSearchConnectorParams<THit>>;
1321
1321
  };
1322
1322
  indexUiState: {
1323
1323
  geoSearch: {
@@ -1872,8 +1872,13 @@ declare type HitsPerPageRenderState = {
1872
1872
  refine: (value: number) => void;
1873
1873
  /**
1874
1874
  * Indicates whether or not the search has results.
1875
+ * @deprecated Use `canRefine` instead.
1875
1876
  */
1876
1877
  hasNoResults: boolean;
1878
+ /**
1879
+ * Indicates if search state can be refined.
1880
+ */
1881
+ canRefine: boolean;
1877
1882
  };
1878
1883
 
1879
1884
  declare type HitsPerPageRenderStateItem = {
@@ -2855,8 +2860,16 @@ declare type NumericMenuRenderState = {
2855
2860
  createURL: CreateURL<NumericMenuRenderStateItem['value']>;
2856
2861
  /**
2857
2862
  * `true` if the last search contains no result
2863
+ * @deprecated Use `canRefine` instead.
2858
2864
  */
2859
2865
  hasNoResults: boolean;
2866
+ /**
2867
+ * Indicates if search state can be refined.
2868
+ *
2869
+ * This is `true` if the last search contains no result and
2870
+ * "All" range is selected
2871
+ */
2872
+ canRefine: boolean;
2860
2873
  /**
2861
2874
  * Sets the selected value and trigger a new search
2862
2875
  */
@@ -3721,6 +3734,8 @@ declare type RatingMenuRenderState = {
3721
3734
  refine: (value: string) => void;
3722
3735
  /**
3723
3736
  * `true` if the last search contains no result.
3737
+ *
3738
+ * @deprecated Use `canRefine` instead.
3724
3739
  */
3725
3740
  hasNoResults: boolean;
3726
3741
  /**
@@ -4683,8 +4698,13 @@ declare type SortByRenderState = {
4683
4698
  refine: (value: string) => void;
4684
4699
  /**
4685
4700
  * `true` if the last search contains no result.
4701
+ * @deprecated Use `canRefine` instead.
4686
4702
  */
4687
4703
  hasNoResults: boolean;
4704
+ /**
4705
+ * `true` if we can refine.
4706
+ */
4707
+ canRefine: boolean;
4688
4708
  };
4689
4709
 
4690
4710
  declare type SortByWidget = WidgetFactory<SortByWidgetDescription & {