instantsearch.js 4.38.1 → 4.39.2
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/CHANGELOG.md +27 -0
- package/cjs/connectors/hits/connectHits.js +1 -1
- package/cjs/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/cjs/lib/version.js +1 -1
- package/dist/instantsearch.development.d.ts +46 -40
- package/dist/instantsearch.development.js +6 -5
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +46 -40
- package/dist/instantsearch.production.min.d.ts +46 -40
- package/dist/instantsearch.production.min.js +2 -2
- package/dist/instantsearch.production.min.js.map +1 -1
- package/es/components/ToggleRefinement/ToggleRefinement.d.ts +3 -0
- package/es/components/ToggleRefinement/ToggleRefinement.js +4 -0
- package/es/connectors/hierarchical-menu/connectHierarchicalMenu.d.ts +2 -1
- package/es/connectors/hits/connectHits.d.ts +10 -10
- package/es/connectors/hits/connectHits.js +1 -1
- package/es/connectors/hits/connectHitsWithInsights.d.ts +1 -1
- package/es/connectors/infinite-hits/connectInfiniteHits.d.ts +21 -21
- package/es/connectors/infinite-hits/connectInfiniteHits.js +3 -2
- package/es/connectors/infinite-hits/connectInfiniteHitsWithInsights.d.ts +1 -1
- package/es/connectors/menu/connectMenu.d.ts +2 -1
- package/es/connectors/refinement-list/connectRefinementList.d.ts +2 -1
- package/es/lib/utils/createSendEventForHits.d.ts +3 -0
- package/es/lib/utils/createSendEventForHits.js +3 -0
- package/es/lib/version.d.ts +1 -1
- package/es/lib/version.js +1 -1
- package/es/types/results.d.ts +8 -5
- package/es/types/widget.d.ts +2 -1
- package/package.json +3 -3
|
@@ -12,8 +12,7 @@ import { default as qs_2 } from 'qs';
|
|
|
12
12
|
import type { SearchParameters } from 'algoliasearch-helper';
|
|
13
13
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
14
14
|
|
|
15
|
-
declare type AlgoliaHit = {
|
|
16
|
-
[attribute: string]: any;
|
|
15
|
+
declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
17
16
|
objectID: string;
|
|
18
17
|
_highlightResult?: HitHighlightResult;
|
|
19
18
|
_snippetResult?: HitSnippetResult;
|
|
@@ -36,7 +35,7 @@ declare type AlgoliaHit = {
|
|
|
36
35
|
};
|
|
37
36
|
_distinctSeqID?: number;
|
|
38
37
|
_geoLoc?: GeoLoc;
|
|
39
|
-
};
|
|
38
|
+
} & THit;
|
|
40
39
|
|
|
41
40
|
declare const analytics: AnalyticsWidget;
|
|
42
41
|
|
|
@@ -292,6 +291,8 @@ declare type AutocompleteWidgetDescription = {
|
|
|
292
291
|
};
|
|
293
292
|
};
|
|
294
293
|
|
|
294
|
+
declare type BaseHit = Record<string, unknown>;
|
|
295
|
+
|
|
295
296
|
declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
|
|
296
297
|
|
|
297
298
|
declare type Bounds = {
|
|
@@ -734,11 +735,11 @@ declare const connectHits: HitsConnector;
|
|
|
734
735
|
|
|
735
736
|
declare const connectHitsPerPage: HitsPerPageConnector;
|
|
736
737
|
|
|
737
|
-
declare const connectHitsWithInsights: HitsConnector
|
|
738
|
+
declare const connectHitsWithInsights: HitsConnector<BaseHit>;
|
|
738
739
|
|
|
739
740
|
declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
740
741
|
|
|
741
|
-
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector
|
|
742
|
+
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector<BaseHit>;
|
|
742
743
|
|
|
743
744
|
/**
|
|
744
745
|
* **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.
|
|
@@ -1471,7 +1472,7 @@ declare type HierarchicalMenuConnectorParams = {
|
|
|
1471
1472
|
*
|
|
1472
1473
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
1473
1474
|
*/
|
|
1474
|
-
sortBy?: SortBy<
|
|
1475
|
+
sortBy?: SortBy<SearchResults.HierarchicalFacet>;
|
|
1475
1476
|
/**
|
|
1476
1477
|
* Function to transform the items passed to the templates.
|
|
1477
1478
|
*/
|
|
@@ -1760,10 +1761,10 @@ declare type HighlightOptions = {
|
|
|
1760
1761
|
|
|
1761
1762
|
declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
1762
1763
|
|
|
1763
|
-
declare type Hit = {
|
|
1764
|
+
declare type Hit<THit extends BaseHit = Record<string, any>> = {
|
|
1764
1765
|
__position: number;
|
|
1765
1766
|
__queryID?: string;
|
|
1766
|
-
} & AlgoliaHit
|
|
1767
|
+
} & AlgoliaHit<THit>;
|
|
1767
1768
|
|
|
1768
1769
|
declare type HitAttributeHighlightResult = {
|
|
1769
1770
|
value: string;
|
|
@@ -1778,13 +1779,16 @@ declare type HitHighlightResult = {
|
|
|
1778
1779
|
[attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
|
|
1779
1780
|
};
|
|
1780
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* @deprecated use Hit[] directly instead
|
|
1784
|
+
*/
|
|
1781
1785
|
declare type Hits = Hit[];
|
|
1782
1786
|
|
|
1783
1787
|
declare const hits: HitsWidget;
|
|
1784
1788
|
|
|
1785
|
-
declare type HitsConnector = Connector<HitsWidgetDescription
|
|
1789
|
+
declare type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
|
|
1786
1790
|
|
|
1787
|
-
declare type HitsConnectorParams = {
|
|
1791
|
+
declare type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
1788
1792
|
/**
|
|
1789
1793
|
* Whether to escape HTML tags from hits string values.
|
|
1790
1794
|
*
|
|
@@ -1794,7 +1798,7 @@ declare type HitsConnectorParams = {
|
|
|
1794
1798
|
/**
|
|
1795
1799
|
* Function to transform the items passed to the templates.
|
|
1796
1800
|
*/
|
|
1797
|
-
transformItems?: TransformItems<Hit
|
|
1801
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
1798
1802
|
};
|
|
1799
1803
|
|
|
1800
1804
|
declare type HitsCSSClasses = Partial<{
|
|
@@ -1923,15 +1927,15 @@ declare type HitsPerPageWidgetParams = {
|
|
|
1923
1927
|
cssClasses?: HitsPerPageCSSClasses;
|
|
1924
1928
|
};
|
|
1925
1929
|
|
|
1926
|
-
declare type HitsRenderState = {
|
|
1930
|
+
declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
1927
1931
|
/**
|
|
1928
1932
|
* The matched hits from Algolia API.
|
|
1929
1933
|
*/
|
|
1930
|
-
hits:
|
|
1934
|
+
hits: Array<Hit<THit>>;
|
|
1931
1935
|
/**
|
|
1932
1936
|
* The response from the Algolia API.
|
|
1933
1937
|
*/
|
|
1934
|
-
results?: SearchResults<Hit
|
|
1938
|
+
results?: SearchResults<Hit<THit>>;
|
|
1935
1939
|
/**
|
|
1936
1940
|
* Sends an event to the Insights middleware.
|
|
1937
1941
|
*/
|
|
@@ -1963,11 +1967,11 @@ declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
|
1963
1967
|
$$widgetType: 'ais.hits';
|
|
1964
1968
|
}, HitsConnectorParams, HitsWidgetParams>;
|
|
1965
1969
|
|
|
1966
|
-
declare type HitsWidgetDescription = {
|
|
1970
|
+
declare type HitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
1967
1971
|
$$type: 'ais.hits';
|
|
1968
|
-
renderState: HitsRenderState
|
|
1972
|
+
renderState: HitsRenderState<THit>;
|
|
1969
1973
|
indexRenderState: {
|
|
1970
|
-
hits: WidgetRenderState<HitsRenderState
|
|
1974
|
+
hits: WidgetRenderState<HitsRenderState<THit>, HitsConnectorParams<THit>>;
|
|
1971
1975
|
};
|
|
1972
1976
|
};
|
|
1973
1977
|
|
|
@@ -2048,18 +2052,18 @@ declare type IndexWidgetParams = {
|
|
|
2048
2052
|
|
|
2049
2053
|
declare const infiniteHits: InfiniteHitsWidget;
|
|
2050
2054
|
|
|
2051
|
-
declare type InfiniteHitsCache = {
|
|
2052
|
-
read: Read
|
|
2053
|
-
write: Write
|
|
2055
|
+
declare type InfiniteHitsCache<THit extends BaseHit = BaseHit> = {
|
|
2056
|
+
read: Read<THit>;
|
|
2057
|
+
write: Write<THit>;
|
|
2054
2058
|
};
|
|
2055
2059
|
|
|
2056
|
-
declare type InfiniteHitsCachedHits = {
|
|
2057
|
-
[page: number]:
|
|
2060
|
+
declare type InfiniteHitsCachedHits<THit extends BaseHit> = {
|
|
2061
|
+
[page: number]: Array<Hit<THit>>;
|
|
2058
2062
|
};
|
|
2059
2063
|
|
|
2060
|
-
declare type InfiniteHitsConnector = Connector<InfiniteHitsWidgetDescription
|
|
2064
|
+
declare type InfiniteHitsConnector<THit extends BaseHit = BaseHit> = Connector<InfiniteHitsWidgetDescription<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2061
2065
|
|
|
2062
|
-
declare type InfiniteHitsConnectorParams = {
|
|
2066
|
+
declare type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
2063
2067
|
/**
|
|
2064
2068
|
* Escapes HTML entities from hits string values.
|
|
2065
2069
|
*
|
|
@@ -2076,13 +2080,13 @@ declare type InfiniteHitsConnectorParams = {
|
|
|
2076
2080
|
* Receives the items, and is called before displaying them.
|
|
2077
2081
|
* Useful for mapping over the items to transform, and remove or reorder them.
|
|
2078
2082
|
*/
|
|
2079
|
-
transformItems?: TransformItems<Hit
|
|
2083
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
2080
2084
|
/**
|
|
2081
2085
|
* Reads and writes hits from/to cache.
|
|
2082
2086
|
* When user comes back to the search page after leaving for product page,
|
|
2083
2087
|
* this helps restore InfiniteHits and its scroll position.
|
|
2084
2088
|
*/
|
|
2085
|
-
cache?: InfiniteHitsCache
|
|
2089
|
+
cache?: InfiniteHitsCache<THit>;
|
|
2086
2090
|
};
|
|
2087
2091
|
|
|
2088
2092
|
declare type InfiniteHitsCSSClasses = Partial<{
|
|
@@ -2120,7 +2124,7 @@ declare type InfiniteHitsCSSClasses = Partial<{
|
|
|
2120
2124
|
disabledLoadMore: string | string[];
|
|
2121
2125
|
}>;
|
|
2122
2126
|
|
|
2123
|
-
declare type InfiniteHitsRenderState = {
|
|
2127
|
+
declare type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
2124
2128
|
/**
|
|
2125
2129
|
* Loads the previous results.
|
|
2126
2130
|
*/
|
|
@@ -2148,15 +2152,15 @@ declare type InfiniteHitsRenderState = {
|
|
|
2148
2152
|
/**
|
|
2149
2153
|
* Hits for the current page
|
|
2150
2154
|
*/
|
|
2151
|
-
currentPageHits:
|
|
2155
|
+
currentPageHits: Array<Hit<THit>>;
|
|
2152
2156
|
/**
|
|
2153
2157
|
* Hits for current and cached pages
|
|
2154
2158
|
*/
|
|
2155
|
-
hits:
|
|
2159
|
+
hits: Array<Hit<THit>>;
|
|
2156
2160
|
/**
|
|
2157
2161
|
* The response from the Algolia API.
|
|
2158
2162
|
*/
|
|
2159
|
-
results?: SearchResults<Hit
|
|
2163
|
+
results?: SearchResults<Hit<THit>>;
|
|
2160
2164
|
};
|
|
2161
2165
|
|
|
2162
2166
|
declare type InfiniteHitsTemplates = Partial<{
|
|
@@ -2186,11 +2190,11 @@ declare type InfiniteHitsWidget = WidgetFactory<InfiniteHitsWidgetDescription &
|
|
|
2186
2190
|
$$widgetType: 'ais.infiniteHits';
|
|
2187
2191
|
}, InfiniteHitsConnectorParams, InfiniteHitsWidgetParams>;
|
|
2188
2192
|
|
|
2189
|
-
declare type InfiniteHitsWidgetDescription = {
|
|
2193
|
+
declare type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
2190
2194
|
$$type: 'ais.infiniteHits';
|
|
2191
|
-
renderState: InfiniteHitsRenderState
|
|
2195
|
+
renderState: InfiniteHitsRenderState<THit>;
|
|
2192
2196
|
indexRenderState: {
|
|
2193
|
-
infiniteHits: WidgetRenderState<InfiniteHitsRenderState
|
|
2197
|
+
infiniteHits: WidgetRenderState<InfiniteHitsRenderState<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2194
2198
|
};
|
|
2195
2199
|
indexUiState: {
|
|
2196
2200
|
page: number;
|
|
@@ -2529,7 +2533,7 @@ declare type MenuConnectorParams = {
|
|
|
2529
2533
|
*
|
|
2530
2534
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
2531
2535
|
*/
|
|
2532
|
-
sortBy?: SortBy<
|
|
2536
|
+
sortBy?: SortBy<SearchResults.HierarchicalFacet>;
|
|
2533
2537
|
/**
|
|
2534
2538
|
* Function to transform the items passed to the templates.
|
|
2535
2539
|
*/
|
|
@@ -3807,9 +3811,9 @@ declare type RatingMenuWidgetParams = {
|
|
|
3807
3811
|
cssClasses?: RatingMenuCSSClasses;
|
|
3808
3812
|
};
|
|
3809
3813
|
|
|
3810
|
-
declare type Read = ({ state, }: {
|
|
3814
|
+
declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
3811
3815
|
state: PlainSearchParameters;
|
|
3812
|
-
}) => InfiniteHitsCachedHits | null;
|
|
3816
|
+
}) => InfiniteHitsCachedHits<THit> | null;
|
|
3813
3817
|
|
|
3814
3818
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
3815
3819
|
|
|
@@ -3873,7 +3877,7 @@ declare type RefinementListConnectorParams = {
|
|
|
3873
3877
|
*
|
|
3874
3878
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
3875
3879
|
*/
|
|
3876
|
-
sortBy?: SortBy<
|
|
3880
|
+
sortBy?: SortBy<SearchResults.FacetValue>;
|
|
3877
3881
|
/**
|
|
3878
3882
|
* Escapes the content of the facet values.
|
|
3879
3883
|
*/
|
|
@@ -4623,7 +4627,7 @@ declare type SnippetOptions = {
|
|
|
4623
4627
|
/**
|
|
4624
4628
|
* Transforms the given items.
|
|
4625
4629
|
*/
|
|
4626
|
-
declare type SortBy<TItem> = ((a: TItem, b: TItem) => number) | Array<'count' | '
|
|
4630
|
+
declare type SortBy<TItem> = ((a: TItem, b: TItem) => number) | Array<SortByDirection<'count' | 'name' | 'isRefined'>>;
|
|
4627
4631
|
|
|
4628
4632
|
/**
|
|
4629
4633
|
* Sort by selector is a widget used for letting the user choose between different
|
|
@@ -4644,6 +4648,8 @@ declare type SortByConnectorParams = {
|
|
|
4644
4648
|
transformItems?: TransformItems<SortByItem>;
|
|
4645
4649
|
};
|
|
4646
4650
|
|
|
4651
|
+
declare type SortByDirection<TCriterion extends string> = TCriterion | `${TCriterion}:asc` | `${TCriterion}:desc`;
|
|
4652
|
+
|
|
4647
4653
|
declare type SortByIndexDefinition = {
|
|
4648
4654
|
/**
|
|
4649
4655
|
* The name of the index to target.
|
|
@@ -5251,9 +5257,9 @@ declare type WidgetType<TWidgetDescription extends WidgetDescription> = TWidgetD
|
|
|
5251
5257
|
|
|
5252
5258
|
declare type WidgetUiStates = PlacesWidgetDescription['indexUiState'];
|
|
5253
5259
|
|
|
5254
|
-
declare type Write = ({ state, hits, }: {
|
|
5260
|
+
declare type Write<THit extends BaseHit> = ({ state, hits, }: {
|
|
5255
5261
|
state: PlainSearchParameters;
|
|
5256
|
-
hits: InfiniteHitsCachedHits
|
|
5262
|
+
hits: InfiniteHitsCachedHits<THit>;
|
|
5257
5263
|
}) => void;
|
|
5258
5264
|
|
|
5259
5265
|
export { }
|
|
@@ -12,8 +12,7 @@ import { default as qs_2 } from 'qs';
|
|
|
12
12
|
import type { SearchParameters } from 'algoliasearch-helper';
|
|
13
13
|
import type { SearchResults } from 'algoliasearch-helper';
|
|
14
14
|
|
|
15
|
-
declare type AlgoliaHit = {
|
|
16
|
-
[attribute: string]: any;
|
|
15
|
+
declare type AlgoliaHit<THit extends BaseHit = Record<string, any>> = {
|
|
17
16
|
objectID: string;
|
|
18
17
|
_highlightResult?: HitHighlightResult;
|
|
19
18
|
_snippetResult?: HitSnippetResult;
|
|
@@ -36,7 +35,7 @@ declare type AlgoliaHit = {
|
|
|
36
35
|
};
|
|
37
36
|
_distinctSeqID?: number;
|
|
38
37
|
_geoLoc?: GeoLoc;
|
|
39
|
-
};
|
|
38
|
+
} & THit;
|
|
40
39
|
|
|
41
40
|
declare const analytics: AnalyticsWidget;
|
|
42
41
|
|
|
@@ -292,6 +291,8 @@ declare type AutocompleteWidgetDescription = {
|
|
|
292
291
|
};
|
|
293
292
|
};
|
|
294
293
|
|
|
294
|
+
declare type BaseHit = Record<string, unknown>;
|
|
295
|
+
|
|
295
296
|
declare type BindEventForHits = BuiltInBindEventForHits & CustomBindEventForHits;
|
|
296
297
|
|
|
297
298
|
declare type Bounds = {
|
|
@@ -734,11 +735,11 @@ declare const connectHits: HitsConnector;
|
|
|
734
735
|
|
|
735
736
|
declare const connectHitsPerPage: HitsPerPageConnector;
|
|
736
737
|
|
|
737
|
-
declare const connectHitsWithInsights: HitsConnector
|
|
738
|
+
declare const connectHitsWithInsights: HitsConnector<BaseHit>;
|
|
738
739
|
|
|
739
740
|
declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
740
741
|
|
|
741
|
-
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector
|
|
742
|
+
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector<BaseHit>;
|
|
742
743
|
|
|
743
744
|
/**
|
|
744
745
|
* **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.
|
|
@@ -1471,7 +1472,7 @@ declare type HierarchicalMenuConnectorParams = {
|
|
|
1471
1472
|
*
|
|
1472
1473
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
1473
1474
|
*/
|
|
1474
|
-
sortBy?: SortBy<
|
|
1475
|
+
sortBy?: SortBy<SearchResults.HierarchicalFacet>;
|
|
1475
1476
|
/**
|
|
1476
1477
|
* Function to transform the items passed to the templates.
|
|
1477
1478
|
*/
|
|
@@ -1760,10 +1761,10 @@ declare type HighlightOptions = {
|
|
|
1760
1761
|
|
|
1761
1762
|
declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
1762
1763
|
|
|
1763
|
-
declare type Hit = {
|
|
1764
|
+
declare type Hit<THit extends BaseHit = Record<string, any>> = {
|
|
1764
1765
|
__position: number;
|
|
1765
1766
|
__queryID?: string;
|
|
1766
|
-
} & AlgoliaHit
|
|
1767
|
+
} & AlgoliaHit<THit>;
|
|
1767
1768
|
|
|
1768
1769
|
declare type HitAttributeHighlightResult = {
|
|
1769
1770
|
value: string;
|
|
@@ -1778,13 +1779,16 @@ declare type HitHighlightResult = {
|
|
|
1778
1779
|
[attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
|
|
1779
1780
|
};
|
|
1780
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* @deprecated use Hit[] directly instead
|
|
1784
|
+
*/
|
|
1781
1785
|
declare type Hits = Hit[];
|
|
1782
1786
|
|
|
1783
1787
|
declare const hits: HitsWidget;
|
|
1784
1788
|
|
|
1785
|
-
declare type HitsConnector = Connector<HitsWidgetDescription
|
|
1789
|
+
declare type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
|
|
1786
1790
|
|
|
1787
|
-
declare type HitsConnectorParams = {
|
|
1791
|
+
declare type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
1788
1792
|
/**
|
|
1789
1793
|
* Whether to escape HTML tags from hits string values.
|
|
1790
1794
|
*
|
|
@@ -1794,7 +1798,7 @@ declare type HitsConnectorParams = {
|
|
|
1794
1798
|
/**
|
|
1795
1799
|
* Function to transform the items passed to the templates.
|
|
1796
1800
|
*/
|
|
1797
|
-
transformItems?: TransformItems<Hit
|
|
1801
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
1798
1802
|
};
|
|
1799
1803
|
|
|
1800
1804
|
declare type HitsCSSClasses = Partial<{
|
|
@@ -1923,15 +1927,15 @@ declare type HitsPerPageWidgetParams = {
|
|
|
1923
1927
|
cssClasses?: HitsPerPageCSSClasses;
|
|
1924
1928
|
};
|
|
1925
1929
|
|
|
1926
|
-
declare type HitsRenderState = {
|
|
1930
|
+
declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
1927
1931
|
/**
|
|
1928
1932
|
* The matched hits from Algolia API.
|
|
1929
1933
|
*/
|
|
1930
|
-
hits:
|
|
1934
|
+
hits: Array<Hit<THit>>;
|
|
1931
1935
|
/**
|
|
1932
1936
|
* The response from the Algolia API.
|
|
1933
1937
|
*/
|
|
1934
|
-
results?: SearchResults<Hit
|
|
1938
|
+
results?: SearchResults<Hit<THit>>;
|
|
1935
1939
|
/**
|
|
1936
1940
|
* Sends an event to the Insights middleware.
|
|
1937
1941
|
*/
|
|
@@ -1963,11 +1967,11 @@ declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
|
1963
1967
|
$$widgetType: 'ais.hits';
|
|
1964
1968
|
}, HitsConnectorParams, HitsWidgetParams>;
|
|
1965
1969
|
|
|
1966
|
-
declare type HitsWidgetDescription = {
|
|
1970
|
+
declare type HitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
1967
1971
|
$$type: 'ais.hits';
|
|
1968
|
-
renderState: HitsRenderState
|
|
1972
|
+
renderState: HitsRenderState<THit>;
|
|
1969
1973
|
indexRenderState: {
|
|
1970
|
-
hits: WidgetRenderState<HitsRenderState
|
|
1974
|
+
hits: WidgetRenderState<HitsRenderState<THit>, HitsConnectorParams<THit>>;
|
|
1971
1975
|
};
|
|
1972
1976
|
};
|
|
1973
1977
|
|
|
@@ -2048,18 +2052,18 @@ declare type IndexWidgetParams = {
|
|
|
2048
2052
|
|
|
2049
2053
|
declare const infiniteHits: InfiniteHitsWidget;
|
|
2050
2054
|
|
|
2051
|
-
declare type InfiniteHitsCache = {
|
|
2052
|
-
read: Read
|
|
2053
|
-
write: Write
|
|
2055
|
+
declare type InfiniteHitsCache<THit extends BaseHit = BaseHit> = {
|
|
2056
|
+
read: Read<THit>;
|
|
2057
|
+
write: Write<THit>;
|
|
2054
2058
|
};
|
|
2055
2059
|
|
|
2056
|
-
declare type InfiniteHitsCachedHits = {
|
|
2057
|
-
[page: number]:
|
|
2060
|
+
declare type InfiniteHitsCachedHits<THit extends BaseHit> = {
|
|
2061
|
+
[page: number]: Array<Hit<THit>>;
|
|
2058
2062
|
};
|
|
2059
2063
|
|
|
2060
|
-
declare type InfiniteHitsConnector = Connector<InfiniteHitsWidgetDescription
|
|
2064
|
+
declare type InfiniteHitsConnector<THit extends BaseHit = BaseHit> = Connector<InfiniteHitsWidgetDescription<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2061
2065
|
|
|
2062
|
-
declare type InfiniteHitsConnectorParams = {
|
|
2066
|
+
declare type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
2063
2067
|
/**
|
|
2064
2068
|
* Escapes HTML entities from hits string values.
|
|
2065
2069
|
*
|
|
@@ -2076,13 +2080,13 @@ declare type InfiniteHitsConnectorParams = {
|
|
|
2076
2080
|
* Receives the items, and is called before displaying them.
|
|
2077
2081
|
* Useful for mapping over the items to transform, and remove or reorder them.
|
|
2078
2082
|
*/
|
|
2079
|
-
transformItems?: TransformItems<Hit
|
|
2083
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
2080
2084
|
/**
|
|
2081
2085
|
* Reads and writes hits from/to cache.
|
|
2082
2086
|
* When user comes back to the search page after leaving for product page,
|
|
2083
2087
|
* this helps restore InfiniteHits and its scroll position.
|
|
2084
2088
|
*/
|
|
2085
|
-
cache?: InfiniteHitsCache
|
|
2089
|
+
cache?: InfiniteHitsCache<THit>;
|
|
2086
2090
|
};
|
|
2087
2091
|
|
|
2088
2092
|
declare type InfiniteHitsCSSClasses = Partial<{
|
|
@@ -2120,7 +2124,7 @@ declare type InfiniteHitsCSSClasses = Partial<{
|
|
|
2120
2124
|
disabledLoadMore: string | string[];
|
|
2121
2125
|
}>;
|
|
2122
2126
|
|
|
2123
|
-
declare type InfiniteHitsRenderState = {
|
|
2127
|
+
declare type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
2124
2128
|
/**
|
|
2125
2129
|
* Loads the previous results.
|
|
2126
2130
|
*/
|
|
@@ -2148,15 +2152,15 @@ declare type InfiniteHitsRenderState = {
|
|
|
2148
2152
|
/**
|
|
2149
2153
|
* Hits for the current page
|
|
2150
2154
|
*/
|
|
2151
|
-
currentPageHits:
|
|
2155
|
+
currentPageHits: Array<Hit<THit>>;
|
|
2152
2156
|
/**
|
|
2153
2157
|
* Hits for current and cached pages
|
|
2154
2158
|
*/
|
|
2155
|
-
hits:
|
|
2159
|
+
hits: Array<Hit<THit>>;
|
|
2156
2160
|
/**
|
|
2157
2161
|
* The response from the Algolia API.
|
|
2158
2162
|
*/
|
|
2159
|
-
results?: SearchResults<Hit
|
|
2163
|
+
results?: SearchResults<Hit<THit>>;
|
|
2160
2164
|
};
|
|
2161
2165
|
|
|
2162
2166
|
declare type InfiniteHitsTemplates = Partial<{
|
|
@@ -2186,11 +2190,11 @@ declare type InfiniteHitsWidget = WidgetFactory<InfiniteHitsWidgetDescription &
|
|
|
2186
2190
|
$$widgetType: 'ais.infiniteHits';
|
|
2187
2191
|
}, InfiniteHitsConnectorParams, InfiniteHitsWidgetParams>;
|
|
2188
2192
|
|
|
2189
|
-
declare type InfiniteHitsWidgetDescription = {
|
|
2193
|
+
declare type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
2190
2194
|
$$type: 'ais.infiniteHits';
|
|
2191
|
-
renderState: InfiniteHitsRenderState
|
|
2195
|
+
renderState: InfiniteHitsRenderState<THit>;
|
|
2192
2196
|
indexRenderState: {
|
|
2193
|
-
infiniteHits: WidgetRenderState<InfiniteHitsRenderState
|
|
2197
|
+
infiniteHits: WidgetRenderState<InfiniteHitsRenderState<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2194
2198
|
};
|
|
2195
2199
|
indexUiState: {
|
|
2196
2200
|
page: number;
|
|
@@ -2529,7 +2533,7 @@ declare type MenuConnectorParams = {
|
|
|
2529
2533
|
*
|
|
2530
2534
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
2531
2535
|
*/
|
|
2532
|
-
sortBy?: SortBy<
|
|
2536
|
+
sortBy?: SortBy<SearchResults.HierarchicalFacet>;
|
|
2533
2537
|
/**
|
|
2534
2538
|
* Function to transform the items passed to the templates.
|
|
2535
2539
|
*/
|
|
@@ -3807,9 +3811,9 @@ declare type RatingMenuWidgetParams = {
|
|
|
3807
3811
|
cssClasses?: RatingMenuCSSClasses;
|
|
3808
3812
|
};
|
|
3809
3813
|
|
|
3810
|
-
declare type Read = ({ state, }: {
|
|
3814
|
+
declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
3811
3815
|
state: PlainSearchParameters;
|
|
3812
|
-
}) => InfiniteHitsCachedHits | null;
|
|
3816
|
+
}) => InfiniteHitsCachedHits<THit> | null;
|
|
3813
3817
|
|
|
3814
3818
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
3815
3819
|
|
|
@@ -3873,7 +3877,7 @@ declare type RefinementListConnectorParams = {
|
|
|
3873
3877
|
*
|
|
3874
3878
|
* If a facetOrdering is set in the index settings, it is used when sortBy isn't passed
|
|
3875
3879
|
*/
|
|
3876
|
-
sortBy?: SortBy<
|
|
3880
|
+
sortBy?: SortBy<SearchResults.FacetValue>;
|
|
3877
3881
|
/**
|
|
3878
3882
|
* Escapes the content of the facet values.
|
|
3879
3883
|
*/
|
|
@@ -4623,7 +4627,7 @@ declare type SnippetOptions = {
|
|
|
4623
4627
|
/**
|
|
4624
4628
|
* Transforms the given items.
|
|
4625
4629
|
*/
|
|
4626
|
-
declare type SortBy<TItem> = ((a: TItem, b: TItem) => number) | Array<'count' | '
|
|
4630
|
+
declare type SortBy<TItem> = ((a: TItem, b: TItem) => number) | Array<SortByDirection<'count' | 'name' | 'isRefined'>>;
|
|
4627
4631
|
|
|
4628
4632
|
/**
|
|
4629
4633
|
* Sort by selector is a widget used for letting the user choose between different
|
|
@@ -4644,6 +4648,8 @@ declare type SortByConnectorParams = {
|
|
|
4644
4648
|
transformItems?: TransformItems<SortByItem>;
|
|
4645
4649
|
};
|
|
4646
4650
|
|
|
4651
|
+
declare type SortByDirection<TCriterion extends string> = TCriterion | `${TCriterion}:asc` | `${TCriterion}:desc`;
|
|
4652
|
+
|
|
4647
4653
|
declare type SortByIndexDefinition = {
|
|
4648
4654
|
/**
|
|
4649
4655
|
* The name of the index to target.
|
|
@@ -5251,9 +5257,9 @@ declare type WidgetType<TWidgetDescription extends WidgetDescription> = TWidgetD
|
|
|
5251
5257
|
|
|
5252
5258
|
declare type WidgetUiStates = PlacesWidgetDescription['indexUiState'];
|
|
5253
5259
|
|
|
5254
|
-
declare type Write = ({ state, hits, }: {
|
|
5260
|
+
declare type Write<THit extends BaseHit> = ({ state, hits, }: {
|
|
5255
5261
|
state: PlainSearchParameters;
|
|
5256
|
-
hits: InfiniteHitsCachedHits
|
|
5262
|
+
hits: InfiniteHitsCachedHits<THit>;
|
|
5257
5263
|
}) => void;
|
|
5258
5264
|
|
|
5259
5265
|
export { }
|