instantsearch.js 4.68.1 → 4.70.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 (68) hide show
  1. package/cjs/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.js +93 -0
  2. package/cjs/connectors/index.js +28 -0
  3. package/cjs/connectors/looking-similar/connectLookingSimilar.js +94 -0
  4. package/cjs/connectors/related-products/connectRelatedProducts.js +94 -0
  5. package/cjs/connectors/trending-items/connectTrendingItems.js +90 -0
  6. package/cjs/lib/InstantSearch.js +10 -1
  7. package/cjs/lib/server.js +28 -9
  8. package/cjs/lib/utils/addWidgetId.js +17 -0
  9. package/cjs/lib/utils/hydrateRecommendCache.js +23 -0
  10. package/cjs/lib/utils/hydrateSearchClient.js +7 -3
  11. package/cjs/lib/utils/index.js +22 -0
  12. package/cjs/lib/utils/render-args.js +3 -3
  13. package/cjs/lib/version.js +1 -1
  14. package/cjs/widgets/frequently-bought-together/frequently-bought-together.js +120 -0
  15. package/cjs/widgets/index/index.js +89 -20
  16. package/cjs/widgets/index.js +28 -0
  17. package/cjs/widgets/looking-similar/looking-similar.js +122 -0
  18. package/cjs/widgets/related-products/related-products.js +122 -0
  19. package/cjs/widgets/trending-items/trending-items.js +126 -0
  20. package/dist/instantsearch.development.d.ts +411 -12
  21. package/dist/instantsearch.development.js +1702 -265
  22. package/dist/instantsearch.development.js.map +1 -1
  23. package/dist/instantsearch.production.d.ts +411 -12
  24. package/dist/instantsearch.production.min.d.ts +411 -12
  25. package/dist/instantsearch.production.min.js +2 -2
  26. package/dist/instantsearch.production.min.js.map +1 -1
  27. package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +45 -0
  28. package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.js +86 -0
  29. package/es/connectors/index.d.ts +4 -0
  30. package/es/connectors/index.js +5 -1
  31. package/es/connectors/looking-similar/connectLookingSimilar.d.ts +49 -0
  32. package/es/connectors/looking-similar/connectLookingSimilar.js +87 -0
  33. package/es/connectors/related-products/connectRelatedProducts.d.ts +49 -0
  34. package/es/connectors/related-products/connectRelatedProducts.js +87 -0
  35. package/es/connectors/trending-items/connectTrendingItems.d.ts +57 -0
  36. package/es/connectors/trending-items/connectTrendingItems.js +83 -0
  37. package/es/lib/InstantSearch.d.ts +2 -0
  38. package/es/lib/InstantSearch.js +11 -2
  39. package/es/lib/server.d.ts +1 -1
  40. package/es/lib/server.js +28 -9
  41. package/es/lib/templating/renderTemplate.d.ts +1 -1
  42. package/es/lib/utils/addWidgetId.d.ts +3 -0
  43. package/es/lib/utils/addWidgetId.js +10 -0
  44. package/es/lib/utils/hydrateRecommendCache.d.ts +3 -0
  45. package/es/lib/utils/hydrateRecommendCache.js +17 -0
  46. package/es/lib/utils/hydrateSearchClient.js +7 -3
  47. package/es/lib/utils/index.d.ts +2 -0
  48. package/es/lib/utils/index.js +2 -0
  49. package/es/lib/utils/render-args.d.ts +3 -3
  50. package/es/lib/utils/render-args.js +3 -3
  51. package/es/lib/version.d.ts +1 -1
  52. package/es/lib/version.js +1 -1
  53. package/es/types/results.d.ts +7 -3
  54. package/es/types/templates.d.ts +1 -1
  55. package/es/types/widget.d.ts +16 -9
  56. package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +41 -0
  57. package/es/widgets/frequently-bought-together/frequently-bought-together.js +112 -0
  58. package/es/widgets/index/index.d.ts +2 -1
  59. package/es/widgets/index/index.js +89 -20
  60. package/es/widgets/index.d.ts +4 -0
  61. package/es/widgets/index.js +5 -1
  62. package/es/widgets/looking-similar/looking-similar.d.ts +41 -0
  63. package/es/widgets/looking-similar/looking-similar.js +114 -0
  64. package/es/widgets/related-products/related-products.d.ts +41 -0
  65. package/es/widgets/related-products/related-products.js +114 -0
  66. package/es/widgets/trending-items/trending-items.d.ts +41 -0
  67. package/es/widgets/trending-items/trending-items.js +118 -0
  68. package/package.json +7 -7
