instantsearch.js 4.68.0 → 4.69.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.
- package/cjs/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.js +93 -0
- package/cjs/connectors/index.js +28 -0
- package/cjs/connectors/looking-similar/connectLookingSimilar.js +94 -0
- package/cjs/connectors/related-products/connectRelatedProducts.js +94 -0
- package/cjs/connectors/trending-items/connectTrendingItems.js +90 -0
- package/cjs/lib/InstantSearch.js +9 -1
- package/cjs/lib/utils/addWidgetId.js +13 -0
- package/cjs/lib/utils/render-args.js +3 -3
- package/cjs/lib/version.js +1 -1
- package/cjs/widgets/frequently-bought-together/frequently-bought-together.js +120 -0
- package/cjs/widgets/index/index.js +82 -20
- package/cjs/widgets/index.js +28 -0
- package/cjs/widgets/looking-similar/looking-similar.js +122 -0
- package/cjs/widgets/related-products/related-products.js +122 -0
- package/cjs/widgets/trending-items/trending-items.js +126 -0
- package/dist/instantsearch.development.d.ts +403 -10
- package/dist/instantsearch.development.js +1679 -274
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +403 -10
- package/dist/instantsearch.production.min.d.ts +403 -10
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.d.ts +45 -0
- package/es/connectors/frequently-bought-together/connectFrequentlyBoughtTogether.js +86 -0
- package/es/connectors/index.d.ts +4 -0
- package/es/connectors/index.js +5 -1
- package/es/connectors/looking-similar/connectLookingSimilar.d.ts +49 -0
- package/es/connectors/looking-similar/connectLookingSimilar.js +87 -0
- package/es/connectors/related-products/connectRelatedProducts.d.ts +49 -0
- package/es/connectors/related-products/connectRelatedProducts.js +87 -0
- package/es/connectors/trending-items/connectTrendingItems.d.ts +57 -0
- package/es/connectors/trending-items/connectTrendingItems.js +83 -0
- package/es/lib/InstantSearch.d.ts +2 -0
- package/es/lib/InstantSearch.js +9 -1
- package/es/lib/templating/renderTemplate.d.ts +1 -1
- package/es/lib/utils/addWidgetId.d.ts +2 -0
- package/es/lib/utils/addWidgetId.js +7 -0
- package/es/lib/utils/render-args.d.ts +3 -3
- package/es/lib/utils/render-args.js +3 -3
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/templates.d.ts +1 -1
- package/es/types/widget.d.ts +16 -9
- package/es/widgets/frequently-bought-together/frequently-bought-together.d.ts +41 -0
- package/es/widgets/frequently-bought-together/frequently-bought-together.js +112 -0
- package/es/widgets/index/index.d.ts +2 -1
- package/es/widgets/index/index.js +82 -20
- package/es/widgets/index.d.ts +4 -0
- package/es/widgets/index.js +5 -1
- package/es/widgets/looking-similar/looking-similar.d.ts +41 -0
- package/es/widgets/looking-similar/looking-similar.js +114 -0
- package/es/widgets/related-products/related-products.d.ts +41 -0
- package/es/widgets/related-products/related-products.js +114 -0
- package/es/widgets/trending-items/trending-items.d.ts +41 -0
- package/es/widgets/trending-items/trending-items.js +118 -0
- 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,19 @@ 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 { RecommendResultItem } from 'algoliasearch-helper';
|
|
23
|
+
import type { RelatedProductsProps } from 'instantsearch-ui-components';
|
|
19
24
|
import { SearchClient } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
20
25
|
import { SearchOptions } from 'algoliasearch-helper/types/algoliasearch.js';
|
|
21
26
|
import type { SearchParameters } from 'algoliasearch-helper';
|
|
22
27
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
28
|
+
import type { TrendingItemsProps } from 'instantsearch-ui-components';
|
|
23
29
|
import { VNode } from 'preact';
|
|
24
30
|
|
|
25
31
|
declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
@@ -735,6 +741,8 @@ declare const connectCurrentRefinements: CurrentRefinementsConnector;
|
|
|
735
741
|
|
|
736
742
|
declare const connectDynamicWidgets: DynamicWidgetsConnector;
|
|
737
743
|
|
|
744
|
+
declare const connectFrequentlyBoughtTogether: FrequentlyBoughtTogetherConnector;
|
|
745
|
+
|
|
738
746
|
/**
|
|
739
747
|
* 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
748
|
*
|
|
@@ -771,6 +779,8 @@ declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
|
771
779
|
|
|
772
780
|
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector<BaseHit>;
|
|
773
781
|
|
|
782
|
+
declare const connectLookingSimilar: LookingSimilarConnector;
|
|
783
|
+
|
|
774
784
|
/**
|
|
775
785
|
* **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
786
|
*
|
|
@@ -820,11 +830,13 @@ declare namespace connectors {
|
|
|
820
830
|
connectPagination,
|
|
821
831
|
connectRange,
|
|
822
832
|
connectRefinementList,
|
|
833
|
+
connectRelatedProducts,
|
|
823
834
|
connectSearchBox,
|
|
824
835
|
connectSortBy,
|
|
825
836
|
connectRatingMenu,
|
|
826
837
|
connectStats,
|
|
827
838
|
connectToggleRefinement,
|
|
839
|
+
connectTrendingItems,
|
|
828
840
|
connectBreadcrumb,
|
|
829
841
|
connectGeoSearch,
|
|
830
842
|
connectPoweredBy,
|
|
@@ -833,7 +845,9 @@ declare namespace connectors {
|
|
|
833
845
|
connectAutocomplete,
|
|
834
846
|
connectQueryRules,
|
|
835
847
|
connectVoiceSearch,
|
|
836
|
-
connectRelevantSort
|
|
848
|
+
connectRelevantSort,
|
|
849
|
+
connectFrequentlyBoughtTogether,
|
|
850
|
+
connectLookingSimilar
|
|
837
851
|
}
|
|
838
852
|
}
|
|
839
853
|
|
|
@@ -889,6 +903,8 @@ declare const connectRatingMenu: RatingMenuConnector;
|
|
|
889
903
|
*/
|
|
890
904
|
declare const connectRefinementList: RefinementListConnector;
|
|
891
905
|
|
|
906
|
+
declare const connectRelatedProducts: RelatedProductsConnector;
|
|
907
|
+
|
|
892
908
|
declare const connectRelevantSort: RelevantSortConnector;
|
|
893
909
|
|
|
894
910
|
/**
|
|
@@ -913,6 +929,8 @@ declare const connectStats: StatsConnector;
|
|
|
913
929
|
*/
|
|
914
930
|
declare const connectToggleRefinement: ToggleRefinementConnector;
|
|
915
931
|
|
|
932
|
+
declare const connectTrendingItems: TrendingItemsConnector;
|
|
933
|
+
|
|
916
934
|
declare const connectVoiceSearch: VoiceSearchConnector;
|
|
917
935
|
|
|
918
936
|
declare function createInfiniteHitsSessionStorageCache(): InfiniteHitsCache;
|
|
@@ -1120,6 +1138,7 @@ declare const _default: PlacesWidget;
|
|
|
1120
1138
|
declare type DisposeOptions = {
|
|
1121
1139
|
helper: AlgoliaSearchHelper;
|
|
1122
1140
|
state: SearchParameters;
|
|
1141
|
+
recommendState: RecommendParameters;
|
|
1123
1142
|
parent: IndexWidget;
|
|
1124
1143
|
};
|
|
1125
1144
|
|
|
@@ -1229,6 +1248,91 @@ declare const EXPERIMENTAL_dynamicWidgets: DynamicWidgetsWidget;
|
|
|
1229
1248
|
|
|
1230
1249
|
declare type FacetValue = string | boolean | number;
|
|
1231
1250
|
|
|
1251
|
+
declare const frequentlyBoughtTogether: FrequentlyBoughtTogetherWidget;
|
|
1252
|
+
|
|
1253
|
+
declare type FrequentlyBoughtTogetherConnector<THit extends BaseHit = BaseHit> = Connector<FrequentlyBoughtTogetherWidgetDescription<THit>, FrequentlyBoughtTogetherConnectorParams<THit>>;
|
|
1254
|
+
|
|
1255
|
+
declare type FrequentlyBoughtTogetherConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
1256
|
+
/**
|
|
1257
|
+
* The objectIDs of the items to get the frequently bought together items for.
|
|
1258
|
+
*/
|
|
1259
|
+
objectIDs: string[];
|
|
1260
|
+
/**
|
|
1261
|
+
* Threshold for the recommendations confidence score (between 0 and 100). Only recommendations with a greater score are returned.
|
|
1262
|
+
*/
|
|
1263
|
+
threshold?: number;
|
|
1264
|
+
/**
|
|
1265
|
+
* The maximum number of recommendations to return.
|
|
1266
|
+
*/
|
|
1267
|
+
limit?: number;
|
|
1268
|
+
/**
|
|
1269
|
+
* Parameters to pass to the request.
|
|
1270
|
+
*/
|
|
1271
|
+
queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
|
|
1272
|
+
/**
|
|
1273
|
+
* Whether to escape HTML tags from items string values.
|
|
1274
|
+
*
|
|
1275
|
+
* @default true
|
|
1276
|
+
*/
|
|
1277
|
+
escapeHTML?: boolean;
|
|
1278
|
+
/**
|
|
1279
|
+
* Function to transform the items passed to the templates.
|
|
1280
|
+
*/
|
|
1281
|
+
transformItems?: TransformItems<Hit<THit>, {
|
|
1282
|
+
results: RecommendResultItem;
|
|
1283
|
+
}>;
|
|
1284
|
+
};
|
|
1285
|
+
|
|
1286
|
+
declare type FrequentlyBoughtTogetherCSSClasses = Partial<RecommendClassNames>;
|
|
1287
|
+
|
|
1288
|
+
declare type FrequentlyBoughtTogetherRenderState<THit extends BaseHit = BaseHit> = {
|
|
1289
|
+
/**
|
|
1290
|
+
* The matched recommendations from Algolia API.
|
|
1291
|
+
*/
|
|
1292
|
+
items: Array<Hit<THit>>;
|
|
1293
|
+
};
|
|
1294
|
+
|
|
1295
|
+
declare type FrequentlyBoughtTogetherTemplates = Partial<{
|
|
1296
|
+
/**
|
|
1297
|
+
* Template to use when there are no results.
|
|
1298
|
+
*/
|
|
1299
|
+
empty: Template<RecommendResultItem>;
|
|
1300
|
+
/**
|
|
1301
|
+
* Template to use for the header of the widget.
|
|
1302
|
+
*/
|
|
1303
|
+
header: Template<Pick<Parameters<NonNullable<FrequentlyBoughtTogetherProps<Hit>['headerComponent']>>[0], 'items'> & {
|
|
1304
|
+
cssClasses: RecommendClassNames;
|
|
1305
|
+
}>;
|
|
1306
|
+
/**
|
|
1307
|
+
* Template to use for each result. This template will receive an object containing a single record.
|
|
1308
|
+
*/
|
|
1309
|
+
item: Template<Hit>;
|
|
1310
|
+
}>;
|
|
1311
|
+
|
|
1312
|
+
declare type FrequentlyBoughtTogetherWidget = WidgetFactory<FrequentlyBoughtTogetherWidgetDescription & {
|
|
1313
|
+
$$widgetType: 'ais.frequentlyBoughtTogether';
|
|
1314
|
+
}, FrequentlyBoughtTogetherConnectorParams, FrequentlyBoughtTogetherWidgetParams>;
|
|
1315
|
+
|
|
1316
|
+
declare type FrequentlyBoughtTogetherWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
1317
|
+
$$type: 'ais.frequentlyBoughtTogether';
|
|
1318
|
+
renderState: FrequentlyBoughtTogetherRenderState<THit>;
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
declare type FrequentlyBoughtTogetherWidgetParams = {
|
|
1322
|
+
/**
|
|
1323
|
+
* CSS Selector or HTMLElement to insert the widget.
|
|
1324
|
+
*/
|
|
1325
|
+
container: string | HTMLElement;
|
|
1326
|
+
/**
|
|
1327
|
+
* Templates to use for the widget.
|
|
1328
|
+
*/
|
|
1329
|
+
templates?: FrequentlyBoughtTogetherTemplates;
|
|
1330
|
+
/**
|
|
1331
|
+
* CSS classes to add.
|
|
1332
|
+
*/
|
|
1333
|
+
cssClasses?: FrequentlyBoughtTogetherCSSClasses;
|
|
1334
|
+
};
|
|
1335
|
+
|
|
1232
1336
|
declare type GeoHit<THit extends BaseHit = Record<string, any>> = Hit<THit> & Required<Pick<Hit, '_geoloc'>>;
|
|
1233
1337
|
|
|
1234
1338
|
declare type GeoLoc = {
|
|
@@ -2100,6 +2204,7 @@ declare type IndexWidget<TUiState extends UiState = UiState> = Omit<Widget<Index
|
|
|
2100
2204
|
getIndexId: () => string;
|
|
2101
2205
|
getHelper: () => AlgoliaSearchHelper | null;
|
|
2102
2206
|
getResults: () => SearchResults | null;
|
|
2207
|
+
getResultsForWidget: (widget: IndexWidget | Widget) => SearchResults | RecommendResultItem | null;
|
|
2103
2208
|
getPreviousState: () => SearchParameters | null;
|
|
2104
2209
|
getScopedResults: () => ScopedResult[];
|
|
2105
2210
|
getParent: () => IndexWidget | null;
|
|
@@ -2401,6 +2506,8 @@ declare class InstantSearch<TUiState extends UiState = UiState, TRouteState = TU
|
|
|
2401
2506
|
_createURL: CreateURL<TUiState>;
|
|
2402
2507
|
_searchFunction?: InstantSearchOptions['searchFunction'];
|
|
2403
2508
|
_mainHelperSearch?: AlgoliaSearchHelper['search'];
|
|
2509
|
+
_hasSearchWidget: boolean;
|
|
2510
|
+
_hasRecommendWidget: boolean;
|
|
2404
2511
|
_insights: InstantSearchOptions['insights'];
|
|
2405
2512
|
middleware: Array<{
|
|
2406
2513
|
creator: Middleware<TUiState>;
|
|
@@ -2656,6 +2763,95 @@ declare type InternalMiddleware<TUiState extends UiState = UiState> = (options:
|
|
|
2656
2763
|
|
|
2657
2764
|
declare function isMetadataEnabled(): boolean;
|
|
2658
2765
|
|
|
2766
|
+
declare const lookingSimilar: LookingSimilarWidget;
|
|
2767
|
+
|
|
2768
|
+
declare type LookingSimilarConnector<THit extends BaseHit = BaseHit> = Connector<LookingSimilarWidgetDescription<THit>, LookingSimilarConnectorParams<THit>>;
|
|
2769
|
+
|
|
2770
|
+
declare type LookingSimilarConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
2771
|
+
/**
|
|
2772
|
+
* The `objectIDs` of the items to get similar looking products from.
|
|
2773
|
+
*/
|
|
2774
|
+
objectIDs: string[];
|
|
2775
|
+
/**
|
|
2776
|
+
* The number of recommendations to retrieve.
|
|
2777
|
+
*/
|
|
2778
|
+
limit?: number;
|
|
2779
|
+
/**
|
|
2780
|
+
* The threshold for the recommendations confidence score (between 0 and 100).
|
|
2781
|
+
*/
|
|
2782
|
+
threshold?: number;
|
|
2783
|
+
/**
|
|
2784
|
+
* List of search parameters to send.
|
|
2785
|
+
*/
|
|
2786
|
+
fallbackParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
|
|
2787
|
+
/**
|
|
2788
|
+
* List of search parameters to send.
|
|
2789
|
+
*/
|
|
2790
|
+
queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
|
|
2791
|
+
/**
|
|
2792
|
+
* Whether to escape HTML tags from items string values.
|
|
2793
|
+
*
|
|
2794
|
+
* @default true
|
|
2795
|
+
*/
|
|
2796
|
+
escapeHTML?: boolean;
|
|
2797
|
+
/**
|
|
2798
|
+
* Function to transform the items passed to the templates.
|
|
2799
|
+
*/
|
|
2800
|
+
transformItems?: TransformItems<Hit<THit>, {
|
|
2801
|
+
results: RecommendResultItem;
|
|
2802
|
+
}>;
|
|
2803
|
+
};
|
|
2804
|
+
|
|
2805
|
+
declare type LookingSimilarCSSClasses = Partial<RecommendClassNames>;
|
|
2806
|
+
|
|
2807
|
+
declare type LookingSimilarRenderState<THit extends BaseHit = BaseHit> = {
|
|
2808
|
+
/**
|
|
2809
|
+
* The matched recommendations from the Algolia API.
|
|
2810
|
+
*/
|
|
2811
|
+
items: Array<Hit<THit>>;
|
|
2812
|
+
};
|
|
2813
|
+
|
|
2814
|
+
declare type LookingSimilarTemplates = Partial<{
|
|
2815
|
+
/**
|
|
2816
|
+
* Template to use when there are no results.
|
|
2817
|
+
*/
|
|
2818
|
+
empty: Template<RecommendResultItem>;
|
|
2819
|
+
/**
|
|
2820
|
+
* Template to use for the header of the widget.
|
|
2821
|
+
*/
|
|
2822
|
+
header: Template<Pick<Parameters<NonNullable<LookingSimilarProps<Hit>['headerComponent']>>[0], 'items'> & {
|
|
2823
|
+
cssClasses: RecommendClassNames;
|
|
2824
|
+
}>;
|
|
2825
|
+
/**
|
|
2826
|
+
* Template to use for each result. This template will receive an object containing a single record.
|
|
2827
|
+
*/
|
|
2828
|
+
item: Template<Hit>;
|
|
2829
|
+
}>;
|
|
2830
|
+
|
|
2831
|
+
declare type LookingSimilarWidget = WidgetFactory<LookingSimilarWidgetDescription & {
|
|
2832
|
+
$$widgetType: 'ais.lookingSimilar';
|
|
2833
|
+
}, LookingSimilarConnectorParams, LookingSimilarWidgetParams>;
|
|
2834
|
+
|
|
2835
|
+
declare type LookingSimilarWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
2836
|
+
$$type: 'ais.lookingSimilar';
|
|
2837
|
+
renderState: LookingSimilarRenderState<THit>;
|
|
2838
|
+
};
|
|
2839
|
+
|
|
2840
|
+
declare type LookingSimilarWidgetParams = {
|
|
2841
|
+
/**
|
|
2842
|
+
* CSS Selector or HTMLElement to insert the widget.
|
|
2843
|
+
*/
|
|
2844
|
+
container: string | HTMLElement;
|
|
2845
|
+
/**
|
|
2846
|
+
* Templates to use for the widget.
|
|
2847
|
+
*/
|
|
2848
|
+
templates?: LookingSimilarTemplates;
|
|
2849
|
+
/**
|
|
2850
|
+
* CSS classes to add.
|
|
2851
|
+
*/
|
|
2852
|
+
cssClasses?: LookingSimilarCSSClasses;
|
|
2853
|
+
};
|
|
2854
|
+
|
|
2659
2855
|
declare type MatchingPatterns = {
|
|
2660
2856
|
[attribute: string]: {
|
|
2661
2857
|
/**
|
|
@@ -4021,11 +4217,18 @@ declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
|
4021
4217
|
state: PlainSearchParameters;
|
|
4022
4218
|
}) => InfiniteHitsCachedHits<THit> | null;
|
|
4023
4219
|
|
|
4024
|
-
declare type
|
|
4025
|
-
|
|
4220
|
+
declare type RecommendRenderOptions = SharedRenderOptions & {
|
|
4221
|
+
results: RecommendResultItem;
|
|
4222
|
+
};
|
|
4223
|
+
|
|
4224
|
+
declare type RecommendWidget<TWidgetDescription extends WidgetDescription & WidgetParams> = {
|
|
4225
|
+
dependsOn: 'recommend';
|
|
4226
|
+
$$id?: number;
|
|
4026
4227
|
getWidgetParameters: (state: RecommendParameters, widgetParametersOptions: {
|
|
4027
4228
|
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4028
4229
|
}) => RecommendParameters;
|
|
4230
|
+
getRenderState: (renderState: Expand<IndexRenderState & Partial<TWidgetDescription['indexRenderState']>>, renderOptions: InitOptions | RecommendRenderOptions) => IndexRenderState & TWidgetDescription['indexRenderState'];
|
|
4231
|
+
getWidgetRenderState: (renderOptions: InitOptions | RecommendRenderOptions) => Expand<WidgetRenderState<TWidgetDescription['renderState'], TWidgetDescription['widgetParams']>>;
|
|
4029
4232
|
};
|
|
4030
4233
|
|
|
4031
4234
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
@@ -4367,6 +4570,95 @@ declare type RefinementListWidgetParams = {
|
|
|
4367
4570
|
cssClasses?: RefinementListCSSClasses;
|
|
4368
4571
|
};
|
|
4369
4572
|
|
|
4573
|
+
declare const relatedProducts: RelatedProductsWidget;
|
|
4574
|
+
|
|
4575
|
+
declare type RelatedProductsConnector<THit extends BaseHit = BaseHit> = Connector<RelatedProductsWidgetDescription<THit>, RelatedProductsConnectorParams<THit>>;
|
|
4576
|
+
|
|
4577
|
+
declare type RelatedProductsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
4578
|
+
/**
|
|
4579
|
+
* The `objectIDs` of the items to get related products from.
|
|
4580
|
+
*/
|
|
4581
|
+
objectIDs: string[];
|
|
4582
|
+
/**
|
|
4583
|
+
* The number of recommendations to retrieve.
|
|
4584
|
+
*/
|
|
4585
|
+
limit?: number;
|
|
4586
|
+
/**
|
|
4587
|
+
* The threshold for the recommendations confidence score (between 0 and 100).
|
|
4588
|
+
*/
|
|
4589
|
+
threshold?: number;
|
|
4590
|
+
/**
|
|
4591
|
+
* List of search parameters to send.
|
|
4592
|
+
*/
|
|
4593
|
+
fallbackParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
|
|
4594
|
+
/**
|
|
4595
|
+
* List of search parameters to send.
|
|
4596
|
+
*/
|
|
4597
|
+
queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
|
|
4598
|
+
/**
|
|
4599
|
+
* Whether to escape HTML tags from items string values.
|
|
4600
|
+
*
|
|
4601
|
+
* @default true
|
|
4602
|
+
*/
|
|
4603
|
+
escapeHTML?: boolean;
|
|
4604
|
+
/**
|
|
4605
|
+
* Function to transform the items passed to the templates.
|
|
4606
|
+
*/
|
|
4607
|
+
transformItems?: TransformItems<Hit<THit>, {
|
|
4608
|
+
results: RecommendResultItem;
|
|
4609
|
+
}>;
|
|
4610
|
+
};
|
|
4611
|
+
|
|
4612
|
+
declare type RelatedProductsCSSClasses = Partial<RecommendClassNames>;
|
|
4613
|
+
|
|
4614
|
+
declare type RelatedProductsRenderState<THit extends BaseHit = BaseHit> = {
|
|
4615
|
+
/**
|
|
4616
|
+
* The matched recommendations from the Algolia API.
|
|
4617
|
+
*/
|
|
4618
|
+
items: Array<Hit<THit>>;
|
|
4619
|
+
};
|
|
4620
|
+
|
|
4621
|
+
declare type RelatedProductsTemplates = Partial<{
|
|
4622
|
+
/**
|
|
4623
|
+
* Template to use when there are no results.
|
|
4624
|
+
*/
|
|
4625
|
+
empty: Template<RecommendResultItem>;
|
|
4626
|
+
/**
|
|
4627
|
+
* Template to use for the header of the widget.
|
|
4628
|
+
*/
|
|
4629
|
+
header: Template<Pick<Parameters<NonNullable<RelatedProductsProps<Hit>['headerComponent']>>[0], 'items'> & {
|
|
4630
|
+
cssClasses: RecommendClassNames;
|
|
4631
|
+
}>;
|
|
4632
|
+
/**
|
|
4633
|
+
* Template to use for each result. This template will receive an object containing a single record.
|
|
4634
|
+
*/
|
|
4635
|
+
item: Template<Hit>;
|
|
4636
|
+
}>;
|
|
4637
|
+
|
|
4638
|
+
declare type RelatedProductsWidget = WidgetFactory<RelatedProductsWidgetDescription & {
|
|
4639
|
+
$$widgetType: 'ais.relatedProducts';
|
|
4640
|
+
}, RelatedProductsConnectorParams, RelatedProductsWidgetParams>;
|
|
4641
|
+
|
|
4642
|
+
declare type RelatedProductsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
4643
|
+
$$type: 'ais.relatedProducts';
|
|
4644
|
+
renderState: RelatedProductsRenderState<THit>;
|
|
4645
|
+
};
|
|
4646
|
+
|
|
4647
|
+
declare type RelatedProductsWidgetParams = {
|
|
4648
|
+
/**
|
|
4649
|
+
* CSS selector or `HTMLElement` to insert the widget into.
|
|
4650
|
+
*/
|
|
4651
|
+
container: string | HTMLElement;
|
|
4652
|
+
/**
|
|
4653
|
+
* Templates to customize the widget.
|
|
4654
|
+
*/
|
|
4655
|
+
templates?: RelatedProductsTemplates;
|
|
4656
|
+
/**
|
|
4657
|
+
* CSS classes to add to the widget elements.
|
|
4658
|
+
*/
|
|
4659
|
+
cssClasses?: RelatedProductsCSSClasses;
|
|
4660
|
+
};
|
|
4661
|
+
|
|
4370
4662
|
declare const relevantSort: RelevantSortWidget;
|
|
4371
4663
|
|
|
4372
4664
|
declare type RelevantSortConnector = Connector<RelevantSortWidgetDescription, RelevantSortConnectorParams>;
|
|
@@ -4488,7 +4780,7 @@ declare function renderTemplate({ templates, templateKey, compileOptions, helper
|
|
|
4488
4780
|
data?: Record<string, any>;
|
|
4489
4781
|
bindEvent?: BindEventForHits;
|
|
4490
4782
|
sendEvent?: SendEventForHits;
|
|
4491
|
-
}): string | VNode< {}> | VNode< {}>[];
|
|
4783
|
+
}): string | VNode< {}> | VNode< {}>[] | null;
|
|
4492
4784
|
|
|
4493
4785
|
declare type RequiredKeys<TObject, TKeys extends keyof TObject> = Expand<Required<Pick<TObject, TKeys>> & Omit<TObject, TKeys>>;
|
|
4494
4786
|
|
|
@@ -4538,7 +4830,7 @@ declare type RequiredUiStateLifeCycle<TWidgetDescription extends WidgetDescripti
|
|
|
4538
4830
|
getWidgetSearchParameters: (state: SearchParameters, widgetSearchParametersOptions: {
|
|
4539
4831
|
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
4540
4832
|
}) => SearchParameters;
|
|
4541
|
-
}
|
|
4833
|
+
};
|
|
4542
4834
|
|
|
4543
4835
|
declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescription> = {
|
|
4544
4836
|
/**
|
|
@@ -4561,7 +4853,7 @@ declare type RequiredWidgetLifeCycle<TWidgetDescription extends WidgetDescriptio
|
|
|
4561
4853
|
* Called when this widget is unmounted. Used to remove refinements set by
|
|
4562
4854
|
* during this widget's initialization and life time.
|
|
4563
4855
|
*/
|
|
4564
|
-
dispose?: (options: DisposeOptions) => SearchParameters | void;
|
|
4856
|
+
dispose?: (options: DisposeOptions) => SearchParameters | RecommendParameters | void;
|
|
4565
4857
|
};
|
|
4566
4858
|
|
|
4567
4859
|
declare type RequiredWidgetType<TWidgetDescription extends WidgetDescription> = {
|
|
@@ -4868,7 +5160,7 @@ declare type SearchBoxWidgetParams = {
|
|
|
4868
5160
|
queryHook?: (query: string, hook: (value: string) => void) => void;
|
|
4869
5161
|
};
|
|
4870
5162
|
|
|
4871
|
-
declare type
|
|
5163
|
+
declare type SearchWidget<TWidgetDescription extends WidgetDescription> = {
|
|
4872
5164
|
dependsOn?: 'search';
|
|
4873
5165
|
getWidgetParameters?: (state: SearchParameters, widgetParametersOptions: {
|
|
4874
5166
|
uiState: Expand<Partial<TWidgetDescription['indexUiState'] & IndexUiState>>;
|
|
@@ -5227,7 +5519,7 @@ declare type StatsWidgetParams = {
|
|
|
5227
5519
|
|
|
5228
5520
|
declare type Status = 'initial' | 'askingPermission' | 'waiting' | 'recognizing' | 'finished' | 'error';
|
|
5229
5521
|
|
|
5230
|
-
declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string);
|
|
5522
|
+
declare type Template<TTemplateData = void> = string | ((data: TTemplateData, params: TemplateParams) => VNode | VNode[] | string | null);
|
|
5231
5523
|
|
|
5232
5524
|
declare type TemplateParams = {
|
|
5233
5525
|
html: typeof html;
|
|
@@ -5423,6 +5715,103 @@ declare type TransformItemsMetadata = {
|
|
|
5423
5715
|
|
|
5424
5716
|
declare type TransformSearchParameters = (searchParameters: SearchParameters) => PlainSearchParameters;
|
|
5425
5717
|
|
|
5718
|
+
declare const trendingItems: TrendingItemsWidget;
|
|
5719
|
+
|
|
5720
|
+
declare type TrendingItemsConnector<THit extends BaseHit = BaseHit> = Connector<TrendingItemsWidgetDescription<THit>, TrendingItemsConnectorParams<THit>>;
|
|
5721
|
+
|
|
5722
|
+
declare type TrendingItemsConnectorParams<THit extends BaseHit = BaseHit> = ({
|
|
5723
|
+
/**
|
|
5724
|
+
* The facet attribute to get recommendations for.
|
|
5725
|
+
*/
|
|
5726
|
+
facetName: string;
|
|
5727
|
+
/**
|
|
5728
|
+
* The facet value to get recommendations for.
|
|
5729
|
+
*/
|
|
5730
|
+
facetValue: string;
|
|
5731
|
+
} | {
|
|
5732
|
+
facetName?: never;
|
|
5733
|
+
facetValue?: never;
|
|
5734
|
+
}) & {
|
|
5735
|
+
/**
|
|
5736
|
+
* The number of recommendations to retrieve.
|
|
5737
|
+
*/
|
|
5738
|
+
limit?: number;
|
|
5739
|
+
/**
|
|
5740
|
+
* The threshold for the recommendations confidence score (between 0 and 100).
|
|
5741
|
+
*/
|
|
5742
|
+
threshold?: number;
|
|
5743
|
+
/**
|
|
5744
|
+
* List of search parameters to send.
|
|
5745
|
+
*/
|
|
5746
|
+
fallbackParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
|
|
5747
|
+
/**
|
|
5748
|
+
* List of search parameters to send.
|
|
5749
|
+
*/
|
|
5750
|
+
queryParameters?: Omit<PlainSearchParameters, 'page' | 'hitsPerPage' | 'offset' | 'length'>;
|
|
5751
|
+
/**
|
|
5752
|
+
* Whether to escape HTML tags from items string values.
|
|
5753
|
+
*
|
|
5754
|
+
* @default true
|
|
5755
|
+
*/
|
|
5756
|
+
escapeHTML?: boolean;
|
|
5757
|
+
/**
|
|
5758
|
+
* Function to transform the items passed to the templates.
|
|
5759
|
+
*/
|
|
5760
|
+
transformItems?: TransformItems<Hit<THit>, {
|
|
5761
|
+
results: RecommendResultItem;
|
|
5762
|
+
}>;
|
|
5763
|
+
};
|
|
5764
|
+
|
|
5765
|
+
declare type TrendingItemsCSSClasses = Partial<RecommendClassNames>;
|
|
5766
|
+
|
|
5767
|
+
declare type TrendingItemsRenderState<THit extends BaseHit = BaseHit> = {
|
|
5768
|
+
/**
|
|
5769
|
+
* The matched recommendations from the Algolia API.
|
|
5770
|
+
*/
|
|
5771
|
+
items: Array<Hit<THit>>;
|
|
5772
|
+
};
|
|
5773
|
+
|
|
5774
|
+
declare type TrendingItemsTemplates = Partial<{
|
|
5775
|
+
/**
|
|
5776
|
+
* Template to use when there are no results.
|
|
5777
|
+
*/
|
|
5778
|
+
empty: Template<RecommendResultItem>;
|
|
5779
|
+
/**
|
|
5780
|
+
* Template to use for the header of the widget.
|
|
5781
|
+
*/
|
|
5782
|
+
header: Template<Pick<Parameters<NonNullable<TrendingItemsProps<Hit>['headerComponent']>>[0], 'items'> & {
|
|
5783
|
+
cssClasses: RecommendClassNames;
|
|
5784
|
+
}>;
|
|
5785
|
+
/**
|
|
5786
|
+
* Template to use for each result. This template will receive an object containing a single record.
|
|
5787
|
+
*/
|
|
5788
|
+
item: Template<Hit>;
|
|
5789
|
+
}>;
|
|
5790
|
+
|
|
5791
|
+
declare type TrendingItemsWidget = WidgetFactory<TrendingItemsWidgetDescription & {
|
|
5792
|
+
$$widgetType: 'ais.trendingItems';
|
|
5793
|
+
}, TrendingItemsConnectorParams, TrendingItemsWidgetParams>;
|
|
5794
|
+
|
|
5795
|
+
declare type TrendingItemsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
5796
|
+
$$type: 'ais.trendingItems';
|
|
5797
|
+
renderState: TrendingItemsRenderState<THit>;
|
|
5798
|
+
};
|
|
5799
|
+
|
|
5800
|
+
declare type TrendingItemsWidgetParams = {
|
|
5801
|
+
/**
|
|
5802
|
+
* CSS selector or `HTMLElement` to insert the widget into.
|
|
5803
|
+
*/
|
|
5804
|
+
container: string | HTMLElement;
|
|
5805
|
+
/**
|
|
5806
|
+
* Templates to customize the widget.
|
|
5807
|
+
*/
|
|
5808
|
+
templates?: TrendingItemsTemplates;
|
|
5809
|
+
/**
|
|
5810
|
+
* CSS classes to add to the widget elements.
|
|
5811
|
+
*/
|
|
5812
|
+
cssClasses?: TrendingItemsCSSClasses;
|
|
5813
|
+
};
|
|
5814
|
+
|
|
5426
5815
|
declare type UiState = {
|
|
5427
5816
|
[indexId: string]: IndexUiState;
|
|
5428
5817
|
};
|
|
@@ -5528,7 +5917,7 @@ declare type VoiceSearchWidgetParams = {
|
|
|
5528
5917
|
|
|
5529
5918
|
declare type Widget<TWidgetDescription extends WidgetDescription & WidgetParams = {
|
|
5530
5919
|
$$type: string;
|
|
5531
|
-
}> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription
|
|
5920
|
+
}> = Expand<RequiredWidgetLifeCycle<TWidgetDescription> & WidgetType<TWidgetDescription> & UiStateLifeCycle<TWidgetDescription> & RenderStateLifeCycle<TWidgetDescription>> & (SearchWidget<TWidgetDescription> | RecommendWidget<TWidgetDescription>);
|
|
5532
5921
|
|
|
5533
5922
|
declare type WidgetDescription = {
|
|
5534
5923
|
$$type: string;
|
|
@@ -5585,6 +5974,7 @@ declare namespace widgets {
|
|
|
5585
5974
|
poweredBy,
|
|
5586
5975
|
queryRuleContext,
|
|
5587
5976
|
queryRuleCustomData,
|
|
5977
|
+
relatedProducts,
|
|
5588
5978
|
rangeInput,
|
|
5589
5979
|
rangeSlider,
|
|
5590
5980
|
ratingMenu,
|
|
@@ -5594,7 +5984,10 @@ declare namespace widgets {
|
|
|
5594
5984
|
sortBy,
|
|
5595
5985
|
stats,
|
|
5596
5986
|
toggleRefinement,
|
|
5597
|
-
|
|
5987
|
+
trendingItems,
|
|
5988
|
+
voiceSearch,
|
|
5989
|
+
frequentlyBoughtTogether,
|
|
5990
|
+
lookingSimilar
|
|
5598
5991
|
}
|
|
5599
5992
|
}
|
|
5600
5993
|
|