instantsearch.js 4.38.0 → 4.39.1
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/routers/history.js +44 -29
- package/cjs/lib/version.js +1 -1
- package/cjs/middlewares/createMetadataMiddleware.js +3 -1
- package/dist/instantsearch.development.d.ts +51 -36
- package/dist/instantsearch.development.js +53 -35
- package/dist/instantsearch.development.js.map +1 -1
- package/dist/instantsearch.production.d.ts +51 -36
- package/dist/instantsearch.production.min.d.ts +51 -36
- 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/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/lib/routers/history.d.ts +11 -0
- package/es/lib/routers/history.js +44 -29
- 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/middlewares/createMetadataMiddleware.js +3 -1
- package/es/types/results.d.ts +8 -5
- package/package.json +4 -4
|
@@ -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 = {
|
|
@@ -466,6 +467,17 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
466
467
|
* It needs to avoid pushing state to history in case of back/forward in browser
|
|
467
468
|
*/
|
|
468
469
|
private shouldPushState;
|
|
470
|
+
/**
|
|
471
|
+
* Indicates whether the history router is disposed or not.
|
|
472
|
+
*/
|
|
473
|
+
private isDisposed;
|
|
474
|
+
/**
|
|
475
|
+
* Indicates the window.history.length before the last call to
|
|
476
|
+
* window.history.pushState (called in `write`).
|
|
477
|
+
* It allows to determine if a `pushState` has been triggered elsewhere,
|
|
478
|
+
* and thus to prevent the `write` method from calling `pushState`.
|
|
479
|
+
*/
|
|
480
|
+
private latestAcknowledgedHistory;
|
|
469
481
|
/**
|
|
470
482
|
* Initializes a new storage provider that syncs the search state to the URL
|
|
471
483
|
* using web APIs (`window.location.pushState` and `onpopstate` event).
|
|
@@ -723,11 +735,11 @@ declare const connectHits: HitsConnector;
|
|
|
723
735
|
|
|
724
736
|
declare const connectHitsPerPage: HitsPerPageConnector;
|
|
725
737
|
|
|
726
|
-
declare const connectHitsWithInsights: HitsConnector
|
|
738
|
+
declare const connectHitsWithInsights: HitsConnector<BaseHit>;
|
|
727
739
|
|
|
728
740
|
declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
729
741
|
|
|
730
|
-
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector
|
|
742
|
+
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector<BaseHit>;
|
|
731
743
|
|
|
732
744
|
/**
|
|
733
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.
|
|
@@ -1749,10 +1761,10 @@ declare type HighlightOptions = {
|
|
|
1749
1761
|
|
|
1750
1762
|
declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
1751
1763
|
|
|
1752
|
-
declare type Hit = {
|
|
1764
|
+
declare type Hit<THit extends BaseHit = Record<string, any>> = {
|
|
1753
1765
|
__position: number;
|
|
1754
1766
|
__queryID?: string;
|
|
1755
|
-
} & AlgoliaHit
|
|
1767
|
+
} & AlgoliaHit<THit>;
|
|
1756
1768
|
|
|
1757
1769
|
declare type HitAttributeHighlightResult = {
|
|
1758
1770
|
value: string;
|
|
@@ -1767,13 +1779,16 @@ declare type HitHighlightResult = {
|
|
|
1767
1779
|
[attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
|
|
1768
1780
|
};
|
|
1769
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* @deprecated use Hit[] directly instead
|
|
1784
|
+
*/
|
|
1770
1785
|
declare type Hits = Hit[];
|
|
1771
1786
|
|
|
1772
1787
|
declare const hits: HitsWidget;
|
|
1773
1788
|
|
|
1774
|
-
declare type HitsConnector = Connector<HitsWidgetDescription
|
|
1789
|
+
declare type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
|
|
1775
1790
|
|
|
1776
|
-
declare type HitsConnectorParams = {
|
|
1791
|
+
declare type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
1777
1792
|
/**
|
|
1778
1793
|
* Whether to escape HTML tags from hits string values.
|
|
1779
1794
|
*
|
|
@@ -1783,7 +1798,7 @@ declare type HitsConnectorParams = {
|
|
|
1783
1798
|
/**
|
|
1784
1799
|
* Function to transform the items passed to the templates.
|
|
1785
1800
|
*/
|
|
1786
|
-
transformItems?: TransformItems<Hit
|
|
1801
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
1787
1802
|
};
|
|
1788
1803
|
|
|
1789
1804
|
declare type HitsCSSClasses = Partial<{
|
|
@@ -1912,15 +1927,15 @@ declare type HitsPerPageWidgetParams = {
|
|
|
1912
1927
|
cssClasses?: HitsPerPageCSSClasses;
|
|
1913
1928
|
};
|
|
1914
1929
|
|
|
1915
|
-
declare type HitsRenderState = {
|
|
1930
|
+
declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
1916
1931
|
/**
|
|
1917
1932
|
* The matched hits from Algolia API.
|
|
1918
1933
|
*/
|
|
1919
|
-
hits:
|
|
1934
|
+
hits: Array<Hit<THit>>;
|
|
1920
1935
|
/**
|
|
1921
1936
|
* The response from the Algolia API.
|
|
1922
1937
|
*/
|
|
1923
|
-
results?: SearchResults<Hit
|
|
1938
|
+
results?: SearchResults<Hit<THit>>;
|
|
1924
1939
|
/**
|
|
1925
1940
|
* Sends an event to the Insights middleware.
|
|
1926
1941
|
*/
|
|
@@ -1952,11 +1967,11 @@ declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
|
1952
1967
|
$$widgetType: 'ais.hits';
|
|
1953
1968
|
}, HitsConnectorParams, HitsWidgetParams>;
|
|
1954
1969
|
|
|
1955
|
-
declare type HitsWidgetDescription = {
|
|
1970
|
+
declare type HitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
1956
1971
|
$$type: 'ais.hits';
|
|
1957
|
-
renderState: HitsRenderState
|
|
1972
|
+
renderState: HitsRenderState<THit>;
|
|
1958
1973
|
indexRenderState: {
|
|
1959
|
-
hits: WidgetRenderState<HitsRenderState
|
|
1974
|
+
hits: WidgetRenderState<HitsRenderState<THit>, HitsConnectorParams<THit>>;
|
|
1960
1975
|
};
|
|
1961
1976
|
};
|
|
1962
1977
|
|
|
@@ -2037,18 +2052,18 @@ declare type IndexWidgetParams = {
|
|
|
2037
2052
|
|
|
2038
2053
|
declare const infiniteHits: InfiniteHitsWidget;
|
|
2039
2054
|
|
|
2040
|
-
declare type InfiniteHitsCache = {
|
|
2041
|
-
read: Read
|
|
2042
|
-
write: Write
|
|
2055
|
+
declare type InfiniteHitsCache<THit extends BaseHit = BaseHit> = {
|
|
2056
|
+
read: Read<THit>;
|
|
2057
|
+
write: Write<THit>;
|
|
2043
2058
|
};
|
|
2044
2059
|
|
|
2045
|
-
declare type InfiniteHitsCachedHits = {
|
|
2046
|
-
[page: number]:
|
|
2060
|
+
declare type InfiniteHitsCachedHits<THit extends BaseHit> = {
|
|
2061
|
+
[page: number]: Array<Hit<THit>>;
|
|
2047
2062
|
};
|
|
2048
2063
|
|
|
2049
|
-
declare type InfiniteHitsConnector = Connector<InfiniteHitsWidgetDescription
|
|
2064
|
+
declare type InfiniteHitsConnector<THit extends BaseHit = BaseHit> = Connector<InfiniteHitsWidgetDescription<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2050
2065
|
|
|
2051
|
-
declare type InfiniteHitsConnectorParams = {
|
|
2066
|
+
declare type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
2052
2067
|
/**
|
|
2053
2068
|
* Escapes HTML entities from hits string values.
|
|
2054
2069
|
*
|
|
@@ -2065,13 +2080,13 @@ declare type InfiniteHitsConnectorParams = {
|
|
|
2065
2080
|
* Receives the items, and is called before displaying them.
|
|
2066
2081
|
* Useful for mapping over the items to transform, and remove or reorder them.
|
|
2067
2082
|
*/
|
|
2068
|
-
transformItems?: TransformItems<Hit
|
|
2083
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
2069
2084
|
/**
|
|
2070
2085
|
* Reads and writes hits from/to cache.
|
|
2071
2086
|
* When user comes back to the search page after leaving for product page,
|
|
2072
2087
|
* this helps restore InfiniteHits and its scroll position.
|
|
2073
2088
|
*/
|
|
2074
|
-
cache?: InfiniteHitsCache
|
|
2089
|
+
cache?: InfiniteHitsCache<THit>;
|
|
2075
2090
|
};
|
|
2076
2091
|
|
|
2077
2092
|
declare type InfiniteHitsCSSClasses = Partial<{
|
|
@@ -2109,7 +2124,7 @@ declare type InfiniteHitsCSSClasses = Partial<{
|
|
|
2109
2124
|
disabledLoadMore: string | string[];
|
|
2110
2125
|
}>;
|
|
2111
2126
|
|
|
2112
|
-
declare type InfiniteHitsRenderState = {
|
|
2127
|
+
declare type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
2113
2128
|
/**
|
|
2114
2129
|
* Loads the previous results.
|
|
2115
2130
|
*/
|
|
@@ -2137,15 +2152,15 @@ declare type InfiniteHitsRenderState = {
|
|
|
2137
2152
|
/**
|
|
2138
2153
|
* Hits for the current page
|
|
2139
2154
|
*/
|
|
2140
|
-
currentPageHits:
|
|
2155
|
+
currentPageHits: Array<Hit<THit>>;
|
|
2141
2156
|
/**
|
|
2142
2157
|
* Hits for current and cached pages
|
|
2143
2158
|
*/
|
|
2144
|
-
hits:
|
|
2159
|
+
hits: Array<Hit<THit>>;
|
|
2145
2160
|
/**
|
|
2146
2161
|
* The response from the Algolia API.
|
|
2147
2162
|
*/
|
|
2148
|
-
results?: SearchResults<Hit
|
|
2163
|
+
results?: SearchResults<Hit<THit>>;
|
|
2149
2164
|
};
|
|
2150
2165
|
|
|
2151
2166
|
declare type InfiniteHitsTemplates = Partial<{
|
|
@@ -2175,11 +2190,11 @@ declare type InfiniteHitsWidget = WidgetFactory<InfiniteHitsWidgetDescription &
|
|
|
2175
2190
|
$$widgetType: 'ais.infiniteHits';
|
|
2176
2191
|
}, InfiniteHitsConnectorParams, InfiniteHitsWidgetParams>;
|
|
2177
2192
|
|
|
2178
|
-
declare type InfiniteHitsWidgetDescription = {
|
|
2193
|
+
declare type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
2179
2194
|
$$type: 'ais.infiniteHits';
|
|
2180
|
-
renderState: InfiniteHitsRenderState
|
|
2195
|
+
renderState: InfiniteHitsRenderState<THit>;
|
|
2181
2196
|
indexRenderState: {
|
|
2182
|
-
infiniteHits: WidgetRenderState<InfiniteHitsRenderState
|
|
2197
|
+
infiniteHits: WidgetRenderState<InfiniteHitsRenderState<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2183
2198
|
};
|
|
2184
2199
|
indexUiState: {
|
|
2185
2200
|
page: number;
|
|
@@ -3796,9 +3811,9 @@ declare type RatingMenuWidgetParams = {
|
|
|
3796
3811
|
cssClasses?: RatingMenuCSSClasses;
|
|
3797
3812
|
};
|
|
3798
3813
|
|
|
3799
|
-
declare type Read = ({ state, }: {
|
|
3814
|
+
declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
3800
3815
|
state: PlainSearchParameters;
|
|
3801
|
-
}) => InfiniteHitsCachedHits | null;
|
|
3816
|
+
}) => InfiniteHitsCachedHits<THit> | null;
|
|
3802
3817
|
|
|
3803
3818
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
3804
3819
|
|
|
@@ -5240,9 +5255,9 @@ declare type WidgetType<TWidgetDescription extends WidgetDescription> = TWidgetD
|
|
|
5240
5255
|
|
|
5241
5256
|
declare type WidgetUiStates = PlacesWidgetDescription['indexUiState'];
|
|
5242
5257
|
|
|
5243
|
-
declare type Write = ({ state, hits, }: {
|
|
5258
|
+
declare type Write<THit extends BaseHit> = ({ state, hits, }: {
|
|
5244
5259
|
state: PlainSearchParameters;
|
|
5245
|
-
hits: InfiniteHitsCachedHits
|
|
5260
|
+
hits: InfiniteHitsCachedHits<THit>;
|
|
5246
5261
|
}) => void;
|
|
5247
5262
|
|
|
5248
5263
|
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 = {
|
|
@@ -466,6 +467,17 @@ declare class BrowserHistory<TRouteState> implements Router<TRouteState> {
|
|
|
466
467
|
* It needs to avoid pushing state to history in case of back/forward in browser
|
|
467
468
|
*/
|
|
468
469
|
private shouldPushState;
|
|
470
|
+
/**
|
|
471
|
+
* Indicates whether the history router is disposed or not.
|
|
472
|
+
*/
|
|
473
|
+
private isDisposed;
|
|
474
|
+
/**
|
|
475
|
+
* Indicates the window.history.length before the last call to
|
|
476
|
+
* window.history.pushState (called in `write`).
|
|
477
|
+
* It allows to determine if a `pushState` has been triggered elsewhere,
|
|
478
|
+
* and thus to prevent the `write` method from calling `pushState`.
|
|
479
|
+
*/
|
|
480
|
+
private latestAcknowledgedHistory;
|
|
469
481
|
/**
|
|
470
482
|
* Initializes a new storage provider that syncs the search state to the URL
|
|
471
483
|
* using web APIs (`window.location.pushState` and `onpopstate` event).
|
|
@@ -723,11 +735,11 @@ declare const connectHits: HitsConnector;
|
|
|
723
735
|
|
|
724
736
|
declare const connectHitsPerPage: HitsPerPageConnector;
|
|
725
737
|
|
|
726
|
-
declare const connectHitsWithInsights: HitsConnector
|
|
738
|
+
declare const connectHitsWithInsights: HitsConnector<BaseHit>;
|
|
727
739
|
|
|
728
740
|
declare const connectInfiniteHits: InfiniteHitsConnector;
|
|
729
741
|
|
|
730
|
-
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector
|
|
742
|
+
declare const connectInfiniteHitsWithInsights: InfiniteHitsConnector<BaseHit>;
|
|
731
743
|
|
|
732
744
|
/**
|
|
733
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.
|
|
@@ -1749,10 +1761,10 @@ declare type HighlightOptions = {
|
|
|
1749
1761
|
|
|
1750
1762
|
declare function historyRouter<TRouteState = UiState>({ createURL, parseURL, writeDelay, windowTitle, getLocation, }?: Partial<BrowserHistoryArgs<TRouteState>>): BrowserHistory<TRouteState>;
|
|
1751
1763
|
|
|
1752
|
-
declare type Hit = {
|
|
1764
|
+
declare type Hit<THit extends BaseHit = Record<string, any>> = {
|
|
1753
1765
|
__position: number;
|
|
1754
1766
|
__queryID?: string;
|
|
1755
|
-
} & AlgoliaHit
|
|
1767
|
+
} & AlgoliaHit<THit>;
|
|
1756
1768
|
|
|
1757
1769
|
declare type HitAttributeHighlightResult = {
|
|
1758
1770
|
value: string;
|
|
@@ -1767,13 +1779,16 @@ declare type HitHighlightResult = {
|
|
|
1767
1779
|
[attribute: string]: HitAttributeHighlightResult | HitAttributeHighlightResult[] | HitHighlightResult[] | HitHighlightResult;
|
|
1768
1780
|
};
|
|
1769
1781
|
|
|
1782
|
+
/**
|
|
1783
|
+
* @deprecated use Hit[] directly instead
|
|
1784
|
+
*/
|
|
1770
1785
|
declare type Hits = Hit[];
|
|
1771
1786
|
|
|
1772
1787
|
declare const hits: HitsWidget;
|
|
1773
1788
|
|
|
1774
|
-
declare type HitsConnector = Connector<HitsWidgetDescription
|
|
1789
|
+
declare type HitsConnector<THit extends BaseHit = BaseHit> = Connector<HitsWidgetDescription<THit>, HitsConnectorParams<THit>>;
|
|
1775
1790
|
|
|
1776
|
-
declare type HitsConnectorParams = {
|
|
1791
|
+
declare type HitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
1777
1792
|
/**
|
|
1778
1793
|
* Whether to escape HTML tags from hits string values.
|
|
1779
1794
|
*
|
|
@@ -1783,7 +1798,7 @@ declare type HitsConnectorParams = {
|
|
|
1783
1798
|
/**
|
|
1784
1799
|
* Function to transform the items passed to the templates.
|
|
1785
1800
|
*/
|
|
1786
|
-
transformItems?: TransformItems<Hit
|
|
1801
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
1787
1802
|
};
|
|
1788
1803
|
|
|
1789
1804
|
declare type HitsCSSClasses = Partial<{
|
|
@@ -1912,15 +1927,15 @@ declare type HitsPerPageWidgetParams = {
|
|
|
1912
1927
|
cssClasses?: HitsPerPageCSSClasses;
|
|
1913
1928
|
};
|
|
1914
1929
|
|
|
1915
|
-
declare type HitsRenderState = {
|
|
1930
|
+
declare type HitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
1916
1931
|
/**
|
|
1917
1932
|
* The matched hits from Algolia API.
|
|
1918
1933
|
*/
|
|
1919
|
-
hits:
|
|
1934
|
+
hits: Array<Hit<THit>>;
|
|
1920
1935
|
/**
|
|
1921
1936
|
* The response from the Algolia API.
|
|
1922
1937
|
*/
|
|
1923
|
-
results?: SearchResults<Hit
|
|
1938
|
+
results?: SearchResults<Hit<THit>>;
|
|
1924
1939
|
/**
|
|
1925
1940
|
* Sends an event to the Insights middleware.
|
|
1926
1941
|
*/
|
|
@@ -1952,11 +1967,11 @@ declare type HitsWidget = WidgetFactory<HitsWidgetDescription & {
|
|
|
1952
1967
|
$$widgetType: 'ais.hits';
|
|
1953
1968
|
}, HitsConnectorParams, HitsWidgetParams>;
|
|
1954
1969
|
|
|
1955
|
-
declare type HitsWidgetDescription = {
|
|
1970
|
+
declare type HitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
1956
1971
|
$$type: 'ais.hits';
|
|
1957
|
-
renderState: HitsRenderState
|
|
1972
|
+
renderState: HitsRenderState<THit>;
|
|
1958
1973
|
indexRenderState: {
|
|
1959
|
-
hits: WidgetRenderState<HitsRenderState
|
|
1974
|
+
hits: WidgetRenderState<HitsRenderState<THit>, HitsConnectorParams<THit>>;
|
|
1960
1975
|
};
|
|
1961
1976
|
};
|
|
1962
1977
|
|
|
@@ -2037,18 +2052,18 @@ declare type IndexWidgetParams = {
|
|
|
2037
2052
|
|
|
2038
2053
|
declare const infiniteHits: InfiniteHitsWidget;
|
|
2039
2054
|
|
|
2040
|
-
declare type InfiniteHitsCache = {
|
|
2041
|
-
read: Read
|
|
2042
|
-
write: Write
|
|
2055
|
+
declare type InfiniteHitsCache<THit extends BaseHit = BaseHit> = {
|
|
2056
|
+
read: Read<THit>;
|
|
2057
|
+
write: Write<THit>;
|
|
2043
2058
|
};
|
|
2044
2059
|
|
|
2045
|
-
declare type InfiniteHitsCachedHits = {
|
|
2046
|
-
[page: number]:
|
|
2060
|
+
declare type InfiniteHitsCachedHits<THit extends BaseHit> = {
|
|
2061
|
+
[page: number]: Array<Hit<THit>>;
|
|
2047
2062
|
};
|
|
2048
2063
|
|
|
2049
|
-
declare type InfiniteHitsConnector = Connector<InfiniteHitsWidgetDescription
|
|
2064
|
+
declare type InfiniteHitsConnector<THit extends BaseHit = BaseHit> = Connector<InfiniteHitsWidgetDescription<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2050
2065
|
|
|
2051
|
-
declare type InfiniteHitsConnectorParams = {
|
|
2066
|
+
declare type InfiniteHitsConnectorParams<THit extends BaseHit = BaseHit> = {
|
|
2052
2067
|
/**
|
|
2053
2068
|
* Escapes HTML entities from hits string values.
|
|
2054
2069
|
*
|
|
@@ -2065,13 +2080,13 @@ declare type InfiniteHitsConnectorParams = {
|
|
|
2065
2080
|
* Receives the items, and is called before displaying them.
|
|
2066
2081
|
* Useful for mapping over the items to transform, and remove or reorder them.
|
|
2067
2082
|
*/
|
|
2068
|
-
transformItems?: TransformItems<Hit
|
|
2083
|
+
transformItems?: TransformItems<Hit<THit>>;
|
|
2069
2084
|
/**
|
|
2070
2085
|
* Reads and writes hits from/to cache.
|
|
2071
2086
|
* When user comes back to the search page after leaving for product page,
|
|
2072
2087
|
* this helps restore InfiniteHits and its scroll position.
|
|
2073
2088
|
*/
|
|
2074
|
-
cache?: InfiniteHitsCache
|
|
2089
|
+
cache?: InfiniteHitsCache<THit>;
|
|
2075
2090
|
};
|
|
2076
2091
|
|
|
2077
2092
|
declare type InfiniteHitsCSSClasses = Partial<{
|
|
@@ -2109,7 +2124,7 @@ declare type InfiniteHitsCSSClasses = Partial<{
|
|
|
2109
2124
|
disabledLoadMore: string | string[];
|
|
2110
2125
|
}>;
|
|
2111
2126
|
|
|
2112
|
-
declare type InfiniteHitsRenderState = {
|
|
2127
|
+
declare type InfiniteHitsRenderState<THit extends BaseHit = BaseHit> = {
|
|
2113
2128
|
/**
|
|
2114
2129
|
* Loads the previous results.
|
|
2115
2130
|
*/
|
|
@@ -2137,15 +2152,15 @@ declare type InfiniteHitsRenderState = {
|
|
|
2137
2152
|
/**
|
|
2138
2153
|
* Hits for the current page
|
|
2139
2154
|
*/
|
|
2140
|
-
currentPageHits:
|
|
2155
|
+
currentPageHits: Array<Hit<THit>>;
|
|
2141
2156
|
/**
|
|
2142
2157
|
* Hits for current and cached pages
|
|
2143
2158
|
*/
|
|
2144
|
-
hits:
|
|
2159
|
+
hits: Array<Hit<THit>>;
|
|
2145
2160
|
/**
|
|
2146
2161
|
* The response from the Algolia API.
|
|
2147
2162
|
*/
|
|
2148
|
-
results?: SearchResults<Hit
|
|
2163
|
+
results?: SearchResults<Hit<THit>>;
|
|
2149
2164
|
};
|
|
2150
2165
|
|
|
2151
2166
|
declare type InfiniteHitsTemplates = Partial<{
|
|
@@ -2175,11 +2190,11 @@ declare type InfiniteHitsWidget = WidgetFactory<InfiniteHitsWidgetDescription &
|
|
|
2175
2190
|
$$widgetType: 'ais.infiniteHits';
|
|
2176
2191
|
}, InfiniteHitsConnectorParams, InfiniteHitsWidgetParams>;
|
|
2177
2192
|
|
|
2178
|
-
declare type InfiniteHitsWidgetDescription = {
|
|
2193
|
+
declare type InfiniteHitsWidgetDescription<THit extends BaseHit = BaseHit> = {
|
|
2179
2194
|
$$type: 'ais.infiniteHits';
|
|
2180
|
-
renderState: InfiniteHitsRenderState
|
|
2195
|
+
renderState: InfiniteHitsRenderState<THit>;
|
|
2181
2196
|
indexRenderState: {
|
|
2182
|
-
infiniteHits: WidgetRenderState<InfiniteHitsRenderState
|
|
2197
|
+
infiniteHits: WidgetRenderState<InfiniteHitsRenderState<THit>, InfiniteHitsConnectorParams<THit>>;
|
|
2183
2198
|
};
|
|
2184
2199
|
indexUiState: {
|
|
2185
2200
|
page: number;
|
|
@@ -3796,9 +3811,9 @@ declare type RatingMenuWidgetParams = {
|
|
|
3796
3811
|
cssClasses?: RatingMenuCSSClasses;
|
|
3797
3812
|
};
|
|
3798
3813
|
|
|
3799
|
-
declare type Read = ({ state, }: {
|
|
3814
|
+
declare type Read<THit extends BaseHit> = ({ state, }: {
|
|
3800
3815
|
state: PlainSearchParameters;
|
|
3801
|
-
}) => InfiniteHitsCachedHits | null;
|
|
3816
|
+
}) => InfiniteHitsCachedHits<THit> | null;
|
|
3802
3817
|
|
|
3803
3818
|
declare type ReconfigurableOptions = Places.ReconfigurableOptions;
|
|
3804
3819
|
|
|
@@ -5240,9 +5255,9 @@ declare type WidgetType<TWidgetDescription extends WidgetDescription> = TWidgetD
|
|
|
5240
5255
|
|
|
5241
5256
|
declare type WidgetUiStates = PlacesWidgetDescription['indexUiState'];
|
|
5242
5257
|
|
|
5243
|
-
declare type Write = ({ state, hits, }: {
|
|
5258
|
+
declare type Write<THit extends BaseHit> = ({ state, hits, }: {
|
|
5244
5259
|
state: PlainSearchParameters;
|
|
5245
|
-
hits: InfiniteHitsCachedHits
|
|
5260
|
+
hits: InfiniteHitsCachedHits<THit>;
|
|
5246
5261
|
}) => void;
|
|
5247
5262
|
|
|
5248
5263
|
export { }
|