@@ -4,6 +4,7 @@
4
4
  import type { AlgoliaSearchHelper } from 'algoliasearch-helper';
5
5
  import EventEmitter from '@algolia/events';
6
6
  import { FindAnswersOptions } from 'algoliasearch-helper/types/algoliasearch.js';
7
+ import type { FrequentlyBoughtTogetherProps } from 'instantsearch-ui-components';
7
8
  import { h } from 'preact';
8
9
  import type { HighlightClassNames as HighlightClassNames_2 } from 'instantsearch-ui-components';
9
10
  import type { HighlightProps as HighlightProps_3 } from 'instantsearch-ui-components';
@@ -12,14 +13,21 @@ import type { HoganOptions } from 'hogan.js';
12
13
  import type { html } from 'htm/preact';
13
14
  import type { InsightsClient as InsightsClient_2 } from 'search-insights';
14
15
  import type { InsightsMethodMap as InsightsMethodMap_2 } from 'search-insights';
16
+ import type { LookingSimilarProps } from 'instantsearch-ui-components';
15
17
  import type * as Places from 'places.js';
16
18
  import type { PlainSearchParameters } from 'algoliasearch-helper';
17
19
  import { default as qs_2 } from 'qs';
20
+ import type { RecommendClassNames } from 'instantsearch-ui-components';
18
21
  import type { RecommendParameters } from 'algoliasearch-helper';
22
+ import type { RecommendParametersOptions } from 'algoliasearch-helper';
23
+ import type { RecommendResultItem } from 'algoliasearch-helper';
24
+ import type { RecommendResults } from 'algoliasearch-helper';
25
+ import type { RelatedProductsProps } from 'instantsearch-ui-components';
19
26
  import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
20
27
  import { SearchOptions } from 'algoliasearch-helper/types/algoliasearch.js';
21
28
  import type { SearchParameters } from 'algoliasearch-helper';
22
29
  import type { SearchResults } from 'algoliasearch-helper';
30
+ import type { TrendingItemsProps } from 'instantsearch-ui-components';
23
31
  import { VNode } from 'preact';
24
32
 
25
33
  declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
@@ -735,6 +743,8 @@ declare const connectCurrentRefinements: CurrentRefinementsConnector;
735
743
 
736
744
  declare const connectDynamicWidgets: DynamicWidgetsConnector;
737
745
 
746
+ declare const connectFrequentlyBoughtTogether: FrequentlyBoughtTogetherConnector;
747
+
738
748
  /**
739
749
  * The **GeoSearch** connector provides the logic to build a widget that will display the results on a map. It also provides a way to search for results based on their position. The connector provides functions to manage the search experience (search on map interaction or control the interaction for example).
740
750
  *
@@ -771,6 +781,8 @@ declare const connectInfiniteHits: InfiniteHitsConnector;
771
781
 
772
782
  declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector<BaseHit>;
773
783
 
784
+ declare const connectLookingSimilar: LookingSimilarConnector;
785
+
774
786
  /**
775
787
  * **Menu** connector provides the logic to build a widget that will give the user the ability to choose a single value for a specific facet. The typical usage of menu is for navigation in categories.
776
788
  *
@@ -820,11 +832,13 @@ declare namespace connectors {
820
832
  connectPagination,
821
833
  connectRange,
822
834
  connectRefinementList,
835
+ connectRelatedProducts,
823
836
  connectSearchBox,
824
837
  connectSortBy,
825
838
  connectRatingMenu,
826
839
  connectStats,
827
840
  connectToggleRefinement,
841
+ connectTrendingItems,
828
842
  connectBreadcrumb,
829
843
  connectGeoSearch,
830
844
  connectPoweredBy,
@@ -833,7 +847,9 @@ declare namespace connectors {
833
847
  connectAutocomplete,
834
848
  connectQueryRules,
835
849
  connectVoiceSearch,
836
- connectRelevantSort
850
+ connectRelevantSort,
851
+ connectFrequentlyBoughtTogether,
852
+ connectLookingSimilar
837
853
  }
838
854
  }
839
855
 
@@ -889,6 +905,8 @@ declare const connectRatingMenu: RatingMenuConnector;
889
905
  */
890
906
  declare const connectRefinementList: RefinementListConnector;
891
907
 
908
+ declare const connectRelatedProducts: RelatedProductsConnector;
909
+
892
910
  declare const connectRelevantSort: RelevantSortConnector;
893
911
 
894
912
  /**
@@ -913,6 +931,8 @@ declare const connectStats: StatsConnector;
913
931
  */
914
932
  declare const connectToggleRefinement: ToggleRefinementConnector;
915
933
 
934
+ declare const connectTrendingItems: TrendingItemsConnector;
935
+
916
936
  declare const connectVoiceSearch: VoiceSearchConnector;
917
937
 
918
938
  declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache;
@@ -1120,6 +1140,7 @@ declare const _default: PlacesWidget;
1120
1140
  declare type DisposeOptions = {
1121
1141
  helper: AlgoliaSearchHelper;
1122
1142
  state: SearchParameters;
1143
+ recommendState: RecommendParameters;
1123
1144
  parent: IndexWidget;
1124
1145
  };
1125
1146
 
@@ -1229,6 +1250,91 @@ declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
1229
1250
 
1230
1251
  declare type FacetValue = string | boolean | number;
1231
1252
 
1253
+ declare const frequentlyBoughtTogether: FrequentlyBoughtTogetherWidget;
1254
+
1255
+ declare type FrequentlyBoughtTogetherConnector<THit extends BaseHit = BaseHit> = Connector<FrequentlyBoughtTogetherWidgetDescription<THit>, FrequentlyBoughtTogetherConnectorParams<THit>>;
1256
+
1257
+ declare type FrequentlyBoughtTogetherConnectorParams<THit extends BaseHit = BaseHit> = {
1258
+ /**
1259
+ * The objectIDs of the items to get the frequently bought together items for.
1260
+ */
1261
+ objectIDs: string[];
1262
+ /**
1263
+ * Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.
1264
+ */
1265
+ threshold?: number;
1266
+ /**
1267
+ * The maximum number of recommendations to return.
1268
+ */
1269
+ limit?: number;
1270
+ /**
1271
+ * Parameters to pass to the request.
1272
+ */
1273
+ queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
1274
+ /**
1275
+ * Whether to escape HTML tags from items string values.
1276
+ *
1277
+ * @default true
1278
+ */
1279
+ escapeHTML?: boolean;
1280
+ /**
1281
+ * Function to transform the items passed to the templates.
1282
+ */
1283
+ transformItems?: TransformItems<Hit<THit>, {
1284
+ results: RecommendResultItem;
1285
+ }>;
1286
+ };
1287
+
1288
+ declare type FrequentlyBoughtTogetherCSSClasses = Partial<RecommendClassNames>;
1289
+
1290
+ declare type FrequentlyBoughtTogetherRenderState<THit extends BaseHit = BaseHit> = {
1291
+ /**
1292
+ * The matched recommendations from Algolia API.
1293
+ */
1294
+ items: Array<Hit<THit>>;
1295
+ };
1296
+
1297
+ declare type FrequentlyBoughtTogetherTemplates = Partial<{
1298
+ /**
1299
+ * Template to use when there are no results.
1300
+ */
1301
+ empty: Template<RecommendResultItem>;
1302
+ /**
1303
+ * Template to use for the header of the widget.
1304
+ */
1305
+ header: Template<Pick<Parameters<NonNullable<FrequentlyBoughtTogetherProps<Hit>['headerComponent']>>[0], 'items'> & {
1306
+ cssClasses: RecommendClassNames;
1307
+ }>;
1308
+ /**
1309
+ * Template to use for each result. This template will receive an object containing a single record.
1310
+ */
1311
+ item: Template<Hit>;
1312
+ }>;
1313
+
1314
+ declare type FrequentlyBoughtTogetherWidget = WidgetFactory<FrequentlyBoughtTogetherWidgetDescription & {
1315
+ $$widgetType: 'ais.frequentlyBoughtTogether';
1316
+ }, FrequentlyBoughtTogetherConnectorParams, FrequentlyBoughtTogetherWidgetParams>;
1317
+
1318
+ declare type FrequentlyBoughtTogetherWidgetDescription<THit extends BaseHit = BaseHit> = {
1319
+ $$type: 'ais.frequentlyBoughtTogether';
1320
+ renderState: FrequentlyBoughtTogetherRenderState<THit>;
1321
+ };
1322
+
1323
+ declare type FrequentlyBoughtTogetherWidgetParams = {
1324
+ /**
1325
+ * CSS Selector or HTMLElement to insert the widget.
1326
+ */
1327
+ container: string | HTMLElement;
1328
+ /**
1329
+ * Templates to use for the widget.
1330
+ */
1331
+ templates?: FrequentlyBoughtTogetherTemplates;
1332
+ /**
1333
+ * CSS classes to add.
1334
+ */
1335
+ cssClasses?: FrequentlyBoughtTogetherCSSClasses;
1336
+ };
1337
+
1232
1338
  declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
1233
1339
 
1234
1340
  declare type GeoLoc = {
@@ -2100,6 +2206,7 @@ declare type IndexWidget<TUiState extends UiState = UiState> = Omit<Widget<Index
2100
2206
  getIndexId: () => string;
2101
2207
  getHelper: () => AlgoliaSearchHelper | null;
2102
2208
  getResults: () => SearchResults | null;
2209
+ getResultsForWidget: (widget: IndexWidget | Widget) => SearchResults | RecommendResultItem | null;
2103
2210
  getPreviousState: () => SearchParameters | null;
2104
2211
  getScopedResults: () => ScopedResult[];
2105
2212
  getParent: () => IndexWidget | null;
@@ -2313,8 +2420,12 @@ declare type InfiniteHitsWidgetParams = {
2313
2420
  };
2314
2421
 
2315
2422
  declare type InitialResult = {
2316
- state: PlainSearchParameters;
2317
- results: SearchResults['_rawResults'];
2423
+ state?: PlainSearchParameters;
2424
+ results?: SearchResults['_rawResults'];
2425
+ recommendResults?: {
2426
+ params: RecommendParametersOptions['params'];
2427
+ results: RecommendResults['_rawResults'];
2428
+ };
2318
2429
  requestParams?: SearchOptions;
2319
2430
  };
2320
2431
 
@@ -2401,6 +2512,8 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
2401
2512
  _createURL: CreateURL<TUiState>;
2402
2513
  _searchFunction?: InstantSearchOptions['searchFunction'];
2403
2514
  _mainHelperSearch?: AlgoliaSearchHelper['search'];
2515
+ _hasSearchWidget: boolean;
2516
+ _hasRecommendWidget: boolean;
2404
2517
  _insights: InstantSearchOptions['insights'];
2405
2518
  middleware: Array<{
2406
2519
  creator: Middleware<TUiState>;
@@ -2656,6 +2769,95 @@ declare type InternalMiddleware<TUiState extends UiState = UiState> = (options:
2656
2769
 
2657
2770
  declare function isMetadataEnabled(): boolean;
2658
2771
 
2772
+ declare const lookingSimilar: LookingSimilarWidget;
2773
+
2774
+ declare type LookingSimilarConnector<THit extends BaseHit = BaseHit> = Connector<LookingSimilarWidgetDescription<THit>, LookingSimilarConnectorParams<THit>>;
2775
+
2776
+ declare type LookingSimilarConnectorParams<THit extends BaseHit = BaseHit> = {
2777
+ /**
2778
+ * The `objectIDs` of the items to get similar looking products from.
2779
+ */
2780
+ objectIDs: string[];
2781
+ /**
2782
+ * The number of recommendations to retrieve.
2783
+ */
2784
+ limit?: number;
2785
+ /**
2786
+ * The threshold for the recommendations confidence score (between 0 and 100).
2787
+ */
2788
+ threshold?: number;
2789
+ /**
2790
+ * List of search parameters to send.
2791
+ */
2792
+ fallbackParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
2793
+ /**
2794
+ * List of search parameters to send.
2795
+ */
2796
+ queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
2797
+ /**
2798
+ * Whether to escape HTML tags from items string values.
2799
+ *
2800
+ * @default true
2801
+ */
2802
+ escapeHTML?: boolean;
2803
+ /**
2804
+ * Function to transform the items passed to the templates.
2805
+ */
2806
+ transformItems?: TransformItems<Hit<THit>, {
2807
+ results: RecommendResultItem;
2808
+ }>;
2809
+ };
2810
+
2811
+ declare type LookingSimilarCSSClasses = Partial<RecommendClassNames>;
2812
+
2813
+ declare type LookingSimilarRenderState<THit extends BaseHit = BaseHit> = {
2814
+ /**
2815
+ * The matched recommendations from the Algolia API.
2816
+ */
2817
+ items: Array<Hit<THit>>;
2818
+ };
2819
+
2820
+ declare type LookingSimilarTemplates = Partial<{
2821
+ /**
2822
+ * Template to use when there are no results.
2823
+ */
2824
+ empty: Template<RecommendResultItem>;
2825
+ /**
2826
+ * Template to use for the header of the widget.
2827
+ */
2828
+ header: Template<Pick<Parameters<NonNullable<LookingSimilarProps<Hit>['headerComponent']>>[0], 'items'> & {
2829
+ cssClasses: RecommendClassNames;
2830
+ }>;
2831
+ /**
2832
+ * Template to use for each result. This template will receive an object containing a single record.
2833
+ */
2834
+ item: Template<Hit>;
2835
+ }>;
2836
+
2837
+ declare type LookingSimilarWidget = WidgetFactory<LookingSimilarWidgetDescription & {
2838
+ $$widgetType: 'ais.lookingSimilar';
2839
+ }, LookingSimilarConnectorParams, LookingSimilarWidgetParams>;
2840
+
2841
+ declare type LookingSimilarWidgetDescription<THit extends BaseHit = BaseHit> = {
2842
+ $$type: 'ais.lookingSimilar';
2843
+ renderState: LookingSimilarRenderState<THit>;
2844
+ };
2845
+
2846
+ declare type LookingSimilarWidgetParams = {
2847
+ /**
2848
+ * CSS Selector or HTMLElement to insert the widget.
2849
+ */
2850
+ container: string | HTMLElement;
2851
+ /**
2852
+ * Templates to use for the widget.
2853
+ */
2854
+ templates?: LookingSimilarTemplates;
2855
+ /**
2856
+ * CSS classes to add.
2857
+ */
2858
+ cssClasses?: LookingSimilarCSSClasses;
2859
+ };
2860
+
2659
2861
  declare type MatchingPatterns = {
2660
2862
  [attribute: string]: {
2661
2863
  /**
@@ -4021,11 +4223,18 @@ declare type Read<THit extends BaseHit> = ({ state, }: {
4021
4223
  state: PlainSearchParameters;
4022
4224
  }) => InfiniteHitsCachedHits<THit> | null;
4023
4225
 
4024
- declare type RecommendWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
4025
- dependsOn?: 'recommend';
4226
+ declare type RecommendRenderOptions = SharedRenderOptions & {
4227
+ results: RecommendResultItem;
4228
+ };
4229
+
4230
+ declare type RecommendWidget<TWidgetDescription extends WidgetDescription & WidgetParams> = {
4231
+ dependsOn: 'recommend';
4232
+ $$id?: number;
4026
4233
  getWidgetParameters: (state: RecommendParameters, widgetParametersOptions: {
4027
4234
  uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
4028
4235
  }) => RecommendParameters;
4236
+ getRenderState: (renderState: Expand<IndexRenderState & Partial<TWidgetDescription['indexRenderState']>>, renderOptions: InitOptions | RecommendRenderOptions) => IndexRenderState & TWidgetDescription['indexRenderState'];
4237
+ getWidgetRenderState: (renderOptions: InitOptions | RecommendRenderOptions) => Expand<WidgetRenderState<TWidgetDescription['renderState'], TWidgetDescription['widgetParams']>>;
4029
4238
  };
4030
4239
 
4031
4240
  declare type ReconfigurableOptions = Places.ReconfigurableOptions;
@@ -4367,6 +4576,95 @@ declare type RefinementListWidgetParams = {
4367
4576
  cssClasses?: RefinementListCSSClasses;
4368
4577
  };
4369
4578
 
4579
+ declare const relatedProducts: RelatedProductsWidget;
4580
+
4581
+ declare type RelatedProductsConnector<THit extends BaseHit = BaseHit> = Connector<RelatedProductsWidgetDescription<THit>, RelatedProductsConnectorParams<THit>>;
4582
+
4583
+ declare type RelatedProductsConnectorParams<THit extends BaseHit = BaseHit> = {
4584
+ /**
4585
+ * The `objectIDs` of the items to get related products from.
4586
+ */
4587
+ objectIDs: string[];
4588
+ /**
4589
+ * The number of recommendations to retrieve.
4590
+ */
4591
+ limit?: number;
4592
+ /**
4593
+ * The threshold for the recommendations confidence score (between 0 and 100).
4594
+ */
4595
+ threshold?: number;
4596
+ /**
4597
+ * List of search parameters to send.
4598
+ */
4599
+ fallbackParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
4600
+ /**
4601
+ * List of search parameters to send.
4602
+ */
4603
+ queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
4604
+ /**
4605
+ * Whether to escape HTML tags from items string values.
4606
+ *
4607
+ * @default true
4608
+ */
4609
+ escapeHTML?: boolean;
4610
+ /**
4611
+ * Function to transform the items passed to the templates.
4612
+ */
4613
+ transformItems?: TransformItems<Hit<THit>, {
4614
+ results: RecommendResultItem;
4615
+ }>;
4616
+ };
4617
+
4618
+ declare type RelatedProductsCSSClasses = Partial<RecommendClassNames>;
4619
+
4620
+ declare type RelatedProductsRenderState<THit extends BaseHit = BaseHit> = {
4621
+ /**
4622
+ * The matched recommendations from the Algolia API.
4623
+ */
4624
+ items: Array<Hit<THit>>;
4625
+ };
4626
+
4627
+ declare type RelatedProductsTemplates = Partial<{
4628
+ /**
4629
+ * Template to use when there are no results.
4630
+ */
4631
+ empty: Template<RecommendResultItem>;
4632
+ /**
4633
+ * Template to use for the header of the widget.
4634
+ */
4635
+ header: Template<Pick<Parameters<NonNullable<RelatedProductsProps<Hit>['headerComponent']>>[0], 'items'> & {
4636
+ cssClasses: RecommendClassNames;
4637
+ }>;
4638
+ /**
4639
+ * Template to use for each result. This template will receive an object containing a single record.
4640
+ */
4641
+ item: Template<Hit>;
4642
+ }>;
4643
+
4644
+ declare type RelatedProductsWidget = WidgetFactory<RelatedProductsWidgetDescription & {
4645
+ $$widgetType: 'ais.relatedProducts';
4646
+ }, RelatedProductsConnectorParams, RelatedProductsWidgetParams>;
4647
+
4648
+ declare type RelatedProductsWidgetDescription<THit extends BaseHit = BaseHit> = {
4649
+ $$type: 'ais.relatedProducts';
4650
+ renderState: RelatedProductsRenderState<THit>;
4651
+ };
4652
+
4653
+ declare type RelatedProductsWidgetParams = {
4654
+ /**
4655
+ * CSS selector or `HTMLElement` to insert the widget into.
4656
+ */
4657
+ container: string | HTMLElement;
4658
+ /**
4659
+ * Templates to customize the widget.
4660
+ */
4661
+ templates?: RelatedProductsTemplates;
4662
+ /**
4663
+ * CSS classes to add to the widget elements.
4664
+ */
4665
+ cssClasses?: RelatedProductsCSSClasses;
4666
+ };
4667
+
4370
4668
  declare const relevantSort: RelevantSortWidget;
4371
4669
 
4372
4670
  declare type RelevantSortConnector = Connector<RelevantSortWidgetDescription, RelevantSortConnectorParams>;
@@ -4488,7 +4786,7 @@ declare function renderTemplate({ templates, templateKey, compileOptions, helper
4488
4786
  data?: Record<string, any>;
4489
4787
  bindEvent?: BindEventForHits;
4490
4788
  sendEvent?: SendEventForHits;
4491
- }): string | VNode< {}> | VNode< {}>[];
4789
+ }): string | VNode< {}> | VNode< {}>[] | null;
4492
4790
 
4493
4791
  declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
4494
4792
 
@@ -4538,7 +4836,7 @@ declare type RequiredUiStateLifeCycle<TWidgetDescription extends WidgetDescripti
4538
4836
  getWidgetSearchParameters: (state: SearchParameters, widgetSearchParametersOptions: {
4539
4837
  uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
4540
4838
  }) => SearchParameters;
4541
- } & (SearchWidgetLifeCycle<TWidgetDescription> | RecommendWidgetLifeCycle<TWidgetDescription>);
4839
+ };
4542
4840
 
4543
4841
  declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
4544
4842
  /**
@@ -4561,7 +4859,7 @@ declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescriptio
4561
4859
  * Called when this widget is unmounted. Used to remove refinements set by
4562
4860
  * during this widget's initialization and life time.
4563
4861
  */
4564
- dispose?: (options: DisposeOptions) => SearchParameters | void;
4862
+ dispose?: (options: DisposeOptions) => SearchParameters | RecommendParameters | void;
4565
4863
  };
4566
4864
 
4567
4865
  declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> = {
@@ -4868,7 +5166,7 @@ declare type SearchBoxWidgetParams = {
4868
5166
  queryHook?: (query: string, hook: (value: string) => void) => void;
4869
5167
  };
4870
5168
 
4871
- declare type SearchWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
5169
+ declare type SearchWidget<TWidgetDescription extends WidgetDescription> = {
4872
5170
  dependsOn?: 'search';
4873
5171
  getWidgetParameters?: (state: SearchParameters, widgetParametersOptions: {
4874
5172
  uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
@@ -5227,7 +5525,7 @@ declare type StatsWidgetParams = {
5227
5525
 
5228
5526
  declare type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
5229
5527
 
5230
- declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
5528
+ declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string | null);
5231
5529
 
5232
5530
  declare type TemplateParams = {
5233
5531
  html: typeof html;
@@ -5423,6 +5721,103 @@ declare type TransformItemsMetadata = {
5423
5721
 
5424
5722
  declare type TransformSearchParameters = (searchParameters: SearchParameters) => PlainSearchParameters;
5425
5723
 
5724
+ declare const trendingItems: TrendingItemsWidget;
5725
+
5726
+ declare type TrendingItemsConnector<THit extends BaseHit = BaseHit> = Connector<TrendingItemsWidgetDescription<THit>, TrendingItemsConnectorParams<THit>>;
5727
+
5728
+ declare type TrendingItemsConnectorParams<THit extends BaseHit = BaseHit> = ({
5729
+ /**
5730
+ * The facet attribute to get recommendations for.
5731
+ */
5732
+ facetName: string;
5733
+ /**
5734
+ * The facet value to get recommendations for.
5735
+ */
5736
+ facetValue: string;
5737
+ } | {
5738
+ facetName?: never;
5739
+ facetValue?: never;
5740
+ }) & {
5741
+ /**
5742
+ * The number of recommendations to retrieve.
5743
+ */
5744
+ limit?: number;
5745
+ /**
5746
+ * The threshold for the recommendations confidence score (between 0 and 100).
5747
+ */
5748
+ threshold?: number;
5749
+ /**
5750
+ * List of search parameters to send.
5751
+ */
5752
+ fallbackParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
5753
+ /**
5754
+ * List of search parameters to send.
5755
+ */
5756
+ queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
5757
+ /**
5758
+ * Whether to escape HTML tags from items string values.
5759
+ *
5760
+ * @default true
5761
+ */
5762
+ escapeHTML?: boolean;
5763
+ /**
5764
+ * Function to transform the items passed to the templates.
5765
+ */
5766
+ transformItems?: TransformItems<Hit<THit>, {
5767
+ results: RecommendResultItem;
5768
+ }>;
5769
+ };
5770
+
5771
+ declare type TrendingItemsCSSClasses = Partial<RecommendClassNames>;
5772
+
5773
+ declare type TrendingItemsRenderState<THit extends BaseHit = BaseHit> = {
5774
+ /**
5775
+ * The matched recommendations from the Algolia API.
5776
+ */
5777
+ items: Array<Hit<THit>>;
5778
+ };
5779
+
5780
+ declare type TrendingItemsTemplates = Partial<{
5781
+ /**
5782
+ * Template to use when there are no results.
5783
+ */
5784
+ empty: Template<RecommendResultItem>;
5785
+ /**
5786
+ * Template to use for the header of the widget.
5787
+ */
5788
+ header: Template<Pick<Parameters<NonNullable<TrendingItemsProps<Hit>['headerComponent']>>[0], 'items'> & {
5789
+ cssClasses: RecommendClassNames;
5790
+ }>;
5791
+ /**
5792
+ * Template to use for each result. This template will receive an object containing a single record.
5793
+ */
5794
+ item: Template<Hit>;
5795
+ }>;
5796
+
5797
+ declare type TrendingItemsWidget = WidgetFactory<TrendingItemsWidgetDescription & {
5798
+ $$widgetType: 'ais.trendingItems';
5799
+ }, TrendingItemsConnectorParams, TrendingItemsWidgetParams>;
5800
+
5801
+ declare type TrendingItemsWidgetDescription<THit extends BaseHit = BaseHit> = {
5802
+ $$type: 'ais.trendingItems';
5803
+ renderState: TrendingItemsRenderState<THit>;
5804
+ };
5805
+
5806
+ declare type TrendingItemsWidgetParams = {
5807
+ /**
5808
+ * CSS selector or `HTMLElement` to insert the widget into.
5809
+ */
5810
+ container: string | HTMLElement;
5811
+ /**
5812
+ * Templates to customize the widget.
5813
+ */
5814
+ templates?: TrendingItemsTemplates;
5815
+ /**
5816
+ * CSS classes to add to the widget elements.
5817
+ */
5818
+ cssClasses?: TrendingItemsCSSClasses;
5819
+ };
5820
+
5426
5821
  declare type UiState = {
5427
5822
  [indexId: string]: IndexUiState;
5428
5823
  };
@@ -5528,7 +5923,7 @@ declare type VoiceSearchWidgetParams = {
5528
5923
 
5529
5924
  declare type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
5530
5925
  $$type: string;
5531
- }> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>>;
5926
+ }> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>> & (SearchWidget<TWidgetDescription> | RecommendWidget<TWidgetDescription>);
5532
5927
 
5533
5928
  declare type WidgetDescription = {
5534
5929
  $$type: string;
@@ -5585,6 +5980,7 @@ declare namespace widgets {
5585
5980
  poweredBy,
5586
5981
  queryRuleContext,
5587
5982
  queryRuleCustomData,
5983
+ relatedProducts,
5588
5984
  rangeInput,
5589
5985
  rangeSlider,
5590
5986
  ratingMenu,
@@ -5594,7 +5990,10 @@ declare namespace widgets {
5594
5990
  sortBy,
5595
5991
  stats,
5596
5992
  toggleRefinement,
5597
- voiceSearch
5993
+ trendingItems,
5994
+ voiceSearch,
5995
+ frequentlyBoughtTogether,
5996
+ lookingSimilar
5598
5997
  }
5599
5998
  }
5600
5999